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 55199abf6a3f4e317df88c4110b5891774100af2..fd2dab3b42238b6a55c107b34e16db373582b207 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 f62bea9b66dade0ba7b8d58f5c48df63710ef45f..933f62c96c7f6eaaaa7a3a9b7c6f6f2b174889bf 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 2112800eebccd0ec81dcbc002869e4cdb5c50c72..59511de973b757b9b370425af7ed93ef5ae11203 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 df4f5927a0fd7060c566f95287d493e948620ea2..742b1b87350bc19655642786857145ddeb7c1210 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 3830a28165bcdc0497013432fcb84fd8e55e6a14..aa8c72513ba1f116f5a6b063cf02b99003da95ed 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 05dcbb852639efbcbc94043d7fad8cc915dd2932..7ac59661acdc4334dd4a9dd3e446c21f23a97ebf 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 85798c16013443b574cb370b91f6febeea5288b2..9b73886816f01ea01336428055a7b9cf2b44a989 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 ff2eb01122518b5535e38495e9504f4ba6974dc5..3d7a0002180c94c9766b5bb6de8812111ab7b2c3 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 f1bc56ea6a4de5b7a32e5d0cc84afb5ba8de15ee..3616d8b14de3e08b6c27a43bec51dda6f385fad5 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 732a85ecf0bdf6af17a4575f9ebe962847de0795..e7ab3677b36120bf25b394b690d7de25e6c19f3a 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 de78f9f6b1bd8e801c52f2c971bd99302ad9c162..f9f7c0d1eeecd55a6f242e7191f93a4ddb76ca75 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 61ab9e6d64a7a7736ef3695be75cfe820eb2d9e4..00fd1259fd6fcee3e18cf041c0613808b3653922 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 ea6db6781d4fba3b59cd6a9fde98ca7604eb1967..7f205f3ca508e442fb0b525141c0912d5c3b9304 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 3a16dadd238e0fba4b80a23f4b862ba4fa3b5dbc..15e29c52cd9c386b0d3ce5a67812a2f124b0a90f 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 3ea9f73dd2043c48530dc44adbb666e771cc1ef5..d3a58a301c2c15c5f33988b9471f2688e53cd788 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