From: Mike Blumenkrantz Date: Wed, 17 Feb 2021 14:48:34 +0000 (-0500) Subject: nir/texcoord_replace: add a yinvert param X-Git-Tag: upstream/21.2.3~7292 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e60929b477c1e187131c71e2bad389097521d04;p=platform%2Fupstream%2Fmesa.git nir/texcoord_replace: add a yinvert param vulkan needs to invert the y coord in order to handle PIPE_SPRITE_COORD_LOWER_LEFT Reviewed-by: Dave Airlie Part-of: --- diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 7ce8484..fd35676 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4941,7 +4941,7 @@ void nir_lower_mediump_outputs(nir_shader *nir); bool nir_lower_point_size(nir_shader *shader, float min, float max); void nir_lower_texcoord_replace(nir_shader *s, unsigned coord_replace, - bool point_coord_is_sysval); + bool point_coord_is_sysval, bool yinvert); typedef enum { nir_lower_interpolation_at_sample = (1 << 1), diff --git a/src/compiler/nir/nir_lower_texcoord_replace.c b/src/compiler/nir/nir_lower_texcoord_replace.c index f0a03e8..d448673 100644 --- a/src/compiler/nir/nir_lower_texcoord_replace.c +++ b/src/compiler/nir/nir_lower_texcoord_replace.c @@ -60,7 +60,8 @@ get_io_index(nir_builder *b, nir_deref_instr *deref) static void nir_lower_texcoord_replace_impl(nir_function_impl *impl, unsigned coord_replace, - bool point_coord_is_sysval) + bool point_coord_is_sysval, + bool yinvert) { nir_builder b; @@ -90,8 +91,11 @@ nir_lower_texcoord_replace_impl(nir_function_impl *impl, */ nir_ssa_def *zero = nir_imm_zero(&b, 1, new_coord->bit_size); nir_ssa_def *one = nir_imm_floatN_t(&b, 1.0, new_coord->bit_size); + nir_ssa_def *y = nir_channel(&b, new_coord, 1); + if (yinvert) + y = nir_fsub(&b, nir_imm_float(&b, 1.0), y); new_coord = nir_vec4(&b, nir_channel(&b, new_coord, 0), - nir_channel(&b, new_coord, 1), + y, zero, one); nir_foreach_block(block, impl) { @@ -134,7 +138,7 @@ nir_lower_texcoord_replace_impl(nir_function_impl *impl, void nir_lower_texcoord_replace(nir_shader *s, unsigned coord_replace, - bool point_coord_is_sysval) + bool point_coord_is_sysval, bool yinvert) { assert(s->info.stage == MESA_SHADER_FRAGMENT); assert(coord_replace != 0); @@ -142,6 +146,6 @@ nir_lower_texcoord_replace(nir_shader *s, unsigned coord_replace, nir_foreach_function(function, s) { if (function->impl) nir_lower_texcoord_replace_impl(function->impl, coord_replace, - point_coord_is_sysval); + point_coord_is_sysval, yinvert); } } diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index ae05224..376490e 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1315,7 +1315,7 @@ st_create_fp_variant(struct st_context *st, if (key->lower_texcoord_replace) { bool point_coord_is_sysval = st->ctx->Const.GLSLPointCoordIsSysVal; NIR_PASS_V(state.ir.nir, nir_lower_texcoord_replace, - key->lower_texcoord_replace, point_coord_is_sysval); + key->lower_texcoord_replace, point_coord_is_sysval, false); finalize = true; }