From: Jonathan Marek Date: Mon, 12 Nov 2018 18:08:50 +0000 (-0500) Subject: glsl/nir: int constants as float for native_integers=false X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d3b47e073e002a01261dacf11e04e37b812736e6;p=mesa.git glsl/nir: int constants as float for native_integers=false All alu instructions emitted with native_integers=false expect float (or bool in some cases) constants, so this change is necessary. This will cause changes with some intrinsics which had integer sources, such as nir_intrinsic_load_uniform. Apparently it might cause issues with some opt passes, but perhaps those don't apply in OpenGL ES 2.0 cases? Signed-off-by: Jonathan Marek Reviewed-by: Jason Ekstrand --- diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index fac9a6a0f50..8a19399d890 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -94,6 +94,8 @@ private: nir_deref_instr *evaluate_deref(ir_instruction *ir); + nir_constant *constant_copy(ir_constant *ir, void *mem_ctx); + /* most recent deref instruction created */ nir_deref_instr *deref; @@ -196,8 +198,8 @@ nir_visitor::evaluate_deref(ir_instruction *ir) return this->deref; } -static nir_constant * -constant_copy(ir_constant *ir, void *mem_ctx) +nir_constant * +nir_visitor::constant_copy(ir_constant *ir, void *mem_ctx) { if (ir == NULL) return NULL; @@ -215,7 +217,10 @@ constant_copy(ir_constant *ir, void *mem_ctx) assert(cols == 1); for (unsigned r = 0; r < rows; r++) - ret->values[0].u32[r] = ir->value.u[r]; + if (supports_ints) + ret->values[0].u32[r] = ir->value.u[r]; + else + ret->values[0].f32[r] = ir->value.u[r]; break; @@ -224,7 +229,10 @@ constant_copy(ir_constant *ir, void *mem_ctx) assert(cols == 1); for (unsigned r = 0; r < rows; r++) - ret->values[0].i32[r] = ir->value.i[r]; + if (supports_ints) + ret->values[0].i32[r] = ir->value.i[r]; + else + ret->values[0].f32[r] = ir->value.i[r]; break;