radeon: fix context destroy needing lock for flushing.
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_screen.c
index c8d491621a850a7b00f255b8f21990baf8bf901b..5ffb55db5efc3c6761a2ab62481d15dc847f1179 100644 (file)
@@ -220,30 +220,6 @@ static const GLuint __driNConfigOptions = 17;
 
 extern const struct dri_extension gl_20_extension[];
 
-#ifndef RADEON_DEBUG
-
-static const struct dri_debug_control debug_control[] = {
-       {"fall", DEBUG_FALLBACKS},
-       {"tex", DEBUG_TEXTURE},
-       {"ioctl", DEBUG_IOCTL},
-       {"prim", DEBUG_PRIMS},
-       {"vert", DEBUG_VERTS},
-       {"state", DEBUG_STATE},
-       {"code", DEBUG_CODEGEN},
-       {"vfmt", DEBUG_VFMT},
-       {"vtxf", DEBUG_VFMT},
-       {"verb", DEBUG_VERBOSE},
-       {"dri", DEBUG_DRI},
-       {"dma", DEBUG_DMA},
-       {"san", DEBUG_SANITY},
-       {"sync", DEBUG_SYNC},
-       {"pix", DEBUG_PIXEL},
-       {"mem", DEBUG_MEMORY},
-       {"allmsg", ~DEBUG_SYNC}, /* avoid the term "sync" because the parser uses strstr */
-       {NULL, 0}
-};
-#endif /* RADEON_DEBUG */
-
 #endif /* RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) */
 
 extern const struct dri_extension card_extensions[];
@@ -259,7 +235,7 @@ radeonGetParam(__DRIscreenPrivate *sPriv, int param, void *value)
   struct drm_radeon_info info = { 0 };
 
   if (sPriv->drm_version.major >= 2) {
-      info.value = (uint64_t)value;
+      info.value = (uint64_t)(uintptr_t)value;
       switch (param) {
       case RADEON_PARAM_DEVICE_ID:
           info.request = RADEON_INFO_DEVICE_ID;
@@ -267,6 +243,9 @@ radeonGetParam(__DRIscreenPrivate *sPriv, int param, void *value)
       case RADEON_PARAM_NUM_GB_PIPES:
           info.request = RADEON_INFO_NUM_GB_PIPES;
           break;
+      case RADEON_PARAM_NUM_Z_PIPES:
+          info.request = RADEON_INFO_NUM_Z_PIPES;
+          break;
       default:
           return -EINVAL;
       }
@@ -853,10 +832,19 @@ static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id)
       screen->chip_family = CHIP_FAMILY_RS780;
       screen->chip_flags = RADEON_CHIPSET_TCL;
       break;
+   case PCI_CHIP_RS880_9710:
+   case PCI_CHIP_RS880_9711:
+   case PCI_CHIP_RS880_9712:
+   case PCI_CHIP_RS880_9713:
+   case PCI_CHIP_RS880_9714:
+      screen->chip_family = CHIP_FAMILY_RS880;
+      screen->chip_flags = RADEON_CHIPSET_TCL;
+      break;
 
    case PCI_CHIP_RV770_9440:
    case PCI_CHIP_RV770_9441:
    case PCI_CHIP_RV770_9442:
+   case PCI_CHIP_RV770_9443:
    case PCI_CHIP_RV770_9444:
    case PCI_CHIP_RV770_9446:
    case PCI_CHIP_RV770_944A:
@@ -954,9 +942,8 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
       return NULL;
    }
 
-#if DO_DEBUG && RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
-       RADEON_DEBUG = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);
-#endif
+   radeon_init_debug();
+
    /* parse information in __driConfigOptions */
    driParseOptionInfo (&screen->optionCache,
                       __driConfigOptions, __driNConfigOptions);
@@ -1163,6 +1150,15 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
        default:
           break;
        }
+
+       if ( sPriv->drm_version.minor >= 31 ) {
+              ret = radeonGetParam(sPriv, RADEON_PARAM_NUM_Z_PIPES, &temp);
+              if (ret)
+                      screen->num_z_pipes = 2;
+              else
+                      screen->num_z_pipes = temp;
+       } else
+              screen->num_z_pipes = 2;
    }
 
    if ( sPriv->drm_version.minor >= 10 ) {
@@ -1280,9 +1276,7 @@ radeonCreateScreen2(__DRIscreenPrivate *sPriv)
       return NULL;
    }
 
-#if DO_DEBUG && RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
-       RADEON_DEBUG = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);
-#endif
+   radeon_init_debug();
 
    /* parse information in __driConfigOptions */
    driParseOptionInfo (&screen->optionCache,
@@ -1364,6 +1358,12 @@ radeonCreateScreen2(__DRIscreenPrivate *sPriv)
           break;
        }
 
+       ret = radeonGetParam(sPriv, RADEON_PARAM_NUM_Z_PIPES, &temp);
+       if (ret)
+              screen->num_z_pipes = 2;
+       else
+              screen->num_z_pipes = temp;
+
    }
 
    i = 0;
@@ -1578,28 +1578,6 @@ radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
     _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
-/**
- * Choose the appropriate CreateContext function based on the chipset.
- * Eventually, all drivers will go through this process.
- */
-static GLboolean radeonCreateContext(const __GLcontextModes * glVisual,
-                                    __DRIcontextPrivate * driContextPriv,
-                                    void *sharedContextPriv)
-{
-       __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
-       radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
-#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
-       if (IS_R300_CLASS(screen))
-               return r300CreateContext(glVisual, driContextPriv, sharedContextPriv);
-#endif
-
-#if !RADEON_COMMON
-       (void)screen;
-       return r100CreateContext(glVisual, driContextPriv, sharedContextPriv);
-#endif
-       return GL_FALSE;
-}
-
 
 /**
  * This is the driver specific part of the createNewScreen entry point.
@@ -1712,6 +1690,8 @@ __DRIconfig **radeonInitScreen2(__DRIscreenPrivate *psp)
    driInitSingleExtension( NULL, NV_vp_extension );
    driInitSingleExtension( NULL, ATI_fs_extension );
    driInitExtensions( NULL, point_extensions, GL_FALSE );
+#elif (defined(RADEON_COMMON_FOR_R300) || defined(RADEON_COMMON_FOR_R600))
+   driInitSingleExtension( NULL, gl_20_extension );
 #endif
 
    if (!radeonInitDriver(psp)) {
@@ -1797,9 +1777,12 @@ const struct __DriverAPIRec driDriverAPI = {
    .DestroyContext  = r200DestroyContext,
 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R600)
    .CreateContext   = r600CreateContext,
-   .DestroyContext  = r600DestroyContext,
+   .DestroyContext  = radeonDestroyContext,
+#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
+   .CreateContext   = r300CreateContext,
+   .DestroyContext  = radeonDestroyContext,
 #else
-   .CreateContext   = radeonCreateContext,
+   .CreateContext   = r100CreateContext,
    .DestroyContext  = radeonDestroyContext,
 #endif
    .CreateBuffer    = radeonCreateBuffer,