summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2012-06-12 12:07:09 -0700
committerKenneth Graunke <kenneth@whitecape.org>2012-07-10 15:09:58 -0700
commit860d5bdf984730f69cd19b4f7145f3c84b57d33d (patch)
treedfff53f1153543e04713fe5a12b0030c87972c72
parent4fae5e32d5272986e9e64303eadc974d57e7b3ed (diff)
i965: Add hardware context support.
With fixes and updates from Ben Widawsky and comments from Paul Berry. v2: Use drm_intel_gem_context_destroy to destroy hardware context; remove useless initialization of hw_ctx, both suggested by Eric. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Acked-by: Paul Berry <stereotype441@gmail.com>
-rw-r--r--configure.ac2
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c1
-rw-r--r--src/mesa/drivers/dri/i965/brw_vtbl.c15
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.c9
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.h2
5 files changed, 22 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index 46265a2218f..b5250f32148 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,13 +30,13 @@ dnl Save user CFLAGS and CXXFLAGS so one can override the default ones
USER_CFLAGS="$CFLAGS"
USER_CXXFLAGS="$CXXFLAGS"
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.4.24
LIBDRM_RADEON_REQUIRED=2.4.31
-LIBDRM_INTEL_REQUIRED=2.4.34
+LIBDRM_INTEL_REQUIRED=2.4.37
LIBDRM_NVVIEUX_REQUIRED=2.4.33
LIBDRM_NOUVEAU_REQUIRED=2.4.33
DRI2PROTO_REQUIRED=2.6
GLPROTO_REQUIRED=1.4.14
LIBDRM_XORG_REQUIRED=2.4.24
LIBKMS_XORG_REQUIRED=1.0.0
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 8f53ff754cd..f5c8b6eea6d 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -299,12 +299,13 @@ brwCreateContext(int api,
if (intel->gen <= 7) {
brw->needs_unlit_centroid_workaround = true;
}
brw->prim_restart.in_progress = false;
brw->prim_restart.enable_cut_index = false;
+ intel->hw_ctx = drm_intel_gem_context_create(intel->bufmgr);
brw_init_state( brw );
brw->curbe.last_buf = calloc(1, 4096);
brw->curbe.next_buf = calloc(1, 4096);
diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c
index 56997493318..e76b264141e 100644
--- a/src/mesa/drivers/dri/i965/brw_vtbl.c
+++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
@@ -77,12 +77,14 @@ static void brw_destroy_context( struct intel_context *intel )
dri_bo_release(&brw->curbe.curbe_bo);
dri_bo_release(&brw->vs.const_bo);
dri_bo_release(&brw->wm.const_bo);
free(brw->curbe.last_buf);
free(brw->curbe.next_buf);
+
+ drm_intel_gem_context_destroy(intel->hw_ctx);
}
/**
* Update the hardware state for drawing into a window or framebuffer object.
*
* Called by glDrawBuffer, glBindFramebufferEXT, MakeCurrent, and other
@@ -163,17 +165,22 @@ static void brw_finish_batch(struct intel_context *intel)
* called from intelFlushBatchLocked
*/
static void brw_new_batch( struct intel_context *intel )
{
struct brw_context *brw = brw_context(&intel->ctx);
- /* Mark all context state as needing to be re-emitted.
- * This is probably not as severe as on 915, since almost all of our state
- * is just in referenced buffers.
+ /* If the kernel supports hardware contexts, then most hardware state is
+ * preserved between batches; we only need to re-emit state that is required
+ * to be in every batch. Otherwise we need to re-emit all the state that
+ * would otherwise be stored in the context (which for all intents and
+ * purposes means everything).
*/
- brw->state.dirty.brw |= BRW_NEW_CONTEXT | BRW_NEW_BATCH;
+ if (intel->hw_ctx == NULL)
+ brw->state.dirty.brw |= BRW_NEW_CONTEXT;
+
+ brw->state.dirty.brw |= BRW_NEW_BATCH;
/* Assume that the last command before the start of our batch was a
* primitive, for safety.
*/
intel->batch.need_workaround_flush = true;
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index 76a69f7c88d..a1b5ccc4204 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -185,14 +185,19 @@ do_flush_locked(struct intel_context *intel)
if (batch->needs_sol_reset)
flags |= I915_EXEC_GEN7_SOL_RESET;
if (ret == 0) {
if (unlikely(INTEL_DEBUG & DEBUG_AUB) && intel->vtbl.annotate_aub)
intel->vtbl.annotate_aub(intel);
- ret = drm_intel_bo_mrb_exec(batch->bo, 4*batch->used, NULL, 0, 0,
- flags);
+ if (intel->hw_ctx == NULL || batch->is_blit) {
+ ret = drm_intel_bo_mrb_exec(batch->bo, 4 * batch->used, NULL, 0, 0,
+ flags);
+ } else {
+ ret = drm_intel_gem_bo_context_exec(batch->bo, intel->hw_ctx,
+ 4 * batch->used, flags);
+ }
}
}
if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
do_batch_dump(intel);
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index cc3ee0d3592..29ab187c3e7 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -222,12 +222,14 @@ struct intel_context
bool has_hiz;
bool has_llc;
bool has_swizzling;
int urb_size;
+ drm_intel_context *hw_ctx;
+
struct intel_batchbuffer batch;
drm_intel_bo *first_post_swapbuffers_batch;
bool need_throttle;
bool no_batch_wrap;
bool tnl_pipeline_running; /**< Set while i915's _tnl_run_pipeline. */