* [PATCH] i965: Add hardware context support.
@ 2012-06-12 19:07 Kenneth Graunke
2012-06-13 17:59 ` Eric Anholt
2012-06-29 17:06 ` Ben Widawsky
0 siblings, 2 replies; 4+ messages in thread
From: Kenneth Graunke @ 2012-06-12 19:07 UTC (permalink / raw)
To: mesa-dev; +Cc: intel-gfx, Ben Widawsky
With fixes and updates from Ben Widawsky and comments from Paul Berry.
This should not be pushed until libdrm 2.4.36 is released with Ben's
hardware context support.
I haven't hooked up the context destroy function yet as I'm not entirely
sure about tear-down, but they will be freed on fd close, so it should
only be a problem for long running processes that open and destroy many
GL contexts.
Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
configure.ac | 2 +-
src/mesa/drivers/dri/i965/brw_context.c | 1 +
src/mesa/drivers/dri/i965/brw_vtbl.c | 13 +++++++++----
src/mesa/drivers/dri/intel/intel_batchbuffer.c | 9 +++++++--
src/mesa/drivers/dri/intel/intel_context.c | 2 ++
src/mesa/drivers/dri/intel/intel_context.h | 2 ++
6 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 29ee87b..e668c69 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,7 @@ 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.36
LIBDRM_NVVIEUX_REQUIRED=2.4.33
LIBDRM_NOUVEAU_REQUIRED=2.4.33
DRI2PROTO_REQUIRED=2.6
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index f7073cd..d4159c7 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -298,6 +298,7 @@ brwCreateContext(int api,
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 );
diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c
index 5699749..88e6dd1 100644
--- a/src/mesa/drivers/dri/i965/brw_vtbl.c
+++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
@@ -166,11 +166,16 @@ 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.
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index 76a69f7..7ba141d 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -188,8 +188,13 @@ do_flush_locked(struct intel_context *intel)
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);
+ }
}
}
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index c2f7d29..fc244c1 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -593,6 +593,8 @@ intelInitContext(struct intel_context *intel,
if (intelScreen->bufmgr == NULL)
return false;
+ intel->hw_ctx = NULL;
+
/* Can't rely on invalidate events, fall back to glViewport hack */
if (!driContextPriv->driScreenPriv->dri2.useInvalidate) {
intel->saved_viewport = functions->Viewport;
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index cc3ee0d..29ab187 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -225,6 +225,8 @@ struct intel_context
int urb_size;
+ drm_intel_context *hw_ctx;
+
struct intel_batchbuffer batch;
drm_intel_bo *first_post_swapbuffers_batch;
--
1.7.10.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] i965: Add hardware context support.
2012-06-12 19:07 [PATCH] i965: Add hardware context support Kenneth Graunke
@ 2012-06-13 17:59 ` Eric Anholt
2012-06-29 17:06 ` Ben Widawsky
1 sibling, 0 replies; 4+ messages in thread
From: Eric Anholt @ 2012-06-13 17:59 UTC (permalink / raw)
To: Kenneth Graunke, mesa-dev; +Cc: intel-gfx, Ben Widawsky
[-- Attachment #1.1: Type: text/plain, Size: 1180 bytes --]
On Tue, 12 Jun 2012 12:07:09 -0700, Kenneth Graunke <kenneth@whitecape.org> wrote:
> With fixes and updates from Ben Widawsky and comments from Paul Berry.
>
> This should not be pushed until libdrm 2.4.36 is released with Ben's
> hardware context support.
>
> I haven't hooked up the context destroy function yet as I'm not entirely
> sure about tear-down, but they will be freed on fd close, so it should
> only be a problem for long running processes that open and destroy many
> GL contexts.
What's wrong with just freeing our context at brw_destroy_context()? We
definietly have to manually free the stuff, since some apps (web
browsers) will have many context create/destroy cycles.
> diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
> index c2f7d29..fc244c1 100644
> --- a/src/mesa/drivers/dri/intel/intel_context.c
> +++ b/src/mesa/drivers/dri/intel/intel_context.c
> @@ -593,6 +593,8 @@ intelInitContext(struct intel_context *intel,
> if (intelScreen->bufmgr == NULL)
> return false;
>
> + intel->hw_ctx = NULL;
it's rzalloced, so we don't manually zero most of our data.
[-- Attachment #1.2: Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 156 bytes --]
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i965: Add hardware context support.
2012-06-12 19:07 [PATCH] i965: Add hardware context support Kenneth Graunke
2012-06-13 17:59 ` Eric Anholt
@ 2012-06-29 17:06 ` Ben Widawsky
2012-06-29 18:23 ` Ben Widawsky
1 sibling, 1 reply; 4+ messages in thread
From: Ben Widawsky @ 2012-06-29 17:06 UTC (permalink / raw)
To: Kenneth Graunke; +Cc: mesa-dev, intel-gfx
On Tue, 12 Jun 2012 12:07:09 -0700
Kenneth Graunke <kenneth@whitecape.org> wrote:
> With fixes and updates from Ben Widawsky and comments from Paul Berry.
>
> This should not be pushed until libdrm 2.4.36 is released with Ben's
> hardware context support.
2.4.36 has been released. I screwed up the announce though.
>
> I haven't hooked up the context destroy function yet as I'm not entirely
> sure about tear-down, but they will be freed on fd close, so it should
> only be a problem for long running processes that open and destroy many
> GL contexts.
>
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> ---
> configure.ac | 2 +-
> src/mesa/drivers/dri/i965/brw_context.c | 1 +
> src/mesa/drivers/dri/i965/brw_vtbl.c | 13 +++++++++----
> src/mesa/drivers/dri/intel/intel_batchbuffer.c | 9 +++++++--
> src/mesa/drivers/dri/intel/intel_context.c | 2 ++
> src/mesa/drivers/dri/intel/intel_context.h | 2 ++
> 6 files changed, 22 insertions(+), 7 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 29ee87b..e668c69 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -33,7 +33,7 @@ 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.36
> LIBDRM_NVVIEUX_REQUIRED=2.4.33
> LIBDRM_NOUVEAU_REQUIRED=2.4.33
> DRI2PROTO_REQUIRED=2.6
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index f7073cd..d4159c7 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -298,6 +298,7 @@ brwCreateContext(int api,
>
> 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 );
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c
> index 5699749..88e6dd1 100644
> --- a/src/mesa/drivers/dri/i965/brw_vtbl.c
> +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
> @@ -166,11 +166,16 @@ 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.
> diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
> index 76a69f7..7ba141d 100644
> --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
> +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
> @@ -188,8 +188,13 @@ do_flush_locked(struct intel_context *intel)
> 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);
> + }
> }
> }
>
> diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
> index c2f7d29..fc244c1 100644
> --- a/src/mesa/drivers/dri/intel/intel_context.c
> +++ b/src/mesa/drivers/dri/intel/intel_context.c
> @@ -593,6 +593,8 @@ intelInitContext(struct intel_context *intel,
> if (intelScreen->bufmgr == NULL)
> return false;
>
> + intel->hw_ctx = NULL;
> +
> /* Can't rely on invalidate events, fall back to glViewport hack */
> if (!driContextPriv->driScreenPriv->dri2.useInvalidate) {
> intel->saved_viewport = functions->Viewport;
> diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
> index cc3ee0d..29ab187 100644
> --- a/src/mesa/drivers/dri/intel/intel_context.h
> +++ b/src/mesa/drivers/dri/intel/intel_context.h
> @@ -225,6 +225,8 @@ struct intel_context
>
> int urb_size;
>
> + drm_intel_context *hw_ctx;
> +
> struct intel_batchbuffer batch;
>
> drm_intel_bo *first_post_swapbuffers_batch;
--
Ben Widawsky, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i965: Add hardware context support.
2012-06-29 17:06 ` Ben Widawsky
@ 2012-06-29 18:23 ` Ben Widawsky
0 siblings, 0 replies; 4+ messages in thread
From: Ben Widawsky @ 2012-06-29 18:23 UTC (permalink / raw)
To: Ben Widawsky; +Cc: mesa-dev, intel-gfx
On Fri, 29 Jun 2012 10:06:29 -0700
Ben Widawsky <ben@bwidawsk.net> wrote:
> On Tue, 12 Jun 2012 12:07:09 -0700
> Kenneth Graunke <kenneth@whitecape.org> wrote:
>
> > With fixes and updates from Ben Widawsky and comments from Paul Berry.
> >
> > This should not be pushed until libdrm 2.4.36 is released with Ben's
> > hardware context support.
>
> 2.4.36 has been released. I screwed up the announce though.
>
Just kidding... 2.6.37
> >
> > I haven't hooked up the context destroy function yet as I'm not entirely
> > sure about tear-down, but they will be freed on fd close, so it should
> > only be a problem for long running processes that open and destroy many
> > GL contexts.
> >
> > Cc: intel-gfx@lists.freedesktop.org
> > Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
> > Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> > ---
> > configure.ac | 2 +-
> > src/mesa/drivers/dri/i965/brw_context.c | 1 +
> > src/mesa/drivers/dri/i965/brw_vtbl.c | 13 +++++++++----
> > src/mesa/drivers/dri/intel/intel_batchbuffer.c | 9 +++++++--
> > src/mesa/drivers/dri/intel/intel_context.c | 2 ++
> > src/mesa/drivers/dri/intel/intel_context.h | 2 ++
> > 6 files changed, 22 insertions(+), 7 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 29ee87b..e668c69 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -33,7 +33,7 @@ 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.36
> > LIBDRM_NVVIEUX_REQUIRED=2.4.33
> > LIBDRM_NOUVEAU_REQUIRED=2.4.33
> > DRI2PROTO_REQUIRED=2.6
> > diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> > index f7073cd..d4159c7 100644
> > --- a/src/mesa/drivers/dri/i965/brw_context.c
> > +++ b/src/mesa/drivers/dri/i965/brw_context.c
> > @@ -298,6 +298,7 @@ brwCreateContext(int api,
> >
> > 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 );
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c
> > index 5699749..88e6dd1 100644
> > --- a/src/mesa/drivers/dri/i965/brw_vtbl.c
> > +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
> > @@ -166,11 +166,16 @@ 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.
> > diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
> > index 76a69f7..7ba141d 100644
> > --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
> > +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
> > @@ -188,8 +188,13 @@ do_flush_locked(struct intel_context *intel)
> > 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);
> > + }
> > }
> > }
> >
> > diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
> > index c2f7d29..fc244c1 100644
> > --- a/src/mesa/drivers/dri/intel/intel_context.c
> > +++ b/src/mesa/drivers/dri/intel/intel_context.c
> > @@ -593,6 +593,8 @@ intelInitContext(struct intel_context *intel,
> > if (intelScreen->bufmgr == NULL)
> > return false;
> >
> > + intel->hw_ctx = NULL;
> > +
> > /* Can't rely on invalidate events, fall back to glViewport hack */
> > if (!driContextPriv->driScreenPriv->dri2.useInvalidate) {
> > intel->saved_viewport = functions->Viewport;
> > diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
> > index cc3ee0d..29ab187 100644
> > --- a/src/mesa/drivers/dri/intel/intel_context.h
> > +++ b/src/mesa/drivers/dri/intel/intel_context.h
> > @@ -225,6 +225,8 @@ struct intel_context
> >
> > int urb_size;
> >
> > + drm_intel_context *hw_ctx;
> > +
> > struct intel_batchbuffer batch;
> >
> > drm_intel_bo *first_post_swapbuffers_batch;
>
>
>
--
Ben Widawsky, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-06-29 18:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-12 19:07 [PATCH] i965: Add hardware context support Kenneth Graunke
2012-06-13 17:59 ` Eric Anholt
2012-06-29 17:06 ` Ben Widawsky
2012-06-29 18:23 ` Ben Widawsky
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.