@@ -5445,6 +5445,97 @@ OpFunctionEnd
54455445 EXPECT_EQ (SPV_SUCCESS, ValidateInstructions ());
54465446}
54475447
5448+ // OpDecorateId
5449+
5450+ TEST_F (ValidateDecorations, DecorateIdGood) {
5451+ const std::string spirv = R"(
5452+ OpCapability Shader
5453+ OpMemoryModel Logical Simple
5454+ OpEntryPoint GLCompute %main "main"
5455+ OpExecutionMode %main LocalSize 1 1 1
5456+ OpName %subgroupscope "subgroupscope"
5457+ OpName %int0 "int0"
5458+ OpName %fn "fn"
5459+ OpDecorateId %int0 UniformId %subgroupscope
5460+ %void = OpTypeVoid
5461+ %float = OpTypeFloat 32
5462+ %int = OpTypeInt 32 1
5463+ %subgroupscope = OpConstant %int 3
5464+ %int0 = OpConstantNull %int
5465+ %fn = OpTypeFunction %void
5466+ %main = OpFunction %void None %fn
5467+ %entry = OpLabel
5468+ OpReturn
5469+ OpFunctionEnd
5470+ )" ;
5471+
5472+ CompileSuccessfully (spirv, SPV_ENV_UNIVERSAL_1_4);
5473+ EXPECT_EQ (SPV_SUCCESS, ValidateInstructions (SPV_ENV_UNIVERSAL_1_4));
5474+ EXPECT_THAT (getDiagnosticString (), Eq (" " ));
5475+ }
5476+
5477+ TEST_F (ValidateDecorations, DecorateIdGroupBad) {
5478+ const std::string spirv = R"(
5479+ OpCapability Shader
5480+ OpMemoryModel Logical Simple
5481+ OpEntryPoint GLCompute %main "main"
5482+ OpExecutionMode %main LocalSize 1 1 1
5483+ OpName %subgroupscope "subgroupscope"
5484+ OpName %int0 "int0"
5485+ OpName %fn "fn"
5486+ OpName %group "group"
5487+ OpDecorateId %group UniformId %subgroupscope
5488+ %group = OpDecorationGroup
5489+ OpGroupDecorate %group %int0
5490+ %void = OpTypeVoid
5491+ %float = OpTypeFloat 32
5492+ %int = OpTypeInt 32 1
5493+ %subgroupscope = OpConstant %int 3
5494+ %int0 = OpConstantNull %int
5495+ %fn = OpTypeFunction %void
5496+ %main = OpFunction %void None %fn
5497+ %entry = OpLabel
5498+ OpReturn
5499+ OpFunctionEnd
5500+ )" ;
5501+
5502+ CompileSuccessfully (spirv, SPV_ENV_UNIVERSAL_1_4);
5503+ EXPECT_EQ (SPV_ERROR_INVALID_ID, ValidateInstructions (SPV_ENV_UNIVERSAL_1_4));
5504+ EXPECT_THAT (getDiagnosticString (),
5505+ HasSubstr (" must not be an OpDecorationGroup instruction.\n "
5506+ " OpDecorateId %group UniformId %subgroupscope" ));
5507+ }
5508+
5509+ TEST_F (ValidateDecorations, DecorateIdOutOfOrderBad) {
5510+ const std::string spirv = R"(
5511+ OpCapability Shader
5512+ OpMemoryModel Logical Simple
5513+ OpEntryPoint GLCompute %main "main"
5514+ OpExecutionMode %main LocalSize 1 1 1
5515+ OpName %subgroupscope "subgroupscope"
5516+ OpName %int0 "int0"
5517+ OpName %fn "fn"
5518+ OpDecorateId %int0 UniformId %subgroupscope
5519+ %void = OpTypeVoid
5520+ %float = OpTypeFloat 32
5521+ %int = OpTypeInt 32 1
5522+ %int0 = OpConstantNull %int
5523+ %subgroupscope = OpConstant %int 3
5524+ %fn = OpTypeFunction %void
5525+ %main = OpFunction %void None %fn
5526+ %entry = OpLabel
5527+ OpReturn
5528+ OpFunctionEnd
5529+ )" ;
5530+
5531+ CompileSuccessfully (spirv, SPV_ENV_UNIVERSAL_1_4);
5532+ EXPECT_EQ (SPV_ERROR_INVALID_ID, ValidateInstructions (SPV_ENV_UNIVERSAL_1_4));
5533+ EXPECT_THAT (getDiagnosticString (),
5534+ HasSubstr (" [%subgroupscope]' must appear earlier in the"
5535+ " binary than the target\n "
5536+ " OpDecorateId %int0 UniformId %subgroupscope" ));
5537+ }
5538+
54485539// Uniform and UniformId decorations
54495540
54505541TEST_F (ValidateDecorations, UniformDecorationGood) {
@@ -5486,17 +5577,19 @@ OpName %subgroupscope "subgroupscope"
54865577OpName %call "call"
54875578OpName %myfunc "myfunc"
54885579OpName %int0 "int0"
5580+ OpName %int1 "int1"
54895581OpName %float0 "float0"
54905582OpName %fn "fn"
54915583)" ) + inst +
54925584 R"(
54935585%void = OpTypeVoid
54945586%float = OpTypeFloat 32
54955587%int = OpTypeInt 32 1
5496- %int0 = OpConstantNull %int
5588+ %int1 = OpConstant %int 1
54975589%int_99 = OpConstant %int 99
54985590%subgroupscope = OpConstant %int 3
54995591%float0 = OpConstantNull %float
5592+ %int0 = OpConstantNull %int
55005593%fn = OpTypeFunction %void
55015594%myfunc = OpFunction %void None %fn
55025595%myfuncentry = OpLabel
@@ -5613,7 +5706,7 @@ TEST_F(ValidateDecorations,
56135706
56145707TEST_F (ValidateDecorations, UniformDecorationWithScopeIdV14VulkanEnv) {
56155708 const std::string spirv =
5616- ShaderWithUniformLikeDecoration (" OpDecorateId %int0 UniformId %int0 " );
5709+ ShaderWithUniformLikeDecoration (" OpDecorateId %int0 UniformId %int1 " );
56175710
56185711 CompileSuccessfully (spirv, SPV_ENV_VULKAN_1_1_SPIRV_1_4);
56195712 EXPECT_EQ (SPV_ERROR_INVALID_DATA,
@@ -10523,8 +10616,8 @@ const std::string kNodeShaderPostlude = R"(
1052310616%node1 = OpConstantStringAMDX "node1"
1052410617%node2 = OpConstantStringAMDX "node2"
1052510618%S = OpTypeStruct
10526- %_payloadarr_S = OpTypeNodePayloadArrayAMDX %S
1052710619%_payloadarr_S_0 = OpTypeNodePayloadArrayAMDX %S
10620+ %_payloadarr_S = OpTypeNodePayloadArrayAMDX %S
1052810621%bool = OpTypeBool
1052910622%true = OpConstantTrue %bool
1053010623%void = OpTypeVoid
0 commit comments