diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2021-02-17 09:48:34 -0500 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-02-24 23:25:01 +0000 |
commit | 2e60929b477c1e187131c71e2bad389097521d04 (patch) | |
tree | ee2a8e033ffb510488363fc72c150a901c463321 | |
parent | 707dc04b78b540912e178e0a67e1577ff05b2e29 (diff) |
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 <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9115>
-rw-r--r-- | src/compiler/nir/nir.h | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_texcoord_replace.c | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 7ce848406c6..fd35676bf3b 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 f0a03e8cef8..d4486733ace 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 ae052247f74..376490ec2bc 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; } |