Search code examples
c++direct3ddirect3d11direct3d12

Can I change binding points in a compiled D3D shader?


I have an HLSL shader that defines some resources, say a constant buffer:

cbuffer MyCB : register(b0);

If I compile my shader, I will then be able to query the register through the reflection API. But is it possible to change the register (for instance, to b3) in a compiled shader blob in a similar manner you can assign bind points to resources in a compiled OpenGL program?


Solution

  • There is no API to change the shader bindings at runtime in a compiled shader.

    If you jumped through many hoops, you might be able to achieve this with dynamic shader linking in Shader Model 5.0, although it would be lots of work and not really worth it, when there is a very easy alternative - simply create a new compiled shader with the bindings you want.