mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-23 11:50:42 +01:00
v3d/compiler: handle compact varyings
We are going to need this in Vulkan because the SPIR-V compiler defines clip distances as a single compact array of scalars, so our compiler needs to know what to do with them. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6022>
This commit is contained in:
parent
17fd191eed
commit
71d5c19241
2 changed files with 23 additions and 3 deletions
|
|
@ -737,6 +737,19 @@ emit_fragment_input(struct v3d_compile *c, int attr, nir_variable *var,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
emit_compact_fragment_input(struct v3d_compile *c, int attr, nir_variable *var,
|
||||
int array_index)
|
||||
{
|
||||
/* Compact variables are scalar arrays where each set of 4 elements
|
||||
* consumes a single location.
|
||||
*/
|
||||
int loc_offset = array_index / 4;
|
||||
int chan = var->data.location_frac + array_index % 4;
|
||||
c->inputs[(attr + loc_offset) * 4 + chan] =
|
||||
emit_fragment_varying(c, var, chan, loc_offset);
|
||||
}
|
||||
|
||||
static void
|
||||
add_output(struct v3d_compile *c,
|
||||
uint32_t decl_offset,
|
||||
|
|
@ -1658,6 +1671,9 @@ ntq_setup_fs_inputs(struct v3d_compile *c)
|
|||
c->fs_key->point_sprite_mask)) {
|
||||
c->inputs[loc * 4 + 0] = c->point_x;
|
||||
c->inputs[loc * 4 + 1] = c->point_y;
|
||||
} else if (var->data.compact) {
|
||||
for (int j = 0; j < array_len; j++)
|
||||
emit_compact_fragment_input(c, loc, var, j);
|
||||
} else {
|
||||
for (int j = 0; j < array_len; j++)
|
||||
emit_fragment_input(c, loc + j, var, j);
|
||||
|
|
|
|||
|
|
@ -172,13 +172,14 @@ v3d_nir_lower_vpm_output(struct v3d_compile *c, nir_builder *b,
|
|||
int start_comp = nir_intrinsic_component(intr);
|
||||
nir_ssa_def *src = nir_ssa_for_src(b, intr->src[0],
|
||||
intr->num_components);
|
||||
|
||||
nir_variable *var = NULL;
|
||||
nir_foreach_variable(scan_var, &c->s->outputs) {
|
||||
int components = scan_var->data.compact ?
|
||||
glsl_get_length(scan_var->type) :
|
||||
glsl_get_components(scan_var->type);
|
||||
if (scan_var->data.driver_location != nir_intrinsic_base(intr) ||
|
||||
start_comp < scan_var->data.location_frac ||
|
||||
start_comp >= scan_var->data.location_frac +
|
||||
glsl_get_components(scan_var->type)) {
|
||||
start_comp >= scan_var->data.location_frac + components) {
|
||||
continue;
|
||||
}
|
||||
var = scan_var;
|
||||
|
|
@ -253,6 +254,9 @@ v3d_nir_lower_vpm_output(struct v3d_compile *c, nir_builder *b,
|
|||
if (vpm_offset == -1)
|
||||
continue;
|
||||
|
||||
if (var->data.compact)
|
||||
vpm_offset += nir_src_as_uint(intr->src[1]) * 4;
|
||||
|
||||
BITSET_SET(state->varyings_stored, vpm_offset);
|
||||
|
||||
v3d_nir_store_output(b, state->varyings_vpm_offset + vpm_offset,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue