Mesa (master): r300g: generalize the way we ask for hyperz

Marek Olšák mareko at kemper.freedesktop.org
Sun Aug 8 20:29:25 UTC 2010


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

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sat Aug  7 02:05:03 2010 +0200

r300g: generalize the way we ask for hyperz

This makes it compatible with the modified DRM interface in drm-radeon-testing.

Also, now you need to set RADEON_HYPERZ=1 to be able to use hyperz.
It's not bug-free yet.

---

 src/gallium/winsys/radeon/drm/radeon_drm.c |   35 ++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm.c b/src/gallium/winsys/radeon/drm/radeon_drm.c
index ecaf096..593741b 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm.c
@@ -55,6 +55,31 @@ radeon_winsys_create(int fd)
     return rws;
 }
 
+/* Enable/disable Hyper-Z access. Return TRUE on success. */
+static boolean radeon_set_hyperz_access(int fd, boolean enable)
+{
+#ifndef RADEON_INFO_WANT_HYPERZ
+#define RADEON_INFO_WANT_HYPERZ 7
+#endif
+
+    struct drm_radeon_info info = {0};
+    unsigned value = enable ? 1 : 0;
+
+    if (!debug_get_bool_option("RADEON_HYPERZ", FALSE))
+        return FALSE;
+
+    info.value = (unsigned long)&value;
+    info.request = RADEON_INFO_WANT_HYPERZ;
+
+    if (drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)) != 0)
+        return FALSE;
+
+    if (enable && !value)
+        return FALSE;
+
+    return TRUE;
+}
+
 /* Helper function to do the ioctls needed for setup and init. */
 static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys)
 {
@@ -134,15 +159,7 @@ static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys)
     }
     winsys->z_pipes = target;
 
-    winsys->hyperz = FALSE;
-#ifndef RADEON_INFO_WANT_HYPERZ
-#define RADEON_INFO_WANT_HYPERZ 7
-#endif
-    info.request = RADEON_INFO_WANT_HYPERZ;
-    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
-    if (!retval && target == 1) {
-        winsys->hyperz = TRUE;
-    }
+    winsys->hyperz = radeon_set_hyperz_access(fd, TRUE);
 
     retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO,
             &gem_info, sizeof(gem_info));




More information about the mesa-commit mailing list