diff options
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r-- | src/mesa/main/texstore.c | 113 |
1 files changed, 112 insertions, 1 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 9a690529a83..6da3e4eb7b4 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -63,7 +63,6 @@ #include "pack.h" #include "pbo.h" #include "imports.h" -#include "pack.h" #include "texcompress.h" #include "texcompress_fxt1.h" #include "texcompress_rgtc.h" @@ -71,6 +70,8 @@ #include "teximage.h" #include "texstore.h" #include "enums.h" +#include "../../gallium/auxiliary/util/u_format_rgb9e5.h" +#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h" enum { @@ -3551,6 +3552,7 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && baseInternalFormat == srcFormat && + baseInternalFormat == baseFormat && srcType == GL_FLOAT) { /* simple memcpy path */ memcpy_texture(ctx, dims, @@ -3625,6 +3627,7 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && baseInternalFormat == srcFormat && + baseInternalFormat == baseFormat && srcType == GL_HALF_FLOAT_ARB) { /* simple memcpy path */ memcpy_texture(ctx, dims, @@ -4175,6 +4178,111 @@ _mesa_texstore_sla8(TEXSTORE_PARAMS) #endif /* FEATURE_EXT_texture_sRGB */ +static GLboolean +_mesa_texstore_rgb9_e5(TEXSTORE_PARAMS) +{ + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB9_E5_FLOAT); + ASSERT(baseInternalFormat == GL_RGB); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_INT_5_9_9_9_REV) { + /* 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 = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * 4 + + dstYoffset * dstRowStride + + dstXoffset * 4; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint*)dstRow; + for (col = 0; col < srcWidth; col++) { + dstUI[col] = float3_to_rgb9e5(&srcRow[col * 3]); + } + dstRow += dstRowStride; + srcRow += srcWidth * 3; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS) +{ + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_R11_G11_B10_FLOAT); + ASSERT(baseInternalFormat == GL_RGB); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_INT_10F_11F_11F_REV) { + /* 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 = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * 4 + + dstYoffset * dstRowStride + + dstXoffset * 4; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint*)dstRow; + for (col = 0; col < srcWidth; col++) { + dstUI[col] = float3_to_r11g11b10f(&srcRow[col * 3]); + } + dstRow += dstRowStride; + srcRow += srcWidth * 3; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} @@ -4308,6 +4416,9 @@ texstore_funcs[MESA_FORMAT_COUNT] = { MESA_FORMAT_SIGNED_L16, _mesa_texstore_snorm16 }, { MESA_FORMAT_SIGNED_AL1616, _mesa_texstore_snorm1616 }, { MESA_FORMAT_SIGNED_I16, _mesa_texstore_snorm16 }, + + { MESA_FORMAT_RGB9_E5_FLOAT, _mesa_texstore_rgb9_e5 }, + { MESA_FORMAT_R11_G11_B10_FLOAT, _mesa_texstore_r11_g11_b10f }, }; |