- keepdepth = GL_TRUE;
- }
-
- if (keepdepth == GL_FALSE)
- /* the 24 depth bits will be in the low position: */
- _mesa_unpack_depth_span(ctx, srcWidth,
- GL_UNSIGNED_INT, /* dst type */
- keepstencil ? depth : dstRow, /* dst addr */
- depthScale,
- srcType, src, srcPacking);
-
- if (keepstencil == GL_FALSE)
- /* get the 8-bit stencil values */
- _mesa_unpack_stencil_span(ctx, srcWidth,
- GL_UNSIGNED_BYTE, /* dst type */
- stencil, /* dst addr */
- srcType, src, srcPacking,
- ctx->_ImageTransferState);
-
- /* merge stencil values into depth values */
- for (i = 0; i < srcWidth; i++) {
- if (keepstencil)
- dstRow[i] = depth[i] | (dstRow[i] & 0xFF000000);
- else
- dstRow[i] = (dstRow[i] & 0xFFFFFF) | (stencil[i] << 24);
-
- }
- src += srcRowStride;
- dstRow += dstRowStride / sizeof(GLuint);
- }
- }
-
- free(depth);
- free(stencil);
-
- return GL_TRUE;
-}
-
-
-/**
- * Store simple 8-bit/value stencil texture data.
- */
-static GLboolean
-_mesa_texstore_s8(TEXSTORE_PARAMS)
-{
- ASSERT(dstFormat == MESA_FORMAT_S8);
- ASSERT(srcFormat == GL_STENCIL_INDEX);
-
- {
- const GLint srcRowStride
- = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLint img, row;
- GLubyte *stencil = malloc(srcWidth * sizeof(GLubyte));
-
- if (!stencil)
- return GL_FALSE;
-
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- const GLubyte *src
- = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
- srcWidth, srcHeight,
- srcFormat, srcType,
- img, 0, 0);
- for (row = 0; row < srcHeight; row++) {
- GLint i;
-
- /* get the 8-bit stencil values */
- _mesa_unpack_stencil_span(ctx, srcWidth,
- GL_UNSIGNED_BYTE, /* dst type */
- stencil, /* dst addr */
- srcType, src, srcPacking,
- ctx->_ImageTransferState);
- /* merge stencil values into depth values */
- for (i = 0; i < srcWidth; i++)
- dstRow[i] = stencil[i];
-
- src += srcRowStride;
- dstRow += dstRowStride / sizeof(GLubyte);
- }
- }
-
- free(stencil);
- }
-
- return GL_TRUE;
-}
-
-
-/**
- * Store an image in any of the formats:
- * _mesa_texformat_rgba_float32
- * _mesa_texformat_rgb_float32
- * _mesa_texformat_alpha_float32
- * _mesa_texformat_luminance_float32
- * _mesa_texformat_luminance_alpha_float32
- * _mesa_texformat_intensity_float32
- */
-static GLboolean
-_mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in _mesa_make_temp_float_image */
- if (dstFormat == MESA_FORMAT_XBGR32323232_FLOAT) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 ||
- dstFormat == MESA_FORMAT_RGB_FLOAT32 ||
- dstFormat == MESA_FORMAT_ALPHA_FLOAT32 ||
- dstFormat == MESA_FORMAT_LUMINANCE_FLOAT32 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 ||
- dstFormat == MESA_FORMAT_INTENSITY_FLOAT32 ||
- dstFormat == MESA_FORMAT_R_FLOAT32 ||
- dstFormat == MESA_FORMAT_RG_FLOAT32 ||
- dstFormat == MESA_FORMAT_XBGR32323232_FLOAT);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_RG);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLfloat));
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint bytesPerRow;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- bytesPerRow = srcWidth * components * sizeof(GLfloat);
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- memcpy(dstRow, srcRow, bytesPerRow);
- dstRow += dstRowStride;
- srcRow += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-
-/**
- * As above, but store 16-bit floats.
- */
-static GLboolean
-_mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in _mesa_make_temp_float_image */
- if (dstFormat == MESA_FORMAT_XBGR16161616_FLOAT) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 ||
- dstFormat == MESA_FORMAT_RGB_FLOAT16 ||
- dstFormat == MESA_FORMAT_ALPHA_FLOAT16 ||
- dstFormat == MESA_FORMAT_LUMINANCE_FLOAT16 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 ||
- dstFormat == MESA_FORMAT_INTENSITY_FLOAT16 ||
- dstFormat == MESA_FORMAT_R_FLOAT16 ||
- dstFormat == MESA_FORMAT_RG_FLOAT16 ||
- dstFormat == MESA_FORMAT_XBGR16161616_FLOAT);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_RG);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLhalfARB));
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLhalfARB *dstTexel = (GLhalfARB *) dstRow;
- GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = _mesa_float_to_half(src[i]);
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, signed int8 */
-static GLboolean
-_mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_XBGR8888_SINT) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_INT8 ||
- dstFormat == MESA_FORMAT_RG_INT8 ||
- dstFormat == MESA_FORMAT_RGB_INT8 ||
- dstFormat == MESA_FORMAT_RGBA_INT8 ||
- dstFormat == MESA_FORMAT_ALPHA_INT8 ||
- dstFormat == MESA_FORMAT_INTENSITY_INT8 ||
- dstFormat == MESA_FORMAT_LUMINANCE_INT8 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT8 ||
- dstFormat == MESA_FORMAT_XBGR8888_SINT);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLbyte));
-
- {
- /* general path */
- const GLuint *tempImage = make_temp_uint_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- 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++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLbyte *dstTexel = (GLbyte *) dstRow;
- GLint 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;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, signed int16 */
-static GLboolean
-_mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_XBGR16161616_SINT) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_INT16 ||
- dstFormat == MESA_FORMAT_RG_INT16 ||
- dstFormat == MESA_FORMAT_RGB_INT16 ||
- dstFormat == MESA_FORMAT_RGBA_INT16 ||
- dstFormat == MESA_FORMAT_ALPHA_INT16 ||
- dstFormat == MESA_FORMAT_LUMINANCE_INT16 ||
- dstFormat == MESA_FORMAT_INTENSITY_INT16 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT16 ||
- dstFormat == MESA_FORMAT_XBGR16161616_SINT);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLshort));
-
- {
- /* general path */
- const GLuint *tempImage = make_temp_uint_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- 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++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLshort *dstTexel = (GLshort *) dstRow;
- GLint 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;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, signed int32 */
-static GLboolean
-_mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_XBGR32323232_SINT) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_INT32 ||
- dstFormat == MESA_FORMAT_RG_INT32 ||
- dstFormat == MESA_FORMAT_RGB_INT32 ||
- dstFormat == MESA_FORMAT_RGBA_INT32 ||
- dstFormat == MESA_FORMAT_ALPHA_INT32 ||
- dstFormat == MESA_FORMAT_INTENSITY_INT32 ||
- dstFormat == MESA_FORMAT_LUMINANCE_INT32 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT32 ||
- dstFormat == MESA_FORMAT_XBGR32323232_SINT);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLint));
-
- {
- /* general path */
- const GLuint *tempImage = make_temp_uint_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- 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++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLint *dstTexel = (GLint *) dstRow;
- GLint 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;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, unsigned int8 */
-static GLboolean
-_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_XBGR8888_UINT) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_UINT8 ||
- dstFormat == MESA_FORMAT_RG_UINT8 ||
- dstFormat == MESA_FORMAT_RGB_UINT8 ||
- dstFormat == MESA_FORMAT_RGBA_UINT8 ||
- dstFormat == MESA_FORMAT_ALPHA_UINT8 ||
- dstFormat == MESA_FORMAT_INTENSITY_UINT8 ||
- dstFormat == MESA_FORMAT_LUMINANCE_UINT8 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT8 ||
- dstFormat == MESA_FORMAT_XBGR8888_UINT);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLubyte));
-
- {
- /* general path */
- const GLuint *tempImage =
- make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat,
- srcWidth, srcHeight, srcDepth,
- 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++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLubyte *dstTexel = (GLubyte *) dstRow;
- GLint i;
- 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;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, unsigned int16 */
-static GLboolean
-_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_XBGR16161616_UINT) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_UINT16 ||
- dstFormat == MESA_FORMAT_RG_UINT16 ||
- dstFormat == MESA_FORMAT_RGB_UINT16 ||
- dstFormat == MESA_FORMAT_RGBA_UINT16 ||
- dstFormat == MESA_FORMAT_ALPHA_UINT16 ||
- dstFormat == MESA_FORMAT_INTENSITY_UINT16 ||
- dstFormat == MESA_FORMAT_LUMINANCE_UINT16 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT16 ||
- dstFormat == MESA_FORMAT_XBGR16161616_UINT);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLushort));
-
- {
- /* general path */
- const GLuint *tempImage =
- make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat,
- srcWidth, srcHeight, srcDepth,
- 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++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstTexel = (GLushort *) dstRow;
- GLint i;
- 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;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, unsigned int32 */
-static GLboolean
-_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_XBGR32323232_UINT) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_UINT32 ||
- dstFormat == MESA_FORMAT_RG_UINT32 ||
- dstFormat == MESA_FORMAT_RGB_UINT32 ||
- dstFormat == MESA_FORMAT_RGBA_UINT32 ||
- dstFormat == MESA_FORMAT_ALPHA_UINT32 ||
- dstFormat == MESA_FORMAT_INTENSITY_UINT32 ||
- dstFormat == MESA_FORMAT_LUMINANCE_UINT32 ||
- dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT32 ||
- dstFormat == MESA_FORMAT_XBGR32323232_UINT);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLuint));
-
- {
- /* general path */
- const GLuint *tempImage =
- make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat,
- 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 (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstTexel = (GLuint *) dstRow;
- GLint 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;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_srgb8(TEXSTORE_PARAMS)
-{
- gl_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_SRGB8);
-
- /* reuse normal rgb texstore code */
- newDstFormat = MESA_FORMAT_RGB888;
-
- k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat,
- newDstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_srgba8(TEXSTORE_PARAMS)
-{
- gl_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_SRGBA8 ||
- dstFormat == MESA_FORMAT_XBGR8888_SRGB);
-
- /* reuse normal rgba texstore code */
- if (dstFormat == MESA_FORMAT_SRGBA8) {
- newDstFormat = MESA_FORMAT_RGBA8888;
- }
- else if (dstFormat == MESA_FORMAT_XBGR8888_SRGB) {
- newDstFormat = MESA_FORMAT_RGBX8888_REV;
- }
- else {
- ASSERT(0);
- return GL_TRUE;
- }
-
- k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat,
- newDstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_sargb8(TEXSTORE_PARAMS)
-{
- gl_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_SARGB8);
-
- /* reuse normal rgba texstore code */
- newDstFormat = MESA_FORMAT_ARGB8888;
-
- k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat,
- newDstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_sl8(TEXSTORE_PARAMS)
-{
- gl_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_SL8);
-
- newDstFormat = MESA_FORMAT_L8;