From 4e634c524024fa05d9ea2047497cd065c905bcdf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 4 Mar 2014 01:11:49 +0100 Subject: [PATCH] st/mesa: implement zero-stride edge flag by culling primitives This was unimplemented. --- src/mesa/state_tracker/st_atom.c | 9 ++++++++- src/mesa/state_tracker/st_atom_rasterizer.c | 8 ++++++++ src/mesa/state_tracker/st_context.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 378254d486d..00149f8ab77 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -132,7 +132,7 @@ static void check_program_state( struct st_context *st ) static void check_attrib_edgeflag(struct st_context *st) { const struct gl_client_array **arrays = st->ctx->Array._DrawArrays; - GLboolean vertdata_edgeflags; + GLboolean vertdata_edgeflags, edgeflag_culls_prims; if (!arrays) return; @@ -142,6 +142,13 @@ static void check_attrib_edgeflag(struct st_context *st) st->vertdata_edgeflags = vertdata_edgeflags; st->dirty.st |= ST_NEW_EDGEFLAGS_DATA; } + + edgeflag_culls_prims = !vertdata_edgeflags && + !st->ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0]; + if (edgeflag_culls_prims != st->edgeflag_culls_prims) { + st->edgeflag_culls_prims = edgeflag_culls_prims; + st->dirty.st |= ST_NEW_RASTERIZER; + } } diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index a4f3ffee324..ee5e9e5743b 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -236,6 +236,14 @@ static void update_raster_state( struct st_context *st ) /* ST_NEW_RASTERIZER */ raster->rasterizer_discard = ctx->RasterDiscard; + if (st->edgeflag_culls_prims) { + /* All edge flags are FALSE. Cull the affected faces. */ + if (raster->fill_front != PIPE_POLYGON_MODE_FILL) + raster->cull_face |= PIPE_FACE_FRONT; + if (raster->fill_back != PIPE_POLYGON_MODE_FILL) + raster->cull_face |= PIPE_FACE_BACK; + } + /* _NEW_TRANSFORM */ raster->depth_clip = ctx->Transform.DepthClamp == GL_FALSE; raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 9c699a015c0..2957b37bd51 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -131,6 +131,7 @@ struct st_context GLboolean missing_textures; GLboolean vertdata_edgeflags; + GLboolean edgeflag_culls_prims; /** Mapping from VARYING_SLOT_x to post-transformed vertex slot */ const GLuint *vertex_result_to_slot; -- 2.30.2