microsoft / microsoft/DirectXShaderCompiler

Report error on local variables with resource binding

Open
#6,971 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug diagnostic incorrect-code
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

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

  • DXC main as od 10/16/2024
  • Windows 11 / Compiler Explorer

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the cs_6_5, cs_6_6, and lib_6_6 examples from the issue in Compiler Explorer and compare diagnostics, generated instructions, and resource metadata. Trace the DXC handling of local resources with register bindings; done means each affected case reports that local resources with bindings are not allowed and does not silently omit the binding from metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.