mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-09 10:08:17 +02:00
glsl: support adding point size to io_lowered shaders
Currently the fixed function vertex shader is built as io_lowered shaders; however the gl_nir_add_point_size() function currently expects the original shader to be not io_lowered, and this function is called to lower the fixed function vertex shader. Add support for adding point size store_output intrinsics for io_lowered shaders. This fixes fixed function rendering on Zink with a Vulkan driver w/o VK_KHR_maintence5. Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn> Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40373>
This commit is contained in:
parent
d089947266
commit
514e0d7de7
1 changed files with 22 additions and 5 deletions
|
|
@ -1192,9 +1192,12 @@ remove_dead_varyings_pre_linking(nir_shader *nir)
|
|||
bool
|
||||
gl_nir_add_point_size(nir_shader *nir)
|
||||
{
|
||||
nir_variable *psiz = nir_create_variable_with_location(nir, nir_var_shader_out,
|
||||
VARYING_SLOT_PSIZ, glsl_float_type());
|
||||
psiz->data.how_declared = nir_var_hidden;
|
||||
nir_variable *psiz;
|
||||
if (!nir->info.io_lowered) {
|
||||
psiz = nir_create_variable_with_location(nir, nir_var_shader_out,
|
||||
VARYING_SLOT_PSIZ, glsl_float_type());
|
||||
psiz->data.how_declared = nir_var_hidden;
|
||||
}
|
||||
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
|
@ -1207,19 +1210,33 @@ gl_nir_add_point_size(nir_shader *nir)
|
|||
intr->intrinsic == nir_intrinsic_copy_deref) {
|
||||
nir_variable *var = nir_intrinsic_get_var(intr, 0);
|
||||
if (var->data.location == VARYING_SLOT_POS) {
|
||||
assert(!nir->info.io_lowered);
|
||||
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;
|
||||
}
|
||||
} else if (intr->intrinsic == nir_intrinsic_store_output) {
|
||||
nir_io_semantics sem = nir_intrinsic_io_semantics(intr);
|
||||
if (sem.location == VARYING_SLOT_POS) {
|
||||
assert(nir->info.io_lowered);
|
||||
b.cursor = nir_after_instr(instr);
|
||||
nir_store_output(&b, nir_imm_float(&b, 1.0), nir_imm_int(&b, 0),
|
||||
.io_semantics.location = VARYING_SLOT_PSIZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
b.cursor = nir_before_impl(impl);
|
||||
nir_deref_instr *deref = nir_build_deref_var(&b, psiz);
|
||||
nir_store_deref(&b, deref, nir_imm_float(&b, 1.0), BITFIELD_BIT(0));
|
||||
if (nir->info.io_lowered) {
|
||||
nir_store_output(&b, nir_imm_float(&b, 1.0), nir_imm_int(&b, 0),
|
||||
.io_semantics.location = VARYING_SLOT_PSIZ);
|
||||
} else {
|
||||
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->info.outputs_written |= VARYING_BIT_PSIZ;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue