diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 0a61a2b3..86e6ac3a 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -493,6 +493,9 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls case EShLangCompute: builder.addCapability(spv::CapabilityShader); + builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSize(0), + glslangIntermediate->getLocalSize(1), + glslangIntermediate->getLocalSize(2)); break; default: diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index df76328e..3e2768b6 100755 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -648,14 +648,18 @@ void Builder::addEntryPoint(ExecutionModel model, Function* function, const char entryPoints.push_back(entryPoint); } -void Builder::addExecutionMode(Function* entryPoint, ExecutionMode mode, int value) +// Currently relying on the fact that all 'value' of interest are small non-negative values. +void Builder::addExecutionMode(Function* entryPoint, ExecutionMode mode, int value1, int value2, int value3) { - // TODO: handle multiple optional arguments Instruction* instr = new Instruction(OpExecutionMode); instr->addIdOperand(entryPoint->getId()); instr->addImmediateOperand(mode); - if (value >= 0) - instr->addImmediateOperand(value); + if (value1 >= 0) + instr->addImmediateOperand(value1); + if (value2 >= 0) + instr->addImmediateOperand(value2); + if (value3 >= 0) + instr->addImmediateOperand(value3); executionModes.push_back(instr); } diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h index 336aa243..c5637f04 100755 --- a/SPIRV/SpvBuilder.h +++ b/SPIRV/SpvBuilder.h @@ -182,7 +182,7 @@ public: // Methods for adding information outside the CFG. void addEntryPoint(ExecutionModel, Function*, const char* name); - void addExecutionMode(Function*, ExecutionMode mode, int value = -1); + void addExecutionMode(Function*, ExecutionMode mode, int value1 = -1, int value2 = -1, int value3 = -1); void addName(Id, const char* name); void addMemberName(Id, int member, const char* name); void addLine(Id target, Id fileName, int line, int column); diff --git a/Test/baseResults/spv.310.comp.out b/Test/baseResults/spv.310.comp.out index d6a53ac7..9a6a10c7 100644 --- a/Test/baseResults/spv.310.comp.out +++ b/Test/baseResults/spv.310.comp.out @@ -14,6 +14,7 @@ Linked compute stage: 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint GLCompute 4 "main" + ExecutionMode 4 LocalSize 16 32 4 Name 4 "main" Name 13 "outb" MemberName 13(outb) 0 "f" diff --git a/Test/baseResults/spv.atomic.comp.out b/Test/baseResults/spv.atomic.comp.out index f3ae798f..ddf48bd1 100755 --- a/Test/baseResults/spv.atomic.comp.out +++ b/Test/baseResults/spv.atomic.comp.out @@ -15,6 +15,7 @@ TBD functionality: Is atomic_uint an opaque handle in the uniform storage class, 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint GLCompute 4 "main" + ExecutionMode 4 LocalSize 1 1 1 Name 4 "main" Name 10 "func(au1;" Name 9 "c" diff --git a/Test/baseResults/spv.double.comp.out b/Test/baseResults/spv.double.comp.out index d3bf5c4f..60183efb 100755 --- a/Test/baseResults/spv.double.comp.out +++ b/Test/baseResults/spv.double.comp.out @@ -14,6 +14,7 @@ Linked compute stage: 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint GLCompute 4 "main" + ExecutionMode 4 LocalSize 1 1 1 Name 4 "main" Name 8 "bufName" MemberName 8(bufName) 0 "f"