mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-25 01:30:30 +01:00
mesa: add packing for int/uint
This just adds a simple packing for GL_UNSIGNED_INT/GL_INT destination formats. This is enough for at least the gallium drivers to pack both unsigned and signed types for read pixels. Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
61285c6cfa
commit
8f9edbad6f
2 changed files with 68 additions and 0 deletions
|
|
@ -467,6 +467,69 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* integer packing , no transfer operations only packs
|
||||
* to dst of GL_UNSIGNED_INT or GL_INT
|
||||
*/
|
||||
void
|
||||
_mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
|
||||
GLenum dstFormat, GLenum dstType,
|
||||
GLvoid *dstAddr)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch(dstType) {
|
||||
case GL_UNSIGNED_INT: {
|
||||
GLuint *dst = (GLuint *) dstAddr;
|
||||
switch (dstFormat) {
|
||||
case GL_RED_INTEGER_EXT:
|
||||
case GL_GREEN_INTEGER_EXT:
|
||||
case GL_BLUE_INTEGER_EXT:
|
||||
case GL_ALPHA_INTEGER_EXT:
|
||||
case GL_RGB_INTEGER_EXT:
|
||||
case GL_RGBA_INTEGER_EXT:
|
||||
case GL_BGR_INTEGER_EXT:
|
||||
case GL_BGRA_INTEGER_EXT:
|
||||
case GL_LUMINANCE_INTEGER_EXT:
|
||||
case GL_LUMINANCE_ALPHA_INTEGER_EXT:
|
||||
for (i=0;i<n;i++) {
|
||||
dst[i*4+0] = (GLuint) rgba[i][RCOMP];
|
||||
dst[i*4+1] = (GLuint) rgba[i][GCOMP];
|
||||
dst[i*4+2] = (GLuint) rgba[i][BCOMP];
|
||||
dst[i*4+3] = (GLuint) rgba[i][ACOMP];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_INT: {
|
||||
GLint *dst = (GLint *) dstAddr;
|
||||
switch (dstFormat) {
|
||||
case GL_RED_INTEGER_EXT:
|
||||
case GL_GREEN_INTEGER_EXT:
|
||||
case GL_BLUE_INTEGER_EXT:
|
||||
case GL_ALPHA_INTEGER_EXT:
|
||||
case GL_RGB_INTEGER_EXT:
|
||||
case GL_RGBA_INTEGER_EXT:
|
||||
case GL_BGR_INTEGER_EXT:
|
||||
case GL_BGRA_INTEGER_EXT:
|
||||
case GL_LUMINANCE_INTEGER_EXT:
|
||||
case GL_LUMINANCE_ALPHA_INTEGER_EXT:
|
||||
for (i=0;i<n;i++) {
|
||||
dst[i*4+0] = (GLint) rgba[i][RCOMP];
|
||||
dst[i*4+1] = (GLint) rgba[i][GCOMP];
|
||||
dst[i*4+2] = (GLint) rgba[i][BCOMP];
|
||||
dst[i*4+3] = (GLint) rgba[i][ACOMP];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -144,4 +144,9 @@ _mesa_unpack_image(GLuint dimensions,
|
|||
const struct gl_pixelstore_attrib *unpack);
|
||||
|
||||
|
||||
void
|
||||
_mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
|
||||
GLenum dstFormat, GLenum dstType,
|
||||
GLvoid *dstAddr);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue