[Mesa-dev] [PATCH 19/25] gallium/i915: handle query_renderer caps

Emil Velikov emil.l.velikov at gmail.com
Fri Feb 21 19:04:09 PST 2014


Implementation is a verbatim copy from the classic driver.

This introduces a driver dependency on libdrm-intel, as the winsys does not
cache the aperture size of the device.

Cc: Stephane Marchesin <stephane.marchesin at gmail.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---

NOTE: This _will_ fail on i915/sw due to the lack of fd on the
particular winsys.

Stephane,
Perhaps we can take a look at i915/sw, its users and future.

I can vision (but I'm not planing to pursue) some cleanups
if the software winsys is retired.

Cheers
-Emil

 src/gallium/drivers/i915/Makefile.am   |  3 ++-
 src/gallium/drivers/i915/SConscript    |  2 ++
 src/gallium/drivers/i915/i915_screen.c | 39 ++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/i915/Makefile.am b/src/gallium/drivers/i915/Makefile.am
index a4a3e86..67936ca 100644
--- a/src/gallium/drivers/i915/Makefile.am
+++ b/src/gallium/drivers/i915/Makefile.am
@@ -24,7 +24,8 @@ include Makefile.sources
 include $(top_srcdir)/src/gallium/Automake.inc
 
 AM_CFLAGS = \
-	$(GALLIUM_DRIVER_CFLAGS)
+	$(GALLIUM_DRIVER_CFLAGS) \
+	$(INTEL_CFLAGS)
 
 noinst_LTLIBRARIES = libi915.la
 
diff --git a/src/gallium/drivers/i915/SConscript b/src/gallium/drivers/i915/SConscript
index 22de67d..a04517e 100644
--- a/src/gallium/drivers/i915/SConscript
+++ b/src/gallium/drivers/i915/SConscript
@@ -2,6 +2,8 @@ Import('*')
 
 env = env.Clone()
 
+env.PkgUseModules('DRM_INTEL')
+
 i915 = env.ConvenienceLibrary(
 	target = 'i915',
 	source = env.ParseSourceList('Makefile.sources', 'C_SOURCES')
diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
index 1f55a06..3970dae 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 
+#include <intel_bufmgr.h>
 #include "draw/draw_context.h"
 #include "util/u_format.h"
 #include "util/u_format_s3tc.h"
@@ -40,6 +41,7 @@
 #include "i915_resource.h"
 #include "i915_winsys.h"
 #include "i915_public.h"
+#include <../winsys/i915/drm/i915_drm_winsys.h>
 
 
 /*
@@ -281,6 +283,43 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_MAX_GL_ES2_VERSION:
       return 20;
 
+   case PIPE_CAP_VENDOR_ID:
+      return 0x8086;
+   case PIPE_CAP_DEVICE_ID:
+      return is->iws->pci_id;
+   case PIPE_CAP_ACCELERATED:
+      return 1;
+   case PIPE_CAP_VIDEO_MEMORY: {
+      /* Once a batch uses more than 75% of the maximum mappable size, we
+       * assume that there's some fragmentation, and we start doing extra
+       * flushing, etc.  That's the big cliff apps will care about.
+       */
+      struct i915_drm_winsys *idws =(struct i915_drm_winsys *)is->iws;
+      size_t aper_size;
+      size_t mappable_size;
+
+      drm_intel_get_aperture_sizes(idws->fd, &mappable_size, &aper_size);
+
+      const unsigned gpu_mappable_megabytes =
+         (aper_size / (1024 * 1024)) * 3 / 4;
+
+      const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
+      const long system_page_size = sysconf(_SC_PAGE_SIZE);
+
+      if (system_memory_pages <= 0 || system_page_size <= 0)
+         return 0;
+
+      const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
+         * (uint64_t) system_page_size;
+
+      const unsigned system_memory_megabytes =
+         (unsigned) (system_memory_bytes / (1024 * 1024));
+
+      return MIN2(system_memory_megabytes, gpu_mappable_megabytes);
+   }
+   case PIPE_CAP_UMA:
+      return 1;
+
    default:
       debug_printf("%s: Unknown cap %u.\n", __FUNCTION__, cap);
       return 0;
-- 
1.9.0



More information about the mesa-dev mailing list