mesa/src/poly/nir/poly_nir_lower_sysvals.c
Faith Ekstrand fcb107accb poly: Fetch the index size from a sysval
On asahi, we can still specialize based on the shader key and get
everything folded.  But this gives drivers the option to make it
dynamic if they wish.

Co-authored-by: Mary Guillemard <mary.guillemard@collabora.com>
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>
2025-11-25 23:20:23 +00:00

38 lines
989 B
C

/*
* 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_index_size_poly: {
b->cursor = nir_before_instr(&intr->instr);
nir_def *vp = nir_load_vertex_param_buffer_poly(b);
nir_def_replace(&intr->def, poly_index_size(b, vp));
return true;
}
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);
}