• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By isu diss
      How do I fill the gap between sky and terrain? Scaling the terrain or procedural terrain rendering?

    • By Jiraya
      For a 2D game, does using a float2 for position increases performance in any way?
      I know that in the end the vertex shader will have to return a float4 anyway, but does using a float2 decreases the amount of data that will have to be sent from the CPU to the GPU?
       
    • By ucfchuck
      I am feeding in 16 bit unsigned integer data to process in a compute shader and i need to get a standard deviation.
      So I read in a series of samples and push them into float arrays
      float vals1[9], vals2[9], vals3[9], vals4[9]; int x = 0,y=0; for ( x = 0; x < 3; x++) { for (y = 0; y < 3; y++) { vals1[3 * x + y] = (float) (asuint(Input1[threadID.xy + int2(x - 1, y - 1)].x)); vals2[3 * x + y] = (float) (asuint(Input2[threadID.xy + int2(x - 1, y - 1)].x)); vals3[3 * x + y] = (float) (asuint(Input3[threadID.xy + int2(x - 1, y - 1)].x)); vals4[3 * x + y] = (float) (asuint(Input4[threadID.xy + int2(x - 1, y - 1)].x)); } } I can send these values out directly and the data is as expected

                             
      Output1[threadID.xy] = (uint) (vals1[4] ); Output2[threadID.xy] = (uint) (vals2[4] ); Output3[threadID.xy] = (uint) (vals3[4] ); Output4[threadID.xy] = (uint) (vals4[4] ); however if i do anything to that data it is destroyed.
      If i add a
      vals1[4] = vals1[4]/2; 
      or a
      vals1[4] = vals[1]-vals[4];
      the data is gone and everything comes back 0.
       
       
      How does one go about converting a uint to a float and performing operations on it and then converting back to a rounded uint?
    • By fs1
      I have been trying to see how the ID3DInclude, and how its methods Open and Close work.
      I would like to add a custom path for the D3DCompile function to search for some of my includes.
      I have not found any working example. Could someone point me on how to implement these functions? I would like D3DCompile to look at a custom C:\Folder path for some of the include files.
      Thanks
    • By stale
      I'm continuing to learn more about terrain rendering, and so far I've managed to load in a heightmap and render it as a tessellated wireframe (following Frank Luna's DX11 book). However, I'm getting some really weird behavior where a large section of the wireframe is being rendered with a yellow color, even though my pixel shader is hard coded to output white. 

      The parts of the mesh that are discolored changes as well, as pictured below (mesh is being clipped by far plane).

      Here is my pixel shader. As mentioned, I simply hard code it to output white:
      float PS(DOUT pin) : SV_Target { return float4(1.0f, 1.0f, 1.0f, 1.0f); } I'm completely lost on what could be causing this, so any help in the right direction would be greatly appreciated. If I can help by providing more information please let me know.
  • Advertisement
  • Advertisement
Sign in to follow this  

DX11 Draw indirect for DX11

This topic is 453 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

Is there any documentation or complete tutorial or references for draw indirect on D3D11?  Is the D3D11 version of draw indirect as robust as the D3D12 version?  I found one barebones tutorial on it through google but thats about it.  Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement

ExecuteIndirect has a lot of functionality that's not supported by DrawIndirect and DispatchIndirect. DrawIndexedInstancedIndirect is exactly the same as DrawIndexedInstanced, except the arguments come from buffer resource instead of being passed in. So you'll need to have the GPU write to a buffer where the first 4 bytes represent IndexCountPerInstance, the next 4 bytes represent InstanceCount, the next 4 represent StartIndexLocation, and so on. DispatchIndirect is exactly the same, except your buffer contains ThreadGroupCountX, ThreadGroupCountY, and ThreadGroupCountZ. The buffer resource needs to be created with D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS to be used as indirect arguments.

 

I'm not sure if there were ever any official samples that used DrawIndirect. I used it in a depth of field sample I wrote a long time ago, where I basically spawned bokeh-shaped particles for certain pixels. For something more advanced, you could look at my shadow rendering sample, where I used DrawIndirect to render meshes after performing culling on the GPU.

Edited by MJP

Share this post


Link to post
Share on other sites

You can only change the draw args.

 

The best approximation would be to DrawIndirect once for each set of textures you might want to apply to the draw and then zero out the index count for any draw you want to cull completely. So long as there aren't too many zero-count draws you shouldn't hit the unfortunate bottleneck of being Command Processor bound.

Share this post


Link to post
Share on other sites

You might have heard the term multi-draw indirect (MDI). I believe there was an OpenGL extension for it. That's the idea of submitting multiple draws with state changes in a single indirect call, which is similar to ExecuteIndirect, but D3D11 does not have any form of MDI. Like Adam said, no state changes between instances.

Share this post


Link to post
Share on other sites
AMD has a MDI extension for D3D11 accessible via their AGS library.

But if you can't change state how would you use for example a different MVP matrix within the same texture batch?

Bind more than one matrix in a buffer (cb or srv).

Share this post


Link to post
Share on other sites

Anyway to get back to state changes, it's the same as if you made a normal DrawIndexedInstanced call. Your vertex shader will have SV_VertexID available as well ad SV_InstanceID, so you're free to use those to index into buffers however you'd like. But you can't actually change bindings per-instance, just like a normal instanced draw call.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement