summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2016-05-25 15:53:25 -0600
committerBrian Paul <[email protected]>2016-05-26 17:44:17 -0600
commitd6c2c7d7109785935086551ac3d82c4ad819483a (patch)
tree7f81bec33273673beededcb284f58a0b4c985364 /src/gallium
parent479d364c39e06dfcbe2e1d995bd82f748b1a172d (diff)
util/indices: implement provoking vertex conversion for adjacency primitives
Tested with new piglit gl-3.2-adj-prims test. Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/indices/u_indices.c52
-rw-r--r--src/gallium/auxiliary/indices/u_indices_gen.py83
-rw-r--r--src/gallium/auxiliary/indices/u_indices_priv.h2
3 files changed, 134 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/indices/u_indices.c b/src/gallium/auxiliary/indices/u_indices.c
index 436f8f008cb..2b2d10c9cba 100644
--- a/src/gallium/auxiliary/indices/u_indices.c
+++ b/src/gallium/auxiliary/indices/u_indices.c
@@ -55,6 +55,8 @@ static void translate_memcpy_uint( const void *in,
* - Translate from first provoking vertex to last provoking vertex and
* vice versa.
*
+ * Note that this function is used for indexed primitives.
+ *
* \param hw_mask mask of (1 << PIPE_PRIM_x) flags indicating which types
* of primitives are supported by the hardware.
* \param prim incoming PIPE_PRIM_x
@@ -172,6 +174,30 @@ u_index_translator(unsigned hw_mask,
*out_nr = (nr - 2) * 3;
break;
+ case PIPE_PRIM_LINES_ADJACENCY:
+ *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
+ *out_prim = PIPE_PRIM_LINES_ADJACENCY;
+ *out_nr = nr;
+ break;
+
+ case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+ *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
+ *out_prim = PIPE_PRIM_LINES_ADJACENCY;
+ *out_nr = (nr - 3) * 4;
+ break;
+
+ case PIPE_PRIM_TRIANGLES_ADJACENCY:
+ *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
+ *out_prim = PIPE_PRIM_TRIANGLES_ADJACENCY;
+ *out_nr = nr;
+ break;
+
+ case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+ *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
+ *out_prim = PIPE_PRIM_TRIANGLES_ADJACENCY;
+ *out_nr = ((nr - 4) / 2) * 6;
+ break;
+
default:
assert(0);
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
@@ -193,6 +219,8 @@ u_index_translator(unsigned hw_mask,
* The generator functions generates a number of ushort or uint indexes
* for drawing the new type of primitive.
*
+ * Note that this function is used for non-indexed primitives.
+ *
* \param hw_mask a bitmask of (1 << PIPE_PRIM_x) values that indicates
* kind of primitives are supported by the driver.
* \param prim the PIPE_PRIM_x that the user wants to draw
@@ -294,6 +322,30 @@ u_index_generator(unsigned hw_mask,
*out_nr = (nr - 2) * 3;
return U_GENERATE_REUSABLE;
+ case PIPE_PRIM_LINES_ADJACENCY:
+ *out_generate = generate[out_idx][in_pv][out_pv][prim];
+ *out_prim = PIPE_PRIM_LINES_ADJACENCY;
+ *out_nr = nr;
+ return U_GENERATE_REUSABLE;
+
+ case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+ *out_generate = generate[out_idx][in_pv][out_pv][prim];
+ *out_prim = PIPE_PRIM_LINES_ADJACENCY;
+ *out_nr = (nr - 3) * 4;
+ return U_GENERATE_REUSABLE;
+
+ case PIPE_PRIM_TRIANGLES_ADJACENCY:
+ *out_generate = generate[out_idx][in_pv][out_pv][prim];
+ *out_prim = PIPE_PRIM_TRIANGLES_ADJACENCY;
+ *out_nr = nr;
+ return U_GENERATE_REUSABLE;
+
+ case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+ *out_generate = generate[out_idx][in_pv][out_pv][prim];
+ *out_prim = PIPE_PRIM_TRIANGLES_ADJACENCY;
+ *out_nr = ((nr - 4) / 2) * 6;
+ return U_GENERATE_REUSABLE;
+
default:
assert(0);
*out_generate = generate[out_idx][in_pv][out_pv][PIPE_PRIM_POINTS];
diff --git a/src/gallium/auxiliary/indices/u_indices_gen.py b/src/gallium/auxiliary/indices/u_indices_gen.py
index 97c8e0d9469..fb6b31016d6 100644
--- a/src/gallium/auxiliary/indices/u_indices_gen.py
+++ b/src/gallium/auxiliary/indices/u_indices_gen.py
@@ -42,7 +42,11 @@ PRIMS=('points',
'tristrip',
'quads',
'quadstrip',
- 'polygon')
+ 'polygon',
+ 'linesadj',
+ 'linestripadj',
+ 'trisadj',
+ 'tristripadj')
LONGPRIMS=('PIPE_PRIM_POINTS',
'PIPE_PRIM_LINES',
@@ -53,7 +57,11 @@ LONGPRIMS=('PIPE_PRIM_POINTS',
'PIPE_PRIM_TRIANGLE_STRIP',
'PIPE_PRIM_QUADS',
'PIPE_PRIM_QUAD_STRIP',
- 'PIPE_PRIM_POLYGON')
+ 'PIPE_PRIM_POLYGON',
+ 'PIPE_PRIM_LINES_ADJACENCY',
+ 'PIPE_PRIM_LINE_STRIP_ADJACENCY',
+ 'PIPE_PRIM_TRIANGLES_ADJACENCY',
+ 'PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY')
longprim = dict(zip(PRIMS, LONGPRIMS))
intype_idx = dict(ubyte='IN_UBYTE', ushort='IN_USHORT', uint='IN_UINT')
@@ -123,6 +131,20 @@ def tri( intype, outtype, ptr, v0, v1, v2 ):
print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
+def lineadj( intype, outtype, ptr, v0, v1, v2, v3 ):
+ print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
+ print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
+ print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
+ print ' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';'
+
+def triadj( intype, outtype, ptr, v0, v1, v2, v3, v4, v5 ):
+ print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
+ print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
+ print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
+ print ' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';'
+ print ' (' + ptr + ')[4] = ' + vert( intype, outtype, v4 ) + ';'
+ print ' (' + ptr + ')[5] = ' + vert( intype, outtype, v5 ) + ';'
+
def do_point( intype, outtype, ptr, v0 ):
point( intype, outtype, ptr, v0 )
@@ -149,6 +171,18 @@ def do_quad( intype, outtype, ptr, v0, v1, v2, v3, inpv, outpv ):
do_tri( intype, outtype, ptr+'+0', v0, v1, v2, inpv, outpv );
do_tri( intype, outtype, ptr+'+3', v0, v2, v3, inpv, outpv );
+def do_lineadj( intype, outtype, ptr, v0, v1, v2, v3, inpv, outpv ):
+ if inpv == outpv:
+ lineadj( intype, outtype, ptr, v0, v1, v2, v3 )
+ else:
+ lineadj( intype, outtype, ptr, v3, v2, v1, v0 )
+
+def do_triadj( intype, outtype, ptr, v0, v1, v2, v3, v4, v5, inpv, outpv ):
+ if inpv == outpv:
+ triadj( intype, outtype, ptr, v0, v1, v2, v3, v4, v5 )
+ else:
+ triadj( intype, outtype, ptr, v4, v5, v0, v1, v2, v3 )
+
def name(intype, outtype, inpv, outpv, pr, prim):
if intype == GENERATE:
return 'generate_' + prim + '_' + outtype + '_' + inpv + '2' + outpv
@@ -343,6 +377,47 @@ def quadstrip(intype, outtype, inpv, outpv, pr):
postamble()
+def linesadj(intype, outtype, inpv, outpv, pr):
+ preamble(intype, outtype, inpv, outpv, pr, prim='linesadj')
+ print ' for (i = start; i < (out_nr+start); i+=4) { '
+ do_lineadj( intype, outtype, 'out+i', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv )
+ print ' }'
+ postamble()
+
+
+def linestripadj(intype, outtype, inpv, outpv, pr):
+ preamble(intype, outtype, inpv, outpv, pr, prim='linestripadj')
+ print ' for (i = start, j = 0; j < out_nr; j+=4, i++) {'
+ do_lineadj( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv )
+ print ' }'
+ postamble()
+
+
+def trisadj(intype, outtype, inpv, outpv, pr):
+ preamble(intype, outtype, inpv, outpv, pr, prim='trisadj')
+ print ' for (i = start; i < (out_nr+start); i+=6) { '
+ do_triadj( intype, outtype, 'out+i', 'i+0', 'i+1', 'i+2', 'i+3',
+ 'i+4', 'i+5', inpv, outpv )
+ print ' }'
+ postamble()
+
+
+def tristripadj(intype, outtype, inpv, outpv, pr):
+ preamble(intype, outtype, inpv, outpv, pr, prim='tristripadj')
+ print ' for (i = start, j = 0; j < out_nr; i+=2, j+=6) { '
+ print ' if (i % 4 == 0) {'
+ print ' /* even triangle */'
+ do_triadj( intype, outtype, 'out+j',
+ 'i+0', 'i+1', 'i+2', 'i+3', 'i+4', 'i+5', inpv, outpv )
+ print ' } else {'
+ print ' /* odd triangle */'
+ do_triadj( intype, outtype, 'out+j',
+ 'i+2', 'i-2', 'i+0', 'i+3', 'i+4', 'i+6', inpv, outpv )
+ print ' }'
+ print ' }'
+ postamble()
+
+
def emit_funcs():
for intype in INTYPES:
for outtype in OUTTYPES:
@@ -361,6 +436,10 @@ def emit_funcs():
quads(intype, outtype, inpv, outpv, pr)
quadstrip(intype, outtype, inpv, outpv, pr)
polygon(intype, outtype, inpv, outpv, pr)
+ linesadj(intype, outtype, inpv, outpv, pr)
+ linestripadj(intype, outtype, inpv, outpv, pr)
+ trisadj(intype, outtype, inpv, outpv, pr)
+ tristripadj(intype, outtype, inpv, outpv, pr)
def init(intype, outtype, inpv, outpv, pr, prim):
if intype == GENERATE:
diff --git a/src/gallium/auxiliary/indices/u_indices_priv.h b/src/gallium/auxiliary/indices/u_indices_priv.h
index 9acf1ff4814..82374eaa73f 100644
--- a/src/gallium/auxiliary/indices/u_indices_priv.h
+++ b/src/gallium/auxiliary/indices/u_indices_priv.h
@@ -38,6 +38,6 @@
#define OUT_COUNT 2
-#define PRIM_COUNT (PIPE_PRIM_POLYGON + 1)
+#define PRIM_COUNT (PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY + 1)
#endif