dri: Fix write/read depth buffer issue under 16bpp mode. See bug #16646
authorXiang, Haihao <haihao.xiang@intel.com>
Tue, 5 Aug 2008 03:28:54 +0000 (11:28 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Tue, 5 Aug 2008 03:34:26 +0000 (11:34 +0800)
15 files changed:
src/mesa/drivers/dri/common/depthtmp.h
src/mesa/drivers/dri/gamma/gamma_span.c
src/mesa/drivers/dri/i810/i810span.c
src/mesa/drivers/dri/intel/intel_span.c
src/mesa/drivers/dri/mach64/mach64_span.c
src/mesa/drivers/dri/mga/mgaspan.c
src/mesa/drivers/dri/r128/r128_span.c
src/mesa/drivers/dri/r200/r200_span.c
src/mesa/drivers/dri/r300/radeon_span.c
src/mesa/drivers/dri/radeon/radeon_span.c
src/mesa/drivers/dri/s3v/s3v_span.c
src/mesa/drivers/dri/savage/savagespan.c
src/mesa/drivers/dri/sis/sis_span.c
src/mesa/drivers/dri/unichrome/via_span.c
src/mesa/drivers/glide/fxddspan.c

index 55199ab..fd2dab3 100644 (file)
@@ -29,7 +29,7 @@ static void TAG(WriteDepthSpan)( GLcontext *ctx,
 {
    HW_WRITE_LOCK()
       {
-         const GLuint *depth = (const GLuint *) values;
+         const VALUE_TYPE *depth = (const VALUE_TYPE *) values;
         GLint x1;
         GLint n1;
         LOCAL_DEPTH_VARS;
@@ -134,7 +134,7 @@ static void TAG(WriteDepthPixels)( GLcontext *ctx,
 {
    HW_WRITE_LOCK()
       {
-         const GLuint *depth = (const GLuint *) values;
+         const VALUE_TYPE *depth = (const VALUE_TYPE *) values;
         GLuint i;
         LOCAL_DEPTH_VARS;
 
@@ -180,7 +180,7 @@ static void TAG(ReadDepthSpan)( GLcontext *ctx,
 {
    HW_READ_LOCK()
       {
-         GLuint *depth = (GLuint *) values;
+         VALUE_TYPE *depth = (VALUE_TYPE *) values;
         GLint x1, n1;
         LOCAL_DEPTH_VARS;
 
@@ -215,7 +215,7 @@ static void TAG(ReadDepthPixels)( GLcontext *ctx,
 {
    HW_READ_LOCK()
       {
-         GLuint *depth = (GLuint *) values;
+         VALUE_TYPE *depth = (VALUE_TYPE *) values;
         GLuint i;
         LOCAL_DEPTH_VARS;
 
@@ -267,3 +267,4 @@ static void TAG(InitDepthPointers)(struct gl_renderbuffer *rb)
 #undef READ_DEPTH
 #endif
 #undef TAG
+#undef VALUE_TYPE
index f62bea9..933f62c 100644 (file)
@@ -112,6 +112,8 @@ do {                                                                        \
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
 
@@ -125,6 +127,8 @@ do {                                                                        \
 #if 0 /* Unused */
 /* 32 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = d;
 
@@ -138,6 +142,8 @@ do {                                                                        \
 
 /* 24/8 bit interleaved depth/stencil functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) {                     \
    GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch);        \
    tmp &= 0xff;                                                \
index 2112800..59511de 100644 (file)
@@ -67,6 +67,8 @@ do {                                                                  \
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d ) \
    *(GLushort *)(buf + (_x)*2 + (_y)*pitch)  = d;
 
index df4f592..742b1b8 100644 (file)
@@ -99,7 +99,6 @@
 #define GET_PTR(X,Y) (buf + ((Y) * irb->pfPitch + (X)) * 4)
 #include "spantmp2.h"
 
-
 #define LOCAL_DEPTH_VARS                                               \
    struct intel_context *intel = intel_context(ctx);                   \
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);            \
 /**
  ** 16-bit depthbuffer functions.
  **/
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d ) \
    ((GLushort *)buf)[(_x) + (_y) * pitch] = d;
 
  ** The wrappers in main/depthstencil.c are used to extract the depth
  ** and stencil values.
  **/
+#define VALUE_TYPE GLuint
+
 /* Change ZZZS -> SZZZ */
 #define WRITE_DEPTH( _x, _y, d ) {                             \
    GLuint tmp = ((d) >> 8) | ((d) << 24);                      \
index 3830a28..aa8c725 100644 (file)
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
    *(GLushort *)(buf + ((_x) + (_y) * drb->pitch) * 2) = d;
 
index 05dcbb8..7ac5966 100644 (file)
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
 
 
 /* 32 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = d;
 
 
 /* 24/8 bit interleaved depth/stencil functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) {                     \
    GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch);        \
    tmp &= 0xff;                                                \
index 85798c1..9b73886 100644 (file)
@@ -131,6 +131,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
 
 #define WRITE_DEPTH_SPAN()                                             \
 do {                                                                   \
@@ -207,6 +208,8 @@ do {                                                                        \
 
 /* 24-bit depth, 8-bit stencil buffer functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH_SPAN()                                             \
 do {                                                                   \
    GLuint buf[n];                                                      \
index ff2eb01..3d7a000 100644 (file)
@@ -172,6 +172,7 @@ r200_mba_z16( driRenderbuffer *drb, GLint x, GLint y )
 
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
 
 #define WRITE_DEPTH( _x, _y, d )                                       \
    *(GLushort *)(buf + r200_mba_z16( drb, _x + xo, _y + yo )) = d;
@@ -185,6 +186,7 @@ r200_mba_z16( driRenderbuffer *drb, GLint x, GLint y )
 
 /* 24 bit depth, 8 bit stencil depthbuffer functions
  */
+#define VALUE_TYPE GLuint
 
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
index f1bc56e..3616d8b 100644 (file)
@@ -172,6 +172,8 @@ radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
 
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
    *(GLushort *)(buf + radeon_mba_z16( drb, _x + xo, _y + yo )) = d;
 
@@ -186,6 +188,8 @@ radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
  * Careful: It looks like the R300 uses ZZZS byte order while the R200
  * uses SZZZ for 24 bit depth, 8 bit stencil mode.
  */
+#define VALUE_TYPE GLuint
+
 #ifdef COMPILE_R300
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
index 732a85e..e7ab367 100644 (file)
@@ -173,6 +173,8 @@ radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
 
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
    *(GLushort *)(buf + radeon_mba_z16( drb, _x + xo, _y + yo )) = d;
 
@@ -187,6 +189,8 @@ radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
  * Careful: It looks like the R300 uses ZZZS byte order while the R200
  * uses SZZZ for 24 bit depth, 8 bit stencil mode.
  */
+#define VALUE_TYPE GLuint
+
 #ifdef COMPILE_R300
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
index de78f9f..f9f7c0d 100644 (file)
@@ -128,6 +128,8 @@ do { \
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d ) \
    *(GLushort *)(buf + _x*2 + _y*dPriv->w*2) = d
 
@@ -143,6 +145,8 @@ do { \
 /* 32 bit depthbuffer functions.
  */
 #if 0
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLuint *)(buf + _x*4 + _y*pitch) = d;
 
@@ -157,6 +161,8 @@ do { \
 /* 24/8 bit interleaved depth/stencil functions
  */
 #if 0
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) { \
    GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch);    \
    tmp &= 0xff; \
index 61ab9e6..00fd125 100644 (file)
@@ -93,6 +93,8 @@
 /* 16 bit integer depthbuffer functions
  * Depth range is reversed. See also savageCalcViewport.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d ) \
     *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = 0xFFFF - d
 
 
 /* 16 bit float depthbuffer functions
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d ) \
     *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = \
         savageEncodeFloat16( 1.0 - (GLfloat)d/65535.0 )
 /* 8-bit stencil /24-bit integer depth depthbuffer functions.
  * Depth range is reversed. See also savageCalcViewport.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) do {                          \
    GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch);     \
    tmp &= 0xFF000000;                                          \
 
 /* 24 bit float depthbuffer functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) do {                          \
     GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch);    \
     tmp &= 0xFF000000;                                         \
index ea6db67..7f205f3 100644 (file)
@@ -85,6 +85,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch) = d;
 
@@ -97,6 +99,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* 32 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = d;
 
@@ -109,6 +113,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* 8/24 bit interleaved depth/stencil functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) {                             \
    GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch);   \
    tmp &= 0xff000000;                                          \
index 3a16dad..15e29c5 100644 (file)
@@ -86,6 +86,7 @@
 
 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS 
 
+#define VALUE_TYPE GLushort
 
 #define WRITE_DEPTH(_x, _y, d)                      \
     *(GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch) = d;
@@ -98,6 +99,8 @@
 
 /* 32 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH(_x, _y, d)                      \
     *(GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch) = d;
 
 
 /* 24/8 bit interleaved depth/stencil functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) {                     \
    GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch);  \
    tmp &= 0x000000ff;                                  \
index 3ea9f73..d3a58a3 100644 (file)
 #undef BYTESPERPIXEL
 #define BYTESPERPIXEL 2
 
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
     *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d
 
 #undef BYTESPERPIXEL
 #define BYTESPERPIXEL 4
 
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
     *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8