st/dri: add inline for dri2 check done in multiple places
authorGeorge Sapountzis <gsapountzis@gmail.com>
Thu, 25 Mar 2010 15:01:51 +0000 (17:01 +0200)
committerGeorge Sapountzis <gsapountzis@gmail.com>
Thu, 25 Mar 2010 15:01:51 +0000 (17:01 +0200)
src/gallium/state_trackers/dri/dri_screen.c
src/gallium/state_trackers/dri/dri_screen.h
src/gallium/state_trackers/dri/dri_st_api.c

index 17b9f1c5faf610d22c4fd04b577c056eea92787f..733d71f99595e45657270573d45ab78348632e9c 100644 (file)
@@ -148,9 +148,7 @@ dri_fill_in_modes(struct dri_screen *screen,
                                             PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
 
    /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
-   if (screen->sPriv->dri2.loader &&
-       (screen->sPriv->dri2.loader->base.version > 2) &&
-       (screen->sPriv->dri2.loader->getBuffersWithFormat != NULL)) {
+   if (dri_with_format(screen->sPriv)) {
       pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
                                              PIPE_TEXTURE_2D,
                                              PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
@@ -352,8 +350,6 @@ dri_init_screen2(__DRIscreen * sPriv)
 {
    struct dri_screen *screen;
    struct drm_create_screen_arg arg;
-   const __DRIdri2LoaderExtension *dri2_ext =
-     sPriv->dri2.loader;
 
    screen = CALLOC_STRUCT(dri_screen);
    if (!screen)
@@ -379,8 +375,7 @@ dri_init_screen2(__DRIscreen * sPriv)
    driParseOptionInfo(&screen->optionCache,
                      __driConfigOptions, __driNConfigOptions);
 
-   screen->auto_fake_front = dri2_ext->base.version >= 3 &&
-      dri2_ext->getBuffersWithFormat != NULL;
+   screen->auto_fake_front = dri_with_format(sPriv);
 
    return dri_fill_in_modes(screen, 32);
 fail:
index e9944e0f63e20e35934ce18f06bbc53910363a85..3b805c539f9d2275873ca6ef8a25d2851dc25de1 100644 (file)
@@ -75,6 +75,16 @@ dri_screen(__DRIscreen * sPriv)
    return (struct dri_screen *)sPriv->private;
 }
 
+static INLINE boolean
+dri_with_format(__DRIscreen * sPriv)
+{
+   const __DRIdri2LoaderExtension *loader = sPriv->dri2.loader;
+
+   return loader
+       && (loader->base.version >= 3)
+       && (loader->getBuffersWithFormat != NULL);
+}
+
 extern const uint __driNConfigOptions;
 
 const __DRIconfig **
index 263c1e19a7036c235bdfe258009b76e5a4fe4bf8..67ab89e7aa87108ba295a9704bfd38307d21f413 100644 (file)
@@ -172,7 +172,7 @@ dri_drawable_get_buffers(struct dri_drawable *drawable,
    unsigned num_attachments, i;
 
    assert(loader);
-   with_format = (loader->base.version > 2 && loader->getBuffersWithFormat);
+   with_format = dri_with_format(drawable->sPriv);
 
    num_attachments = 0;