summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/indices
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2016-05-25 11:58:29 -0600
committerBrian Paul <brianp@vmware.com>2016-05-26 17:44:17 -0600
commit0f983e1793360d98eb8e254755d95d33e2ea8ea2 (patch)
tree459d24b151c5166178d57e5a5fec7387bd48761c /src/gallium/auxiliary/indices
parentd6c2c7d7109785935086551ac3d82c4ad819483a (diff)
downloadexternal_mesa3d-0f983e1793360d98eb8e254755d95d33e2ea8ea2.zip
external_mesa3d-0f983e1793360d98eb8e254755d95d33e2ea8ea2.tar.gz
external_mesa3d-0f983e1793360d98eb8e254755d95d33e2ea8ea2.tar.bz2
util/indices: implement unfilled (tri->line) conversion for adjacency prims
Tested with new piglit gl-3.2-adj-prims test. v2: re-order trisadj and tristripadj code, per Roland. Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/indices')
-rw-r--r--src/gallium/auxiliary/indices/u_unfilled_gen.py26
-rw-r--r--src/gallium/auxiliary/indices/u_unfilled_indices.c14
2 files changed, 38 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.py b/src/gallium/auxiliary/indices/u_unfilled_gen.py
index 873e781..6b02627 100644
--- a/src/gallium/auxiliary/indices/u_unfilled_gen.py
+++ b/src/gallium/auxiliary/indices/u_unfilled_gen.py
@@ -35,14 +35,18 @@ PRIMS=('tris',
'tristrip',
'quads',
'quadstrip',
- 'polygon')
+ 'polygon',
+ 'trisadj',
+ 'tristripadj')
LONGPRIMS=('PIPE_PRIM_TRIANGLES',
'PIPE_PRIM_TRIANGLE_FAN',
'PIPE_PRIM_TRIANGLE_STRIP',
'PIPE_PRIM_QUADS',
'PIPE_PRIM_QUAD_STRIP',
- 'PIPE_PRIM_POLYGON')
+ 'PIPE_PRIM_POLYGON',
+ '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')
@@ -194,6 +198,22 @@ def quadstrip(intype, outtype):
postamble()
+def trisadj(intype, outtype):
+ preamble(intype, outtype, prim='trisadj')
+ print ' for (i = start, j = 0; j < out_nr; j+=6, i+=6) { '
+ do_tri( intype, outtype, 'out+j', 'i', 'i+2', 'i+4' );
+ print ' }'
+ postamble()
+
+
+def tristripadj(intype, outtype):
+ preamble(intype, outtype, prim='tristripadj')
+ print ' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { '
+ do_tri( intype, outtype, 'out+j', 'i', 'i+2', 'i+4' );
+ print ' }'
+ postamble()
+
+
def emit_funcs():
for intype in INTYPES:
for outtype in OUTTYPES:
@@ -203,6 +223,8 @@ def emit_funcs():
quads(intype, outtype)
quadstrip(intype, outtype)
polygon(intype, outtype)
+ trisadj(intype, outtype)
+ tristripadj(intype, outtype)
def init(intype, outtype, prim):
if intype == GENERATE:
diff --git a/src/gallium/auxiliary/indices/u_unfilled_indices.c b/src/gallium/auxiliary/indices/u_unfilled_indices.c
index 49fff6b..8cb5192 100644
--- a/src/gallium/auxiliary/indices/u_unfilled_indices.c
+++ b/src/gallium/auxiliary/indices/u_unfilled_indices.c
@@ -22,6 +22,12 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+
+/*
+ * NOTE: This file is not compiled by itself. It's actually #included
+ * by the generated u_unfilled_gen.c file!
+ */
+
#include "u_indices.h"
#include "u_indices_priv.h"
#include "util/u_prim.h"
@@ -104,6 +110,14 @@ nr_lines(unsigned prim, unsigned nr)
return (nr - 2) / 2 * 8;
case PIPE_PRIM_POLYGON:
return 2 * nr; /* a line (two verts) for each polygon edge */
+ /* Note: these cases can't really be handled since drawing lines instead
+ * of triangles would also require changing the GS. But if there's no GS,
+ * this should work.
+ */
+ case PIPE_PRIM_TRIANGLES_ADJACENCY:
+ return (nr / 6) * 6;
+ case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+ return ((nr - 4) / 2) * 6;
default:
assert(0);
return 0;