From 2122b902b8003719c739db718a97463bbf99ebb3 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 22 Jun 2020 15:56:45 +0200 Subject: [PATCH] gallium/indices: don't expand prim-type for 8-bit indices Expanding the primitive-type has two undesirable effects: 1. It breaks primitive-restart. This is possible to fix by explicitly handling primitive-restart in more conversion routines. But u_indices_gen.py is kind of a mess, so it's not trivial as-is. 2. It changes the reported gl_VertexID. While it might be possible to work around this in each driver, it seems better to avoid this when we can. Reviewed-By: Mike Blumenkrantz Reviewed-by: Gert Wollny Part-of: --- src/gallium/auxiliary/indices/u_indices.c | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/indices/u_indices.c b/src/gallium/auxiliary/indices/u_indices.c index 3d1ebedffd6..94e22c9deb9 100644 --- a/src/gallium/auxiliary/indices/u_indices.c +++ b/src/gallium/auxiliary/indices/u_indices.c @@ -44,7 +44,20 @@ static void translate_memcpy_uint( const void *in, { memcpy(out, &((int *)in)[start], out_nr*sizeof(int)); } - + +static void translate_byte_to_ushort( const void *in, + unsigned start, + UNUSED unsigned in_nr, + unsigned out_nr, + UNUSED unsigned restart_index, + void *out ) +{ + uint8_t *src = (uint8_t *)in + start; + uint16_t *dst = out; + while (out_nr--) { + *dst++ = *src++; + } +} /** * Translate indexes when a driver can't support certain types @@ -97,15 +110,15 @@ u_index_translator(unsigned hw_mask, *out_index_size = (in_index_size == 4) ? 4 : 2; out_idx = out_size_idx(*out_index_size); - if ((hw_mask & (1<