Jump to content
  • Advertisement
Sign in to follow this  
cp25stack

DX11 Some noob HLSL question about register c, b

Recommended Posts

Hello, I have some questions about HLSL register which can't find any good reference s on the internet.
1. what is the differencet of register b and c?
Are this two lines equivalent (in term of using and binding data)
float4 dummy :register(b0)
and
float4 dummy :register(c0)

2. What is the benefit of keyword Constant Buffer
Are these 2 codes eqivalent?

float4 v1 :register(c0) // or (b0)
and
Constant buffer dummy : register(b0) // or (c0)?
{
    float4 v1 :register(c0)
}

3. What register that "SetPixelShaderConstantF" bind data to? b or c or both?

Thanks

Share this post


Link to post
Share on other sites
Advertisement

"b" registers are for D3D10 and above (SM 4.0+), and "c" registers are for D3D9 (SM 2.x and 3.0). In D3D9 era the shader programming model exposed a set of constant registers, and you would set those registers one at a time using functions like SetPixelShaderConstantF. The shader would then use the values of those constants when when executing.

For D3D10 and Shader Model 4.0 the constant registers were scrapped, and replaced with constant buffers. Instead of dealing with 1 constant register at a time, you would instead create buffer resources of arbitrary size (up to 64KB or so) and bind the entire buffer to a single slot/register. The "cb" register is used for these constant buffer slots when the shader assembly needs to read from a particular buffer. Confusingly even though the assembly refers to the registers as "cb", in HLSL you use "register(bX)" to specify which register you want the constant buffer bound to.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • 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!