Sign in to follow this  

Magic function called DrawIndexedInstancedIndirect

This topic is 1796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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;
};

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites

This topic is 1796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this