From 8b4f7b0672d663273310fffa9490ad996f5b914a Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Mon, 6 Feb 2012 16:29:03 +0100 Subject: gallium: add PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION Just let the hardware do it if it can and avoid drivers having to check for the special case on each draw call. v2: update the draw module --- src/gallium/auxiliary/draw/draw_context.c | 7 +++++-- src/gallium/auxiliary/draw/draw_decompose_tmp.h | 26 +++++++++++++++++-------- src/gallium/auxiliary/draw/draw_gs_tmp.h | 1 + src/gallium/auxiliary/draw/draw_private.h | 2 ++ src/gallium/auxiliary/draw/draw_pt_decompose.h | 2 ++ src/gallium/auxiliary/draw/draw_so_emit_tmp.h | 1 + 6 files changed, 29 insertions(+), 10 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 3c0b1aa39c9..ad49ce733ac 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -93,11 +93,11 @@ draw_create_context(struct pipe_context *pipe, boolean try_llvm, } #endif + draw->pipe = pipe; + if (!draw_init(draw)) goto err_destroy; - draw->pipe = pipe; - return draw; err_destroy: @@ -168,6 +168,9 @@ boolean draw_init(struct draw_context *draw) if (!draw_gs_init( draw )) return FALSE; + draw->quads_always_flatshade_last = !draw->pipe->screen->get_param( + draw->pipe->screen, PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION); + return TRUE; } diff --git a/src/gallium/auxiliary/draw/draw_decompose_tmp.h b/src/gallium/auxiliary/draw/draw_decompose_tmp.h index a142563af97..ee6877df99d 100644 --- a/src/gallium/auxiliary/draw/draw_decompose_tmp.h +++ b/src/gallium/auxiliary/draw/draw_decompose_tmp.h @@ -193,13 +193,18 @@ FUNC(FUNC_VARS) flags = DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_0 | DRAW_PIPE_EDGE_FLAG_1; - /* XXX should always emit idx[0] first */ - /* always emit idx[3] first */ - TRIANGLE(flags, idx[3], idx[0], idx[1]); + /* always emit idx[3] / idx[0] first */ + if (quads_flatshade_last) + TRIANGLE(flags, idx[3], idx[0], idx[1]); + else + TRIANGLE(flags, idx[0], idx[1], idx[2]); flags = DRAW_PIPE_EDGE_FLAG_1 | DRAW_PIPE_EDGE_FLAG_2; - TRIANGLE(flags, idx[3], idx[1], idx[2]); + if (quads_flatshade_last) + TRIANGLE(flags, idx[3], idx[1], idx[2]); + else + TRIANGLE(flags, idx[0], idx[2], idx[3]); } } break; @@ -237,13 +242,18 @@ FUNC(FUNC_VARS) flags = DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_0 | DRAW_PIPE_EDGE_FLAG_1; - /* XXX should always emit idx[0] first */ - /* always emit idx[3] first */ - TRIANGLE(flags, idx[3], idx[2], idx[0]); + /* always emit idx[3] / idx[0 first */ + if (quads_flatshade_last) + TRIANGLE(flags, idx[3], idx[2], idx[0]); + else + TRIANGLE(flags, idx[0], idx[3], idx[2]); flags = DRAW_PIPE_EDGE_FLAG_1 | DRAW_PIPE_EDGE_FLAG_2; - TRIANGLE(flags, idx[3], idx[0], idx[1]); + if (quads_flatshade_last) + TRIANGLE(flags, idx[3], idx[0], idx[1]); + else + TRIANGLE(flags, idx[0], idx[1], idx[3]); } } } diff --git a/src/gallium/auxiliary/draw/draw_gs_tmp.h b/src/gallium/auxiliary/draw/draw_gs_tmp.h index de7b02655a5..92b6fb75ea1 100644 --- a/src/gallium/auxiliary/draw/draw_gs_tmp.h +++ b/src/gallium/auxiliary/draw/draw_gs_tmp.h @@ -9,6 +9,7 @@ const unsigned prim = input_prims->prim; \ const unsigned prim_flags = input_prims->flags; \ const unsigned count = input_prims->count; \ + const boolean quads_flatshade_last = FALSE; \ const boolean last_vertex_last = TRUE; \ do { \ debug_assert(input_prims->primitive_count == 1); \ diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index c3eca973e92..9e6380341da 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -204,6 +204,8 @@ struct draw_context boolean guard_band_xy; } driver; + boolean quads_always_flatshade_last; + boolean flushing; /**< debugging/sanity */ boolean suspend_flushing; /**< internally set */ diff --git a/src/gallium/auxiliary/draw/draw_pt_decompose.h b/src/gallium/auxiliary/draw/draw_pt_decompose.h index 3127aad7310..8637085064a 100644 --- a/src/gallium/auxiliary/draw/draw_pt_decompose.h +++ b/src/gallium/auxiliary/draw/draw_pt_decompose.h @@ -1,5 +1,7 @@ #define LOCAL_VARS \ char *verts = (char *) vertices; \ + const boolean quads_flatshade_last = \ + draw->quads_always_flatshade_last; \ const boolean last_vertex_last = \ !(draw->rasterizer->flatshade && \ draw->rasterizer->flatshade_first); diff --git a/src/gallium/auxiliary/draw/draw_so_emit_tmp.h b/src/gallium/auxiliary/draw/draw_so_emit_tmp.h index 7fafde9d5e6..ec31c3ff32f 100644 --- a/src/gallium/auxiliary/draw/draw_so_emit_tmp.h +++ b/src/gallium/auxiliary/draw/draw_so_emit_tmp.h @@ -9,6 +9,7 @@ /* declare more local vars */ \ const unsigned prim = input_prims->prim; \ const unsigned prim_flags = input_prims->flags; \ + const boolean quads_flatshade_last = FALSE; \ const boolean last_vertex_last = TRUE; \ do { \ debug_assert(input_prims->primitive_count == 1); \ -- cgit v1.2.3