| 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 |
%1 = OpExtInstImport "GLSL.std.450" |
| 29 |
OpMemoryModel Logical GLSL450 |
| 30 |
OpEntryPoint GLCompute %main "main" |
| 31 |
OpExecutionMode %main LocalSize 1 1 1 |
| 32 |
OpSource GLSL 450 |
| 33 |
OpName %main "main" |
| 34 |
OpDecorate %7 SpecId 3 |
| 35 |
OpDecorate %8 SpecId 4 |
| 36 |
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize |
| 37 |
%void = OpTypeVoid |
| 38 |
%3 = OpTypeFunction %void |
| 39 |
%uint = OpTypeInt 32 0 |
| 40 |
%7 = OpSpecConstant %uint 1 |
| 41 |
%8 = OpSpecConstant %uint 1 |
| 42 |
%uint_1 = OpConstant %uint 1 |
| 43 |
%v3uint = OpTypeVector %uint 3 |
| 44 |
%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 |
| 45 |
%main = OpFunction %void None %3 |
| 46 |
%5 = OpLabel |
| 47 |
OpReturn |
| 48 |
OpFunctionEnd)"; |
| 49 |
constexpr char kDst[] = R"( OpCapability Shader |
| 50 |
%1 = OpExtInstImport "GLSL.std.450" |
| 51 |
OpMemoryModel Logical GLSL450 |
| 52 |
OpEntryPoint GLCompute %main "main" |
| 53 |
OpExecutionMode %main LocalSize 1 1 1 |
| 54 |
OpSource GLSL 450 |
| 55 |
OpName %main "main" |
| 56 |
OpDecorate %7 SpecId 3 |
| 57 |
OpDecorate %8 SpecId 4 |
| 58 |
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize |
| 59 |
%void = OpTypeVoid |
| 60 |
%3 = OpTypeFunction %void |
| 61 |
%uint = OpTypeInt 32 0 |
| 62 |
%7 = OpSpecConstant %uint 2048 |
| 63 |
%8 = OpSpecConstant %uint 1 |
| 64 |
%uint_1 = OpConstant %uint 1 |
| 65 |
%v3uint = OpTypeVector %uint 3 |
| 66 |
%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 |
| 67 |
%main = OpFunction %void None %3 |
| 68 |
%5 = OpLabel |
| 69 |
OpReturn |
| 70 |
OpFunctionEnd |
| 71 |
)"; |
| 72 |
|
| 73 |
TEST(DiffTest, SpecConstantComposite) { |
| 74 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 75 |
; Version: 1.6 |
| 76 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 77 |
; Bound: 12 |
| 78 |
; Schema: 0 |
| 79 |
OpCapability Shader |
| 80 |
%1 = OpExtInstImport "GLSL.std.450" |
| 81 |
OpMemoryModel Logical GLSL450 |
| 82 |
OpEntryPoint GLCompute %2 "main" |
| 83 |
OpExecutionMode %2 LocalSize 1 1 1 |
| 84 |
OpSource GLSL 450 |
| 85 |
OpName %2 "main" |
| 86 |
OpDecorate %7 SpecId 3 |
| 87 |
OpDecorate %8 SpecId 4 |
| 88 |
OpDecorate %4 BuiltIn WorkgroupSize |
| 89 |
%6 = OpTypeVoid |
| 90 |
%3 = OpTypeFunction %6 |
| 91 |
%9 = OpTypeInt 32 0 |
| 92 |
-%7 = OpSpecConstant %9 1 |
| 93 |
+%7 = OpSpecConstant %9 2048 |
| 94 |
%8 = OpSpecConstant %9 1 |
| 95 |
%10 = OpConstant %9 1 |
| 96 |
%11 = OpTypeVector %9 3 |
| 97 |
%4 = OpSpecConstantComposite %11 %7 %8 %10 |
| 98 |
%2 = OpFunction %6 None %3 |
| 99 |
%5 = OpLabel |
| 100 |
OpReturn |
| 101 |
OpFunctionEnd |
| 102 |
)"; |
| 103 |
Options options; |
| 104 |
DoStringDiffTest(kSrc, kDst, kDiff, options); |
| 105 |
} |
| 106 |
|
| 107 |
TEST(DiffTest, SpecConstantCompositeNoDebug) { |
| 108 |
constexpr char kSrcNoDebug[] = R"( OpCapability Shader |
| 109 |
%1 = OpExtInstImport "GLSL.std.450" |
| 110 |
OpMemoryModel Logical GLSL450 |
| 111 |
OpEntryPoint GLCompute %main "main" |
| 112 |
OpExecutionMode %main LocalSize 1 1 1 |
| 113 |
OpSource GLSL 450 |
| 114 |
OpDecorate %7 SpecId 3 |
| 115 |
OpDecorate %8 SpecId 4 |
| 116 |
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize |
| 117 |
%void = OpTypeVoid |
| 118 |
%3 = OpTypeFunction %void |
| 119 |
%uint = OpTypeInt 32 0 |
| 120 |
%7 = OpSpecConstant %uint 1 |
| 121 |
%8 = OpSpecConstant %uint 1 |
| 122 |
%uint_1 = OpConstant %uint 1 |
| 123 |
%v3uint = OpTypeVector %uint 3 |
| 124 |
%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 |
| 125 |
%main = OpFunction %void None %3 |
| 126 |
%5 = OpLabel |
| 127 |
OpReturn |
| 128 |
OpFunctionEnd |
| 129 |
)"; |
| 130 |
constexpr char kDstNoDebug[] = R"( OpCapability Shader |
| 131 |
%1 = OpExtInstImport "GLSL.std.450" |
| 132 |
OpMemoryModel Logical GLSL450 |
| 133 |
OpEntryPoint GLCompute %main "main" |
| 134 |
OpExecutionMode %main LocalSize 1 1 1 |
| 135 |
OpSource GLSL 450 |
| 136 |
OpDecorate %7 SpecId 3 |
| 137 |
OpDecorate %8 SpecId 4 |
| 138 |
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize |
| 139 |
%void = OpTypeVoid |
| 140 |
%3 = OpTypeFunction %void |
| 141 |
%uint = OpTypeInt 32 0 |
| 142 |
%7 = OpSpecConstant %uint 2048 |
| 143 |
%8 = OpSpecConstant %uint 1 |
| 144 |
%uint_1 = OpConstant %uint 1 |
| 145 |
%v3uint = OpTypeVector %uint 3 |
| 146 |
%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1 |
| 147 |
%main = OpFunction %void None %3 |
| 148 |
%5 = OpLabel |
| 149 |
OpReturn |
| 150 |
OpFunctionEnd |
| 151 |
)"; |
| 152 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 153 |
; Version: 1.6 |
| 154 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 155 |
; Bound: 12 |
| 156 |
; Schema: 0 |
| 157 |
OpCapability Shader |
| 158 |
%1 = OpExtInstImport "GLSL.std.450" |
| 159 |
OpMemoryModel Logical GLSL450 |
| 160 |
OpEntryPoint GLCompute %2 "main" |
| 161 |
OpExecutionMode %2 LocalSize 1 1 1 |
| 162 |
OpSource GLSL 450 |
| 163 |
OpDecorate %7 SpecId 3 |
| 164 |
OpDecorate %8 SpecId 4 |
| 165 |
OpDecorate %4 BuiltIn WorkgroupSize |
| 166 |
%6 = OpTypeVoid |
| 167 |
%3 = OpTypeFunction %6 |
| 168 |
%9 = OpTypeInt 32 0 |
| 169 |
-%7 = OpSpecConstant %9 1 |
| 170 |
+%7 = OpSpecConstant %9 2048 |
| 171 |
%8 = OpSpecConstant %9 1 |
| 172 |
%10 = OpConstant %9 1 |
| 173 |
%11 = OpTypeVector %9 3 |
| 174 |
%4 = OpSpecConstantComposite %11 %7 %8 %10 |
| 175 |
%2 = OpFunction %6 None %3 |
| 176 |
%5 = OpLabel |
| 177 |
OpReturn |
| 178 |
OpFunctionEnd |
| 179 |
)"; |
| 180 |
Options options; |
| 181 |
DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); |
| 182 |
} |
| 183 |
|
| 184 |
} // namespace |
| 185 |
} // namespace diff |
| 186 |
} // namespace spvtools |