d[3] = 1.0;
}
+/* MESA_FORMAT_ABGR2101010 */
+
+static void
+pack_ubyte_ABGR2101010(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r = UBYTE_TO_USHORT(src[RCOMP]);
+ GLushort g = UBYTE_TO_USHORT(src[GCOMP]);
+ GLushort b = UBYTE_TO_USHORT(src[BCOMP]);
+ GLushort a = UBYTE_TO_USHORT(src[ACOMP]);
+ *d = PACK_COLOR_2101010_US(a, b, g, r);
+}
+
+static void
+pack_float_ABGR2101010(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r, g, b, a;
+ UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+ *d = PACK_COLOR_2101010_US(a, b, g, r);
+}
+
/**
* Return a function that can pack a GLubyte rgba[4] color.
table[MESA_FORMAT_XBGR32323232_UINT] = NULL;
table[MESA_FORMAT_XBGR32323232_SINT] = NULL;
+ table[MESA_FORMAT_ABGR2101010] = pack_ubyte_ABGR2101010;
+
initialized = GL_TRUE;
}
table[MESA_FORMAT_XBGR32323232_UINT] = NULL;
table[MESA_FORMAT_XBGR32323232_SINT] = NULL;
+ table[MESA_FORMAT_ABGR2101010] = pack_float_ABGR2101010;
+
initialized = GL_TRUE;
}
}
}
+static void
+unpack_ABGR2101010(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLuint *s = ((const GLuint *) src);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = ((s[i] >> 0) & 0x3ff) * (1.0F / 1023.0F);
+ dst[i][GCOMP] = ((s[i] >> 10) & 0x3ff) * (1.0F / 1023.0F);
+ dst[i][BCOMP] = ((s[i] >> 20) & 0x3ff) * (1.0F / 1023.0F);
+ dst[i][ACOMP] = ((s[i] >> 30) & 0x03) * (1.0F / 3.0F);
+ }
+}
/**
* Return the unpacker function for the given format.
table[MESA_FORMAT_XBGR32323232_UINT] = unpack_XBGR32323232_UINT;
table[MESA_FORMAT_XBGR32323232_SINT] = unpack_XBGR32323232_SINT;
+ table[MESA_FORMAT_ABGR2101010] = unpack_ABGR2101010;
+
initialized = GL_TRUE;
}
}
}
+static void
+unpack_int_rgba_ABGR2101010(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ GLuint tmp = src[i];
+ dst[i][0] = (tmp >> 0) & 0x3ff;
+ dst[i][1] = (tmp >> 10) & 0x3ff;
+ dst[i][2] = (tmp >> 20) & 0x3ff;
+ dst[i][3] = (tmp >> 30) & 0x3;
+ }
+}
+
void
_mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
const void *src, GLuint dst[][4])
unpack_int_rgba_XBGR32323232_UINT(src, dst, n);
break;
+ case MESA_FORMAT_ABGR2101010:
+ unpack_int_rgba_ABGR2101010(src, dst, n);
+ break;
+
default:
_mesa_problem(NULL, "%s: bad format %s", __FUNCTION__,
_mesa_get_format_name(format));
0, 0, 0, 0, 0,
1, 1, 16
},
+ {
+ MESA_FORMAT_ABGR2101010,
+ "MESA_FORMAT_ABGR2101010",
+ GL_RGBA,
+ GL_UNSIGNED_NORMALIZED,
+ 10, 10, 10, 2,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
};
*comps = 4;
return;
+ case MESA_FORMAT_ABGR2101010:
+ *datatype = GL_UNSIGNED_INT_2_10_10_10_REV;
+ *comps = 4;
+ return;
+
case MESA_FORMAT_COUNT:
assert(0);
return;
case MESA_FORMAT_XBGR32323232_UINT:
case MESA_FORMAT_XBGR32323232_SINT:
return GL_FALSE;
+
+ case MESA_FORMAT_ABGR2101010:
+ return format == GL_RGBA && type == GL_UNSIGNED_INT_2_10_10_10_REV &&
+ !swapBytes;
+
}
return GL_FALSE;
MESA_FORMAT_XBGR32323232_UINT, /* ... */
MESA_FORMAT_XBGR32323232_SINT, /* ... */
+ MESA_FORMAT_ABGR2101010,
+
MESA_FORMAT_COUNT
} gl_format;
return GL_TRUE;
}
+static GLboolean
+_mesa_texstore_abgr2101010(TEXSTORE_PARAMS)
+{
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_ABGR2101010);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
+
+ {
+ /* 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 *src = tempImage;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstSlices[img];
+
+ 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]);
+ 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, b, g, r);
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
static GLboolean
_mesa_texstore_null(TEXSTORE_PARAMS)
{
table[MESA_FORMAT_XBGR32323232_UINT] = _mesa_texstore_rgba_uint32;
table[MESA_FORMAT_XBGR32323232_SINT] = _mesa_texstore_rgba_int32;
+ table[MESA_FORMAT_ABGR2101010] = _mesa_texstore_abgr2101010;
+
initialized = GL_TRUE;
}
NULL,
NULL
},
+ {
+ MESA_FORMAT_ABGR2101010,
+ NULL,
+ NULL,
+ NULL
+ },
};