Jump to content
  • Advertisement
Sign in to follow this  
poigwym

DX11 dx11 shader reflection need advice

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

How to use dx11 shader reflection ?

 

Every time there's a cbuffer in shader, I need to get the size, and new a buffer (named tmpBuffer) in c++ - side and create a c++ - side Cbuffer.

In update time, I set the data to the tmpBuffer first, and before transfer to GPU, I need to copy data from tmpBuffer to Cbuffer(c++ side),

then SetConstantBuffer(cb) to pass  the Cbuffer to GPU side.

 

Is there a better way to update and transfer to GPU more effective ?

 

 

 

 

Share this post


Link to post
Share on other sites
Advertisement

Do you explicitly need reflection for what you're trying to achieve? I often times find it much easier to just declare C++ structures for the constant buffers I'm going to require, and just create instances of those which I can bind directly. You completely avoid having to dynamically construct a bunch of intermediate buffers and such for your shader to use. This especially holds true for constant buffers which you know you'll need 99% of the time, such as engine constants or per-view constants.

 

If you do need to have a fully dynamic setup for constant buffer binding it might be a good idea to just store some form of descriptor structure for your constant buffer which can provide your application with the info it needs to build a buffer which can be sent to the GPU. Think of it as a simple schema for your constant buffers. In that case you can just build these buffers where you need them in your application and then write to them simply by mapping them and copying over the chunk of memory which holds your data, which I assume is sort of like what you described.

 

I'm not a huge fan of the fully dynamic approach though. I can see shader reflection being used in tools where you're setting up material structures and stuff like that, but I'm not a huge fan of using it at runtime. To each his/her own though :)

Share this post


Link to post
Share on other sites

@Rad sorry for the downvote, I meant to press up vote. Tablet glitched out on me.

Anyways, the reflection system for DX11 needs a quite a bit of setup before it becomes useful for you. From what I am gathering, you really shouldn't need to set up a reflection system just yet. A constant buffer is pretty predictable in most cases, so you'll be 90% sure of what's going on when it comes to it.

 

If you do need to use it, there's a bit of documentation availible for you.

 

https://msdn.microsoft.com/en-us/library/windows/desktop/ff476590(v=vs.85).aspx

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!