Mesa (master): gallium/indices: generalize primitive-restart logic
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Aug 18 12:28:43 UTC 2020
Module: Mesa
Branch: master
Commit: ac96225eb0e4108a416049f3ebac6c5bdb178e9d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac96225eb0e4108a416049f3ebac6c5bdb178e9d
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Thu Jun 18 15:05:13 2020 +0200
gallium/indices: generalize primitive-restart logic
These blocks are all the same logic, but with a few details changed.
Let's add a parameterized version and add calls to that instead.
Reviewed-by: Gert Wollny <gert.wollny at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5976>
---
src/gallium/auxiliary/indices/u_indices_gen.py | 68 ++++++--------------------
1 file changed, 16 insertions(+), 52 deletions(-)
diff --git a/src/gallium/auxiliary/indices/u_indices_gen.py b/src/gallium/auxiliary/indices/u_indices_gen.py
index 498878746d2..e2177c31614 100644
--- a/src/gallium/auxiliary/indices/u_indices_gen.py
+++ b/src/gallium/auxiliary/indices/u_indices_gen.py
@@ -208,6 +208,19 @@ def preamble(intype, outtype, inpv, outpv, pr, prim):
def postamble():
print('}')
+def prim_restart(in_verts, out_verts, out_prims):
+ print('restart:')
+ print(' if (i + ' + str(in_verts) + ' > in_nr) {')
+ for i in range(out_prims):
+ for j in range(out_verts):
+ print(' (out+j+' + str(out_verts * i) + ')[' + str(j) + '] = restart_index;')
+ print(' continue;')
+ print(' }')
+ for i in range(in_verts):
+ print(' if (in[i + ' + str(i) + '] == restart_index) {')
+ print(' i += ' + str(i + 1) + ';')
+ print(' goto restart;')
+ print(' }')
def points(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='points')
@@ -305,32 +318,7 @@ def quads(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='quads')
print(' for (i = start, j = 0; j < out_nr; j+=6, i+=4) { ')
if pr == PRENABLE:
- print('restart:')
- print(' if (i + 4 > in_nr) {')
- print(' (out+j+0)[0] = restart_index;')
- print(' (out+j+0)[1] = restart_index;')
- print(' (out+j+0)[2] = restart_index;')
- print(' (out+j+3)[0] = restart_index;')
- print(' (out+j+3)[1] = restart_index;')
- print(' (out+j+3)[2] = restart_index;')
- print(' continue;')
- print(' }')
- print(' if (in[i + 0] == restart_index) {')
- print(' i += 1;')
- print(' goto restart;')
- print(' }')
- print(' if (in[i + 1] == restart_index) {')
- print(' i += 2;')
- print(' goto restart;')
- print(' }')
- print(' if (in[i + 2] == restart_index) {')
- print(' i += 3;')
- print(' goto restart;')
- print(' }')
- print(' if (in[i + 3] == restart_index) {')
- print(' i += 4;')
- print(' goto restart;')
- print(' }')
+ prim_restart(4, 3, 2)
do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv );
print(' }')
@@ -341,32 +329,8 @@ def quadstrip(intype, outtype, inpv, outpv, pr):
preamble(intype, outtype, inpv, outpv, pr, prim='quadstrip')
print(' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { ')
if pr == PRENABLE:
- print('restart:')
- print(' if (i + 4 > in_nr) {')
- print(' (out+j+0)[0] = restart_index;')
- print(' (out+j+0)[1] = restart_index;')
- print(' (out+j+0)[2] = restart_index;')
- print(' (out+j+3)[0] = restart_index;')
- print(' (out+j+3)[1] = restart_index;')
- print(' (out+j+3)[2] = restart_index;')
- print(' continue;')
- print(' }')
- print(' if (in[i + 0] == restart_index) {')
- print(' i += 1;')
- print(' goto restart;')
- print(' }')
- print(' if (in[i + 1] == restart_index) {')
- print(' i += 2;')
- print(' goto restart;')
- print(' }')
- print(' if (in[i + 2] == restart_index) {')
- print(' i += 3;')
- print(' goto restart;')
- print(' }')
- print(' if (in[i + 3] == restart_index) {')
- print(' i += 4;')
- print(' goto restart;')
- print(' }')
+ prim_restart(4, 3, 2)
+
if inpv == LAST:
do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv );
else:
More information about the mesa-commit
mailing list