Enclose passed macro values in brackets to ensure correct read/write span

values.
This commit is contained in:
Alan Hourihane
2005-01-20 13:24:08 +00:00
parent cb3bc2c49a
commit ddfa61ee19
7 changed files with 33 additions and 33 deletions

View File

@@ -147,10 +147,10 @@ do { \
/* 16 bit depthbuffer functions. /* 16 bit depthbuffer functions.
*/ */
#define WRITE_DEPTH( _x, _y, d ) \ #define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = d; *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
#define READ_DEPTH( d, _x, _y ) \ #define READ_DEPTH( d, _x, _y ) \
d = *(GLushort *)(buf + _x*2 + _y*pitch); d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
#define TAG(x) gamma##x##_16 #define TAG(x) gamma##x##_16
#include "depthtmp.h" #include "depthtmp.h"
@@ -161,10 +161,10 @@ do { \
/* 32 bit depthbuffer functions. /* 32 bit depthbuffer functions.
*/ */
#define WRITE_DEPTH( _x, _y, d ) \ #define WRITE_DEPTH( _x, _y, d ) \
*(GLuint *)(buf + _x*4 + _y*pitch) = d; *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = d;
#define READ_DEPTH( d, _x, _y ) \ #define READ_DEPTH( d, _x, _y ) \
d = *(GLuint *)(buf + _x*4 + _y*pitch); d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch);
#define TAG(x) gamma##x##_32 #define TAG(x) gamma##x##_32
#include "depthtmp.h" #include "depthtmp.h"
@@ -174,14 +174,14 @@ do { \
/* 24/8 bit interleaved depth/stencil functions /* 24/8 bit interleaved depth/stencil functions
*/ */
#define WRITE_DEPTH( _x, _y, d ) { \ #define WRITE_DEPTH( _x, _y, d ) { \
GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \
tmp &= 0xff; \ tmp &= 0xff; \
tmp |= (d) & 0xffffff00; \ tmp |= (d) & 0xffffff00; \
*(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \ *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \
} }
#define READ_DEPTH( d, _x, _y ) \ #define READ_DEPTH( d, _x, _y ) \
d = *(GLuint *)(buf + _x*4 + _y*pitch) & ~0xff; d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch) & ~0xff;
#define TAG(x) gamma##x##_24_8 #define TAG(x) gamma##x##_24_8

View File

@@ -102,10 +102,10 @@ do { \
/* 16 bit depthbuffer functions. /* 16 bit depthbuffer functions.
*/ */
#define WRITE_DEPTH( _x, _y, d ) \ #define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = d; *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
#define READ_DEPTH( d, _x, _y ) \ #define READ_DEPTH( d, _x, _y ) \
d = *(GLushort *)(buf + _x*2 + _y*pitch); d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
#define TAG(x) i810##x##_16 #define TAG(x) i810##x##_16
#include "depthtmp.h" #include "depthtmp.h"

View File

@@ -153,10 +153,10 @@ do { \
/* 16 bit depthbuffer functions. /* 16 bit depthbuffer functions.
*/ */
#define WRITE_DEPTH( _x, _y, d ) \ #define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = d; *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
#define READ_DEPTH( d, _x, _y ) \ #define READ_DEPTH( d, _x, _y ) \
d = *(GLushort *)(buf + _x*2 + _y*pitch); d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
#define TAG(x) intel##x##_16 #define TAG(x) intel##x##_16

View File

@@ -138,10 +138,10 @@
/* 16 bit depthbuffer functions. /* 16 bit depthbuffer functions.
*/ */
#define WRITE_DEPTH( _x, _y, d ) \ #define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = d; *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
#define READ_DEPTH( d, _x, _y ) \ #define READ_DEPTH( d, _x, _y ) \
d = *(GLushort *)(buf + _x*2 + _y*pitch); d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
#define TAG(x) mga##x##_16 #define TAG(x) mga##x##_16
#include "depthtmp.h" #include "depthtmp.h"
@@ -152,10 +152,10 @@
/* 32 bit depthbuffer functions. /* 32 bit depthbuffer functions.
*/ */
#define WRITE_DEPTH( _x, _y, d ) \ #define WRITE_DEPTH( _x, _y, d ) \
*(GLuint *)(buf + _x*4 + _y*pitch) = d; *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = d;
#define READ_DEPTH( d, _x, _y ) \ #define READ_DEPTH( d, _x, _y ) \
d = *(GLuint *)(buf + _x*4 + _y*pitch); d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch);
#define TAG(x) mga##x##_32 #define TAG(x) mga##x##_32
#include "depthtmp.h" #include "depthtmp.h"
@@ -165,14 +165,14 @@
/* 24/8 bit interleaved depth/stencil functions /* 24/8 bit interleaved depth/stencil functions
*/ */
#define WRITE_DEPTH( _x, _y, d ) { \ #define WRITE_DEPTH( _x, _y, d ) { \
GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \
tmp &= 0xff; \ tmp &= 0xff; \
tmp |= (d) << 8; \ tmp |= (d) << 8; \
*(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \ *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \
} }
#define READ_DEPTH( d, _x, _y ) { \ #define READ_DEPTH( d, _x, _y ) { \
d = (*(GLuint *)(buf + _x*4 + _y*pitch) & ~0xff) >> 8; \ d = (*(GLuint *)(buf + (_x)*4 + (_y)*pitch) & ~0xff) >> 8; \
} }
#define TAG(x) mga##x##_24_8 #define TAG(x) mga##x##_24_8

