[Mesa-dev] [PATCH 4/5] util/indices: implement provoking vertex conversion for adjacency primitives
Roland Scheidegger
sroland at vmware.com
Thu May 26 15:35:30 UTC 2016
Am 26.05.2016 um 16:06 schrieb Brian Paul:
> Tested with new piglit gl-3.2-adj-prims test.
> ---
> src/gallium/auxiliary/indices/u_indices.c | 52 ++++++++++++++++
> src/gallium/auxiliary/indices/u_indices_gen.py | 83 +++++++++++++++++++++++++-
> src/gallium/auxiliary/indices/u_indices_priv.h | 2 +-
> 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 436f8f0..2b2d10c 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];
Can't you get that line out of the switch? (Not that this is really new...)
Patch looks good though (albeit I can't quite verify the index numbers...)
Roland
> + *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 97c8e0d..fb6b310 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 9acf1ff..82374ea 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
>
More information about the mesa-dev
mailing list