Jump to content
  • Advertisement
Sign in to follow this  
katsh

DX11 about "register" in hlsl

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

hi smarts. hows goin.
i am reading DetailTessallation11 sample in SDK sample for Dx11..

there is followiong code.(DetailTessallation11.hlsl line 30)
Buffer<float4> g_DensityBuffer : register( t0 ); // Density vertex buffer ?

well,i have 2 question about this.

1. in my knowledge "t#" is for a texture or texture buffer.
however, g_DensityBuffer is just a array of D3DXVECTOR4 element.(if my reading is correct)
i think this should be "t3" or somethin.(but if i change so ,wont work)

2. "t0" is already used in another hlsl file(Shader_include.hlsl).
normaly another hlsl file is ok but this hlsl file "include" then another hlsl file.
So, it means "t0" is used twice in the same hlsl file.

how come this works?

Share this post


Link to post
Share on other sites
Advertisement
The t# registers are for shader resource views, which can contain either buffers or textures - as long as they have a valid shader resource view.

As far as two objects using the same register, are they referring to the same resource? I would suggest to take a frame capture with PIX and inspect the status of the pipeline stage in question during the use of this shader, and that will tell you what is actually in the register.

Share this post


Link to post
Share on other sites

The t# registers are for shader resource views, which can contain either buffers or textures - as long as they have a valid shader resource view.

As far as two objects using the same register, are they referring to the same resource? I would suggest to take a frame capture with PIX and inspect the status of the pipeline stage in question during the use of this shader, and that will tell you what is actually in the register.

i have tried PIX before this problem,PIX no work for the program that contain Hull shader or/and Domain shader.i guess. for me it crashes PIX.

i read again the SDK document carefully and found that "Buffer" can be everything include just an array of simple data set.

still have quietion #2.

Share this post


Link to post
Share on other sites

[quote name='Jason Z' timestamp='1305456435' post='4811021']
The t# registers are for shader resource views, which can contain either buffers or textures - as long as they have a valid shader resource view.

As far as two objects using the same register, are they referring to the same resource? I would suggest to take a frame capture with PIX and inspect the status of the pipeline stage in question during the use of this shader, and that will tell you what is actually in the register.

i have tried PIX before this problem,PIX no work for the program that contain Hull shader or/and Domain shader.i guess. for me it crashes PIX.

i read again the SDK document carefully and found that "Buffer" can be everything include just an array of simple data set.

still have quietion #2.
[/quote]
Can you post the two declarations? If they refer to the same type of variable, then I don't think it would cause any problems. Another option is to compile the shader offline with the FXC.exe tool and check out the resulting assembly listing. This will show you what type of variable is being used in t0, and then you could work backward from there to see which listing is valid (if not both of them).

Share this post


Link to post
Share on other sites
oh FXC.exe looks fun.thank you. i will invest with FXC later.

here is two declarations.
[media]http://www.northbrain.org/t0.jpg[/media]

its strange for me.

Share this post


Link to post
Share on other sites

oh FXC.exe looks fun.thank you. i will invest with FXC later.

here is two declarations.
[media]http://www.northbrain.org/t0.jpg[/media]

its strange for me.


The two resources are not compatible with one another, so only one of them is occupying t0. Are you sure that both of the resources (g_BaseTexture and g_DensityBuffer) are both used in the body of your shader somewhere? I still would suggest using FXC to compile the shader and get a listing. This will show you exactly what you want to know - what is t0 being used for. That would be the easiest way to figure it out...

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!