poly: Add a poly_nir_lower_sysvals() pass

There are a few sysvals which exist just so we can specialize them based
on shader keys or linking.  In the case where we can't specialize them,
this provides a pass which loads them from the appropriate poly_*_param
struct.

Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38404>
This commit is contained in:
Faith Ekstrand 2025-11-13 22:15:28 -05:00 committed by Marge Bot
parent 349219df6a
commit 735b4ec9c7
3 changed files with 34 additions and 0 deletions

View file

@ -3,6 +3,7 @@
libpoly_nir_files = files(
'poly_nir_lower_gs.c',
'poly_nir_lower_sysvals.c',
'poly_nir_lower_tess.c',
'poly_nir_lower_vs.c',
)

View file

@ -59,3 +59,5 @@ bool poly_nir_lower_tes(struct nir_shader *tes, bool to_hw_vs);
uint64_t poly_tcs_per_vertex_outputs(const struct nir_shader *nir);
unsigned poly_tcs_output_stride(const struct nir_shader *nir);
bool poly_nir_lower_sysvals(struct nir_shader *nir);

View file

@ -0,0 +1,31 @@
/*
* Copyright 2023 Valve Corporation
* SPDX-License-Identifier: MIT
*/
#include "nir_builder.h"
#include "poly/cl/libpoly.h"
#include "poly/nir/poly_nir.h"
static bool
lower_sysvals_intr(nir_builder *b, nir_intrinsic_instr *intr, void *data)
{
switch (intr->intrinsic) {
case nir_intrinsic_load_vs_outputs_poly: {
b->cursor = nir_before_instr(&intr->instr);
nir_def *vp = nir_load_vertex_param_buffer_poly(b);
nir_def_replace(&intr->def, poly_vertex_outputs(b, vp));
return true;
}
default:
return false;
}
}
bool
poly_nir_lower_sysvals(struct nir_shader *nir)
{
return nir_shader_intrinsics_pass(nir, lower_sysvals_intr,
nir_metadata_control_flow, NULL);
}