1 // GENERATED FILE - DO NOT EDIT.
2 // Generated by generate_tests.py
3 //
4 // Copyright (c) 2022 Google LLC.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17
18 #include "../diff_test_utils.h"
19
20 #include "gtest/gtest.h"
21
22 namespace spvtools {
23 namespace diff {
24 namespace {
25
26 // Tests OpSpecConstantComposite matching.
27 constexpr char kSrc[] = R"( OpCapability Shader
28 OpMemoryModel Logical GLSL450
29 OpEntryPoint GLCompute %main "main"
30 OpExecutionMode %main LocalSize 1 1 1
31 OpDecorate %sc SpecId 0
32 %void = OpTypeVoid
33 %3 = OpTypeFunction %void
34 %uint = OpTypeInt 32 0
35 %v3uint = OpTypeVector %uint 3
36 %sc = OpSpecConstant %uint 10
37 %main = OpFunction %void None %3
38 %5 = OpLabel
39 OpReturn
40 OpFunctionEnd)";
41 constexpr char kDst[] = R"( OpCapability Shader
42 OpMemoryModel Logical GLSL450
43 OpEntryPoint GLCompute %main "main"
44 OpExecutionMode %main LocalSize 1 1 1
45 %void = OpTypeVoid
46 %3 = OpTypeFunction %void
47 %uint = OpTypeInt 32 0
48 %v3uint = OpTypeVector %uint 3
49 %ss = OpSpecConstant %uint 10
50 %main = OpFunction %void None %3
51 %5 = OpLabel
52 OpReturn
53 OpFunctionEnd
54 )";
55
TEST(DiffTest,SpecConstantSpecid)56 TEST(DiffTest, SpecConstantSpecid) {
57 constexpr char kDiff[] = R"( ; SPIR-V
58 ; Version: 1.6
59 ; Generator: Khronos SPIR-V Tools Assembler; 0
60 -; Bound: 8
61 +; Bound: 9
62 ; Schema: 0
63 OpCapability Shader
64 OpMemoryModel Logical GLSL450
65 OpEntryPoint GLCompute %1 "main"
66 OpExecutionMode %1 LocalSize 1 1 1
67 -OpDecorate %2 SpecId 0
68 %4 = OpTypeVoid
69 %3 = OpTypeFunction %4
70 %6 = OpTypeInt 32 0
71 %7 = OpTypeVector %6 3
72 -%2 = OpSpecConstant %6 10
73 +%8 = OpSpecConstant %6 10
74 %1 = OpFunction %4 None %3
75 %5 = OpLabel
76 OpReturn
77 OpFunctionEnd
78 )";
79 Options options;
80 DoStringDiffTest(kSrc, kDst, kDiff, options);
81 }
82
TEST(DiffTest,SpecConstantSpecidNoDebug)83 TEST(DiffTest, SpecConstantSpecidNoDebug) {
84 constexpr char kSrcNoDebug[] = R"( OpCapability Shader
85 OpMemoryModel Logical GLSL450
86 OpEntryPoint GLCompute %main "main"
87 OpExecutionMode %main LocalSize 1 1 1
88 OpDecorate %sc SpecId 0
89 %void = OpTypeVoid
90 %3 = OpTypeFunction %void
91 %uint = OpTypeInt 32 0
92 %v3uint = OpTypeVector %uint 3
93 %sc = OpSpecConstant %uint 10
94 %main = OpFunction %void None %3
95 %5 = OpLabel
96 OpReturn
97 OpFunctionEnd
98 )";
99 constexpr char kDstNoDebug[] = R"( OpCapability Shader
100 OpMemoryModel Logical GLSL450
101 OpEntryPoint GLCompute %main "main"
102 OpExecutionMode %main LocalSize 1 1 1
103 %void = OpTypeVoid
104 %3 = OpTypeFunction %void
105 %uint = OpTypeInt 32 0
106 %v3uint = OpTypeVector %uint 3
107 %ss = OpSpecConstant %uint 10
108 %main = OpFunction %void None %3
109 %5 = OpLabel
110 OpReturn
111 OpFunctionEnd
112 )";
113 constexpr char kDiff[] = R"( ; SPIR-V
114 ; Version: 1.6
115 ; Generator: Khronos SPIR-V Tools Assembler; 0
116 -; Bound: 8
117 +; Bound: 9
118 ; Schema: 0
119 OpCapability Shader
120 OpMemoryModel Logical GLSL450
121 OpEntryPoint GLCompute %1 "main"
122 OpExecutionMode %1 LocalSize 1 1 1
123 -OpDecorate %2 SpecId 0
124 %4 = OpTypeVoid
125 %3 = OpTypeFunction %4
126 %6 = OpTypeInt 32 0
127 %7 = OpTypeVector %6 3
128 -%2 = OpSpecConstant %6 10
129 +%8 = OpSpecConstant %6 10
130 %1 = OpFunction %4 None %3
131 %5 = OpLabel
132 OpReturn
133 OpFunctionEnd
134 )";
135 Options options;
136 DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
137 }
138
139 } // namespace
140 } // namespace diff
141 } // namespace spvtools
142