public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ben Widawsky <benjamin.widawsky@intel.com>
To: mesa-dev <mesa-dev@lists.freedesktop.org>
Cc: Intel GFX <intel-gfx@lists.freedesktop.org>,
	Kenneth Graunke <kenneth.w.graunke@intel.com>,
	Ben Widawsky <ben@bwidawsk.net>,
	Ben Widawsky <benjamin.widawsky@intel.com>
Subject: [PATCH] i965: Use default contexts when possible.
Date: Thu,  2 Jan 2014 19:50:35 -1000	[thread overview]
Message-ID: <1388728235-20410-9-git-send-email-benjamin.widawsky@intel.com> (raw)
In-Reply-To: <1388728235-20410-1-git-send-email-benjamin.widawsky@intel.com>

Will full PPGTT support it can be assumed that every file descriptor
gets its own hardware context. As such, there is no need to allocate
anew context in order to use the features provided by hardware contexts.
Eliminating this extra context allocation saves both physical memory
(currently PPGTT pages are pinned forever), GGTT space on IVB, and HSW,
as well as the associated startup cost of allocating the second context
- which can include an eviction in pathological cases.

Unfortunately, this requires a libdrm version bump as it requires a new
interface.

NOTE: I am uncertain if the share context idea is valid. Needs mesa
eyes.

Cc: Kenneth Graunke <kenneth.w.graunke@intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 configure.ac                            | 2 +-
 src/mesa/drivers/dri/i965/brw_context.c | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index f75325d..a0ae0b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,7 +29,7 @@ AC_SUBST([OSMESA_VERSION])
 dnl Versions for external dependencies
 LIBDRM_REQUIRED=2.4.24
 LIBDRM_RADEON_REQUIRED=2.4.50
-LIBDRM_INTEL_REQUIRED=2.4.49
+LIBDRM_INTEL_REQUIRED=2.4.51
 LIBDRM_NVVIEUX_REQUIRED=2.4.33
 LIBDRM_NOUVEAU_REQUIRED="2.4.33 libdrm >= 2.4.41"
 LIBDRM_FREEDRENO_REQUIRED=2.4.39
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 78c06fc..f5a66e1 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -674,7 +674,14 @@ brwCreateContext(gl_api api,
 
    intel_fbo_init(brw);
 
-   if (brw->gen >= 6) {
+   /* We assume that the hw_ctx is the first created for the file descriptor if
+    * this is not a share context. If that assumption turns false then we'll
+    * end up having hw_ctx for two contexts using the same actual context.
+    */
+   if (!shareCtx)
+      brw->hw_ctx = drm_intel_gem_default_context_get(brw->bufmgr);
+
+   if (!brw->hw_ctx && brw->gen >= 6) {
       /* Create a new hardware context.  Using a hardware context means that
        * our GPU state will be saved/restored on context switch, allowing us
        * to assume that the GPU is in the same state we left it in.
-- 
1.8.5.2

  parent reply	other threads:[~2014-01-03  5:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <to=1388555170-19936-1-git-send-email-benjamin.widawsky@intel.com>
2014-01-03  5:50 ` [PATCH] [v2] drm/i915/ppgtt: Never return a NULL context Ben Widawsky
2014-01-03  5:50   ` [PATCH 2/3] drm/i915: set ctx->initialized only after RCS Ben Widawsky
2014-01-03  5:50   ` [PATCH 3/3] drm/i915: Make file default context persistent Ben Widawsky
2014-01-03  5:50   ` [PATCH 1/5] intel: squash unused variable 'bo_gem' Ben Widawsky
2014-01-03  5:50   ` [PATCH 2/5] intel: Handle malloc fails in context create Ben Widawsky
2014-01-03  5:50   ` [PATCH 3/5] intel: Merge latest i915_drm.h Ben Widawsky
2014-01-03  5:50   ` [PATCH 4/5] intel: Intel full PPGTT param Ben Widawsky
2014-01-07  7:53     ` Daniel Vetter
2014-01-09 23:20       ` Ben Widawsky
2014-01-03  5:50   ` [PATCH 5/5] configure.ac: bump version to 2.4.51 for release Ben Widawsky
2014-01-03  5:50   ` Ben Widawsky [this message]
2014-02-23 20:32     ` [Intel-gfx] [PATCH] i965: Use default contexts when possible Ben Widawsky
2014-01-03 12:07   ` [PATCH] [v2] drm/i915/ppgtt: Never return a NULL context Mika Kuoppala
2014-01-07  7:51     ` Daniel Vetter
     [not found]       ` <CALNAZXq8EZ4Wmq2ONz08gNFcEv4Bi-JzBasEvnAKWEfEWyf_xw@mail.gmail.com>
     [not found]         ` <CAKMK7uE9aai27U7jwGe0jK5AzjxKx40z8VyS1D4mr__a5x-Qeg@mail.gmail.com>
2014-01-10 23:20           ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1388728235-20410-9-git-send-email-benjamin.widawsky@intel.com \
    --to=benjamin.widawsky@intel.com \
    --cc=ben@bwidawsk.net \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=kenneth.w.graunke@intel.com \
    --cc=mesa-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox