summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_draw.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2006-09-07 19:05:40 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2006-09-07 19:05:40 +0000
commit493b2ddecb47fdacc4b73d9c9a3ba2e46489105f (patch)
tree011c2f4570d336020c0db6562d294d638a981531 /src/mesa/drivers/dri/i965/brw_draw.c
parentc26f36c830cc6df1093a145eb43645f535004eb7 (diff)
Cope with memory pool fragmentation by allowing a second attempt at
rendering operations to take place after evicting all resident buffers. Cope better with memory allocation failures throughout the driver and improve tracking of failures.
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_draw.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c62
1 files changed, 52 insertions, 10 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 104404b301..02c2457423 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -265,14 +265,14 @@ static GLboolean check_fallbacks( struct brw_context *brw,
}
-GLboolean brw_draw_prims( GLcontext *ctx,
- const struct gl_client_array *arrays[],
- const struct brw_draw_prim *prim,
- GLuint nr_prims,
- const struct brw_draw_index_buffer *ib,
- GLuint min_index,
- GLuint max_index,
- GLuint flags )
+static GLboolean brw_try_draw_prims( GLcontext *ctx,
+ const struct gl_client_array *arrays[],
+ const struct brw_draw_prim *prim,
+ GLuint nr_prims,
+ const struct brw_draw_index_buffer *ib,
+ GLuint min_index,
+ GLuint max_index,
+ GLuint flags )
{
struct intel_context *intel = intel_context(ctx);
struct brw_context *brw = brw_context(ctx);
@@ -338,9 +338,12 @@ GLboolean brw_draw_prims( GLcontext *ctx,
* way around this, as not every flush is due to a buffer filling
* up.
*/
- intel_batchbuffer_flush( brw->intel.batch );
+ if (!intel_batchbuffer_flush( brw->intel.batch )) {
+ DBG("%s intel_batchbuffer_flush failed\n", __FUNCTION__);
+ retval = GL_FALSE;
+ }
- if (intel->thrashing) {
+ if (retval && intel->thrashing) {
bmSetFence(intel);
}
@@ -359,9 +362,48 @@ GLboolean brw_draw_prims( GLcontext *ctx,
}
UNLOCK_HARDWARE(intel);
+
+ if (!retval)
+ _mesa_printf("%s failed\n", __FUNCTION__);
+
return retval;
}
+
+GLboolean brw_draw_prims( GLcontext *ctx,
+ const struct gl_client_array *arrays[],
+ const struct brw_draw_prim *prim,
+ GLuint nr_prims,
+ const struct brw_draw_index_buffer *ib,
+ GLuint min_index,
+ GLuint max_index,
+ GLuint flags )
+{
+ struct intel_context *intel = intel_context(ctx);
+ GLboolean retval;
+
+ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index, flags);
+
+
+ if (!retval && bmError(intel)) {
+
+ DBG("retrying\n");
+ /* This looks like out-of-memory but potentially we have
+ * situation where there is enough memory but it has become
+ * fragmented. Clear out all heaps and start from scratch by
+ * faking a contended lock event: (done elsewhere)
+ */
+
+ /* Then try a second time only to upload textures and draw the
+ * primitives:
+ */
+ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index, flags);
+ }
+
+ return retval;
+}
+
+
static void brw_invalidate_vbo_cb( struct intel_context *intel, void *ptr )
{
/* nothing to do, we don't rely on the contents being preserved */