mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-04 08:48:14 +02:00
kk: Rewrite force position output pass to use lowered io
Signed-off-by: Aitor Camacho <aitor@lunarg.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41849>
This commit is contained in:
parent
dc8f9c91c9
commit
52168e67b1
2 changed files with 12 additions and 10 deletions
|
|
@ -224,17 +224,19 @@ msl_ensure_vertex_position_output(nir_shader *nir)
|
|||
bool has_position_write =
|
||||
nir->info.outputs_written & BITFIELD64_BIT(VARYING_SLOT_POS);
|
||||
if (!has_position_write) {
|
||||
nir_variable *position_var = nir_create_variable_with_location(
|
||||
nir, nir_var_shader_out, VARYING_SLOT_POS, glsl_vec4_type());
|
||||
|
||||
/* Write to depth at the very beginning */
|
||||
nir_function_impl *entrypoint = nir_shader_get_entrypoint(nir);
|
||||
nir_builder b = nir_builder_at(nir_before_impl(entrypoint));
|
||||
|
||||
nir_deref_instr *position_deref = nir_build_deref_var(&b, position_var);
|
||||
struct nir_io_semantics io_semantics = {
|
||||
.location = VARYING_SLOT_POS,
|
||||
.num_slots = 4u,
|
||||
};
|
||||
nir_def *zero = nir_imm_float(&b, 0.0f);
|
||||
nir_store_deref(&b, position_deref, nir_vec4(&b, zero, zero, zero, zero),
|
||||
0xFFFFFFFF);
|
||||
nir_store_output(
|
||||
&b, nir_vec4(&b, zero, zero, zero, zero), nir_imm_int(&b, 0u),
|
||||
.base = 0u, .range = 4u, .write_mask = 0xf, .component = 0u,
|
||||
.src_type = nir_type_float32, .io_semantics = io_semantics);
|
||||
|
||||
nir->info.outputs_written |= BITFIELD64_BIT(VARYING_SLOT_POS);
|
||||
return nir_progress(true, entrypoint, nir_metadata_control_flow);
|
||||
|
|
|
|||
|
|
@ -327,6 +327,10 @@ kk_lower_vs_vbo(nir_shader *nir, const struct vk_graphics_pipeline_state *state,
|
|||
static void
|
||||
kk_lower_vs(nir_shader *nir, const struct vk_graphics_pipeline_state *state)
|
||||
{
|
||||
NIR_PASS(_, nir, msl_ensure_vertex_position_output);
|
||||
if (state->ia->primitive_topology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST)
|
||||
NIR_PASS(_, nir, msl_ensure_vertex_point_size_output);
|
||||
|
||||
if (state->ia->primitive_topology != VK_PRIMITIVE_TOPOLOGY_POINT_LIST)
|
||||
nir_shader_intrinsics_pass(nir, msl_nir_vs_remove_point_size_write,
|
||||
nir_metadata_control_flow, NULL);
|
||||
|
|
@ -502,10 +506,6 @@ kk_lower_nir(struct kk_device *dev, nir_shader *nir,
|
|||
NIR_PASS(_, nir, nir_lower_vars_to_scratch, 0,
|
||||
glsl_get_natural_size_align_bytes,
|
||||
glsl_get_natural_size_align_bytes);
|
||||
|
||||
NIR_PASS(_, nir, msl_ensure_vertex_position_output);
|
||||
if (state->ia->primitive_topology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST)
|
||||
NIR_PASS(_, nir, msl_ensure_vertex_point_size_output);
|
||||
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
NIR_PASS(_, nir, kk_nir_lower_fs_multiview, state->mv->view_mask);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue