File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -360,6 +360,13 @@ void CCPPass::Initialize() {
360
360
}
361
361
}
362
362
363
+ // Mark the extended instruction imports as `kVarying`. We know they
364
+ // will not be constants, and will be used by `OpExtInst` instructions.
365
+ // This allows those instructions to be fully processed.
366
+ for (const auto & inst : get_module ()->ext_inst_imports ()) {
367
+ values_[inst.result_id ()] = kVaryingSSAId ;
368
+ }
369
+
363
370
original_id_bound_ = context ()->module ()->IdBound ();
364
371
}
365
372
Original file line number Diff line number Diff line change @@ -1237,6 +1237,34 @@ TEST_F(CCPTest, CCPNoChangeFailureWithUnfoldableInstr) {
1237
1237
EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithChange);
1238
1238
}
1239
1239
1240
+ TEST_F (CCPTest, CCPSuccessWithNoCCPOnExtendedInstruction) {
1241
+ // We don't expect to have Constant Propagation on certain
1242
+ // extended instructions with 16 bit integers. This is to
1243
+ // test that this stage doesn't throw errors. If we add support
1244
+ // for 16 bit integers, this test should change.
1245
+
1246
+ const std::string text = R"( OpCapability Shader
1247
+ OpCapability Float16
1248
+ %1 = OpExtInstImport "GLSL.std.450"
1249
+ OpMemoryModel Logical GLSL450
1250
+ OpEntryPoint Fragment %main "main"
1251
+ OpExecutionMode %main OriginUpperLeft
1252
+ OpSource GLSL 140
1253
+ OpName %main "main"
1254
+ %void = OpTypeVoid
1255
+ %half = OpTypeFloat 16
1256
+ %half_0x1p_0 = OpConstant %half 0x1p+0
1257
+ %6 = OpTypeFunction %void
1258
+ %main = OpFunction %void None %6
1259
+ %7 = OpLabel
1260
+ %8 = OpExtInst %half %1 Cos %half_0x1p_0
1261
+ OpReturn
1262
+ OpFunctionEnd
1263
+ )" ;
1264
+
1265
+ SinglePassRunAndCheck<CCPPass>(text, text, false );
1266
+ }
1267
+
1240
1268
TEST_F (CCPTest, FunctionDeclaration) {
1241
1269
// Make sure the pass works with a function declaration that is called.
1242
1270
const std::string text = R"( OpCapability Addresses
You can’t perform that action at this time.
0 commit comments