r300g, radeon-gallium: Fix API, cleanup.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Thu, 23 Jul 2009 14:14:07 +0000 (07:14 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Thu, 23 Jul 2009 14:18:29 +0000 (07:18 -0700)
Something called "validate" should return FALSE on failure, not TRUE.

src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_surface.c
src/gallium/winsys/drm/radeon/core/radeon_drm.c
src/gallium/winsys/drm/radeon/core/radeon_drm.h
src/gallium/winsys/drm/radeon/core/radeon_r300.c
src/gallium/winsys/drm/radeon/core/radeon_r300.h

index 7ba56cdc1d221832d218b8938a59ada5d9313672..ac510ffc2ed5ed3f9b8bc766cc6afeb197406044 100644 (file)
@@ -531,10 +531,11 @@ validate:
     } else {
         debug_printf("No VBO while emitting dirty state!\n");
     }
-    if (r300->winsys->validate(r300->winsys)) {
+    if (!r300->winsys->validate(r300->winsys)) {
         r300->context.flush(&r300->context, 0, NULL);
         if (invalid) {
             /* Well, hell. */
+            debug_printf("r300: Stuck in validation loop, gonna quit now.");
             exit(1);
         }
         invalid = TRUE;
index fdabe4d9cfed39e0261e9a1ca4f6cbe3345e7db7..25168ce5e950d0fe2bf8b15f2191d6422018554d 100644 (file)
@@ -125,9 +125,10 @@ validate:
         r300->context.flush(&r300->context, 0, NULL);
         goto validate;
     }
-    if (r300->winsys->validate(r300->winsys)) {
+    if (!r300->winsys->validate(r300->winsys)) {
         r300->context.flush(&r300->context, 0, NULL);
         if (invalid) {
+            debug_printf("r300: Stuck in validation loop, gonna fallback.");
             goto fallback;
         }
         invalid = TRUE;
@@ -256,9 +257,10 @@ validate:
         r300->context.flush(&r300->context, 0, NULL);
         goto validate;
     }
-    if (r300->winsys->validate(r300->winsys)) {
+    if (!r300->winsys->validate(r300->winsys)) {
         r300->context.flush(&r300->context, 0, NULL);
         if (invalid) {
+            debug_printf("r300: Stuck in validation loop, gonna fallback.");
             goto fallback;
         }
         invalid = TRUE;
index d6e4e4b5eb11c90143424ff733bf88053f2c618d..8d818cf830122119496e55050b64c8b63afdf6cd 100644 (file)
  */
 
 #include "radeon_drm.h"
-#include "trace/tr_drm.h"
-
-#include "r300_screen.h"
-#include "xf86drm.h"
-
-#include <sys/ioctl.h>
 
 /* Create a pipe_screen. */
 struct pipe_screen* radeon_create_screen(struct drm_api* api,
@@ -59,7 +53,8 @@ struct pipe_context* radeon_create_context(struct drm_api* api,
     if (getenv("RADEON_SOFTPIPE")) {
         return radeon_create_softpipe(screen->winsys);
     } else {
-        return r300_create_context(screen, screen->winsys);
+        return r300_create_context(screen,
+                                   (struct r300_winsys*)screen->winsys);
     }
 }
 
index 8560f71db653d26370a9e8ac74157f34a18390f6..88a5c82b284b67ed822bc771e0618833365d891a 100644 (file)
 #ifndef RADEON_DRM_H
 #define RADEON_DRM_H
 
+#include <sys/ioctl.h>
+
+#include "xf86drm.h"
+
 #include "pipe/p_screen.h"
 
+#include "trace/tr_drm.h"
 #include "util/u_memory.h"
 
 #include "state_tracker/drm_api.h"
@@ -40,6 +45,9 @@
 #include "radeon_r300.h"
 #include "radeon_winsys_softpipe.h"
 
+/* XXX */
+#include "r300_screen.h"
+
 struct pipe_screen* radeon_create_screen(struct drm_api* api,
                                          int drmFB,
                                         struct drm_create_screen_arg *arg);
index ac33ea4c6e2d1a30a3cc7e77621aba436463b8f1..e927409e3ab4ba0c0de38ab3e94e301be2ea95ec 100644 (file)
@@ -41,11 +41,11 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys)
         (struct radeon_winsys_priv*)winsys->radeon_winsys;
 
     if (radeon_cs_space_check(priv->cs) < 0) {
-        return TRUE;
+        return FALSE;
     }
 
     /* Things are fine, we can proceed as normal. */
-    return FALSE;
+    return TRUE;
 }
 
 static boolean radeon_r300_check_cs(struct r300_winsys* winsys, int size)
@@ -118,10 +118,15 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys)
         debug_printf("radeon: Bad CS, dumping...\n");
         radeon_cs_print(priv->cs, stderr);
     }
-    radeon_cs_erase(priv->cs);
 
     /* Clean out BOs. */
     radeon_cs_space_reset_bos(priv->cs);
+
+    /* Reset CS.
+     * Someday, when we care about performance, we should really find a way
+     * to rotate between two or three CS objects so that the GPU can be
+     * spinning through one CS while another one is being filled. */
+    radeon_cs_erase(priv->cs);
 }
 
 /* Helper function to do the ioctls needed for setup and init. */
index 7f0246cc7adc097c7d169fdf911009ac8a97304e..741c13718895ed4441c1c632b7a34cf863f49d05 100644 (file)
 
 #include "radeon_buffer.h"
 
-/* protect us from bonghits */
-#ifndef RADEON_INFO_DEVICE_ID
-#define RADEON_INFO_DEVICE_ID 0
-#endif
-#ifndef DRM_RADEON_INFO
-#define DRM_RADEON_INFO 0x1
-struct drm_radeon_info {
-       uint32_t                request;
-       uint32_t                pad;
-       uint64_t                value;
-};
-#endif
-
 struct radeon_winsys;
 
 struct r300_winsys*