Magic function called DrawIndexedInstancedIndirect

Started by
4 comments, last by MJP 11 years, 2 months ago

Hello,

I am trying to get more information about this function and how to use it.

From very few information, i found on the internet, i should be able to pass some parameters.

In my case, i would like to say, i want to render INSTANCES with index 5 to 20, 25 to 65 from one buffer.

Is it possible with this function ?

Thank you very much.

DirectX 11, C++

Advertisement

It is not magic. It executes a DrawIndexedInstanced call, but with the arguments coming from a buffer instead of being passed in. The buffer should contain the same arguments passed to DrawIndexedInstanced, in the same order. The easiest way to do it is with a structured buffer that uses this as its struct:

struct DrawArgs
{
   uint IndexCountPerInstance;
   uint InstanceCount;
   uint StartIndexLocation;
   int BaseVertexLocation;
   uint StartInstanceLocation;
};

Thank you :)

How about performace ? is it better to use DrawIndexedInstancedIndirect or call DrawIndexedInstanced X times ?

I don't know how DrawIndexedInstancedIndirect works internaly, but i thought, i just pass these buffers and GPU will do that instead this function calls DrawIndexedInstanced several times.

DirectX 11, C++

The intent of the function is to allow using GPU generated data to control the execution of the draw call. The CPU still calls the function, but the args reside in a buffer which can be controlled by the GPU (presumably through the Compute Shader). So it would be hard to say which one is more performant, but I would guess that the non-indirect version would be slightly faster. That's only a guess though, so you should try it out both ways and determine which one works best in your scene / driver / GPU configuration.

Thanks.

Ah, it killed my idea :) It will be nice to pass Index buffer, where you can store instance index. So it will work same way like index buffer for vertex buffer.

Is this possible ?

DirectX 11, C++

It's possible, you would just have to do it yourself in the vertex shader instead of letting the Input Assembler do it all for you.

This topic is closed to new replies.

Advertisement