On Fri, 2009-02-06 at 01:50 +0000, Peter Clifton wrote:
> On Thu, 2009-02-05 at 17:40 -0500, Kristian Høgsberg wrote:
> > On Thu, Feb 5, 2009 at 4:46 PM, Peter Clifton <[email protected]> wrote:
> > > On Fri, 2009-01-30 at 11:51 -0500, Kristian Høgsberg wrote:
> > >> On Thu, Jan 29, 2009 at 6:08 PM, Eric Anholt <[email protected]> wrote:
> > >> > We can support any combination of (a8r8g8b8, x8r8g8b8, r5g6b5) x 
> > >> > (z0,z24,z24s8)
> > >> > on either class of chipsets.  The only restriction is no mixing bpp 
> > >> > when also
> > >> > mixing tiling.  This shouldn't be occurring currently.
> > >>
> > >> Cool, that should fix it.  Or at least let the compositing managers
> > >> pick the right fbconfig.  We should probably fix all drivers to report
> > >> RGB visuals, and then we can yank the reset-alpha-channel hack in the
> > >> tfp sw fallback.
> > >
> > > It doesn't fix it on its own.. certainly not for the intel driver.
> > >
> > > The setTexBuffer hook still explicitly sets the format of the texture to
> > > be BGRA, and I assume it ought to be setting this information based on
> > > the FBconfig (now hopefully correct) of the GLXPixmap the texture is
> > > being mapped from.
> > >
> > > Does anyone have any hints how start fixing that?
> > 
> > Something like the attached patch?  Haven't tested it...
> 
> I've not tried it yet, but I'm looking at the 965 brw code, and am not
> sure the right format is going to make it...
> 
> In the  brw_update_texture_surface function (brw_wm_surface_state.c),
> the bo key's texture format is set to firstImage->TexFormat->MesaFormat
> in the case where there is no format override (e.g. from the DRI1 TFP
> hack).
> 
> The code path then goes via brw_create_texture_surface(), and since the
> key->bo field is set, the following code-path is taken:
> 
>     if (key->bo) 
>       surf.ss0.surface_format = translate_tex_format(key->format,
> key->depthmode);
> 
> That code-path has no conditional which ends up returning the desired:
> BRW_SURFACEFORMAT_B8G8R8X8_UNORM, as might be hit in the DRI1 override
> path where no bo is set, and the alternative code-path sets that format
> type for the case where key->depth == 24.
> 
> Any ideas what MESA format will be appropriate to select the above
> BRW_SURFACEFORMAT_B8G8R8X8_UNORM for inside translate_tex_format() ?
> 
> 
> (And I presume there might be other fixes required for the non 965
> drivers.)


I've tried this, but it didn't work.. any clues?

(Ok.. I've not verified that compiz is definitely choosing the correct
FBconfig...)

