From ee29db02706de7cd34be9c93199499036aa543e5 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 8 Apr 2022 12:45:22 -0400 Subject: [PATCH] mesa/st: handle adding pointsize when gl_Position is never written MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Part-of: --- 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