0
\$\begingroup\$

The background of the question is, does it make sense to introduce an if case when drawing a mesh for whether there is instancing or not?

This is using DirectX 11 with SharpDX in the Stride game engine:

Pseudo-code:

if (mesh.InstanceCount > 1)
    commandList.DrawInstanced(mesh.DrawCount, mesh.InstanceCount);
else
    commandList.Draw(mesh.DrawCount);

Or is it equivalent to just calling DrawInstanced() in any case?

\$\endgroup\$
1
  • 3
    \$\begingroup\$ This sounds like a question you can answer faster for yourself by trying both ways for a large number of objects and profiling the result: do you get a measurable difference on your target hardware? This will give you empirical proof — much more reliable than hearsay from a stranger on the Internet! \$\endgroup\$
    – DMGregory
    Aug 6, 2022 at 12:10

1 Answer 1

2
\$\begingroup\$

While you can bench this yourself, it may be worth noting that in the new APIs (Vulkan, D3D12), there are no non-instanced draw calls. Every draw call is instanced, and you specify a number of instances of 1 if you require non-instanced drawing.

This suggests that at a hardware or driver level, and with sufficiently modern components, there is no difference. With older components it may still be worth implementing a dedicated non-instanced path.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .