GLboolean _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) { GLbyte *dst; const GLfloat *tempImage = NULL; int i, j; int numxpixels, numypixels; const GLfloat *srcaddr; GLbyte srcpixels[4][4]; GLbyte *blkaddr; GLint dstRowDiff; ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2_SNORM || dstFormat == MESA_FORMAT_LA_LATC2_SNORM); tempImage = _mesa_make_temp_float_image(ctx, dims, baseInternalFormat, _mesa_get_format_base_format(dstFormat), srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking, 0x0); if (!tempImage) return GL_FALSE; /* out of memory */ dst = (GLbyte *) dstSlices[0]; blkaddr = dst; dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0; for (j = 0; j < srcHeight; j += 4) { if (srcHeight > j + 3) numypixels = 4; else numypixels = srcHeight - j; srcaddr = tempImage + j * srcWidth * 2; for (i = 0; i < srcWidth; i += 4) { if (srcWidth > i + 3) numxpixels = 4; else numxpixels = srcWidth - i; extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2); signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); blkaddr += 8; extractsrc_s(srcpixels, srcaddr + 1, srcWidth, numxpixels, numypixels, 2); signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); blkaddr += 8; srcaddr += numxpixels * 2; } blkaddr += dstRowDiff; } free((void *) tempImage); return GL_TRUE; }
GLboolean _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS) { GLbyte *dst; const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ const GLfloat *tempImage = NULL; int i, j; int numxpixels, numypixels; const GLfloat *srcaddr; GLbyte srcpixels[4][4]; GLbyte *blkaddr; GLint dstRowDiff; ASSERT(dstFormat == MESA_FORMAT_SIGNED_RED_RGTC1 || dstFormat == MESA_FORMAT_SIGNED_L_LATC1); ASSERT(dstXoffset % 4 == 0); ASSERT(dstYoffset % 4 == 0); ASSERT(dstZoffset % 4 == 0); (void) dstZoffset; tempImage = _mesa_make_temp_float_image(ctx, dims, baseInternalFormat, _mesa_get_format_base_format(dstFormat), srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking, 0x0); if (!tempImage) return GL_FALSE; /* out of memory */ dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0, dstFormat, texWidth, dstSlices[0]); blkaddr = dst; dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0; for (j = 0; j < srcHeight; j+=4) { if (srcHeight > j + 3) numypixels = 4; else numypixels = srcHeight - j; srcaddr = tempImage + j * srcWidth; for (i = 0; i < srcWidth; i += 4) { if (srcWidth > i + 3) numxpixels = 4; else numxpixels = srcWidth - i; extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1); signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); srcaddr += numxpixels; blkaddr += 8; } blkaddr += dstRowDiff; } if (tempImage) free((void *) tempImage); return GL_TRUE; }
GLboolean _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS) { GLbyte *dst; const GLfloat *tempImage = NULL; int i, j; int numxpixels, numypixels; const GLfloat *srcaddr; GLbyte srcpixels[4][4]; GLbyte *blkaddr; GLint dstRowDiff, redRowStride; GLfloat *tempImageSlices[1]; assert(dstFormat == MESA_FORMAT_R_RGTC1_SNORM || dstFormat == MESA_FORMAT_L_LATC1_SNORM); redRowStride = 1 * srcWidth * sizeof(GLfloat); tempImage = malloc(srcWidth * srcHeight * 1 * sizeof(GLfloat)); if (!tempImage) return GL_FALSE; /* out of memory */ tempImageSlices[0] = (GLfloat *) tempImage; _mesa_texstore(ctx, dims, baseInternalFormat, MESA_FORMAT_R_FLOAT32, redRowStride, (GLubyte **)tempImageSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); dst = (GLbyte *) dstSlices[0]; blkaddr = dst; dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0; for (j = 0; j < srcHeight; j+=4) { if (srcHeight > j + 3) numypixels = 4; else numypixels = srcHeight - j; srcaddr = tempImage + j * srcWidth; for (i = 0; i < srcWidth; i += 4) { if (srcWidth > i + 3) numxpixels = 4; else numxpixels = srcWidth - i; extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1); util_format_signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); srcaddr += numxpixels; blkaddr += 8; } blkaddr += dstRowDiff; } free((void *) tempImage); return GL_TRUE; }