microsoft / hlsl-specs

HLSL Specifications
MIT License
116 stars 29 forks source link

Local to global resource mapping when accessing through an array #275

Open shaderdev opened 1 month ago

shaderdev commented 1 month ago

Hello,

I believe I found an issue with DXC compiler which causes a false error to be produced: "local resource not guaranteed to map to unique global resource"

I created a small repro shader in compiler explorer that demonstrates the issue: https://godbolt.org/z/4W6MqE4fc

I this example, indexing an array of textures works fine through "_Textures" but not when accessing through "_TexturesFlatten" which is declared as static. It seems to me that some information about the uniqueness of the texture resources is lost when using such a construct. What do you think?

Keenuts commented 1 month ago

On the SPIR-V backend, we handle that just fine. But I'm not sure if storing opaque resources handles in a static global is allowed so deferring this to MS.

On another note: why are you doing this instead of declaring directly an array of Texture2D? Curious what the use-case is, and if alternatives could be advised.

damyanp commented 1 month ago

DXIL doesn't allow for this unfortunately. I think it would be good to find a way to make this scenario work in the future, but that would be a shader model change. Moving this to hlsl-specs to consider it there.