Module: Mesa Branch: main Commit: ee29db02706de7cd34be9c93199499036aa543e5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee29db02706de7cd34be9c93199499036aa543e5
Author: Mike Blumenkrantz <[email protected]> Date: Fri Apr 8 12:45:22 2022 -0400 mesa/st: handle adding pointsize when gl_Position is never written Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15821> --- src/mesa/state_tracker/st_glsl_to_nir.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 4ebc53f23e3..4d485ff843b 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -265,6 +265,7 @@ st_nir_add_point_size(nir_shader *nir) nir_builder b; nir_function_impl *impl = nir_shader_get_entrypoint(nir); nir_builder_init(&b, impl); + bool found = false; nir_foreach_block_safe(block, impl) { nir_foreach_instr_safe(instr, block) { if (instr->type == nir_instr_type_intrinsic) { @@ -276,11 +277,17 @@ st_nir_add_point_size(nir_shader *nir) b.cursor = nir_after_instr(instr); nir_deref_instr *deref = nir_build_deref_var(&b, psiz); nir_store_deref(&b, deref, nir_imm_float(&b, 1.0), BITFIELD_BIT(0)); + found = true; } } } } } + if (!found) { + b.cursor = nir_before_cf_list(&impl->body); + nir_deref_instr *deref = nir_build_deref_var(&b, psiz); + nir_store_deref(&b, deref, nir_imm_float(&b, 1.0), BITFIELD_BIT(0)); + } } static void
