diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 0705e378..f5cf26c5 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -9596,7 +9596,13 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) { uint32_t result_type = ops[0]; uint32_t id = ops[1]; - auto &e = set(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(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. auto *var = maybe_get_backing_variable(ops[2]); diff --git a/spirv_msl.cpp b/spirv_msl.cpp index 407db39f..786d7dc3 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -5562,7 +5562,12 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) } else { - CompilerGLSL::emit_instruction(instruction); + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + auto &e = set(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; }