View File

@@ -154,7 +154,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* 16-bit depth buffer functions /* 16-bit depth buffer functions
*/ */
#define READ_DEPTH(d, _x, _y) \ #define READ_DEPTH(d, _x, _y) \
d = *(GLushort *)(buf + _x*2 + _y*pitch) d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch)
#define WRITE_DEPTH_SPAN() \ #define WRITE_DEPTH_SPAN() \
r128WriteDepthSpanLocked( rmesa, n, \ r128WriteDepthSpanLocked( rmesa, n, \

View File

@@ -143,10 +143,10 @@ do { \
/* 16 bit depthbuffer functions. /* 16 bit depthbuffer functions.
*/ */
#define WRITE_DEPTH( _x, _y, d ) \ #define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + _x*2 + _y*smesa->depthPitch) = d; *(GLushort *)(buf + (_x)*2 + (_y)*smesa->depthPitch) = d;
#define READ_DEPTH( d, _x, _y ) \ #define READ_DEPTH( d, _x, _y ) \
d = *(GLushort *)(buf + _x*2 + _y*smesa->depthPitch); d = *(GLushort *)(buf + (_x)*2 + (_y)*smesa->depthPitch);
#define TAG(x) sis##x##_16 #define TAG(x) sis##x##_16
#include "depthtmp.h" #include "depthtmp.h"
@@ -155,10 +155,10 @@ do { \
/* 32 bit depthbuffer functions. /* 32 bit depthbuffer functions.
*/ */
#define WRITE_DEPTH( _x, _y, d ) \ #define WRITE_DEPTH( _x, _y, d ) \
*(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) = d; *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = d;
#define READ_DEPTH( d, _x, _y ) \ #define READ_DEPTH( d, _x, _y ) \
d = *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch); d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch);
#define TAG(x) sis##x##_32 #define TAG(x) sis##x##_32
#include "depthtmp.h" #include "depthtmp.h"
@@ -167,28 +167,28 @@ do { \
/* 8/24 bit interleaved depth/stencil functions /* 8/24 bit interleaved depth/stencil functions
*/ */
#define WRITE_DEPTH( _x, _y, d ) { \ #define WRITE_DEPTH( _x, _y, d ) { \
GLuint tmp = *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch); \ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch); \
tmp &= 0xff000000; \ tmp &= 0xff000000; \
tmp |= (d & 0x00ffffff); \ tmp |= (d & 0x00ffffff); \
*(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) = tmp; \ *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = tmp; \
} }
#define READ_DEPTH( d, _x, _y ) { \ #define READ_DEPTH( d, _x, _y ) { \
d = *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) & 0x00ffffff; \ d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0x00ffffff; \
} }
#define TAG(x) sis##x##_24_8 #define TAG(x) sis##x##_24_8
#include "depthtmp.h" #include "depthtmp.h"
#define WRITE_STENCIL( _x, _y, d ) { \ #define WRITE_STENCIL( _x, _y, d ) { \
GLuint tmp = *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch); \ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch); \
tmp &= 0x00ffffff; \ tmp &= 0x00ffffff; \
tmp |= (d << 24); \ tmp |= (d << 24); \
*(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) = tmp; \ *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = tmp; \
} }
#define READ_STENCIL( d, _x, _y ) \ #define READ_STENCIL( d, _x, _y ) \
d = (*(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) & 0xff000000) >> 24; d = (*(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0xff000000) >> 24;
#define TAG(x) sis##x##_24_8 #define TAG(x) sis##x##_24_8
#include "stenciltmp.h" #include "stenciltmp.h"

View File

@@ -121,10 +121,10 @@
#define WRITE_DEPTH(_x, _y, d) \ #define WRITE_DEPTH(_x, _y, d) \
*(GLushort *)(buf + _x * 2 + _y * depth_pitch) = d; *(GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch) = d;
#define READ_DEPTH(d, _x, _y) \ #define READ_DEPTH(d, _x, _y) \
d = *(GLushort *)(buf + _x * 2 + _y * depth_pitch); d = *(volatile GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch);
#define TAG(x) via##x##_16 #define TAG(x) via##x##_16
#include "depthtmp.h" #include "depthtmp.h"
@@ -132,10 +132,10 @@
/* 32 bit depthbuffer functions. /* 32 bit depthbuffer functions.
*/ */
#define WRITE_DEPTH(_x, _y, d) \ #define WRITE_DEPTH(_x, _y, d) \
*(GLuint *)(buf + _x * 4 + _y * depth_pitch) = d; *(GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch) = d;
#define READ_DEPTH(d, _x, _y) \ #define READ_DEPTH(d, _x, _y) \
d = *(GLuint *)(buf + _x * 4 + _y * depth_pitch); d = *(volatile GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch);
#define TAG(x) via##x##_32 #define TAG(x) via##x##_32
#include "depthtmp.h" #include "depthtmp.h"