summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-04-05 14:56:21 -0700
committerPaul Berry <[email protected]>2013-04-09 15:37:35 -0700
commita7388f8e6f72b31fa05c824ae1c42bf86794f878 (patch)
tree700a5f06ff3960d09164635fc0a73ac3097701d4 /src
parent56ce7fa4b8e1cdede206802e512b320b1b26110d (diff)
i965: Only use brw_draw.c's trim() function when necessary.
brw_draw.c contains a trim() function which modifies the vertex count for quads and quad strips in order to discard dangling vertices. In principle this shouldn't be necessary, since hardware since Gen4 is capable of discarding dangling vertices by itself. However, it's necessary because as a hack to speed up rendering on Gen 4-5, we sometimes convert quads to trifans and quad strips to tristrips. The trim() function isn't necessary on Gen6 and up. This patch documents why and when the trim() function is necessary, and avoids calling it when it's not needed. This will avoid creating problems when we enable hardware support for primitive restart of quads and quad strips on Haswell. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 7195ec89179..8c37e0b5ef8 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -136,6 +136,14 @@ static void gen6_set_prim(struct brw_context *brw,
}
+/**
+ * The hardware is capable of removing dangling vertices on its own; however,
+ * prior to Gen6, we sometimes convert quads into trifans (and quad strips
+ * into tristrips), since pre-Gen6 hardware requires a GS to render quads.
+ * This function manually trims dangling vertices from a draw call involving
+ * quads so that those dangling vertices won't get drawn when we convert to
+ * trifans/tristrips.
+ */
static GLuint trim(GLenum prim, GLuint length)
{
if (prim == GL_QUAD_STRIP)
@@ -171,7 +179,11 @@ static void brw_emit_prim(struct brw_context *brw,
start_vertex_location += brw->vb.start_vertex_bias;
}
- verts_per_instance = trim(prim->mode, prim->count);
+ /* We only need to trim the primitive count on pre-Gen6. */
+ if (intel->gen < 6)
+ verts_per_instance = trim(prim->mode, prim->count);
+ else
+ verts_per_instance = prim->count;
/* If nothing to emit, just return. */
if (verts_per_instance == 0)
@@ -228,7 +240,7 @@ static void gen7_emit_prim(struct brw_context *brw,
start_vertex_location += brw->vb.start_vertex_bias;
}
- verts_per_instance = trim(prim->mode, prim->count);
+ verts_per_instance = prim->count;
/* If nothing to emit, just return. */
if (verts_per_instance == 0)