@@ -8106,6 +8106,133 @@ OpFunctionEnd
8106
8106
SinglePassRunAndCheck<AggressiveDCEPass>(text, text, true , true );
8107
8107
}
8108
8108
8109
+ TEST_F (AggressiveDCETest, MarkCentroidInterpolantLive) {
8110
+ const std::string spirv =
8111
+ R"( OpCapability InterpolationFunction
8112
+ OpCapability Shader
8113
+ %1 = OpExtInstImport "GLSL.std.450"
8114
+ OpMemoryModel Logical GLSL450
8115
+ OpEntryPoint Fragment %main "main" %in_var_COLOR %out_var_SV_Target
8116
+ OpExecutionMode %main OriginUpperLeft
8117
+ OpSource HLSL 680
8118
+ OpName %in_var_COLOR "in.var.COLOR"
8119
+ OpName %out_var_SV_Target "out.var.SV_Target"
8120
+ OpName %main "main"
8121
+ OpName %param_var_p1 "param.var.p1"
8122
+ OpDecorate %in_var_COLOR Location 0
8123
+ OpDecorate %out_var_SV_Target Location 0
8124
+ %float = OpTypeFloat 32
8125
+ %v4float = OpTypeVector %float 4
8126
+ %_ptr_Input_v4float = OpTypePointer Input %v4float
8127
+ %_ptr_Output_v4float = OpTypePointer Output %v4float
8128
+ %void = OpTypeVoid
8129
+ %11 = OpTypeFunction %void
8130
+ %_ptr_Function_v4float = OpTypePointer Function %v4float
8131
+ %in_var_COLOR = OpVariable %_ptr_Input_v4float Input
8132
+ %out_var_SV_Target = OpVariable %_ptr_Output_v4float Output
8133
+ %main = OpFunction %void None %11
8134
+ %13 = OpLabel
8135
+ %14 = OpVariable %_ptr_Function_v4float Function
8136
+ %param_var_p1 = OpVariable %_ptr_Function_v4float Function
8137
+ %15 = OpLoad %v4float %in_var_COLOR
8138
+ OpStore %param_var_p1 %15
8139
+ %16 = OpExtInst %v4float %1 InterpolateAtCentroid %param_var_p1
8140
+ OpStore %14 %16
8141
+ %17 = OpLoad %v4float %14
8142
+ OpStore %out_var_SV_Target %17
8143
+ OpReturn
8144
+ OpFunctionEnd
8145
+ )" ;
8146
+
8147
+ SinglePassRunAndCheck<AggressiveDCEPass>(spirv, spirv, true , false );
8148
+ }
8149
+
8150
+ TEST_F (AggressiveDCETest, MarkSampleInterpolantLive) {
8151
+ const std::string spirv =
8152
+ R"( OpCapability InterpolationFunction
8153
+ OpCapability Shader
8154
+ %1 = OpExtInstImport "GLSL.std.450"
8155
+ OpMemoryModel Logical GLSL450
8156
+ OpEntryPoint Fragment %main "main" %in_var_COLOR %out_var_SV_Target
8157
+ OpExecutionMode %main OriginUpperLeft
8158
+ OpSource HLSL 680
8159
+ OpName %in_var_COLOR "in.var.COLOR"
8160
+ OpName %out_var_SV_Target "out.var.SV_Target"
8161
+ OpName %main "main"
8162
+ OpName %param_var_p1 "param.var.p1"
8163
+ OpDecorate %in_var_COLOR Location 0
8164
+ OpDecorate %out_var_SV_Target Location 0
8165
+ %float = OpTypeFloat 32
8166
+ %int = OpTypeInt 32 1
8167
+ %v4float = OpTypeVector %float 4
8168
+ %_ptr_Input_v4float = OpTypePointer Input %v4float
8169
+ %_ptr_Output_v4float = OpTypePointer Output %v4float
8170
+ %void = OpTypeVoid
8171
+ %12 = OpTypeFunction %void
8172
+ %_ptr_Function_v4float = OpTypePointer Function %v4float
8173
+ %in_var_COLOR = OpVariable %_ptr_Input_v4float Input
8174
+ %out_var_SV_Target = OpVariable %_ptr_Output_v4float Output
8175
+ %int_123 = OpConstant %int 123
8176
+ %main = OpFunction %void None %12
8177
+ %15 = OpLabel
8178
+ %16 = OpVariable %_ptr_Function_v4float Function
8179
+ %param_var_p1 = OpVariable %_ptr_Function_v4float Function
8180
+ %17 = OpLoad %v4float %in_var_COLOR
8181
+ OpStore %param_var_p1 %17
8182
+ %18 = OpExtInst %v4float %1 InterpolateAtSample %param_var_p1 %int_123
8183
+ OpStore %16 %18
8184
+ %19 = OpLoad %v4float %16
8185
+ OpStore %out_var_SV_Target %19
8186
+ OpReturn
8187
+ OpFunctionEnd
8188
+ )" ;
8189
+
8190
+ SinglePassRunAndCheck<AggressiveDCEPass>(spirv, spirv, true , false );
8191
+ }
8192
+
8193
+ TEST_F (AggressiveDCETest, MarkOffsetInterpolantLive) {
8194
+ const std::string spirv =
8195
+ R"( OpCapability InterpolationFunction
8196
+ OpCapability Shader
8197
+ %1 = OpExtInstImport "GLSL.std.450"
8198
+ OpMemoryModel Logical GLSL450
8199
+ OpEntryPoint Fragment %main "main" %in_var_COLOR %out_var_SV_Target
8200
+ OpExecutionMode %main OriginUpperLeft
8201
+ OpSource HLSL 680
8202
+ OpName %in_var_COLOR "in.var.COLOR"
8203
+ OpName %out_var_SV_Target "out.var.SV_Target"
8204
+ OpName %main "main"
8205
+ OpName %param_var_p1 "param.var.p1"
8206
+ OpDecorate %in_var_COLOR Location 0
8207
+ OpDecorate %out_var_SV_Target Location 0
8208
+ %float = OpTypeFloat 32
8209
+ %int = OpTypeInt 32 1
8210
+ %v4float = OpTypeVector %float 4
8211
+ %_ptr_Input_v4float = OpTypePointer Input %v4float
8212
+ %_ptr_Output_v4float = OpTypePointer Output %v4float
8213
+ %void = OpTypeVoid
8214
+ %12 = OpTypeFunction %void
8215
+ %_ptr_Function_v4float = OpTypePointer Function %v4float
8216
+ %in_var_COLOR = OpVariable %_ptr_Input_v4float Input
8217
+ %out_var_SV_Target = OpVariable %_ptr_Output_v4float Output
8218
+ %int_123 = OpConstant %int 123
8219
+ %main = OpFunction %void None %12
8220
+ %15 = OpLabel
8221
+ %16 = OpVariable %_ptr_Function_v4float Function
8222
+ %param_var_p1 = OpVariable %_ptr_Function_v4float Function
8223
+ %17 = OpLoad %v4float %in_var_COLOR
8224
+ OpStore %param_var_p1 %17
8225
+ %18 = OpExtInst %v4float %1 InterpolateAtOffset %param_var_p1 %int_123
8226
+ OpStore %16 %18
8227
+ %19 = OpLoad %v4float %16
8228
+ OpStore %out_var_SV_Target %19
8229
+ OpReturn
8230
+ OpFunctionEnd
8231
+ )" ;
8232
+
8233
+ SinglePassRunAndCheck<AggressiveDCEPass>(spirv, spirv, true , false );
8234
+ }
8235
+
8109
8236
} // namespace
8110
8237
} // namespace opt
8111
8238
} // namespace spvtools
0 commit comments