summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-11-09 22:21:16 +0000
committerIan Romanick <ian.d.romanick@intel.com>2012-05-17 22:13:49 -0700
commit815d6e3f2f6c48104268195b7d48976d189b9d30 (patch)
treed2a9714650df357da450b3c6021b7f1efc06f3c0
parentc9aa4607c54affcec38d814cd9abc9b9056a5d47 (diff)
i830: Compute initial number of vertices from remaining batch space
In order to prevent an overflow of the batch buffer when emitting triangles, we need to limit the initial primitive to fit within the current batch. To do we need to measure the remaining space and thence compute the maximum number of vertices that fit into that space. Reported-by: Kurt Roeckx <kurt@roeckx.be> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41495 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Eric Anholt <eric@anholt.net> NOTE: This is a candidate for release branches. (cherry picked from commit 33b07893e92dcee495908c549be872887096c894)
-rw-r--r--src/mesa/drivers/dri/i915/intel_render.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/i915/intel_render.c b/src/mesa/drivers/dri/i915/intel_render.c
index 432fc7a14b..a4041bea9b 100644
--- a/src/mesa/drivers/dri/i915/intel_render.c
+++ b/src/mesa/drivers/dri/i915/intel_render.c
@@ -119,12 +119,14 @@ intelDmaPrimitive(struct intel_context *intel, GLenum prim)
intel_set_prim(intel, hw_prim[prim]);
}
+#define INTEL_NO_VBO_STATE_RESERVED 1500
+
static INLINE GLuint intel_get_vb_max(struct intel_context *intel)
{
GLuint ret;
if (intel->intelScreen->no_vbo)
- ret = sizeof(intel->batch.map) - 1500;
+ ret = sizeof(intel->batch.map) - INTEL_NO_VBO_STATE_RESERVED;
else
ret = INTEL_VB_SIZE;
ret /= (intel->vertex_size * 4);
@@ -133,11 +135,15 @@ static INLINE GLuint intel_get_vb_max(struct intel_context *intel)
static INLINE GLuint intel_get_current_max(struct intel_context *intel)
{
+ GLuint ret;
- if (intel->intelScreen->no_vbo)
- return intel_get_vb_max(intel);
- else
- return (INTEL_VB_SIZE - intel->prim.current_offset) / (intel->vertex_size * 4);
+ if (intel->intelScreen->no_vbo) {
+ ret = intel_batchbuffer_space(intel);
+ ret = ret <= INTEL_NO_VBO_STATE_RESERVED ? 0 : ret - INTEL_NO_VBO_STATE_RESERVED;
+ } else
+ ret = (INTEL_VB_SIZE - intel->prim.current_offset);
+
+ return ret / (intel->vertex_size * 4);
}
#define LOCAL_VARS struct intel_context *intel = intel_context(ctx)