Jump to content
  • Advertisement

Structured Buffers vs. Constant Buffers?

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

What're the differences between structured buffers and constant buffers? From their name alone I'd assume you want to set up your constant buffers at the start of execution to hold your constant values, but I've seen guides (even on MSDN) showing how to update them every frame, which I would hardly call constant.

Whereas I can't find all that much information on structured buffers, just the odd forum post here and there. I can't even see a single thing on the MSDN about it, but I know they can be used to pass data from the CPU to the GPU.

So let's say I have three scenarios:

1) I have a depth of field shader, but I allow the user to specify the size of the blurring kernel at run time. I then build an array of length kernelsize*2 of Vector3s for sampling offsets and weightings combined. I want to pass this to the shader, but I only want to do it when the user changes the blur kernel size, not every frame.

2) I have a view matrix and a projection matrix, I want to send the view matrix to my shaders every time the viewpoint moves, however I only want to send the projection matrix at the start of the program, as I assume it will never change.

2) I have a list of lights in the scene, every frame I calculate which lights are near the player and send their positions and colors to the GPU in order to build a light map.

Which method would be best for which scenario and are there any other ways of sending data to the GPU (I'm using SlimDX - but C++ examples should be translatable)?

I realize this is quite basic, but I just can't find any good resources on, well, shader resources.

Share this post

Link to post
Share on other sites
Thanks for the update, that's a really in-depth and helpful response. I think I'll go with StructuredBuffers when I eventually get around to lighting my engine, because I really can't be sure how many lights I'll need.

Thanks very much :)

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!