asahi: rearrange VS uniforms

this puts draw parameters in the right order and adds in the draw ID. together
this makes MDI a lot more straightforward to do efficiently.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29179>
This commit is contained in:
Alyssa Rosenzweig
2024-04-24 22:06:04 -04:00
committed by Marge Bot
parent 6d518609e3
commit 5b3af5b7e6
3 changed files with 16 additions and 22 deletions

View File

@@ -38,16 +38,17 @@ For a vertex shader reading $n$ attributes, the following layout is used:
* The first $n$ 64-bit uniforms are the base addresses of each attribute.
* The next $n$ 32-bit uniforms are the associated clamps (sizes). Presently
robustness is always used.
* The next 32-bit uniform is the base instance. This must always be reserved
because it is unknown at vertex shader compile-time whether any attribute will
use instancing.
* For a hardware compute shader, the next 32-bit uniform is the base/first
vertex.
* The next 2x32-bit uniform is the base vertex and base instance. This must
always be reserved because it is unknown at vertex shader compile-time whether
any attribute will use instancing. Reserving also the base vertex allows us to
push both conveniently with a single USC Uniform word.
* The next 16-bit is the draw ID.
* For a hardware compute shader, the next 48-bit is padding.
* For a hardware compute shader, the next 64-bit uniform is a pointer to the
input assembly buffer.
In total, the first $6n + 2$ 16-bit uniform slots are reserved for a hardware
vertex shader, or $6n + 8$ for a hardware compute shader.
In total, the first $6n + 5$ 16-bit uniform slots are reserved for a hardware
vertex shader, or $6n + 12$ for a hardware compute shader.
## Fragment

View File

@@ -80,12 +80,12 @@ map_vs_part_uniform(nir_intrinsic_instr *intr, unsigned nr_attribs)
return 4 * nir_src_as_uint(intr->src[0]);
case nir_intrinsic_load_attrib_clamp_agx:
return (4 * nr_attribs) + (2 * nir_src_as_uint(intr->src[0]));
case nir_intrinsic_load_base_instance:
return (6 * nr_attribs);
case nir_intrinsic_load_first_vertex:
return (6 * nr_attribs);
case nir_intrinsic_load_base_instance:
return (6 * nr_attribs) + 2;
case nir_intrinsic_load_input_assembly_buffer_agx:
return (6 * nr_attribs) + 4;
return (6 * nr_attribs) + 8;
default:
return -1;
}

View File

@@ -395,28 +395,21 @@ lay_out_uniforms(struct agx_compiled_shader *shader, struct state *state)
shader->push[shader->push_range_count++] = (struct agx_push_range){
.uniform = 6 * count,
.table = AGX_SYSVAL_TABLE_PARAMS,
.offset = 4,
.length = 2,
.offset = 0,
.length = 4,
};
uniform = (6 * count) + 2;
uniform = (6 * count) + 4;
if (state->hw_stage == PIPE_SHADER_COMPUTE) {
shader->push[shader->push_range_count++] = (struct agx_push_range){
.uniform = (6 * count) + 2,
.table = AGX_SYSVAL_TABLE_PARAMS,
.offset = 0,
.length = 2,
};
shader->push[shader->push_range_count++] = (struct agx_push_range){
.uniform = (6 * count) + 4,
.uniform = (6 * count) + 8,
.table = AGX_SYSVAL_TABLE_ROOT,
.offset = (uintptr_t)&u->input_assembly,
.length = 4,
};
uniform = (6 * count) + 8;
uniform = (6 * count) + 12;
}
} else if (state->stage == PIPE_SHADER_FRAGMENT) {
struct agx_draw_uniforms *u = NULL;