[Intel-gfx] [PATCH] i965: Use default contexts when possible.

Ben Widawsky benjamin.widawsky at intel.com
Fri Jan 3 06:50:35 CET 2014


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 at intel.com>
Signed-off-by: Ben Widawsky <ben at 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




More information about the Intel-gfx mailing list