@@ -2366,6 +2366,94 @@ TEST_F(TrimCapabilitiesPassTest,
2366
2366
EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithChange);
2367
2367
}
2368
2368
2369
+ TEST_F (TrimCapabilitiesPassTest,
2370
+ StorageImageWriteWithoutFormat_RemainsWhenRequiredWithWrite) {
2371
+ const std::string kTest = R"(
2372
+ OpCapability StorageImageWriteWithoutFormat
2373
+ ; CHECK: OpCapability StorageImageWriteWithoutFormat
2374
+ OpCapability Shader
2375
+ OpCapability StorageImageExtendedFormats
2376
+ OpMemoryModel Logical GLSL450
2377
+ OpEntryPoint GLCompute %main "main" %id %img
2378
+ OpExecutionMode %main LocalSize 8 8 8
2379
+ OpSource HLSL 670
2380
+ OpName %type_image "type.3d.image"
2381
+ OpName %img "img"
2382
+ OpName %main "main"
2383
+ OpDecorate %id BuiltIn GlobalInvocationId
2384
+ OpDecorate %img DescriptorSet 0
2385
+ OpDecorate %img Binding 0
2386
+ %float = OpTypeFloat 32
2387
+ %float_4 = OpConstant %float 4
2388
+ %float_5 = OpConstant %float 5
2389
+ %v2float = OpTypeVector %float 2
2390
+ %9 = OpConstantComposite %v2float %float_4 %float_5
2391
+ %type_image = OpTypeImage %float 3D 2 0 0 2 Unknown
2392
+ %ptr_img = OpTypePointer UniformConstant %type_image
2393
+ %uint = OpTypeInt 32 0
2394
+ %v3uint = OpTypeVector %uint 3
2395
+ %ptr_input = OpTypePointer Input %v3uint
2396
+ %void = OpTypeVoid
2397
+ %15 = OpTypeFunction %void
2398
+ %img = OpVariable %ptr_img UniformConstant
2399
+ %id = OpVariable %ptr_input Input
2400
+ %main = OpFunction %void None %15
2401
+ %16 = OpLabel
2402
+ %17 = OpLoad %v3uint %id
2403
+ %18 = OpLoad %type_image %img
2404
+ OpImageWrite %18 %17 %9 None
2405
+ OpReturn
2406
+ OpFunctionEnd
2407
+ )" ;
2408
+ const auto result =
2409
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2410
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithoutChange);
2411
+ }
2412
+
2413
+ TEST_F (TrimCapabilitiesPassTest,
2414
+ StorageImageWriteWithoutFormat_RemovedWithWriteOnKnownFormat) {
2415
+ const std::string kTest = R"(
2416
+ OpCapability StorageImageWriteWithoutFormat
2417
+ ; CHECK-NOT: OpCapability StorageImageWriteWithoutFormat
2418
+ OpCapability Shader
2419
+ OpCapability StorageImageExtendedFormats
2420
+ OpMemoryModel Logical GLSL450
2421
+ OpEntryPoint GLCompute %main "main" %id %img
2422
+ OpExecutionMode %main LocalSize 8 8 8
2423
+ OpSource HLSL 670
2424
+ OpName %type_image "type.3d.image"
2425
+ OpName %img "img"
2426
+ OpName %main "main"
2427
+ OpDecorate %id BuiltIn GlobalInvocationId
2428
+ OpDecorate %img DescriptorSet 0
2429
+ OpDecorate %img Binding 0
2430
+ %float = OpTypeFloat 32
2431
+ %float_4 = OpConstant %float 4
2432
+ %float_5 = OpConstant %float 5
2433
+ %v2float = OpTypeVector %float 2
2434
+ %9 = OpConstantComposite %v2float %float_4 %float_5
2435
+ %type_image = OpTypeImage %float 3D 2 0 0 2 Rg32f
2436
+ %ptr_img = OpTypePointer UniformConstant %type_image
2437
+ %uint = OpTypeInt 32 0
2438
+ %v3uint = OpTypeVector %uint 3
2439
+ %ptr_input = OpTypePointer Input %v3uint
2440
+ %void = OpTypeVoid
2441
+ %15 = OpTypeFunction %void
2442
+ %img = OpVariable %ptr_img UniformConstant
2443
+ %id = OpVariable %ptr_input Input
2444
+ %main = OpFunction %void None %15
2445
+ %16 = OpLabel
2446
+ %17 = OpLoad %v3uint %id
2447
+ %18 = OpLoad %type_image %img
2448
+ OpImageWrite %18 %17 %9 None
2449
+ OpReturn
2450
+ OpFunctionEnd
2451
+ )" ;
2452
+ const auto result =
2453
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2454
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithChange);
2455
+ }
2456
+
2369
2457
TEST_F (TrimCapabilitiesPassTest, PhysicalStorageBuffer_RemovedWhenUnused) {
2370
2458
const std::string kTest = R"(
2371
2459
OpCapability PhysicalStorageBufferAddresses
0 commit comments