diff options
| author | Gangzheng Tong <tonggangzheng@gmail.com> | 2025-05-30 17:16:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-31 00:16:59 +0000 |
| commit | da5cf478c6be06c9e6c20917a7d472cbdcb624e3 (patch) | |
| tree | 7be790c85547c86b92fff80fa9340c89d71a167e /source/slang/slang-parser.cpp | |
| parent | 3ca27faa23a92124f26875a6f00bcfc3a1c6431e (diff) | |
Add check for the variable requirement (#6677)
* Add check for the variable requirement
This change adds the capability check for the variables requirement.
With this check, the shader
```
[require(cpp_cuda_glsl_hlsl_metal_spirv)]
Buffer<float> InputTyped;
[require(cpp_cuda_glsl_hlsl_metal_spirv)]
RWBuffer<float> OutputTyped;
```
will issue error if targeting to WSGL
e.g. `.\build\Debug\bin\slangc .\tests\wgsl_no_buffer.slang -o
wgsl_no_buffer.txt -target wgsl -entry Main -stage compute`
.\tests\wgsl_no_buffer.slang(2): error 36108: 'InputTyped' has dependencies that are not compatible on the required target 'wgsl'.
Buffer<float> InputTyped;
^~~~~~~~~~
.\tests\wgsl_no_buffer.slang(4): error 36108: 'OutputTyped' has dependencies that are not compatible on the required target 'wgsl'.
RWBuffer<float> OutputTyped;
^~~~~~~~~~~
Fixes #6304
* Add var capability tests
* Do capability checks for global var only
* Add inferredCapabilityRequirements to var capability check
* Add requirement to the intrinsic types Buffer/RWBuffer
* format code
* Update capabliity test
* use DefaultDataLayout as default data layout
* Use visitMemberExpr to check the capabilities
* Update the cap tests to match the error messages
* update test to use the ScalarDataLayout for hlsl target
* Update tests check condition to use error number only
* Add default push_constant data layout type
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-parser.cpp')
| -rw-r--r-- | source/slang/slang-parser.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index 9eb8c1391..439959827 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -4976,8 +4976,9 @@ static DeclBase* ParseDeclWithModifiers( }; if (AdvanceIf(parser, "buffer")) { - decl = as<Decl>( - parseGLSLShaderStorageBufferDecl(parser, getLayoutArg("Std430DataLayout"))); + decl = as<Decl>(parseGLSLShaderStorageBufferDecl( + parser, + getLayoutArg("DefaultDataLayout"))); break; } else if (auto mod = findPotentialGLSLInterfaceBlockModifier(parser, modifiers)) |