Does the attached patch look like the correct approach though? (Adding a
new mesa texture format for an RGB texture with 4cpp spacing?

Or should we just use a similar approach to the DRI(1) tfp override
hack, and keep the details within the driver?

Of course.. if someone wants to beat me to fixing this, please do!

I'm not sure about whether I managed to get all the texel store / fetch
routines for the xrgb8 right.. and there was one I didn't even attempt.
I fugured someone here could do this quicker, or at least point me in
the right direction.

Best regards,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
--- mesa-7.3.orig/src/mesa/main/texformat.h
+++ mesa-7.3/src/mesa/main/texformat.h
@@ -64,6 +64,7 @@
 				/* ---- ---- ---- ---- ---- ---- ---- ---- */
    MESA_FORMAT_RGBA8888,	/* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
    MESA_FORMAT_RGBA8888_REV,	/* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
+   MESA_FORMAT_XRGB8888,	/* XXXX XXXX RRRR RRRR GGGG GGGG BBBB BBBB */
    MESA_FORMAT_ARGB8888,	/* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
    MESA_FORMAT_ARGB8888_REV,	/* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
    MESA_FORMAT_RGB888,		/*           RRRR RRRR GGGG GGGG BBBB BBBB */
@@ -196,6 +197,7 @@
 /*...@{*/
 extern const struct gl_texture_format _mesa_texformat_rgba8888;
 extern const struct gl_texture_format _mesa_texformat_rgba8888_rev;
+extern const struct gl_texture_format _mesa_texformat_xrgb8888;
 extern const struct gl_texture_format _mesa_texformat_argb8888;
 extern const struct gl_texture_format _mesa_texformat_argb8888_rev;
 extern const struct gl_texture_format _mesa_texformat_rgb888;
--- mesa-7.3.orig/src/mesa/main/texstore.h
+++ mesa-7.3/src/mesa/main/texstore.h
@@ -41,6 +41,7 @@
 extern GLboolean _mesa_texstore_rgba(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_color_index(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_rgba8888(TEXSTORE_PARAMS);
+extern GLboolean _mesa_texstore_xrgb8888(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_argb8888(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_rgb888(TEXSTORE_PARAMS);
 extern GLboolean _mesa_texstore_bgr888(TEXSTORE_PARAMS);
--- mesa-7.3.orig/src/mesa/main/texformat_tmp.h
+++ mesa-7.3/src/mesa/main/texformat_tmp.h
@@ -651,6 +651,31 @@
 #endif
 
 
+/* MESA_FORMAT_XRGB8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 3 GLchans */
+static void FETCH(xrgb8888)( const struct gl_texture_image *texImage,
+			     GLint i, GLint j, GLint k, GLchan *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
+   texel[GCOMP] = UBYTE_TO_CHAN( (s >>  8) & 0xff );
+   texel[BCOMP] = UBYTE_TO_CHAN( (s      ) & 0xff );
+}
+
+#if DIM == 3
+static void store_texel_xrgb8888(struct gl_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLubyte *rgba = (const GLubyte *) texel;
+   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
+   dst[0] = rgba[RCOMP];
+   dst[1] = rgba[GCOMP];
+   dst[2] = rgba[BCOMP];
+}
+#endif
+
+
 /* MESA_FORMAT_ARGB8888 ******************************************************/
 
 /* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
--- mesa-7.3.orig/src/mesa/main/texformat.c
+++ mesa-7.3/src/mesa/main/texformat.c
@@ -727,6 +727,30 @@
    store_texel_rgba8888_rev		/* StoreTexel */
 };
 
+const struct gl_texture_format _mesa_texformat_xrgb8888 = {
+   MESA_FORMAT_XRGB8888,		/* MesaFormat */
+   GL_RGB,				/* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,		/* DataType */
+   8,					/* RedBits */
+   8,					/* GreenBits */
+   8,					/* BlueBits */
+   0,					/* AlphaBits */
+   0,					/* LuminanceBits */
+   0,					/* IntensityBits */
+   0,					/* IndexBits */
+   0,					/* DepthBits */
+   0,					/* StencilBits */
+   4,					/* TexelBytes */
+   _mesa_texstore_argb8888,		/* StoreTexImageFunc */
+   fetch_texel_1d_xrgb8888,		/* FetchTexel1D */
+   fetch_texel_2d_xrgb8888,		/* FetchTexel2D */
+   fetch_texel_3d_xrgb8888,		/* FetchTexel3D */
+   NULL,				/* FetchTexel1Df */
+   NULL,				/* FetchTexel2Df */
+   NULL,				/* FetchTexel3Df */
+   store_texel_xrgb8888			/* StoreTexel */
+};
+
 const struct gl_texture_format _mesa_texformat_argb8888 = {
    MESA_FORMAT_ARGB8888,		/* MesaFormat */
    GL_RGBA,				/* BaseFormat */
@@ -1669,6 +1693,7 @@
       *datatype = CHAN_TYPE;
       *comps = 4;
       return;
+   case MESA_FORMAT_XRGB8888:
    case MESA_FORMAT_RGB888:
    case MESA_FORMAT_BGR888:
       *datatype = GL_UNSIGNED_BYTE;
--- mesa-7.3.orig/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ mesa-7.3/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -88,6 +88,9 @@
       assert(0);		/* not supported for sampling */
       return BRW_SURFACEFORMAT_R8G8B8_UNORM;      
 
+   case MESA_FORMAT_XRGB8888:
+      return BRW_SURFACEFORMAT_B8G8R8X8_UNORM;
+
    case MESA_FORMAT_ARGB8888:
       return BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
 
--- mesa-7.3.orig/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ mesa-7.3/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -739,7 +739,11 @@
    if (rb->region == NULL)
       return;
 
-   type = GL_BGRA;
+   if (intel_fb->Base.Visual.alphaBits > 0)
+      type = GL_BGRA;
+   else
+      type = GL_BGR;
+
    format = GL_UNSIGNED_BYTE;
    internalFormat = (rb->region->cpp == 3 ? 3 : 4);
 
--- mesa-7.3.orig/src/mesa/drivers/dri/intel/intel_tex_format.c
+++ mesa-7.3/src/mesa/drivers/dri/intel/intel_tex_format.c
@@ -32,6 +32,10 @@
          else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
             return &_mesa_texformat_argb1555;
          }
+      } else if (format == GL_BGR) {
+         if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) {
+            return &_mesa_texformat_xrgb8888;
+         }
       }
       return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
 
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to