aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-07-05 20:07:07 -0600
committerBrian Paul <[email protected]>2010-07-05 20:14:39 -0600
commitabd5627a6a034885b0b01b995c73870da1361bb0 (patch)
treef13fb38b514f020d6637d64cdf709c4f94e7a876 /src/mesa/main
parente54164b4e3890e3eddc4ae976e3cc2f1fa2f441b (diff)
mesa: initial support for unnormalized integer texture formats
As defined by GL_EXT_texture_integer.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/formats.c92
-rw-r--r--src/mesa/main/formats.h16
-rw-r--r--src/mesa/main/image.c451
-rw-r--r--src/mesa/main/image.h3
-rw-r--r--src/mesa/main/texfetch.c50
-rw-r--r--src/mesa/main/texfetch_tmp.h168
-rw-r--r--src/mesa/main/texformat.c47
-rw-r--r--src/mesa/main/teximage.c52
-rw-r--r--src/mesa/main/texstore.c394
9 files changed, 1140 insertions, 133 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 3671140e859..49463fcc3c2 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -48,7 +48,7 @@ struct gl_format_info
/**
* Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED,
- * GL_UNSIGNED_INT, GL_SIGNED_INT, GL_FLOAT.
+ * GL_UNSIGNED_INT, GL_INT, GL_FLOAT.
*/
GLenum DataType;
@@ -628,6 +628,66 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 16, 0, 0, 0,
1, 1, 2
},
+
+ /* unnormalized signed int formats */
+ {
+ MESA_FORMAT_RGBA_INT8,
+ "MESA_FORMAT_RGBA_INT8",
+ GL_RGBA,
+ GL_INT,
+ 8, 8, 8, 8,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
+ {
+ MESA_FORMAT_RGBA_INT16,
+ "MESA_FORMAT_RGBA_INT16",
+ GL_RGBA,
+ GL_INT,
+ 16, 16, 16, 16,
+ 0, 0, 0, 0, 0,
+ 1, 1, 8
+ },
+ {
+ MESA_FORMAT_RGBA_INT32,
+ "MESA_FORMAT_RGBA_INT32",
+ GL_RGBA,
+ GL_INT,
+ 32, 32, 32, 32,
+ 0, 0, 0, 0, 0,
+ 1, 1, 16
+ },
+
+ /* unnormalized unsigned int formats */
+ {
+ MESA_FORMAT_RGBA_UINT8,
+ "MESA_FORMAT_RGBA_UINT8",
+ GL_RGBA,
+ GL_UNSIGNED_INT,
+ 8, 8, 8, 8,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
+ {
+ MESA_FORMAT_RGBA_UINT16,
+ "MESA_FORMAT_RGBA_UINT16",
+ GL_RGBA,
+ GL_UNSIGNED_INT,
+ 16, 16, 16, 16,
+ 0, 0, 0, 0, 0,
+ 1, 1, 8
+ },
+ {
+ MESA_FORMAT_RGBA_UINT32,
+ "MESA_FORMAT_RGBA_UINT32",
+ GL_RGBA,
+ GL_UNSIGNED_INT,
+ 32, 32, 32, 32,
+ 0, 0, 0, 0, 0,
+ 1, 1, 16
+ },
+
+
{
MESA_FORMAT_DUDV8,
"MESA_FORMAT_DUDV8",
@@ -1230,6 +1290,36 @@ _mesa_format_to_type_and_comps(gl_format format,
*comps = 1;
return;
+ case MESA_FORMAT_RGBA_INT8:
+ *datatype = GL_BYTE;
+ *comps = 4;
+ return;
+ case MESA_FORMAT_RGBA_INT16:
+ *datatype = GL_SHORT;
+ *comps = 4;
+ return;
+ case MESA_FORMAT_RGBA_INT32:
+ *datatype = GL_INT;
+ *comps = 4;
+ return;
+
+ /**
+ * \name Non-normalized unsigned integer formats.
+ */
+ case MESA_FORMAT_RGBA_UINT8:
+ *datatype = GL_UNSIGNED_BYTE;
+ *comps = 4;
+ return;
+ case MESA_FORMAT_RGBA_UINT16:
+ *datatype = GL_UNSIGNED_SHORT;
+ *comps = 4;
+ return;
+ case MESA_FORMAT_RGBA_UINT32:
+ *datatype = GL_UNSIGNED_INT;
+ *comps = 4;
+ return;
+
+
default:
_mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps");
*datatype = 0;
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index c744688122f..aa14185628f 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -130,6 +130,22 @@ typedef enum
MESA_FORMAT_INTENSITY_FLOAT16,
/*@}*/
+ /**
+ * \name Non-normalized signed integer formats.
+ * XXX Note: these are just stand-ins for some better hardware
+ * formats TBD such as BGRA or ARGB.
+ */
+ MESA_FORMAT_RGBA_INT8,
+ MESA_FORMAT_RGBA_INT16,
+ MESA_FORMAT_RGBA_INT32,
+
+ /**
+ * \name Non-normalized unsigned integer formats.
+ */
+ MESA_FORMAT_RGBA_UINT8,
+ MESA_FORMAT_RGBA_UINT16,
+ MESA_FORMAT_RGBA_UINT32,
+
/* msb <------ TEXEL BITS -----------> lsb */
/* ---- ---- ---- ---- ---- ---- ---- ---- */
/**
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 93b01423dcf..63c28342f26 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -274,17 +274,25 @@ _mesa_components_in_format( GLenum format )
case GL_STENCIL_INDEX:
case GL_DEPTH_COMPONENT:
case GL_RED:
+ case GL_RED_INTEGER_EXT:
case GL_GREEN:
+ case GL_GREEN_INTEGER_EXT:
case GL_BLUE:
+ case GL_BLUE_INTEGER_EXT:
case GL_ALPHA:
+ case GL_ALPHA_INTEGER_EXT:
case GL_LUMINANCE:
+ case GL_LUMINANCE_INTEGER_EXT:
case GL_INTENSITY:
return 1;
case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
return 2;
case GL_RGB:
+ case GL_RGB_INTEGER_EXT:
return 3;
case GL_RGBA:
+ case GL_RGBA_INTEGER_EXT:
return 4;
case GL_BGR:
return 3;
@@ -523,6 +531,28 @@ _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type )
default:
return GL_FALSE;
}
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_RGB_INTEGER_EXT:
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGR_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return ctx->Extensions.EXT_texture_integer;
+ default:
+ return GL_FALSE;
+ }
+
default:
; /* fall-through */
}
@@ -777,6 +807,30 @@ _mesa_is_dudv_format(GLenum format)
/**
+ * Test if the given format is an integer (non-normalized) format.
+ */
+GLboolean
+_mesa_is_integer_format(GLenum format)
+{
+ switch (format) {
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_RGB_INTEGER_EXT:
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGR_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
* Test if an image format is a supported compressed format.
* \param format the internal format token provided by the user.
* \return GL_TRUE if compressed, GL_FALSE if uncompressed
@@ -3275,6 +3329,8 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
GLint redIndex, greenIndex, blueIndex, alphaIndex;
GLint stride;
GLint rComp, bComp, gComp, aComp;
+ GLboolean intFormat;
+ GLfloat rs = 1.0f, gs = 1.0f, bs = 1.0f, as = 1.0f; /* scale factors */
ASSERT(srcFormat == GL_RED ||
srcFormat == GL_GREEN ||
@@ -3289,7 +3345,17 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
srcFormat == GL_BGRA ||
srcFormat == GL_ABGR_EXT ||
srcFormat == GL_DU8DV8_ATI ||
- srcFormat == GL_DUDV_ATI);
+ srcFormat == GL_DUDV_ATI ||
+ srcFormat == GL_RED_INTEGER_EXT ||
+ srcFormat == GL_GREEN_INTEGER_EXT ||
+ srcFormat == GL_BLUE_INTEGER_EXT ||
+ srcFormat == GL_ALPHA_INTEGER_EXT ||
+ srcFormat == GL_RGB_INTEGER_EXT ||
+ srcFormat == GL_RGBA_INTEGER_EXT ||
+ srcFormat == GL_BGR_INTEGER_EXT ||
+ srcFormat == GL_BGRA_INTEGER_EXT ||
+ srcFormat == GL_LUMINANCE_INTEGER_EXT ||
+ srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT);
ASSERT(srcType == GL_UNSIGNED_BYTE ||
srcType == GL_BYTE ||
@@ -3316,31 +3382,37 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
switch (srcFormat) {
case GL_RED:
+ case GL_RED_INTEGER_EXT:
redIndex = 0;
greenIndex = blueIndex = alphaIndex = -1;
stride = 1;
break;
case GL_GREEN:
+ case GL_GREEN_INTEGER_EXT:
greenIndex = 0;
redIndex = blueIndex = alphaIndex = -1;
stride = 1;
break;
case GL_BLUE:
+ case GL_BLUE_INTEGER_EXT:
blueIndex = 0;
redIndex = greenIndex = alphaIndex = -1;
stride = 1;
break;
case GL_ALPHA:
+ case GL_ALPHA_INTEGER_EXT:
redIndex = greenIndex = blueIndex = -1;
alphaIndex = 0;
stride = 1;
break;
case GL_LUMINANCE:
+ case GL_LUMINANCE_INTEGER_EXT:
redIndex = greenIndex = blueIndex = 0;
alphaIndex = -1;
stride = 1;
break;
case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
redIndex = greenIndex = blueIndex = 0;
alphaIndex = 1;
stride = 2;
@@ -3350,6 +3422,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
stride = 1;
break;
case GL_RGB:
+ case GL_RGB_INTEGER:
redIndex = 0;
greenIndex = 1;
blueIndex = 2;
@@ -3372,6 +3445,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
stride = 3;
break;
case GL_RGBA:
+ case GL_RGBA_INTEGER:
redIndex = 0;
greenIndex = 1;
blueIndex = 2;
@@ -3418,12 +3492,20 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
return;
}
+ intFormat = _mesa_is_integer_format(srcFormat);
-#define PROCESS(INDEX, CHANNEL, DEFAULT, TYPE, CONVERSION) \
+#define PROCESS(INDEX, CHANNEL, DEFAULT, DEFAULT_INT, TYPE, CONVERSION) \
if ((INDEX) < 0) { \
GLuint i; \
- for (i = 0; i < n; i++) { \
- rgba[i][CHANNEL] = DEFAULT; \
+ if (intFormat) { \
+ for (i = 0; i < n; i++) { \
+ rgba[i][CHANNEL] = DEFAULT_INT; \
+ } \
+ } \
+ else { \
+ for (i = 0; i < n; i++) { \
+ rgba[i][CHANNEL] = DEFAULT; \
+ } \
} \
} \
else if (swapBytes) { \
@@ -3437,77 +3519,93 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
else if (sizeof(TYPE) == 4) { \
SWAP4BYTE(value); \
} \
- rgba[i][CHANNEL] = (GLfloat) CONVERSION(value); \
+ if (intFormat) \
+ rgba[i][CHANNEL] = (GLfloat) value; \
+ else \
+ rgba[i][CHANNEL] = (GLfloat) CONVERSION(value); \
s += stride; \
} \
} \
else { \
const TYPE *s = (const TYPE *) src; \
GLuint i; \
- for (i = 0; i < n; i++) { \
- rgba[i][CHANNEL] = (GLfloat) CONVERSION(s[INDEX]); \
- s += stride; \
+ if (intFormat) { \
+ for (i = 0; i < n; i++) { \
+ rgba[i][CHANNEL] = (GLfloat) s[INDEX]; \
+ s += stride; \
+ } \
+ } \
+ else { \
+ for (i = 0; i < n; i++) { \
+ rgba[i][CHANNEL] = (GLfloat) CONVERSION(s[INDEX]); \
+ s += stride; \
+ } \
} \
}
switch (srcType) {
case GL_UNSIGNED_BYTE:
- PROCESS(redIndex, RCOMP, 0.0F, GLubyte, UBYTE_TO_FLOAT);
- PROCESS(greenIndex, GCOMP, 0.0F, GLubyte, UBYTE_TO_FLOAT);
- PROCESS(blueIndex, BCOMP, 0.0F, GLubyte, UBYTE_TO_FLOAT);
- PROCESS(alphaIndex, ACOMP, 1.0F, GLubyte, UBYTE_TO_FLOAT);
+ PROCESS(redIndex, RCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, 255, GLubyte, UBYTE_TO_FLOAT);
break;
case GL_BYTE:
- PROCESS(redIndex, RCOMP, 0.0F, GLbyte, BYTE_TO_FLOAT);
- PROCESS(greenIndex, GCOMP, 0.0F, GLbyte, BYTE_TO_FLOAT);
- PROCESS(blueIndex, BCOMP, 0.0F, GLbyte, BYTE_TO_FLOAT);
- PROCESS(alphaIndex, ACOMP, 1.0F, GLbyte, BYTE_TO_FLOAT);
+ PROCESS(redIndex, RCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, 127, GLbyte, BYTE_TO_FLOAT);
break;
case GL_UNSIGNED_SHORT:
- PROCESS(redIndex, RCOMP, 0.0F, GLushort, USHORT_TO_FLOAT);
- PROCESS(greenIndex, GCOMP, 0.0F, GLushort, USHORT_TO_FLOAT);
- PROCESS(blueIndex, BCOMP, 0.0F, GLushort, USHORT_TO_FLOAT);
- PROCESS(alphaIndex, ACOMP, 1.0F, GLushort, USHORT_TO_FLOAT);
+ PROCESS(redIndex, RCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, 0xffff, GLushort, USHORT_TO_FLOAT);
break;
case GL_SHORT:
- PROCESS(redIndex, RCOMP, 0.0F, GLshort, SHORT_TO_FLOAT);
- PROCESS(greenIndex, GCOMP, 0.0F, GLshort, SHORT_TO_FLOAT);
- PROCESS(blueIndex, BCOMP, 0.0F, GLshort, SHORT_TO_FLOAT);
- PROCESS(alphaIndex, ACOMP, 1.0F, GLshort, SHORT_TO_FLOAT);
+ PROCESS(redIndex, RCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, 32767, GLshort, SHORT_TO_FLOAT);
break;
case GL_UNSIGNED_INT:
- PROCESS(redIndex, RCOMP, 0.0F, GLuint, UINT_TO_FLOAT);
- PROCESS(greenIndex, GCOMP, 0.0F, GLuint, UINT_TO_FLOAT);
- PROCESS(blueIndex, BCOMP, 0.0F, GLuint, UINT_TO_FLOAT);
- PROCESS(alphaIndex, ACOMP, 1.0F, GLuint, UINT_TO_FLOAT);
+ PROCESS(redIndex, RCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, 0xffffffff, GLuint, UINT_TO_FLOAT);
break;
case GL_INT:
- PROCESS(redIndex, RCOMP, 0.0F, GLint, INT_TO_FLOAT);
- PROCESS(greenIndex, GCOMP, 0.0F, GLint, INT_TO_FLOAT);
- PROCESS(blueIndex, BCOMP, 0.0F, GLint, INT_TO_FLOAT);
- PROCESS(alphaIndex, ACOMP, 1.0F, GLint, INT_TO_FLOAT);
+ PROCESS(redIndex, RCOMP, 0.0F, 0, GLint, INT_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, 0, GLint, INT_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, 0, GLint, INT_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, 2147483647, GLint, INT_TO_FLOAT);
break;
case GL_FLOAT:
- PROCESS(redIndex, RCOMP, 0.0F, GLfloat, (GLfloat));
- PROCESS(greenIndex, GCOMP, 0.0F, GLfloat, (GLfloat));
- PROCESS(blueIndex, BCOMP, 0.0F, GLfloat, (GLfloat));
- PROCESS(alphaIndex, ACOMP, 1.0F, GLfloat, (GLfloat));
+ PROCESS(redIndex, RCOMP, 0.0F, 0.0F, GLfloat, (GLfloat));
+ PROCESS(greenIndex, GCOMP, 0.0F, 0.0F, GLfloat, (GLfloat));
+ PROCESS(blueIndex, BCOMP, 0.0F, 0.0F, GLfloat, (GLfloat));
+ PROCESS(alphaIndex, ACOMP, 1.0F, 1.0F, GLfloat, (GLfloat));
break;
case GL_HALF_FLOAT_ARB:
- PROCESS(redIndex, RCOMP, 0.0F, GLhalfARB, _mesa_half_to_float);
- PROCESS(greenIndex, GCOMP, 0.0F, GLhalfARB, _mesa_half_to_float);
- PROCESS(blueIndex, BCOMP, 0.0F, GLhalfARB, _mesa_half_to_float);
- PROCESS(alphaIndex, ACOMP, 1.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(redIndex, RCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(greenIndex, GCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(blueIndex, BCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(alphaIndex, ACOMP, 1.0F, 1.0F, GLhalfARB, _mesa_half_to_float);
break;
case GL_UNSIGNED_BYTE_3_3_2:
{
const GLubyte *ubsrc = (const GLubyte *) src;
GLuint i;
+ if (!intFormat) {
+ rs = 1.0F / 7.0F;
+ gs = 1.0F / 7.0F;
+ bs = 1.0F / 3.0F;
+ }
for (i = 0; i < n; i ++) {
GLubyte p = ubsrc[i];
- rgba[i][rComp] = ((p >> 5) ) * (1.0F / 7.0F);
- rgba[i][gComp] = ((p >> 2) & 0x7) * (1.0F / 7.0F);
- rgba[i][bComp] = ((p ) & 0x3) * (1.0F / 3.0F);
+ rgba[i][rComp] = ((p >> 5) ) * rs;
+ rgba[i][gComp] = ((p >> 2) & 0x7) * gs;
+ rgba[i][bComp] = ((p ) & 0x3) * bs;
rgba[i][aComp] = 1.0F;
}
}
@@ -3516,25 +3614,35 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
{
const GLubyte *ubsrc = (const GLubyte *) src;
GLuint i;
+ if (!intFormat) {
+ rs = 1.0F / 7.0F;
+ gs = 1.0F / 7.0F;
+ bs = 1.0F / 3.0F;
+ }
for (i = 0; i < n; i ++) {
GLubyte p = ubsrc[i];
- rgba[i][rComp] = ((p ) & 0x7) * (1.0F / 7.0F);
- rgba[i][gComp] = ((p >> 3) & 0x7) * (1.0F / 7.0F);
- rgba[i][bComp] = ((p >> 6) ) * (1.0F / 3.0F);
+ rgba[i][rComp] = ((p ) & 0x7) * rs;
+ rgba[i][gComp] = ((p >> 3) & 0x7) * gs;
+ rgba[i][bComp] = ((p >> 6) ) * bs;
rgba[i][aComp] = 1.0F;
}
}
break;
case GL_UNSIGNED_SHORT_5_6_5:
+ if (!intFormat) {
+ rs = 1.0F / 31.0F;
+ gs = 1.0F / 63.0F;
+ bs = 1.0F / 31.0F;
+ }
if (swapBytes) {
const GLushort *ussrc = (const GLushort *) src;
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
SWAP2BYTE(p);
- rgba[i][rComp] = ((p >> 11) ) * (1.0F / 31.0F);
- rgba[i][gComp] = ((p >> 5) & 0x3f) * (1.0F / 63.0F);
- rgba[i][bComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][rComp] = ((p >> 11) ) * rs;
+ rgba[i][gComp] = ((p >> 5) & 0x3f) * gs;
+ rgba[i][bComp] = ((p ) & 0x1f) * bs;
rgba[i][aComp] = 1.0F;
}
}
@@ -3543,23 +3651,28 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
- rgba[i][rComp] = ((p >> 11) ) * (1.0F / 31.0F);
- rgba[i][gComp] = ((p >> 5) & 0x3f) * (1.0F / 63.0F);
- rgba[i][bComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][rComp] = ((p >> 11) ) * rs;
+ rgba[i][gComp] = ((p >> 5) & 0x3f) * gs;
+ rgba[i][bComp] = ((p ) & 0x1f) * bs;
rgba[i][aComp] = 1.0F;
}
}
break;
case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (!intFormat) {
+ rs = 1.0F / 31.0F;
+ gs = 1.0F / 63.0F;
+ bs = 1.0F / 31.0F;
+ }
if (swapBytes) {
const GLushort *ussrc = (const GLushort *) src;
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
SWAP2BYTE(p);
- rgba[i][rComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
- rgba[i][gComp] = ((p >> 5) & 0x3f) * (1.0F / 63.0F);
- rgba[i][bComp] = ((p >> 11) ) * (1.0F / 31.0F);
+ rgba[i][rComp] = ((p ) & 0x1f) * rs;
+ rgba[i][gComp] = ((p >> 5) & 0x3f) * gs;
+ rgba[i][bComp] = ((p >> 11) ) * bs;
rgba[i][aComp] = 1.0F;
}
}
@@ -3568,24 +3681,27 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
- rgba[i][rComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
- rgba[i][gComp] = ((p >> 5) & 0x3f) * (1.0F / 63.0F);
- rgba[i][bComp] = ((p >> 11) ) * (1.0F / 31.0F);
+ rgba[i][rComp] = ((p ) & 0x1f) * rs;
+ rgba[i][gComp] = ((p >> 5) & 0x3f) * gs;
+ rgba[i][bComp] = ((p >> 11) ) * bs;
rgba[i][aComp] = 1.0F;
}
}
break;
case GL_UNSIGNED_SHORT_4_4_4_4:
+ if (!intFormat) {
+ rs = gs = bs = as = 1.0F / 15.0F;
+ }
if (swapBytes) {
const GLushort *ussrc = (const GLushort *) src;
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
SWAP2BYTE(p);
- rgba[i][rComp] = ((p >> 12) ) * (1.0F / 15.0F);
- rgba[i][gComp] = ((p >> 8) & 0xf) * (1.0F / 15.0F);
- rgba[i][bComp] = ((p >> 4) & 0xf) * (1.0F / 15.0F);
- rgba[i][aComp] = ((p ) & 0xf) * (1.0F / 15.0F);
+ rgba[i][rComp] = ((p >> 12) ) * rs;
+ rgba[i][gComp] = ((p >> 8) & 0xf) * gs;
+ rgba[i][bComp] = ((p >> 4) & 0xf) * bs;
+ rgba[i][aComp] = ((p ) & 0xf) * as;
}
}
else {
@@ -3593,24 +3709,27 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
- rgba[i][rComp] = ((p >> 12) ) * (1.0F / 15.0F);
- rgba[i][gComp] = ((p >> 8) & 0xf) * (1.0F / 15.0F);
- rgba[i][bComp] = ((p >> 4) & 0xf) * (1.0F / 15.0F);
- rgba[i][aComp] = ((p ) & 0xf) * (1.0F / 15.0F);
+ rgba[i][rComp] = ((p >> 12) ) * rs;
+ rgba[i][gComp] = ((p >> 8) & 0xf) * gs;
+ rgba[i][bComp] = ((p >> 4) & 0xf) * bs;
+ rgba[i][aComp] = ((p ) & 0xf) * as;
}
}
break;
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ if (!intFormat) {
+ rs = gs = bs = as = 1.0F / 15.0F;
+ }
if (swapBytes) {
const GLushort *ussrc = (const GLushort *) src;
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
SWAP2BYTE(p);
- rgba[i][rComp] = ((p ) & 0xf) * (1.0F / 15.0F);
- rgba[i][gComp] = ((p >> 4) & 0xf) * (1.0F / 15.0F);
- rgba[i][bComp] = ((p >> 8) & 0xf) * (1.0F / 15.0F);
- rgba[i][aComp] = ((p >> 12) ) * (1.0F / 15.0F);
+ rgba[i][rComp] = ((p ) & 0xf) * rs;
+ rgba[i][gComp] = ((p >> 4) & 0xf) * gs;
+ rgba[i][bComp] = ((p >> 8) & 0xf) * bs;
+ rgba[i][aComp] = ((p >> 12) ) * as;
}
}
else {
@@ -3618,24 +3737,27 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
- rgba[i][rComp] = ((p ) & 0xf) * (1.0F / 15.0F);
- rgba[i][gComp] = ((p >> 4) & 0xf) * (1.0F / 15.0F);
- rgba[i][bComp] = ((p >> 8) & 0xf) * (1.0F / 15.0F);
- rgba[i][aComp] = ((p >> 12) ) * (1.0F / 15.0F);
+ rgba[i][rComp] = ((p ) & 0xf) * rs;
+ rgba[i][gComp] = ((p >> 4) & 0xf) * gs;
+ rgba[i][bComp] = ((p >> 8) & 0xf) * bs;
+ rgba[i][aComp] = ((p >> 12) ) * as;
}
}
break;
case GL_UNSIGNED_SHORT_5_5_5_1:
+ if (!intFormat) {
+ rs = gs = bs = 1.0F / 31.0F;
+ }
if (swapBytes) {
const GLushort *ussrc = (const GLushort *) src;
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
SWAP2BYTE(p);
- rgba[i][rComp] = ((p >> 11) ) * (1.0F / 31.0F);
- rgba[i][gComp] = ((p >> 6) & 0x1f) * (1.0F / 31.0F);
- rgba[i][bComp] = ((p >> 1) & 0x1f) * (1.0F / 31.0F);
- rgba[i][aComp] = ((p ) & 0x1) * (1.0F / 1.0F);
+ rgba[i][rComp] = ((p >> 11) ) * rs;
+ rgba[i][gComp] = ((p >> 6) & 0x1f) * gs;
+ rgba[i][bComp] = ((p >> 1) & 0x1f) * bs;
+ rgba[i][aComp] = ((p ) & 0x1) * as;
}
}
else {
@@ -3643,24 +3765,27 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
- rgba[i][rComp] = ((p >> 11) ) * (1.0F / 31.0F);
- rgba[i][gComp] = ((p >> 6) & 0x1f) * (1.0F / 31.0F);
- rgba[i][bComp] = ((p >> 1) & 0x1f) * (1.0F / 31.0F);
- rgba[i][aComp] = ((p ) & 0x1) * (1.0F / 1.0F);
+ rgba[i][rComp] = ((p >> 11) ) * rs;
+ rgba[i][gComp] = ((p >> 6) & 0x1f) * gs;
+ rgba[i][bComp] = ((p >> 1) & 0x1f) * bs;
+ rgba[i][aComp] = ((p ) & 0x1) * as;
}
}
break;
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if (!intFormat) {
+ rs = gs = bs = 1.0F / 31.0F;
+ }
if (swapBytes) {
const GLushort *ussrc = (const GLushort *) src;
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
SWAP2BYTE(p);
- rgba[i][rComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
- rgba[i][gComp] = ((p >> 5) & 0x1f) * (1.0F / 31.0F);
- rgba[i][bComp] = ((p >> 10) & 0x1f) * (1.0F / 31.0F);
- rgba[i][aComp] = ((p >> 15) ) * (1.0F / 1.0F);
+ rgba[i][rComp] = ((p ) & 0x1f) * rs;
+ rgba[i][gComp] = ((p >> 5) & 0x1f) * gs;
+ rgba[i][bComp] = ((p >> 10) & 0x1f) * bs;
+ rgba[i][aComp] = ((p >> 15) ) * as;
}
}
else {
@@ -3668,10 +3793,10 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
GLuint i;
for (i = 0; i < n; i ++) {
GLushort p = ussrc[i];
- rgba[i][rComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
- rgba[i][gComp] = ((p >> 5) & 0x1f) * (1.0F / 31.0F);
- rgba[i][bComp] = ((p >> 10) & 0x1f) * (1.0F / 31.0F);
- rgba[i][aComp] = ((p >> 15) ) * (1.0F / 1.0F);
+ rgba[i][rComp] = ((p ) & 0x1f) * rs;
+ rgba[i][gComp] = ((p >> 5) & 0x1f) * gs;
+ rgba[i][bComp] = ((p >> 10) & 0x1f) * bs;
+ rgba[i][aComp] = ((p >> 15) ) * as;
}
}
break;
@@ -3679,23 +3804,45 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
if (swapBytes) {
const GLuint *uisrc = (const GLuint *) src;
GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff);
- rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
- rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
- rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) );
+ if (intFormat) {
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = (GLfloat) ((p ) & 0xff);
+ rgba[i][gComp] = (GLfloat) ((p >> 8) & 0xff);
+ rgba[i][bComp] = (GLfloat) ((p >> 16) & 0xff);
+ rgba[i][aComp] = (GLfloat) ((p >> 24) );
+ }
+ }
+ else {
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
+ rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
+ rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) );
+ }
}
}
else {
const GLuint *uisrc = (const GLuint *) src;
GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) );
- rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
- rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
- rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ if (intFormat) {
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = (GLfloat) ((p >> 24) );
+ rgba[i][gComp] = (GLfloat) ((p >> 16) & 0xff);
+ rgba[i][bComp] = (GLfloat) ((p >> 8) & 0xff);
+ rgba[i][aComp] = (GLfloat) ((p ) & 0xff);
+ }
+ }
+ else {
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) );
+ rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
+ rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
+ rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ }
}
}
break;
@@ -3703,37 +3850,65 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
if (swapBytes) {
const GLuint *uisrc = (const GLuint *) src;
GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) );
- rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
- rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
- rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ if (intFormat) {
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = (GLfloat) ((p >> 24) );
+ rgba[i][gComp] = (GLfloat) ((p >> 16) & 0xff);
+ rgba[i][bComp] = (GLfloat) ((p >> 8) & 0xff);
+ rgba[i][aComp] = (GLfloat) ((p ) & 0xff);
+ }
+ }
+ else {
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) );
+ rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
+ rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
+ rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ }
}
}
else {
const GLuint *uisrc = (const GLuint *) src;
GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff);
- rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
- rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
- rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) );
+ if (intFormat) {
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = (GLfloat) ((p ) & 0xff);
+ rgba[i][gComp] = (GLfloat) ((p >> 8) & 0xff);
+ rgba[i][bComp] = (GLfloat) ((p >> 16) & 0xff);
+ rgba[i][aComp] = (GLfloat) ((p >> 24) );
+ }
+ }
+ else {
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
+ rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
+ rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) );
+ }
}
}
break;
case GL_UNSIGNED_INT_10_10_10_2:
+ if (!intFormat) {
+ rs = 1.0F / 1023.0F;
+ gs = 1.0F / 1023.0F;
+ bs = 1.0F / 1023.0F;
+ as = 1.0F / 3.0F;
+ }
if (swapBytes) {
const GLuint *uisrc = (const GLuint *) src;
GLuint i;
for (i = 0; i < n; i ++) {
GLuint p = uisrc[i];
SWAP4BYTE(p);
- rgba[i][rComp] = ((p >> 22) ) * (1.0F / 1023.0F);
- rgba[i][gComp] = ((p >> 12) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][bComp] = ((p >> 2) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][aComp] = ((p ) & 0x3 ) * (1.0F / 3.0F);
+ rgba[i][rComp] = ((p >> 22) ) * rs;
+ rgba[i][gComp] = ((p >> 12) & 0x3ff) * gs;
+ rgba[i][bComp] = ((p >> 2) & 0x3ff) * bs;
+ rgba[i][aComp] = ((p ) & 0x3 ) * as;
}
}
else {
@@ -3741,24 +3916,30 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
GLuint i;
for (i = 0; i < n; i ++) {
GLuint p = uisrc[i];
- rgba[i][rComp] = ((p >> 22) ) * (1.0F / 1023.0F);
- rgba[i][gComp] = ((p >> 12) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][bComp] = ((p >> 2) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][aComp] = ((p ) & 0x3 ) * (1.0F / 3.0F);
+ rgba[i][rComp] = ((p >> 22) ) * rs;
+ rgba[i][gComp] = ((p >> 12) & 0x3ff) * gs;
+ rgba[i][bComp] = ((p >> 2) & 0x3ff) * bs;
+ rgba[i][aComp] = ((p ) & 0x3 ) * as;
}
}
break;
case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (!intFormat) {
+ rs = 1.0F / 1023.0F;
+ gs = 1.0F / 1023.0F;
+ bs = 1.0F / 1023.0F;
+ as = 1.0F / 3.0F;
+ }
if (swapBytes) {
const GLuint *uisrc = (const GLuint *) src;
GLuint i;
for (i = 0; i < n; i ++) {
GLuint p = uisrc[i];
SWAP4BYTE(p);
- rgba[i][rComp] = ((p ) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][gComp] = ((p >> 10) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][bComp] = ((p >> 20) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][aComp] = ((p >> 30) ) * (1.0F / 3.0F);
+ rgba[i][rComp] = ((p ) & 0x3ff) * rs;
+ rgba[i][gComp] = ((p >> 10) & 0x3ff) * gs;
+ rgba[i][bComp] = ((p >> 20) & 0x3ff) * bs;
+ rgba[i][aComp] = ((p >> 30) ) * as;
}
}
else {
@@ -3766,10 +3947,10 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
GLuint i;
for (i = 0; i < n; i ++) {
GLuint p = uisrc[i];
- rgba[i][rComp] = ((p ) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][gComp] = ((p >> 10) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][bComp] = ((p >> 20) & 0x3ff) * (1.0F / 1023.0F);
- rgba[i][aComp] = ((p >> 30) ) * (1.0F / 3.0F);
+ rgba[i][rComp] = ((p ) & 0x3ff) * rs;
+ rgba[i][gComp] = ((p >> 10) & 0x3ff) * gs;
+ rgba[i][bComp] = ((p >> 20) & 0x3ff) * bs;
+ rgba[i][aComp] = ((p >> 30) ) * as;
}
}
break;
@@ -4161,6 +4342,16 @@ _mesa_unpack_color_span_float( GLcontext *ctx,
srcFormat == GL_RGBA ||
srcFormat == GL_BGRA ||
srcFormat == GL_ABGR_EXT ||
+ srcFormat == GL_RED_INTEGER_EXT ||
+ srcFormat == GL_GREEN_INTEGER_EXT ||
+ srcFormat == GL_BLUE_INTEGER_EXT ||
+ srcFormat == GL_ALPHA_INTEGER_EXT ||
+ srcFormat == GL_RGB_INTEGER_EXT ||
+ srcFormat == GL_RGBA_INTEGER_EXT ||
+ srcFormat == GL_BGR_INTEGER_EXT ||
+ srcFormat == GL_BGRA_INTEGER_EXT ||
+ srcFormat == GL_LUMINANCE_INTEGER_EXT ||
+ srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT ||
srcFormat == GL_COLOR_INDEX);
ASSERT(srcType == GL_BITMAP ||
diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index 48582eb3bbe..8b180d6bfe6 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -79,6 +79,9 @@ extern GLboolean
_mesa_is_dudv_format(GLenum format);
extern GLboolean
+_mesa_is_integer_format(GLenum format);
+
+extern GLboolean
_mesa_is_compressed_format(GLcontext *ctx, GLenum format);
extern GLvoid *
diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c
index 24d29137b0c..fe002082cca 100644
--- a/src/mesa/main/texfetch.c
+++ b/src/mesa/main/texfetch.c
@@ -552,6 +552,54 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
fetch_texel_3d_f_intensity_f16,
store_texel_intensity_f16
},
+
+ /* non-normalized, signed int */
+ {
+ MESA_FORMAT_RGBA_INT8,
+ fetch_texel_1d_rgba_int8,
+ fetch_texel_2d_rgba_int8,
+ fetch_texel_3d_rgba_int8,
+ store_texel_rgba_int8
+ },
+ {
+ MESA_FORMAT_RGBA_INT16,
+ fetch_texel_1d_rgba_int16,
+ fetch_texel_2d_rgba_int16,
+ fetch_texel_3d_rgba_int16,
+ store_texel_rgba_int16
+ },
+ {
+ MESA_FORMAT_RGBA_INT32,
+ fetch_texel_1d_rgba_int32,
+ fetch_texel_2d_rgba_int32,
+ fetch_texel_3d_rgba_int32,
+ store_texel_rgba_int32
+ },
+
+ /* non-normalized, unsigned int */
+ {
+ MESA_FORMAT_RGBA_UINT8,
+ fetch_texel_1d_rgba_uint8,
+ fetch_texel_2d_rgba_uint8,
+ fetch_texel_3d_rgba_uint8,
+ store_texel_rgba_uint8
+ },
+ {
+ MESA_FORMAT_RGBA_UINT16,
+ fetch_texel_1d_rgba_uint16,
+ fetch_texel_2d_rgba_uint16,
+ fetch_texel_3d_rgba_uint16,
+ store_texel_rgba_uint16
+ },
+ {
+ MESA_FORMAT_RGBA_UINT32,
+ fetch_texel_1d_rgba_uint32,
+ fetch_texel_2d_rgba_uint32,
+ fetch_texel_3d_rgba_uint32,
+ store_texel_rgba_uint32
+ },
+
+ /* dudv */
{
MESA_FORMAT_DUDV8,
fetch_texel_1d_dudv8,
@@ -559,6 +607,8 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
fetch_texel_3d_dudv8,
NULL
},
+
+ /* signed, normalized */
{
MESA_FORMAT_SIGNED_R8,
fetch_texel_1d_signed_r8,
diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h
index e51fe3a5773..f943554370f 100644
--- a/src/mesa/main/texfetch_tmp.h
+++ b/src/mesa/main/texfetch_tmp.h
@@ -1195,6 +1195,174 @@ static void store_texel_sla8(struct gl_texture_image *texImage,
#endif
+/* MESA_FORMAT_RGBA_INT8 **************************************************/
+
+static void
+FETCH(rgba_int8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_int8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_INT16 **************************************************/
+
+static void
+FETCH(rgba_int16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_int16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_INT32 **************************************************/
+
+static void
+FETCH(rgba_int32)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_int32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLint *rgba = (const GLint *) texel;
+ GLint *dst = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_UINT8 **************************************************/
+
+static void
+FETCH(rgba_uint8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_uint8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_UINT16 **************************************************/
+
+static void
+FETCH(rgba_uint16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_uint16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLushort *rgba = (const GLushort *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_UINT32 **************************************************/
+
+static void
+FETCH(rgba_uint32)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_uint32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLuint *rgba = (const GLuint *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
/* MESA_FORMAT_DUDV8 ********************************************************/
/* this format by definition produces 0,0,0,1 as rgba values,
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index d235485721a..b9271ef58ef 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -382,6 +382,53 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
}
#endif /* FEATURE_EXT_texture_sRGB */
+ if (ctx->Extensions.EXT_texture_integer) {
+ switch (internalFormat) {
+ case GL_RGBA32UI_EXT:
+ case GL_RGB32UI_EXT:
+ case GL_ALPHA32UI_EXT:
+ case GL_INTENSITY32UI_EXT:
+ case GL_LUMINANCE32UI_EXT:
+ case GL_LUMINANCE_ALPHA32UI_EXT:
+ return MESA_FORMAT_RGBA_UINT32;
+ case GL_RGBA16UI_EXT:
+ case GL_RGB16UI_EXT:
+ case GL_ALPHA16UI_EXT:
+ case GL_INTENSITY16UI_EXT:
+ case GL_LUMINANCE16UI_EXT:
+ case GL_LUMINANCE_ALPHA16UI_EXT:
+ return MESA_FORMAT_RGBA_UINT16;
+ case GL_RGBA8UI_EXT:
+ case GL_RGB8UI_EXT:
+ case GL_ALPHA8UI_EXT:
+ case GL_INTENSITY8UI_EXT:
+ case GL_LUMINANCE8UI_EXT:
+ case GL_LUMINANCE_ALPHA8UI_EXT:
+ return MESA_FORMAT_RGBA_UINT8;
+ case GL_RGBA32I_EXT:
+ case GL_RGB32I_EXT:
+ case GL_ALPHA32I_EXT:
+ case GL_INTENSITY32I_EXT:
+ case GL_LUMINANCE32I_EXT:
+ case GL_LUMINANCE_ALPHA32I_EXT:
+ return MESA_FORMAT_RGBA_INT32;
+ case GL_RGBA16I_EXT:
+ case GL_RGB16I_EXT:
+ case GL_ALPHA16I_EXT:
+ case GL_INTENSITY16I_EXT:
+ case GL_LUMINANCE16I_EXT:
+ case GL_LUMINANCE_ALPHA16I_EXT:
+ return MESA_FORMAT_RGBA_INT16;
+ case GL_RGBA8I_EXT:
+ case GL_RGB8I_EXT:
+ case GL_ALPHA8I_EXT:
+ case GL_INTENSITY8I_EXT:
+ case GL_LUMINANCE8I_EXT:
+ case GL_LUMINANCE_ALPHA8I_EXT:
+ return MESA_FORMAT_RGBA_INT8;
+ }
+ }
+
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
return MESA_FORMAT_NONE;
}
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index ff752155ea9..f3073220104 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -348,12 +348,60 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
case GL_SLUMINANCE8_EXT:
return GL_LUMINANCE;
default:
- ; /* fallthrough */
+ ; /* fallthrough */
}
}
-
#endif /* FEATURE_EXT_texture_sRGB */
+ if (ctx->Extensions.EXT_texture_integer) {
+ switch (internalFormat) {
+ case GL_RGBA8UI_EXT:
+ case GL_RGBA16UI_EXT:
+ case GL_RGBA32UI_EXT:
+ case GL_RGBA8I_EXT:
+ case GL_RGBA16I_EXT:
+ case GL_RGBA32I_EXT:
+ return GL_RGBA;
+ case GL_RGB8UI_EXT:
+ case GL_RGB16UI_EXT:
+ case GL_RGB32UI_EXT:
+ case GL_RGB8I_EXT:
+ case GL_RGB16I_EXT:
+ case GL_RGB32I_EXT:
+ return GL_RGB;
+ case GL_ALPHA8UI_EXT:
+ case GL_ALPHA16UI_EXT:
+ case GL_ALPHA32UI_EXT:
+ case GL_ALPHA8I_EXT:
+ case GL_ALPHA16I_EXT:
+ case GL_ALPHA32I_EXT:
+ return GL_ALPHA;
+ case GL_INTENSITY8UI_EXT:
+ case GL_INTENSITY16UI_EXT:
+ case GL_INTENSITY32UI_EXT:
+ case GL_INTENSITY8I_EXT:
+ case GL_INTENSITY16I_EXT:
+ case GL_INTENSITY32I_EXT:
+ return GL_INTENSITY;
+ case GL_LUMINANCE8UI_EXT:
+ case GL_LUMINANCE16UI_EXT:
+ case GL_LUMINANCE32UI_EXT:
+ case GL_LUMINANCE8I_EXT:
+ case GL_LUMINANCE16I_EXT:
+ case GL_LUMINANCE32I_EXT:
+ return GL_LUMINANCE;
+ case GL_LUMINANCE_ALPHA8UI_EXT:
+ case GL_LUMINANCE_ALPHA16UI_EXT:
+ case GL_LUMINANCE_ALPHA32UI_EXT:
+ case GL_LUMINANCE_ALPHA8I_EXT:
+ case GL_LUMINANCE_ALPHA16I_EXT:
+ case GL_LUMINANCE_ALPHA32I_EXT:
+ return GL_LUMINANCE_ALPHA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
return -1; /* error */
}
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index ce05652c935..0f21395af39 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -3278,6 +3278,392 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
}
+/* non-normalized, signed int8 */
+static GLboolean
+_mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+ const GLint components = _mesa_components_in_format(baseFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_RGBA_INT8);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(texelBytes == components * sizeof(GLbyte));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_BYTE) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLbyte *dstTexel = (GLbyte *) dstRow;
+ GLint i;
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLbyte) src[i];
+ }
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ }
+
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/* non-normalized, signed int16 */
+static GLboolean
+_mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+ const GLint components = _mesa_components_in_format(baseFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_RGBA_INT16);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(texelBytes == components * sizeof(GLshort));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_INT) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLshort *dstTexel = (GLshort *) dstRow;
+ GLint i;
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLint) src[i];
+ }
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ }
+
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/* non-normalized, signed int32 */
+static GLboolean
+_mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+ const GLint components = _mesa_components_in_format(baseFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_RGBA_INT32);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(texelBytes == components * sizeof(GLint));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_INT) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLint *dstTexel = (GLint *) dstRow;
+ GLint i;
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLint) src[i];
+ }
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ }
+
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/* non-normalized, unsigned int8 */
+static GLboolean
+_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+ const GLint components = _mesa_components_in_format(baseFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT8);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(texelBytes == components * sizeof(GLubyte));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_UNSIGNED_BYTE) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLubyte *dstTexel = (GLubyte *) dstRow;
+ GLint i;
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLubyte) src[i];
+ }
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ }
+
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/* non-normalized, unsigned int16 */
+static GLboolean
+_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+ const GLint components = _mesa_components_in_format(baseFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT16);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(texelBytes == components * sizeof(GLushort));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_UNSIGNED_SHORT) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstTexel = (GLushort *) dstRow;
+ GLint i;
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLushort) src[i];
+ }
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ }
+
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/* non-normalized, unsigned int32 */
+static GLboolean
+_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+ const GLint components = _mesa_components_in_format(baseFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT32);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(texelBytes == components * sizeof(GLuint));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_UNSIGNED_INT) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstTexel = (GLuint *) dstRow;
+ GLint i;
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLuint) src[i];
+ }
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ }
+
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+
+
#if FEATURE_EXT_texture_sRGB
static GLboolean
_mesa_texstore_srgb8(TEXSTORE_PARAMS)
@@ -3472,6 +3858,14 @@ texstore_funcs[MESA_FORMAT_COUNT] =
{ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 },
{ MESA_FORMAT_INTENSITY_FLOAT32, _mesa_texstore_rgba_float32 },
{ MESA_FORMAT_INTENSITY_FLOAT16, _mesa_texstore_rgba_float16 },
+
+ { MESA_FORMAT_RGBA_INT8, _mesa_texstore_rgba_int8 },
+ { MESA_FORMAT_RGBA_INT16, _mesa_texstore_rgba_int16 },
+ { MESA_FORMAT_RGBA_INT32, _mesa_texstore_rgba_int32 },
+ { MESA_FORMAT_RGBA_UINT8, _mesa_texstore_rgba_uint8 },
+ { MESA_FORMAT_RGBA_UINT16, _mesa_texstore_rgba_uint16 },
+ { MESA_FORMAT_RGBA_UINT32, _mesa_texstore_rgba_uint32 },
+
{ MESA_FORMAT_DUDV8, _mesa_texstore_dudv8 },
{ MESA_FORMAT_SIGNED_R8, _mesa_texstore_signed_r8 },