From 842dee3b6b62c7eb37134e3e27b2ebebdde99b42 Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Tue, 8 Oct 2024 15:41:51 +0300 Subject: WGSL emitter: Specify private address space for global non-handle variable declarations (#5236) Closes issue #5229. --- source/slang/slang-emit-wgsl.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source') diff --git a/source/slang/slang-emit-wgsl.cpp b/source/slang/slang-emit-wgsl.cpp index 66e802571..a05e03afc 100644 --- a/source/slang/slang-emit-wgsl.cpp +++ b/source/slang/slang-emit-wgsl.cpp @@ -602,6 +602,21 @@ void WGSLSourceEmitter::emitVarKeywordImpl(IRType * type, IRInst* varDecl) m_writer->emit("storage, read"); m_writer->emit(">"); } + else if(varDecl->getOp() == kIROp_GlobalVar) + { + // Global ("module-scope") non-handle variables need to specify storage space + + // https://www.w3.org/TR/WGSL/#var-decls + // " + // Variables in the private, storage, uniform, workgroup, and handle address + // spaces must only be declared in module scope, while variables in the function + // address space must only be declared in function scope. The address space must + // be specified for all address spaces except handle and function. The handle + // address space must not be specified. Specifying the function address space is + // optional. + // " + m_writer->emit(""); + } } void WGSLSourceEmitter::_emitType(IRType* type, DeclaratorInfo* declarator) -- cgit v1.2.3