v3d/compiler: implement nir_intrinsic_load_base_instance
Vulkan lowers gl_InstanceIndex to load_base_instance + load_instance_id, so we need to implement loading the base instance in the compiler. The base instance is set by the BASE_VERTEX_BASE_INSTANCE command right before the instanced draw call and it is included in the VPM payload together with the InstanceID and VertexID if this is requested by the shader record. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:

committed by
Marge Bot

parent
ee917d2b78
commit
f41857eb48
@@ -1560,10 +1560,14 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
|
||||
bool uses_iid = c->s->info.system_values_read &
|
||||
(1ull << SYSTEM_VALUE_INSTANCE_ID |
|
||||
1ull << SYSTEM_VALUE_INSTANCE_INDEX);
|
||||
bool uses_biid = c->s->info.system_values_read &
|
||||
(1ull << SYSTEM_VALUE_BASE_INSTANCE);
|
||||
bool uses_vid = c->s->info.system_values_read &
|
||||
(1ull << SYSTEM_VALUE_VERTEX_ID |
|
||||
1ull << SYSTEM_VALUE_VERTEX_ID_ZERO_BASE);
|
||||
|
||||
num_components += uses_iid;
|
||||
num_components += uses_biid;
|
||||
num_components += uses_vid;
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(c->vattr_sizes); i++)
|
||||
@@ -1574,6 +1578,11 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
|
||||
&num_components, ~0);
|
||||
}
|
||||
|
||||
if (uses_biid) {
|
||||
c->biid = ntq_emit_vpm_read(c, &vpm_components_queued,
|
||||
&num_components, ~0);
|
||||
}
|
||||
|
||||
if (uses_vid) {
|
||||
c->vid = ntq_emit_vpm_read(c, &vpm_components_queued,
|
||||
&num_components, ~0);
|
||||
@@ -2002,6 +2011,10 @@ ntq_emit_load_input(struct v3d_compile *c, nir_intrinsic_instr *instr)
|
||||
(1ull << SYSTEM_VALUE_INSTANCE_ID)) {
|
||||
index++;
|
||||
}
|
||||
if (c->s->info.system_values_read &
|
||||
(1ull << SYSTEM_VALUE_BASE_INSTANCE)) {
|
||||
index++;
|
||||
}
|
||||
if (c->s->info.system_values_read &
|
||||
(1ull << SYSTEM_VALUE_VERTEX_ID)) {
|
||||
index++;
|
||||
@@ -2252,6 +2265,10 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr)
|
||||
vir_REVF(c)));
|
||||
break;
|
||||
|
||||
case nir_intrinsic_load_base_instance:
|
||||
ntq_store_dest(c, &instr->dest, 0, vir_MOV(c, c->biid));
|
||||
break;
|
||||
|
||||
case nir_intrinsic_load_instance_id:
|
||||
ntq_store_dest(c, &instr->dest, 0, vir_MOV(c, c->iid));
|
||||
break;
|
||||
|
Reference in New Issue
Block a user