Skip to content

Commit 4be3152

Browse files
ruiminzhaoruimzhao
and
ruimzhao
authored
llpc: Fix the failures for the cases:spirv_assembly.instruction.compute.localsize.*_wgsize_literal_* (GPUOpen-Drivers#2757)
1. Fix the failure when translate SPIRV:"%gl_WorkGroupSize = OpConstantComposite %uvec3 %wgs_0 %wgs_1 %wgs_2" 2. Fix the incorrect code under ShaderModes::setComputeShaderMode Co-authored-by: ruimzhao <[email protected]>
1 parent 3a2a469 commit 4be3152

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

lgc/state/ShaderModes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void ShaderModes::setComputeShaderMode(Module &module, const ComputeShaderMode &
183183
mode.workgroupSizeZ = std::max(1U, mode.workgroupSizeZ);
184184
assert(mode.workgroupSizeX <= MaxComputeWorkgroupSize && mode.workgroupSizeY <= MaxComputeWorkgroupSize &&
185185
mode.workgroupSizeZ <= MaxComputeWorkgroupSize);
186-
PipelineState::setNamedMetadataToArrayOfInt32(&module, inMode, ComputeShaderModeMetadataName);
186+
PipelineState::setNamedMetadataToArrayOfInt32(&module, mode, ComputeShaderModeMetadataName);
187187
}
188188

189189
// =====================================================================================================================
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
; BEGIN_SHADERTEST
2+
; RUN: amdllpc -v %gfxip %s | FileCheck -check-prefix=SHADERTEST %s
3+
; SHADERTEST-LABEL: {{^// LLPC}} pipeline before-patching results
4+
; SHADERTEST: call <3 x i32> @lgc.shader.input.WorkgroupId(i32 0) #1
5+
; SHADERTEST: %{{[0-9]*}} = mul <3 x i32> %{{[0-9]*}}, <i32 1, i32 1, i32 1>
6+
; SHADERTEST: AMDLLPC SUCCESS
7+
; END_SHADERTEST
8+
9+
; SPIR-V
10+
; Version: 1.0
11+
; Generator: Khronos SPIR-V Tools Assembler; 0
12+
; Bound: 32
13+
; Schema: 0
14+
OpCapability Shader
15+
OpMemoryModel Logical GLSL450
16+
OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID
17+
OpSource GLSL 430
18+
OpName %main "main"
19+
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
20+
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
21+
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
22+
OpDecorate %_struct_4 BufferBlock
23+
OpDecorate %5 DescriptorSet 0
24+
OpDecorate %5 Binding 0
25+
OpDecorate %6 DescriptorSet 0
26+
OpDecorate %6 Binding 1
27+
OpDecorate %_runtimearr_float ArrayStride 4
28+
OpMemberDecorate %_struct_4 0 Offset 0
29+
%bool = OpTypeBool
30+
%void = OpTypeVoid
31+
%10 = OpTypeFunction %void
32+
%uint = OpTypeInt 32 0
33+
%int = OpTypeInt 32 1
34+
%float = OpTypeFloat 32
35+
%v3uint = OpTypeVector %uint 3
36+
%v3float = OpTypeVector %float 3
37+
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
38+
%_ptr_Uniform_int = OpTypePointer Uniform %int
39+
%_ptr_Uniform_float = OpTypePointer Uniform %float
40+
%_runtimearr_int = OpTypeRuntimeArray %int
41+
%_runtimearr_float = OpTypeRuntimeArray %float
42+
%_struct_4 = OpTypeStruct %_runtimearr_float
43+
%_ptr_Uniform__struct_4 = OpTypePointer Uniform %_struct_4
44+
%5 = OpVariable %_ptr_Uniform__struct_4 Uniform
45+
%6 = OpVariable %_ptr_Uniform__struct_4 Uniform
46+
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
47+
%int_0 = OpConstant %int 0
48+
%uint_1 = OpConstant %uint 1
49+
%uint_1_0 = OpConstant %uint 1
50+
%uint_1_1 = OpConstant %uint 1
51+
%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_1_0 %uint_1_1
52+
%main = OpFunction %void None %10
53+
%25 = OpLabel
54+
%26 = OpLoad %v3uint %gl_GlobalInvocationID
55+
%27 = OpCompositeExtract %uint %26 0
56+
%28 = OpAccessChain %_ptr_Uniform_float %5 %int_0 %27
57+
%29 = OpLoad %float %28
58+
%30 = OpFNegate %float %29
59+
%31 = OpAccessChain %_ptr_Uniform_float %6 %int_0 %27
60+
OpStore %31 %30
61+
OpReturn
62+
OpFunctionEnd

llpc/translator/lib/SPIRV/SPIRVReader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7642,7 +7642,8 @@ bool SPIRVToLLVM::transMetadata() {
76427642
for (unsigned i = 0, e = m_bm->getNumConstants(); i != e; ++i) {
76437643
auto bv = m_bm->getConstant(i);
76447644
SPIRVWord builtIn = SPIRVID_INVALID;
7645-
if ((bv->getOpCode() == OpSpecConstant || bv->getOpCode() == OpSpecConstantComposite) &&
7645+
if ((bv->getOpCode() == OpSpecConstant || bv->getOpCode() == OpSpecConstantComposite ||
7646+
bv->getOpCode() == OpConstant || bv->getOpCode() == OpConstantComposite) &&
76467647
bv->hasDecorate(DecorationBuiltIn, 0, &builtIn)) {
76477648
if (builtIn == spv::BuiltInWorkgroupSize) {
76487649
// NOTE: Overwrite values of local sizes specified in execution

0 commit comments

Comments
 (0)