gallium/i915: handle query_renderer caps
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 14 Aug 2014 19:11:32 +0000 (20:11 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 15 Aug 2014 16:42:46 +0000 (17:42 +0100)
Implementation based on the classic driver with the following
changes:
 - Use auxiliarry function os_get_total_physical_memory to get the
total amount of memory.
 - Move the libdrm_intel specific get_aperture_size to the winsys.

Cc: Stephane Marchesin <stephane.marchesin@gmail.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/i915/i915_winsys.h
src/gallium/winsys/i915/drm/i915_drm_winsys.c

index 53d5e7580b50a61133d19063259fea809457ed1e..3af0b151b5af62c9c283b7a4b8b21de3573b05f7 100644 (file)
@@ -27,6 +27,7 @@
 
 
 #include "draw/draw_context.h"
+#include "os/os_misc.h"
 #include "util/u_format.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_inlines.h"
@@ -283,6 +284,28 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_ENDIANNESS:
       return PIPE_ENDIAN_LITTLE;
 
+   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.
+       */
+      const int gpu_mappable_megabytes = is->iws->aperture_size(is->iws) * 3 / 4;
+      uint64_t system_memory;
+
+      if (!os_get_total_physical_memory(&system_memory))
+         return 0;
+
+      return MIN2(gpu_mappable_megabytes, (int) (system_memory >> 20));
+   }
+   case PIPE_CAP_UMA:
+      return 1;
+
    default:
       debug_printf("%s: Unknown cap %u.\n", __FUNCTION__, cap);
       return 0;
index 8823c549a3312e0dfe7ce37a8040aa1379f40e8c..6cf802fe073930f192a86612bdc23dd4cbc2f3d2 100644 (file)
@@ -247,6 +247,11 @@ struct i915_winsys {
                        struct pipe_fence_handle *fence);
    /*@}*/
 
+   /**
+    * Retrieve the aperture size (in MiB) of the device.
+    */
+   int (*aperture_size)(struct i915_winsys *iws);
+
 
    /**
     * Destroy the winsys.
index 9e16f409ceab1184bbc00a96704b07dfb11f63b0..d4a2e013ae6e35abef4a76b0632e849f0839127e 100644 (file)
@@ -28,6 +28,17 @@ i915_drm_get_device_id(int fd, unsigned int *device_id)
    assert(ret == 0);
 }
 
+static int
+i915_drm_aperture_size(struct i915_winsys *iws)
+{
+   struct i915_drm_winsys *idws = i915_drm_winsys(iws);
+   size_t aper_size, mappable_size;
+
+   drm_intel_get_aperture_sizes(idws->fd, &mappable_size, &aper_size);
+
+   return aper_size >> 20;
+}
+
 static void
 i915_drm_winsys_destroy(struct i915_winsys *iws)
 {
@@ -58,6 +69,7 @@ i915_drm_winsys_create(int drmFD)
    idws->base.pci_id = deviceID;
    idws->max_batch_size = 1 * 4096;
 
+   idws->base.aperture_size = i915_drm_aperture_size;
    idws->base.destroy = i915_drm_winsys_destroy;
 
    idws->gem_manager = drm_intel_bufmgr_gem_init(idws->fd, idws->max_batch_size);