[Mesa-dev] [PATCH] swrast: add casts for ImageSlices pointer arithmetic
Brian Paul
brianp at vmware.com
Tue Apr 30 12:35:23 PDT 2013
MSVC doesn't like pointer arithmetic with void * so use GLubyte *.
---
src/mesa/swrast/s_texfetch_tmp.h | 8 ++++----
src/mesa/swrast/s_texfilter.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/mesa/swrast/s_texfetch_tmp.h b/src/mesa/swrast/s_texfetch_tmp.h
index c9991cd..714226c 100644
--- a/src/mesa/swrast/s_texfetch_tmp.h
+++ b/src/mesa/swrast/s_texfetch_tmp.h
@@ -44,15 +44,15 @@
#if DIM == 1
#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((void) (j), (void) (k), ((type *)(image)->ImageSlices[0] + (i) * (size)))
+ ((void) (j), (void) (k), ((type *)((GLubyte *) (image)->ImageSlices[0]) + (i) * (size)))
#define FETCH(x) fetch_texel_1d_##x
#elif DIM == 2
#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((void) (k), \
- ((type *)((image)->ImageSlices[0] + (image)->RowStride * (j)) + \
+ ((void) (k), \
+ ((type *)((GLubyte *) (image)->ImageSlices[0] + (image)->RowStride * (j)) + \
(i) * (size)))
#define FETCH(x) fetch_texel_2d_##x
@@ -60,7 +60,7 @@
#elif DIM == 3
#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((type *)((image)->ImageSlices[k] + \
+ ((type *)((GLubyte *) (image)->ImageSlices[k] + \
(image)->RowStride * (j)) + (i) * (size))
#define FETCH(x) fetch_texel_3d_##x
diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index c8ea26a..fba8e6c 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -1436,7 +1436,7 @@ opt_sample_rgb_2d(struct gl_context *ctx,
GLint i = IFLOOR(texcoords[k][0] * width) & colMask;
GLint j = IFLOOR(texcoords[k][1] * height) & rowMask;
GLint pos = (j << shift) | i;
- GLubyte *texel = swImg->ImageSlices[0] + 3 * pos;
+ GLubyte *texel = (GLubyte *) swImg->ImageSlices[0] + 3 * pos;
rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]);
rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]);
rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]);
--
1.7.3.4
More information about the mesa-dev
mailing list