dri: Fix write/read depth buffer issue under 16bpp mode. See bug #16646
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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; \
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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); \
|
||||
@@ -115,6 +114,8 @@
|
||||
/**
|
||||
** 16-bit depthbuffer functions.
|
||||
**/
|
||||
#define VALUE_TYPE GLushort
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
((GLushort *)buf)[(_x) + (_y) * pitch] = d;
|
||||
|
||||
@@ -132,6 +133,8 @@
|
||||
** 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); \
|
||||
|
||||
@@ -117,6 +117,8 @@
|
||||
|
||||
/* 16 bit depthbuffer functions.
|
||||
*/
|
||||
#define VALUE_TYPE GLushort
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLushort *)(buf + ((_x) + (_y) * drb->pitch) * 2) = d;
|
||||
|
||||
|
||||
@@ -107,6 +107,8 @@
|
||||
|
||||
/* 16 bit depthbuffer functions.
|
||||
*/
|
||||
#define VALUE_TYPE GLushort
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
|
||||
|
||||
@@ -121,6 +123,8 @@
|
||||
|
||||
/* 32 bit depthbuffer functions.
|
||||
*/
|
||||
#define VALUE_TYPE GLuint
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLuint *)(buf + (_x)*4 + (_y)*pitch) = d;
|
||||
|
||||
@@ -134,6 +138,8 @@
|
||||
|
||||
/* 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; \
|
||||
|
||||
@@ -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]; \
|
||||
|
||||
@@ -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 { \
|
||||
|
||||
@@ -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 { \
|
||||
|
||||
@@ -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 { \
|
||||
|
||||
@@ -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; \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -107,6 +109,8 @@
|
||||
|
||||
/* 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 )
|
||||
@@ -125,6 +129,8 @@
|
||||
/* 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; \
|
||||
@@ -143,6 +149,8 @@
|
||||
|
||||
/* 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; \
|
||||
|
||||
@@ -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; \
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -111,6 +114,8 @@
|
||||
|
||||
/* 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; \
|
||||
|
||||
@@ -275,6 +275,8 @@
|
||||
#undef BYTESPERPIXEL
|
||||
#define BYTESPERPIXEL 2
|
||||
|
||||
#define VALUE_TYPE GLushort
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d
|
||||
|
||||
@@ -302,6 +304,8 @@
|
||||
#undef BYTESPERPIXEL
|
||||
#define BYTESPERPIXEL 4
|
||||
|
||||
#define VALUE_TYPE GLuint
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8
|
||||
|
||||
|
||||
Reference in New Issue
Block a user