diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/formats.c | 9 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 1 | ||||
-rw-r--r-- | src/mesa/main/texfetch.c | 7 | ||||
-rw-r--r-- | src/mesa/main/texfetch_tmp.h | 31 | ||||
-rw-r--r-- | src/mesa/main/texformat.c | 22 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 67 |
6 files changed, 127 insertions, 10 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 7f57fc05d59..3671140e859 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -721,6 +721,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 16, 16, 16, 16, 0, 0, 0, 0, 0, 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_16, + "MESA_FORMAT_RGBA_16", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 } }; diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index bfd4f20337e..c744688122f 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -146,6 +146,7 @@ typedef enum MESA_FORMAT_SIGNED_RG_16, /* ushort[0]=R, ushort[1]=G */ MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ MESA_FORMAT_SIGNED_RGBA_16, /* ... */ + MESA_FORMAT_RGBA_16, /* ... */ /*@}*/ MESA_FORMAT_COUNT diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index 48a22c19455..3169f3b3f56 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -622,6 +622,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] = fetch_texel_3d_signed_rgba_16, store_texel_signed_rgba_16 }, + { + MESA_FORMAT_RGBA_16, + fetch_texel_1d_rgba_16, + fetch_texel_2d_rgba_16, + fetch_texel_3d_rgba_16, + store_texel_rgba_16 + } }; diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h index 4df2b19181a..280c8d9400d 100644 --- a/src/mesa/main/texfetch_tmp.h +++ b/src/mesa/main/texfetch_tmp.h @@ -1374,7 +1374,7 @@ store_texel_signed_rg_16(struct gl_texture_image *texImage, #endif -/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/ +/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ static void FETCH(signed_rgb_16)(const struct gl_texture_image *texImage, @@ -1430,6 +1430,35 @@ store_texel_signed_rgba_16(struct gl_texture_image *texImage, +/* MESA_FORMAT_RGBA_16 ***********************************************/ + +static void +FETCH(rgba_16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); + texel[RCOMP] = USHORT_TO_FLOAT( s[0] ); + texel[GCOMP] = USHORT_TO_FLOAT( s[1] ); + texel[BCOMP] = USHORT_TO_FLOAT( s[2] ); + texel[ACOMP] = USHORT_TO_FLOAT( s[3] ); +} + +#if DIM == 3 +static void +store_texel_rgba_16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + + /* MESA_FORMAT_YCBCR *********************************************************/ /* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats. diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 06e6fd92fca..d235485721a 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -61,12 +61,9 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, (void) type; switch (internalFormat) { - /* RGBA formats */ + /* shallow RGBA formats */ case 4: case GL_RGBA: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: case GL_RGBA8: return MESA_FORMAT_RGBA8888; case GL_RGB5_A1: @@ -76,12 +73,15 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, case GL_RGBA4: return MESA_FORMAT_ARGB4444; - /* RGB formats */ + /* deep RGBA formats */ + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return MESA_FORMAT_RGBA_16; + + /* shallow RGB formats */ case 3: case GL_RGB: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: case GL_RGB8: return MESA_FORMAT_RGB888; case GL_R3_G3_B2: @@ -91,6 +91,12 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, case GL_RGB5: return MESA_FORMAT_RGB565; + /* deep RGB formats */ + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return MESA_FORMAT_RGBA_16; + /* Alpha formats */ case GL_ALPHA: case GL_ALPHA4: diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 2356b24f4af..ce05652c935 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2225,6 +2225,70 @@ _mesa_texstore_al1616(TEXSTORE_PARAMS) static GLboolean +_mesa_texstore_rgba_16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_16); + ASSERT(texelBytes == 8); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGBA && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_SHORT) { + /* 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 = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r, g, b, a; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[1]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[2]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[3]); + dstUS[col*4+0] = r; + dstUS[col*4+1] = g; + dstUS[col*4+2] = b; + dstUS[col*4+3] = a; + src += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) { const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); @@ -3420,7 +3484,8 @@ texstore_funcs[MESA_FORMAT_COUNT] = { MESA_FORMAT_SIGNED_R_16, _mesa_texstore_signed_rgba_16 }, { MESA_FORMAT_SIGNED_RG_16, _mesa_texstore_signed_rgba_16 }, { MESA_FORMAT_SIGNED_RGB_16, _mesa_texstore_signed_rgba_16 }, - { MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 } + { MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 } }; |