aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2011-04-26 02:18:24 +0200
committerMarek Olšák <[email protected]>2011-04-29 11:31:55 +0200
commit9d7698c468f4ea7da8bb4ec00520c98f11cca0fa (patch)
treeda4a82690218f5a3c78f0961e4ca105ff3bc20ed /src/mesa/main/texstore.c
parent1d5f16ff8fae936f2e920800b169cf7736a8052a (diff)
mesa: implement EXT_texture_shared_exponent
swrast support done. There is no renderbuffer support in swrast, because it's not required by the extension. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r--src/mesa/main/texstore.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index c4fe82a0b94..5cdde4524b2 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -70,6 +70,7 @@
#include "teximage.h"
#include "texstore.h"
#include "enums.h"
+#include "rgb9e5.h"
enum {
@@ -4176,6 +4177,60 @@ _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 bytesPerRow;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ bytesPerRow = srcWidth * 3 * sizeof(GLfloat);
+ 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;
+}
@@ -4309,6 +4364,8 @@ 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 },
};