summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/i915simple/i915_batch.h
diff options
context:
space:
mode:
authorJakob Bornecrantz <jakob@aurora.(none)>2008-06-02 14:55:06 +0200
committerJakob Bornecrantz <[email protected]>2008-06-02 17:24:30 +0200
commit4ee14279f3a466093869f1f40819e6c6d5af378d (patch)
tree1ef05ca525c4bdb073e8b15c22f86274f6df2341 /src/gallium/drivers/i915simple/i915_batch.h
parent5a67df6d7cc8c74bfb71a8f19b8f6fdfb525091b (diff)
i915: Rework of batchbuffer code
Diffstat (limited to 'src/gallium/drivers/i915simple/i915_batch.h')
-rw-r--r--src/gallium/drivers/i915simple/i915_batch.h92
1 files changed, 88 insertions, 4 deletions
diff --git a/src/gallium/drivers/i915simple/i915_batch.h b/src/gallium/drivers/i915simple/i915_batch.h
index 4ea06ce02bf..6c62e84bc38 100644
--- a/src/gallium/drivers/i915simple/i915_batch.h
+++ b/src/gallium/drivers/i915simple/i915_batch.h
@@ -31,23 +31,107 @@
#include "i915_winsys.h"
#include "i915_debug.h"
+struct i915_batchbuffer
+{
+ struct pipe_buffer *buffer;
+ struct i915_winsys *winsys;
+
+ unsigned char *map;
+ unsigned char *ptr;
+
+ size_t size;
+
+ size_t relocs;
+ size_t max_relocs;
+};
+
+static INLINE boolean
+i915_batchbuffer_check( struct i915_batchbuffer *batch,
+ size_t dwords,
+ size_t relocs )
+{
+#if 0 /* To be used */
+ /** TODO JB: Check relocs */
+ return dwords * 4 <= batch->size - (batch->ptr - batch->map);
+#else
+ if (batch->winsys->batch_start( batch->winsys, dwords, relocs ))
+ return 1;
+ return 0;
+#endif
+}
+
+static INLINE size_t
+i915_batchbuffer_space( struct i915_batchbuffer *batch )
+{
+#if 0 /* To be used */
+ return batch->size - (batch->ptr - batch->map);
+#else
+ return 0;
+#endif
+}
+
+static INLINE void
+i915_batchbuffer_dword( struct i915_batchbuffer *batch,
+ unsigned dword )
+{
+#if 0 /* To be used */
+ if (i915_batchbuffer_space(batch) < 4)
+ return;
+
+ *(unsigned *)batch->ptr = dword;
+ batch->ptr += 4;
+#else
+ batch->winsys->batch_dword( batch->winsys, dword );
+#endif
+}
+
+static INLINE void
+i915_batchbuffer_write( struct i915_batchbuffer *batch,
+ void *data,
+ size_t size )
+{
+#if 0 /* To be used */
+ if (i915_batchbuffer_space(batch) < size)
+ return;
+
+ memcpy(data, batch->ptr, size);
+ batch->ptr += size;
+#else
+#endif
+}
+
+static INLINE void
+i915_batchbuffer_reloc( struct i915_batchbuffer *batch,
+ struct pipe_buffer *buffer,
+ size_t flags,
+ size_t offset )
+{
+ batch->winsys->batch_reloc( batch->winsys, buffer, flags, offset );
+}
+
+static INLINE void
+i915_batchbuffer_flush( struct i915_batchbuffer *batch,
+ struct pipe_fence_handle **fence )
+{
+ batch->winsys->batch_flush( batch->winsys, fence );
+}
+
#define BATCH_LOCALS
#define BEGIN_BATCH( dwords, relocs ) \
- (i915->batch_start = i915->winsys->batch_start( i915->winsys, dwords, relocs ))
+ (i915_batchbuffer_check( i915->batch, dwords, relocs ))
#define OUT_BATCH( dword ) \
- i915->winsys->batch_dword( i915->winsys, dword )
+ i915_batchbuffer_dword( i915->batch, dword )
#define OUT_RELOC( buf, flags, delta ) \
- i915->winsys->batch_reloc( i915->winsys, buf, flags, delta )
+ i915_batchbuffer_reloc( i915->batch, buf, flags, delta )
#define ADVANCE_BATCH()
#define FLUSH_BATCH(fence) do { \
if (0) i915_dump_batchbuffer( i915 ); \
i915->winsys->batch_flush( i915->winsys, fence ); \
- i915->batch_start = NULL; \
i915->hardware_dirty = ~0; \
} while (0)