Ian Romanick wrote:

It looks like destination alpha was disabled in the DDX at some point. I seem to remember some discussion about this a long time ago. Do any of the DRI developers remember why this was done?

So, I found this in the archives:

http://marc.theaimsgroup.com/?l=dri-devel&m=104456147219701&w=4

It looks like, basically, there was a bug in the span read function. Rather than fixing it, destination alpha was just disabled.

If the DDX is modified to export visuals with an alphaSize of 8 and a bufferSize of 32, the attached patch should fix things. As noted in the comment in the patch, this will break RGB888 visuals (e.g., using this patch with an unmodified DDX).

I think the right answer is to apply the fix for reading alpha from the framebuffer and ignore the 888 modes. Since the hardware is operating in 8888 mode, pretending to be 888 is just wrong. We'd have to go through and make sure that 0xff is *always* written as the output from the alpha blend stage in 888 mode. Yuck.

I guess this is a case where the DDX version should get a bump and the DRI driver should check for the new version?
? src/mesa/drivers/dri/mga/depend
Index: src/mesa/drivers/dri/mga/mga_xmesa.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/mga/mga_xmesa.c,v
retrieving revision 1.32
diff -u -d -r1.32 mga_xmesa.c
--- src/mesa/drivers/dri/mga/mga_xmesa.c        4 Oct 2004 22:58:39 -0000       1.32
+++ src/mesa/drivers/dri/mga/mga_xmesa.c        4 Oct 2004 23:14:57 -0000
@@ -103,8 +103,10 @@
     unsigned num_modes;
     unsigned depth_buffer_factor;
     unsigned back_buffer_factor;
-    GLenum fb_format;
-    GLenum fb_type;
+    GLenum fb_format[2];
+    GLenum fb_type[2];
+    unsigned fb_count;
+    unsigned i;
 
     /* GLX_SWAP_COPY_OML is only supported because the MGA driver doesn't
      * support pageflipping at all.
@@ -132,35 +134,41 @@
     depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
     back_buffer_factor  = (have_back_buffer) ? 2 : 1;
 
-    num_modes = depth_buffer_factor * back_buffer_factor * 4;
-
     if ( pixel_bits == 16 ) {
-        fb_format = GL_RGB;
-        fb_type = GL_UNSIGNED_SHORT_5_6_5;
+       fb_count = 1;
+        fb_format[0] = GL_RGB;
+        fb_type[0] = GL_UNSIGNED_SHORT_5_6_5;
     }
     else {
-        fb_format = GL_BGR;
-        fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+       fb_count = 2;
+        fb_format[0] = GL_BGR;
+        fb_type[0] = GL_UNSIGNED_INT_8_8_8_8_REV;
+        fb_format[1] = GL_BGRA;
+        fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV;
     }
 
+    num_modes = depth_buffer_factor * back_buffer_factor * fb_count * 4;
+
     modes = (*create_context_modes)( num_modes, sizeof( __GLcontextModes ) );
     m = modes;
-    if ( ! driFillInModes( & m, fb_format, fb_type,
-                          depth_bits_array, stencil_bits_array, depth_buffer_factor,
-                          back_buffer_modes, back_buffer_factor,
-                          GLX_TRUE_COLOR ) ) {
-       fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
-                __func__, __LINE__ );
-       return NULL;
-    }
+    for ( i = 0 ; i < fb_count ; i++ ) {
+       if ( ! driFillInModes( & m, fb_format[i], fb_type[i],
+                              depth_bits_array, stencil_bits_array, 
depth_buffer_factor,
+                              back_buffer_modes, back_buffer_factor,
+                              GLX_TRUE_COLOR ) ) {
+           fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+                    __func__, __LINE__ );
+           return NULL;
+       }
 
-    if ( ! driFillInModes( & m, fb_format, fb_type,
-                          depth_bits_array, stencil_bits_array, depth_buffer_factor,
-                          back_buffer_modes, back_buffer_factor,
-                          GLX_DIRECT_COLOR ) ) {
-       fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
-                __func__, __LINE__ );
-       return NULL;
+       if ( ! driFillInModes( & m, fb_format[i], fb_type[i],
+                              depth_bits_array, stencil_bits_array, 
depth_buffer_factor,
+                              back_buffer_modes, back_buffer_factor,
+                              GLX_DIRECT_COLOR ) ) {
+           fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+                    __func__, __LINE__ );
+           return NULL;
+       }
     }
 
     /* Mark the visual as slow if there are "fake" stencil bits.
Index: src/mesa/drivers/dri/mga/mgaspan.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/mga/mgaspan.c,v
retrieving revision 1.5
diff -u -d -r1.5 mgaspan.c
--- src/mesa/drivers/dri/mga/mgaspan.c  21 Mar 2004 17:05:03 -0000      1.5
+++ src/mesa/drivers/dri/mga/mgaspan.c  4 Oct 2004 23:14:57 -0000
@@ -166,7 +166,7 @@
        rgba[0] = (p >> 16) & 0xff;                             \
        rgba[1] = (p >> 8)  & 0xff;                             \
        rgba[2] = (p >> 0)  & 0xff;                             \
-       rgba[3] = 0xff;                                         \
+       rgba[3] = (p >> 24) & 0xff;                             \
     } while (0)
 
 #define TAG(x) mga##x##_8888
@@ -260,6 +260,14 @@
        ? mmesa->driDrawable : mmesa->driReadable;
 }
 
+/**
+ * Initialize the driver callbacks for the read / write span functions.
+ *
+ * \bug
+ * To really support RGB888 and RGBA8888 visuals, we need separate read and
+ * write routines for 888 and 8888.  We also need to determine whether or not
+ * the visual has destination alpha.
+ */
 void mgaDDInitSpanFuncs( GLcontext *ctx )
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);

Reply via email to