srcPacking);
const GLuint *src = tempImage;
GLint img, row;
+ GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
for (row = 0; row < srcHeight; row++) {
GLbyte *dstTexel = (GLbyte *) dstRow;
GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLbyte) src[i];
+ if (is_unsigned) {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLbyte) MIN2(src[i], 0x7f);
+ }
+ } else {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLbyte) CLAMP((GLint) src[i], -0x80, 0x7f);
+ }
}
dstRow += dstRowStride;
src += srcWidth * components;
srcPacking);
const GLuint *src = tempImage;
GLint img, row;
+ GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
for (row = 0; row < srcHeight; row++) {
GLshort *dstTexel = (GLshort *) dstRow;
GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLint) src[i];
+ if (is_unsigned) {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLshort) MIN2(src[i], 0x7fff);
+ }
+ } else {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLshort)CLAMP((GLint) src[i], -0x8000, 0x7fff);
+ }
}
dstRow += dstRowStride;
src += srcWidth * components;
srcPacking);
const GLuint *src = tempImage;
GLint img, row;
+ GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
for (row = 0; row < srcHeight; row++) {
GLint *dstTexel = (GLint *) dstRow;
GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLint) src[i];
+ if (is_unsigned) {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLint) MIN2(src[i], 0x7fffffff);
+ }
+ } else {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLint) src[i];
+ }
}
dstRow += dstRowStride;
src += srcWidth * components;
srcFormat, srcType, srcAddr, srcPacking);
const GLuint *src = tempImage;
GLint img, row;
+ GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
for (row = 0; row < srcHeight; row++) {
GLubyte *dstTexel = (GLubyte *) dstRow;
GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLubyte) CLAMP(src[i], 0, 0xff);
+ if (is_unsigned) {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLubyte) MIN2(src[i], 0xff);
+ }
+ } else {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLubyte) CLAMP((GLint) src[i], 0, 0xff);
+ }
}
dstRow += dstRowStride;
src += srcWidth * components;
srcFormat, srcType, srcAddr, srcPacking);
const GLuint *src = tempImage;
GLint img, row;
+ GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
for (row = 0; row < srcHeight; row++) {
GLushort *dstTexel = (GLushort *) dstRow;
GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLushort) CLAMP(src[i], 0, 0xffff);
+ if (is_unsigned) {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLushort) MIN2(src[i], 0xffff);
+ }
+ } else {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = (GLushort) CLAMP((GLint) src[i], 0, 0xffff);
+ }
}
dstRow += dstRowStride;
src += srcWidth * components;
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr, srcPacking);
const GLuint *src = tempImage;
+ GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
GLint img, row;
if (!tempImage)
return GL_FALSE;
for (row = 0; row < srcHeight; row++) {
GLuint *dstTexel = (GLuint *) dstRow;
GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = src[i];
+ if (is_unsigned) {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = src[i];
+ }
+ } else {
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = MAX2((GLint) src[i], 0);
+ }
}
dstRow += dstRowStride;
src += srcWidth * components;
srcPacking);
const GLuint *src = tempImage;
GLint img, row, col;
+ GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort a,r,g,b;
- r = src[RCOMP];
- g = src[GCOMP];
- b = src[BCOMP];
- a = src[ACOMP];
- dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b);
- src += 4;
+ if (is_unsigned) {
+ for (col = 0; col < srcWidth; col++) {
+ GLushort a,r,g,b;
+ r = MIN2(src[RCOMP], 0x3ff);
+ g = MIN2(src[GCOMP], 0x3ff);
+ b = MIN2(src[BCOMP], 0x3ff);
+ a = MIN2(src[ACOMP], 0x003);
+ dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b);
+ src += 4;
+ }
+ } else {
+ for (col = 0; col < srcWidth; col++) {
+ GLushort a,r,g,b;
+ r = CLAMP((GLint) src[RCOMP], 0, 0x3ff);
+ g = CLAMP((GLint) src[GCOMP], 0, 0x3ff);
+ b = CLAMP((GLint) src[BCOMP], 0, 0x3ff);
+ a = CLAMP((GLint) src[ACOMP], 0, 0x003);
+ dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b);
+ src += 4;
+ }
}
dstRow += dstRowStride;
}