Jump to content
  • Advertisement
Sign in to follow this  
DarkChris

[SOLVED] What's the difference between a StructuredBuffer and a cbuffer?

This topic is 2660 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's the difference between a StructuredBuffer as a ShaderResourceView and a cbuffer? As far as I know they are mostly the same. And when should I choose which and why?

EDIT: Oh, I already found out. StructuredBuffers are like Arrays, cbuffers aren't. -.-

Share this post


Link to post
Share on other sites
Advertisement

What's the difference between a StructuredBuffer as a ShaderResourceView and a cbuffer? As far as I know they are mostly the same. And when should I choose which and why?

EDIT: Oh, I already found out. StructuredBuffers are like Arrays, cbuffers aren't. -.-


Just to elaborate a little further, they're also designed for different use cases. Constant buffers are meant for having a relatively small amount of heterogeneous data that's accessed synchronously by many shader threads, which all access the same locations. Consequently the driver and GPU will be optimized for those cases. It's possible to use them in other ways (for instance, having a large array of homogeneous bone matrices) but in those cases you may experience degraded performance. A Buffer or Texture on the other hand is designed for those use cases, and will use things like caching and asynchronous fetches to make them more optimal.

One neat thing you could do in D3D10 is declare a tbuffer rather than a cbuffer in your shader, and bind a texture rather than a constant buffer. This allows you to access the texture as if it were a constant buffer, but it would still use the texture pipeline for the fetch. Of course in D3D11 this kinda redundant, since a StructuredBuffer gives you nearly the same functionality.

Share this post


Link to post
Share on other sites

[quote name='DarkChris' timestamp='1299931776' post='4784758']
What's the difference between a StructuredBuffer as a ShaderResourceView and a cbuffer? As far as I know they are mostly the same. And when should I choose which and why?

EDIT: Oh, I already found out. StructuredBuffers are like Arrays, cbuffers aren't. -.-


Just to elaborate a little further, they're also designed for different use cases. Constant buffers are meant for having a relatively small amount of heterogeneous data that's accessed synchronously by many shader threads, which all access the same locations. Consequently the driver and GPU will be optimized for those cases. It's possible to use them in other ways (for instance, having a large array of homogeneous bone matrices) but in those cases you may experience degraded performance. A Buffer or Texture on the other hand is designed for those use cases, and will use things like caching and asynchronous fetches to make them more optimal.

One neat thing you could do in D3D10 is declare a tbuffer rather than a cbuffer in your shader, and bind a texture rather than a constant buffer. This allows you to access the texture as if it were a constant buffer, but it would still use the texture pipeline for the fetch. Of course in D3D11 this kinda redundant, since a StructuredBuffer gives you nearly the same functionality.
[/quote]

Ok, thank you. I hoped that you'd respond, as I thought that you'd know better than me. And it definitely happened and I still learned something... Thanks... :)

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!