@@ -5445,6 +5445,97 @@ OpFunctionEnd
5445
5445
EXPECT_EQ (SPV_SUCCESS, ValidateInstructions ());
5446
5446
}
5447
5447
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
+
5448
5539
// Uniform and UniformId decorations
5449
5540
5450
5541
TEST_F (ValidateDecorations, UniformDecorationGood) {
@@ -5486,17 +5577,19 @@ OpName %subgroupscope "subgroupscope"
5486
5577
OpName %call "call"
5487
5578
OpName %myfunc "myfunc"
5488
5579
OpName %int0 "int0"
5580
+ OpName %int1 "int1"
5489
5581
OpName %float0 "float0"
5490
5582
OpName %fn "fn"
5491
5583
)" ) + inst +
5492
5584
R"(
5493
5585
%void = OpTypeVoid
5494
5586
%float = OpTypeFloat 32
5495
5587
%int = OpTypeInt 32 1
5496
- %int0 = OpConstantNull %int
5588
+ %int1 = OpConstant %int 1
5497
5589
%int_99 = OpConstant %int 99
5498
5590
%subgroupscope = OpConstant %int 3
5499
5591
%float0 = OpConstantNull %float
5592
+ %int0 = OpConstantNull %int
5500
5593
%fn = OpTypeFunction %void
5501
5594
%myfunc = OpFunction %void None %fn
5502
5595
%myfuncentry = OpLabel
@@ -5613,7 +5706,7 @@ TEST_F(ValidateDecorations,
5613
5706
5614
5707
TEST_F (ValidateDecorations, UniformDecorationWithScopeIdV14VulkanEnv) {
5615
5708
const std::string spirv =
5616
- ShaderWithUniformLikeDecoration (" OpDecorateId %int0 UniformId %int0 " );
5709
+ ShaderWithUniformLikeDecoration (" OpDecorateId %int0 UniformId %int1 " );
5617
5710
5618
5711
CompileSuccessfully (spirv, SPV_ENV_VULKAN_1_1_SPIRV_1_4);
5619
5712
EXPECT_EQ (SPV_ERROR_INVALID_DATA,
@@ -10523,8 +10616,8 @@ const std::string kNodeShaderPostlude = R"(
10523
10616
%node1 = OpConstantStringAMDX "node1"
10524
10617
%node2 = OpConstantStringAMDX "node2"
10525
10618
%S = OpTypeStruct
10526
- %_payloadarr_S = OpTypeNodePayloadArrayAMDX %S
10527
10619
%_payloadarr_S_0 = OpTypeNodePayloadArrayAMDX %S
10620
+ %_payloadarr_S = OpTypeNodePayloadArrayAMDX %S
10528
10621
%bool = OpTypeBool
10529
10622
%true = OpConstantTrue %bool
10530
10623
%void = OpTypeVoid
0 commit comments