diff options
Diffstat (limited to 'src/gallium/state_trackers')
28 files changed, 544 insertions, 150 deletions
| diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index fe91cf59b4..458473853c 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -353,11 +353,11 @@ dri_create_buffer(__DRIscreen * sPriv,     if (visual->redBits == 8) {        if (visual->alphaBits == 8) -         drawable->color_format = PIPE_FORMAT_A8R8G8B8_UNORM; +         drawable->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;        else -         drawable->color_format = PIPE_FORMAT_X8R8G8B8_UNORM; +         drawable->color_format = PIPE_FORMAT_B8G8R8X8_UNORM;     } else { -      drawable->color_format = PIPE_FORMAT_R5G6B5_UNORM; +      drawable->color_format = PIPE_FORMAT_B5G6R5_UNORM;     }     switch(visual->depthBits) { @@ -371,12 +371,12 @@ dri_create_buffer(__DRIscreen * sPriv,     case 24:        if (visual->stencilBits == 0) {  	 drawable->depth_stencil_format = (screen->d_depth_bits_last) ? -                                          PIPE_FORMAT_X8Z24_UNORM: -                                          PIPE_FORMAT_Z24X8_UNORM; +                                          PIPE_FORMAT_Z24X8_UNORM: +                                          PIPE_FORMAT_X8Z24_UNORM;        } else {  	 drawable->depth_stencil_format = (screen->sd_depth_bits_last) ? -                                          PIPE_FORMAT_S8Z24_UNORM: -                                          PIPE_FORMAT_Z24S8_UNORM; +                                          PIPE_FORMAT_Z24S8_UNORM: +                                          PIPE_FORMAT_S8Z24_UNORM;        }        break;     case 32: diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 77d640227f..60bc560049 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -109,22 +109,22 @@ dri_fill_in_modes(struct dri_screen *screen,     stencil_bits_array[0] = 0;     depth_buffer_factor = 1; -   pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM, +   pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM,  					    PIPE_TEXTURE_2D,  					    PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); -   pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM, +   pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM,  					    PIPE_TEXTURE_2D,  					    PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); -   pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM, +   pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM,  					    PIPE_TEXTURE_2D,  					    PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); -   pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM, +   pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM,  					    PIPE_TEXTURE_2D,  					    PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); -   pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_A8R8G8B8_UNORM, +   pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,  					       PIPE_TEXTURE_2D,  					       PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); -   pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8R8G8B8_UNORM, +   pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,  					       PIPE_TEXTURE_2D,  					       PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); @@ -139,7 +139,7 @@ dri_fill_in_modes(struct dri_screen *screen,        pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,                                               PIPE_TEXTURE_2D,                                               PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); -      pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_R5G6B5_UNORM, +      pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,                                                  PIPE_TEXTURE_2D,                                                  PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);     } else { diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 086e644e21..50774b03f3 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -36,6 +36,7 @@  #include "native.h"  #include "egl_g3d.h" +#include "egl_g3d_image.h"  #include "egl_st.h"  /** @@ -531,6 +532,24 @@ egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private)     egl_g3d_validate_context(gctx->base.Resource.Display, &gctx->base);  } +static void +egl_g3d_invalid_surface(struct native_display *ndpy, +                        struct native_surface *nsurf, +                        unsigned int seq_num) +{ +   /* XXX not thread safe? */ +   struct egl_g3d_surface *gsurf = egl_g3d_surface(nsurf->user_data); +   struct egl_g3d_context *gctx = egl_g3d_context(gsurf->base.CurrentContext); + +   /* set force_validate to skip an unnecessary check */ +   if (gctx) +      gctx->force_validate = TRUE; +} + +static struct native_event_handler egl_g3d_native_event_handler = { +   .invalid_surface = egl_g3d_invalid_surface +}; +  static EGLBoolean  egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy)  { @@ -575,12 +594,14 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,     }     dpy->DriverData = gdpy; -   gdpy->native = native_create_display(dpy->NativeDisplay); +   gdpy->native = native_create_display(dpy->NativeDisplay, +         &egl_g3d_native_event_handler);     if (!gdpy->native) {        _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)");        goto fail;     } +   gdpy->native->user_data = (void *) dpy;     gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer;     gdpy->native->screen->update_buffer = egl_g3d_update_buffer; @@ -595,6 +616,10 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,     }  #endif +   dpy->Extensions.KHR_image_base = EGL_TRUE; +   if (gdpy->native->get_param(gdpy->native, NATIVE_PARAM_USE_NATIVE_BUFFER)) +      dpy->Extensions.KHR_image_pixmap = EGL_TRUE; +     if (egl_g3d_add_configs(drv, dpy, 1) == 1) {        _eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)");        goto fail; @@ -776,6 +801,7 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,        return NULL;     } +   nsurf->user_data = &gsurf->base;     gsurf->native = nsurf;     gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER) ? @@ -937,8 +963,8 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)  /**   * Find a config that supports the pixmap.   */ -static _EGLConfig * -find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix) +_EGLConfig * +egl_g3d_find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix)  {     struct egl_g3d_display *gdpy = egl_g3d_display(dpy);     struct egl_g3d_config *gconf; @@ -990,7 +1016,7 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,     if (!gsurf->render_surface)        return EGL_TRUE; -   gconf = egl_g3d_config(find_pixmap_config(dpy, target)); +   gconf = egl_g3d_config(egl_g3d_find_pixmap_config(dpy, target));     if (!gconf)        return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); @@ -1097,7 +1123,7 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy,        target_format = PIPE_FORMAT_R8G8B8_UNORM;        break;     case EGL_TEXTURE_RGBA: -      target_format = PIPE_FORMAT_A8R8G8B8_UNORM; +      target_format = PIPE_FORMAT_B8G8R8A8_UNORM;        break;     default:        return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); @@ -1301,6 +1327,9 @@ _eglMain(const char *args)     gdrv->base.API.BindTexImage = egl_g3d_bind_tex_image;     gdrv->base.API.ReleaseTexImage = egl_g3d_release_tex_image; +   gdrv->base.API.CreateImageKHR = egl_g3d_create_image; +   gdrv->base.API.DestroyImageKHR = egl_g3d_destroy_image; +  #ifdef EGL_MESA_screen_surface     gdrv->base.API.CreateScreenSurfaceMESA = egl_g3d_create_screen_surface;     gdrv->base.API.ShowScreenSurfaceMESA = egl_g3d_show_screen_surface; diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h index 5d2d9c481a..e3e55e46d3 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.h +++ b/src/gallium/state_trackers/egl/common/egl_g3d.h @@ -34,6 +34,7 @@  #include "eglcontext.h"  #include "eglsurface.h"  #include "eglconfig.h" +#include "eglimage.h"  #include "eglscreen.h"  #include "eglmode.h" @@ -81,6 +82,14 @@ struct egl_g3d_config {     const struct native_config *native;  }; +struct egl_g3d_image { +   _EGLImage base; +   struct pipe_texture *texture; +   unsigned face; +   unsigned level; +   unsigned zslice; +}; +  struct egl_g3d_screen {     _EGLScreen base;     const struct native_connector *native; @@ -90,5 +99,10 @@ struct egl_g3d_screen {  /* standard typecasts */  _EGL_DRIVER_STANDARD_TYPECASTS(egl_g3d)  _EGL_DRIVER_TYPECAST(egl_g3d_screen, _EGLScreen, obj) +_EGL_DRIVER_TYPECAST(egl_g3d_image, _EGLImage, obj) + + +_EGLConfig * +egl_g3d_find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix);  #endif /* _EGL_G3D_H_ */ diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_image.c b/src/gallium/state_trackers/egl/common/egl_g3d_image.c new file mode 100644 index 0000000000..d701f9c9a8 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.c @@ -0,0 +1,136 @@ +/* + * Mesa 3-D graphics library + * Version:  7.8 + * + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + *    Chia-I Wu <olv@lunarg.com> + */ + +#include <assert.h> +#include "pipe/p_screen.h" +#include "util/u_memory.h" +#include "util/u_rect.h" +#include "util/u_inlines.h" +#include "eglcurrent.h" +#include "egllog.h" + +#include "native.h" +#include "egl_g3d.h" +#include "egl_g3d_image.h" + +/** + * Reference and return the front left buffer of the native pixmap. + */ +static struct pipe_texture * +egl_g3d_reference_native_pixmap(_EGLDisplay *dpy, EGLNativePixmapType pix) +{ +   struct egl_g3d_display *gdpy = egl_g3d_display(dpy); +   struct egl_g3d_config *gconf; +   struct native_surface *nsurf; +   struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; +   enum native_attachment natt; + +   gconf = egl_g3d_config(egl_g3d_find_pixmap_config(dpy, pix)); +   if (!gconf) +      return NULL; + +   nsurf = gdpy->native->create_pixmap_surface(gdpy->native, +         pix, gconf->native); +   if (!nsurf) +      return NULL; + +   natt = NATIVE_ATTACHMENT_FRONT_LEFT; +   if (!nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL)) +      textures[natt] = NULL; + +   nsurf->destroy(nsurf); + +   return textures[natt]; +} + +_EGLImage * +egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, +                     EGLenum target, EGLClientBuffer buffer, +                     const EGLint *attribs) +{ +   struct pipe_texture *ptex; +   struct egl_g3d_image *gimg; +   unsigned face = 0, level = 0, zslice = 0; + +   gimg = CALLOC_STRUCT(egl_g3d_image); +   if (!gimg) { +      _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); +      return NULL; +   } + +   if (!_eglInitImage(&gimg->base, dpy, attribs)) { +      free(gimg); +      return NULL; +   } + +   switch (target) { +   case EGL_NATIVE_PIXMAP_KHR: +      ptex = egl_g3d_reference_native_pixmap(dpy, +            (EGLNativePixmapType) buffer); +      break; +   default: +      ptex = NULL; +      break; +   } + +   if (!ptex) { +      free(gimg); +      return NULL; +   } + +   if (level > ptex->last_level) { +      _eglError(EGL_BAD_MATCH, "eglCreateEGLImageKHR"); +      pipe_texture_reference(&gimg->texture, NULL); +      free(gimg); +      return NULL; +   } +   if (zslice > ptex->depth0) { +      _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); +      pipe_texture_reference(&gimg->texture, NULL); +      free(gimg); +      return NULL; +   } + +   /* transfer the ownership to the image */ +   gimg->texture = ptex; +   gimg->face = face; +   gimg->level = level; +   gimg->zslice = zslice; + +   return &gimg->base; +} + +EGLBoolean +egl_g3d_destroy_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img) +{ +   struct egl_g3d_image *gimg = egl_g3d_image(img); + +   pipe_texture_reference(&gimg->texture, NULL); +   free(gimg); + +   return EGL_TRUE; +} diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_image.h b/src/gallium/state_trackers/egl/common/egl_g3d_image.h new file mode 100644 index 0000000000..c199c46645 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.h @@ -0,0 +1,41 @@ +/* + * Mesa 3-D graphics library + * Version:  7.8 + * + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + *    Chia-I Wu <olv@lunarg.com> + */ + +#ifndef _EGL_G3D_IMAGE_H_ +#define _EGL_G3D_IMAGE_H_ + +#include "egl_g3d.h" + +_EGLImage * +egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, +                     EGLenum target, EGLClientBuffer buffer, +                     const EGLint *attribs); + +EGLBoolean +egl_g3d_destroy_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image); + +#endif /* _EGL_G3D_IMAGE_H_ */ diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h index 4f9758545a..9c22ff3e43 100644 --- a/src/gallium/state_trackers/egl/common/native.h +++ b/src/gallium/state_trackers/egl/common/native.h @@ -34,6 +34,8 @@  #include "pipe/p_context.h"  #include "pipe/p_state.h" +#include "native_modeset.h" +  /**   * Only color buffers are listed.  The others are allocated privately through,   * for example, st_renderbuffer_alloc_storage(). @@ -47,6 +49,14 @@ enum native_attachment {     NUM_NATIVE_ATTACHMENTS  }; +enum native_param_type { +   /* +    * Return TRUE if window/pixmap surfaces use the buffers of the native +    * types. +    */ +   NATIVE_PARAM_USE_NATIVE_BUFFER +}; +  /**   * Enumerations for probe results.   */ @@ -69,6 +79,11 @@ struct native_probe {  };  struct native_surface { +   /** +    * Available for caller's use. +    */ +   void *user_data; +     void (*destroy)(struct native_surface *nsurf);     /** @@ -117,18 +132,6 @@ struct native_config {     boolean scanout_bit;  }; -struct native_connector { -   int dummy; -}; - -struct native_mode { -   const char *desc; -   int width, height; -   int refresh_rate; -}; - -struct native_display_modeset; -  /**   * A pipe winsys abstracts the OS.  A pipe screen abstracts the graphcis   * hardware.  A native display consists of a pipe winsys, a pipe screen, and @@ -143,9 +146,22 @@ struct native_display {      */     struct pipe_screen *screen; +   /** +    * Available for caller's use. +    */ +   void *user_data; +     void (*destroy)(struct native_display *ndpy);     /** +    * Query the parameters of the native display. +    * +    * The return value is defined by the parameter. +    */ +   int (*get_param)(struct native_display *ndpy, +                    enum native_param_type param); + +   /**      * Get the supported configs.  The configs are owned by the display, but      * the returned array should be free()ed.      * @@ -196,46 +212,17 @@ struct native_display {  };  /** - * Mode setting interface of the native display.  It exposes the mode setting - * capabilities of the underlying graphics hardware. + * The handler for events that a native display may generate.  The events are + * generated asynchronously and the handler may be called by any thread at any + * time.   */ -struct native_display_modeset { -   /** -    * Get the available physical connectors and the number of CRTCs. -    */ -   const struct native_connector **(*get_connectors)(struct native_display *ndpy, -                                                     int *num_connectors, -                                                     int *num_crtcs); - +struct native_event_handler {     /** -    * Get the current supported modes of a connector.  The returned modes may -    * change every time this function is called and those from previous calls -    * might become invalid. -    */ -   const struct native_mode **(*get_modes)(struct native_display *ndpy, -                                           const struct native_connector *nconn, -                                           int *num_modes); - -   /** -    * Create a scan-out surface.  Required unless no config has -    * GLX_SCREEN_BIT_MESA set. -    */ -   struct native_surface *(*create_scanout_surface)(struct native_display *ndpy, -                                                    const struct native_config *nconf, -                                                    uint width, uint height); - -   /** -    * Program the CRTC to output the surface to the given connectors with the -    * given mode.  When surface is not given, the CRTC is disabled. -    * -    * This interface does not export a way to query capabilities of the CRTCs. -    * The native display usually needs to dynamically map the index to a CRTC -    * that supports the given connectors. +    * This function is called when a surface needs to be validated.      */ -   boolean (*program)(struct native_display *ndpy, int crtc_idx, -                      struct native_surface *nsurf, uint x, uint y, -                      const struct native_connector **nconns, int num_nconns, -                      const struct native_mode *nmode); +   void (*invalid_surface)(struct native_display *ndpy, +                           struct native_surface *nsurf, +                           unsigned int seq_num);  };  /** @@ -267,6 +254,7 @@ const char *  native_get_name(void);  struct native_display * -native_create_display(EGLNativeDisplayType dpy); +native_create_display(EGLNativeDisplayType dpy, +                      struct native_event_handler *handler);  #endif /* _NATIVE_H_ */ diff --git a/src/gallium/state_trackers/egl/common/native_modeset.h b/src/gallium/state_trackers/egl/common/native_modeset.h new file mode 100644 index 0000000000..71dc3ec860 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/native_modeset.h @@ -0,0 +1,87 @@ +/* + * Mesa 3-D graphics library + * Version:  7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu <olv@0xlab.org> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _NATIVE_MODESET_H_ +#define _NATIVE_MODESET_H_ + +#include "pipe/p_compiler.h" + +struct native_display; +struct native_surface; +struct native_config; + +struct native_connector { +   int dummy; +}; + +struct native_mode { +   const char *desc; +   int width, height; +   int refresh_rate; +}; + +/** + * Mode setting interface of the native display.  It exposes the mode setting + * capabilities of the underlying graphics hardware. + */ +struct native_display_modeset { +   /** +    * Get the available physical connectors and the number of CRTCs. +    */ +   const struct native_connector **(*get_connectors)(struct native_display *ndpy, +                                                     int *num_connectors, +                                                     int *num_crtcs); + +   /** +    * Get the current supported modes of a connector.  The returned modes may +    * change every time this function is called and those from previous calls +    * might become invalid. +    */ +   const struct native_mode **(*get_modes)(struct native_display *ndpy, +                                           const struct native_connector *nconn, +                                           int *num_modes); + +   /** +    * Create a scan-out surface.  Required unless no config has +    * GLX_SCREEN_BIT_MESA set. +    */ +   struct native_surface *(*create_scanout_surface)(struct native_display *ndpy, +                                                    const struct native_config *nconf, +                                                    uint width, uint height); + +   /** +    * Program the CRTC to output the surface to the given connectors with the +    * given mode.  When surface is not given, the CRTC is disabled. +    * +    * This interface does not export a way to query capabilities of the CRTCs. +    * The native display usually needs to dynamically map the index to a CRTC +    * that supports the given connectors. +    */ +   boolean (*program)(struct native_display *ndpy, int crtc_idx, +                      struct native_surface *nsurf, uint x, uint y, +                      const struct native_connector **nconns, int num_nconns, +                      const struct native_mode *nmode); +}; + +#endif /* _NATIVE_MODESET_H_ */ diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c index dbdb1e635a..418461089a 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.c +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -201,6 +201,8 @@ kms_surface_swap_buffers(struct native_surface *nsurf)     /* the front/back textures are swapped */     ksurf->sequence_number++; +   kdpy->event_handler->invalid_surface(&kdpy->base, +         &ksurf->base, ksurf->sequence_number);     return TRUE;  } @@ -609,9 +611,9 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs)        /* always double-buffered */        nconf->mode.doubleBufferMode = TRUE; -      format = PIPE_FORMAT_A8R8G8B8_UNORM; +      format = PIPE_FORMAT_B8G8R8A8_UNORM;        if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) { -         format = PIPE_FORMAT_B8G8R8A8_UNORM; +         format = PIPE_FORMAT_A8R8G8B8_UNORM;           if (!kms_display_is_format_supported(&kdpy->base, format, TRUE))              format = PIPE_FORMAT_NONE;        } @@ -625,9 +627,9 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs)        nconf->mode.alphaBits = 8;        nconf->mode.rgbBits = 32; -      format = PIPE_FORMAT_S8Z24_UNORM; +      format = PIPE_FORMAT_Z24S8_UNORM;        if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) { -         format = PIPE_FORMAT_Z24S8_UNORM; +         format = PIPE_FORMAT_S8Z24_UNORM;           if (!kms_display_is_format_supported(&kdpy->base, format, FALSE))              format = PIPE_FORMAT_NONE;        } @@ -663,6 +665,21 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs)     return configs;  } +static int +kms_display_get_param(struct native_display *ndpy, +                      enum native_param_type param) +{ +   int val; + +   switch (param) { +   default: +      val = 0; +      break; +   } + +   return val; +} +  static void  kms_display_destroy(struct native_display *ndpy)  { @@ -762,7 +779,9 @@ static struct native_display_modeset kms_display_modeset = {  };  static struct native_display * -kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api) +kms_create_display(EGLNativeDisplayType dpy, +                   struct native_event_handler *event_handler, +                   struct drm_api *api)  {     struct kms_display *kdpy; @@ -770,6 +789,8 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api)     if (!kdpy)        return NULL; +   kdpy->event_handler = event_handler; +     kdpy->api = api;     if (!kdpy->api) {        _eglLog(_EGL_WARNING, "failed to create DRM API"); @@ -805,6 +826,7 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api)     }     kdpy->base.destroy = kms_display_destroy; +   kdpy->base.get_param = kms_display_get_param;     kdpy->base.get_configs = kms_display_get_configs;     kdpy->base.create_pbuffer_surface = kms_display_create_pbuffer_surface; @@ -845,7 +867,8 @@ native_get_name(void)  }  struct native_display * -native_create_display(EGLNativeDisplayType dpy) +native_create_display(EGLNativeDisplayType dpy, +                      struct native_event_handler *event_handler)  {     struct native_display *ndpy = NULL; @@ -853,7 +876,7 @@ native_create_display(EGLNativeDisplayType dpy)        drm_api = drm_api_create();     if (drm_api) -      ndpy = kms_create_display(dpy, drm_api); +      ndpy = kms_create_display(dpy, event_handler, drm_api);     return ndpy;  } diff --git a/src/gallium/state_trackers/egl/kms/native_kms.h b/src/gallium/state_trackers/egl/kms/native_kms.h index 095186e3cf..f9cbcb158b 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.h +++ b/src/gallium/state_trackers/egl/kms/native_kms.h @@ -53,6 +53,8 @@ struct kms_crtc {  struct kms_display {     struct native_display base; +   struct native_event_handler *event_handler; +     int fd;     struct drm_api *api;     drmModeResPtr resources; diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index b80b376e12..9839979231 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -48,6 +48,8 @@ struct dri2_display {     Display *dpy;     boolean own_dpy; +   struct native_event_handler *event_handler; +     struct drm_api *api;     struct x11_screen *xscr;     int xscr_number; @@ -327,8 +329,11 @@ dri2_surface_flush_frontbuffer(struct native_surface *nsurf)              DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);     /* force buffers to be updated in next validation call */ -   if (!dri2_surface_receive_events(&dri2surf->base)) +   if (!dri2_surface_receive_events(&dri2surf->base)) {        dri2surf->server_stamp++; +      dri2dpy->event_handler->invalid_surface(&dri2dpy->base, +            &dri2surf->base, dri2surf->server_stamp); +   }     return TRUE;  } @@ -356,8 +361,11 @@ dri2_surface_swap_buffers(struct native_surface *nsurf)              DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);     /* force buffers to be updated in next validation call */ -   if (!dri2_surface_receive_events(&dri2surf->base)) +   if (!dri2_surface_receive_events(&dri2surf->base)) {        dri2surf->server_stamp++; +      dri2dpy->event_handler->invalid_surface(&dri2dpy->base, +            &dri2surf->base, dri2surf->server_stamp); +   }     return TRUE;  } @@ -519,17 +527,17 @@ choose_color_format(const __GLcontextModes *mode, enum pipe_format formats[32])     switch (mode->rgbBits) {     case 32: -      formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM;        formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; +      formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM;        break;     case 24: -      formats[count++] = PIPE_FORMAT_X8R8G8B8_UNORM;        formats[count++] = PIPE_FORMAT_B8G8R8X8_UNORM; -      formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; +      formats[count++] = PIPE_FORMAT_X8R8G8B8_UNORM;        formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; +      formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM;        break;     case 16: -      formats[count++] = PIPE_FORMAT_R5G6B5_UNORM; +      formats[count++] = PIPE_FORMAT_B5G6R5_UNORM;        break;     default:        break; @@ -550,12 +558,12 @@ choose_depth_stencil_format(const __GLcontextModes *mode,        break;     case 24:        if (mode->stencilBits) { -         formats[count++] = PIPE_FORMAT_S8Z24_UNORM;           formats[count++] = PIPE_FORMAT_Z24S8_UNORM; +         formats[count++] = PIPE_FORMAT_S8Z24_UNORM;        }        else { -         formats[count++] = PIPE_FORMAT_X8Z24_UNORM;           formats[count++] = PIPE_FORMAT_Z24X8_UNORM; +         formats[count++] = PIPE_FORMAT_X8Z24_UNORM;        }        break;     case 16: @@ -702,6 +710,25 @@ dri2_display_is_pixmap_supported(struct native_display *ndpy,     return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth));  } +static int +dri2_display_get_param(struct native_display *ndpy, +                       enum native_param_type param) +{ +   int val; + +   switch (param) { +   case NATIVE_PARAM_USE_NATIVE_BUFFER: +      /* DRI2GetBuffers use the native buffers */ +      val = TRUE; +      break; +   default: +      val = 0; +      break; +   } + +   return val; +} +  static void  dri2_display_destroy(struct native_display *ndpy)  { @@ -740,7 +767,10 @@ dri2_display_invalidate_buffers(struct x11_screen *xscr, Drawable drawable,        return;     dri2surf = dri2_surface(nsurf); +     dri2surf->server_stamp++; +   dri2dpy->event_handler->invalid_surface(&dri2dpy->base, +         &dri2surf->base, dri2surf->server_stamp);  }  /** @@ -799,7 +829,9 @@ dri2_display_hash_table_compare(void *key1, void *key2)  }  struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) +x11_create_dri2_display(EGLNativeDisplayType dpy, +                        struct native_event_handler *event_handler, +                        struct drm_api *api)  {     struct dri2_display *dri2dpy; @@ -807,6 +839,7 @@ x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api)     if (!dri2dpy)        return NULL; +   dri2dpy->event_handler = event_handler;     dri2dpy->api = api;     dri2dpy->dpy = dpy; @@ -839,6 +872,7 @@ x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api)     }     dri2dpy->base.destroy = dri2_display_destroy; +   dri2dpy->base.get_param = dri2_display_get_param;     dri2dpy->base.get_configs = dri2_display_get_configs;     dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported;     dri2dpy->base.create_window_surface = dri2_display_create_window_surface; diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c index 3add95d0ac..7b4fe63fa0 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.c +++ b/src/gallium/state_trackers/egl/x11/native_x11.c @@ -126,7 +126,8 @@ native_get_name(void)  }  struct native_display * -native_create_display(EGLNativeDisplayType dpy) +native_create_display(EGLNativeDisplayType dpy, +                      struct native_event_handler *event_handler)  {     struct native_display *ndpy = NULL;     boolean force_sw; @@ -136,7 +137,7 @@ native_create_display(EGLNativeDisplayType dpy)     force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE);     if (api && !force_sw) { -      ndpy = x11_create_dri2_display(dpy, api); +      ndpy = x11_create_dri2_display(dpy, event_handler, api);     }     if (!ndpy) { @@ -150,7 +151,7 @@ native_create_display(EGLNativeDisplayType dpy)         */        use_shm = FALSE;        _eglLog(level, "use software%s fallback", (use_shm) ? " (SHM)" : ""); -      ndpy = x11_create_ximage_display(dpy, use_shm); +      ndpy = x11_create_ximage_display(dpy, event_handler, use_shm);     }     return ndpy; diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h index 622ddac5df..8c6a7d9349 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.h +++ b/src/gallium/state_trackers/egl/x11/native_x11.h @@ -29,9 +29,13 @@  #include "common/native.h"  struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm); +x11_create_ximage_display(EGLNativeDisplayType dpy, +                          struct native_event_handler *event_handler, +                          boolean use_xshm);  struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api); +x11_create_dri2_display(EGLNativeDisplayType dpy, +                        struct native_event_handler *event_handler, +                        struct drm_api *api);  #endif /* _NATIVE_X11_H_ */ diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 8ba73f289d..3421c1951a 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -56,6 +56,8 @@ struct ximage_display {     struct x11_screen *xscr;     int xscr_number; +   struct native_event_handler *event_handler; +     boolean use_xshm;     struct pipe_winsys *winsys; @@ -228,6 +230,16 @@ ximage_surface_update_geometry(struct native_surface *nsurf)     return updated;  } +static void +ximage_surface_notify_invalid(struct native_surface *nsurf) +{ +   struct ximage_surface *xsurf = ximage_surface(nsurf); +   struct ximage_display *xdpy = xsurf->xdpy; + +   xdpy->event_handler->invalid_surface(&xdpy->base, +         &xsurf->base, xsurf->server_stamp); +} +  /**   * Update the buffers of the surface.  It is a slow function due to the   * round-trip to the server. @@ -339,6 +351,7 @@ ximage_surface_flush_frontbuffer(struct native_surface *nsurf)           NATIVE_ATTACHMENT_FRONT_LEFT);     /* force buffers to be updated in next validation call */     xsurf->server_stamp++; +   ximage_surface_notify_invalid(&xsurf->base);     return ret;  } @@ -354,6 +367,7 @@ ximage_surface_swap_buffers(struct native_surface *nsurf)     ret = ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT);     /* force buffers to be updated in next validation call */     xsurf->server_stamp++; +   ximage_surface_notify_invalid(&xsurf->base);     xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT];     xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT]; @@ -561,13 +575,13 @@ choose_format(const XVisualInfo *vinfo)     /* TODO elaborate the formats */     switch (vinfo->depth) {     case 32: -      fmt = PIPE_FORMAT_A8R8G8B8_UNORM; +      fmt = PIPE_FORMAT_B8G8R8A8_UNORM;        break;     case 24: -      fmt = PIPE_FORMAT_X8R8G8B8_UNORM; +      fmt = PIPE_FORMAT_B8G8R8X8_UNORM;        break;     case 16: -      fmt = PIPE_FORMAT_R5G6B5_UNORM; +      fmt = PIPE_FORMAT_B5G6R5_UNORM;        break;     default:        fmt = PIPE_FORMAT_NONE; @@ -620,8 +634,8 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs)              xconf->base.stencil_format = PIPE_FORMAT_NONE;              /* create the second config with depth/stencil buffer */              if (j == 1) { -               xconf->base.depth_format = PIPE_FORMAT_S8Z24_UNORM; -               xconf->base.stencil_format = PIPE_FORMAT_S8Z24_UNORM; +               xconf->base.depth_format = PIPE_FORMAT_Z24S8_UNORM; +               xconf->base.stencil_format = PIPE_FORMAT_Z24S8_UNORM;                 mode->depthBits = 24;                 mode->stencilBits = 8;                 mode->haveDepthBuffer = TRUE; @@ -669,13 +683,13 @@ ximage_display_is_pixmap_supported(struct native_display *ndpy,     depth = x11_drawable_get_depth(xdpy->xscr, (Drawable) pix);     switch (depth) {     case 32: -      fmt = PIPE_FORMAT_A8R8G8B8_UNORM; +      fmt = PIPE_FORMAT_B8G8R8A8_UNORM;        break;     case 24: -      fmt = PIPE_FORMAT_X8R8G8B8_UNORM; +      fmt = PIPE_FORMAT_B8G8R8X8_UNORM;        break;     case 16: -      fmt = PIPE_FORMAT_R5G6B5_UNORM; +      fmt = PIPE_FORMAT_B5G6R5_UNORM;        break;     default:        fmt = PIPE_FORMAT_NONE; @@ -685,6 +699,25 @@ ximage_display_is_pixmap_supported(struct native_display *ndpy,     return (fmt == nconf->color_format);  } +static int +ximage_display_get_param(struct native_display *ndpy, +                         enum native_param_type param) +{ +   int val; + +   switch (param) { +   case NATIVE_PARAM_USE_NATIVE_BUFFER: +      /* private buffers are allocated */ +      val = FALSE; +      break; +   default: +      val = 0; +      break; +   } + +   return val; +} +  static void  ximage_display_destroy(struct native_display *ndpy)  { @@ -703,7 +736,9 @@ ximage_display_destroy(struct native_display *ndpy)  }  struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) +x11_create_ximage_display(EGLNativeDisplayType dpy, +                          struct native_event_handler *event_handler, +                          boolean use_xshm)  {     struct ximage_display *xdpy; @@ -728,6 +763,8 @@ x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm)        return NULL;     } +   xdpy->event_handler = event_handler; +     xdpy->use_xshm =        (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM)); @@ -735,6 +772,7 @@ x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm)     xdpy->base.screen = softpipe_create_screen(xdpy->winsys);     xdpy->base.destroy = ximage_display_destroy; +   xdpy->base.get_param = ximage_display_get_param;     xdpy->base.get_configs = ximage_display_get_configs;     xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported; diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 188b885f68..217bdeff75 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -274,10 +274,10 @@ choose_pixel_format(XMesaVisual v)         && v->BitsPerPixel == 32) {        if (native_byte_order) {           /* no byteswapping needed */ -         return 0 /* PIXEL_FORMAT_U_A8_B8_G8_R8 */; +         return PIPE_FORMAT_R8G8B8A8_UNORM;        }        else { -         return PIPE_FORMAT_R8G8B8A8_UNORM; +         return PIPE_FORMAT_A8B8G8R8_UNORM;        }     }     else if (   GET_REDMASK(v)   == 0xff0000 @@ -286,10 +286,10 @@ choose_pixel_format(XMesaVisual v)              && v->BitsPerPixel == 32) {        if (native_byte_order) {           /* no byteswapping needed */ -         return PIPE_FORMAT_A8R8G8B8_UNORM; +         return PIPE_FORMAT_B8G8R8A8_UNORM;        }        else { -         return PIPE_FORMAT_B8G8R8A8_UNORM; +         return PIPE_FORMAT_A8R8G8B8_UNORM;        }     }     else if (   GET_REDMASK(v)   == 0x0000ff00 @@ -298,10 +298,10 @@ choose_pixel_format(XMesaVisual v)              && v->BitsPerPixel == 32) {        if (native_byte_order) {           /* no byteswapping needed */ -         return PIPE_FORMAT_B8G8R8A8_UNORM; +         return PIPE_FORMAT_A8R8G8B8_UNORM;        }        else { -         return PIPE_FORMAT_A8R8G8B8_UNORM; +         return PIPE_FORMAT_B8G8R8A8_UNORM;        }     }     else if (   GET_REDMASK(v)   == 0xf800 @@ -310,7 +310,7 @@ choose_pixel_format(XMesaVisual v)              && native_byte_order              && v->BitsPerPixel == 16) {        /* 5-6-5 RGB */ -      return PIPE_FORMAT_R5G6B5_UNORM; +      return PIPE_FORMAT_B5G6R5_UNORM;     }     assert(0); @@ -333,8 +333,8 @@ xmesa_choose_z_stencil_format(int depthBits, int stencilBits,     const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE |                                  PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO);     static enum pipe_format formats[] = { -      PIPE_FORMAT_Z24S8_UNORM,        PIPE_FORMAT_S8Z24_UNORM, +      PIPE_FORMAT_Z24S8_UNORM,        PIPE_FORMAT_Z16_UNORM,        PIPE_FORMAT_Z32_UNORM     }; @@ -746,10 +746,9 @@ XMesaVisual XMesaCreateVisual( Display *display,     }     _mesa_initialize_visual( &v->mesa_visual, -                            rgb_flag, db_flag, stereo_flag, +                            db_flag, stereo_flag,                              red_bits, green_bits,                              blue_bits, alpha_bits, -                            v->mesa_visual.indexBits,                              depth_size,                              stencil_size,                              accum_red_size, accum_green_size, diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index a3798a5521..45e7841750 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -244,7 +244,7 @@ st_context_create(struct st_device *st_dev)        memset( &templat, 0, sizeof( templat ) );        templat.target = PIPE_TEXTURE_2D; -      templat.format = PIPE_FORMAT_A8R8G8B8_UNORM; +      templat.format = PIPE_FORMAT_B8G8R8A8_UNORM;        templat.width0 = 1;        templat.height0 = 1;        templat.depth0 = 1; diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c index 32a6551a87..e180815346 100644 --- a/src/gallium/state_trackers/python/st_sample.c +++ b/src/gallium/state_trackers/python/st_sample.c @@ -485,7 +485,7 @@ st_sample_generic_pixel_block(enum pipe_format format,                           w, h,                           rgba, rgba_stride); -   if(format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV) { +   if(format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) {        for(y = 0; y < h; ++y) {           for(x = 0; x < w; ++x) {              for(ch = 0; ch < 4; ++ch) { diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 20c72c1ff5..02248ad433 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -67,7 +67,7 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx,     memset(&templ, 0, sizeof(templ));     templ.target = PIPE_TEXTURE_1D; -   templ.format = PIPE_FORMAT_A8R8G8B8_UNORM; +   templ.format = PIPE_FORMAT_B8G8R8A8_UNORM;     templ.last_level = 0;     templ.width0 = color_data_len;     templ.height0 = 1; diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index 2e10965be4..41c979bfec 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -48,16 +48,16 @@ static enum pipe_format vg_format_to_pipe(VGImageFormat format)  {     switch(format) {     case VG_sRGB_565: -      return PIPE_FORMAT_R5G6B5_UNORM; +      return PIPE_FORMAT_B5G6R5_UNORM;     case VG_sRGBA_5551: -      return PIPE_FORMAT_A1R5G5B5_UNORM; +      return PIPE_FORMAT_B5G5R5A1_UNORM;     case VG_sRGBA_4444: -      return PIPE_FORMAT_A4R4G4B4_UNORM; +      return PIPE_FORMAT_B4G4R4A4_UNORM;     case VG_sL_8:     case VG_lL_8:        return PIPE_FORMAT_L8_UNORM;     case VG_BW_1: -      return PIPE_FORMAT_A8R8G8B8_UNORM; +      return PIPE_FORMAT_B8G8R8A8_UNORM;     case VG_A_8:        return PIPE_FORMAT_A8_UNORM;  #ifdef OPENVG_VERSION_1_1 @@ -66,7 +66,7 @@ static enum pipe_format vg_format_to_pipe(VGImageFormat format)        return PIPE_FORMAT_A8_UNORM;  #endif     default: -      return PIPE_FORMAT_A8R8G8B8_UNORM; +      return PIPE_FORMAT_B8G8R8A8_UNORM;     }  } diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index 467b95b751..839dc19a3b 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -488,7 +488,7 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height)        memset(&pt, 0, sizeof(pt));        pt.target = PIPE_TEXTURE_2D; -      pt.format = PIPE_FORMAT_A8R8G8B8_UNORM; +      pt.format = PIPE_FORMAT_B8G8R8A8_UNORM;        pt.last_level = 0;        pt.width0 = width;        pt.height0 = height; diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index 3405d635f0..caf0c14b74 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -151,7 +151,7 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p)     memset(&templ, 0, sizeof(templ));     templ.target = PIPE_TEXTURE_1D; -   templ.format = PIPE_FORMAT_A8R8G8B8_UNORM; +   templ.format = PIPE_FORMAT_B8G8R8A8_UNORM;     templ.last_level = 0;     templ.width0 = 1024;     templ.height0 = 1; diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index a94dfb160c..57d3baad7f 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -51,7 +51,7 @@ create_texture(struct pipe_context *pipe, enum pipe_format format,        templ.format = format;     }     else { -      templ.format = PIPE_FORMAT_A8R8G8B8_UNORM; +      templ.format = PIPE_FORMAT_B8G8R8A8_UNORM;     }     templ.target = PIPE_TEXTURE_2D; @@ -186,7 +186,7 @@ struct st_framebuffer * st_create_framebuffer(const void *visual,        if (stencilFormat == depthFormat)           stfb->dsrb = st_new_renderbuffer_fb(stencilFormat);        else -         stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_S8Z24_UNORM); +         stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_Z24S8_UNORM);        /*### currently we always allocate it but it's possible it's          not necessary if EGL_ALPHA_MASK_SIZE was 0 @@ -209,12 +209,12 @@ static void setup_new_alpha_mask(struct vg_context *ctx,     struct pipe_texture *old_texture = stfb->alpha_mask;     /* -     we use PIPE_FORMAT_A8R8G8B8_UNORM because we want to render to +     we use PIPE_FORMAT_B8G8R8A8_UNORM because we want to render to       this texture and use it as a sampler, so while this wastes some       space it makes both of those a lot simpler     */     stfb->alpha_mask = -      create_texture(pipe, PIPE_FORMAT_A8R8G8B8_UNORM, width, height); +      create_texture(pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height);     if (!stfb->alpha_mask) {        if (old_texture) @@ -327,7 +327,7 @@ void st_resize_framebuffer(struct st_framebuffer *stfb,     setup_new_alpha_mask(ctx, stfb, width, height);     pipe_texture_reference( &stfb->blend_texture, NULL ); -   stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_A8R8G8B8_UNORM, +   stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM,                                          width, height);  } diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index e5fa6ac8eb..472a2a5379 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -47,7 +47,6 @@  #ifdef WIN32_THREADS  extern _glthread_Mutex OneTimeLock; -extern void FreeAllTSD(void);  #endif @@ -183,7 +182,8 @@ stw_cleanup(void)  #ifdef WIN32_THREADS     _glthread_DESTROY_MUTEX(OneTimeLock); -   FreeAllTSD(); + +   _glapi_destroy_multithread();  #endif  #ifdef DEBUG diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index b750b03695..bc28f31ed1 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -74,17 +74,17 @@ struct stw_pf_depth_info  static const struct stw_pf_color_info  stw_pf_color[] = {     /* no-alpha */ -   { PIPE_FORMAT_X8R8G8B8_UNORM,    { 8,  8,  8,  0}, {16,  8,  0,  0} }, -   { PIPE_FORMAT_B8G8R8X8_UNORM,    { 8,  8,  8,  0}, { 8, 16, 24,  0} }, -   { PIPE_FORMAT_R5G6B5_UNORM,      { 5,  6,  5,  0}, {11,  5,  0,  0} }, +   { PIPE_FORMAT_B8G8R8X8_UNORM,    { 8,  8,  8,  0}, {16,  8,  0,  0} }, +   { PIPE_FORMAT_X8R8G8B8_UNORM,    { 8,  8,  8,  0}, { 8, 16, 24,  0} }, +   { PIPE_FORMAT_B5G6R5_UNORM,      { 5,  6,  5,  0}, {11,  5,  0,  0} },     /* alpha */ -   { PIPE_FORMAT_A8R8G8B8_UNORM,    { 8,  8,  8,  8}, {16,  8,  0, 24} }, -   { PIPE_FORMAT_B8G8R8A8_UNORM,    { 8,  8,  8,  8}, { 8, 16, 24,  0} }, +   { PIPE_FORMAT_B8G8R8A8_UNORM,    { 8,  8,  8,  8}, {16,  8,  0, 24} }, +   { PIPE_FORMAT_A8R8G8B8_UNORM,    { 8,  8,  8,  8}, { 8, 16, 24,  0} },  #if 0 -   { PIPE_FORMAT_A2B10G10R10_UNORM, {10, 10, 10,  2}, { 0, 10, 20, 30} }, +   { PIPE_FORMAT_R10G10B10A2_UNORM, {10, 10, 10,  2}, { 0, 10, 20, 30} },  #endif -   { PIPE_FORMAT_A1R5G5B5_UNORM,    { 5,  5,  5,  1}, {10,  5,  0, 15} }, -   { PIPE_FORMAT_A4R4G4B4_UNORM,    { 4,  4,  4,  4}, {16,  4,  0, 12} } +   { PIPE_FORMAT_B5G5R5A1_UNORM,    { 5,  5,  5,  1}, {10,  5,  0, 15} }, +   { PIPE_FORMAT_B4G4R4A4_UNORM,    { 4,  4,  4,  4}, {16,  4,  0, 12} }  }; @@ -92,12 +92,12 @@ static const struct stw_pf_depth_info  stw_pf_depth_stencil[] = {     /* pure depth */     { PIPE_FORMAT_Z32_UNORM,   {32, 0} }, -   { PIPE_FORMAT_Z24X8_UNORM, {24, 0} },     { PIPE_FORMAT_X8Z24_UNORM, {24, 0} }, +   { PIPE_FORMAT_Z24X8_UNORM, {24, 0} },     { PIPE_FORMAT_Z16_UNORM,   {16, 0} },     /* combined depth-stencil */ -   { PIPE_FORMAT_S8Z24_UNORM, {24, 8} }, -   { PIPE_FORMAT_Z24S8_UNORM, {24, 8} } +   { PIPE_FORMAT_Z24S8_UNORM, {24, 8} }, +   { PIPE_FORMAT_S8Z24_UNORM, {24, 8} }  }; @@ -271,14 +271,12 @@ stw_pixelformat_visual(GLvisual *visual,     memset(visual, 0, sizeof *visual);     _mesa_initialize_visual(        visual, -      (pfi->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE,        (pfi->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,        (pfi->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE,        pfi->pfd.cRedBits,        pfi->pfd.cGreenBits,        pfi->pfd.cBlueBits,        pfi->pfd.cAlphaBits, -      (pfi->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pfi->pfd.cColorBits : 0,        pfi->pfd.cDepthBits,        pfi->pfd.cStencilBits,        pfi->pfd.cAccumRedBits, diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 8f6426bcc8..44f7da0f96 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -205,7 +205,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)  	templat.target = PIPE_TEXTURE_2D;  	templat.last_level = 0;  	templat.depth0 = 1; -	templat.format = PIPE_FORMAT_A8R8G8B8_UNORM; +	templat.format = PIPE_FORMAT_B8G8R8A8_UNORM;  	templat.width0 = 64;  	templat.height0 = 64; diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index e7f1b2d411..f23e4c6cc7 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -117,12 +117,12 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form                    break;                 default:                    template.format = ms->ds_depth_bits_last ? -                                    PIPE_FORMAT_X8Z24_UNORM : PIPE_FORMAT_Z24X8_UNORM; +                                    PIPE_FORMAT_Z24X8_UNORM : PIPE_FORMAT_X8Z24_UNORM;                    break;                 }              } else {                 template.format = ms->ds_depth_bits_last ? -                                 PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM; +                                 PIPE_FORMAT_Z24S8_UNORM : PIPE_FORMAT_S8Z24_UNORM;              }  	    template.width0 = pDraw->width;  	    template.height0 = pDraw->height; @@ -435,11 +435,11 @@ xorg_dri2_init(ScreenPtr pScreen)      dri2info.Wait = NULL;      ms->d_depth_bits_last = -	 ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_X8Z24_UNORM, +	 ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24X8_UNORM,  					 PIPE_TEXTURE_2D,  					 PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);      ms->ds_depth_bits_last = -	 ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_S8Z24_UNORM, +	 ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24S8_UNORM,  					 PIPE_TEXTURE_2D,  					 PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 5c3e92efdf..a7ffe3f499 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -118,22 +118,22 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp, int *picture_  {      switch (depth) {      case 32: -	*format = PIPE_FORMAT_A8R8G8B8_UNORM; +	*format = PIPE_FORMAT_B8G8R8A8_UNORM;  	*picture_format = PICT_a8r8g8b8;  	assert(*bbp == 32);  	break;      case 24: -	*format = PIPE_FORMAT_X8R8G8B8_UNORM; +	*format = PIPE_FORMAT_B8G8R8X8_UNORM;  	*picture_format = PICT_x8r8g8b8;  	assert(*bbp == 32);  	break;      case 16: -	*format = PIPE_FORMAT_R5G6B5_UNORM; +	*format = PIPE_FORMAT_B5G6R5_UNORM;  	*picture_format = PICT_r5g6b5;  	assert(*bbp == 16);  	break;      case 15: -	*format = PIPE_FORMAT_A1R5G5B5_UNORM; +	*format = PIPE_FORMAT_B5G5R5A1_UNORM;  	*picture_format = PICT_x1r5g5b5;  	assert(*bbp == 16);  	break; @@ -144,7 +144,7 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp, int *picture_  	break;      case 4:      case 1: -	*format = PIPE_FORMAT_A8R8G8B8_UNORM; /* bad bad bad */ +	*format = PIPE_FORMAT_B8G8R8A8_UNORM; /* bad bad bad */  	break;      default:  	assert(0); diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c index c113f49e55..12d94e0c5c 100644 --- a/src/gallium/state_trackers/xorg/xvmc/surface.c +++ b/src/gallium/state_trackers/xorg/xvmc/surface.c @@ -101,7 +101,7 @@ CreateOrResizeBackBuffer(struct pipe_video_context *vpipe, unsigned int width, u     memset(&template, 0, sizeof(struct pipe_texture));     template.target = PIPE_TEXTURE_2D;     /* XXX: Needs to match the drawable's format? */ -   template.format = PIPE_FORMAT_X8R8G8B8_UNORM; +   template.format = PIPE_FORMAT_B8G8R8X8_UNORM;     template.last_level = 0;     template.width0 = width;     template.height0 = height; | 
