简体   繁体   中英

DirectX 11 Shader Resource Management

I'm creating a shader management system instead of using the Effects 11 library. I have a couple of questions about resource management for shaders.

If I have a Constant Buffer set to a certain register in the shader code, does it need to be set to that register when I set it on the device? What if I have multiple shaders that use that register?

Are constant buffers maintained in memory between draws, or are they cleared? Say for example I have a constant buffer that is not changed from the last draw, do I need to set it again?

Is it slower to set constant buffers one at a time or all at once?

Thanks in advance.

Yes, you need to set to that register, think of it as a constant buffer slot.

Yes, it will keep there until you switch it by another.

"Is it slower to set constant buffers one at a time or all at once?"

What do you mean by "all at once"?

Anyway, check this nvidia presentation for great info on cbuffer management: https://developer.nvidia.com/sites/default/files/akamai/gamedev/files/gdc12/Efficient_Buffer_Management_McDonald.pdf

Note that pixel shaders and vertex shaders (different shader types) use different registers EVEN if you are using the exactly same "variable" on the hlsl code. Thats handled for you, the thing to note is that to update the cbuffer to the register, you use the pixel shader version of the d3d function(VSSetConstantBuffer vs PSSetConstantBuffer, etc.). Thats for all types of shaders of course.

So for example, in the hlsl code, you can have 2 constant buffers using the same slot(register), BUT, remember to not use both on the same shader..Or, again, you can use the same constant buffer on both shaders, just remember that its not really the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM