@@ -132,6 +132,134 @@ TEST_F(ValidateExtensionCapabilities, DeclCapabilityFailure) {
132
132
EXPECT_THAT (getDiagnosticString (), HasSubstr (" SPV_KHR_device_group" ));
133
133
}
134
134
135
+ TEST_F (ValidateExtensionCapabilities, SpirvVersionImageProcessingQCOM) {
136
+ const std::string str = R"(
137
+ OpCapability Shader
138
+ OpCapability TextureBlockMatch2QCOM
139
+ OpExtension "SPV_QCOM_image_processing"
140
+ OpExtension "SPV_QCOM_image_processing2"
141
+ %1 = OpExtInstImport "GLSL.std.450"
142
+ OpMemoryModel Logical GLSL450
143
+ OpEntryPoint Fragment %main "main" %v_texcoord %fragColor %target_samp %ref_samp
144
+ OpExecutionMode %main OriginUpperLeft
145
+ OpSource GLSL 450
146
+ OpSourceExtension "GL_QCOM_image_processing"
147
+ OpSourceExtension "GL_QCOM_image_processing2"
148
+ OpDecorate %v_texcoord Location 0
149
+ OpDecorate %fragColor Location 0
150
+ OpDecorate %target_samp DescriptorSet 0
151
+ OpDecorate %target_samp Binding 4
152
+ OpDecorate %ref_samp DescriptorSet 0
153
+ OpDecorate %ref_samp Binding 5
154
+ OpDecorate %target_samp BlockMatchTextureQCOM
155
+ OpDecorate %target_samp BlockMatchSamplerQCOM
156
+ OpDecorate %ref_samp BlockMatchTextureQCOM
157
+ OpDecorate %ref_samp BlockMatchSamplerQCOM
158
+ %void = OpTypeVoid
159
+ %3 = OpTypeFunction %void
160
+ %uint = OpTypeInt 32 0
161
+ %v2uint = OpTypeVector %uint 2
162
+ %_ptr_Function_v2uint = OpTypePointer Function %v2uint
163
+ %float = OpTypeFloat 32
164
+ %v4float = OpTypeVector %float 4
165
+ %_ptr_Input_v4float = OpTypePointer Input %v4float
166
+ %v_texcoord = OpVariable %_ptr_Input_v4float Input
167
+ %uint_0 = OpConstant %uint 0
168
+ %_ptr_Input_float = OpTypePointer Input %float
169
+ %_ptr_Function_uint = OpTypePointer Function %uint
170
+ %uint_1 = OpConstant %uint 1
171
+ %uint_2 = OpConstant %uint 2
172
+ %uint_3 = OpConstant %uint 3
173
+ %uint_4 = OpConstant %uint 4
174
+ %39 = OpConstantComposite %v2uint %uint_4 %uint_4
175
+ %_ptr_Output_v4float = OpTypePointer Output %v4float
176
+ %fragColor = OpVariable %_ptr_Output_v4float Output
177
+ %42 = OpTypeImage %float 2D 0 0 0 1 Unknown
178
+ %43 = OpTypeSampledImage %42
179
+ %_ptr_UniformConstant_43 = OpTypePointer UniformConstant %43
180
+ %target_samp = OpVariable %_ptr_UniformConstant_43 UniformConstant
181
+ %ref_samp = OpVariable %_ptr_UniformConstant_43 UniformConstant
182
+ %main = OpFunction %void None %3
183
+ %5 = OpLabel
184
+ %tgt_coords = OpVariable %_ptr_Function_v2uint Function
185
+ %ref_coords = OpVariable %_ptr_Function_v2uint Function
186
+ %blockSize = OpVariable %_ptr_Function_v2uint Function
187
+ %16 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_0
188
+ %17 = OpLoad %float %16
189
+ %18 = OpConvertFToU %uint %17
190
+ %20 = OpAccessChain %_ptr_Function_uint %tgt_coords %uint_0
191
+ OpStore %20 %18
192
+ %22 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_1
193
+ %23 = OpLoad %float %22
194
+ %24 = OpConvertFToU %uint %23
195
+ %25 = OpAccessChain %_ptr_Function_uint %tgt_coords %uint_0
196
+ OpStore %25 %24
197
+ %28 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_2
198
+ %29 = OpLoad %float %28
199
+ %30 = OpConvertFToU %uint %29
200
+ %31 = OpAccessChain %_ptr_Function_uint %ref_coords %uint_0
201
+ OpStore %31 %30
202
+ %33 = OpAccessChain %_ptr_Input_float %v_texcoord %uint_3
203
+ %34 = OpLoad %float %33
204
+ %35 = OpConvertFToU %uint %34
205
+ %36 = OpAccessChain %_ptr_Function_uint %ref_coords %uint_1
206
+ OpStore %36 %35
207
+ OpStore %blockSize %39
208
+ %46 = OpLoad %43 %target_samp
209
+ %47 = OpLoad %v2uint %tgt_coords
210
+ %49 = OpLoad %43 %ref_samp
211
+ %50 = OpLoad %v2uint %ref_coords
212
+ %51 = OpLoad %v2uint %blockSize
213
+ %52 = OpImageBlockMatchWindowSADQCOM %v4float %46 %47 %49 %50 %51
214
+ OpStore %fragColor %52
215
+ OpReturn
216
+ OpFunctionEnd
217
+ )" ;
218
+ CompileSuccessfully (str.c_str (), SPV_ENV_UNIVERSAL_1_3);
219
+ ASSERT_EQ (SPV_ERROR_WRONG_VERSION,
220
+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_3));
221
+ EXPECT_THAT (getDiagnosticString (),
222
+ HasSubstr (" SPV_QCOM_image_processing extension requires SPIR-V "
223
+ " version 1.4 or later." ));
224
+ }
225
+
226
+ TEST_F (ValidateExtensionCapabilities, SpirvVersionCoopMatConversionQCOM) {
227
+ const std::string body = R"(
228
+ OpCapability Shader
229
+ OpCapability Float16
230
+ OpCapability CooperativeMatrixKHR
231
+ OpCapability VulkanMemoryModelKHR
232
+ OpCapability CooperativeMatrixConversionQCOM
233
+ OpExtension "SPV_KHR_cooperative_matrix"
234
+ OpExtension "SPV_KHR_vulkan_memory_model"
235
+ OpExtension "SPV_QCOM_cooperative_matrix_conversion"
236
+ OpMemoryModel Logical VulkanKHR
237
+ OpEntryPoint GLCompute %main "main"
238
+ %void = OpTypeVoid
239
+ %3 = OpTypeFunction %void
240
+ %uint = OpTypeInt 32 0
241
+ %f16 = OpTypeFloat 16
242
+ %uint_0 = OpConstant %uint 0
243
+ %uint_8 = OpConstant %uint 8
244
+ %uint_64 = OpConstant %uint 64
245
+ %_arr_f16_uint_8 = OpTypeArray %f16 %uint_8
246
+ %_arr_f16_uint_64 = OpTypeArray %f16 %uint_64
247
+ %_ptr_Function__arr_f16_uint_64 = OpTypePointer Function %_arr_f16_uint_64
248
+ %main = OpFunction %void None %3
249
+ %5 = OpLabel
250
+ %f16vec64Acc = OpVariable %_ptr_Function__arr_f16_uint_64 Function
251
+ %83 = OpLoad %_arr_f16_uint_64 %f16vec64Acc
252
+ %86 = OpExtractSubArrayQCOM %_arr_f16_uint_8 %83 %uint_0
253
+ OpReturn
254
+ OpFunctionEnd)" ;
255
+
256
+ CompileSuccessfully (body.c_str ());
257
+ ASSERT_EQ (SPV_ERROR_WRONG_VERSION, ValidateInstructions ());
258
+ EXPECT_THAT (getDiagnosticString (),
259
+ HasSubstr (" SPV_KHR_vulkan_memory_model extension requires SPIR-V "
260
+ " version 1.3 or later." ));
261
+ }
262
+
135
263
TEST_F (ValidateExtensionCapabilities,
136
264
DeclCapabilityFailureBlockMatchWIndowSAD) {
137
265
const std::string str = R"(
@@ -223,8 +351,9 @@ TEST_F(ValidateExtensionCapabilities,
223
351
OpReturn
224
352
OpFunctionEnd
225
353
)" ;
226
- CompileSuccessfully (str.c_str ());
227
- ASSERT_EQ (SPV_ERROR_MISSING_EXTENSION, ValidateInstructions ());
354
+ CompileSuccessfully (str.c_str (), SPV_ENV_UNIVERSAL_1_4);
355
+ ASSERT_EQ (SPV_ERROR_MISSING_EXTENSION,
356
+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_4));
228
357
EXPECT_THAT (getDiagnosticString (), HasSubstr (" 2nd operand of Decorate" ));
229
358
EXPECT_THAT (getDiagnosticString (),
230
359
HasSubstr (" requires one of these extensions" ));
@@ -332,8 +461,9 @@ TEST_F(ValidateExtensionCapabilities,
332
461
OpReturn
333
462
OpFunctionEnd
334
463
)" ;
335
- CompileSuccessfully (str.c_str ());
336
- ASSERT_EQ (SPV_ERROR_MISSING_EXTENSION, ValidateInstructions ());
464
+ CompileSuccessfully (str.c_str (), SPV_ENV_UNIVERSAL_1_4);
465
+ ASSERT_EQ (SPV_ERROR_MISSING_EXTENSION,
466
+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_4));
337
467
EXPECT_THAT (getDiagnosticString (), HasSubstr (" 2nd operand of Decorate" ));
338
468
EXPECT_THAT (getDiagnosticString (),
339
469
HasSubstr (" requires one of these extensions" ));
@@ -482,7 +612,8 @@ TEST_P(ValidateExtIntoCore, DoNotAskForExtensionInLaterVersion) {
482
612
GetParam ().cap + R"(
483
613
OpMemoryModel Logical GLSL450
484
614
OpEntryPoint Vertex %main "main" %builtin
485
- OpDecorate %builtin BuiltIn )" + GetParam ().builtin + R"(
615
+ OpDecorate %builtin BuiltIn )" +
616
+ GetParam ().builtin + R"(
486
617
%void = OpTypeVoid
487
618
%3 = OpTypeFunction %void
488
619
%int = OpTypeInt 32 1
0 commit comments