summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2011-04-26 02:27:25 +0200
committerMarek Olšák <[email protected]>2011-04-29 11:31:55 +0200
commit631d23daa91c569bf268a2191bd466df73a64263 (patch)
tree84bffa5944f0c6b745cc31942dfb75a4f9db128b /src/mesa/main/texstore.c
parentb48359184e36ecd11510e9c87e3db535935c99e2 (diff)
mesa: implement EXT_packed_float
Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[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 39f59e3cbd9..d694ab8e5ad 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -71,6 +71,7 @@
#include "texstore.h"
#include "enums.h"
#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
+#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
enum {
@@ -4232,6 +4233,61 @@ _mesa_texstore_rgb9_e5(TEXSTORE_PARAMS)
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 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_r11g11b10f(&srcRow[col * 3]);
+ }
+ dstRow += dstRowStride;
+ srcRow += srcWidth * 3;
+ }
+ }
+
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
/**
@@ -4366,6 +4422,7 @@ texstore_funcs[MESA_FORMAT_COUNT] =
{ 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 },
};