[PATCH 4/5] context: libdrm wrappers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This wraps libdrm functionality to create, destroy, and exec with
contexts. This patch shouldn't be applied until libdrm for contexts is
updated.

Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 lib/intel_batchbuffer.c |   40 +++++++++++++++++++++++++++++++++++-----
 lib/intel_batchbuffer.h |    2 ++
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 518435c..2344d53 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -74,14 +74,13 @@ intel_batchbuffer_free(struct intel_batchbuffer *batch)
 
 #define CMD_POLY_STIPPLE_OFFSET       0x7906
 
-void
-intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring)
+static unsigned int
+flush_on_ring_common(struct intel_batchbuffer *batch, int ring)
 {
 	unsigned int used = batch->ptr - batch->buffer;
-	int ret;
 
 	if (used == 0)
-		return;
+		return 0;
 
 	if (IS_GEN5(batch->devid)) {
 		BEGIN_BATCH(2);
@@ -99,7 +98,17 @@ intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring)
 	/* Mark the end of the buffer. */
 	*(uint32_t *)(batch->ptr) = MI_BATCH_BUFFER_END; /* noop */
 	batch->ptr += 4;
-	used = batch->ptr - batch->buffer;
+	return batch->ptr - batch->buffer;
+}
+
+void
+intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring)
+{
+	int ret;
+	unsigned int used = flush_on_ring_common(batch, ring);
+
+	if (used == 0)
+		return;
 
 	ret = drm_intel_bo_subdata(batch->bo, 0, used, batch->buffer);
 	assert(ret == 0);
@@ -113,6 +122,27 @@ intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring)
 }
 
 void
+intel_batchbuffer_flush_with_context(struct intel_batchbuffer *batch)
+{
+	int ret;
+	unsigned int used = flush_on_ring_common(batch, I915_EXEC_RENDER);
+
+	if (used == 0)
+		return;
+
+	ret = drm_intel_bo_subdata(batch->bo, 0, used, batch->buffer);
+	assert(ret == 0);
+
+	batch->ptr = NULL;
+
+	ret = drm_intel_bo_context_exec(batch->bo, batch->context, used,
+					I915_EXEC_RENDER);
+	assert(ret == 0);
+
+	intel_batchbuffer_reset(batch);
+}
+
+void
 intel_batchbuffer_flush(struct intel_batchbuffer *batch)
 {
 	int ring = 0;
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 4dffda7..006fdd1 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -12,6 +12,7 @@ struct intel_batchbuffer {
 	uint32_t devid;
 
 	drm_intel_bo *bo;
+	drm_intel_context *context;
 
 	uint8_t buffer[BATCH_SZ];
 	uint8_t *ptr;
@@ -25,6 +26,7 @@ void intel_batchbuffer_free(struct intel_batchbuffer *batch);
 
 void intel_batchbuffer_flush(struct intel_batchbuffer *batch);
 void intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring);
+void intel_batchbuffer_flush_with_context(struct intel_batchbuffer *batch);
 
 void intel_batchbuffer_reset(struct intel_batchbuffer *batch);
 
-- 
1.7.8.3



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux