Jump to content

  • Log In with Google      Sign In   
  • Create Account

Passing vertex information to compute shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 DrumminOmelette   Members   -  Reputation: 113

Like
0Likes
Like

Posted 11 February 2014 - 05:51 PM

Hi all

I am currently attempting to create a ray tracer using the GPU with the intention of extending it to a path tracer once I get a basic ray tracer working for a project of mine.


As both algorithms require performing intersection tests against all known geometry in the scene, this means that I will need a single buffer containing the triangle/vertex information for every piece of geometry in a given scene as I expect repeated render calls for individual pieces of geometry will be very slow. This is fine for scenes with a low amount of triangles but my intention is to render fairly complex scenes later, which could potentially contain thousands of triangles so this is my first concern: Is there a set limit to the amount of data I can pass in a single buffer to the GPU or is it solely limited to the amount of RAM available on the GPU?


My second question is how do I actually go about passing the data to the compute shader? I have only ever used vertex/pixel shaders before which obviously make use of the standard rasterization pipeline : IE the input assembler and buffers containing the vertices (and indices) with the D3D11_BIND_VERTEX_BUFFER (and D3D11_BIND_INDEX_BUFFER) flags. As the application will only use the compute shader and a different method of drawing graphics, I'm not sure if I can use these specific buffers or if I should be using a structured buffer instead with a struct matching the vertex information, as I've heard that there are conflicts with specifying a buffer with both the D3D11_BIND_VERTEX_BUFFER and the D3D11_BIND_UNORDERED_ACCESS flags but I could be mistaken.

Any information or help would be greatly appreciated. Thank you

Sponsor:

#2 MJP   Moderators   -  Reputation: 11761

Like
2Likes
Like

Posted 11 February 2014 - 06:27 PM

I don't think there's a limit, aside from how much memory that the driver can allocate. For reading a buffer in a compute shader you're probably going to want to use a structured buffer. Unfortunately D3D11 has a silly restriction that you can't create a buffer with both D3D11_BIND_VERTEX_BUFFER and D3D11_BIND_SHADER_RESOURCE, so if you want to read from a buffer in a shader then it can't be a vertex buffer. However if you create the buffer as a structured buffer and you need to rasterize it with the graphics pipeline, you can always just directly read from the buffer a shader resource view in your vertex shader using SV_VertexID.



#3 Ryan_001   Prime Members   -  Reputation: 1459

Like
2Likes
Like

Posted 12 February 2014 - 03:26 AM

The resource limits can be found here: http://msdn.microsoft.com/en-us/library/windows/desktop/ff819065(v=vs.85).aspx.  Generally speaking the maximum size of any resource is 1/4 the total video ram, with a minimum of 128MB, up to a max of 2GB.  As MJP pointed out a structured buffer is the best thing to use for passing the data.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS