diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2019-03-27 12:51:23 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2019-03-27 12:51:23 +0300 |
commit | df3e21a762b8fd40f57030ae9377b0341fe4336f (patch) | |
tree | 9e5687cb46096bc7ce129b632d520e946d348719 /spirv_parser.cpp | |
parent | 88ce958a513ddae27f0ba1acf9806ebcc57fabee (diff) |
Parser: Fix OpCompositeConstruct with OpUndef.
Just treat any undefined argument as 0. It is risky to use the undefined
variable as it might not lower to a true constant.
Diffstat (limited to 'spirv_parser.cpp')
-rw-r--r-- | spirv_parser.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spirv_parser.cpp b/spirv_parser.cpp index f5ca7dfc..fa87fa37 100644 --- a/spirv_parser.cpp +++ b/spirv_parser.cpp @@ -775,6 +775,7 @@ void Parser::parse(const Instruction &instruction) // We do not know their value, so any attempt to query SPIRConstant later // will fail. We can only propagate the ID of the expression and use to_expression on it. auto *constant_op = maybe_get<SPIRConstantOp>(ops[2 + i]); + auto *undef_op = maybe_get<SPIRUndef>(ops[2 + i]); if (constant_op) { if (op == OpConstantComposite) @@ -786,6 +787,13 @@ void Parser::parse(const Instruction &instruction) remapped_constant_ops[i].specialization = true; c[i] = &remapped_constant_ops[i]; } + else if (undef_op) + { + // Undefined, just pick 0. + remapped_constant_ops[i].make_null(get<SPIRType>(undef_op->basetype)); + remapped_constant_ops[i].constant_type = undef_op->basetype; + c[i] = &remapped_constant_ops[i]; + } else c[i] = &get<SPIRConstant>(ops[2 + i]); } |