Mesa (master): xorg/vmwgfx: Implement early mode pruning based on max fb size.

Thomas Hellstrom thomash at kemper.freedesktop.org
Fri Jul 23 11:19:08 UTC 2010


Module: Mesa
Branch: master
Commit: a96feddddb64f6839bc292ffdbe5834a8dbb340d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a96feddddb64f6839bc292ffdbe5834a8dbb340d

Author: Thomas Hellstrom <thellstrom at vmware.com>
Date:   Fri Jul 23 04:44:26 2010 +0200

xorg/vmwgfx: Implement early mode pruning based on max fb size.

Also move some initialization from screen init to pre-init, now
that it is possible.

Also import a new vmwgfx drm (1.3) header.

Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>

---

 src/gallium/targets/xorg-vmwgfx/vmw_driver.h |    1 +
 src/gallium/targets/xorg-vmwgfx/vmw_screen.c |   39 +++++++++++++++++++++++--
 src/gallium/winsys/svga/drm/vmwgfx_drm.h     |    1 +
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_driver.h b/src/gallium/targets/xorg-vmwgfx/vmw_driver.h
index d6e3620..8dfc9d2 100644
--- a/src/gallium/targets/xorg-vmwgfx/vmw_driver.h
+++ b/src/gallium/targets/xorg-vmwgfx/vmw_driver.h
@@ -59,6 +59,7 @@ struct vmw_customizer
 
     /* vmw_video.c */
     void *video_priv;
+    uint64_t max_fb_size;
 };
 
 static INLINE struct vmw_customizer *
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_screen.c b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
index 514c3f1..8173908 100644
--- a/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
+++ b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
@@ -35,6 +35,7 @@
 #include <pipe/p_context.h>
 
 #include "cursorstr.h"
+#include "../../winsys/svga/drm/vmwgfx_drm.h"
 
 void vmw_winsys_screen_set_throttling(struct pipe_screen *screen,
 				      uint32_t throttle_us);
@@ -111,21 +112,28 @@ vmw_context_no_throttle(CustomizerPtr cust,
 }
 
 static Bool
-vmw_pre_init(CustomizerPtr cust, int fd)
+vmw_check_fb_size(CustomizerPtr cust,
+		  unsigned long pitch,
+		  unsigned long height)
 {
     struct vmw_customizer *vmw = vmw_customizer(cust);
 
-    vmw->fd = fd;
+    /**
+     *  1) Is there a pitch alignment?
+     *  2) The 1024 byte pad is an arbitrary value to be on
+     */
 
-    return TRUE;
+    return ((uint64_t) pitch * height + 1024ULL < vmw->max_fb_size);
 }
 
 static Bool
-vmw_screen_init(CustomizerPtr cust)
+vmw_pre_init(CustomizerPtr cust, int fd)
 {
     struct vmw_customizer *vmw = vmw_customizer(cust);
     drmVersionPtr ver;
 
+    vmw->fd = fd;
+
     ver = drmGetVersion(vmw->fd);
     if (ver == NULL ||
 	(ver->version_major == 1 && ver->version_minor < 1)) {
@@ -137,11 +145,34 @@ vmw_screen_init(CustomizerPtr cust)
 	cust->dirty_throttling = FALSE;
 	cust->winsys_context_throttle = vmw_context_throttle;
 	debug_printf("%s: Enabling kernel throttling.\n", __func__);
+
+	if (ver->version_major > 1 ||
+	    (ver->version_major == 1 && ver->version_minor >= 3)) {
+	    struct drm_vmw_getparam_arg arg;
+	    int ret;
+
+	    arg.param = DRM_VMW_PARAM_MAX_FB_SIZE;
+	    ret = drmCommandWriteRead(fd, DRM_VMW_GET_PARAM, &arg,
+				      sizeof(arg));
+	    if (!ret) {
+		vmw->max_fb_size = arg.value;
+		cust->winsys_check_fb_size = vmw_check_fb_size;
+		debug_printf("%s: Enabling fb size check.\n", __func__);
+	    }
+	}
     }
 
     if (ver)
 	drmFreeVersion(ver);
 
+    return TRUE;
+}
+
+static Bool
+vmw_screen_init(CustomizerPtr cust)
+{
+    struct vmw_customizer *vmw = vmw_customizer(cust);
+
     vmw_screen_cursor_init(vmw);
 
     vmw_ctrl_ext_init(vmw);
diff --git a/src/gallium/winsys/svga/drm/vmwgfx_drm.h b/src/gallium/winsys/svga/drm/vmwgfx_drm.h
index fbb1a8f..2f2807d 100644
--- a/src/gallium/winsys/svga/drm/vmwgfx_drm.h
+++ b/src/gallium/winsys/svga/drm/vmwgfx_drm.h
@@ -72,6 +72,7 @@
 #define DRM_VMW_PARAM_FIFO_OFFSET      3
 #define DRM_VMW_PARAM_HW_CAPS          4
 #define DRM_VMW_PARAM_FIFO_CAPS        5
+#define DRM_VMW_PARAM_MAX_FB_SIZE      6
 
 /**
  * struct drm_vmw_getparam_arg




More information about the mesa-commit mailing list