mesa: document sRGBDecode field
[mesa.git] / src / mesa / main / texstore.c
index e43636eafcbb6a3b9eeef72671d03ba1695e6f65..7dd4a1fa6506d1b3f3157a543f2b0121244c84da 100644 (file)
@@ -58,6 +58,8 @@
 #include "image.h"
 #include "macros.h"
 #include "mipmap.h"
+#include "mfeatures.h"
+#include "mtypes.h"
 #include "pack.h"
 #include "imports.h"
 #include "pack.h"
@@ -2063,13 +2065,14 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
    }
    else {
       /* general path */
-      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+      const GLfloat *tempImage = make_temp_float_image(ctx, dims,
                                                  baseInternalFormat,
                                                  baseFormat,
                                                  srcWidth, srcHeight, srcDepth,
                                                  srcFormat, srcType, srcAddr,
-                                                 srcPacking);
-      const GLchan *src = tempImage;
+                                                 srcPacking,
+                                                 ctx->_ImageTransferState);
+      const GLfloat *src = tempImage;
       GLint img, row, col;
       if (!tempImage)
          return GL_FALSE;
@@ -2080,24 +2083,29 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
             + dstXoffset * texelBytes;
          if (baseInternalFormat == GL_RGBA) {
             for (row = 0; row < srcHeight; row++) {
-               GLuint *dstUS = (GLuint *) dstRow;
+               GLuint *dstUI = (GLuint *) dstRow;
                for (col = 0; col < srcWidth; col++) {
-                  dstUS[col] = PACK_COLOR_2101010( CHAN_TO_UBYTE(src[ACOMP]),
-                                                   CHAN_TO_UBYTE(src[RCOMP]),
-                                                   CHAN_TO_UBYTE(src[GCOMP]),
-                                                   CHAN_TO_UBYTE(src[BCOMP]) );
+                  GLushort a,r,g,b;
+
+                  UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+                  UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+                  UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+                  UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
+                  dstUI[col] = PACK_COLOR_2101010_US(a, r, g, b);
                   src += 4;
                }
                dstRow += dstRowStride;
             }
          } else if (baseInternalFormat == GL_RGB) {
             for (row = 0; row < srcHeight; row++) {
-               GLuint *dstUS = (GLuint *) dstRow;
+               GLuint *dstUI = (GLuint *) dstRow;
                for (col = 0; col < srcWidth; col++) {
-                  dstUS[col] = PACK_COLOR_2101010( 0xff,
-                                                   CHAN_TO_UBYTE(src[RCOMP]),
-                                                   CHAN_TO_UBYTE(src[GCOMP]),
-                                                   CHAN_TO_UBYTE(src[BCOMP]) );
+                  GLushort r,g,b;
+
+                  UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+                  UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+                  UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
+                  dstUI[col] = PACK_COLOR_2101010_US(0xffff, r, g, b);
                   src += 4;
                }
                dstRow += dstRowStride;
@@ -2357,7 +2365,7 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS)
 }
 
 
-/* Texstore for R16, A16, L16. */
+/* Texstore for R16, A16, L16, I16. */
 static GLboolean
 _mesa_texstore_unorm16(TEXSTORE_PARAMS)
 {
@@ -2367,7 +2375,8 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS)
 
    ASSERT(dstFormat == MESA_FORMAT_R16 ||
           dstFormat == MESA_FORMAT_A16 ||
-          dstFormat == MESA_FORMAT_L16);
+          dstFormat == MESA_FORMAT_L16 ||
+          dstFormat == MESA_FORMAT_I16);
    ASSERT(texelBytes == 2);
 
    if (!ctx->_ImageTransferState &&
@@ -4053,6 +4062,7 @@ texstore_funcs[MESA_FORMAT_COUNT] =
    { MESA_FORMAT_L8, _mesa_texstore_a8 },
    { MESA_FORMAT_L16, _mesa_texstore_unorm16 },
    { MESA_FORMAT_I8, _mesa_texstore_a8 },
+   { MESA_FORMAT_I16, _mesa_texstore_unorm16 },
    { MESA_FORMAT_CI8, _mesa_texstore_ci8 },
    { MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr },
    { MESA_FORMAT_YCBCR_REV, _mesa_texstore_ycbcr },