[Mesa-dev] [PATCH 22/23] texstore argb2101010: merge GL_RGBA and GL_RGB cases
Ian Romanick
idr at freedesktop.org
Mon Jan 7 13:34:10 PST 2013
On 01/04/2013 06:41 PM, Jordan Justen wrote:
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
> src/mesa/main/texstore.c | 21 ++++++---------------
> 1 file changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
> index 7511509..6627cf5 100644
> --- a/src/mesa/main/texstore.c
> +++ b/src/mesa/main/texstore.c
> @@ -1714,18 +1714,23 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
> srcPacking,
> ctx->_ImageTransferState);
> const GLfloat *src = tempImage;
> + GLushort aMask = 0;
> GLint img, row, col;
> if (!tempImage)
> return GL_FALSE;
> + if (srcFormat == GL_RGB) {
> + aMask = 0xffff;
> + }
This is the situation where I really like this idiom:
const GLushort aMask = (srcFormat == GL_RGB) ? 0xffff : 0;
but that's just my own personal preference...
> for (img = 0; img < srcDepth; img++) {
> GLubyte *dstRow = dstSlices[img];
> - if (baseInternalFormat == GL_RGBA) {
> + if (baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB) {
> for (row = 0; row < srcHeight; row++) {
> GLuint *dstUI = (GLuint *) dstRow;
> for (col = 0; col < srcWidth; col++) {
> GLushort a,r,g,b;
>
> UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
> + a = a | aMask;
> UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
> UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
> UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
> @@ -1734,20 +1739,6 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
> }
> dstRow += dstRowStride;
> }
> - } else if (baseInternalFormat == GL_RGB) {
> - for (row = 0; row < srcHeight; row++) {
> - GLuint *dstUI = (GLuint *) dstRow;
> - for (col = 0; col < srcWidth; col++) {
> - 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;
> - }
> } else {
> ASSERT(0);
> }
>
More information about the mesa-dev
mailing list