Jump to content
  • Advertisement
xhcao

DX11 HLSL: Can two RWTexture2D resource view variables share the same register

Recommended Posts

In Direct3D 11, Could I define two RWTexture2D resource variables which share the same register in pixel shader as below,

RWTexture2D<float4> tex1 : register(u0);

RWTexture2D<float4> tex2 : register(u0);

Compile error: error X4500: overlapping register semantics not yet implemented 'u0'

It seems that it is illegal to define as above. The reason to define as above is that I want to these two resource variable bind the same texture.

I try to create two different unodered access views, and their resources are the same texture.  But Two UAVs conflict if they share a subresource (and therefore share the same resource), reference to https://msdn.microsoft.com/en-us/library/windows/desktop/ff476465(v=vs.85).aspx

Share this post


Link to post
Share on other sites
Advertisement

The registers are shared between descriptors of the same type in the same space. You either need to change the space of one of the uavs (only applicable to DX12). If you are on DX11, then you need separate registers.

Share this post


Link to post
Share on other sites
39 minutes ago, mark_braga said:

The registers are shared between descriptors of the same type in the same space. You either need to change the space of one of the uavs (only applicable to DX12). If you are on DX11, then you need separate registers.

Sorry, I did not understand you clearly.

What is the same space? What is the meaning that the registers are shared between descriptors. I need to implement two HLSL RWTexture2D binding to the same resource on D3D11. Is it possible?

In my opinion, if separate registers on D3D11, the two RWTexture2D variable must be bound to different resource.

Share this post


Link to post
Share on other sites

The space is a shader model 5.1 to allow two or more unbounded arrays of resources like "texture2D foo[]: register(t0,space1)" it does not concern you.

 

And no, you can't bind the same writable object to two registers, it is a violation, and would lead to cache coherency issues if it was doable.

 

If you want two variables to reference the same resource, then use one variable and rewrite your code to not use globals in the first place !

Share this post


Link to post
Share on other sites
22 hours ago, xhcao said:

What is the same space? What is the meaning that the registers are shared between descriptors. I need to implement two HLSL RWTexture2D binding to the same resource on D3D11. Is it possible?

Sorry for mixing DX11 and DX12. Also I guess galop1N answered your question :)

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

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