summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/i965/brw_winsys.h
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-11-05 13:57:05 +0000
committerKeith Whitwell <[email protected]>2009-11-05 14:01:37 +0000
commitc796aed5ddad011d66e631c4cafdbf779e73f213 (patch)
treed8a510233b281c9d6a0690632948f10a03819a84 /src/gallium/drivers/i965/brw_winsys.h
parent31b8b1dd36d9f07a7893a89ee985d83c4d0bb95b (diff)
i965g: add lots of error checks and early returns
Any allocation that may fail should be checked, and propogate the error upwards. At the highest level we will flush batch and retry. This is an alternate strategy to what the original DRI driver did of attempting to flush batch from the lowest levels (eg inside BEGIN_BATCH). The trouble with that strategy was that flushes could occur at unexpected times, and additionally there was a need for a wierd notification mechanism to propogate the 'lost context' state back up to higher levels. Propogating the errors directly gives us a lot of flexibility how to deal with these states, at the expense of a lot more checking in the code. Will add some sanity checks later to make sure that out-of-memory conditions are properly escalated and not lost halfway up the stack.
Diffstat (limited to 'src/gallium/drivers/i965/brw_winsys.h')
-rw-r--r--src/gallium/drivers/i965/brw_winsys.h56
1 files changed, 37 insertions, 19 deletions
diff --git a/src/gallium/drivers/i965/brw_winsys.h b/src/gallium/drivers/i965/brw_winsys.h
index d941fbcebee..f61c541ad15 100644
--- a/src/gallium/drivers/i965/brw_winsys.h
+++ b/src/gallium/drivers/i965/brw_winsys.h
@@ -28,6 +28,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
+#include "pipe/p_refcnt.h"
struct brw_winsys;
struct pipe_fence_handle;
@@ -36,10 +37,13 @@ struct pipe_fence_handle;
*/
#define BRW_BATCH_SIZE (32*1024)
+struct brw_winsys_screen;
/* Need a tiny bit of information inside the abstract buffer struct:
*/
struct brw_winsys_buffer {
+ struct pipe_reference reference;
+ struct brw_winsys_screen *sws;
unsigned *offset;
unsigned size;
};
@@ -105,6 +109,10 @@ enum brw_buffer_data_type {
BRW_DATA_MAX
};
+
+
+
+
struct brw_winsys_screen {
@@ -116,33 +124,33 @@ struct brw_winsys_screen {
/**
* Create a buffer.
*/
- struct brw_winsys_buffer *(*bo_alloc)( struct brw_winsys_screen *sws,
- enum brw_buffer_type type,
- unsigned size,
- unsigned alignment );
+ enum pipe_error (*bo_alloc)( struct brw_winsys_screen *sws,
+ enum brw_buffer_type type,
+ unsigned size,
+ unsigned alignment,
+ struct brw_winsys_buffer **bo_out );
- /* Reference and unreference buffers:
+ /* Destroy a buffer when our refcount goes to zero:
*/
- void (*bo_reference)( struct brw_winsys_buffer *buffer );
- void (*bo_unreference)( struct brw_winsys_buffer *buffer );
+ void (*bo_destroy)( struct brw_winsys_buffer *buffer );
/* delta -- added to b2->offset, and written into buffer
* offset -- location above value is written to within buffer
*/
- int (*bo_emit_reloc)( struct brw_winsys_buffer *buffer,
- enum brw_buffer_usage usage,
- unsigned delta,
- unsigned offset,
- struct brw_winsys_buffer *b2);
+ enum pipe_error (*bo_emit_reloc)( struct brw_winsys_buffer *buffer,
+ enum brw_buffer_usage usage,
+ unsigned delta,
+ unsigned offset,
+ struct brw_winsys_buffer *b2);
- int (*bo_exec)( struct brw_winsys_buffer *buffer,
- unsigned bytes_used );
+ enum pipe_error (*bo_exec)( struct brw_winsys_buffer *buffer,
+ unsigned bytes_used );
- int (*bo_subdata)(struct brw_winsys_buffer *buffer,
- enum brw_buffer_data_type data_type,
- size_t offset,
- size_t size,
- const void *data);
+ enum pipe_error (*bo_subdata)(struct brw_winsys_buffer *buffer,
+ enum brw_buffer_data_type data_type,
+ size_t offset,
+ size_t size,
+ const void *data);
boolean (*bo_is_busy)(struct brw_winsys_buffer *buffer);
boolean (*bo_references)(struct brw_winsys_buffer *a,
@@ -175,6 +183,16 @@ struct brw_winsys_screen {
};
+static INLINE void
+bo_reference(struct brw_winsys_buffer **ptr, struct brw_winsys_buffer *buf)
+{
+ struct brw_winsys_buffer *old_buf = *ptr;
+
+ if (pipe_reference((struct pipe_reference **)ptr, &buf->reference))
+ old_buf->sws->bo_destroy(old_buf);
+}
+
+
/**
* Create brw pipe_screen.
*/