mesa/st: handle adding pointsize when gl_Position is never written

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15821>
This commit is contained in:
Mike Blumenkrantz 2022-04-08 12:45:22 -04:00 committed by Marge Bot
parent 9c212e117d
commit ee29db0270

View file

@ -265,6 +265,7 @@ st_nir_add_point_size(nir_shader *nir)
nir_builder b; nir_builder b;
nir_function_impl *impl = nir_shader_get_entrypoint(nir); nir_function_impl *impl = nir_shader_get_entrypoint(nir);
nir_builder_init(&b, impl); nir_builder_init(&b, impl);
bool found = false;
nir_foreach_block_safe(block, impl) { nir_foreach_block_safe(block, impl) {
nir_foreach_instr_safe(instr, block) { nir_foreach_instr_safe(instr, block) {
if (instr->type == nir_instr_type_intrinsic) { 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); b.cursor = nir_after_instr(instr);
nir_deref_instr *deref = nir_build_deref_var(&b, psiz); nir_deref_instr *deref = nir_build_deref_var(&b, psiz);
nir_store_deref(&b, deref, nir_imm_float(&b, 1.0), BITFIELD_BIT(0)); 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 static void