microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
3.11k stars 695 forks source link

Report error on local variables with resource binding #6971

Open hekota opened 1 month ago

hekota commented 1 month ago

Description DXC should report error on local variable with resource binding.

Steps to Reproduce

For cs_6_5 this reports an error local resource not guaranteed to map to unique global resource. https://godbolt.org/z/qhP8dqbed

[numthreads(4,1,1)]
void main() {
  RWBuffer<int> buf : register(u0);
  buf[0] = 1;
}

For cs_6_6 it does not report an error, generatesannotateHandle without createHandle, and the resource binding is not captured in metadata. https://godbolt.org/z/xcadsEjzr

For lib_6_6 it also does not report an error, produces annotateHandle and createHandleForLib, and the resource binding is not captured in metadata. https://godbolt.org/z/MWzdTEb6q

export int foo() {
  RWBuffer<int> buf : register(u0);
  return buf.Load(0);
}

Actual Behavior Local resources with bindings should not be allowed and the compiler should report an error.

Environment

damyanp commented 1 month ago

Somewhat related, since validation should pick this up: #4415