@@ -3635,6 +3635,148 @@ TEST_F(TrimCapabilitiesPassTest, PhysicalStorageBuffer_RecursiveTypes) {
3635
3635
EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithoutChange);
3636
3636
}
3637
3637
3638
+ TEST_F (TrimCapabilitiesPassTest, Geometry_Remains) {
3639
+ const std::string kTest = R"(
3640
+ OpCapability Geometry
3641
+ ; CHECK: OpCapability Geometry
3642
+ OpMemoryModel Logical GLSL450
3643
+ OpEntryPoint Geometry %gs_main "gs_main" %gl_Position
3644
+ OpExecutionMode %gs_main OutputVertices 3
3645
+ OpExecutionMode %gs_main Invocations 1
3646
+ OpExecutionMode %gs_main Triangles
3647
+ OpExecutionMode %gs_main OutputTriangleStrip
3648
+ OpSource HLSL 660
3649
+ OpName %gs_main "gs_main"
3650
+ OpDecorate %gl_Position BuiltIn Position
3651
+ %float = OpTypeFloat 32
3652
+ %v4float = OpTypeVector %float 4
3653
+ %_ptr_Output_v4float = OpTypePointer Output %v4float
3654
+ %void = OpTypeVoid
3655
+ %7 = OpTypeFunction %void
3656
+ %gl_Position = OpVariable %_ptr_Output_v4float Output
3657
+ %gs_main = OpFunction %void None %7
3658
+ %8 = OpLabel
3659
+ OpEmitVertex
3660
+ OpReturn
3661
+ OpFunctionEnd
3662
+ )" ;
3663
+ const auto result =
3664
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
3665
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithoutChange);
3666
+ }
3667
+
3668
+ // FIXME(6277): enable once spirv-opt supports SPV_INTEL_function_variants
3669
+ #if 0
3670
+ TEST_F(TrimCapabilitiesPassTest, Geometry_RemainsIntel) {
3671
+ const std::string kTest = R"(
3672
+ OpCapability Geometry
3673
+ ; CHECK: OpCapability Geometry
3674
+ OpCapability SpecConditionalINTEL
3675
+ OpExtension "SPV_INTEL_function_variants"
3676
+ OpMemoryModel Logical GLSL450
3677
+ OpConditionalEntryPointINTEL %false Geometry %gs_main "gs_main"
3678
+ OpExecutionMode %gs_main OutputVertices 3
3679
+ OpExecutionMode %gs_main Invocations 1
3680
+ OpExecutionMode %gs_main Triangles
3681
+ OpExecutionMode %gs_main OutputTriangleStrip
3682
+ OpSource HLSL 660
3683
+ OpName %gs_main "gs_main"
3684
+ OpDecorate %gl_Position BuiltIn Position
3685
+ %bool = OpTypeBool
3686
+ %false = OpSpecConstantFalse %bool
3687
+ %float = OpTypeFloat 32
3688
+ %v4float = OpTypeVector %float 4
3689
+ %_ptr_Output_v4float = OpTypePointer Output %v4float
3690
+ %void = OpTypeVoid
3691
+ %7 = OpTypeFunction %void
3692
+ %gl_Position = OpVariable %_ptr_Output_v4float Output
3693
+ %gs_main = OpFunction %void None %7
3694
+ %8 = OpLabel
3695
+ OpEmitVertex
3696
+ OpReturn
3697
+ OpFunctionEnd
3698
+ )";
3699
+ const auto result =
3700
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest, /* skip_nop= */ false);
3701
+ EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange);
3702
+ }
3703
+ #endif
3704
+
3705
+ TEST_F (TrimCapabilitiesPassTest, Geometry_Removed) {
3706
+ const std::string kTest = R"(
3707
+ OpCapability Shader
3708
+ OpCapability Geometry
3709
+ ; CHECK-NOT: OpCapability Geometry
3710
+ OpMemoryModel Logical GLSL450
3711
+ OpEntryPoint Fragment %ps_main "ps_main" %in_var_POSITION %out_var_SV_Target
3712
+ OpExecutionMode %ps_main OriginUpperLeft
3713
+ OpSource HLSL 660
3714
+ OpName %in_var_POSITION "in.var.POSITION"
3715
+ OpName %out_var_SV_Target "out.var.SV_Target"
3716
+ OpName %ps_main "ps_main"
3717
+ OpDecorate %in_var_POSITION Location 0
3718
+ OpDecorate %out_var_SV_Target Location 0
3719
+ %float = OpTypeFloat 32
3720
+ %v4float = OpTypeVector %float 4
3721
+ %_ptr_Input_v4float = OpTypePointer Input %v4float
3722
+ %_ptr_Output_v4float = OpTypePointer Output %v4float
3723
+ %void = OpTypeVoid
3724
+ %9 = OpTypeFunction %void
3725
+ %in_var_POSITION = OpVariable %_ptr_Input_v4float Input
3726
+ %out_var_SV_Target = OpVariable %_ptr_Output_v4float Output
3727
+ %ps_main = OpFunction %void None %9
3728
+ %10 = OpLabel
3729
+ %11 = OpLoad %v4float %in_var_POSITION
3730
+ OpStore %out_var_SV_Target %11
3731
+ OpReturn
3732
+ OpFunctionEnd
3733
+ )" ;
3734
+ const auto result =
3735
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
3736
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithChange);
3737
+ }
3738
+
3739
+ // FIXME(6277): enable once spirv-opt supports SPV_INTEL_function_variants
3740
+ #if 0
3741
+ TEST_F(TrimCapabilitiesPassTest, Geometry_RemovedIntel) {
3742
+ const std::string kTest = R"(
3743
+ OpCapability Shader
3744
+ OpCapability Geometry
3745
+ ; CHECK-NOT: OpCapability Geometry
3746
+ OpCapability SpecConditionalINTEL
3747
+ OpExtension "SPV_INTEL_function_variants"
3748
+ OpMemoryModel Logical GLSL450
3749
+ OpConditionalEntryPointINTEL %false Fragment %ps_main "ps_main" %in_var_POSITION %out_var_SV_Target
3750
+ OpExecutionMode %ps_main OriginUpperLeft
3751
+ OpSource HLSL 660
3752
+ OpName %in_var_POSITION "in.var.POSITION"
3753
+ OpName %out_var_SV_Target "out.var.SV_Target"
3754
+ OpName %ps_main "ps_main"
3755
+ OpDecorate %in_var_POSITION Location 0
3756
+ OpDecorate %out_var_SV_Target Location 0
3757
+ %bool = OpTypeBool
3758
+ %false = OpSpecConstantFalse %bool
3759
+ %float = OpTypeFloat 32
3760
+ %v4float = OpTypeVector %float 4
3761
+ %_ptr_Input_v4float = OpTypePointer Input %v4float
3762
+ %_ptr_Output_v4float = OpTypePointer Output %v4float
3763
+ %void = OpTypeVoid
3764
+ %9 = OpTypeFunction %void
3765
+ %in_var_POSITION = OpVariable %_ptr_Input_v4float Input
3766
+ %out_var_SV_Target = OpVariable %_ptr_Output_v4float Output
3767
+ %ps_main = OpFunction %void None %9
3768
+ %10 = OpLabel
3769
+ %11 = OpLoad %v4float %in_var_POSITION
3770
+ OpStore %out_var_SV_Target %11
3771
+ OpReturn
3772
+ OpFunctionEnd
3773
+ )";
3774
+ const auto result =
3775
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest, /* skip_nop= */ false);
3776
+ EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
3777
+ }
3778
+ #endif
3779
+
3638
3780
INSTANTIATE_TEST_SUITE_P (
3639
3781
TrimCapabilitiesPassTestSubgroupClustered_Unsigned_I,
3640
3782
TrimCapabilitiesPassTestSubgroupClustered_Unsigned,
0 commit comments