Advertisement

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

Started by September 07, 2017 03:06 AM
4 comments, last by mark_braga 7 years, 5 months ago

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

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.

Advertisement
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.

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 !

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 :)

This topic is closed to new replies.

Advertisement