dri/radeon: use a const __DRIextension array
authorEmil Velikov <emil.l.velikov@gmail.com>
Tue, 18 Feb 2014 03:43:14 +0000 (03:43 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Mon, 28 Apr 2014 18:11:27 +0000 (19:11 +0100)
Rather than keeping a separate and unused copy of the screen extensions
within the radeon screen, use a constant array that can be used directly
with __DRIscreen.

[Kristian Høgsberg]
The copy in the radeon screen isn't unused, that's where the array is
built and stored, the dri screen just points to that.  The pattern
here was used for cases where the extensions exported by a dri driver
could vary at runtime, for example depending on chipset.  In this
case, it's known at compile time, so it makes sense to use a static
const array instead.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
src/mesa/drivers/dri/radeon/radeon_screen.c
src/mesa/drivers/dri/radeon/radeon_screen.h

index dd940382be0a101cc23021c3b7ac226eb574e36b..fe72b775228339a6047c3dc9545ac4d6e9b9e396 100644 (file)
@@ -481,11 +481,23 @@ static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id)
    return 0;
 }
 
+
+static const __DRIextension *radeon_screen_extensions[] = {
+    &dri2ConfigQueryExtension.base,
+#if defined(RADEON_R100)
+    &radeonTexBufferExtension.base,
+#elif defined(RADEON_R200)
+    &r200TexBufferExtension.base,
+#endif
+    &radeonFlushExtension.base,
+    &radeonImageExtension.base,
+    NULL
+};
+
 static radeonScreenPtr
 radeonCreateScreen2(__DRIscreen *sPriv)
 {
    radeonScreenPtr screen;
-   int i;
    int ret;
    uint32_t device_id = 0;
 
@@ -522,20 +534,7 @@ radeonCreateScreen2(__DRIscreen *sPriv)
    if (getenv("RADEON_NO_TCL"))
           screen->chip_flags &= ~RADEON_CHIPSET_TCL;
 
-   i = 0;
-   screen->extensions[i++] = &dri2ConfigQueryExtension.base;
-
-#if defined(RADEON_R100)
-   screen->extensions[i++] = &radeonTexBufferExtension.base;
-#elif defined(RADEON_R200)
-   screen->extensions[i++] = &r200TexBufferExtension.base;
-#endif
-
-   screen->extensions[i++] = &radeonFlushExtension.base;
-   screen->extensions[i++] = &radeonImageExtension.base;
-
-   screen->extensions[i++] = NULL;
-   sPriv->extensions = screen->extensions;
+   sPriv->extensions = radeon_screen_extensions;
 
    screen->driScreen = sPriv;
    screen->bom = radeon_bo_manager_gem_ctor(sPriv->fd);
index 03abb2a2b55123e7b02ad7c80c3dccb2afc221ed..76fa1ec05dd7906271cb2a9145c0327001c10809 100644 (file)
@@ -97,8 +97,6 @@ typedef struct radeon_screen {
    /* Configuration cache with default values for all contexts */
    driOptionCache optionCache;
 
-   const __DRIextension *extensions[17];
-
    int num_gb_pipes;
    int num_z_pipes;
    drm_radeon_sarea_t *sarea;  /* Private SAREA data */