From c0cf7f578a907298fc4dc24e312d187eaaaa155c Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Sun, 24 Apr 2022 13:21:13 +0200 Subject: [PATCH] clc: parse localSize and localSizeHint Signed-off-by: Karol Herbst Reviewed-by: Jesse Natalie Part-of: --- src/compiler/clc/clc.h | 3 +++ src/compiler/clc/clc_helpers.cpp | 31 ++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/compiler/clc/clc.h b/src/compiler/clc/clc.h index 68366340ced..0431643c00d 100644 --- a/src/compiler/clc/clc.h +++ b/src/compiler/clc/clc.h @@ -128,6 +128,9 @@ struct clc_kernel_info { unsigned vec_hint_size; enum clc_vec_hint_type vec_hint_type; + + unsigned local_size[3]; + unsigned local_size_hint[3]; }; enum clc_spec_constant_type { diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp index 01ef8a66e4a..383f236e7e4 100644 --- a/src/compiler/clc/clc_helpers.cpp +++ b/src/compiler/clc/clc_helpers.cpp @@ -102,13 +102,16 @@ public: class SPIRVKernelInfo { public: - SPIRVKernelInfo(uint32_t fid, const char *nm) : funcId(fid), name(nm), vecHint(0) { } + SPIRVKernelInfo(uint32_t fid, const char *nm) + : funcId(fid), name(nm), vecHint(0), localSize(), localSizeHint() { } ~SPIRVKernelInfo() { } uint32_t funcId; std::string name; std::vector args; unsigned vecHint; + unsigned localSize[3]; + unsigned localSizeHint[3]; }; class SPIRVKernelParser { @@ -447,14 +450,26 @@ public: void parseExecutionMode(const spv_parsed_instruction_t *ins) { uint32_t executionMode = ins->words[ins->operands[1].offset]; - if (executionMode != SpvExecutionModeVecTypeHint) - return; - uint32_t funcId = ins->words[ins->operands[0].offset]; - uint32_t vecHint = ins->words[ins->operands[2].offset]; + for (auto& kernel : kernels) { - if (kernel.funcId == funcId) - kernel.vecHint = vecHint; + if (kernel.funcId == funcId) { + switch (executionMode) { + case SpvExecutionModeVecTypeHint: + kernel.vecHint = ins->words[ins->operands[2].offset]; + break; + case SpvExecutionModeLocalSize: + kernel.localSize[0] = ins->words[ins->operands[2].offset]; + kernel.localSize[1] = ins->words[ins->operands[3].offset]; + kernel.localSize[2] = ins->words[ins->operands[4].offset]; + case SpvExecutionModeLocalSizeHint: + kernel.localSizeHint[0] = ins->words[ins->operands[2].offset]; + kernel.localSizeHint[1] = ins->words[ins->operands[3].offset]; + kernel.localSizeHint[2] = ins->words[ins->operands[4].offset]; + default: + return; + } + } } } @@ -692,6 +707,8 @@ clc_spirv_get_kernels_info(const struct clc_binary *spvbin, kernels[i].num_args = parser.kernels[i].args.size(); kernels[i].vec_hint_size = parser.kernels[i].vecHint >> 16; kernels[i].vec_hint_type = (enum clc_vec_hint_type)(parser.kernels[i].vecHint & 0xFFFF); + memcpy(kernels[i].local_size, parser.kernels[i].localSize, sizeof(kernels[i].local_size)); + memcpy(kernels[i].local_size_hint, parser.kernels[i].localSizeHint, sizeof(kernels[i].local_size_hint)); if (!kernels[i].num_args) continue;