OpImageTexelPointer needs to use an int coordinate type for GLSL, but not for MSL.

This commit is contained in:
Mark Satterthwaite 2019-08-26 11:28:13 -04:00 committed by Lukas Hermanns
parent fdaf9b47bd
commit c4f9704af0
2 changed files with 13 additions and 2 deletions

View File

@ -9596,7 +9596,13 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{ {
uint32_t result_type = ops[0]; uint32_t result_type = ops[0];
uint32_t id = ops[1]; uint32_t id = ops[1];
auto &e = set<SPIRExpression>(id, join(to_expression(ops[2]), ", ", to_expression(ops[3])), result_type, true);
auto coord_expr = to_expression(ops[3]);
auto target_coord_type = expression_type(ops[3]);
target_coord_type.basetype = SPIRType::Int;
coord_expr = bitcast_expression(target_coord_type, expression_type(ops[3]).basetype, coord_expr);
auto &e = set<SPIRExpression>(id, join(to_expression(ops[2]), ", ", coord_expr), result_type, true);
// When using the pointer, we need to know which variable it is actually loaded from. // When using the pointer, we need to know which variable it is actually loaded from.
auto *var = maybe_get_backing_variable(ops[2]); auto *var = maybe_get_backing_variable(ops[2]);

View File

@ -5562,7 +5562,12 @@ void CompilerMSL::emit_instruction(const Instruction &instruction)
} }
else else
{ {
CompilerGLSL::emit_instruction(instruction); uint32_t result_type = ops[0];
uint32_t id = ops[1];
auto &e = set<SPIRExpression>(id, join(to_expression(ops[2]), ", ", to_expression(ops[3])), result_type, true);
// When using the pointer, we need to know which variable it is actually loaded from.
e.loaded_from = var ? var->self : 0;
} }
break; break;
} }