From da5cf478c6be06c9e6c20917a7d472cbdcb624e3 Mon Sep 17 00:00:00 2001 From: Gangzheng Tong Date: Fri, 30 May 2025 17:16:59 -0700 Subject: 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 InputTyped; [require(cpp_cuda_glsl_hlsl_metal_spirv)] RWBuffer 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 InputTyped; ^~~~~~~~~~ .\tests\wgsl_no_buffer.slang(4): error 36108: 'OutputTyped' has dependencies that are not compatible on the required target 'wgsl'. RWBuffer 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> --- source/slang/slang-ast-builder.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/slang/slang-ast-builder.cpp') diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index 893d5e6d7..d3e99ee4b 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -289,6 +289,12 @@ Type* ASTBuilder::getDefaultLayoutType() { return getSpecializedBuiltinType({}, "DefaultDataLayoutType"); } + +Type* ASTBuilder::getDefaultPushConstantLayoutType() +{ + return getSpecializedBuiltinType({}, "DefaultPushConstantDataLayoutType"); +} + Type* ASTBuilder::getStd140LayoutType() { return getSpecializedBuiltinType({}, "Std140DataLayoutType"); -- cgit v1.2.3