mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 22:08:26 +02:00
mesa: Add unpack functions for R/RG/RGB [U]INT8/16/32 formats.
NOTE: This is a candidate for stable branches.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63569
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit 995051ee34)
This commit is contained in:
parent
9f66038b5b
commit
07671a5627
1 changed files with 253 additions and 0 deletions
|
|
@ -1075,6 +1075,45 @@ unpack_RG_FLOAT16(const void *src, GLfloat dst[][4], GLuint n)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
unpack_R_INT8(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLbyte *s = (const GLbyte *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i];
|
||||
dst[i][GCOMP] = 0.0;
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RG_INT8(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLbyte *s = (const GLbyte *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*2+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*2+1];
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGB_INT8(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLbyte *s = (const GLbyte *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*3+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*3+1];
|
||||
dst[i][BCOMP] = (GLfloat) s[i*3+2];
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGBA_INT8(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
|
|
@ -1088,6 +1127,45 @@ unpack_RGBA_INT8(const void *src, GLfloat dst[][4], GLuint n)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_R_INT16(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLshort *s = (const GLshort *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i];
|
||||
dst[i][GCOMP] = 0.0;
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RG_INT16(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLshort *s = (const GLshort *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*2+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*2+1];
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGB_INT16(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLshort *s = (const GLshort *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*3+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*3+1];
|
||||
dst[i][BCOMP] = (GLfloat) s[i*3+2];
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGBA_INT16(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
|
|
@ -1101,6 +1179,46 @@ unpack_RGBA_INT16(const void *src, GLfloat dst[][4], GLuint n)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_R_INT32(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLint *s = (const GLint *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i];
|
||||
dst[i][GCOMP] = 0.0;
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RG_INT32(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLint *s = (const GLint *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*2+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*2+1];
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGB_INT32(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLint *s = (const GLint *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*3+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*3+1];
|
||||
dst[i][BCOMP] = (GLfloat) s[i*3+2];
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
unpack_RGBA_INT32(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
|
|
@ -1114,6 +1232,45 @@ unpack_RGBA_INT32(const void *src, GLfloat dst[][4], GLuint n)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_R_UINT8(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLubyte *s = (const GLubyte *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i];
|
||||
dst[i][GCOMP] = 0.0;
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RG_UINT8(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLubyte *s = (const GLubyte *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*2+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*2+1];
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGB_UINT8(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLubyte *s = (const GLubyte *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*3+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*3+1];
|
||||
dst[i][BCOMP] = (GLfloat) s[i*3+2];
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGBA_UINT8(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
|
|
@ -1127,6 +1284,45 @@ unpack_RGBA_UINT8(const void *src, GLfloat dst[][4], GLuint n)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_R_UINT16(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLushort *s = (const GLushort *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i];
|
||||
dst[i][GCOMP] = 0.0;
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RG_UINT16(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLushort *s = (const GLushort *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*2+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*2+1];
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGB_UINT16(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
const GLushort *s = (const GLushort *) src;
|
||||
GLuint i;
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i][RCOMP] = (GLfloat) s[i*3+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*3+1];
|
||||
dst[i][BCOMP] = (GLfloat) s[i*3+2];
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGBA_UINT16(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
|
|
@ -1140,6 +1336,45 @@ unpack_RGBA_UINT16(const void *src, GLfloat dst[][4], GLuint n)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_R_UINT32(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] = (GLfloat) s[i];
|
||||
dst[i][GCOMP] = 0.0;
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RG_UINT32(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] = (GLfloat) s[i*2+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*2+1];
|
||||
dst[i][BCOMP] = 0.0;
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGB_UINT32(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] = (GLfloat) s[i*3+0];
|
||||
dst[i][GCOMP] = (GLfloat) s[i*3+1];
|
||||
dst[i][BCOMP] = (GLfloat) s[i*3+2];
|
||||
dst[i][ACOMP] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_RGBA_UINT32(const void *src, GLfloat dst[][4], GLuint n)
|
||||
{
|
||||
|
|
@ -1632,11 +1867,29 @@ get_unpack_rgba_function(gl_format format)
|
|||
table[MESA_FORMAT_RG_FLOAT32] = unpack_RG_FLOAT32;
|
||||
table[MESA_FORMAT_RG_FLOAT16] = unpack_RG_FLOAT16;
|
||||
|
||||
table[MESA_FORMAT_R_INT8] = unpack_R_INT8;
|
||||
table[MESA_FORMAT_RG_INT8] = unpack_RG_INT8;
|
||||
table[MESA_FORMAT_RGB_INT8] = unpack_RGB_INT8;
|
||||
table[MESA_FORMAT_RGBA_INT8] = unpack_RGBA_INT8;
|
||||
table[MESA_FORMAT_R_INT16] = unpack_R_INT16;
|
||||
table[MESA_FORMAT_RG_INT16] = unpack_RG_INT16;
|
||||
table[MESA_FORMAT_RGB_INT16] = unpack_RGB_INT16;
|
||||
table[MESA_FORMAT_RGBA_INT16] = unpack_RGBA_INT16;
|
||||
table[MESA_FORMAT_R_INT32] = unpack_R_INT32;
|
||||
table[MESA_FORMAT_RG_INT32] = unpack_RG_INT32;
|
||||
table[MESA_FORMAT_RGB_INT32] = unpack_RGB_INT32;
|
||||
table[MESA_FORMAT_RGBA_INT32] = unpack_RGBA_INT32;
|
||||
table[MESA_FORMAT_R_UINT8] = unpack_R_UINT8;
|
||||
table[MESA_FORMAT_RG_UINT8] = unpack_RG_UINT8;
|
||||
table[MESA_FORMAT_RGB_UINT8] = unpack_RGB_UINT8;
|
||||
table[MESA_FORMAT_RGBA_UINT8] = unpack_RGBA_UINT8;
|
||||
table[MESA_FORMAT_R_UINT16] = unpack_R_UINT16;
|
||||
table[MESA_FORMAT_RG_UINT16] = unpack_RG_UINT16;
|
||||
table[MESA_FORMAT_RGB_UINT16] = unpack_RGB_UINT16;
|
||||
table[MESA_FORMAT_RGBA_UINT16] = unpack_RGBA_UINT16;
|
||||
table[MESA_FORMAT_R_UINT32] = unpack_R_UINT32;
|
||||
table[MESA_FORMAT_RG_UINT32] = unpack_RG_UINT32;
|
||||
table[MESA_FORMAT_RGB_UINT32] = unpack_RGB_UINT32;
|
||||
table[MESA_FORMAT_RGBA_UINT32] = unpack_RGBA_UINT32;
|
||||
|
||||
table[MESA_FORMAT_DUDV8] = unpack_DUDV8;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue