Debugging with RenderDoc, I found that the problem may occur in the "draw" function of the "QRhiCommandBuffer" class.
In the original code, I called the "draw" function twice, namely:
cb->draw(6, 1, 0, 0);
cb->draw(3, 1, 6, 1);
I intend to specify the "instanceCount", and the most important parameter - "firstInstance" (the "firstInstance" in the first call is 0, and 1 in the second) for each rendering. Through RenderDoc's debugging (as shown in the figure below), I found that these two calls correspond to two "glDrawArray" function events. The vertex number counts are 6 and 3, respectively, consistent with the numbers in my code, but "glDrawArrays" cannot specify instance ID.
[image: 3fdfccc2-f30e-450e-afaf-6b203ac745a3.png]
Furthermore, I changed the two "draw" function calls to one but changed the "instanceCount" to 2(draw two rectangle instances), and the firstInstance started from 0:
cb->draw(6, 2, 0, 0);
This time, the "draw" function corresponds to a "glDrawArraysInstanced" function event in RenderDoc, and the two graphics can use different object matrices.
[image: c8968a62-361d-40e6-be47-8ef57cd6b8bb.png]
Two rectangle instances with different model matrixes
[image: e48dd912-2538-4e31-89eb-313b306e5601.png]
So, It seems that when you want to draw multiple instances using the draw function, the parameter "firstInstance" should start from 0; the draw function can work adequately; is this a feature or a bug on the Windows platform?
I noticed the note "firstInstance may not be supported when QRhi::BaseInstance feature is reported as not supported..." but I have checked the "QRhi::BaseInstance" feature in my platform, and it's said supported.