nir: Offset vertex_id by first_vertex instead of base_vertex

base_vertex will be zero for non-indexed calls and in that case we
need vertex_id to be offset by the ‘first’ parameter instead. That is
what we get with first_vertex. This is true for both GL and Vulkan.

The freedreno driver is also setting vertex_id_zero_based on
nir_options. In order to avoid breakage this patch switches the
relevant code to handle SYSTEM_VALUE_FIRST_VERTEX so that it can
retain the same behavior.

v2: change a3xx/fd3_emit.c and a4xx/fd4_emit.c from
SYSTEM_VALUE_BASE_VERTEX to SYSTEM_VALUE_FIRST_VERTEX (Kenneth).

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Cc: Rob Clark <robdclark@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Neil Roberts
2018-01-25 19:15:43 +01:00
committed by Ian Romanick
parent c4f30a9100
commit c366f422f0
6 changed files with 6 additions and 13 deletions

View File

@@ -115,7 +115,7 @@ convert_block(nir_block *block, nir_builder *b)
if (b->shader->options->vertex_id_zero_based) {
sysval = nir_iadd(b,
nir_load_vertex_id_zero_base(b),
nir_load_base_vertex(b));
nir_load_first_vertex(b));
} else {
sysval = nir_load_vertex_id(b);
}