aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-07-11 08:47:29 +0200
committermarha <marha@users.sourceforge.net>2011-07-11 08:47:29 +0200
commit0b43e0b4ddbd9fdac70658164f3dbf653067a4de (patch)
tree96f2c71cec2c8c7e34b1f2e0c1518bea14adfcf2 /mesalib/src/mesa
parent47a6ae678489d7082b5d7da35d1a92b4233fb5eb (diff)
downloadvcxsrv-0b43e0b4ddbd9fdac70658164f3dbf653067a4de.tar.gz
vcxsrv-0b43e0b4ddbd9fdac70658164f3dbf653067a4de.tar.bz2
vcxsrv-0b43e0b4ddbd9fdac70658164f3dbf653067a4de.zip
mesa update 11 july 2011
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r--mesalib/src/mesa/main/depthstencil.c322
-rw-r--r--mesalib/src/mesa/main/depthstencil.h119
-rw-r--r--mesalib/src/mesa/main/fbobject.c23
-rw-r--r--mesalib/src/mesa/main/formats.c29
-rw-r--r--mesalib/src/mesa/main/formats.h3
-rw-r--r--mesalib/src/mesa/main/framebuffer.c10
-rw-r--r--mesalib/src/mesa/main/image.c3884
-rw-r--r--mesalib/src/mesa/main/mipmap.c20
-rw-r--r--mesalib/src/mesa/main/mtypes.h2
-rw-r--r--mesalib/src/mesa/main/pack.c83
-rw-r--r--mesalib/src/mesa/main/pack.h294
-rw-r--r--mesalib/src/mesa/main/readpix.c29
-rw-r--r--mesalib/src/mesa/main/renderbuffer.c3
-rw-r--r--mesalib/src/mesa/main/samplerobj.c2
-rw-r--r--mesalib/src/mesa/main/shaderapi.c4
-rw-r--r--mesalib/src/mesa/main/texenv.c6
-rw-r--r--mesalib/src/mesa/main/texfetch.c2114
-rw-r--r--mesalib/src/mesa/main/texfetch_tmp.h4781
-rw-r--r--mesalib/src/mesa/main/texformat.c13
-rw-r--r--mesalib/src/mesa/main/texobj.c2
-rw-r--r--mesalib/src/mesa/main/texstore.c79
-rw-r--r--mesalib/src/mesa/main/uniforms.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c64
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_readpixels.c45
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c54
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c9
-rw-r--r--mesalib/src/mesa/swrast/s_blit.c3
-rw-r--r--mesalib/src/mesa/swrast/s_readpix.c2
30 files changed, 6379 insertions, 5641 deletions
diff --git a/mesalib/src/mesa/main/depthstencil.c b/mesalib/src/mesa/main/depthstencil.c
index ab62c97fe..4d0600050 100644
--- a/mesalib/src/mesa/main/depthstencil.c
+++ b/mesalib/src/mesa/main/depthstencil.c
@@ -393,6 +393,217 @@ _mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
}
+static void
+get_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ GLfloat temp[MAX_WIDTH*2];
+ GLfloat *dst = (GLfloat *) values;
+ const GLfloat *src = (const GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
+ GLuint i;
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ if (!src) {
+ dsrb->GetRow(ctx, dsrb, count, x, y, temp);
+ src = temp;
+ }
+ for (i = 0; i < count; i++) {
+ dst[i] = src[i*2];
+ }
+}
+
+static void
+get_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ GLfloat temp[MAX_WIDTH*2];
+ GLfloat *dst = (GLfloat *) values;
+ GLuint i;
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ ASSERT(count <= MAX_WIDTH);
+ /* don't bother trying direct access */
+ dsrb->GetValues(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ dst[i] = temp[i*2];
+ }
+}
+
+static void
+put_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ const GLfloat *src = (const GLfloat *) values;
+ GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ if (dst) {
+ /* direct access */
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i*2] = src[i];
+ }
+ }
+ }
+ else {
+ /* get, modify, put */
+ GLfloat temp[MAX_WIDTH*2];
+ GLuint i;
+ dsrb->GetRow(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2] = src[i];
+ }
+ }
+ dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
+ }
+}
+
+static void
+put_mono_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ if (dst) {
+ /* direct access */
+ GLuint i;
+ const GLfloat val = *(GLfloat*)value;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i*2] = val;
+ }
+ }
+ }
+ else {
+ /* get, modify, put */
+ GLfloat temp[MAX_WIDTH*2];
+ GLuint i;
+ const GLfloat val = *(GLfloat *)value;
+ dsrb->GetRow(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2] = val;
+ }
+ }
+ dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
+ }
+}
+
+static void
+put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ const GLfloat *src = (const GLfloat *) values;
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
+ /* direct access */
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+ *dst = src[i];
+ }
+ }
+ }
+ else {
+ /* get, modify, put */
+ GLfloat temp[MAX_WIDTH*2];
+ GLuint i;
+ dsrb->GetValues(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2] = src[i];
+ }
+ }
+ dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
+ }
+}
+
+static void
+put_mono_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ GLfloat temp[MAX_WIDTH*2];
+ GLuint i;
+ const GLfloat val = *(GLfloat *)value;
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ /* get, modify, put */
+ dsrb->GetValues(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2] = val;
+ }
+ }
+ dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
+}
+
+
+/**
+ * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like
+ * a depth renderbuffer.
+ * \return new depth renderbuffer
+ */
+struct gl_renderbuffer *
+_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
+ struct gl_renderbuffer *dsrb)
+{
+ struct gl_renderbuffer *z32frb;
+
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+
+ z32frb = ctx->Driver.NewRenderbuffer(ctx, 0);
+ if (!z32frb)
+ return NULL;
+
+ /* NOTE: need to do manual refcounting here */
+ z32frb->Wrapped = dsrb;
+ dsrb->RefCount++;
+
+ z32frb->Name = dsrb->Name;
+ z32frb->RefCount = 0;
+ z32frb->Width = dsrb->Width;
+ z32frb->Height = dsrb->Height;
+ z32frb->RowStride = dsrb->RowStride;
+ z32frb->InternalFormat = GL_DEPTH_COMPONENT32F;
+ z32frb->Format = MESA_FORMAT_Z32_FLOAT;
+ z32frb->_BaseFormat = GL_DEPTH_COMPONENT;
+ z32frb->DataType = GL_FLOAT;
+ z32frb->Data = NULL;
+ z32frb->Delete = delete_wrapper;
+ z32frb->AllocStorage = alloc_wrapper_storage;
+ z32frb->GetPointer = nop_get_pointer;
+ z32frb->GetRow = get_row_z32f;
+ z32frb->GetValues = get_values_z32f;
+ z32frb->PutRow = put_row_z32f;
+ z32frb->PutRowRGB = NULL;
+ z32frb->PutMonoRow = put_mono_row_z32f;
+ z32frb->PutValues = put_values_z32f;
+ z32frb->PutMonoValues = put_mono_values_z32f;
+
+ return z32frb;
+}
+
+
/*======================================================================
* Stencil wrapper around depth/stencil renderbuffer
*/
@@ -402,16 +613,22 @@ get_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
GLint x, GLint y, void *values)
{
struct gl_renderbuffer *dsrb = s8rb->Wrapped;
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
GLubyte *dst = (GLubyte *) values;
const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
if (!src) {
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
src = temp;
}
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ dst[i] = src[i*2+1] & 0xff;
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
dst[i] = src[i] & 0xff;
}
@@ -429,14 +646,20 @@ get_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count
const GLint x[], const GLint y[], void *values)
{
struct gl_renderbuffer *dsrb = s8rb->Wrapped;
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
GLubyte *dst = (GLubyte *) values;
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
ASSERT(count <= MAX_WIDTH);
/* don't bother trying direct access */
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ dst[i] = temp[i*2+1] & 0xff;
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
dst[i] = temp[i] & 0xff;
}
@@ -457,11 +680,19 @@ put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
const GLubyte *src = (const GLubyte *) values;
GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
if (dst) {
/* direct access */
GLuint i;
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i*2+1] = src[i];
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
dst[i] = (dst[i] & 0xffffff00) | src[i];
@@ -479,9 +710,16 @@ put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
}
else {
/* get, modify, put */
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2+1] = src[i];
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
temp[i] = (temp[i] & 0xffffff00) | src[i];
@@ -508,11 +746,19 @@ put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint cou
const GLubyte val = *((GLubyte *) value);
GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
if (dst) {
/* direct access */
GLuint i;
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i*2+1] = val;
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
dst[i] = (dst[i] & 0xffffff00) | val;
@@ -530,9 +776,16 @@ put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint cou
}
else {
/* get, modify, put */
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2+1] = val;
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
temp[i] = (temp[i] & 0xffffff00) | val;
@@ -559,11 +812,20 @@ put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count
struct gl_renderbuffer *dsrb = s8rb->Wrapped;
const GLubyte *src = (const GLubyte *) values;
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
/* direct access */
GLuint i;
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+ dst[1] = src[i];
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
@@ -583,9 +845,16 @@ put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count
}
else {
/* get, modify, put */
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2+1] = src[i];
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
temp[i] = (temp[i] & 0xffffff00) | src[i];
@@ -610,11 +879,18 @@ put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint
const void *value, const GLubyte *mask)
{
struct gl_renderbuffer *dsrb = s8rb->Wrapped;
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
const GLubyte val = *((GLubyte *) value);
/* get, modify, put */
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2+1] = val;
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
temp[i] = (temp[i] & 0xffffff00) | val;
@@ -644,8 +920,10 @@ _mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer
struct gl_renderbuffer *s8rb;
ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 ||
- dsrb->Format == MESA_FORMAT_S8_Z24);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ dsrb->Format == MESA_FORMAT_S8_Z24 ||
+ dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
s8rb = ctx->Driver.NewRenderbuffer(ctx, 0);
if (!s8rb)
diff --git a/mesalib/src/mesa/main/depthstencil.h b/mesalib/src/mesa/main/depthstencil.h
index a86f54d96..b47a2e482 100644
--- a/mesalib/src/mesa/main/depthstencil.h
+++ b/mesalib/src/mesa/main/depthstencil.h
@@ -1,57 +1,62 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef DEPTHSTENCIL_H
-#define DEPTHSTENCIL_H
-
-struct gl_context;
-
-extern struct gl_renderbuffer *
-_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
- struct gl_renderbuffer *dsrb);
-
-
-extern struct gl_renderbuffer *
-_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx,
- struct gl_renderbuffer *dsrb);
-
-
-extern void
-_mesa_extract_stencil(struct gl_context *ctx,
- struct gl_renderbuffer *dsRb,
- struct gl_renderbuffer *stencilRb);
-
-
-extern void
-_mesa_insert_stencil(struct gl_context *ctx,
- struct gl_renderbuffer *dsRb,
- struct gl_renderbuffer *stencilRb);
-
-
-extern void
-_mesa_promote_stencil(struct gl_context *ctx, struct gl_renderbuffer *stencilRb);
-
-
-#endif /* DEPTHSTENCIL_H */
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef DEPTHSTENCIL_H
+#define DEPTHSTENCIL_H
+
+struct gl_context;
+
+extern struct gl_renderbuffer *
+_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
+ struct gl_renderbuffer *dsrb);
+
+
+extern struct gl_renderbuffer *
+_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
+ struct gl_renderbuffer *dsrb);
+
+
+extern struct gl_renderbuffer *
+_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx,
+ struct gl_renderbuffer *dsrb);
+
+
+extern void
+_mesa_extract_stencil(struct gl_context *ctx,
+ struct gl_renderbuffer *dsRb,
+ struct gl_renderbuffer *stencilRb);
+
+
+extern void
+_mesa_insert_stencil(struct gl_context *ctx,
+ struct gl_renderbuffer *dsRb,
+ struct gl_renderbuffer *stencilRb);
+
+
+extern void
+_mesa_promote_stencil(struct gl_context *ctx, struct gl_renderbuffer *stencilRb);
+
+
+#endif /* DEPTHSTENCIL_H */
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 8cc3fd49a..84969360d 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -1131,6 +1131,16 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
return GL_DEPTH_STENCIL_EXT;
else
return 0;
+ case GL_DEPTH_COMPONENT32F:
+ if (ctx->Extensions.ARB_depth_buffer_float)
+ return GL_DEPTH_COMPONENT;
+ else
+ return 0;
+ case GL_DEPTH32F_STENCIL8:
+ if (ctx->Extensions.ARB_depth_buffer_float)
+ return GL_DEPTH_STENCIL;
+ else
+ return 0;
case GL_RED:
case GL_R8:
case GL_R16:
@@ -2266,6 +2276,15 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
/* special cases */
*params = GL_INDEX;
}
+ else if (format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ /* depends on the attachment parameter */
+ if (attachment == GL_STENCIL_ATTACHMENT) {
+ *params = GL_INDEX;
+ }
+ else {
+ *params = GL_FLOAT;
+ }
+ }
else {
*params = _mesa_get_format_datatype(format);
}
@@ -2584,6 +2603,10 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
}
}
+ if (!mask) {
+ return;
+ }
+
ASSERT(ctx->Driver.BlitFramebuffer);
ctx->Driver.BlitFramebuffer(ctx,
srcX0, srcY0, srcX1, srcY1,
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index e88ba4397..f58b19756 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -1091,6 +1091,25 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 0, 0, 0, 0,
1, 1, 4
},
+ /* ARB_depth_buffer_float */
+ {
+ MESA_FORMAT_Z32_FLOAT, /* Name */
+ "MESA_FORMAT_Z32_FLOAT", /* StrName */
+ GL_DEPTH_COMPONENT, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
+ 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
+ 1, 1, 4 /* BlockWidth/Height,Bytes */
+ },
+ {
+ MESA_FORMAT_Z32_FLOAT_X24S8, /* Name */
+ "MESA_FORMAT_Z32_FLOAT_X24S8", /* StrName */
+ GL_DEPTH_STENCIL, /* BaseFormat */
+ GL_NONE /* XXX */, /* DataType */
+ 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
+ 0, 0, 0, 32, 8, /* Lum/Int/Index/Depth/StencilBits */
+ 1, 1, 8 /* BlockWidth/Height,Bytes */
+ },
};
@@ -1654,6 +1673,16 @@ _mesa_format_to_type_and_comps(gl_format format,
*comps = 1;
return;
+ case MESA_FORMAT_Z32_FLOAT:
+ *datatype = GL_FLOAT;
+ *comps = 1;
+ return;
+
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ *datatype = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+ *comps = 1;
+ return;
+
case MESA_FORMAT_DUDV8:
*datatype = GL_BYTE;
*comps = 2;
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index 0640bbc4a..5b8c01781 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -209,6 +209,9 @@ typedef enum
MESA_FORMAT_RGB9_E5_FLOAT,
MESA_FORMAT_R11_G11_B10_FLOAT,
+ MESA_FORMAT_Z32_FLOAT,
+ MESA_FORMAT_Z32_FLOAT_X24S8,
+
MESA_FORMAT_COUNT
} gl_format;
diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c
index 66c9bd910..6e2ce7421 100644
--- a/mesalib/src/mesa/main/framebuffer.c
+++ b/mesalib/src/mesa/main/framebuffer.c
@@ -631,8 +631,14 @@ _mesa_update_depth_buffer(struct gl_context *ctx,
|| fb->_DepthBuffer->Wrapped != depthRb
|| _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) {
/* need to update wrapper */
- struct gl_renderbuffer *wrapper
- = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb);
+ struct gl_renderbuffer *wrapper;
+
+ if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ wrapper = _mesa_new_z32f_renderbuffer_wrapper(ctx, depthRb);
+ }
+ else {
+ wrapper = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb);
+ }
_mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper);
ASSERT(fb->_DepthBuffer->Wrapped == depthRb);
}
diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c
index a5cd5ac03..37127dcb7 100644
--- a/mesalib/src/mesa/main/image.c
+++ b/mesalib/src/mesa/main/image.c
@@ -1,1935 +1,1949 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.5
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/**
- * \file image.c
- * Image handling.
- */
-
-
-#include "glheader.h"
-#include "colormac.h"
-#include "image.h"
-#include "imports.h"
-#include "macros.h"
-#include "mfeatures.h"
-#include "mtypes.h"
-
-
-/**
- * NOTE:
- * Normally, BYTE_TO_FLOAT(0) returns 0.00392 That causes problems when
- * we later convert the float to a packed integer value (such as for
- * GL_RGB5_A1) because we'll wind up with a non-zero value.
- *
- * We redefine the macros here so zero is handled correctly.
- */
-#undef BYTE_TO_FLOAT
-#define BYTE_TO_FLOAT(B) ((B) == 0 ? 0.0F : ((2.0F * (B) + 1.0F) * (1.0F/255.0F)))
-
-#undef SHORT_TO_FLOAT
-#define SHORT_TO_FLOAT(S) ((S) == 0 ? 0.0F : ((2.0F * (S) + 1.0F) * (1.0F/65535.0F)))
-
-
-
-/** Compute ceiling of integer quotient of A divided by B. */
-#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
-
-
-/**
- * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise.
- */
-GLboolean
-_mesa_type_is_packed(GLenum type)
-{
- switch (type) {
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case MESA_UNSIGNED_BYTE_4_4:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- case GL_UNSIGNED_SHORT_8_8_MESA:
- case GL_UNSIGNED_SHORT_8_8_REV_MESA:
- case GL_UNSIGNED_INT_24_8_EXT:
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-
-
-/**
- * Flip the order of the 2 bytes in each word in the given array.
- *
- * \param p array.
- * \param n number of words.
- */
-void
-_mesa_swap2( GLushort *p, GLuint n )
-{
- GLuint i;
- for (i = 0; i < n; i++) {
- p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00);
- }
-}
-
-
-
-/*
- * Flip the order of the 4 bytes in each word in the given array.
- */
-void
-_mesa_swap4( GLuint *p, GLuint n )
-{
- GLuint i, a, b;
- for (i = 0; i < n; i++) {
- b = p[i];
- a = (b >> 24)
- | ((b >> 8) & 0xff00)
- | ((b << 8) & 0xff0000)
- | ((b << 24) & 0xff000000);
- p[i] = a;
- }
-}
-
-
-/**
- * Get the size of a GL data type.
- *
- * \param type GL data type.
- *
- * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1
- * if an invalid type enum.
- */
-GLint
-_mesa_sizeof_type( GLenum type )
-{
- switch (type) {
- case GL_BITMAP:
- return 0;
- case GL_UNSIGNED_BYTE:
- return sizeof(GLubyte);
- case GL_BYTE:
- return sizeof(GLbyte);
- case GL_UNSIGNED_SHORT:
- return sizeof(GLushort);
- case GL_SHORT:
- return sizeof(GLshort);
- case GL_UNSIGNED_INT:
- return sizeof(GLuint);
- case GL_INT:
- return sizeof(GLint);
- case GL_FLOAT:
- return sizeof(GLfloat);
- case GL_DOUBLE:
- return sizeof(GLdouble);
- case GL_HALF_FLOAT_ARB:
- return sizeof(GLhalfARB);
- case GL_FIXED:
- return sizeof(GLfixed);
- default:
- return -1;
- }
-}
-
-
-/**
- * Same as _mesa_sizeof_type() but also accepting the packed pixel
- * format data types.
- */
-GLint
-_mesa_sizeof_packed_type( GLenum type )
-{
- switch (type) {
- case GL_BITMAP:
- return 0;
- case GL_UNSIGNED_BYTE:
- return sizeof(GLubyte);
- case GL_BYTE:
- return sizeof(GLbyte);
- case GL_UNSIGNED_SHORT:
- return sizeof(GLushort);
- case GL_SHORT:
- return sizeof(GLshort);
- case GL_UNSIGNED_INT:
- return sizeof(GLuint);
- case GL_INT:
- return sizeof(GLint);
- case GL_HALF_FLOAT_ARB:
- return sizeof(GLhalfARB);
- case GL_FLOAT:
- return sizeof(GLfloat);
- case GL_UNSIGNED_BYTE_3_3_2:
- return sizeof(GLubyte);
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- return sizeof(GLubyte);
- case MESA_UNSIGNED_BYTE_4_4:
- return sizeof(GLubyte);
- case GL_UNSIGNED_SHORT_5_6_5:
- return sizeof(GLushort);
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- return sizeof(GLushort);
- case GL_UNSIGNED_SHORT_4_4_4_4:
- return sizeof(GLushort);
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- return sizeof(GLushort);
- case GL_UNSIGNED_SHORT_5_5_5_1:
- return sizeof(GLushort);
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- return sizeof(GLushort);
- case GL_UNSIGNED_INT_8_8_8_8:
- return sizeof(GLuint);
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- return sizeof(GLuint);
- case GL_UNSIGNED_INT_10_10_10_2:
- return sizeof(GLuint);
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- return sizeof(GLuint);
- case GL_UNSIGNED_SHORT_8_8_MESA:
- case GL_UNSIGNED_SHORT_8_8_REV_MESA:
- return sizeof(GLushort);
- case GL_UNSIGNED_INT_24_8_EXT:
- return sizeof(GLuint);
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- return sizeof(GLuint);
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- return sizeof(GLuint);
- default:
- return -1;
- }
-}
-
-
-/**
- * Get the number of components in a pixel format.
- *
- * \param format pixel format.
- *
- * \return the number of components in the given format, or -1 if a bad format.
- */
-GLint
-_mesa_components_in_format( GLenum format )
-{
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_COLOR_INDEX1_EXT:
- case GL_COLOR_INDEX2_EXT:
- case GL_COLOR_INDEX4_EXT:
- case GL_COLOR_INDEX8_EXT:
- case GL_COLOR_INDEX12_EXT:
- case GL_COLOR_INDEX16_EXT:
- case GL_STENCIL_INDEX:
- case GL_DEPTH_COMPONENT:
- case GL_RED:
- case GL_RED_INTEGER_EXT:
- case GL_GREEN:
- case GL_GREEN_INTEGER_EXT:
- case GL_BLUE:
- case GL_BLUE_INTEGER_EXT:
- case GL_ALPHA:
- case GL_ALPHA_INTEGER_EXT:
- case GL_LUMINANCE:
- case GL_LUMINANCE_INTEGER_EXT:
- case GL_INTENSITY:
- return 1;
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE_ALPHA_INTEGER_EXT:
- case GL_RG:
- return 2;
- case GL_RGB:
- case GL_RGB_INTEGER_EXT:
- return 3;
- case GL_RGBA:
- case GL_RGBA_INTEGER_EXT:
- return 4;
- case GL_BGR:
- return 3;
- case GL_BGRA:
- return 4;
- case GL_ABGR_EXT:
- return 4;
- case GL_YCBCR_MESA:
- return 2;
- case GL_DEPTH_STENCIL_EXT:
- return 2;
- case GL_DUDV_ATI:
- case GL_DU8DV8_ATI:
- return 2;
- default:
- return -1;
- }
-}
-
-
-/**
- * Get the bytes per pixel of pixel format type pair.
- *
- * \param format pixel format.
- * \param type pixel type.
- *
- * \return bytes per pixel, or -1 if a bad format or type was given.
- */
-GLint
-_mesa_bytes_per_pixel( GLenum format, GLenum type )
-{
- GLint comps = _mesa_components_in_format( format );
- if (comps < 0)
- return -1;
-
- switch (type) {
- case GL_BITMAP:
- return 0; /* special case */
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- return comps * sizeof(GLubyte);
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- return comps * sizeof(GLshort);
- case GL_INT:
- case GL_UNSIGNED_INT:
- return comps * sizeof(GLint);
- case GL_FLOAT:
- return comps * sizeof(GLfloat);
- case GL_HALF_FLOAT_ARB:
- return comps * sizeof(GLhalfARB);
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- if (format == GL_RGB || format == GL_BGR ||
- format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT)
- return sizeof(GLubyte);
- else
- return -1; /* error */
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- if (format == GL_RGB || format == GL_BGR ||
- format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT)
- return sizeof(GLushort);
- else
- return -1; /* error */
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
- format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
- return sizeof(GLushort);
- else
- return -1;
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
- format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
- return sizeof(GLuint);
- else
- return -1;
- case GL_UNSIGNED_SHORT_8_8_MESA:
- case GL_UNSIGNED_SHORT_8_8_REV_MESA:
- if (format == GL_YCBCR_MESA)
- return sizeof(GLushort);
- else
- return -1;
- case GL_UNSIGNED_INT_24_8_EXT:
- if (format == GL_DEPTH_STENCIL_EXT)
- return sizeof(GLuint);
- else
- return -1;
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- if (format == GL_RGB)
- return sizeof(GLuint);
- else
- return -1;
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- if (format == GL_RGB)
- return sizeof(GLuint);
- else
- return -1;
- default:
- return -1;
- }
-}
-
-
-/**
- * Test for a legal pixel format and type.
- *
- * \param format pixel format.
- * \param type pixel type.
- *
- * \return GL_TRUE if the given pixel format and type are legal, or GL_FALSE
- * otherwise.
- */
-GLboolean
-_mesa_is_legal_format_and_type(const struct gl_context *ctx,
- GLenum format, GLenum type)
-{
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- switch (type) {
- case GL_BITMAP:
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
- default:
- return GL_FALSE;
- }
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
-#if 0 /* not legal! see table 3.6 of the 1.5 spec */
- case GL_INTENSITY:
-#endif
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- case GL_DEPTH_COMPONENT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
- default:
- return GL_FALSE;
- }
- case GL_RG:
- if (!ctx->Extensions.ARB_texture_rg)
- return GL_FALSE;
-
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
- default:
- return GL_FALSE;
- }
- case GL_RGB:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- return ctx->Extensions.EXT_texture_shared_exponent;
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- return ctx->Extensions.EXT_packed_float;
- default:
- return GL_FALSE;
- }
- case GL_BGR:
- switch (type) {
- /* NOTE: no packed types are supported with BGR. That's
- * intentional, according to the GL spec.
- */
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
- default:
- return GL_FALSE;
- }
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
- default:
- return GL_FALSE;
- }
- case GL_YCBCR_MESA:
- if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
- type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
- return GL_TRUE;
- else
- return GL_FALSE;
- case GL_DEPTH_STENCIL_EXT:
- if (ctx->Extensions.EXT_packed_depth_stencil
- && type == GL_UNSIGNED_INT_24_8_EXT)
- return GL_TRUE;
- else
- return GL_FALSE;
- case GL_DUDV_ATI:
- case GL_DU8DV8_ATI:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-
- /* integer-valued formats */
- case GL_RED_INTEGER_EXT:
- case GL_GREEN_INTEGER_EXT:
- case GL_BLUE_INTEGER_EXT:
- case GL_ALPHA_INTEGER_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- return ctx->Extensions.EXT_texture_integer;
- default:
- return GL_FALSE;
- }
-
- case GL_RGB_INTEGER_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- return ctx->Extensions.EXT_texture_integer;
- default:
- return GL_FALSE;
- }
-
- case GL_BGR_INTEGER_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- /* NOTE: no packed formats w/ BGR format */
- return ctx->Extensions.EXT_texture_integer;
- default:
- return GL_FALSE;
- }
-
- case GL_RGBA_INTEGER_EXT:
- case GL_BGRA_INTEGER_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- return ctx->Extensions.EXT_texture_integer;
- default:
- return GL_FALSE;
- }
-
- case GL_LUMINANCE_INTEGER_EXT:
- case GL_LUMINANCE_ALPHA_INTEGER_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- return ctx->Extensions.EXT_texture_integer;
- default:
- return GL_FALSE;
- }
-
- default:
- ; /* fall-through */
- }
- return GL_FALSE;
-}
-
-
-/**
- * Test if the given image format is a color/RGBA format (i.e., not color
- * index, depth, stencil, etc).
- * \param format the image format value (may by an internal texture format)
- * \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise.
- */
-GLboolean
-_mesa_is_color_format(GLenum format)
-{
- switch (format) {
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_ALPHA12:
- case GL_ALPHA16:
- case 1:
- case GL_LUMINANCE:
- case GL_LUMINANCE4:
- case GL_LUMINANCE8:
- case GL_LUMINANCE12:
- case GL_LUMINANCE16:
- case 2:
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE4_ALPHA4:
- case GL_LUMINANCE6_ALPHA2:
- case GL_LUMINANCE8_ALPHA8:
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
- case GL_INTENSITY:
- case GL_INTENSITY4:
- case GL_INTENSITY8:
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- case GL_R8:
- case GL_R16:
- case GL_RG:
- case GL_RG8:
- case GL_RG16:
- case 3:
- case GL_RGB:
- case GL_BGR:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- case 4:
- case GL_ABGR_EXT:
- case GL_RGBA:
- case GL_BGRA:
- case GL_RGBA2:
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- /* float texture formats */
- case GL_ALPHA16F_ARB:
- case GL_ALPHA32F_ARB:
- case GL_LUMINANCE16F_ARB:
- case GL_LUMINANCE32F_ARB:
- case GL_LUMINANCE_ALPHA16F_ARB:
- case GL_LUMINANCE_ALPHA32F_ARB:
- case GL_INTENSITY16F_ARB:
- case GL_INTENSITY32F_ARB:
- case GL_R16F:
- case GL_R32F:
- case GL_RG16F:
- case GL_RG32F:
- case GL_RGB16F_ARB:
- case GL_RGB32F_ARB:
- case GL_RGBA16F_ARB:
- case GL_RGBA32F_ARB:
- /* compressed formats */
- case GL_COMPRESSED_ALPHA:
- case GL_COMPRESSED_LUMINANCE:
- case GL_COMPRESSED_LUMINANCE_ALPHA:
- case GL_COMPRESSED_INTENSITY:
- case GL_COMPRESSED_RED:
- case GL_COMPRESSED_RG:
- case GL_COMPRESSED_RGB:
- case GL_COMPRESSED_RGBA:
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
-#if FEATURE_EXT_texture_sRGB
- case GL_SRGB_EXT:
- case GL_SRGB8_EXT:
- case GL_SRGB_ALPHA_EXT:
- case GL_SRGB8_ALPHA8_EXT:
- case GL_SLUMINANCE_ALPHA_EXT:
- case GL_SLUMINANCE8_ALPHA8_EXT:
- case GL_SLUMINANCE_EXT:
- case GL_SLUMINANCE8_EXT:
- case GL_COMPRESSED_SRGB_EXT:
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- case GL_COMPRESSED_SLUMINANCE_EXT:
- case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
-#endif /* FEATURE_EXT_texture_sRGB */
- case GL_COMPRESSED_RED_RGTC1:
- case GL_COMPRESSED_SIGNED_RED_RGTC1:
- case GL_COMPRESSED_RG_RGTC2:
- case GL_COMPRESSED_SIGNED_RG_RGTC2:
- case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
- case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
- case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
- case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
- case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
- /* generic integer formats */
- 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:
- /* sized integer formats */
- case GL_RGBA32UI_EXT:
- case GL_RGB32UI_EXT:
- case GL_ALPHA32UI_EXT:
- case GL_INTENSITY32UI_EXT:
- case GL_LUMINANCE32UI_EXT:
- case GL_LUMINANCE_ALPHA32UI_EXT:
- case GL_RGBA16UI_EXT:
- case GL_RGB16UI_EXT:
- case GL_ALPHA16UI_EXT:
- case GL_INTENSITY16UI_EXT:
- case GL_LUMINANCE16UI_EXT:
- case GL_LUMINANCE_ALPHA16UI_EXT:
- case GL_RGBA8UI_EXT:
- case GL_RGB8UI_EXT:
- case GL_ALPHA8UI_EXT:
- case GL_INTENSITY8UI_EXT:
- case GL_LUMINANCE8UI_EXT:
- case GL_LUMINANCE_ALPHA8UI_EXT:
- case GL_RGBA32I_EXT:
- case GL_RGB32I_EXT:
- case GL_ALPHA32I_EXT:
- case GL_INTENSITY32I_EXT:
- case GL_LUMINANCE32I_EXT:
- case GL_LUMINANCE_ALPHA32I_EXT:
- case GL_RGBA16I_EXT:
- case GL_RGB16I_EXT:
- case GL_ALPHA16I_EXT:
- case GL_INTENSITY16I_EXT:
- case GL_LUMINANCE16I_EXT:
- case GL_LUMINANCE_ALPHA16I_EXT:
- case GL_RGBA8I_EXT:
- case GL_RGB8I_EXT:
- case GL_ALPHA8I_EXT:
- case GL_INTENSITY8I_EXT:
- case GL_LUMINANCE8I_EXT:
- case GL_LUMINANCE_ALPHA8I_EXT:
- /* signed, normalized texture formats */
- case GL_RED_SNORM:
- case GL_R8_SNORM:
- case GL_R16_SNORM:
- case GL_RG_SNORM:
- case GL_RG8_SNORM:
- case GL_RG16_SNORM:
- case GL_RGB_SNORM:
- case GL_RGB8_SNORM:
- case GL_RGB16_SNORM:
- case GL_RGBA_SNORM:
- case GL_RGBA8_SNORM:
- case GL_RGBA16_SNORM:
- case GL_ALPHA_SNORM:
- case GL_ALPHA8_SNORM:
- case GL_ALPHA16_SNORM:
- case GL_LUMINANCE_SNORM:
- case GL_LUMINANCE8_SNORM:
- case GL_LUMINANCE16_SNORM:
- case GL_LUMINANCE_ALPHA_SNORM:
- case GL_LUMINANCE8_ALPHA8_SNORM:
- case GL_LUMINANCE16_ALPHA16_SNORM:
- case GL_INTENSITY_SNORM:
- case GL_INTENSITY8_SNORM:
- case GL_INTENSITY16_SNORM:
- case GL_RGB9_E5:
- case GL_R11F_G11F_B10F:
- return GL_TRUE;
- case GL_YCBCR_MESA: /* not considered to be RGB */
- /* fall-through */
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a color index format.
- */
-GLboolean
-_mesa_is_index_format(GLenum format)
-{
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_COLOR_INDEX1_EXT:
- case GL_COLOR_INDEX2_EXT:
- case GL_COLOR_INDEX4_EXT:
- case GL_COLOR_INDEX8_EXT:
- case GL_COLOR_INDEX12_EXT:
- case GL_COLOR_INDEX16_EXT:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a depth component format.
- */
-GLboolean
-_mesa_is_depth_format(GLenum format)
-{
- switch (format) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- case GL_DEPTH_COMPONENT24:
- case GL_DEPTH_COMPONENT32:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a stencil format.
- */
-GLboolean
-_mesa_is_stencil_format(GLenum format)
-{
- switch (format) {
- case GL_STENCIL_INDEX:
- case GL_DEPTH_STENCIL:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a YCbCr format.
- */
-GLboolean
-_mesa_is_ycbcr_format(GLenum format)
-{
- switch (format) {
- case GL_YCBCR_MESA:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a depth+stencil format.
- */
-GLboolean
-_mesa_is_depthstencil_format(GLenum format)
-{
- switch (format) {
- case GL_DEPTH24_STENCIL8_EXT:
- case GL_DEPTH_STENCIL_EXT:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a depth or stencil format.
- */
-GLboolean
-_mesa_is_depth_or_stencil_format(GLenum format)
-{
- switch (format) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- case GL_DEPTH_COMPONENT24:
- case GL_DEPTH_COMPONENT32:
- case GL_STENCIL_INDEX:
- case GL_STENCIL_INDEX1_EXT:
- case GL_STENCIL_INDEX4_EXT:
- case GL_STENCIL_INDEX8_EXT:
- case GL_STENCIL_INDEX16_EXT:
- case GL_DEPTH_STENCIL_EXT:
- case GL_DEPTH24_STENCIL8_EXT:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a dudv format.
- */
-GLboolean
-_mesa_is_dudv_format(GLenum format)
-{
- switch (format) {
- case GL_DUDV_ATI:
- case GL_DU8DV8_ATI:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given format is an integer (non-normalized) format.
- */
-GLboolean
-_mesa_is_integer_format(GLenum format)
-{
- switch (format) {
- /* generic integer formats */
- 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:
- /* specific integer formats */
- case GL_RGBA32UI_EXT:
- case GL_RGB32UI_EXT:
- case GL_ALPHA32UI_EXT:
- case GL_INTENSITY32UI_EXT:
- case GL_LUMINANCE32UI_EXT:
- case GL_LUMINANCE_ALPHA32UI_EXT:
- case GL_RGBA16UI_EXT:
- case GL_RGB16UI_EXT:
- case GL_ALPHA16UI_EXT:
- case GL_INTENSITY16UI_EXT:
- case GL_LUMINANCE16UI_EXT:
- case GL_LUMINANCE_ALPHA16UI_EXT:
- case GL_RGBA8UI_EXT:
- case GL_RGB8UI_EXT:
- case GL_ALPHA8UI_EXT:
- case GL_INTENSITY8UI_EXT:
- case GL_LUMINANCE8UI_EXT:
- case GL_LUMINANCE_ALPHA8UI_EXT:
- case GL_RGBA32I_EXT:
- case GL_RGB32I_EXT:
- case GL_ALPHA32I_EXT:
- case GL_INTENSITY32I_EXT:
- case GL_LUMINANCE32I_EXT:
- case GL_LUMINANCE_ALPHA32I_EXT:
- case GL_RGBA16I_EXT:
- case GL_RGB16I_EXT:
- case GL_ALPHA16I_EXT:
- case GL_INTENSITY16I_EXT:
- case GL_LUMINANCE16I_EXT:
- case GL_LUMINANCE_ALPHA16I_EXT:
- case GL_RGBA8I_EXT:
- case GL_RGB8I_EXT:
- case GL_ALPHA8I_EXT:
- case GL_INTENSITY8I_EXT:
- case GL_LUMINANCE8I_EXT:
- case GL_LUMINANCE_ALPHA8I_EXT:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if an image format is a supported compressed format.
- * \param format the internal format token provided by the user.
- * \return GL_TRUE if compressed, GL_FALSE if uncompressed
- */
-GLboolean
-_mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
-{
- switch (format) {
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- return ctx->Extensions.EXT_texture_compression_s3tc;
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
- return ctx->Extensions.S3_s3tc;
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- return ctx->Extensions.EXT_texture_sRGB
- && ctx->Extensions.EXT_texture_compression_s3tc;
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- return ctx->Extensions.TDFX_texture_compression_FXT1;
- case GL_COMPRESSED_RED_RGTC1:
- case GL_COMPRESSED_SIGNED_RED_RGTC1:
- case GL_COMPRESSED_RG_RGTC2:
- case GL_COMPRESSED_SIGNED_RG_RGTC2:
- return ctx->Extensions.ARB_texture_compression_rgtc;
- case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
- case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
- case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
- case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
- return ctx->Extensions.EXT_texture_compression_latc;
- case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
- return ctx->Extensions.ATI_texture_compression_3dc;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Return the address of a specific pixel in an image (1D, 2D or 3D).
- *
- * Pixel unpacking/packing parameters are observed according to \p packing.
- *
- * \param dimensions either 1, 2 or 3 to indicate dimensionality of image
- * \param image starting address of image data
- * \param width the image width
- * \param height theimage height
- * \param format the pixel format
- * \param type the pixel data type
- * \param packing the pixelstore attributes
- * \param img which image in the volume (0 for 1D or 2D images)
- * \param row row of pixel in the image (0 for 1D images)
- * \param column column of pixel in the image
- *
- * \return address of pixel on success, or NULL on error.
- *
- * \sa gl_pixelstore_attrib.
- */
-GLvoid *
-_mesa_image_address( GLuint dimensions,
- const struct gl_pixelstore_attrib *packing,
- const GLvoid *image,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- GLint img, GLint row, GLint column )
-{
- GLint alignment; /* 1, 2 or 4 */
- GLint pixels_per_row;
- GLint rows_per_image;
- GLint skiprows;
- GLint skippixels;
- GLint skipimages; /* for 3-D volume images */
- GLubyte *pixel_addr;
-
- ASSERT(dimensions >= 1 && dimensions <= 3);
-
- alignment = packing->Alignment;
- if (packing->RowLength > 0) {
- pixels_per_row = packing->RowLength;
- }
- else {
- pixels_per_row = width;
- }
- if (packing->ImageHeight > 0) {
- rows_per_image = packing->ImageHeight;
- }
- else {
- rows_per_image = height;
- }
-
- skippixels = packing->SkipPixels;
- /* Note: SKIP_ROWS _is_ used for 1D images */
- skiprows = packing->SkipRows;
- /* Note: SKIP_IMAGES is only used for 3D images */
- skipimages = (dimensions == 3) ? packing->SkipImages : 0;
-
- if (type == GL_BITMAP) {
- /* BITMAP data */
- GLint comp_per_pixel; /* components per pixel */
- GLint bytes_per_comp; /* bytes per component */
- GLint bytes_per_row;
- GLint bytes_per_image;
-
- /* Compute bytes per component */
- bytes_per_comp = _mesa_sizeof_packed_type( type );
- if (bytes_per_comp < 0) {
- return NULL;
- }
-
- /* Compute number of components per pixel */
- comp_per_pixel = _mesa_components_in_format( format );
- if (comp_per_pixel < 0) {
- return NULL;
- }
-
- bytes_per_row = alignment
- * CEILING( comp_per_pixel*pixels_per_row, 8*alignment );
-
- bytes_per_image = bytes_per_row * rows_per_image;
-
- pixel_addr = (GLubyte *) image
- + (skipimages + img) * bytes_per_image
- + (skiprows + row) * bytes_per_row
- + (skippixels + column) / 8;
- }
- else {
- /* Non-BITMAP data */
- GLint bytes_per_pixel, bytes_per_row, remainder, bytes_per_image;
- GLint topOfImage;
-
- bytes_per_pixel = _mesa_bytes_per_pixel( format, type );
-
- /* The pixel type and format should have been error checked earlier */
- assert(bytes_per_pixel > 0);
-
- bytes_per_row = pixels_per_row * bytes_per_pixel;
- remainder = bytes_per_row % alignment;
- if (remainder > 0)
- bytes_per_row += (alignment - remainder);
-
- ASSERT(bytes_per_row % alignment == 0);
-
- bytes_per_image = bytes_per_row * rows_per_image;
-
- if (packing->Invert) {
- /* set pixel_addr to the last row */
- topOfImage = bytes_per_row * (height - 1);
- bytes_per_row = -bytes_per_row;
- }
- else {
- topOfImage = 0;
- }
-
- /* compute final pixel address */
- pixel_addr = (GLubyte *) image
- + (skipimages + img) * bytes_per_image
- + topOfImage
- + (skiprows + row) * bytes_per_row
- + (skippixels + column) * bytes_per_pixel;
- }
-
- return (GLvoid *) pixel_addr;
-}
-
-
-GLvoid *
-_mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
- const GLvoid *image,
- GLsizei width,
- GLenum format, GLenum type,
- GLint column )
-{
- return _mesa_image_address(1, packing, image, width, 1,
- format, type, 0, 0, column);
-}
-
-
-GLvoid *
-_mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
- const GLvoid *image,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- GLint row, GLint column )
-{
- return _mesa_image_address(2, packing, image, width, height,
- format, type, 0, row, column);
-}
-
-
-GLvoid *
-_mesa_image_address3d( const struct gl_pixelstore_attrib *packing,
- const GLvoid *image,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- GLint img, GLint row, GLint column )
-{
- return _mesa_image_address(3, packing, image, width, height,
- format, type, img, row, column);
-}
-
-
-
-/**
- * Compute the stride (in bytes) between image rows.
- *
- * \param packing the pixelstore attributes
- * \param width image width.
- * \param format pixel format.
- * \param type pixel data type.
- *
- * \return the stride in bytes for the given parameters, or -1 if error
- */
-GLint
-_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
- GLint width, GLenum format, GLenum type )
-{
- GLint bytesPerRow, remainder;
-
- ASSERT(packing);
-
- if (type == GL_BITMAP) {
- if (packing->RowLength == 0) {
- bytesPerRow = (width + 7) / 8;
- }
- else {
- bytesPerRow = (packing->RowLength + 7) / 8;
- }
- }
- else {
- /* Non-BITMAP data */
- const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
- if (bytesPerPixel <= 0)
- return -1; /* error */
- if (packing->RowLength == 0) {
- bytesPerRow = bytesPerPixel * width;
- }
- else {
- bytesPerRow = bytesPerPixel * packing->RowLength;
- }
- }
-
- remainder = bytesPerRow % packing->Alignment;
- if (remainder > 0) {
- bytesPerRow += (packing->Alignment - remainder);
- }
-
- if (packing->Invert) {
- /* negate the bytes per row (negative row stride) */
- bytesPerRow = -bytesPerRow;
- }
-
- return bytesPerRow;
-}
-
-
-/*
- * Compute the stride between images in a 3D texture (in bytes) for the given
- * pixel packing parameters and image width, format and type.
- */
-GLint
-_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
- GLint width, GLint height,
- GLenum format, GLenum type )
-{
- GLint bytesPerRow, bytesPerImage, remainder;
-
- ASSERT(packing);
-
- if (type == GL_BITMAP) {
- if (packing->RowLength == 0) {
- bytesPerRow = (width + 7) / 8;
- }
- else {
- bytesPerRow = (packing->RowLength + 7) / 8;
- }
- }
- else {
- const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
-
- if (bytesPerPixel <= 0)
- return -1; /* error */
- if (packing->RowLength == 0) {
- bytesPerRow = bytesPerPixel * width;
- }
- else {
- bytesPerRow = bytesPerPixel * packing->RowLength;
- }
- }
-
- remainder = bytesPerRow % packing->Alignment;
- if (remainder > 0)
- bytesPerRow += (packing->Alignment - remainder);
-
- if (packing->ImageHeight == 0)
- bytesPerImage = bytesPerRow * height;
- else
- bytesPerImage = bytesPerRow * packing->ImageHeight;
-
- return bytesPerImage;
-}
-
-
-
-/**
- * "Expand" a bitmap from 1-bit per pixel to 8-bits per pixel.
- * This is typically used to convert a bitmap into a GLubyte/pixel texture.
- * "On" bits will set texels to \p onValue.
- * "Off" bits will not modify texels.
- * \param width src bitmap width in pixels
- * \param height src bitmap height in pixels
- * \param unpack bitmap unpacking state
- * \param bitmap the src bitmap data
- * \param destBuffer start of dest buffer
- * \param destStride row stride in dest buffer
- * \param onValue if bit is 1, set destBuffer pixel to this value
- */
-void
-_mesa_expand_bitmap(GLsizei width, GLsizei height,
- const struct gl_pixelstore_attrib *unpack,
- const GLubyte *bitmap,
- GLubyte *destBuffer, GLint destStride,
- GLubyte onValue)
-{
- const GLubyte *srcRow = (const GLubyte *)
- _mesa_image_address2d(unpack, bitmap, width, height,
- GL_COLOR_INDEX, GL_BITMAP, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(unpack, width,
- GL_COLOR_INDEX, GL_BITMAP);
- GLint row, col;
-
-#define SET_PIXEL(COL, ROW) \
- destBuffer[(ROW) * destStride + (COL)] = onValue;
-
- for (row = 0; row < height; row++) {
- const GLubyte *src = srcRow;
-
- if (unpack->LsbFirst) {
- /* Lsb first */
- GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
- for (col = 0; col < width; col++) {
-
- if (*src & mask) {
- SET_PIXEL(col, row);
- }
-
- if (mask == 128U) {
- src++;
- mask = 1U;
- }
- else {
- mask = mask << 1;
- }
- }
-
- /* get ready for next row */
- if (mask != 1)
- src++;
- }
- else {
- /* Msb first */
- GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
- for (col = 0; col < width; col++) {
-
- if (*src & mask) {
- SET_PIXEL(col, row);
- }
-
- if (mask == 1U) {
- src++;
- mask = 128U;
- }
- else {
- mask = mask >> 1;
- }
- }
-
- /* get ready for next row */
- if (mask != 128)
- src++;
- }
-
- srcRow += srcStride;
- } /* row */
-
-#undef SET_PIXEL
-}
-
-
-
-
-/**
- * Convert an array of RGBA colors from one datatype to another.
- * NOTE: src may equal dst. In that case, we use a temporary buffer.
- */
-void
-_mesa_convert_colors(GLenum srcType, const GLvoid *src,
- GLenum dstType, GLvoid *dst,
- GLuint count, const GLubyte mask[])
-{
- GLuint tempBuffer[MAX_WIDTH][4];
- const GLboolean useTemp = (src == dst);
-
- ASSERT(srcType != dstType);
-
- switch (srcType) {
- case GL_UNSIGNED_BYTE:
- if (dstType == GL_UNSIGNED_SHORT) {
- const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src;
- GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst);
- GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst2[i][RCOMP] = UBYTE_TO_USHORT(src1[i][RCOMP]);
- dst2[i][GCOMP] = UBYTE_TO_USHORT(src1[i][GCOMP]);
- dst2[i][BCOMP] = UBYTE_TO_USHORT(src1[i][BCOMP]);
- dst2[i][ACOMP] = UBYTE_TO_USHORT(src1[i][ACOMP]);
- }
- }
- if (useTemp)
- memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort));
- }
- else {
- const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src;
- GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst);
- GLuint i;
- ASSERT(dstType == GL_FLOAT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst4[i][RCOMP] = UBYTE_TO_FLOAT(src1[i][RCOMP]);
- dst4[i][GCOMP] = UBYTE_TO_FLOAT(src1[i][GCOMP]);
- dst4[i][BCOMP] = UBYTE_TO_FLOAT(src1[i][BCOMP]);
- dst4[i][ACOMP] = UBYTE_TO_FLOAT(src1[i][ACOMP]);
- }
- }
- if (useTemp)
- memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat));
- }
- break;
- case GL_UNSIGNED_SHORT:
- if (dstType == GL_UNSIGNED_BYTE) {
- const GLushort (*src2)[4] = (const GLushort (*)[4]) src;
- GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst);
- GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst1[i][RCOMP] = USHORT_TO_UBYTE(src2[i][RCOMP]);
- dst1[i][GCOMP] = USHORT_TO_UBYTE(src2[i][GCOMP]);
- dst1[i][BCOMP] = USHORT_TO_UBYTE(src2[i][BCOMP]);
- dst1[i][ACOMP] = USHORT_TO_UBYTE(src2[i][ACOMP]);
- }
- }
- if (useTemp)
- memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte));
- }
- else {
- const GLushort (*src2)[4] = (const GLushort (*)[4]) src;
- GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst);
- GLuint i;
- ASSERT(dstType == GL_FLOAT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst4[i][RCOMP] = USHORT_TO_FLOAT(src2[i][RCOMP]);
- dst4[i][GCOMP] = USHORT_TO_FLOAT(src2[i][GCOMP]);
- dst4[i][BCOMP] = USHORT_TO_FLOAT(src2[i][BCOMP]);
- dst4[i][ACOMP] = USHORT_TO_FLOAT(src2[i][ACOMP]);
- }
- }
- if (useTemp)
- memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat));
- }
- break;
- case GL_FLOAT:
- if (dstType == GL_UNSIGNED_BYTE) {
- const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src;
- GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst);
- GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][RCOMP], src4[i][RCOMP]);
- UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][GCOMP], src4[i][GCOMP]);
- UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][BCOMP], src4[i][BCOMP]);
- UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][ACOMP], src4[i][ACOMP]);
- }
- }
- if (useTemp)
- memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte));
- }
- else {
- const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src;
- GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst);
- GLuint i;
- ASSERT(dstType == GL_UNSIGNED_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- UNCLAMPED_FLOAT_TO_USHORT(dst2[i][RCOMP], src4[i][RCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(dst2[i][GCOMP], src4[i][GCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(dst2[i][BCOMP], src4[i][BCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(dst2[i][ACOMP], src4[i][ACOMP]);
- }
- }
- if (useTemp)
- memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort));
- }
- break;
- default:
- _mesa_problem(NULL, "Invalid datatype in _mesa_convert_colors");
- }
-}
-
-
-
-
-/**
- * Perform basic clipping for glDrawPixels. The image's position and size
- * and the unpack SkipPixels and SkipRows are adjusted so that the image
- * region is entirely within the window and scissor bounds.
- * NOTE: this will only work when glPixelZoom is (1, 1) or (1, -1).
- * If Pixel.ZoomY is -1, *destY will be changed to be the first row which
- * we'll actually write. Beforehand, *destY-1 is the first drawing row.
- *
- * \return GL_TRUE if image is ready for drawing or
- * GL_FALSE if image was completely clipped away (draw nothing)
- */
-GLboolean
-_mesa_clip_drawpixels(const struct gl_context *ctx,
- GLint *destX, GLint *destY,
- GLsizei *width, GLsizei *height,
- struct gl_pixelstore_attrib *unpack)
-{
- const struct gl_framebuffer *buffer = ctx->DrawBuffer;
-
- if (unpack->RowLength == 0) {
- unpack->RowLength = *width;
- }
-
- ASSERT(ctx->Pixel.ZoomX == 1.0F);
- ASSERT(ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F);
-
- /* left clipping */
- if (*destX < buffer->_Xmin) {
- unpack->SkipPixels += (buffer->_Xmin - *destX);
- *width -= (buffer->_Xmin - *destX);
- *destX = buffer->_Xmin;
- }
- /* right clipping */
- if (*destX + *width > buffer->_Xmax)
- *width -= (*destX + *width - buffer->_Xmax);
-
- if (*width <= 0)
- return GL_FALSE;
-
- if (ctx->Pixel.ZoomY == 1.0F) {
- /* bottom clipping */
- if (*destY < buffer->_Ymin) {
- unpack->SkipRows += (buffer->_Ymin - *destY);
- *height -= (buffer->_Ymin - *destY);
- *destY = buffer->_Ymin;
- }
- /* top clipping */
- if (*destY + *height > buffer->_Ymax)
- *height -= (*destY + *height - buffer->_Ymax);
- }
- else { /* upside down */
- /* top clipping */
- if (*destY > buffer->_Ymax) {
- unpack->SkipRows += (*destY - buffer->_Ymax);
- *height -= (*destY - buffer->_Ymax);
- *destY = buffer->_Ymax;
- }
- /* bottom clipping */
- if (*destY - *height < buffer->_Ymin)
- *height -= (buffer->_Ymin - (*destY - *height));
- /* adjust destY so it's the first row to write to */
- (*destY)--;
- }
-
- if (*height <= 0)
- return GL_FALSE;
-
- return GL_TRUE;
-}
-
-
-/**
- * Perform clipping for glReadPixels. The image's window position
- * and size, and the pack skipPixels, skipRows and rowLength are adjusted
- * so that the image region is entirely within the window bounds.
- * Note: this is different from _mesa_clip_drawpixels() in that the
- * scissor box is ignored, and we use the bounds of the current readbuffer
- * surface.
- *
- * \return GL_TRUE if region to read is in bounds
- * GL_FALSE if region is completely out of bounds (nothing to read)
- */
-GLboolean
-_mesa_clip_readpixels(const struct gl_context *ctx,
- GLint *srcX, GLint *srcY,
- GLsizei *width, GLsizei *height,
- struct gl_pixelstore_attrib *pack)
-{
- const struct gl_framebuffer *buffer = ctx->ReadBuffer;
-
- if (pack->RowLength == 0) {
- pack->RowLength = *width;
- }
-
- /* left clipping */
- if (*srcX < 0) {
- pack->SkipPixels += (0 - *srcX);
- *width -= (0 - *srcX);
- *srcX = 0;
- }
- /* right clipping */
- if (*srcX + *width > (GLsizei) buffer->Width)
- *width -= (*srcX + *width - buffer->Width);
-
- if (*width <= 0)
- return GL_FALSE;
-
- /* bottom clipping */
- if (*srcY < 0) {
- pack->SkipRows += (0 - *srcY);
- *height -= (0 - *srcY);
- *srcY = 0;
- }
- /* top clipping */
- if (*srcY + *height > (GLsizei) buffer->Height)
- *height -= (*srcY + *height - buffer->Height);
-
- if (*height <= 0)
- return GL_FALSE;
-
- return GL_TRUE;
-}
-
-
-/**
- * Do clipping for a glCopyTexSubImage call.
- * The framebuffer source region might extend outside the framebuffer
- * bounds. Clip the source region against the framebuffer bounds and
- * adjust the texture/dest position and size accordingly.
- *
- * \return GL_FALSE if region is totally clipped, GL_TRUE otherwise.
- */
-GLboolean
-_mesa_clip_copytexsubimage(const struct gl_context *ctx,
- GLint *destX, GLint *destY,
- GLint *srcX, GLint *srcY,
- GLsizei *width, GLsizei *height)
-{
- const struct gl_framebuffer *fb = ctx->ReadBuffer;
- const GLint srcX0 = *srcX, srcY0 = *srcY;
-
- if (_mesa_clip_to_region(0, 0, fb->Width, fb->Height,
- srcX, srcY, width, height)) {
- *destX = *destX + *srcX - srcX0;
- *destY = *destY + *srcY - srcY0;
-
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-
-
-
-/**
- * Clip the rectangle defined by (x, y, width, height) against the bounds
- * specified by [xmin, xmax) and [ymin, ymax).
- * \return GL_FALSE if rect is totally clipped, GL_TRUE otherwise.
- */
-GLboolean
-_mesa_clip_to_region(GLint xmin, GLint ymin,
- GLint xmax, GLint ymax,
- GLint *x, GLint *y,
- GLsizei *width, GLsizei *height )
-{
- /* left clipping */
- if (*x < xmin) {
- *width -= (xmin - *x);
- *x = xmin;
- }
-
- /* right clipping */
- if (*x + *width > xmax)
- *width -= (*x + *width - xmax);
-
- if (*width <= 0)
- return GL_FALSE;
-
- /* bottom (or top) clipping */
- if (*y < ymin) {
- *height -= (ymin - *y);
- *y = ymin;
- }
-
- /* top (or bottom) clipping */
- if (*y + *height > ymax)
- *height -= (*y + *height - ymax);
-
- if (*height <= 0)
- return GL_FALSE;
-
- return GL_TRUE;
-}
-
-
-/**
- * Clip dst coords against Xmax (or Ymax).
- */
-static INLINE void
-clip_right_or_top(GLint *srcX0, GLint *srcX1,
- GLint *dstX0, GLint *dstX1,
- GLint maxValue)
-{
- GLfloat t, bias;
-
- if (*dstX1 > maxValue) {
- /* X1 outside right edge */
- ASSERT(*dstX0 < maxValue); /* X0 should be inside right edge */
- t = (GLfloat) (maxValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0);
- /* chop off [t, 1] part */
- ASSERT(t >= 0.0 && t <= 1.0);
- *dstX1 = maxValue;
- bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F;
- *srcX1 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
- }
- else if (*dstX0 > maxValue) {
- /* X0 outside right edge */
- ASSERT(*dstX1 < maxValue); /* X1 should be inside right edge */
- t = (GLfloat) (maxValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1);
- /* chop off [t, 1] part */
- ASSERT(t >= 0.0 && t <= 1.0);
- *dstX0 = maxValue;
- bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F;
- *srcX0 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
- }
-}
-
-
-/**
- * Clip dst coords against Xmin (or Ymin).
- */
-static INLINE void
-clip_left_or_bottom(GLint *srcX0, GLint *srcX1,
- GLint *dstX0, GLint *dstX1,
- GLint minValue)
-{
- GLfloat t, bias;
-
- if (*dstX0 < minValue) {
- /* X0 outside left edge */
- ASSERT(*dstX1 > minValue); /* X1 should be inside left edge */
- t = (GLfloat) (minValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0);
- /* chop off [0, t] part */
- ASSERT(t >= 0.0 && t <= 1.0);
- *dstX0 = minValue;
- bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; /* flipped??? */
- *srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
- }
- else if (*dstX1 < minValue) {
- /* X1 outside left edge */
- ASSERT(*dstX0 > minValue); /* X0 should be inside left edge */
- t = (GLfloat) (minValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1);
- /* chop off [0, t] part */
- ASSERT(t >= 0.0 && t <= 1.0);
- *dstX1 = minValue;
- bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F;
- *srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
- }
-}
-
-
-/**
- * Do clipping of blit src/dest rectangles.
- * The dest rect is clipped against both the buffer bounds and scissor bounds.
- * The src rect is just clipped against the buffer bounds.
- *
- * When either the src or dest rect is clipped, the other is also clipped
- * proportionately!
- *
- * Note that X0 need not be less than X1 (same for Y) for either the source
- * and dest rects. That makes the clipping a little trickier.
- *
- * \return GL_TRUE if anything is left to draw, GL_FALSE if totally clipped
- */
-GLboolean
-_mesa_clip_blit(struct gl_context *ctx,
- GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1,
- GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1)
-{
- const GLint srcXmin = 0;
- const GLint srcXmax = ctx->ReadBuffer->Width;
- const GLint srcYmin = 0;
- const GLint srcYmax = ctx->ReadBuffer->Height;
-
- /* these include scissor bounds */
- const GLint dstXmin = ctx->DrawBuffer->_Xmin;
- const GLint dstXmax = ctx->DrawBuffer->_Xmax;
- const GLint dstYmin = ctx->DrawBuffer->_Ymin;
- const GLint dstYmax = ctx->DrawBuffer->_Ymax;
-
- /*
- printf("PreClipX: src: %d .. %d dst: %d .. %d\n",
- *srcX0, *srcX1, *dstX0, *dstX1);
- printf("PreClipY: src: %d .. %d dst: %d .. %d\n",
- *srcY0, *srcY1, *dstY0, *dstY1);
- */
-
- /* trivial rejection tests */
- if (*dstX0 == *dstX1)
- return GL_FALSE; /* no width */
- if (*dstX0 <= dstXmin && *dstX1 <= dstXmin)
- return GL_FALSE; /* totally out (left) of bounds */
- if (*dstX0 >= dstXmax && *dstX1 >= dstXmax)
- return GL_FALSE; /* totally out (right) of bounds */
-
- if (*dstY0 == *dstY1)
- return GL_FALSE;
- if (*dstY0 <= dstYmin && *dstY1 <= dstYmin)
- return GL_FALSE;
- if (*dstY0 >= dstYmax && *dstY1 >= dstYmax)
- return GL_FALSE;
-
- if (*srcX0 == *srcX1)
- return GL_FALSE;
- if (*srcX0 <= srcXmin && *srcX1 <= srcXmin)
- return GL_FALSE;
- if (*srcX0 >= srcXmax && *srcX1 >= srcXmax)
- return GL_FALSE;
-
- if (*srcY0 == *srcY1)
- return GL_FALSE;
- if (*srcY0 <= srcYmin && *srcY1 <= srcYmin)
- return GL_FALSE;
- if (*srcY0 >= srcYmax && *srcY1 >= srcYmax)
- return GL_FALSE;
-
- /*
- * dest clip
- */
- clip_right_or_top(srcX0, srcX1, dstX0, dstX1, dstXmax);
- clip_right_or_top(srcY0, srcY1, dstY0, dstY1, dstYmax);
- clip_left_or_bottom(srcX0, srcX1, dstX0, dstX1, dstXmin);
- clip_left_or_bottom(srcY0, srcY1, dstY0, dstY1, dstYmin);
-
- /*
- * src clip (just swap src/dst values from above)
- */
- clip_right_or_top(dstX0, dstX1, srcX0, srcX1, srcXmax);
- clip_right_or_top(dstY0, dstY1, srcY0, srcY1, srcYmax);
- clip_left_or_bottom(dstX0, dstX1, srcX0, srcX1, srcXmin);
- clip_left_or_bottom(dstY0, dstY1, srcY0, srcY1, srcYmin);
-
- /*
- printf("PostClipX: src: %d .. %d dst: %d .. %d\n",
- *srcX0, *srcX1, *dstX0, *dstX1);
- printf("PostClipY: src: %d .. %d dst: %d .. %d\n",
- *srcY0, *srcY1, *dstY0, *dstY1);
- */
-
- ASSERT(*dstX0 >= dstXmin);
- ASSERT(*dstX0 <= dstXmax);
- ASSERT(*dstX1 >= dstXmin);
- ASSERT(*dstX1 <= dstXmax);
-
- ASSERT(*dstY0 >= dstYmin);
- ASSERT(*dstY0 <= dstYmax);
- ASSERT(*dstY1 >= dstYmin);
- ASSERT(*dstY1 <= dstYmax);
-
- ASSERT(*srcX0 >= srcXmin);
- ASSERT(*srcX0 <= srcXmax);
- ASSERT(*srcX1 >= srcXmin);
- ASSERT(*srcX1 <= srcXmax);
-
- ASSERT(*srcY0 >= srcYmin);
- ASSERT(*srcY0 <= srcYmax);
- ASSERT(*srcY1 >= srcYmin);
- ASSERT(*srcY1 <= srcYmax);
-
- return GL_TRUE;
-}
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.5
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file image.c
+ * Image handling.
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "image.h"
+#include "imports.h"
+#include "macros.h"
+#include "mfeatures.h"
+#include "mtypes.h"
+
+
+/**
+ * NOTE:
+ * Normally, BYTE_TO_FLOAT(0) returns 0.00392 That causes problems when
+ * we later convert the float to a packed integer value (such as for
+ * GL_RGB5_A1) because we'll wind up with a non-zero value.
+ *
+ * We redefine the macros here so zero is handled correctly.
+ */
+#undef BYTE_TO_FLOAT
+#define BYTE_TO_FLOAT(B) ((B) == 0 ? 0.0F : ((2.0F * (B) + 1.0F) * (1.0F/255.0F)))
+
+#undef SHORT_TO_FLOAT
+#define SHORT_TO_FLOAT(S) ((S) == 0 ? 0.0F : ((2.0F * (S) + 1.0F) * (1.0F/65535.0F)))
+
+
+
+/** Compute ceiling of integer quotient of A divided by B. */
+#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
+
+
+/**
+ * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise.
+ */
+GLboolean
+_mesa_type_is_packed(GLenum type)
+{
+ switch (type) {
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case MESA_UNSIGNED_BYTE_4_4:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ case GL_UNSIGNED_INT_24_8_EXT:
+ case GL_UNSIGNED_INT_5_9_9_9_REV:
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return GL_TRUE;
+ }
+
+ return GL_FALSE;
+}
+
+
+
+/**
+ * Flip the order of the 2 bytes in each word in the given array.
+ *
+ * \param p array.
+ * \param n number of words.
+ */
+void
+_mesa_swap2( GLushort *p, GLuint n )
+{
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00);
+ }
+}
+
+
+
+/*
+ * Flip the order of the 4 bytes in each word in the given array.
+ */
+void
+_mesa_swap4( GLuint *p, GLuint n )
+{
+ GLuint i, a, b;
+ for (i = 0; i < n; i++) {
+ b = p[i];
+ a = (b >> 24)
+ | ((b >> 8) & 0xff00)
+ | ((b << 8) & 0xff0000)
+ | ((b << 24) & 0xff000000);
+ p[i] = a;
+ }
+}
+
+
+/**
+ * Get the size of a GL data type.
+ *
+ * \param type GL data type.
+ *
+ * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1
+ * if an invalid type enum.
+ */
+GLint
+_mesa_sizeof_type( GLenum type )
+{
+ switch (type) {
+ case GL_BITMAP:
+ return 0;
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLubyte);
+ case GL_BYTE:
+ return sizeof(GLbyte);
+ case GL_UNSIGNED_SHORT:
+ return sizeof(GLushort);
+ case GL_SHORT:
+ return sizeof(GLshort);
+ case GL_UNSIGNED_INT:
+ return sizeof(GLuint);
+ case GL_INT:
+ return sizeof(GLint);
+ case GL_FLOAT:
+ return sizeof(GLfloat);
+ case GL_DOUBLE:
+ return sizeof(GLdouble);
+ case GL_HALF_FLOAT_ARB:
+ return sizeof(GLhalfARB);
+ case GL_FIXED:
+ return sizeof(GLfixed);
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Same as _mesa_sizeof_type() but also accepting the packed pixel
+ * format data types.
+ */
+GLint
+_mesa_sizeof_packed_type( GLenum type )
+{
+ switch (type) {
+ case GL_BITMAP:
+ return 0;
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLubyte);
+ case GL_BYTE:
+ return sizeof(GLbyte);
+ case GL_UNSIGNED_SHORT:
+ return sizeof(GLushort);
+ case GL_SHORT:
+ return sizeof(GLshort);
+ case GL_UNSIGNED_INT:
+ return sizeof(GLuint);
+ case GL_INT:
+ return sizeof(GLint);
+ case GL_HALF_FLOAT_ARB:
+ return sizeof(GLhalfARB);
+ case GL_FLOAT:
+ return sizeof(GLfloat);
+ case GL_UNSIGNED_BYTE_3_3_2:
+ return sizeof(GLubyte);
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ return sizeof(GLubyte);
+ case MESA_UNSIGNED_BYTE_4_4:
+ return sizeof(GLubyte);
+ case GL_UNSIGNED_SHORT_5_6_5:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_INT_8_8_8_8:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_INT_10_10_10_2:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_INT_24_8_EXT:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_INT_5_9_9_9_REV:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ return sizeof(GLuint);
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return 8;
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Get the number of components in a pixel format.
+ *
+ * \param format pixel format.
+ *
+ * \return the number of components in the given format, or -1 if a bad format.
+ */
+GLint
+_mesa_components_in_format( GLenum format )
+{
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_COLOR_INDEX1_EXT:
+ case GL_COLOR_INDEX2_EXT:
+ case GL_COLOR_INDEX4_EXT:
+ case GL_COLOR_INDEX8_EXT:
+ case GL_COLOR_INDEX12_EXT:
+ case GL_COLOR_INDEX16_EXT:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_RED:
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_INTENSITY:
+ return 1;
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ case GL_RG:
+ return 2;
+ case GL_RGB:
+ case GL_RGB_INTEGER_EXT:
+ return 3;
+ case GL_RGBA:
+ case GL_RGBA_INTEGER_EXT:
+ return 4;
+ case GL_BGR:
+ return 3;
+ case GL_BGRA:
+ return 4;
+ case GL_ABGR_EXT:
+ return 4;
+ case GL_YCBCR_MESA:
+ return 2;
+ case GL_DEPTH_STENCIL_EXT:
+ return 2;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ return 2;
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Get the bytes per pixel of pixel format type pair.
+ *
+ * \param format pixel format.
+ * \param type pixel type.
+ *
+ * \return bytes per pixel, or -1 if a bad format or type was given.
+ */
+GLint
+_mesa_bytes_per_pixel( GLenum format, GLenum type )
+{
+ GLint comps = _mesa_components_in_format( format );
+ if (comps < 0)
+ return -1;
+
+ switch (type) {
+ case GL_BITMAP:
+ return 0; /* special case */
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ return comps * sizeof(GLubyte);
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ return comps * sizeof(GLshort);
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return comps * sizeof(GLint);
+ case GL_FLOAT:
+ return comps * sizeof(GLfloat);
+ case GL_HALF_FLOAT_ARB:
+ return comps * sizeof(GLhalfARB);
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ if (format == GL_RGB || format == GL_BGR ||
+ format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT)
+ return sizeof(GLubyte);
+ else
+ return -1; /* error */
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (format == GL_RGB || format == GL_BGR ||
+ format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT)
+ return sizeof(GLushort);
+ else
+ return -1; /* error */
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
+ format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
+ return sizeof(GLushort);
+ else
+ return -1;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
+ format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
+ return sizeof(GLuint);
+ else
+ return -1;
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ if (format == GL_YCBCR_MESA)
+ return sizeof(GLushort);
+ else
+ return -1;
+ case GL_UNSIGNED_INT_24_8_EXT:
+ if (format == GL_DEPTH_STENCIL_EXT)
+ return sizeof(GLuint);
+ else
+ return -1;
+ case GL_UNSIGNED_INT_5_9_9_9_REV:
+ if (format == GL_RGB)
+ return sizeof(GLuint);
+ else
+ return -1;
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ if (format == GL_RGB)
+ return sizeof(GLuint);
+ else
+ return -1;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ if (format == GL_DEPTH_STENCIL)
+ return 8;
+ else
+ return -1;
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Test for a legal pixel format and type.
+ *
+ * \param format pixel format.
+ * \param type pixel type.
+ *
+ * \return GL_TRUE if the given pixel format and type are legal, or GL_FALSE
+ * otherwise.
+ */
+GLboolean
+_mesa_is_legal_format_and_type(const struct gl_context *ctx,
+ GLenum format, GLenum type)
+{
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ switch (type) {
+ case GL_BITMAP:
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+#if 0 /* not legal! see table 3.6 of the 1.5 spec */
+ case GL_INTENSITY:
+#endif
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_DEPTH_COMPONENT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_RG:
+ if (!ctx->Extensions.ARB_texture_rg)
+ return GL_FALSE;
+
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_RGB:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ case GL_UNSIGNED_INT_5_9_9_9_REV:
+ return ctx->Extensions.EXT_texture_shared_exponent;
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ return ctx->Extensions.EXT_packed_float;
+ default:
+ return GL_FALSE;
+ }
+ case GL_BGR:
+ switch (type) {
+ /* NOTE: no packed types are supported with BGR. That's
+ * intentional, according to the GL spec.
+ */
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
+ type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
+ return GL_TRUE;
+ else
+ return GL_FALSE;
+ case GL_DEPTH_STENCIL_EXT:
+ if ((ctx->Extensions.EXT_packed_depth_stencil &&
+ type == GL_UNSIGNED_INT_24_8_EXT) ||
+ (ctx->Extensions.ARB_depth_buffer_float &&
+ type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV))
+ return GL_TRUE;
+ else
+ return GL_FALSE;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+
+ /* integer-valued formats */
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return ctx->Extensions.EXT_texture_integer;
+ default:
+ return GL_FALSE;
+ }
+
+ case GL_RGB_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return ctx->Extensions.EXT_texture_integer;
+ default:
+ return GL_FALSE;
+ }
+
+ case GL_BGR_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ /* NOTE: no packed formats w/ BGR format */
+ return ctx->Extensions.EXT_texture_integer;
+ default:
+ return GL_FALSE;
+ }
+
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return ctx->Extensions.EXT_texture_integer;
+ default:
+ return GL_FALSE;
+ }
+
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return ctx->Extensions.EXT_texture_integer;
+ default:
+ return GL_FALSE;
+ }
+
+ default:
+ ; /* fall-through */
+ }
+ return GL_FALSE;
+}
+
+
+/**
+ * Test if the given image format is a color/RGBA format (i.e., not color
+ * index, depth, stencil, etc).
+ * \param format the image format value (may by an internal texture format)
+ * \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise.
+ */
+GLboolean
+_mesa_is_color_format(GLenum format)
+{
+ switch (format) {
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_R8:
+ case GL_R16:
+ case GL_RG:
+ case GL_RG8:
+ case GL_RG16:
+ case 3:
+ case GL_RGB:
+ case GL_BGR:
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ case 4:
+ case GL_ABGR_EXT:
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ /* float texture formats */
+ case GL_ALPHA16F_ARB:
+ case GL_ALPHA32F_ARB:
+ case GL_LUMINANCE16F_ARB:
+ case GL_LUMINANCE32F_ARB:
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ case GL_INTENSITY16F_ARB:
+ case GL_INTENSITY32F_ARB:
+ case GL_R16F:
+ case GL_R32F:
+ case GL_RG16F:
+ case GL_RG32F:
+ case GL_RGB16F_ARB:
+ case GL_RGB32F_ARB:
+ case GL_RGBA16F_ARB:
+ case GL_RGBA32F_ARB:
+ /* compressed formats */
+ case GL_COMPRESSED_ALPHA:
+ case GL_COMPRESSED_LUMINANCE:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ case GL_COMPRESSED_INTENSITY:
+ case GL_COMPRESSED_RED:
+ case GL_COMPRESSED_RG:
+ case GL_COMPRESSED_RGB:
+ case GL_COMPRESSED_RGBA:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+#if FEATURE_EXT_texture_sRGB
+ case GL_SRGB_EXT:
+ case GL_SRGB8_EXT:
+ case GL_SRGB_ALPHA_EXT:
+ case GL_SRGB8_ALPHA8_EXT:
+ case GL_SLUMINANCE_ALPHA_EXT:
+ case GL_SLUMINANCE8_ALPHA8_EXT:
+ case GL_SLUMINANCE_EXT:
+ case GL_SLUMINANCE8_EXT:
+ case GL_COMPRESSED_SRGB_EXT:
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ case GL_COMPRESSED_SLUMINANCE_EXT:
+ case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
+#endif /* FEATURE_EXT_texture_sRGB */
+ case GL_COMPRESSED_RED_RGTC1:
+ case GL_COMPRESSED_SIGNED_RED_RGTC1:
+ case GL_COMPRESSED_RG_RGTC2:
+ case GL_COMPRESSED_SIGNED_RG_RGTC2:
+ case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+ /* generic integer formats */
+ 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:
+ /* sized integer formats */
+ case GL_RGBA32UI_EXT:
+ case GL_RGB32UI_EXT:
+ case GL_ALPHA32UI_EXT:
+ case GL_INTENSITY32UI_EXT:
+ case GL_LUMINANCE32UI_EXT:
+ case GL_LUMINANCE_ALPHA32UI_EXT:
+ case GL_RGBA16UI_EXT:
+ case GL_RGB16UI_EXT:
+ case GL_ALPHA16UI_EXT:
+ case GL_INTENSITY16UI_EXT:
+ case GL_LUMINANCE16UI_EXT:
+ case GL_LUMINANCE_ALPHA16UI_EXT:
+ case GL_RGBA8UI_EXT:
+ case GL_RGB8UI_EXT:
+ case GL_ALPHA8UI_EXT:
+ case GL_INTENSITY8UI_EXT:
+ case GL_LUMINANCE8UI_EXT:
+ case GL_LUMINANCE_ALPHA8UI_EXT:
+ case GL_RGBA32I_EXT:
+ case GL_RGB32I_EXT:
+ case GL_ALPHA32I_EXT:
+ case GL_INTENSITY32I_EXT:
+ case GL_LUMINANCE32I_EXT:
+ case GL_LUMINANCE_ALPHA32I_EXT:
+ case GL_RGBA16I_EXT:
+ case GL_RGB16I_EXT:
+ case GL_ALPHA16I_EXT:
+ case GL_INTENSITY16I_EXT:
+ case GL_LUMINANCE16I_EXT:
+ case GL_LUMINANCE_ALPHA16I_EXT:
+ case GL_RGBA8I_EXT:
+ case GL_RGB8I_EXT:
+ case GL_ALPHA8I_EXT:
+ case GL_INTENSITY8I_EXT:
+ case GL_LUMINANCE8I_EXT:
+ case GL_LUMINANCE_ALPHA8I_EXT:
+ /* signed, normalized texture formats */
+ case GL_RED_SNORM:
+ case GL_R8_SNORM:
+ case GL_R16_SNORM:
+ case GL_RG_SNORM:
+ case GL_RG8_SNORM:
+ case GL_RG16_SNORM:
+ case GL_RGB_SNORM:
+ case GL_RGB8_SNORM:
+ case GL_RGB16_SNORM:
+ case GL_RGBA_SNORM:
+ case GL_RGBA8_SNORM:
+ case GL_RGBA16_SNORM:
+ case GL_ALPHA_SNORM:
+ case GL_ALPHA8_SNORM:
+ case GL_ALPHA16_SNORM:
+ case GL_LUMINANCE_SNORM:
+ case GL_LUMINANCE8_SNORM:
+ case GL_LUMINANCE16_SNORM:
+ case GL_LUMINANCE_ALPHA_SNORM:
+ case GL_LUMINANCE8_ALPHA8_SNORM:
+ case GL_LUMINANCE16_ALPHA16_SNORM:
+ case GL_INTENSITY_SNORM:
+ case GL_INTENSITY8_SNORM:
+ case GL_INTENSITY16_SNORM:
+ case GL_RGB9_E5:
+ case GL_R11F_G11F_B10F:
+ return GL_TRUE;
+ case GL_YCBCR_MESA: /* not considered to be RGB */
+ /* fall-through */
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a color index format.
+ */
+GLboolean
+_mesa_is_index_format(GLenum format)
+{
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_COLOR_INDEX1_EXT:
+ case GL_COLOR_INDEX2_EXT:
+ case GL_COLOR_INDEX4_EXT:
+ case GL_COLOR_INDEX8_EXT:
+ case GL_COLOR_INDEX12_EXT:
+ case GL_COLOR_INDEX16_EXT:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a depth component format.
+ */
+GLboolean
+_mesa_is_depth_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ case GL_DEPTH_COMPONENT32F:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a stencil format.
+ */
+GLboolean
+_mesa_is_stencil_format(GLenum format)
+{
+ switch (format) {
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_STENCIL:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a YCbCr format.
+ */
+GLboolean
+_mesa_is_ycbcr_format(GLenum format)
+{
+ switch (format) {
+ case GL_YCBCR_MESA:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a depth+stencil format.
+ */
+GLboolean
+_mesa_is_depthstencil_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH24_STENCIL8_EXT:
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH32F_STENCIL8:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a depth or stencil format.
+ */
+GLboolean
+_mesa_is_depth_or_stencil_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ case GL_STENCIL_INDEX16_EXT:
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ case GL_DEPTH_COMPONENT32F:
+ case GL_DEPTH32F_STENCIL8:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a dudv format.
+ */
+GLboolean
+_mesa_is_dudv_format(GLenum format)
+{
+ switch (format) {
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given format is an integer (non-normalized) format.
+ */
+GLboolean
+_mesa_is_integer_format(GLenum format)
+{
+ switch (format) {
+ /* generic integer formats */
+ 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:
+ /* specific integer formats */
+ case GL_RGBA32UI_EXT:
+ case GL_RGB32UI_EXT:
+ case GL_ALPHA32UI_EXT:
+ case GL_INTENSITY32UI_EXT:
+ case GL_LUMINANCE32UI_EXT:
+ case GL_LUMINANCE_ALPHA32UI_EXT:
+ case GL_RGBA16UI_EXT:
+ case GL_RGB16UI_EXT:
+ case GL_ALPHA16UI_EXT:
+ case GL_INTENSITY16UI_EXT:
+ case GL_LUMINANCE16UI_EXT:
+ case GL_LUMINANCE_ALPHA16UI_EXT:
+ case GL_RGBA8UI_EXT:
+ case GL_RGB8UI_EXT:
+ case GL_ALPHA8UI_EXT:
+ case GL_INTENSITY8UI_EXT:
+ case GL_LUMINANCE8UI_EXT:
+ case GL_LUMINANCE_ALPHA8UI_EXT:
+ case GL_RGBA32I_EXT:
+ case GL_RGB32I_EXT:
+ case GL_ALPHA32I_EXT:
+ case GL_INTENSITY32I_EXT:
+ case GL_LUMINANCE32I_EXT:
+ case GL_LUMINANCE_ALPHA32I_EXT:
+ case GL_RGBA16I_EXT:
+ case GL_RGB16I_EXT:
+ case GL_ALPHA16I_EXT:
+ case GL_INTENSITY16I_EXT:
+ case GL_LUMINANCE16I_EXT:
+ case GL_LUMINANCE_ALPHA16I_EXT:
+ case GL_RGBA8I_EXT:
+ case GL_RGB8I_EXT:
+ case GL_ALPHA8I_EXT:
+ case GL_INTENSITY8I_EXT:
+ case GL_LUMINANCE8I_EXT:
+ case GL_LUMINANCE_ALPHA8I_EXT:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if an image format is a supported compressed format.
+ * \param format the internal format token provided by the user.
+ * \return GL_TRUE if compressed, GL_FALSE if uncompressed
+ */
+GLboolean
+_mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
+{
+ switch (format) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return ctx->Extensions.EXT_texture_compression_s3tc;
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ return ctx->Extensions.S3_s3tc;
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ return ctx->Extensions.EXT_texture_sRGB
+ && ctx->Extensions.EXT_texture_compression_s3tc;
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return ctx->Extensions.TDFX_texture_compression_FXT1;
+ case GL_COMPRESSED_RED_RGTC1:
+ case GL_COMPRESSED_SIGNED_RED_RGTC1:
+ case GL_COMPRESSED_RG_RGTC2:
+ case GL_COMPRESSED_SIGNED_RG_RGTC2:
+ return ctx->Extensions.ARB_texture_compression_rgtc;
+ case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+ return ctx->Extensions.EXT_texture_compression_latc;
+ case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+ return ctx->Extensions.ATI_texture_compression_3dc;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Return the address of a specific pixel in an image (1D, 2D or 3D).
+ *
+ * Pixel unpacking/packing parameters are observed according to \p packing.
+ *
+ * \param dimensions either 1, 2 or 3 to indicate dimensionality of image
+ * \param image starting address of image data
+ * \param width the image width
+ * \param height theimage height
+ * \param format the pixel format
+ * \param type the pixel data type
+ * \param packing the pixelstore attributes
+ * \param img which image in the volume (0 for 1D or 2D images)
+ * \param row row of pixel in the image (0 for 1D images)
+ * \param column column of pixel in the image
+ *
+ * \return address of pixel on success, or NULL on error.
+ *
+ * \sa gl_pixelstore_attrib.
+ */
+GLvoid *
+_mesa_image_address( GLuint dimensions,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint img, GLint row, GLint column )
+{
+ GLint alignment; /* 1, 2 or 4 */
+ GLint pixels_per_row;
+ GLint rows_per_image;
+ GLint skiprows;
+ GLint skippixels;
+ GLint skipimages; /* for 3-D volume images */
+ GLubyte *pixel_addr;
+
+ ASSERT(dimensions >= 1 && dimensions <= 3);
+
+ alignment = packing->Alignment;
+ if (packing->RowLength > 0) {
+ pixels_per_row = packing->RowLength;
+ }
+ else {
+ pixels_per_row = width;
+ }
+ if (packing->ImageHeight > 0) {
+ rows_per_image = packing->ImageHeight;
+ }
+ else {
+ rows_per_image = height;
+ }
+
+ skippixels = packing->SkipPixels;
+ /* Note: SKIP_ROWS _is_ used for 1D images */
+ skiprows = packing->SkipRows;
+ /* Note: SKIP_IMAGES is only used for 3D images */
+ skipimages = (dimensions == 3) ? packing->SkipImages : 0;
+
+ if (type == GL_BITMAP) {
+ /* BITMAP data */
+ GLint comp_per_pixel; /* components per pixel */
+ GLint bytes_per_comp; /* bytes per component */
+ GLint bytes_per_row;
+ GLint bytes_per_image;
+
+ /* Compute bytes per component */
+ bytes_per_comp = _mesa_sizeof_packed_type( type );
+ if (bytes_per_comp < 0) {
+ return NULL;
+ }
+
+ /* Compute number of components per pixel */
+ comp_per_pixel = _mesa_components_in_format( format );
+ if (comp_per_pixel < 0) {
+ return NULL;
+ }
+
+ bytes_per_row = alignment
+ * CEILING( comp_per_pixel*pixels_per_row, 8*alignment );
+
+ bytes_per_image = bytes_per_row * rows_per_image;
+
+ pixel_addr = (GLubyte *) image
+ + (skipimages + img) * bytes_per_image
+ + (skiprows + row) * bytes_per_row
+ + (skippixels + column) / 8;
+ }
+ else {
+ /* Non-BITMAP data */
+ GLint bytes_per_pixel, bytes_per_row, remainder, bytes_per_image;
+ GLint topOfImage;
+
+ bytes_per_pixel = _mesa_bytes_per_pixel( format, type );
+
+ /* The pixel type and format should have been error checked earlier */
+ assert(bytes_per_pixel > 0);
+
+ bytes_per_row = pixels_per_row * bytes_per_pixel;
+ remainder = bytes_per_row % alignment;
+ if (remainder > 0)
+ bytes_per_row += (alignment - remainder);
+
+ ASSERT(bytes_per_row % alignment == 0);
+
+ bytes_per_image = bytes_per_row * rows_per_image;
+
+ if (packing->Invert) {
+ /* set pixel_addr to the last row */
+ topOfImage = bytes_per_row * (height - 1);
+ bytes_per_row = -bytes_per_row;
+ }
+ else {
+ topOfImage = 0;
+ }
+
+ /* compute final pixel address */
+ pixel_addr = (GLubyte *) image
+ + (skipimages + img) * bytes_per_image
+ + topOfImage
+ + (skiprows + row) * bytes_per_row
+ + (skippixels + column) * bytes_per_pixel;
+ }
+
+ return (GLvoid *) pixel_addr;
+}
+
+
+GLvoid *
+_mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width,
+ GLenum format, GLenum type,
+ GLint column )
+{
+ return _mesa_image_address(1, packing, image, width, 1,
+ format, type, 0, 0, column);
+}
+
+
+GLvoid *
+_mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint row, GLint column )
+{
+ return _mesa_image_address(2, packing, image, width, height,
+ format, type, 0, row, column);
+}
+
+
+GLvoid *
+_mesa_image_address3d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint img, GLint row, GLint column )
+{
+ return _mesa_image_address(3, packing, image, width, height,
+ format, type, img, row, column);
+}
+
+
+
+/**
+ * Compute the stride (in bytes) between image rows.
+ *
+ * \param packing the pixelstore attributes
+ * \param width image width.
+ * \param format pixel format.
+ * \param type pixel data type.
+ *
+ * \return the stride in bytes for the given parameters, or -1 if error
+ */
+GLint
+_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
+ GLint width, GLenum format, GLenum type )
+{
+ GLint bytesPerRow, remainder;
+
+ ASSERT(packing);
+
+ if (type == GL_BITMAP) {
+ if (packing->RowLength == 0) {
+ bytesPerRow = (width + 7) / 8;
+ }
+ else {
+ bytesPerRow = (packing->RowLength + 7) / 8;
+ }
+ }
+ else {
+ /* Non-BITMAP data */
+ const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
+ if (bytesPerPixel <= 0)
+ return -1; /* error */
+ if (packing->RowLength == 0) {
+ bytesPerRow = bytesPerPixel * width;
+ }
+ else {
+ bytesPerRow = bytesPerPixel * packing->RowLength;
+ }
+ }
+
+ remainder = bytesPerRow % packing->Alignment;
+ if (remainder > 0) {
+ bytesPerRow += (packing->Alignment - remainder);
+ }
+
+ if (packing->Invert) {
+ /* negate the bytes per row (negative row stride) */
+ bytesPerRow = -bytesPerRow;
+ }
+
+ return bytesPerRow;
+}
+
+
+/*
+ * Compute the stride between images in a 3D texture (in bytes) for the given
+ * pixel packing parameters and image width, format and type.
+ */
+GLint
+_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
+ GLint width, GLint height,
+ GLenum format, GLenum type )
+{
+ GLint bytesPerRow, bytesPerImage, remainder;
+
+ ASSERT(packing);
+
+ if (type == GL_BITMAP) {
+ if (packing->RowLength == 0) {
+ bytesPerRow = (width + 7) / 8;
+ }
+ else {
+ bytesPerRow = (packing->RowLength + 7) / 8;
+ }
+ }
+ else {
+ const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
+
+ if (bytesPerPixel <= 0)
+ return -1; /* error */
+ if (packing->RowLength == 0) {
+ bytesPerRow = bytesPerPixel * width;
+ }
+ else {
+ bytesPerRow = bytesPerPixel * packing->RowLength;
+ }
+ }
+
+ remainder = bytesPerRow % packing->Alignment;
+ if (remainder > 0)
+ bytesPerRow += (packing->Alignment - remainder);
+
+ if (packing->ImageHeight == 0)
+ bytesPerImage = bytesPerRow * height;
+ else
+ bytesPerImage = bytesPerRow * packing->ImageHeight;
+
+ return bytesPerImage;
+}
+
+
+
+/**
+ * "Expand" a bitmap from 1-bit per pixel to 8-bits per pixel.
+ * This is typically used to convert a bitmap into a GLubyte/pixel texture.
+ * "On" bits will set texels to \p onValue.
+ * "Off" bits will not modify texels.
+ * \param width src bitmap width in pixels
+ * \param height src bitmap height in pixels
+ * \param unpack bitmap unpacking state
+ * \param bitmap the src bitmap data
+ * \param destBuffer start of dest buffer
+ * \param destStride row stride in dest buffer
+ * \param onValue if bit is 1, set destBuffer pixel to this value
+ */
+void
+_mesa_expand_bitmap(GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap,
+ GLubyte *destBuffer, GLint destStride,
+ GLubyte onValue)
+{
+ const GLubyte *srcRow = (const GLubyte *)
+ _mesa_image_address2d(unpack, bitmap, width, height,
+ GL_COLOR_INDEX, GL_BITMAP, 0, 0);
+ const GLint srcStride = _mesa_image_row_stride(unpack, width,
+ GL_COLOR_INDEX, GL_BITMAP);
+ GLint row, col;
+
+#define SET_PIXEL(COL, ROW) \
+ destBuffer[(ROW) * destStride + (COL)] = onValue;
+
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = srcRow;
+
+ if (unpack->LsbFirst) {
+ /* Lsb first */
+ GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
+ for (col = 0; col < width; col++) {
+
+ if (*src & mask) {
+ SET_PIXEL(col, row);
+ }
+
+ if (mask == 128U) {
+ src++;
+ mask = 1U;
+ }
+ else {
+ mask = mask << 1;
+ }
+ }
+
+ /* get ready for next row */
+ if (mask != 1)
+ src++;
+ }
+ else {
+ /* Msb first */
+ GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
+ for (col = 0; col < width; col++) {
+
+ if (*src & mask) {
+ SET_PIXEL(col, row);
+ }
+
+ if (mask == 1U) {
+ src++;
+ mask = 128U;
+ }
+ else {
+ mask = mask >> 1;
+ }
+ }
+
+ /* get ready for next row */
+ if (mask != 128)
+ src++;
+ }
+
+ srcRow += srcStride;
+ } /* row */
+
+#undef SET_PIXEL
+}
+
+
+
+
+/**
+ * Convert an array of RGBA colors from one datatype to another.
+ * NOTE: src may equal dst. In that case, we use a temporary buffer.
+ */
+void
+_mesa_convert_colors(GLenum srcType, const GLvoid *src,
+ GLenum dstType, GLvoid *dst,
+ GLuint count, const GLubyte mask[])
+{
+ GLuint tempBuffer[MAX_WIDTH][4];
+ const GLboolean useTemp = (src == dst);
+
+ ASSERT(srcType != dstType);
+
+ switch (srcType) {
+ case GL_UNSIGNED_BYTE:
+ if (dstType == GL_UNSIGNED_SHORT) {
+ const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src;
+ GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst);
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst2[i][RCOMP] = UBYTE_TO_USHORT(src1[i][RCOMP]);
+ dst2[i][GCOMP] = UBYTE_TO_USHORT(src1[i][GCOMP]);
+ dst2[i][BCOMP] = UBYTE_TO_USHORT(src1[i][BCOMP]);
+ dst2[i][ACOMP] = UBYTE_TO_USHORT(src1[i][ACOMP]);
+ }
+ }
+ if (useTemp)
+ memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort));
+ }
+ else {
+ const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src;
+ GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst);
+ GLuint i;
+ ASSERT(dstType == GL_FLOAT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst4[i][RCOMP] = UBYTE_TO_FLOAT(src1[i][RCOMP]);
+ dst4[i][GCOMP] = UBYTE_TO_FLOAT(src1[i][GCOMP]);
+ dst4[i][BCOMP] = UBYTE_TO_FLOAT(src1[i][BCOMP]);
+ dst4[i][ACOMP] = UBYTE_TO_FLOAT(src1[i][ACOMP]);
+ }
+ }
+ if (useTemp)
+ memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat));
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ if (dstType == GL_UNSIGNED_BYTE) {
+ const GLushort (*src2)[4] = (const GLushort (*)[4]) src;
+ GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst);
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst1[i][RCOMP] = USHORT_TO_UBYTE(src2[i][RCOMP]);
+ dst1[i][GCOMP] = USHORT_TO_UBYTE(src2[i][GCOMP]);
+ dst1[i][BCOMP] = USHORT_TO_UBYTE(src2[i][BCOMP]);
+ dst1[i][ACOMP] = USHORT_TO_UBYTE(src2[i][ACOMP]);
+ }
+ }
+ if (useTemp)
+ memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte));
+ }
+ else {
+ const GLushort (*src2)[4] = (const GLushort (*)[4]) src;
+ GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst);
+ GLuint i;
+ ASSERT(dstType == GL_FLOAT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst4[i][RCOMP] = USHORT_TO_FLOAT(src2[i][RCOMP]);
+ dst4[i][GCOMP] = USHORT_TO_FLOAT(src2[i][GCOMP]);
+ dst4[i][BCOMP] = USHORT_TO_FLOAT(src2[i][BCOMP]);
+ dst4[i][ACOMP] = USHORT_TO_FLOAT(src2[i][ACOMP]);
+ }
+ }
+ if (useTemp)
+ memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat));
+ }
+ break;
+ case GL_FLOAT:
+ if (dstType == GL_UNSIGNED_BYTE) {
+ const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src;
+ GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst);
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][RCOMP], src4[i][RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][GCOMP], src4[i][GCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][BCOMP], src4[i][BCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][ACOMP], src4[i][ACOMP]);
+ }
+ }
+ if (useTemp)
+ memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte));
+ }
+ else {
+ const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src;
+ GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst);
+ GLuint i;
+ ASSERT(dstType == GL_UNSIGNED_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ UNCLAMPED_FLOAT_TO_USHORT(dst2[i][RCOMP], src4[i][RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(dst2[i][GCOMP], src4[i][GCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(dst2[i][BCOMP], src4[i][BCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(dst2[i][ACOMP], src4[i][ACOMP]);
+ }
+ }
+ if (useTemp)
+ memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort));
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "Invalid datatype in _mesa_convert_colors");
+ }
+}
+
+
+
+
+/**
+ * Perform basic clipping for glDrawPixels. The image's position and size
+ * and the unpack SkipPixels and SkipRows are adjusted so that the image
+ * region is entirely within the window and scissor bounds.
+ * NOTE: this will only work when glPixelZoom is (1, 1) or (1, -1).
+ * If Pixel.ZoomY is -1, *destY will be changed to be the first row which
+ * we'll actually write. Beforehand, *destY-1 is the first drawing row.
+ *
+ * \return GL_TRUE if image is ready for drawing or
+ * GL_FALSE if image was completely clipped away (draw nothing)
+ */
+GLboolean
+_mesa_clip_drawpixels(const struct gl_context *ctx,
+ GLint *destX, GLint *destY,
+ GLsizei *width, GLsizei *height,
+ struct gl_pixelstore_attrib *unpack)
+{
+ const struct gl_framebuffer *buffer = ctx->DrawBuffer;
+
+ if (unpack->RowLength == 0) {
+ unpack->RowLength = *width;
+ }
+
+ ASSERT(ctx->Pixel.ZoomX == 1.0F);
+ ASSERT(ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F);
+
+ /* left clipping */
+ if (*destX < buffer->_Xmin) {
+ unpack->SkipPixels += (buffer->_Xmin - *destX);
+ *width -= (buffer->_Xmin - *destX);
+ *destX = buffer->_Xmin;
+ }
+ /* right clipping */
+ if (*destX + *width > buffer->_Xmax)
+ *width -= (*destX + *width - buffer->_Xmax);
+
+ if (*width <= 0)
+ return GL_FALSE;
+
+ if (ctx->Pixel.ZoomY == 1.0F) {
+ /* bottom clipping */
+ if (*destY < buffer->_Ymin) {
+ unpack->SkipRows += (buffer->_Ymin - *destY);
+ *height -= (buffer->_Ymin - *destY);
+ *destY = buffer->_Ymin;
+ }
+ /* top clipping */
+ if (*destY + *height > buffer->_Ymax)
+ *height -= (*destY + *height - buffer->_Ymax);
+ }
+ else { /* upside down */
+ /* top clipping */
+ if (*destY > buffer->_Ymax) {
+ unpack->SkipRows += (*destY - buffer->_Ymax);
+ *height -= (*destY - buffer->_Ymax);
+ *destY = buffer->_Ymax;
+ }
+ /* bottom clipping */
+ if (*destY - *height < buffer->_Ymin)
+ *height -= (buffer->_Ymin - (*destY - *height));
+ /* adjust destY so it's the first row to write to */
+ (*destY)--;
+ }
+
+ if (*height <= 0)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Perform clipping for glReadPixels. The image's window position
+ * and size, and the pack skipPixels, skipRows and rowLength are adjusted
+ * so that the image region is entirely within the window bounds.
+ * Note: this is different from _mesa_clip_drawpixels() in that the
+ * scissor box is ignored, and we use the bounds of the current readbuffer
+ * surface.
+ *
+ * \return GL_TRUE if region to read is in bounds
+ * GL_FALSE if region is completely out of bounds (nothing to read)
+ */
+GLboolean
+_mesa_clip_readpixels(const struct gl_context *ctx,
+ GLint *srcX, GLint *srcY,
+ GLsizei *width, GLsizei *height,
+ struct gl_pixelstore_attrib *pack)
+{
+ const struct gl_framebuffer *buffer = ctx->ReadBuffer;
+
+ if (pack->RowLength == 0) {
+ pack->RowLength = *width;
+ }
+
+ /* left clipping */
+ if (*srcX < 0) {
+ pack->SkipPixels += (0 - *srcX);
+ *width -= (0 - *srcX);
+ *srcX = 0;
+ }
+ /* right clipping */
+ if (*srcX + *width > (GLsizei) buffer->Width)
+ *width -= (*srcX + *width - buffer->Width);
+
+ if (*width <= 0)
+ return GL_FALSE;
+
+ /* bottom clipping */
+ if (*srcY < 0) {
+ pack->SkipRows += (0 - *srcY);
+ *height -= (0 - *srcY);
+ *srcY = 0;
+ }
+ /* top clipping */
+ if (*srcY + *height > (GLsizei) buffer->Height)
+ *height -= (*srcY + *height - buffer->Height);
+
+ if (*height <= 0)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Do clipping for a glCopyTexSubImage call.
+ * The framebuffer source region might extend outside the framebuffer
+ * bounds. Clip the source region against the framebuffer bounds and
+ * adjust the texture/dest position and size accordingly.
+ *
+ * \return GL_FALSE if region is totally clipped, GL_TRUE otherwise.
+ */
+GLboolean
+_mesa_clip_copytexsubimage(const struct gl_context *ctx,
+ GLint *destX, GLint *destY,
+ GLint *srcX, GLint *srcY,
+ GLsizei *width, GLsizei *height)
+{
+ const struct gl_framebuffer *fb = ctx->ReadBuffer;
+ const GLint srcX0 = *srcX, srcY0 = *srcY;
+
+ if (_mesa_clip_to_region(0, 0, fb->Width, fb->Height,
+ srcX, srcY, width, height)) {
+ *destX = *destX + *srcX - srcX0;
+ *destY = *destY + *srcY - srcY0;
+
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+}
+
+
+
+/**
+ * Clip the rectangle defined by (x, y, width, height) against the bounds
+ * specified by [xmin, xmax) and [ymin, ymax).
+ * \return GL_FALSE if rect is totally clipped, GL_TRUE otherwise.
+ */
+GLboolean
+_mesa_clip_to_region(GLint xmin, GLint ymin,
+ GLint xmax, GLint ymax,
+ GLint *x, GLint *y,
+ GLsizei *width, GLsizei *height )
+{
+ /* left clipping */
+ if (*x < xmin) {
+ *width -= (xmin - *x);
+ *x = xmin;
+ }
+
+ /* right clipping */
+ if (*x + *width > xmax)
+ *width -= (*x + *width - xmax);
+
+ if (*width <= 0)
+ return GL_FALSE;
+
+ /* bottom (or top) clipping */
+ if (*y < ymin) {
+ *height -= (ymin - *y);
+ *y = ymin;
+ }
+
+ /* top (or bottom) clipping */
+ if (*y + *height > ymax)
+ *height -= (*y + *height - ymax);
+
+ if (*height <= 0)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Clip dst coords against Xmax (or Ymax).
+ */
+static INLINE void
+clip_right_or_top(GLint *srcX0, GLint *srcX1,
+ GLint *dstX0, GLint *dstX1,
+ GLint maxValue)
+{
+ GLfloat t, bias;
+
+ if (*dstX1 > maxValue) {
+ /* X1 outside right edge */
+ ASSERT(*dstX0 < maxValue); /* X0 should be inside right edge */
+ t = (GLfloat) (maxValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0);
+ /* chop off [t, 1] part */
+ ASSERT(t >= 0.0 && t <= 1.0);
+ *dstX1 = maxValue;
+ bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F;
+ *srcX1 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
+ }
+ else if (*dstX0 > maxValue) {
+ /* X0 outside right edge */
+ ASSERT(*dstX1 < maxValue); /* X1 should be inside right edge */
+ t = (GLfloat) (maxValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1);
+ /* chop off [t, 1] part */
+ ASSERT(t >= 0.0 && t <= 1.0);
+ *dstX0 = maxValue;
+ bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F;
+ *srcX0 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
+ }
+}
+
+
+/**
+ * Clip dst coords against Xmin (or Ymin).
+ */
+static INLINE void
+clip_left_or_bottom(GLint *srcX0, GLint *srcX1,
+ GLint *dstX0, GLint *dstX1,
+ GLint minValue)
+{
+ GLfloat t, bias;
+
+ if (*dstX0 < minValue) {
+ /* X0 outside left edge */
+ ASSERT(*dstX1 > minValue); /* X1 should be inside left edge */
+ t = (GLfloat) (minValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0);
+ /* chop off [0, t] part */
+ ASSERT(t >= 0.0 && t <= 1.0);
+ *dstX0 = minValue;
+ bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; /* flipped??? */
+ *srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
+ }
+ else if (*dstX1 < minValue) {
+ /* X1 outside left edge */
+ ASSERT(*dstX0 > minValue); /* X0 should be inside left edge */
+ t = (GLfloat) (minValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1);
+ /* chop off [0, t] part */
+ ASSERT(t >= 0.0 && t <= 1.0);
+ *dstX1 = minValue;
+ bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F;
+ *srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
+ }
+}
+
+
+/**
+ * Do clipping of blit src/dest rectangles.
+ * The dest rect is clipped against both the buffer bounds and scissor bounds.
+ * The src rect is just clipped against the buffer bounds.
+ *
+ * When either the src or dest rect is clipped, the other is also clipped
+ * proportionately!
+ *
+ * Note that X0 need not be less than X1 (same for Y) for either the source
+ * and dest rects. That makes the clipping a little trickier.
+ *
+ * \return GL_TRUE if anything is left to draw, GL_FALSE if totally clipped
+ */
+GLboolean
+_mesa_clip_blit(struct gl_context *ctx,
+ GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1,
+ GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1)
+{
+ const GLint srcXmin = 0;
+ const GLint srcXmax = ctx->ReadBuffer->Width;
+ const GLint srcYmin = 0;
+ const GLint srcYmax = ctx->ReadBuffer->Height;
+
+ /* these include scissor bounds */
+ const GLint dstXmin = ctx->DrawBuffer->_Xmin;
+ const GLint dstXmax = ctx->DrawBuffer->_Xmax;
+ const GLint dstYmin = ctx->DrawBuffer->_Ymin;
+ const GLint dstYmax = ctx->DrawBuffer->_Ymax;
+
+ /*
+ printf("PreClipX: src: %d .. %d dst: %d .. %d\n",
+ *srcX0, *srcX1, *dstX0, *dstX1);
+ printf("PreClipY: src: %d .. %d dst: %d .. %d\n",
+ *srcY0, *srcY1, *dstY0, *dstY1);
+ */
+
+ /* trivial rejection tests */
+ if (*dstX0 == *dstX1)
+ return GL_FALSE; /* no width */
+ if (*dstX0 <= dstXmin && *dstX1 <= dstXmin)
+ return GL_FALSE; /* totally out (left) of bounds */
+ if (*dstX0 >= dstXmax && *dstX1 >= dstXmax)
+ return GL_FALSE; /* totally out (right) of bounds */
+
+ if (*dstY0 == *dstY1)
+ return GL_FALSE;
+ if (*dstY0 <= dstYmin && *dstY1 <= dstYmin)
+ return GL_FALSE;
+ if (*dstY0 >= dstYmax && *dstY1 >= dstYmax)
+ return GL_FALSE;
+
+ if (*srcX0 == *srcX1)
+ return GL_FALSE;
+ if (*srcX0 <= srcXmin && *srcX1 <= srcXmin)
+ return GL_FALSE;
+ if (*srcX0 >= srcXmax && *srcX1 >= srcXmax)
+ return GL_FALSE;
+
+ if (*srcY0 == *srcY1)
+ return GL_FALSE;
+ if (*srcY0 <= srcYmin && *srcY1 <= srcYmin)
+ return GL_FALSE;
+ if (*srcY0 >= srcYmax && *srcY1 >= srcYmax)
+ return GL_FALSE;
+
+ /*
+ * dest clip
+ */
+ clip_right_or_top(srcX0, srcX1, dstX0, dstX1, dstXmax);
+ clip_right_or_top(srcY0, srcY1, dstY0, dstY1, dstYmax);
+ clip_left_or_bottom(srcX0, srcX1, dstX0, dstX1, dstXmin);
+ clip_left_or_bottom(srcY0, srcY1, dstY0, dstY1, dstYmin);
+
+ /*
+ * src clip (just swap src/dst values from above)
+ */
+ clip_right_or_top(dstX0, dstX1, srcX0, srcX1, srcXmax);
+ clip_right_or_top(dstY0, dstY1, srcY0, srcY1, srcYmax);
+ clip_left_or_bottom(dstX0, dstX1, srcX0, srcX1, srcXmin);
+ clip_left_or_bottom(dstY0, dstY1, srcY0, srcY1, srcYmin);
+
+ /*
+ printf("PostClipX: src: %d .. %d dst: %d .. %d\n",
+ *srcX0, *srcX1, *dstX0, *dstX1);
+ printf("PostClipY: src: %d .. %d dst: %d .. %d\n",
+ *srcY0, *srcY1, *dstY0, *dstY1);
+ */
+
+ ASSERT(*dstX0 >= dstXmin);
+ ASSERT(*dstX0 <= dstXmax);
+ ASSERT(*dstX1 >= dstXmin);
+ ASSERT(*dstX1 <= dstXmax);
+
+ ASSERT(*dstY0 >= dstYmin);
+ ASSERT(*dstY0 <= dstYmax);
+ ASSERT(*dstY1 >= dstYmin);
+ ASSERT(*dstY1 <= dstYmax);
+
+ ASSERT(*srcX0 >= srcXmin);
+ ASSERT(*srcX0 <= srcXmax);
+ ASSERT(*srcX1 >= srcXmin);
+ ASSERT(*srcX1 <= srcXmax);
+
+ ASSERT(*srcY0 >= srcYmin);
+ ASSERT(*srcY0 <= srcYmax);
+ ASSERT(*srcY1 >= srcYmin);
+ ASSERT(*srcY1 <= srcYmax);
+
+ return GL_TRUE;
+}
diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index f2724dbca..8a811cb72 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/src/mesa/main/mipmap.c
@@ -706,6 +706,17 @@ do_row(GLenum datatype, GLuint comps, GLint srcWidth,
}
}
+ else if (datatype == GL_FLOAT_32_UNSIGNED_INT_24_8_REV && comps == 1) {
+ GLuint i, j, k;
+ const GLfloat *rowA = (const GLfloat *) srcRowA;
+ const GLfloat *rowB = (const GLfloat *) srcRowB;
+ GLfloat *dst = (GLfloat *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i*2] = (rowA[j*2] + rowA[k*2] + rowB[j*2] + rowB[k*2]) * 0.25F;
+ }
+ }
+
else {
_mesa_problem(NULL, "bad format in do_row()");
}
@@ -1341,6 +1352,15 @@ do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth,
}
}
+ else if (datatype == GL_FLOAT_32_UNSIGNED_INT_24_8_REV && comps == 1) {
+ DECLARE_ROW_POINTERS(GLfloat, 2);
+
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ FILTER_F_3D(0);
+ }
+ }
+
else {
_mesa_problem(NULL, "bad format in do_row()");
}
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index f018c75cc..b88118366 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1856,7 +1856,7 @@ struct gl_program
GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */
GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */
GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */
- GLbitfield TexturesUsed[MAX_TEXTURE_UNITS]; /**< TEXTURE_x_BIT bitmask */
+ GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */
GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index a232a51c3..7de1d05b9 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -1971,7 +1971,8 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
srcType == GL_INT ||
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_HALF_FLOAT_ARB ||
- srcType == GL_FLOAT);
+ srcType == GL_FLOAT ||
+ srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
switch (srcType) {
case GL_BITMAP:
@@ -2142,6 +2143,23 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
}
}
break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ {
+ GLuint i;
+ const GLuint *s = (const GLuint *) src;
+ if (unpack->SwapBytes) {
+ for (i = 0; i < n; i++) {
+ GLuint value = s[i*2+1];
+ SWAP4BYTE(value);
+ indexes[i] = value & 0xff; /* lower 8 bits */
+ }
+ }
+ else {
+ for (i = 0; i < n; i++)
+ indexes[i] = s[i*2+1] & 0xff; /* lower 8 bits */
+ }
+ }
+ break;
default:
_mesa_problem(NULL, "bad srcType in extract_uint_indexes");
@@ -4412,11 +4430,13 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
srcType == GL_INT ||
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_HALF_FLOAT_ARB ||
- srcType == GL_FLOAT);
+ srcType == GL_FLOAT ||
+ srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
ASSERT(dstType == GL_UNSIGNED_BYTE ||
dstType == GL_UNSIGNED_SHORT ||
- dstType == GL_UNSIGNED_INT);
+ dstType == GL_UNSIGNED_INT ||
+ dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
/* only shift and offset apply to stencil */
transferOps &= IMAGE_SHIFT_OFFSET_BIT;
@@ -4488,6 +4508,15 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
case GL_UNSIGNED_INT:
memcpy(dest, indexes, n * sizeof(GLuint));
break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ {
+ GLuint *dst = (GLuint *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i*2+1] = indexes[i] & 0xff; /* lower 8 bits */
+ }
+ }
+ break;
default:
_mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span");
}
@@ -4798,6 +4827,20 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
}
}
break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ {
+ GLuint i;
+ const GLfloat *src = (const GLfloat *)source;
+ for (i = 0; i < n; i++) {
+ GLfloat value = src[i * 2];
+ if (srcPacking->SwapBytes) {
+ SWAP4BYTE(value);
+ }
+ depthValues[i] = value;
+ }
+ needClamp = GL_TRUE;
+ }
+ break;
case GL_FLOAT:
DEPTH_VALUES(GLfloat, 1*);
needClamp = GL_TRUE;
@@ -4874,9 +4917,18 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax);
}
}
+ else if (dstType == GL_FLOAT) {
+ /* Nothing to do. depthValues is pointing to dest. */
+ }
+ else if (dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV) {
+ GLfloat *zValues = (GLfloat*) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ zValues[i*2] = depthValues[i];
+ }
+ }
else {
- ASSERT(dstType == GL_FLOAT);
- /*ASSERT(depthMax == 1.0F);*/
+ ASSERT(0);
}
free(depthTemp);
@@ -5004,10 +5056,11 @@ _mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest,
/**
- * Pack depth and stencil values as GL_DEPTH_STENCIL/GL_UNSIGNED_INT_24_8.
+ * Pack depth and stencil values as GL_DEPTH_STENCIL (GL_UNSIGNED_INT_24_8 etc)
*/
void
-_mesa_pack_depth_stencil_span(struct gl_context *ctx, GLuint n, GLuint *dest,
+_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n,
+ GLenum dstType, GLuint *dest,
const GLfloat *depthVals,
const GLstencil *stencilVals,
const struct gl_pixelstore_attrib *dstPacking)
@@ -5037,9 +5090,19 @@ _mesa_pack_depth_stencil_span(struct gl_context *ctx, GLuint n, GLuint *dest,
stencilVals = stencilCopy;
}
- for (i = 0; i < n; i++) {
- GLuint z = (GLuint) (depthVals[i] * 0xffffff);
- dest[i] = (z << 8) | (stencilVals[i] & 0xff);
+ switch (dstType) {
+ case GL_UNSIGNED_INT_24_8:
+ for (i = 0; i < n; i++) {
+ GLuint z = (GLuint) (depthVals[i] * 0xffffff);
+ dest[i] = (z << 8) | (stencilVals[i] & 0xff);
+ }
+ break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ for (i = 0; i < n; i++) {
+ ((GLfloat*)dest)[i*2] = depthVals[i];
+ dest[i*2+1] = stencilVals[i] & 0xff;
+ }
+ break;
}
if (dstPacking->SwapBytes) {
diff --git a/mesalib/src/mesa/main/pack.h b/mesalib/src/mesa/main/pack.h
index 1f19a5a7c..00aab409e 100644
--- a/mesalib/src/mesa/main/pack.h
+++ b/mesalib/src/mesa/main/pack.h
@@ -1,147 +1,147 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (C) 1999-2010 VMware, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef PACK_H
-#define PACK_H
-
-
-#include "mtypes.h"
-
-
-extern void
-_mesa_unpack_polygon_stipple(const GLubyte *pattern, GLuint dest[32],
- const struct gl_pixelstore_attrib *unpacking);
-
-
-extern void
-_mesa_pack_polygon_stipple(const GLuint pattern[32], GLubyte *dest,
- const struct gl_pixelstore_attrib *packing);
-
-
-extern GLvoid *
-_mesa_unpack_bitmap(GLint width, GLint height, const GLubyte *pixels,
- const struct gl_pixelstore_attrib *packing);
-
-extern void
-_mesa_pack_bitmap(GLint width, GLint height, const GLubyte *source,
- GLubyte *dest, const struct gl_pixelstore_attrib *packing);
-
-
-extern void
-_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n,
- GLfloat rgba[][4],
- GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
- const struct gl_pixelstore_attrib *dstPacking,
- GLbitfield transferOps);
-
-
-extern void
-_mesa_unpack_color_span_chan(struct gl_context *ctx,
- GLuint n, GLenum dstFormat, GLchan dest[],
- GLenum srcFormat, GLenum srcType,
- const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking,
- GLbitfield transferOps);
-
-
-extern void
-_mesa_unpack_color_span_float(struct gl_context *ctx,
- GLuint n, GLenum dstFormat, GLfloat dest[],
- GLenum srcFormat, GLenum srcType,
- const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking,
- GLbitfield transferOps);
-
-extern void
-_mesa_unpack_color_span_uint(struct gl_context *ctx,
- GLuint n, GLenum dstFormat, GLuint *dest,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking);
-
-extern void
-_mesa_unpack_dudv_span_byte(struct gl_context *ctx,
- GLuint n, GLenum dstFormat, GLbyte dest[],
- GLenum srcFormat, GLenum srcType,
- const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking,
- GLbitfield transferOps);
-
-extern void
-_mesa_unpack_index_span(struct gl_context *ctx, GLuint n,
- GLenum dstType, GLvoid *dest,
- GLenum srcType, const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking,
- GLbitfield transferOps);
-
-
-extern void
-_mesa_pack_index_span(struct gl_context *ctx, GLuint n,
- GLenum dstType, GLvoid *dest, const GLuint *source,
- const struct gl_pixelstore_attrib *dstPacking,
- GLbitfield transferOps);
-
-
-extern void
-_mesa_unpack_stencil_span(struct gl_context *ctx, GLuint n,
- GLenum dstType, GLvoid *dest,
- GLenum srcType, const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking,
- GLbitfield transferOps);
-
-extern void
-_mesa_pack_stencil_span(struct gl_context *ctx, GLuint n,
- GLenum dstType, GLvoid *dest, const GLstencil *source,
- const struct gl_pixelstore_attrib *dstPacking);
-
-
-extern void
-_mesa_unpack_depth_span(struct gl_context *ctx, GLuint n,
- GLenum dstType, GLvoid *dest, GLuint depthMax,
- GLenum srcType, const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking);
-
-extern void
-_mesa_pack_depth_span(struct gl_context *ctx, GLuint n, GLvoid *dest,
- GLenum dstType, const GLfloat *depthSpan,
- const struct gl_pixelstore_attrib *dstPacking);
-
-
-extern void
-_mesa_pack_depth_stencil_span(struct gl_context *ctx,
- GLuint n, GLuint *dest,
- const GLfloat *depthVals,
- const GLstencil *stencilVals,
- const struct gl_pixelstore_attrib *dstPacking);
-
-
-extern void *
-_mesa_unpack_image(GLuint dimensions,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *unpack);
-
-
-#endif
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2010 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef PACK_H
+#define PACK_H
+
+
+#include "mtypes.h"
+
+
+extern void
+_mesa_unpack_polygon_stipple(const GLubyte *pattern, GLuint dest[32],
+ const struct gl_pixelstore_attrib *unpacking);
+
+
+extern void
+_mesa_pack_polygon_stipple(const GLuint pattern[32], GLubyte *dest,
+ const struct gl_pixelstore_attrib *packing);
+
+
+extern GLvoid *
+_mesa_unpack_bitmap(GLint width, GLint height, const GLubyte *pixels,
+ const struct gl_pixelstore_attrib *packing);
+
+extern void
+_mesa_pack_bitmap(GLint width, GLint height, const GLubyte *source,
+ GLubyte *dest, const struct gl_pixelstore_attrib *packing);
+
+
+extern void
+_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n,
+ GLfloat rgba[][4],
+ GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLbitfield transferOps);
+
+
+extern void
+_mesa_unpack_color_span_chan(struct gl_context *ctx,
+ GLuint n, GLenum dstFormat, GLchan dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLbitfield transferOps);
+
+
+extern void
+_mesa_unpack_color_span_float(struct gl_context *ctx,
+ GLuint n, GLenum dstFormat, GLfloat dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLbitfield transferOps);
+
+extern void
+_mesa_unpack_color_span_uint(struct gl_context *ctx,
+ GLuint n, GLenum dstFormat, GLuint *dest,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking);
+
+extern void
+_mesa_unpack_dudv_span_byte(struct gl_context *ctx,
+ GLuint n, GLenum dstFormat, GLbyte dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLbitfield transferOps);
+
+extern void
+_mesa_unpack_index_span(struct gl_context *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest,
+ GLenum srcType, const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLbitfield transferOps);
+
+
+extern void
+_mesa_pack_index_span(struct gl_context *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest, const GLuint *source,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLbitfield transferOps);
+
+
+extern void
+_mesa_unpack_stencil_span(struct gl_context *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest,
+ GLenum srcType, const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLbitfield transferOps);
+
+extern void
+_mesa_pack_stencil_span(struct gl_context *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest, const GLstencil *source,
+ const struct gl_pixelstore_attrib *dstPacking);
+
+
+extern void
+_mesa_unpack_depth_span(struct gl_context *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest, GLuint depthMax,
+ GLenum srcType, const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking);
+
+extern void
+_mesa_pack_depth_span(struct gl_context *ctx, GLuint n, GLvoid *dest,
+ GLenum dstType, const GLfloat *depthSpan,
+ const struct gl_pixelstore_attrib *dstPacking);
+
+
+extern void
+_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n,
+ GLenum dstType, GLuint *dest,
+ const GLfloat *depthVals,
+ const GLstencil *stencilVals,
+ const struct gl_pixelstore_attrib *dstPacking);
+
+
+extern void *
+_mesa_unpack_image(GLuint dimensions,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *unpack);
+
+
+#endif
diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c
index 0331a8ca2..84c5b2228 100644
--- a/mesalib/src/mesa/main/readpix.c
+++ b/mesalib/src/mesa/main/readpix.c
@@ -61,6 +61,14 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
return GL_TRUE;
}
+ if (ctx->Extensions.ARB_depth_buffer_float
+ && type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV
+ && format != GL_DEPTH_STENCIL_EXT) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw);
+ return GL_TRUE;
+ }
+
/* basic combinations test */
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -142,10 +150,23 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
}
break;
case GL_DEPTH_STENCIL_EXT:
- if (!ctx->Extensions.EXT_packed_depth_stencil ||
- type != GL_UNSIGNED_INT_24_8_EXT) {
- _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
- return GL_TRUE;
+ /* Check validity of the type first. */
+ switch (type) {
+ case GL_UNSIGNED_INT_24_8_EXT:
+ if (!ctx->Extensions.EXT_packed_depth_stencil) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+ return GL_TRUE;
+ }
+ break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ if (!ctx->Extensions.ARB_depth_buffer_float) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+ return GL_TRUE;
+ }
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+ return GL_TRUE;
}
if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) ||
(reading && !_mesa_source_buffer_exists(ctx, format))) {
diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c
index c36175c60..f5b20020d 100644
--- a/mesalib/src/mesa/main/renderbuffer.c
+++ b/mesalib/src/mesa/main/renderbuffer.c
@@ -66,6 +66,9 @@ get_datatype_bytes(struct gl_renderbuffer *rb)
int component_size;
switch (rb->DataType) {
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ component_size = 8;
+ break;
case GL_FLOAT:
case GL_UNSIGNED_INT:
case GL_UNSIGNED_INT_24_8_EXT:
diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c
index f7774fdd7..8f8d87b90 100644
--- a/mesalib/src/mesa/main/samplerobj.c
+++ b/mesalib/src/mesa/main/samplerobj.c
@@ -251,7 +251,7 @@ _mesa_BindSampler(GLuint unit, GLuint sampler)
struct gl_sampler_object *sampObj;
GET_CURRENT_CONTEXT(ctx);
- if (unit >= ctx->Const.MaxTextureImageUnits) {
+ if (unit >= ctx->Const.MaxCombinedTextureImageUnits) {
_mesa_error(ctx, GL_INVALID_VALUE, "glBindSampler(unit %u)", unit);
return;
}
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index b58e30de9..8df25c3f9 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -1032,7 +1032,7 @@ validate_samplers(const struct gl_program *prog, char *errMsg)
"TEXTURE_2D",
"TEXTURE_1D",
};
- GLint targetUsed[MAX_TEXTURE_IMAGE_UNITS];
+ GLint targetUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
GLbitfield samplersUsed = prog->SamplersUsed;
GLuint i;
@@ -1050,7 +1050,7 @@ validate_samplers(const struct gl_program *prog, char *errMsg)
gl_texture_index target;
GLint sampler = _mesa_ffs(samplersUsed) - 1;
assert(sampler >= 0);
- assert(sampler < MAX_TEXTURE_IMAGE_UNITS);
+ assert(sampler < Elements(prog->SamplerUnits));
unit = prog->SamplerUnits[sampler];
target = prog->SamplerTargets[sampler];
if (targetUsed[unit] != -1 && targetUsed[unit] != (int) target) {
diff --git a/mesalib/src/mesa/main/texenv.c b/mesalib/src/mesa/main/texenv.c
index 9228e354a..c0d0f3779 100644
--- a/mesalib/src/mesa/main/texenv.c
+++ b/mesalib/src/mesa/main/texenv.c
@@ -419,7 +419,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
ASSERT_OUTSIDE_BEGIN_END(ctx);
maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
- ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+ ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
if (ctx->Texture.CurrentUnit >= maxUnit) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)");
return;
@@ -748,7 +748,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
ASSERT_OUTSIDE_BEGIN_END(ctx);
maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
- ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+ ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
if (ctx->Texture.CurrentUnit >= maxUnit) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)");
return;
@@ -817,7 +817,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
ASSERT_OUTSIDE_BEGIN_END(ctx);
maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
- ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+ ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
if (ctx->Texture.CurrentUnit >= maxUnit) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)");
return;
diff --git a/mesalib/src/mesa/main/texfetch.c b/mesalib/src/mesa/main/texfetch.c
index ab3abf657..72283eb68 100644
--- a/mesalib/src/mesa/main/texfetch.c
+++ b/mesalib/src/mesa/main/texfetch.c
@@ -1,1050 +1,1064 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.7
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/**
- * \file texfetch.c
- *
- * Texel fetch/store functions
- *
- * \author Gareth Hughes
- */
-
-
-#include "colormac.h"
-#include "macros.h"
-#include "texcompress.h"
-#include "texcompress_fxt1.h"
-#include "texcompress_s3tc.h"
-#include "texcompress_rgtc.h"
-#include "texfetch.h"
-#include "teximage.h"
-#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
-#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
-
-
-/**
- * Convert an 8-bit sRGB value from non-linear space to a
- * linear RGB value in [0, 1].
- * Implemented with a 256-entry lookup table.
- */
-static INLINE GLfloat
-nonlinear_to_linear(GLubyte cs8)
-{
- static GLfloat table[256];
- static GLboolean tableReady = GL_FALSE;
- if (!tableReady) {
- /* compute lookup table now */
- GLuint i;
- for (i = 0; i < 256; i++) {
- const GLfloat cs = UBYTE_TO_FLOAT(i);
- if (cs <= 0.04045) {
- table[i] = cs / 12.92f;
- }
- else {
- table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4);
- }
- }
- tableReady = GL_TRUE;
- }
- return table[cs8];
-}
-
-
-
-/* Texel fetch routines for all supported formats
- */
-#define DIM 1
-#include "texfetch_tmp.h"
-
-#define DIM 2
-#include "texfetch_tmp.h"
-
-#define DIM 3
-#include "texfetch_tmp.h"
-
-/**
- * Null texel fetch function.
- *
- * Have to have this so the FetchTexel function pointer is never NULL.
- */
-static void fetch_null_texelf( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- (void) texImage; (void) i; (void) j; (void) k;
- texel[RCOMP] = 0.0;
- texel[GCOMP] = 0.0;
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 0.0;
- _mesa_warning(NULL, "fetch_null_texelf() called!");
-}
-
-static void store_null_texel(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- (void) texImage;
- (void) i;
- (void) j;
- (void) k;
- (void) texel;
- /* no-op */
-}
-
-
-
-/**
- * Table to map MESA_FORMAT_ to texel fetch/store funcs.
- * XXX this is somewhat temporary.
- */
-static struct {
- gl_format Name;
- FetchTexelFuncF Fetch1D;
- FetchTexelFuncF Fetch2D;
- FetchTexelFuncF Fetch3D;
- StoreTexelFunc StoreTexel;
-}
-texfetch_funcs[MESA_FORMAT_COUNT] =
-{
- {
- MESA_FORMAT_NONE,
- fetch_null_texelf,
- fetch_null_texelf,
- fetch_null_texelf,
- store_null_texel
- },
-
- {
- MESA_FORMAT_RGBA8888,
- fetch_texel_1d_f_rgba8888,
- fetch_texel_2d_f_rgba8888,
- fetch_texel_3d_f_rgba8888,
- store_texel_rgba8888
- },
- {
- MESA_FORMAT_RGBA8888_REV,
- fetch_texel_1d_f_rgba8888_rev,
- fetch_texel_2d_f_rgba8888_rev,
- fetch_texel_3d_f_rgba8888_rev,
- store_texel_rgba8888_rev
- },
- {
- MESA_FORMAT_ARGB8888,
- fetch_texel_1d_f_argb8888,
- fetch_texel_2d_f_argb8888,
- fetch_texel_3d_f_argb8888,
- store_texel_argb8888
- },
- {
- MESA_FORMAT_ARGB8888_REV,
- fetch_texel_1d_f_argb8888_rev,
- fetch_texel_2d_f_argb8888_rev,
- fetch_texel_3d_f_argb8888_rev,
- store_texel_argb8888_rev
- },
- {
- MESA_FORMAT_XRGB8888,
- fetch_texel_1d_f_xrgb8888,
- fetch_texel_2d_f_xrgb8888,
- fetch_texel_3d_f_xrgb8888,
- store_texel_xrgb8888
- },
- {
- MESA_FORMAT_XRGB8888_REV,
- fetch_texel_1d_f_xrgb8888_rev,
- fetch_texel_2d_f_xrgb8888_rev,
- fetch_texel_3d_f_xrgb8888_rev,
- store_texel_xrgb8888_rev,
- },
- {
- MESA_FORMAT_RGB888,
- fetch_texel_1d_f_rgb888,
- fetch_texel_2d_f_rgb888,
- fetch_texel_3d_f_rgb888,
- store_texel_rgb888
- },
- {
- MESA_FORMAT_BGR888,
- fetch_texel_1d_f_bgr888,
- fetch_texel_2d_f_bgr888,
- fetch_texel_3d_f_bgr888,
- store_texel_bgr888
- },
- {
- MESA_FORMAT_RGB565,
- fetch_texel_1d_f_rgb565,
- fetch_texel_2d_f_rgb565,
- fetch_texel_3d_f_rgb565,
- store_texel_rgb565
- },
- {
- MESA_FORMAT_RGB565_REV,
- fetch_texel_1d_f_rgb565_rev,
- fetch_texel_2d_f_rgb565_rev,
- fetch_texel_3d_f_rgb565_rev,
- store_texel_rgb565_rev
- },
- {
- MESA_FORMAT_ARGB4444,
- fetch_texel_1d_f_argb4444,
- fetch_texel_2d_f_argb4444,
- fetch_texel_3d_f_argb4444,
- store_texel_argb4444
- },
- {
- MESA_FORMAT_ARGB4444_REV,
- fetch_texel_1d_f_argb4444_rev,
- fetch_texel_2d_f_argb4444_rev,
- fetch_texel_3d_f_argb4444_rev,
- store_texel_argb4444_rev
- },
- {
- MESA_FORMAT_RGBA5551,
- fetch_texel_1d_f_rgba5551,
- fetch_texel_2d_f_rgba5551,
- fetch_texel_3d_f_rgba5551,
- store_texel_rgba5551
- },
- {
- MESA_FORMAT_ARGB1555,
- fetch_texel_1d_f_argb1555,
- fetch_texel_2d_f_argb1555,
- fetch_texel_3d_f_argb1555,
- store_texel_argb1555
- },
- {
- MESA_FORMAT_ARGB1555_REV,
- fetch_texel_1d_f_argb1555_rev,
- fetch_texel_2d_f_argb1555_rev,
- fetch_texel_3d_f_argb1555_rev,
- store_texel_argb1555_rev
- },
- {
- MESA_FORMAT_AL44,
- fetch_texel_1d_f_al44,
- fetch_texel_2d_f_al44,
- fetch_texel_3d_f_al44,
- store_texel_al44
- },
- {
- MESA_FORMAT_AL88,
- fetch_texel_1d_f_al88,
- fetch_texel_2d_f_al88,
- fetch_texel_3d_f_al88,
- store_texel_al88
- },
- {
- MESA_FORMAT_AL88_REV,
- fetch_texel_1d_f_al88_rev,
- fetch_texel_2d_f_al88_rev,
- fetch_texel_3d_f_al88_rev,
- store_texel_al88_rev
- },
- {
- MESA_FORMAT_AL1616,
- fetch_texel_1d_f_al1616,
- fetch_texel_2d_f_al1616,
- fetch_texel_3d_f_al1616,
- store_texel_al1616
- },
- {
- MESA_FORMAT_AL1616_REV,
- fetch_texel_1d_f_al1616_rev,
- fetch_texel_2d_f_al1616_rev,
- fetch_texel_3d_f_al1616_rev,
- store_texel_al1616_rev
- },
- {
- MESA_FORMAT_RGB332,
- fetch_texel_1d_f_rgb332,
- fetch_texel_2d_f_rgb332,
- fetch_texel_3d_f_rgb332,
- store_texel_rgb332
- },
- {
- MESA_FORMAT_A8,
- fetch_texel_1d_f_a8,
- fetch_texel_2d_f_a8,
- fetch_texel_3d_f_a8,
- store_texel_a8
- },
- {
- MESA_FORMAT_A16,
- fetch_texel_1d_f_a16,
- fetch_texel_2d_f_a16,
- fetch_texel_3d_f_a16,
- store_texel_a16
- },
- {
- MESA_FORMAT_L8,
- fetch_texel_1d_f_l8,
- fetch_texel_2d_f_l8,
- fetch_texel_3d_f_l8,
- store_texel_l8
- },
- {
- MESA_FORMAT_L16,
- fetch_texel_1d_f_l16,
- fetch_texel_2d_f_l16,
- fetch_texel_3d_f_l16,
- store_texel_l16
- },
- {
- MESA_FORMAT_I8,
- fetch_texel_1d_f_i8,
- fetch_texel_2d_f_i8,
- fetch_texel_3d_f_i8,
- store_texel_i8
- },
- {
- MESA_FORMAT_I16,
- fetch_texel_1d_f_i16,
- fetch_texel_2d_f_i16,
- fetch_texel_3d_f_i16,
- store_texel_i16
- },
- {
- MESA_FORMAT_CI8,
- fetch_texel_1d_f_ci8,
- fetch_texel_2d_f_ci8,
- fetch_texel_3d_f_ci8,
- store_texel_ci8
- },
- {
- MESA_FORMAT_YCBCR,
- fetch_texel_1d_f_ycbcr,
- fetch_texel_2d_f_ycbcr,
- fetch_texel_3d_f_ycbcr,
- store_texel_ycbcr
- },
- {
- MESA_FORMAT_YCBCR_REV,
- fetch_texel_1d_f_ycbcr_rev,
- fetch_texel_2d_f_ycbcr_rev,
- fetch_texel_3d_f_ycbcr_rev,
- store_texel_ycbcr_rev
- },
- {
- MESA_FORMAT_R8,
- fetch_texel_1d_f_r8,
- fetch_texel_2d_f_r8,
- fetch_texel_3d_f_r8,
- store_texel_r8,
- },
- {
- MESA_FORMAT_RG88,
- fetch_texel_1d_f_rg88,
- fetch_texel_2d_f_rg88,
- fetch_texel_3d_f_rg88,
- store_texel_rg88,
- },
- {
- MESA_FORMAT_RG88_REV,
- fetch_texel_1d_f_rg88_rev,
- fetch_texel_2d_f_rg88_rev,
- fetch_texel_3d_f_rg88_rev,
- store_texel_rg88_rev,
- },
- {
- MESA_FORMAT_R16,
- fetch_texel_1d_f_r16,
- fetch_texel_2d_f_r16,
- fetch_texel_3d_f_r16,
- store_texel_r16,
- },
- {
- MESA_FORMAT_RG1616,
- fetch_texel_1d_f_rg1616,
- fetch_texel_2d_f_rg1616,
- fetch_texel_3d_f_rg1616,
- store_texel_rg1616,
- },
- {
- MESA_FORMAT_RG1616_REV,
- fetch_texel_1d_f_rg1616_rev,
- fetch_texel_2d_f_rg1616_rev,
- fetch_texel_3d_f_rg1616_rev,
- store_texel_rg1616_rev,
- },
- {
- MESA_FORMAT_ARGB2101010,
- fetch_texel_1d_f_argb2101010,
- fetch_texel_2d_f_argb2101010,
- fetch_texel_3d_f_argb2101010,
- store_texel_argb2101010
- },
- {
- MESA_FORMAT_Z24_S8,
- fetch_texel_1d_f_z24_s8,
- fetch_texel_2d_f_z24_s8,
- fetch_texel_3d_f_z24_s8,
- store_texel_z24_s8
- },
- {
- MESA_FORMAT_S8_Z24,
- fetch_texel_1d_f_s8_z24,
- fetch_texel_2d_f_s8_z24,
- fetch_texel_3d_f_s8_z24,
- store_texel_s8_z24
- },
- {
- MESA_FORMAT_Z16,
- fetch_texel_1d_f_z16,
- fetch_texel_2d_f_z16,
- fetch_texel_3d_f_z16,
- store_texel_z16
- },
- {
- MESA_FORMAT_X8_Z24,
- fetch_texel_1d_f_s8_z24,
- fetch_texel_2d_f_s8_z24,
- fetch_texel_3d_f_s8_z24,
- store_texel_s8_z24
- },
- {
- MESA_FORMAT_Z24_X8,
- fetch_texel_1d_f_z24_s8,
- fetch_texel_2d_f_z24_s8,
- fetch_texel_3d_f_z24_s8,
- store_texel_z24_s8
- },
- {
- MESA_FORMAT_Z32,
- fetch_texel_1d_f_z32,
- fetch_texel_2d_f_z32,
- fetch_texel_3d_f_z32,
- store_texel_z32
- },
- {
- MESA_FORMAT_S8,
- NULL,
- NULL,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGB8,
- fetch_texel_1d_srgb8,
- fetch_texel_2d_srgb8,
- fetch_texel_3d_srgb8,
- store_texel_srgb8
- },
- {
- MESA_FORMAT_SRGBA8,
- fetch_texel_1d_srgba8,
- fetch_texel_2d_srgba8,
- fetch_texel_3d_srgba8,
- store_texel_srgba8
- },
- {
- MESA_FORMAT_SARGB8,
- fetch_texel_1d_sargb8,
- fetch_texel_2d_sargb8,
- fetch_texel_3d_sargb8,
- store_texel_sargb8
- },
- {
- MESA_FORMAT_SL8,
- fetch_texel_1d_sl8,
- fetch_texel_2d_sl8,
- fetch_texel_3d_sl8,
- store_texel_sl8
- },
- {
- MESA_FORMAT_SLA8,
- fetch_texel_1d_sla8,
- fetch_texel_2d_sla8,
- fetch_texel_3d_sla8,
- store_texel_sla8
- },
- {
- MESA_FORMAT_SRGB_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_srgb_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGBA_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGBA_DXT3,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt3,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SRGBA_DXT5,
- NULL,
- _mesa_fetch_texel_2d_f_srgba_dxt5,
- NULL,
- NULL
- },
-
- {
- MESA_FORMAT_RGB_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgb_fxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_fxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGB_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgb_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_DXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_DXT3,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt3,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_DXT5,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_dxt5,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RGBA_FLOAT32,
- fetch_texel_1d_f_rgba_f32,
- fetch_texel_2d_f_rgba_f32,
- fetch_texel_3d_f_rgba_f32,
- store_texel_rgba_f32
- },
- {
- MESA_FORMAT_RGBA_FLOAT16,
- fetch_texel_1d_f_rgba_f16,
- fetch_texel_2d_f_rgba_f16,
- fetch_texel_3d_f_rgba_f16,
- store_texel_rgba_f16
- },
- {
- MESA_FORMAT_RGB_FLOAT32,
- fetch_texel_1d_f_rgb_f32,
- fetch_texel_2d_f_rgb_f32,
- fetch_texel_3d_f_rgb_f32,
- store_texel_rgb_f32
- },
- {
- MESA_FORMAT_RGB_FLOAT16,
- fetch_texel_1d_f_rgb_f16,
- fetch_texel_2d_f_rgb_f16,
- fetch_texel_3d_f_rgb_f16,
- store_texel_rgb_f16
- },
- {
- MESA_FORMAT_ALPHA_FLOAT32,
- fetch_texel_1d_f_alpha_f32,
- fetch_texel_2d_f_alpha_f32,
- fetch_texel_3d_f_alpha_f32,
- store_texel_alpha_f32
- },
- {
- MESA_FORMAT_ALPHA_FLOAT16,
- fetch_texel_1d_f_alpha_f16,
- fetch_texel_2d_f_alpha_f16,
- fetch_texel_3d_f_alpha_f16,
- store_texel_alpha_f16
- },
- {
- MESA_FORMAT_LUMINANCE_FLOAT32,
- fetch_texel_1d_f_luminance_f32,
- fetch_texel_2d_f_luminance_f32,
- fetch_texel_3d_f_luminance_f32,
- store_texel_luminance_f32
- },
- {
- MESA_FORMAT_LUMINANCE_FLOAT16,
- fetch_texel_1d_f_luminance_f16,
- fetch_texel_2d_f_luminance_f16,
- fetch_texel_3d_f_luminance_f16,
- store_texel_luminance_f16
- },
- {
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
- fetch_texel_1d_f_luminance_alpha_f32,
- fetch_texel_2d_f_luminance_alpha_f32,
- fetch_texel_3d_f_luminance_alpha_f32,
- store_texel_luminance_alpha_f32
- },
- {
- MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
- fetch_texel_1d_f_luminance_alpha_f16,
- fetch_texel_2d_f_luminance_alpha_f16,
- fetch_texel_3d_f_luminance_alpha_f16,
- store_texel_luminance_alpha_f16
- },
- {
- MESA_FORMAT_INTENSITY_FLOAT32,
- fetch_texel_1d_f_intensity_f32,
- fetch_texel_2d_f_intensity_f32,
- fetch_texel_3d_f_intensity_f32,
- store_texel_intensity_f32
- },
- {
- MESA_FORMAT_INTENSITY_FLOAT16,
- fetch_texel_1d_f_intensity_f16,
- fetch_texel_2d_f_intensity_f16,
- fetch_texel_3d_f_intensity_f16,
- store_texel_intensity_f16
- },
- {
- MESA_FORMAT_R_FLOAT32,
- fetch_texel_1d_f_r_f32,
- fetch_texel_2d_f_r_f32,
- fetch_texel_3d_f_r_f32,
- store_texel_r_f32
- },
- {
- MESA_FORMAT_R_FLOAT16,
- fetch_texel_1d_f_r_f16,
- fetch_texel_2d_f_r_f16,
- fetch_texel_3d_f_r_f16,
- store_texel_r_f16
- },
- {
- MESA_FORMAT_RG_FLOAT32,
- fetch_texel_1d_f_rg_f32,
- fetch_texel_2d_f_rg_f32,
- fetch_texel_3d_f_rg_f32,
- store_texel_rg_f32
- },
- {
- MESA_FORMAT_RG_FLOAT16,
- fetch_texel_1d_f_rg_f16,
- fetch_texel_2d_f_rg_f16,
- fetch_texel_3d_f_rg_f16,
- store_texel_rg_f16
- },
-
- /* non-normalized, signed int */
- {
- MESA_FORMAT_RGBA_INT8,
- fetch_texel_1d_rgba_int8,
- fetch_texel_2d_rgba_int8,
- fetch_texel_3d_rgba_int8,
- store_texel_rgba_int8
- },
- {
- MESA_FORMAT_RGBA_INT16,
- fetch_texel_1d_rgba_int16,
- fetch_texel_2d_rgba_int16,
- fetch_texel_3d_rgba_int16,
- store_texel_rgba_int16
- },
- {
- MESA_FORMAT_RGBA_INT32,
- fetch_texel_1d_rgba_int32,
- fetch_texel_2d_rgba_int32,
- fetch_texel_3d_rgba_int32,
- store_texel_rgba_int32
- },
-
- /* non-normalized, unsigned int */
- {
- MESA_FORMAT_RGBA_UINT8,
- fetch_texel_1d_rgba_uint8,
- fetch_texel_2d_rgba_uint8,
- fetch_texel_3d_rgba_uint8,
- store_texel_rgba_uint8
- },
- {
- MESA_FORMAT_RGBA_UINT16,
- fetch_texel_1d_rgba_uint16,
- fetch_texel_2d_rgba_uint16,
- fetch_texel_3d_rgba_uint16,
- store_texel_rgba_uint16
- },
- {
- MESA_FORMAT_RGBA_UINT32,
- fetch_texel_1d_rgba_uint32,
- fetch_texel_2d_rgba_uint32,
- fetch_texel_3d_rgba_uint32,
- store_texel_rgba_uint32
- },
-
- /* dudv */
- {
- MESA_FORMAT_DUDV8,
- fetch_texel_1d_dudv8,
- fetch_texel_2d_dudv8,
- fetch_texel_3d_dudv8,
- NULL
- },
-
- /* signed, normalized */
- {
- MESA_FORMAT_SIGNED_R8,
- fetch_texel_1d_signed_r8,
- fetch_texel_2d_signed_r8,
- fetch_texel_3d_signed_r8,
- store_texel_signed_r8
- },
- {
- MESA_FORMAT_SIGNED_RG88_REV,
- fetch_texel_1d_signed_rg88_rev,
- fetch_texel_2d_signed_rg88_rev,
- fetch_texel_3d_signed_rg88_rev,
- store_texel_signed_rg88_rev
- },
- {
- MESA_FORMAT_SIGNED_RGBX8888,
- fetch_texel_1d_signed_rgbx8888,
- fetch_texel_2d_signed_rgbx8888,
- fetch_texel_3d_signed_rgbx8888,
- store_texel_signed_rgbx8888
- },
- {
- MESA_FORMAT_SIGNED_RGBA8888,
- fetch_texel_1d_signed_rgba8888,
- fetch_texel_2d_signed_rgba8888,
- fetch_texel_3d_signed_rgba8888,
- store_texel_signed_rgba8888
- },
- {
- MESA_FORMAT_SIGNED_RGBA8888_REV,
- fetch_texel_1d_signed_rgba8888_rev,
- fetch_texel_2d_signed_rgba8888_rev,
- fetch_texel_3d_signed_rgba8888_rev,
- store_texel_signed_rgba8888_rev
- },
- {
- MESA_FORMAT_SIGNED_R16,
- fetch_texel_1d_signed_r16,
- fetch_texel_2d_signed_r16,
- fetch_texel_3d_signed_r16,
- store_texel_signed_r16
- },
- {
- MESA_FORMAT_SIGNED_GR1616,
- fetch_texel_1d_signed_rg1616,
- fetch_texel_2d_signed_rg1616,
- fetch_texel_3d_signed_rg1616,
- store_texel_signed_rg1616
- },
- {
- MESA_FORMAT_SIGNED_RGB_16,
- fetch_texel_1d_signed_rgb_16,
- fetch_texel_2d_signed_rgb_16,
- fetch_texel_3d_signed_rgb_16,
- store_texel_signed_rgb_16
- },
- {
- MESA_FORMAT_SIGNED_RGBA_16,
- fetch_texel_1d_signed_rgba_16,
- fetch_texel_2d_signed_rgba_16,
- 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
- },
- {
- MESA_FORMAT_RED_RGTC1,
- NULL,
- _mesa_fetch_texel_2d_f_red_rgtc1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SIGNED_RED_RGTC1,
- NULL,
- _mesa_fetch_texel_2d_f_signed_red_rgtc1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_RG_RGTC2,
- NULL,
- _mesa_fetch_texel_2d_f_rg_rgtc2,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SIGNED_RG_RGTC2,
- NULL,
- _mesa_fetch_texel_2d_f_signed_rg_rgtc2,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_L_LATC1,
- NULL,
- _mesa_fetch_texel_2d_f_l_latc1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SIGNED_L_LATC1,
- NULL,
- _mesa_fetch_texel_2d_f_signed_l_latc1,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_LA_LATC2,
- NULL,
- _mesa_fetch_texel_2d_f_la_latc2,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SIGNED_LA_LATC2,
- NULL,
- _mesa_fetch_texel_2d_f_signed_la_latc2,
- NULL,
- NULL
- },
- {
- MESA_FORMAT_SIGNED_A8,
- fetch_texel_1d_signed_a8,
- fetch_texel_2d_signed_a8,
- fetch_texel_3d_signed_a8,
- store_texel_signed_a8
- },
- {
- MESA_FORMAT_SIGNED_L8,
- fetch_texel_1d_signed_l8,
- fetch_texel_2d_signed_l8,
- fetch_texel_3d_signed_l8,
- store_texel_signed_l8
- },
- {
- MESA_FORMAT_SIGNED_AL88,
- fetch_texel_1d_signed_al88,
- fetch_texel_2d_signed_al88,
- fetch_texel_3d_signed_al88,
- store_texel_signed_al88
- },
- {
- MESA_FORMAT_SIGNED_I8,
- fetch_texel_1d_signed_i8,
- fetch_texel_2d_signed_i8,
- fetch_texel_3d_signed_i8,
- store_texel_signed_i8
- },
- {
- MESA_FORMAT_SIGNED_A16,
- fetch_texel_1d_signed_a16,
- fetch_texel_2d_signed_a16,
- fetch_texel_3d_signed_a16,
- store_texel_signed_a16
- },
- {
- MESA_FORMAT_SIGNED_L16,
- fetch_texel_1d_signed_l16,
- fetch_texel_2d_signed_l16,
- fetch_texel_3d_signed_l16,
- store_texel_signed_l16
- },
- {
- MESA_FORMAT_SIGNED_AL1616,
- fetch_texel_1d_signed_al1616,
- fetch_texel_2d_signed_al1616,
- fetch_texel_3d_signed_al1616,
- store_texel_signed_al1616
- },
- {
- MESA_FORMAT_SIGNED_I16,
- fetch_texel_1d_signed_i16,
- fetch_texel_2d_signed_i16,
- fetch_texel_3d_signed_i16,
- store_texel_signed_i16
- },
- {
- MESA_FORMAT_RGB9_E5_FLOAT,
- fetch_texel_1d_rgb9_e5,
- fetch_texel_2d_rgb9_e5,
- fetch_texel_3d_rgb9_e5,
- store_texel_rgb9_e5
- },
- {
- MESA_FORMAT_R11_G11_B10_FLOAT,
- fetch_texel_1d_r11_g11_b10f,
- fetch_texel_2d_r11_g11_b10f,
- fetch_texel_3d_r11_g11_b10f,
- store_texel_r11_g11_b10f
- }
-};
-
-
-FetchTexelFuncF
-_mesa_get_texel_fetch_func(gl_format format, GLuint dims)
-{
-#ifdef DEBUG
- /* check that the table entries are sorted by format name */
- gl_format fmt;
- for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) {
- assert(texfetch_funcs[fmt].Name == fmt);
- }
-#endif
-
- assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT);
- assert(format < MESA_FORMAT_COUNT);
-
- switch (dims) {
- case 1:
- return texfetch_funcs[format].Fetch1D;
- case 2:
- return texfetch_funcs[format].Fetch2D;
- case 3:
- return texfetch_funcs[format].Fetch3D;
- default:
- assert(0 && "bad dims in _mesa_get_texel_fetch_func");
- return NULL;
- }
-}
-
-
-StoreTexelFunc
-_mesa_get_texel_store_func(gl_format format)
-{
- assert(format < MESA_FORMAT_COUNT);
- return texfetch_funcs[format].StoreTexel;
-}
-
-
-/**
- * Adaptor for fetching a GLchan texel from a float-valued texture.
- */
-static void
-fetch_texel_float_to_chan(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLchan *texelOut)
-{
- GLfloat temp[4];
- GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
-
- ASSERT(texImage->FetchTexelf);
- texImage->FetchTexelf(texImage, i, j, k, temp);
- if (baseFormat == GL_DEPTH_COMPONENT ||
- baseFormat == GL_DEPTH_STENCIL_EXT) {
- /* just one channel */
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
- }
- else {
- /* four channels */
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]);
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]);
- UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]);
- }
-}
-
-
-#if 0
-/**
- * Adaptor for fetching a float texel from a GLchan-valued texture.
- */
-static void
-fetch_texel_chan_to_float(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texelOut)
-{
- GLchan temp[4];
- GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
-
- ASSERT(texImage->FetchTexelc);
- texImage->FetchTexelc(texImage, i, j, k, temp);
- if (baseFormat == GL_DEPTH_COMPONENT ||
- baseFormat == GL_DEPTH_STENCIL_EXT) {
- /* just one channel */
- texelOut[0] = CHAN_TO_FLOAT(temp[0]);
- }
- else {
- /* four channels */
- texelOut[0] = CHAN_TO_FLOAT(temp[0]);
- texelOut[1] = CHAN_TO_FLOAT(temp[1]);
- texelOut[2] = CHAN_TO_FLOAT(temp[2]);
- texelOut[3] = CHAN_TO_FLOAT(temp[3]);
- }
-}
-#endif
-
-
-/**
- * Initialize the texture image's FetchTexelc and FetchTexelf methods.
- */
-void
-_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
-{
- gl_format format = texImage->TexFormat;
-
- ASSERT(dims == 1 || dims == 2 || dims == 3);
-
- if (texImage->TexObject->Sampler.sRGBDecode == GL_SKIP_DECODE_EXT &&
- _mesa_get_format_color_encoding(format) == GL_SRGB) {
- format = _mesa_get_srgb_format_linear(format);
- }
-
- texImage->FetchTexelf = _mesa_get_texel_fetch_func(format, dims);
-
- texImage->FetchTexelc = fetch_texel_float_to_chan;
-
- ASSERT(texImage->FetchTexelc);
- ASSERT(texImage->FetchTexelf);
-}
-
-void
-_mesa_update_fetch_functions(struct gl_texture_object *texObj)
-{
- GLuint face, i;
- GLuint dims;
-
- dims = _mesa_get_texture_dimensions(texObj->Target);
-
- for (face = 0; face < 6; face++) {
- for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
- if (texObj->Image[face][i]) {
- _mesa_set_fetch_functions(texObj->Image[face][i], dims);
- }
- }
- }
-}
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.7
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (c) 2009 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texfetch.c
+ *
+ * Texel fetch/store functions
+ *
+ * \author Gareth Hughes
+ */
+
+
+#include "colormac.h"
+#include "macros.h"
+#include "texcompress.h"
+#include "texcompress_fxt1.h"
+#include "texcompress_s3tc.h"
+#include "texcompress_rgtc.h"
+#include "texfetch.h"
+#include "teximage.h"
+#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
+#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
+
+
+/**
+ * Convert an 8-bit sRGB value from non-linear space to a
+ * linear RGB value in [0, 1].
+ * Implemented with a 256-entry lookup table.
+ */
+static INLINE GLfloat
+nonlinear_to_linear(GLubyte cs8)
+{
+ static GLfloat table[256];
+ static GLboolean tableReady = GL_FALSE;
+ if (!tableReady) {
+ /* compute lookup table now */
+ GLuint i;
+ for (i = 0; i < 256; i++) {
+ const GLfloat cs = UBYTE_TO_FLOAT(i);
+ if (cs <= 0.04045) {
+ table[i] = cs / 12.92f;
+ }
+ else {
+ table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4);
+ }
+ }
+ tableReady = GL_TRUE;
+ }
+ return table[cs8];
+}
+
+
+
+/* Texel fetch routines for all supported formats
+ */
+#define DIM 1
+#include "texfetch_tmp.h"
+
+#define DIM 2
+#include "texfetch_tmp.h"
+
+#define DIM 3
+#include "texfetch_tmp.h"
+
+/**
+ * Null texel fetch function.
+ *
+ * Have to have this so the FetchTexel function pointer is never NULL.
+ */
+static void fetch_null_texelf( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ (void) texImage; (void) i; (void) j; (void) k;
+ texel[RCOMP] = 0.0;
+ texel[GCOMP] = 0.0;
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 0.0;
+ _mesa_warning(NULL, "fetch_null_texelf() called!");
+}
+
+static void store_null_texel(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ (void) texImage;
+ (void) i;
+ (void) j;
+ (void) k;
+ (void) texel;
+ /* no-op */
+}
+
+
+
+/**
+ * Table to map MESA_FORMAT_ to texel fetch/store funcs.
+ * XXX this is somewhat temporary.
+ */
+static struct {
+ gl_format Name;
+ FetchTexelFuncF Fetch1D;
+ FetchTexelFuncF Fetch2D;
+ FetchTexelFuncF Fetch3D;
+ StoreTexelFunc StoreTexel;
+}
+texfetch_funcs[MESA_FORMAT_COUNT] =
+{
+ {
+ MESA_FORMAT_NONE,
+ fetch_null_texelf,
+ fetch_null_texelf,
+ fetch_null_texelf,
+ store_null_texel
+ },
+
+ {
+ MESA_FORMAT_RGBA8888,
+ fetch_texel_1d_f_rgba8888,
+ fetch_texel_2d_f_rgba8888,
+ fetch_texel_3d_f_rgba8888,
+ store_texel_rgba8888
+ },
+ {
+ MESA_FORMAT_RGBA8888_REV,
+ fetch_texel_1d_f_rgba8888_rev,
+ fetch_texel_2d_f_rgba8888_rev,
+ fetch_texel_3d_f_rgba8888_rev,
+ store_texel_rgba8888_rev
+ },
+ {
+ MESA_FORMAT_ARGB8888,
+ fetch_texel_1d_f_argb8888,
+ fetch_texel_2d_f_argb8888,
+ fetch_texel_3d_f_argb8888,
+ store_texel_argb8888
+ },
+ {
+ MESA_FORMAT_ARGB8888_REV,
+ fetch_texel_1d_f_argb8888_rev,
+ fetch_texel_2d_f_argb8888_rev,
+ fetch_texel_3d_f_argb8888_rev,
+ store_texel_argb8888_rev
+ },
+ {
+ MESA_FORMAT_XRGB8888,
+ fetch_texel_1d_f_xrgb8888,
+ fetch_texel_2d_f_xrgb8888,
+ fetch_texel_3d_f_xrgb8888,
+ store_texel_xrgb8888
+ },
+ {
+ MESA_FORMAT_XRGB8888_REV,
+ fetch_texel_1d_f_xrgb8888_rev,
+ fetch_texel_2d_f_xrgb8888_rev,
+ fetch_texel_3d_f_xrgb8888_rev,
+ store_texel_xrgb8888_rev,
+ },
+ {
+ MESA_FORMAT_RGB888,
+ fetch_texel_1d_f_rgb888,
+ fetch_texel_2d_f_rgb888,
+ fetch_texel_3d_f_rgb888,
+ store_texel_rgb888
+ },
+ {
+ MESA_FORMAT_BGR888,
+ fetch_texel_1d_f_bgr888,
+ fetch_texel_2d_f_bgr888,
+ fetch_texel_3d_f_bgr888,
+ store_texel_bgr888
+ },
+ {
+ MESA_FORMAT_RGB565,
+ fetch_texel_1d_f_rgb565,
+ fetch_texel_2d_f_rgb565,
+ fetch_texel_3d_f_rgb565,
+ store_texel_rgb565
+ },
+ {
+ MESA_FORMAT_RGB565_REV,
+ fetch_texel_1d_f_rgb565_rev,
+ fetch_texel_2d_f_rgb565_rev,
+ fetch_texel_3d_f_rgb565_rev,
+ store_texel_rgb565_rev
+ },
+ {
+ MESA_FORMAT_ARGB4444,
+ fetch_texel_1d_f_argb4444,
+ fetch_texel_2d_f_argb4444,
+ fetch_texel_3d_f_argb4444,
+ store_texel_argb4444
+ },
+ {
+ MESA_FORMAT_ARGB4444_REV,
+ fetch_texel_1d_f_argb4444_rev,
+ fetch_texel_2d_f_argb4444_rev,
+ fetch_texel_3d_f_argb4444_rev,
+ store_texel_argb4444_rev
+ },
+ {
+ MESA_FORMAT_RGBA5551,
+ fetch_texel_1d_f_rgba5551,
+ fetch_texel_2d_f_rgba5551,
+ fetch_texel_3d_f_rgba5551,
+ store_texel_rgba5551
+ },
+ {
+ MESA_FORMAT_ARGB1555,
+ fetch_texel_1d_f_argb1555,
+ fetch_texel_2d_f_argb1555,
+ fetch_texel_3d_f_argb1555,
+ store_texel_argb1555
+ },
+ {
+ MESA_FORMAT_ARGB1555_REV,
+ fetch_texel_1d_f_argb1555_rev,
+ fetch_texel_2d_f_argb1555_rev,
+ fetch_texel_3d_f_argb1555_rev,
+ store_texel_argb1555_rev
+ },
+ {
+ MESA_FORMAT_AL44,
+ fetch_texel_1d_f_al44,
+ fetch_texel_2d_f_al44,
+ fetch_texel_3d_f_al44,
+ store_texel_al44
+ },
+ {
+ MESA_FORMAT_AL88,
+ fetch_texel_1d_f_al88,
+ fetch_texel_2d_f_al88,
+ fetch_texel_3d_f_al88,
+ store_texel_al88
+ },
+ {
+ MESA_FORMAT_AL88_REV,
+ fetch_texel_1d_f_al88_rev,
+ fetch_texel_2d_f_al88_rev,
+ fetch_texel_3d_f_al88_rev,
+ store_texel_al88_rev
+ },
+ {
+ MESA_FORMAT_AL1616,
+ fetch_texel_1d_f_al1616,
+ fetch_texel_2d_f_al1616,
+ fetch_texel_3d_f_al1616,
+ store_texel_al1616
+ },
+ {
+ MESA_FORMAT_AL1616_REV,
+ fetch_texel_1d_f_al1616_rev,
+ fetch_texel_2d_f_al1616_rev,
+ fetch_texel_3d_f_al1616_rev,
+ store_texel_al1616_rev
+ },
+ {
+ MESA_FORMAT_RGB332,
+ fetch_texel_1d_f_rgb332,
+ fetch_texel_2d_f_rgb332,
+ fetch_texel_3d_f_rgb332,
+ store_texel_rgb332
+ },
+ {
+ MESA_FORMAT_A8,
+ fetch_texel_1d_f_a8,
+ fetch_texel_2d_f_a8,
+ fetch_texel_3d_f_a8,
+ store_texel_a8
+ },
+ {
+ MESA_FORMAT_A16,
+ fetch_texel_1d_f_a16,
+ fetch_texel_2d_f_a16,
+ fetch_texel_3d_f_a16,
+ store_texel_a16
+ },
+ {
+ MESA_FORMAT_L8,
+ fetch_texel_1d_f_l8,
+ fetch_texel_2d_f_l8,
+ fetch_texel_3d_f_l8,
+ store_texel_l8
+ },
+ {
+ MESA_FORMAT_L16,
+ fetch_texel_1d_f_l16,
+ fetch_texel_2d_f_l16,
+ fetch_texel_3d_f_l16,
+ store_texel_l16
+ },
+ {
+ MESA_FORMAT_I8,
+ fetch_texel_1d_f_i8,
+ fetch_texel_2d_f_i8,
+ fetch_texel_3d_f_i8,
+ store_texel_i8
+ },
+ {
+ MESA_FORMAT_I16,
+ fetch_texel_1d_f_i16,
+ fetch_texel_2d_f_i16,
+ fetch_texel_3d_f_i16,
+ store_texel_i16
+ },
+ {
+ MESA_FORMAT_CI8,
+ fetch_texel_1d_f_ci8,
+ fetch_texel_2d_f_ci8,
+ fetch_texel_3d_f_ci8,
+ store_texel_ci8
+ },
+ {
+ MESA_FORMAT_YCBCR,
+ fetch_texel_1d_f_ycbcr,
+ fetch_texel_2d_f_ycbcr,
+ fetch_texel_3d_f_ycbcr,
+ store_texel_ycbcr
+ },
+ {
+ MESA_FORMAT_YCBCR_REV,
+ fetch_texel_1d_f_ycbcr_rev,
+ fetch_texel_2d_f_ycbcr_rev,
+ fetch_texel_3d_f_ycbcr_rev,
+ store_texel_ycbcr_rev
+ },
+ {
+ MESA_FORMAT_R8,
+ fetch_texel_1d_f_r8,
+ fetch_texel_2d_f_r8,
+ fetch_texel_3d_f_r8,
+ store_texel_r8,
+ },
+ {
+ MESA_FORMAT_RG88,
+ fetch_texel_1d_f_rg88,
+ fetch_texel_2d_f_rg88,
+ fetch_texel_3d_f_rg88,
+ store_texel_rg88,
+ },
+ {
+ MESA_FORMAT_RG88_REV,
+ fetch_texel_1d_f_rg88_rev,
+ fetch_texel_2d_f_rg88_rev,
+ fetch_texel_3d_f_rg88_rev,
+ store_texel_rg88_rev,
+ },
+ {
+ MESA_FORMAT_R16,
+ fetch_texel_1d_f_r16,
+ fetch_texel_2d_f_r16,
+ fetch_texel_3d_f_r16,
+ store_texel_r16,
+ },
+ {
+ MESA_FORMAT_RG1616,
+ fetch_texel_1d_f_rg1616,
+ fetch_texel_2d_f_rg1616,
+ fetch_texel_3d_f_rg1616,
+ store_texel_rg1616,
+ },
+ {
+ MESA_FORMAT_RG1616_REV,
+ fetch_texel_1d_f_rg1616_rev,
+ fetch_texel_2d_f_rg1616_rev,
+ fetch_texel_3d_f_rg1616_rev,
+ store_texel_rg1616_rev,
+ },
+ {
+ MESA_FORMAT_ARGB2101010,
+ fetch_texel_1d_f_argb2101010,
+ fetch_texel_2d_f_argb2101010,
+ fetch_texel_3d_f_argb2101010,
+ store_texel_argb2101010
+ },
+ {
+ MESA_FORMAT_Z24_S8,
+ fetch_texel_1d_f_z24_s8,
+ fetch_texel_2d_f_z24_s8,
+ fetch_texel_3d_f_z24_s8,
+ store_texel_z24_s8
+ },
+ {
+ MESA_FORMAT_S8_Z24,
+ fetch_texel_1d_f_s8_z24,
+ fetch_texel_2d_f_s8_z24,
+ fetch_texel_3d_f_s8_z24,
+ store_texel_s8_z24
+ },
+ {
+ MESA_FORMAT_Z16,
+ fetch_texel_1d_f_z16,
+ fetch_texel_2d_f_z16,
+ fetch_texel_3d_f_z16,
+ store_texel_z16
+ },
+ {
+ MESA_FORMAT_X8_Z24,
+ fetch_texel_1d_f_s8_z24,
+ fetch_texel_2d_f_s8_z24,
+ fetch_texel_3d_f_s8_z24,
+ store_texel_s8_z24
+ },
+ {
+ MESA_FORMAT_Z24_X8,
+ fetch_texel_1d_f_z24_s8,
+ fetch_texel_2d_f_z24_s8,
+ fetch_texel_3d_f_z24_s8,
+ store_texel_z24_s8
+ },
+ {
+ MESA_FORMAT_Z32,
+ fetch_texel_1d_f_z32,
+ fetch_texel_2d_f_z32,
+ fetch_texel_3d_f_z32,
+ store_texel_z32
+ },
+ {
+ MESA_FORMAT_S8,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SRGB8,
+ fetch_texel_1d_srgb8,
+ fetch_texel_2d_srgb8,
+ fetch_texel_3d_srgb8,
+ store_texel_srgb8
+ },
+ {
+ MESA_FORMAT_SRGBA8,
+ fetch_texel_1d_srgba8,
+ fetch_texel_2d_srgba8,
+ fetch_texel_3d_srgba8,
+ store_texel_srgba8
+ },
+ {
+ MESA_FORMAT_SARGB8,
+ fetch_texel_1d_sargb8,
+ fetch_texel_2d_sargb8,
+ fetch_texel_3d_sargb8,
+ store_texel_sargb8
+ },
+ {
+ MESA_FORMAT_SL8,
+ fetch_texel_1d_sl8,
+ fetch_texel_2d_sl8,
+ fetch_texel_3d_sl8,
+ store_texel_sl8
+ },
+ {
+ MESA_FORMAT_SLA8,
+ fetch_texel_1d_sla8,
+ fetch_texel_2d_sla8,
+ fetch_texel_3d_sla8,
+ store_texel_sla8
+ },
+ {
+ MESA_FORMAT_SRGB_DXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_srgb_dxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SRGBA_DXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_srgba_dxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SRGBA_DXT3,
+ NULL,
+ _mesa_fetch_texel_2d_f_srgba_dxt3,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SRGBA_DXT5,
+ NULL,
+ _mesa_fetch_texel_2d_f_srgba_dxt5,
+ NULL,
+ NULL
+ },
+
+ {
+ MESA_FORMAT_RGB_FXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgb_fxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_FXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgba_fxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGB_DXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgb_dxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_DXT1,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgba_dxt1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_DXT3,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgba_dxt3,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_DXT5,
+ NULL,
+ _mesa_fetch_texel_2d_f_rgba_dxt5,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RGBA_FLOAT32,
+ fetch_texel_1d_f_rgba_f32,
+ fetch_texel_2d_f_rgba_f32,
+ fetch_texel_3d_f_rgba_f32,
+ store_texel_rgba_f32
+ },
+ {
+ MESA_FORMAT_RGBA_FLOAT16,
+ fetch_texel_1d_f_rgba_f16,
+ fetch_texel_2d_f_rgba_f16,
+ fetch_texel_3d_f_rgba_f16,
+ store_texel_rgba_f16
+ },
+ {
+ MESA_FORMAT_RGB_FLOAT32,
+ fetch_texel_1d_f_rgb_f32,
+ fetch_texel_2d_f_rgb_f32,
+ fetch_texel_3d_f_rgb_f32,
+ store_texel_rgb_f32
+ },
+ {
+ MESA_FORMAT_RGB_FLOAT16,
+ fetch_texel_1d_f_rgb_f16,
+ fetch_texel_2d_f_rgb_f16,
+ fetch_texel_3d_f_rgb_f16,
+ store_texel_rgb_f16
+ },
+ {
+ MESA_FORMAT_ALPHA_FLOAT32,
+ fetch_texel_1d_f_alpha_f32,
+ fetch_texel_2d_f_alpha_f32,
+ fetch_texel_3d_f_alpha_f32,
+ store_texel_alpha_f32
+ },
+ {
+ MESA_FORMAT_ALPHA_FLOAT16,
+ fetch_texel_1d_f_alpha_f16,
+ fetch_texel_2d_f_alpha_f16,
+ fetch_texel_3d_f_alpha_f16,
+ store_texel_alpha_f16
+ },
+ {
+ MESA_FORMAT_LUMINANCE_FLOAT32,
+ fetch_texel_1d_f_luminance_f32,
+ fetch_texel_2d_f_luminance_f32,
+ fetch_texel_3d_f_luminance_f32,
+ store_texel_luminance_f32
+ },
+ {
+ MESA_FORMAT_LUMINANCE_FLOAT16,
+ fetch_texel_1d_f_luminance_f16,
+ fetch_texel_2d_f_luminance_f16,
+ fetch_texel_3d_f_luminance_f16,
+ store_texel_luminance_f16
+ },
+ {
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
+ fetch_texel_1d_f_luminance_alpha_f32,
+ fetch_texel_2d_f_luminance_alpha_f32,
+ fetch_texel_3d_f_luminance_alpha_f32,
+ store_texel_luminance_alpha_f32
+ },
+ {
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
+ fetch_texel_1d_f_luminance_alpha_f16,
+ fetch_texel_2d_f_luminance_alpha_f16,
+ fetch_texel_3d_f_luminance_alpha_f16,
+ store_texel_luminance_alpha_f16
+ },
+ {
+ MESA_FORMAT_INTENSITY_FLOAT32,
+ fetch_texel_1d_f_intensity_f32,
+ fetch_texel_2d_f_intensity_f32,
+ fetch_texel_3d_f_intensity_f32,
+ store_texel_intensity_f32
+ },
+ {
+ MESA_FORMAT_INTENSITY_FLOAT16,
+ fetch_texel_1d_f_intensity_f16,
+ fetch_texel_2d_f_intensity_f16,
+ fetch_texel_3d_f_intensity_f16,
+ store_texel_intensity_f16
+ },
+ {
+ MESA_FORMAT_R_FLOAT32,
+ fetch_texel_1d_f_r_f32,
+ fetch_texel_2d_f_r_f32,
+ fetch_texel_3d_f_r_f32,
+ store_texel_r_f32
+ },
+ {
+ MESA_FORMAT_R_FLOAT16,
+ fetch_texel_1d_f_r_f16,
+ fetch_texel_2d_f_r_f16,
+ fetch_texel_3d_f_r_f16,
+ store_texel_r_f16
+ },
+ {
+ MESA_FORMAT_RG_FLOAT32,
+ fetch_texel_1d_f_rg_f32,
+ fetch_texel_2d_f_rg_f32,
+ fetch_texel_3d_f_rg_f32,
+ store_texel_rg_f32
+ },
+ {
+ MESA_FORMAT_RG_FLOAT16,
+ fetch_texel_1d_f_rg_f16,
+ fetch_texel_2d_f_rg_f16,
+ fetch_texel_3d_f_rg_f16,
+ store_texel_rg_f16
+ },
+
+ /* non-normalized, signed int */
+ {
+ MESA_FORMAT_RGBA_INT8,
+ fetch_texel_1d_rgba_int8,
+ fetch_texel_2d_rgba_int8,
+ fetch_texel_3d_rgba_int8,
+ store_texel_rgba_int8
+ },
+ {
+ MESA_FORMAT_RGBA_INT16,
+ fetch_texel_1d_rgba_int16,
+ fetch_texel_2d_rgba_int16,
+ fetch_texel_3d_rgba_int16,
+ store_texel_rgba_int16
+ },
+ {
+ MESA_FORMAT_RGBA_INT32,
+ fetch_texel_1d_rgba_int32,
+ fetch_texel_2d_rgba_int32,
+ fetch_texel_3d_rgba_int32,
+ store_texel_rgba_int32
+ },
+
+ /* non-normalized, unsigned int */
+ {
+ MESA_FORMAT_RGBA_UINT8,
+ fetch_texel_1d_rgba_uint8,
+ fetch_texel_2d_rgba_uint8,
+ fetch_texel_3d_rgba_uint8,
+ store_texel_rgba_uint8
+ },
+ {
+ MESA_FORMAT_RGBA_UINT16,
+ fetch_texel_1d_rgba_uint16,
+ fetch_texel_2d_rgba_uint16,
+ fetch_texel_3d_rgba_uint16,
+ store_texel_rgba_uint16
+ },
+ {
+ MESA_FORMAT_RGBA_UINT32,
+ fetch_texel_1d_rgba_uint32,
+ fetch_texel_2d_rgba_uint32,
+ fetch_texel_3d_rgba_uint32,
+ store_texel_rgba_uint32
+ },
+
+ /* dudv */
+ {
+ MESA_FORMAT_DUDV8,
+ fetch_texel_1d_dudv8,
+ fetch_texel_2d_dudv8,
+ fetch_texel_3d_dudv8,
+ NULL
+ },
+
+ /* signed, normalized */
+ {
+ MESA_FORMAT_SIGNED_R8,
+ fetch_texel_1d_signed_r8,
+ fetch_texel_2d_signed_r8,
+ fetch_texel_3d_signed_r8,
+ store_texel_signed_r8
+ },
+ {
+ MESA_FORMAT_SIGNED_RG88_REV,
+ fetch_texel_1d_signed_rg88_rev,
+ fetch_texel_2d_signed_rg88_rev,
+ fetch_texel_3d_signed_rg88_rev,
+ store_texel_signed_rg88_rev
+ },
+ {
+ MESA_FORMAT_SIGNED_RGBX8888,
+ fetch_texel_1d_signed_rgbx8888,
+ fetch_texel_2d_signed_rgbx8888,
+ fetch_texel_3d_signed_rgbx8888,
+ store_texel_signed_rgbx8888
+ },
+ {
+ MESA_FORMAT_SIGNED_RGBA8888,
+ fetch_texel_1d_signed_rgba8888,
+ fetch_texel_2d_signed_rgba8888,
+ fetch_texel_3d_signed_rgba8888,
+ store_texel_signed_rgba8888
+ },
+ {
+ MESA_FORMAT_SIGNED_RGBA8888_REV,
+ fetch_texel_1d_signed_rgba8888_rev,
+ fetch_texel_2d_signed_rgba8888_rev,
+ fetch_texel_3d_signed_rgba8888_rev,
+ store_texel_signed_rgba8888_rev
+ },
+ {
+ MESA_FORMAT_SIGNED_R16,
+ fetch_texel_1d_signed_r16,
+ fetch_texel_2d_signed_r16,
+ fetch_texel_3d_signed_r16,
+ store_texel_signed_r16
+ },
+ {
+ MESA_FORMAT_SIGNED_GR1616,
+ fetch_texel_1d_signed_rg1616,
+ fetch_texel_2d_signed_rg1616,
+ fetch_texel_3d_signed_rg1616,
+ store_texel_signed_rg1616
+ },
+ {
+ MESA_FORMAT_SIGNED_RGB_16,
+ fetch_texel_1d_signed_rgb_16,
+ fetch_texel_2d_signed_rgb_16,
+ fetch_texel_3d_signed_rgb_16,
+ store_texel_signed_rgb_16
+ },
+ {
+ MESA_FORMAT_SIGNED_RGBA_16,
+ fetch_texel_1d_signed_rgba_16,
+ fetch_texel_2d_signed_rgba_16,
+ 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
+ },
+ {
+ MESA_FORMAT_RED_RGTC1,
+ NULL,
+ _mesa_fetch_texel_2d_f_red_rgtc1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SIGNED_RED_RGTC1,
+ NULL,
+ _mesa_fetch_texel_2d_f_signed_red_rgtc1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_RG_RGTC2,
+ NULL,
+ _mesa_fetch_texel_2d_f_rg_rgtc2,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SIGNED_RG_RGTC2,
+ NULL,
+ _mesa_fetch_texel_2d_f_signed_rg_rgtc2,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_L_LATC1,
+ NULL,
+ _mesa_fetch_texel_2d_f_l_latc1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SIGNED_L_LATC1,
+ NULL,
+ _mesa_fetch_texel_2d_f_signed_l_latc1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_LA_LATC2,
+ NULL,
+ _mesa_fetch_texel_2d_f_la_latc2,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SIGNED_LA_LATC2,
+ NULL,
+ _mesa_fetch_texel_2d_f_signed_la_latc2,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SIGNED_A8,
+ fetch_texel_1d_signed_a8,
+ fetch_texel_2d_signed_a8,
+ fetch_texel_3d_signed_a8,
+ store_texel_signed_a8
+ },
+ {
+ MESA_FORMAT_SIGNED_L8,
+ fetch_texel_1d_signed_l8,
+ fetch_texel_2d_signed_l8,
+ fetch_texel_3d_signed_l8,
+ store_texel_signed_l8
+ },
+ {
+ MESA_FORMAT_SIGNED_AL88,
+ fetch_texel_1d_signed_al88,
+ fetch_texel_2d_signed_al88,
+ fetch_texel_3d_signed_al88,
+ store_texel_signed_al88
+ },
+ {
+ MESA_FORMAT_SIGNED_I8,
+ fetch_texel_1d_signed_i8,
+ fetch_texel_2d_signed_i8,
+ fetch_texel_3d_signed_i8,
+ store_texel_signed_i8
+ },
+ {
+ MESA_FORMAT_SIGNED_A16,
+ fetch_texel_1d_signed_a16,
+ fetch_texel_2d_signed_a16,
+ fetch_texel_3d_signed_a16,
+ store_texel_signed_a16
+ },
+ {
+ MESA_FORMAT_SIGNED_L16,
+ fetch_texel_1d_signed_l16,
+ fetch_texel_2d_signed_l16,
+ fetch_texel_3d_signed_l16,
+ store_texel_signed_l16
+ },
+ {
+ MESA_FORMAT_SIGNED_AL1616,
+ fetch_texel_1d_signed_al1616,
+ fetch_texel_2d_signed_al1616,
+ fetch_texel_3d_signed_al1616,
+ store_texel_signed_al1616
+ },
+ {
+ MESA_FORMAT_SIGNED_I16,
+ fetch_texel_1d_signed_i16,
+ fetch_texel_2d_signed_i16,
+ fetch_texel_3d_signed_i16,
+ store_texel_signed_i16
+ },
+ {
+ MESA_FORMAT_RGB9_E5_FLOAT,
+ fetch_texel_1d_rgb9_e5,
+ fetch_texel_2d_rgb9_e5,
+ fetch_texel_3d_rgb9_e5,
+ store_texel_rgb9_e5
+ },
+ {
+ MESA_FORMAT_R11_G11_B10_FLOAT,
+ fetch_texel_1d_r11_g11_b10f,
+ fetch_texel_2d_r11_g11_b10f,
+ fetch_texel_3d_r11_g11_b10f,
+ store_texel_r11_g11_b10f
+ },
+ {
+ MESA_FORMAT_Z32_FLOAT,
+ fetch_texel_1d_f_r_f32, /* Reuse the R32F functions. */
+ fetch_texel_2d_f_r_f32,
+ fetch_texel_3d_f_r_f32,
+ store_texel_r_f32
+ },
+ {
+ MESA_FORMAT_Z32_FLOAT_X24S8,
+ fetch_texel_1d_z32f_x24s8,
+ fetch_texel_2d_z32f_x24s8,
+ fetch_texel_3d_z32f_x24s8,
+ store_texel_z32f_x24s8
+ }
+};
+
+
+FetchTexelFuncF
+_mesa_get_texel_fetch_func(gl_format format, GLuint dims)
+{
+#ifdef DEBUG
+ /* check that the table entries are sorted by format name */
+ gl_format fmt;
+ for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) {
+ assert(texfetch_funcs[fmt].Name == fmt);
+ }
+#endif
+
+ assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT);
+ assert(format < MESA_FORMAT_COUNT);
+
+ switch (dims) {
+ case 1:
+ return texfetch_funcs[format].Fetch1D;
+ case 2:
+ return texfetch_funcs[format].Fetch2D;
+ case 3:
+ return texfetch_funcs[format].Fetch3D;
+ default:
+ assert(0 && "bad dims in _mesa_get_texel_fetch_func");
+ return NULL;
+ }
+}
+
+
+StoreTexelFunc
+_mesa_get_texel_store_func(gl_format format)
+{
+ assert(format < MESA_FORMAT_COUNT);
+ return texfetch_funcs[format].StoreTexel;
+}
+
+
+/**
+ * Adaptor for fetching a GLchan texel from a float-valued texture.
+ */
+static void
+fetch_texel_float_to_chan(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texelOut)
+{
+ GLfloat temp[4];
+ GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
+
+ ASSERT(texImage->FetchTexelf);
+ texImage->FetchTexelf(texImage, i, j, k, temp);
+ if (baseFormat == GL_DEPTH_COMPONENT ||
+ baseFormat == GL_DEPTH_STENCIL_EXT) {
+ /* just one channel */
+ UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
+ }
+ else {
+ /* four channels */
+ UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]);
+ }
+}
+
+
+#if 0
+/**
+ * Adaptor for fetching a float texel from a GLchan-valued texture.
+ */
+static void
+fetch_texel_chan_to_float(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texelOut)
+{
+ GLchan temp[4];
+ GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
+
+ ASSERT(texImage->FetchTexelc);
+ texImage->FetchTexelc(texImage, i, j, k, temp);
+ if (baseFormat == GL_DEPTH_COMPONENT ||
+ baseFormat == GL_DEPTH_STENCIL_EXT) {
+ /* just one channel */
+ texelOut[0] = CHAN_TO_FLOAT(temp[0]);
+ }
+ else {
+ /* four channels */
+ texelOut[0] = CHAN_TO_FLOAT(temp[0]);
+ texelOut[1] = CHAN_TO_FLOAT(temp[1]);
+ texelOut[2] = CHAN_TO_FLOAT(temp[2]);
+ texelOut[3] = CHAN_TO_FLOAT(temp[3]);
+ }
+}
+#endif
+
+
+/**
+ * Initialize the texture image's FetchTexelc and FetchTexelf methods.
+ */
+void
+_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
+{
+ gl_format format = texImage->TexFormat;
+
+ ASSERT(dims == 1 || dims == 2 || dims == 3);
+
+ if (texImage->TexObject->Sampler.sRGBDecode == GL_SKIP_DECODE_EXT &&
+ _mesa_get_format_color_encoding(format) == GL_SRGB) {
+ format = _mesa_get_srgb_format_linear(format);
+ }
+
+ texImage->FetchTexelf = _mesa_get_texel_fetch_func(format, dims);
+
+ texImage->FetchTexelc = fetch_texel_float_to_chan;
+
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
+}
+
+void
+_mesa_update_fetch_functions(struct gl_texture_object *texObj)
+{
+ GLuint face, i;
+ GLuint dims;
+
+ dims = _mesa_get_texture_dimensions(texObj->Target);
+
+ for (face = 0; face < 6; face++) {
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ if (texObj->Image[face][i]) {
+ _mesa_set_fetch_functions(texObj->Image[face][i], dims);
+ }
+ }
+ }
+}
diff --git a/mesalib/src/mesa/main/texfetch_tmp.h b/mesalib/src/mesa/main/texfetch_tmp.h
index 278becc11..3b1eedf39 100644
--- a/mesalib/src/mesa/main/texfetch_tmp.h
+++ b/mesalib/src/mesa/main/texfetch_tmp.h
@@ -1,2379 +1,2402 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.7
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (c) 2008-2009 VMware, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/**
- * \file texfetch_tmp.h
- * Texel fetch functions template.
- *
- * This template file is used by texfetch.c to generate texel fetch functions
- * for 1-D, 2-D and 3-D texture images.
- *
- * It should be expanded by defining \p DIM as the number texture dimensions
- * (1, 2 or 3). According to the value of \p DIM a series of macros is defined
- * for the texel lookup in the gl_texture_image::Data.
- *
- * \author Gareth Hughes
- * \author Brian Paul
- */
-
-
-#if DIM == 1
-
-#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size)))
-
-#define FETCH(x) fetch_texel_1d_##x
-
-#elif DIM == 2
-
-#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((void) (k), \
- ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size)))
-
-#define FETCH(x) fetch_texel_2d_##x
-
-#elif DIM == 3
-
-#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((type *)(image)->Data + ((image)->ImageOffsets[k] \
- + (image)->RowStride * (j) + (i)) * (size))
-
-#define FETCH(x) fetch_texel_3d_##x
-
-#else
-#error illegal number of texture dimensions
-#endif
-
-
-/* MESA_FORMAT_Z32 ***********************************************************/
-
-/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture,
- * returning 1 GLfloat.
- * Note: no GLchan version of this function.
- */
-static void FETCH(f_z32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[0] = src[0] * (1.0F / 0xffffffff);
-}
-
-#if DIM == 3
-static void store_texel_z32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLuint *depth = (const GLuint *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- dst[0] = *depth;
-}
-#endif
-
-
-/* MESA_FORMAT_Z16 ***********************************************************/
-
-/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture,
- * returning 1 GLfloat.
- * Note: no GLchan version of this function.
- */
-static void FETCH(f_z16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[0] = src[0] * (1.0F / 65535.0F);
-}
-
-#if DIM == 3
-static void store_texel_z16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLushort *depth = (const GLushort *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- dst[0] = *depth;
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA_F32 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats.
- */
-static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
- texel[RCOMP] = src[0];
- texel[GCOMP] = src[1];
- texel[BCOMP] = src[2];
- texel[ACOMP] = src[3];
-}
-
-#if DIM == 3
-static void store_texel_rgba_f32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *depth = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
- dst[0] = depth[RCOMP];
- dst[1] = depth[GCOMP];
- dst[2] = depth[BCOMP];
- dst[3] = depth[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA_F16 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
- texel[RCOMP] = _mesa_half_to_float(src[0]);
- texel[GCOMP] = _mesa_half_to_float(src[1]);
- texel[BCOMP] = _mesa_half_to_float(src[2]);
- texel[ACOMP] = _mesa_half_to_float(src[3]);
-}
-
-#if DIM == 3
-static void store_texel_rgba_f16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
- dst[0] = _mesa_float_to_half(src[RCOMP]);
- dst[1] = _mesa_float_to_half(src[GCOMP]);
- dst[2] = _mesa_float_to_half(src[BCOMP]);
- dst[3] = _mesa_float_to_half(src[ACOMP]);
-}
-#endif
-
-/* MESA_FORMAT_RGB_F32 *******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
- texel[RCOMP] = src[0];
- texel[GCOMP] = src[1];
- texel[BCOMP] = src[2];
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb_f32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
- dst[0] = src[RCOMP];
- dst[1] = src[GCOMP];
- dst[2] = src[BCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_RGB_F16 *******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
- texel[RCOMP] = _mesa_half_to_float(src[0]);
- texel[GCOMP] = _mesa_half_to_float(src[1]);
- texel[BCOMP] = _mesa_half_to_float(src[2]);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb_f16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
- dst[0] = _mesa_float_to_half(src[RCOMP]);
- dst[1] = _mesa_float_to_half(src[GCOMP]);
- dst[2] = _mesa_float_to_half(src[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ALPHA_F32 *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = src[0];
-}
-
-#if DIM == 3
-static void store_texel_alpha_f32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- dst[0] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_ALPHA_F32 *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = _mesa_half_to_float(src[0]);
-}
-
-#if DIM == 3
-static void store_texel_alpha_f16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- dst[0] = _mesa_float_to_half(rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_LUMINANCE_F32 *************************************************/
-
-/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = src[0];
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_luminance_f32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- dst[0] = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_LUMINANCE_F16 *************************************************/
-
-/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = _mesa_half_to_float(src[0]);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_luminance_f16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/
-
-/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = src[0];
- texel[ACOMP] = src[1];
-}
-
-#if DIM == 3
-static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
-
-/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = _mesa_half_to_float(src[0]);
- texel[ACOMP] = _mesa_half_to_float(src[1]);
-}
-
-#if DIM == 3
-static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
- dst[1] = _mesa_float_to_half(rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_INTENSITY_F32 *************************************************/
-
-/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = src[0];
-}
-
-#if DIM == 3
-static void store_texel_intensity_f32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- dst[0] = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_INTENSITY_F16 *************************************************/
-
-/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = _mesa_half_to_float(src[0]);
-}
-
-#if DIM == 3
-static void store_texel_intensity_f16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_R_FLOAT32 *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D R_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_r_f32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- texel[RCOMP] = src[0];
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_r_f32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- dst[0] = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_R_FLOAT16 *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D R_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_r_f16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- texel[RCOMP] = _mesa_half_to_float(src[0]);
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_r_f16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RG_FLOAT32 ****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RG_FLOAT32 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_rg_f32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- texel[RCOMP] = src[0];
- texel[GCOMP] = src[1];
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rg_f32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_RG_FLOAT16 ****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D RG_FLOAT16 texture,
- * returning 4 GLfloats.
- */
-static void FETCH(f_rg_f16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
- texel[RCOMP] = _mesa_half_to_float(src[0]);
- texel[GCOMP] = _mesa_half_to_float(src[1]);
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rg_f16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *rgba = (const GLfloat *) texel;
- GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
- dst[0] = _mesa_float_to_half(rgba[RCOMP]);
- dst[1] = _mesa_float_to_half(rgba[GCOMP]);
-}
-#endif
-
-
-/*
- * Begin Hardware formats
- */
-
-/* MESA_FORMAT_RGBA8888 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
-static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
-}
-
-
-
-#if DIM == 3
-static void store_texel_rgba8888(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA888_REV ***************************************************/
-
-/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
-static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
-}
-
-#if DIM == 3
-static void store_texel_rgba8888_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB8888 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
-static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
-}
-
-#if DIM == 3
-static void store_texel_argb8888(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB8888_REV **************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
-static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
-}
-
-#if DIM == 3
-static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_XRGB8888 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */
-static void FETCH(f_xrgb8888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
- texel[ACOMP] = 1.0f;
-}
-
-#if DIM == 3
-static void store_texel_xrgb8888(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(0xff, rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_XRGB8888_REV **************************************************/
-
-/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */
-static void FETCH(f_xrgb8888_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
- texel[ACOMP] = 1.0f;
-}
-
-#if DIM == 3
-static void store_texel_xrgb8888_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], 0xff);
-}
-#endif
-
-
-/* MESA_FORMAT_RGB888 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
-static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
- texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
- texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb888(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- dst[0] = rgba[BCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_BGR888 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
-static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
- texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
- texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_bgr888(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
-}
-#endif
-
-
-/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding)
- instead of slow (g << 2) * 255 / 252 (always rounds down) */
-
-/* MESA_FORMAT_RGB565 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
-static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = *src;
- texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
- texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F);
- texel[BCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb565(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RGB565_REV ****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */
-static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
- texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
- texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) );
- texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB4444 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
-static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = *src;
- texel[RCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
- texel[GCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
- texel[BCOMP] = ((s ) & 0xf) * (1.0F / 15.0F);
- texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
-}
-
-#if DIM == 3
-static void store_texel_argb4444(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB4444_REV **************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */
-static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] = ((s ) & 0xf) * (1.0F / 15.0F);
- texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
- texel[BCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
- texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
-}
-
-#if DIM == 3
-static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
-}
-#endif
-
-/* MESA_FORMAT_RGBA5551 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
-static void FETCH(f_rgba5551)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = *src;
- texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
- texel[GCOMP] = ((s >> 6) & 0x1f) * (1.0F / 31.0F);
- texel[BCOMP] = ((s >> 1) & 0x1f) * (1.0F / 31.0F);
- texel[ACOMP] = ((s ) & 0x01) * 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgba5551(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-/* MESA_FORMAT_ARGB1555 ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
-static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = *src;
- texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
- texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F);
- texel[BCOMP] = ((s >> 0) & 0x1f) * (1.0F / 31.0F);
- texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_argb1555(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB1555_REV **************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */
-static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
- texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) );
- texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) );
- texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
- texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 );
-}
-
-#if DIM == 3
-static void store_texel_argb1555_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_ARGB2101010 ***************************************************/
-
-/* Fetch texel from 1D, 2D or 3D argb2101010 texture, return 4 GLchans */
-static void FETCH(f_argb2101010)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- const GLuint s = *src;
- texel[RCOMP] = ((s >> 20) & 0x3ff) * (1.0F / 1023.0F);
- texel[GCOMP] = ((s >> 10) & 0x3ff) * (1.0F / 1023.0F);
- texel[BCOMP] = ((s >> 0) & 0x3ff) * (1.0F / 1023.0F);
- texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F);
-}
-
-#if DIM == 3
-static void store_texel_argb2101010(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_2101010_UB(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RG88 **********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
-static void FETCH(f_rg88)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( s >> 8 );
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-#if DIM == 3
-static void store_texel_rg88(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_88(rgba[RCOMP], rgba[GCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RG88_REV ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rg88_rev texture, return 4 GLchans */
-static void FETCH(f_rg88_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( s >> 8 );
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-#if DIM == 3
-static void store_texel_rg88_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_88(rgba[GCOMP], rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_AL44 **********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D al44 texture, return 4 GLchans */
-static void FETCH(f_al44)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = (s & 0xf) * (1.0F / 15.0F);
- texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
-}
-
-#if DIM == 3
-static void store_texel_al44(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = PACK_COLOR_44(rgba[ACOMP], rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_AL88 **********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
-static void FETCH(f_al88)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 );
-}
-
-#if DIM == 3
-static void store_texel_al88(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_R8 ************************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
-static void FETCH(f_r8)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT(s);
- texel[GCOMP] = 0.0;
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-#if DIM == 3
-static void store_texel_r8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_R16 ***********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D r16 texture, return 4 GLchans */
-static void FETCH(f_r16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] = USHORT_TO_FLOAT(s);
- texel[GCOMP] = 0.0;
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-#if DIM == 3
-static void store_texel_r16(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, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_AL88_REV ******************************************************/
-
-/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */
-static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 );
- texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff );
-}
-
-#if DIM == 3
-static void store_texel_al88_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RG1616 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rg1616 texture, return 4 GLchans */
-static void FETCH(f_rg1616)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = USHORT_TO_FLOAT( s & 0xffff );
- texel[GCOMP] = USHORT_TO_FLOAT( s >> 16 );
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-#if DIM == 3
-static void store_texel_rg1616(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[GCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RG1616_REV ****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rg1616_rev texture, return 4 GLchans */
-static void FETCH(f_rg1616_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = USHORT_TO_FLOAT( s >> 16 );
- texel[GCOMP] = USHORT_TO_FLOAT( s & 0xffff );
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-#if DIM == 3
-static void store_texel_rg1616_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1616(rgba[GCOMP], rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_AL1616 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */
-static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff );
- texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 );
-}
-
-#if DIM == 3
-static void store_texel_al1616(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLushort *rgba = (const GLushort *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_AL1616_REV ****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */
-static void FETCH(f_al1616_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 );
- texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff );
-}
-
-#if DIM == 3
-static void store_texel_al1616_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLushort *rgba = (const GLushort *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_RGB332 ********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
-static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- const GLubyte s = *src;
- texel[RCOMP] = ((s >> 5) & 0x7) * (1.0F / 7.0F);
- texel[GCOMP] = ((s >> 2) & 0x7) * (1.0F / 7.0F);
- texel[BCOMP] = ((s ) & 0x3) * (1.0F / 3.0F);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb332(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_A8 ************************************************************/
-
-/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
-static void FETCH(f_a8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
-}
-
-#if DIM == 3
-static void store_texel_a8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_A16 ************************************************************/
-
-/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
-static void FETCH(f_a16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
-}
-
-#if DIM == 3
-static void store_texel_a16(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, 1);
- *dst = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_L8 ************************************************************/
-
-/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
-static void FETCH(f_l8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_l8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_L16 ***********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D l16 texture, return 4 GLchans */
-static void FETCH(f_l16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = USHORT_TO_FLOAT( src[0] );
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_l16(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, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_I8 ************************************************************/
-
-/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
-static void FETCH(f_i8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
-}
-
-#if DIM == 3
-static void store_texel_i8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_I16 ***********************************************************/
-
-/* Fetch texel from 1D, 2D or 3D i16 texture, return 4 GLchans */
-static void FETCH(f_i16)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
-}
-
-#if DIM == 3
-static void store_texel_i16(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, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_CI8 ***********************************************************/
-
-/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
- * color table, and return 4 GLchans.
- */
-static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- const struct gl_color_table *palette;
- GLuint index;
- GET_CURRENT_CONTEXT(ctx);
-
- if (ctx->Texture.SharedPalette) {
- palette = &ctx->Texture.Palette;
- }
- else {
- palette = &texImage->TexObject->Palette;
- }
- if (palette->Size == 0)
- return; /* undefined results */
-
- /* Mask the index against size of palette to avoid going out of bounds */
- index = (*src) & (palette->Size - 1);
-
- {
- const GLfloat *table = palette->TableF;
- switch (palette->_BaseFormat) {
- case GL_ALPHA:
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = table[index];
- break;
- case GL_LUMINANCE:
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = table[index];
- texel[ACOMP] = 1.0F;
- break;
- case GL_INTENSITY:
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = table[index];
- break;
- case GL_LUMINANCE_ALPHA:
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = table[index * 2 + 0];
- texel[ACOMP] = table[index * 2 + 1];
- break;
- case GL_RGB:
- texel[RCOMP] = table[index * 3 + 0];
- texel[GCOMP] = table[index * 3 + 1];
- texel[BCOMP] = table[index * 3 + 2];
- texel[ACOMP] = 1.0F;
- break;
- case GL_RGBA:
- texel[RCOMP] = table[index * 4 + 0];
- texel[GCOMP] = table[index * 4 + 1];
- texel[BCOMP] = table[index * 4 + 2];
- texel[ACOMP] = table[index * 4 + 3];
- break;
- default:
- _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8");
- return;
- }
- }
-}
-
-#if DIM == 3
-static void store_texel_ci8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *index = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- *dst = *index;
-}
-#endif
-
-
-/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */
-/* Note: component order is same as for MESA_FORMAT_RGB888 */
-static void FETCH(srgb8)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- texel[RCOMP] = nonlinear_to_linear(src[2]);
- texel[GCOMP] = nonlinear_to_linear(src[1]);
- texel[BCOMP] = nonlinear_to_linear(src[0]);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_srgb8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- dst[0] = rgba[BCOMP]; /* no conversion */
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[RCOMP];
-}
-#endif
-
-/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */
-static void FETCH(srgba8)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = nonlinear_to_linear( (s >> 24) );
- texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
- texel[BCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */
-}
-
-#if DIM == 3
-static void store_texel_srgba8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */
-static void FETCH(sargb8)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
- texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
- texel[BCOMP] = nonlinear_to_linear( (s ) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
-}
-
-#if DIM == 3
-static void store_texel_sargb8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
-}
-#endif
-
-/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */
-static void FETCH(sl8)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = nonlinear_to_linear(src[0]);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_sl8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- dst[0] = rgba[RCOMP];
-}
-#endif
-
-/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */
-static void FETCH(sla8)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = nonlinear_to_linear(src[0]);
- texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */
-}
-
-#if DIM == 3
-static void store_texel_sla8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA_INT8 **************************************************/
-
-static void
-FETCH(rgba_int8)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-#if DIM == 3
-static void
-store_texel_rgba_int8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA_INT16 **************************************************/
-
-static void
-FETCH(rgba_int16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-#if DIM == 3
-static void
-store_texel_rgba_int16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA_INT32 **************************************************/
-
-static void
-FETCH(rgba_int32)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-#if DIM == 3
-static void
-store_texel_rgba_int32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLint *rgba = (const GLint *) texel;
- GLint *dst = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA_UINT8 **************************************************/
-
-static void
-FETCH(rgba_uint8)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-#if DIM == 3
-static void
-store_texel_rgba_uint8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_RGBA_UINT16 **************************************************/
-
-static void
-FETCH(rgba_uint16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-#if DIM == 3
-static void
-store_texel_rgba_uint16(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_RGBA_UINT32 **************************************************/
-
-static void
-FETCH(rgba_uint32)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-#if DIM == 3
-static void
-store_texel_rgba_uint32(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLuint *rgba = (const GLuint *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_DUDV8 ********************************************************/
-
-/* this format by definition produces 0,0,0,1 as rgba values,
- however we'll return the dudv values as rg and fix up elsewhere */
-static void FETCH(dudv8)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2);
- texel[RCOMP] = BYTE_TO_FLOAT(src[0]);
- texel[GCOMP] = BYTE_TO_FLOAT(src[1]);
- texel[BCOMP] = 0;
- texel[ACOMP] = 0;
-}
-
-
-/* MESA_FORMAT_SIGNED_R8 ***********************************************/
-
-static void FETCH(signed_r8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( s );
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_signed_r8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_A8 ***********************************************/
-
-static void FETCH(signed_a8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- texel[RCOMP] = 0.0F;
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
-}
-
-#if DIM == 3
-static void store_texel_signed_a8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- *dst = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_L8 ***********************************************/
-
-static void FETCH(signed_l8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( s );
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_signed_l8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_I8 ***********************************************/
-
-static void FETCH(signed_i8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
-}
-
-#if DIM == 3
-static void store_texel_signed_i8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_RG88_REV ***********************************************/
-
-static void FETCH(signed_rg88_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_signed_rg88_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rg = (const GLbyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- dst[0] = PACK_COLOR_88(rg[GCOMP], rg[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_AL88 ***********************************************/
-
-static void FETCH(signed_al88)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
-}
-
-#if DIM == 3
-static void store_texel_signed_al88(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rg = (const GLbyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- dst[0] = PACK_COLOR_88(rg[ACOMP], rg[RCOMP]);
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/
-
-static void FETCH(signed_rgbx8888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
- texel[ACOMP] = 1.0f;
-}
-
-#if DIM == 3
-static void store_texel_signed_rgbx8888(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 255);
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
-
-static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) );
-}
-
-#if DIM == 3
-static void store_texel_signed_rgba8888(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLbyte *rgba = (const GLbyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
-}
-
-#if DIM == 3
-static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
-}
-#endif
-
-
-
-/* MESA_FORMAT_SIGNED_R16 ***********************************************/
-
-static void
-FETCH(signed_r16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] = SHORT_TO_FLOAT_TEX( s );
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void
-store_texel_signed_r16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- *dst = rgba[0];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_A16 ***********************************************/
-
-static void
-FETCH(signed_a16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] = 0.0F;
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
-}
-
-#if DIM == 3
-static void
-store_texel_signed_a16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- *dst = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_L16 ***********************************************/
-
-static void
-FETCH(signed_l16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = SHORT_TO_FLOAT_TEX( s );
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void
-store_texel_signed_l16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_I16 ***********************************************/
-
-static void
-FETCH(signed_i16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
-}
-
-#if DIM == 3
-static void
-store_texel_signed_i16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_RG1616 ***********************************************/
-
-static void
-FETCH(signed_rg1616)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
- texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void
-store_texel_signed_rg1616(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_AL1616 ***********************************************/
-
-static void
-FETCH(signed_al1616)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
- texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[1] );
-}
-
-#if DIM == 3
-static void
-store_texel_signed_al1616(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[ACOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/
-
-static void
-FETCH(signed_rgb_16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
- texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
- texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
- texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void
-store_texel_signed_rgb_16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
-}
-#endif
-
-
-/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/
-
-static void
-FETCH(signed_rgba_16)(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
- texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
- texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
- texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
- texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] );
-}
-
-#if DIM == 3
-static void
-store_texel_signed_rgba_16(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLshort *rgba = (const GLshort *) texel;
- GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
-}
-#endif
-
-
-
-/* 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.
- * We convert YCbCr to RGB here.
- */
-static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
- const GLushort *src1 = src0 + 1; /* odd */
- const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
- const GLubyte cb = *src0 & 0xff; /* chroma U */
- const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */
- const GLubyte cr = *src1 & 0xff; /* chroma V */
- const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
- GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
- GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
- GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
- r *= (1.0F / 255.0F);
- g *= (1.0F / 255.0F);
- b *= (1.0F / 255.0F);
- texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
- texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
- texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_ycbcr(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- (void) texImage;
- (void) i;
- (void) j;
- (void) k;
- (void) texel;
- /* XXX to do */
-}
-#endif
-
-
-/* MESA_FORMAT_YCBCR_REV *****************************************************/
-
-/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats.
- * We convert YCbCr to RGB here.
- */
-static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
- const GLushort *src1 = src0 + 1; /* odd */
- const GLubyte y0 = *src0 & 0xff; /* luminance */
- const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
- const GLubyte y1 = *src1 & 0xff; /* luminance */
- const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
- const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
- GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
- GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
- GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
- r *= (1.0F / 255.0F);
- g *= (1.0F / 255.0F);
- b *= (1.0F / 255.0F);
- texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
- texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
- texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_ycbcr_rev(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- (void) texImage;
- (void) i;
- (void) j;
- (void) k;
- (void) texel;
- /* XXX to do */
-}
-#endif
-
-
-/* MESA_TEXFORMAT_Z24_S8 ***************************************************/
-
-static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- /* only return Z, not stencil data */
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
- texel[0] = ((*src) >> 8) * scale;
- ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8);
- ASSERT(texel[0] >= 0.0F);
- ASSERT(texel[0] <= 1.0F);
-}
-
-#if DIM == 3
-static void store_texel_z24_s8(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- /* only store Z, not stencil */
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- GLfloat depth = *((GLfloat *) texel);
- GLuint zi = ((GLuint) (depth * 0xffffff)) << 8;
- *dst = zi | (*dst & 0xff);
-}
-#endif
-
-
-/* MESA_TEXFORMAT_S8_Z24 ***************************************************/
-
-static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- /* only return Z, not stencil data */
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
- texel[0] = ((*src) & 0x00ffffff) * scale;
- ASSERT(texImage->TexFormat == MESA_FORMAT_S8_Z24);
- ASSERT(texel[0] >= 0.0F);
- ASSERT(texel[0] <= 1.0F);
-}
-
-#if DIM == 3
-static void store_texel_s8_z24(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- /* only store Z, not stencil */
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- GLfloat depth = *((GLfloat *) texel);
- GLuint zi = (GLuint) (depth * 0xffffff);
- *dst = zi | (*dst & 0xff000000);
-}
-#endif
-
-
-/* MESA_FORMAT_RGB9_E5 ******************************************************/
-
-static void FETCH(rgb9_e5)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- rgb9e5_to_float3(*src, texel);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_rgb9_e5(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = float3_to_rgb9e5(src);
-}
-#endif
-
-
-/* MESA_FORMAT_R11_G11_B10_FLOAT *********************************************/
-
-static void FETCH(r11_g11_b10f)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- r11g11b10f_to_float3(*src, texel);
- texel[ACOMP] = 1.0F;
-}
-
-#if DIM == 3
-static void store_texel_r11_g11_b10f(struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, const void *texel)
-{
- const GLfloat *src = (const GLfloat *) texel;
- GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = float3_to_r11g11b10f(src);
-}
-#endif
-
-
-#undef TEXEL_ADDR
-#undef DIM
-#undef FETCH
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.7
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (c) 2008-2009 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texfetch_tmp.h
+ * Texel fetch functions template.
+ *
+ * This template file is used by texfetch.c to generate texel fetch functions
+ * for 1-D, 2-D and 3-D texture images.
+ *
+ * It should be expanded by defining \p DIM as the number texture dimensions
+ * (1, 2 or 3). According to the value of \p DIM a series of macros is defined
+ * for the texel lookup in the gl_texture_image::Data.
+ *
+ * \author Gareth Hughes
+ * \author Brian Paul
+ */
+
+
+#if DIM == 1
+
+#define TEXEL_ADDR( type, image, i, j, k, size ) \
+ ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size)))
+
+#define FETCH(x) fetch_texel_1d_##x
+
+#elif DIM == 2
+
+#define TEXEL_ADDR( type, image, i, j, k, size ) \
+ ((void) (k), \
+ ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size)))
+
+#define FETCH(x) fetch_texel_2d_##x
+
+#elif DIM == 3
+
+#define TEXEL_ADDR( type, image, i, j, k, size ) \
+ ((type *)(image)->Data + ((image)->ImageOffsets[k] \
+ + (image)->RowStride * (j) + (i)) * (size))
+
+#define FETCH(x) fetch_texel_3d_##x
+
+#else
+#error illegal number of texture dimensions
+#endif
+
+
+/* MESA_FORMAT_Z32 ***********************************************************/
+
+/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture,
+ * returning 1 GLfloat.
+ * Note: no GLchan version of this function.
+ */
+static void FETCH(f_z32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[0] = src[0] * (1.0F / 0xffffffff);
+}
+
+#if DIM == 3
+static void store_texel_z32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLuint *depth = (const GLuint *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORMAT_Z16 ***********************************************************/
+
+/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture,
+ * returning 1 GLfloat.
+ * Note: no GLchan version of this function.
+ */
+static void FETCH(f_z16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[0] = src[0] * (1.0F / 65535.0F);
+}
+
+#if DIM == 3
+static void store_texel_z16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLushort *depth = (const GLushort *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_F32 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats.
+ */
+static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[1];
+ texel[BCOMP] = src[2];
+ texel[ACOMP] = src[3];
+}
+
+#if DIM == 3
+static void store_texel_rgba_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
+ dst[0] = depth[RCOMP];
+ dst[1] = depth[GCOMP];
+ dst[2] = depth[BCOMP];
+ dst[3] = depth[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_F16 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
+ texel[RCOMP] = _mesa_half_to_float(src[0]);
+ texel[GCOMP] = _mesa_half_to_float(src[1]);
+ texel[BCOMP] = _mesa_half_to_float(src[2]);
+ texel[ACOMP] = _mesa_half_to_float(src[3]);
+}
+
+#if DIM == 3
+static void store_texel_rgba_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *src = (const GLfloat *) texel;
+ GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
+ dst[0] = _mesa_float_to_half(src[RCOMP]);
+ dst[1] = _mesa_float_to_half(src[GCOMP]);
+ dst[2] = _mesa_float_to_half(src[BCOMP]);
+ dst[3] = _mesa_float_to_half(src[ACOMP]);
+}
+#endif
+
+/* MESA_FORMAT_RGB_F32 *******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[1];
+ texel[BCOMP] = src[2];
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *src = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
+ dst[0] = src[RCOMP];
+ dst[1] = src[GCOMP];
+ dst[2] = src[BCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGB_F16 *******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
+ texel[RCOMP] = _mesa_half_to_float(src[0]);
+ texel[GCOMP] = _mesa_half_to_float(src[1]);
+ texel[BCOMP] = _mesa_half_to_float(src[2]);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *src = (const GLfloat *) texel;
+ GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
+ dst[0] = _mesa_float_to_half(src[RCOMP]);
+ dst[1] = _mesa_float_to_half(src[GCOMP]);
+ dst[2] = _mesa_float_to_half(src[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ALPHA_F32 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = src[0];
+}
+
+#if DIM == 3
+static void store_texel_alpha_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+ dst[0] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_ALPHA_F32 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = _mesa_half_to_float(src[0]);
+}
+
+#if DIM == 3
+static void store_texel_alpha_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_F32 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_luminance_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_F16 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = _mesa_half_to_float(src[0]);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_luminance_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = src[1];
+}
+
+#if DIM == 3
+static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = _mesa_half_to_float(src[0]);
+ texel[ACOMP] = _mesa_half_to_float(src[1]);
+}
+
+#if DIM == 3
+static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+ dst[1] = _mesa_float_to_half(rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_INTENSITY_F32 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = src[0];
+}
+
+#if DIM == 3
+static void store_texel_intensity_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_INTENSITY_F16 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = _mesa_half_to_float(src[0]);
+}
+
+#if DIM == 3
+static void store_texel_intensity_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_R_FLOAT32 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D R_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_r_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_r_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_R_FLOAT16 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D R_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_r_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+ texel[RCOMP] = _mesa_half_to_float(src[0]);
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_r_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RG_FLOAT32 ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RG_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rg_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[1];
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rg_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RG_FLOAT16 ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RG_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rg_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
+ texel[RCOMP] = _mesa_half_to_float(src[0]);
+ texel[GCOMP] = _mesa_half_to_float(src[1]);
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rg_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+ dst[1] = _mesa_float_to_half(rgba[GCOMP]);
+}
+#endif
+
+
+/*
+ * Begin Hardware formats
+ */
+
+/* MESA_FORMAT_RGBA8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
+static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+}
+
+
+
+#if DIM == 3
+static void store_texel_rgba8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA888_REV ***************************************************/
+
+/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
+static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+}
+
+#if DIM == 3
+static void store_texel_rgba8888_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
+static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+}
+
+#if DIM == 3
+static void store_texel_argb8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB8888_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
+static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+}
+
+#if DIM == 3
+static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_XRGB8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */
+static void FETCH(f_xrgb8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+ texel[ACOMP] = 1.0f;
+}
+
+#if DIM == 3
+static void store_texel_xrgb8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(0xff, rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_XRGB8888_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */
+static void FETCH(f_xrgb8888_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+ texel[ACOMP] = 1.0f;
+}
+
+#if DIM == 3
+static void store_texel_xrgb8888_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], 0xff);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB888 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
+static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+ texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
+ texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+ dst[0] = rgba[BCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_BGR888 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
+static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+ texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_bgr888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+}
+#endif
+
+
+/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding)
+ instead of slow (g << 2) * 255 / 252 (always rounds down) */
+
+/* MESA_FORMAT_RGB565 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
+static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ const GLushort s = *src;
+ texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
+ texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F);
+ texel[BCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb565(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB565_REV ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */
+static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
+ texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
+ texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) );
+ texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB4444 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
+static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ const GLushort s = *src;
+ texel[RCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
+ texel[GCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
+ texel[BCOMP] = ((s ) & 0xf) * (1.0F / 15.0F);
+ texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
+}
+
+#if DIM == 3
+static void store_texel_argb4444(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB4444_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */
+static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[RCOMP] = ((s ) & 0xf) * (1.0F / 15.0F);
+ texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
+ texel[BCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
+ texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
+}
+
+#if DIM == 3
+static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+/* MESA_FORMAT_RGBA5551 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
+static void FETCH(f_rgba5551)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ const GLushort s = *src;
+ texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
+ texel[GCOMP] = ((s >> 6) & 0x1f) * (1.0F / 31.0F);
+ texel[BCOMP] = ((s >> 1) & 0x1f) * (1.0F / 31.0F);
+ texel[ACOMP] = ((s ) & 0x01) * 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgba5551(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+/* MESA_FORMAT_ARGB1555 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
+static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ const GLushort s = *src;
+ texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
+ texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F);
+ texel[BCOMP] = ((s >> 0) & 0x1f) * (1.0F / 31.0F);
+ texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_argb1555(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB1555_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */
+static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
+ texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) );
+ texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) );
+ texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
+ texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 );
+}
+
+#if DIM == 3
+static void store_texel_argb1555_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB2101010 ***************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb2101010 texture, return 4 GLchans */
+static void FETCH(f_argb2101010)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ const GLuint s = *src;
+ texel[RCOMP] = ((s >> 20) & 0x3ff) * (1.0F / 1023.0F);
+ texel[GCOMP] = ((s >> 10) & 0x3ff) * (1.0F / 1023.0F);
+ texel[BCOMP] = ((s >> 0) & 0x3ff) * (1.0F / 1023.0F);
+ texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F);
+}
+
+#if DIM == 3
+static void store_texel_argb2101010(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_2101010_UB(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RG88 **********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
+static void FETCH(f_rg88)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( s >> 8 );
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+#if DIM == 3
+static void store_texel_rg88(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_88(rgba[RCOMP], rgba[GCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RG88_REV ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rg88_rev texture, return 4 GLchans */
+static void FETCH(f_rg88_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( s >> 8 );
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+#if DIM == 3
+static void store_texel_rg88_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_88(rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL44 **********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al44 texture, return 4 GLchans */
+static void FETCH(f_al44)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = (s & 0xf) * (1.0F / 15.0F);
+ texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
+}
+
+#if DIM == 3
+static void store_texel_al44(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_44(rgba[ACOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL88 **********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
+static void FETCH(f_al88)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 );
+}
+
+#if DIM == 3
+static void store_texel_al88(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_R8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
+static void FETCH(f_r8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT(s);
+ texel[GCOMP] = 0.0;
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+#if DIM == 3
+static void store_texel_r8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_R16 ***********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D r16 texture, return 4 GLchans */
+static void FETCH(f_r16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[RCOMP] = USHORT_TO_FLOAT(s);
+ texel[GCOMP] = 0.0;
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+#if DIM == 3
+static void store_texel_r16(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, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_AL88_REV ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */
+static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 );
+ texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff );
+}
+
+#if DIM == 3
+static void store_texel_al88_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RG1616 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rg1616 texture, return 4 GLchans */
+static void FETCH(f_rg1616)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = USHORT_TO_FLOAT( s & 0xffff );
+ texel[GCOMP] = USHORT_TO_FLOAT( s >> 16 );
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+#if DIM == 3
+static void store_texel_rg1616(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[GCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RG1616_REV ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rg1616_rev texture, return 4 GLchans */
+static void FETCH(f_rg1616_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = USHORT_TO_FLOAT( s >> 16 );
+ texel[GCOMP] = USHORT_TO_FLOAT( s & 0xffff );
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+#if DIM == 3
+static void store_texel_rg1616_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_1616(rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL1616 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */
+static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff );
+ texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 );
+}
+
+#if DIM == 3
+static void store_texel_al1616(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLushort *rgba = (const GLushort *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL1616_REV ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */
+static void FETCH(f_al1616_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 );
+ texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff );
+}
+
+#if DIM == 3
+static void store_texel_al1616_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLushort *rgba = (const GLushort *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB332 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
+static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ const GLubyte s = *src;
+ texel[RCOMP] = ((s >> 5) & 0x7) * (1.0F / 7.0F);
+ texel[GCOMP] = ((s >> 2) & 0x7) * (1.0F / 7.0F);
+ texel[BCOMP] = ((s ) & 0x3) * (1.0F / 3.0F);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb332(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_A8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
+static void FETCH(f_a8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+#if DIM == 3
+static void store_texel_a8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ *dst = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_A16 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
+static void FETCH(f_a16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
+}
+
+#if DIM == 3
+static void store_texel_a16(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, 1);
+ *dst = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_L8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
+static void FETCH(f_l8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_l8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_L16 ***********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D l16 texture, return 4 GLchans */
+static void FETCH(f_l16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = USHORT_TO_FLOAT( src[0] );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_l16(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, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_I8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
+static void FETCH(f_i8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+#if DIM == 3
+static void store_texel_i8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_I16 ***********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D i16 texture, return 4 GLchans */
+static void FETCH(f_i16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
+}
+
+#if DIM == 3
+static void store_texel_i16(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, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_CI8 ***********************************************************/
+
+/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
+ * color table, and return 4 GLchans.
+ */
+static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ const struct gl_color_table *palette;
+ GLuint index;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->Texture.SharedPalette) {
+ palette = &ctx->Texture.Palette;
+ }
+ else {
+ palette = &texImage->TexObject->Palette;
+ }
+ if (palette->Size == 0)
+ return; /* undefined results */
+
+ /* Mask the index against size of palette to avoid going out of bounds */
+ index = (*src) & (palette->Size - 1);
+
+ {
+ const GLfloat *table = palette->TableF;
+ switch (palette->_BaseFormat) {
+ case GL_ALPHA:
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = table[index];
+ break;
+ case GL_LUMINANCE:
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = table[index];
+ texel[ACOMP] = 1.0F;
+ break;
+ case GL_INTENSITY:
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = table[index];
+ break;
+ case GL_LUMINANCE_ALPHA:
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = table[index * 2 + 0];
+ texel[ACOMP] = table[index * 2 + 1];
+ break;
+ case GL_RGB:
+ texel[RCOMP] = table[index * 3 + 0];
+ texel[GCOMP] = table[index * 3 + 1];
+ texel[BCOMP] = table[index * 3 + 2];
+ texel[ACOMP] = 1.0F;
+ break;
+ case GL_RGBA:
+ texel[RCOMP] = table[index * 4 + 0];
+ texel[GCOMP] = table[index * 4 + 1];
+ texel[BCOMP] = table[index * 4 + 2];
+ texel[ACOMP] = table[index * 4 + 3];
+ break;
+ default:
+ _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8");
+ return;
+ }
+ }
+}
+
+#if DIM == 3
+static void store_texel_ci8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *index = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ *dst = *index;
+}
+#endif
+
+
+/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */
+/* Note: component order is same as for MESA_FORMAT_RGB888 */
+static void FETCH(srgb8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+ texel[RCOMP] = nonlinear_to_linear(src[2]);
+ texel[GCOMP] = nonlinear_to_linear(src[1]);
+ texel[BCOMP] = nonlinear_to_linear(src[0]);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_srgb8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
+ dst[0] = rgba[BCOMP]; /* no conversion */
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[RCOMP];
+}
+#endif
+
+/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */
+static void FETCH(srgba8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = nonlinear_to_linear( (s >> 24) );
+ texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+ texel[BCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */
+}
+
+#if DIM == 3
+static void store_texel_srgba8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */
+static void FETCH(sargb8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+ texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
+ texel[BCOMP] = nonlinear_to_linear( (s ) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
+}
+
+#if DIM == 3
+static void store_texel_sargb8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */
+static void FETCH(sl8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = nonlinear_to_linear(src[0]);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_sl8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */
+static void FETCH(sla8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = nonlinear_to_linear(src[0]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */
+}
+
+#if DIM == 3
+static void store_texel_sla8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_INT8 **************************************************/
+
+static void
+FETCH(rgba_int8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_int8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_INT16 **************************************************/
+
+static void
+FETCH(rgba_int16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_int16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_INT32 **************************************************/
+
+static void
+FETCH(rgba_int32)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_int32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLint *rgba = (const GLint *) texel;
+ GLint *dst = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_UINT8 **************************************************/
+
+static void
+FETCH(rgba_uint8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_uint8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_UINT16 **************************************************/
+
+static void
+FETCH(rgba_uint16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_uint16(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_RGBA_UINT32 **************************************************/
+
+static void
+FETCH(rgba_uint32)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
+ texel[RCOMP] = (GLfloat) src[0];
+ texel[GCOMP] = (GLfloat) src[1];
+ texel[BCOMP] = (GLfloat) src[2];
+ texel[ACOMP] = (GLfloat) src[3];
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_uint32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLuint *rgba = (const GLuint *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_DUDV8 ********************************************************/
+
+/* this format by definition produces 0,0,0,1 as rgba values,
+ however we'll return the dudv values as rg and fix up elsewhere */
+static void FETCH(dudv8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2);
+ texel[RCOMP] = BYTE_TO_FLOAT(src[0]);
+ texel[GCOMP] = BYTE_TO_FLOAT(src[1]);
+ texel[BCOMP] = 0;
+ texel[ACOMP] = 0;
+}
+
+
+/* MESA_FORMAT_SIGNED_R8 ***********************************************/
+
+static void FETCH(signed_r8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( s );
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_signed_r8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_A8 ***********************************************/
+
+static void FETCH(signed_a8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ texel[RCOMP] = 0.0F;
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
+}
+
+#if DIM == 3
+static void store_texel_signed_a8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ *dst = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_L8 ***********************************************/
+
+static void FETCH(signed_l8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( s );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_signed_l8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_I8 ***********************************************/
+
+static void FETCH(signed_i8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
+}
+
+#if DIM == 3
+static void store_texel_signed_i8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RG88_REV ***********************************************/
+
+static void FETCH(signed_rg88_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
+ texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_signed_rg88_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rg = (const GLbyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ dst[0] = PACK_COLOR_88(rg[GCOMP], rg[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_AL88 ***********************************************/
+
+static void FETCH(signed_al88)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+}
+
+#if DIM == 3
+static void store_texel_signed_al88(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rg = (const GLbyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ dst[0] = PACK_COLOR_88(rg[ACOMP], rg[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/
+
+static void FETCH(signed_rgbx8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
+ texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[ACOMP] = 1.0f;
+}
+
+#if DIM == 3
+static void store_texel_signed_rgbx8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 255);
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
+
+static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
+ texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) );
+}
+
+#if DIM == 3
+static void store_texel_signed_rgba8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLbyte *rgba = (const GLbyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) );
+ texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
+}
+
+#if DIM == 3
+static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+
+/* MESA_FORMAT_SIGNED_R16 ***********************************************/
+
+static void
+FETCH(signed_r16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] = SHORT_TO_FLOAT_TEX( s );
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_r16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ *dst = rgba[0];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_A16 ***********************************************/
+
+static void
+FETCH(signed_a16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] = 0.0F;
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
+}
+
+#if DIM == 3
+static void
+store_texel_signed_a16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ *dst = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_L16 ***********************************************/
+
+static void
+FETCH(signed_l16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = SHORT_TO_FLOAT_TEX( s );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_l16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_I16 ***********************************************/
+
+static void
+FETCH(signed_i16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
+}
+
+#if DIM == 3
+static void
+store_texel_signed_i16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RG1616 ***********************************************/
+
+static void
+FETCH(signed_rg1616)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+ texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+ texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_rg1616(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_AL1616 ***********************************************/
+
+static void
+FETCH(signed_al1616)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+ texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+}
+
+#if DIM == 3
+static void
+store_texel_signed_al1616(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/
+
+static void
+FETCH(signed_rgb_16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
+ texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+ texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+ texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_rgb_16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/
+
+static void
+FETCH(signed_rgba_16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+ texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+ texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+ texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
+ texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] );
+}
+
+#if DIM == 3
+static void
+store_texel_signed_rgba_16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLshort *rgba = (const GLshort *) texel;
+ GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+
+/* 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.
+ * We convert YCbCr to RGB here.
+ */
+static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
+ const GLushort *src1 = src0 + 1; /* odd */
+ const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
+ const GLubyte cb = *src0 & 0xff; /* chroma U */
+ const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */
+ const GLubyte cr = *src1 & 0xff; /* chroma V */
+ const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
+ GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
+ GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
+ GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
+ r *= (1.0F / 255.0F);
+ g *= (1.0F / 255.0F);
+ b *= (1.0F / 255.0F);
+ texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
+ texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
+ texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_ycbcr(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ (void) texImage;
+ (void) i;
+ (void) j;
+ (void) k;
+ (void) texel;
+ /* XXX to do */
+}
+#endif
+
+
+/* MESA_FORMAT_YCBCR_REV *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats.
+ * We convert YCbCr to RGB here.
+ */
+static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
+ const GLushort *src1 = src0 + 1; /* odd */
+ const GLubyte y0 = *src0 & 0xff; /* luminance */
+ const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
+ const GLubyte y1 = *src1 & 0xff; /* luminance */
+ const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
+ const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
+ GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
+ GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
+ GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
+ r *= (1.0F / 255.0F);
+ g *= (1.0F / 255.0F);
+ b *= (1.0F / 255.0F);
+ texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
+ texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
+ texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_ycbcr_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ (void) texImage;
+ (void) i;
+ (void) j;
+ (void) k;
+ (void) texel;
+ /* XXX to do */
+}
+#endif
+
+
+/* MESA_TEXFORMAT_Z24_S8 ***************************************************/
+
+static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* only return Z, not stencil data */
+ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+ texel[0] = ((*src) >> 8) * scale;
+ ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8);
+ ASSERT(texel[0] >= 0.0F);
+ ASSERT(texel[0] <= 1.0F);
+}
+
+#if DIM == 3
+static void store_texel_z24_s8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ /* only store Z, not stencil */
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ GLfloat depth = *((GLfloat *) texel);
+ GLuint zi = ((GLuint) (depth * 0xffffff)) << 8;
+ *dst = zi | (*dst & 0xff);
+}
+#endif
+
+
+/* MESA_TEXFORMAT_S8_Z24 ***************************************************/
+
+static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* only return Z, not stencil data */
+ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
+ texel[0] = ((*src) & 0x00ffffff) * scale;
+ ASSERT(texImage->TexFormat == MESA_FORMAT_S8_Z24);
+ ASSERT(texel[0] >= 0.0F);
+ ASSERT(texel[0] <= 1.0F);
+}
+
+#if DIM == 3
+static void store_texel_s8_z24(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ /* only store Z, not stencil */
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ GLfloat depth = *((GLfloat *) texel);
+ GLuint zi = (GLuint) (depth * 0xffffff);
+ *dst = zi | (*dst & 0xff000000);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB9_E5 ******************************************************/
+
+static void FETCH(rgb9_e5)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ rgb9e5_to_float3(*src, texel);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb9_e5(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *src = (const GLfloat *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = float3_to_rgb9e5(src);
+}
+#endif
+
+
+/* MESA_FORMAT_R11_G11_B10_FLOAT *********************************************/
+
+static void FETCH(r11_g11_b10f)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ r11g11b10f_to_float3(*src, texel);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_r11_g11_b10f(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *src = (const GLfloat *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = float3_to_r11g11b10f(src);
+}
+#endif
+
+
+/* MESA_FORMAT_Z32_FLOAT_X24S8 ***********************************************/
+
+static void FETCH(z32f_x24s8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_z32f_x24s8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *src = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+ dst[0] = src[0];
+}
+#endif
+
+
+#undef TEXEL_ADDR
+#undef DIM
+#undef FETCH
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index 8cbb021d8..c919a74e0 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -416,6 +416,19 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
}
}
+ if (ctx->Extensions.ARB_depth_buffer_float) {
+ switch (internalFormat) {
+ case GL_DEPTH_COMPONENT32F:
+ ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT]);
+ return MESA_FORMAT_Z32_FLOAT;
+ case GL_DEPTH32F_STENCIL8:
+ ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT_X24S8]);
+ return MESA_FORMAT_Z32_FLOAT_X24S8;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
if (ctx->Extensions.ATI_envmap_bumpmap) {
switch (internalFormat) {
case GL_DUDV_ATI:
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index 565a3a2d8..0e84b8744 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -899,7 +899,7 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
{
GLuint u, tex;
- for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
+ for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
if (texObj == unit->CurrentTex[tex]) {
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index e527981ff..6e1e63bdf 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -1002,15 +1002,17 @@ memcpy_texture(struct gl_context *ctx,
/**
- * Store a 32-bit integer depth component texture image.
+ * Store a 32-bit integer or float depth component texture image.
*/
static GLboolean
_mesa_texstore_z32(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffffffff;
const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum dstType = _mesa_get_format_datatype(dstFormat);
(void) dims;
- ASSERT(dstFormat == MESA_FORMAT_Z32);
+ ASSERT(dstFormat == MESA_FORMAT_Z32 ||
+ dstFormat == MESA_FORMAT_Z32_FLOAT);
ASSERT(texelBytes == sizeof(GLuint));
if (ctx->Pixel.DepthScale == 1.0f &&
@@ -1018,7 +1020,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
!srcPacking->SwapBytes &&
baseInternalFormat == GL_DEPTH_COMPONENT &&
srcFormat == GL_DEPTH_COMPONENT &&
- srcType == GL_UNSIGNED_INT) {
+ srcType == dstType) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
@@ -1039,7 +1041,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
_mesa_unpack_depth_span(ctx, srcWidth,
- GL_UNSIGNED_INT, (GLuint *) dstRow,
+ dstType, dstRow,
depthScale, srcType, src, srcPacking);
dstRow += dstRowStride;
}
@@ -4285,6 +4287,72 @@ _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS)
}
+static GLboolean
+_mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
+{
+ ASSERT(dstFormat == MESA_FORMAT_Z32_FLOAT_X24S8);
+ ASSERT(srcFormat == GL_DEPTH_STENCIL ||
+ srcFormat == GL_DEPTH_COMPONENT ||
+ srcFormat == GL_STENCIL_INDEX);
+ ASSERT(srcFormat != GL_DEPTH_STENCIL ||
+ srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+
+ if (srcFormat == GL_DEPTH_STENCIL &&
+ ctx->Pixel.DepthScale == 1.0f &&
+ ctx->Pixel.DepthBias == 0.0f &&
+ !srcPacking->SwapBytes) {
+ /* simple path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (srcFormat == GL_DEPTH_COMPONENT ||
+ srcFormat == GL_STENCIL_INDEX) {
+ GLint img, row;
+ const GLint srcRowStride
+ = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
+ / sizeof(uint64_t);
+
+ /* In case we only upload depth we need to preserve the stencil */
+ for (img = 0; img < srcDepth; img++) {
+ uint64_t *dstRow = (uint64_t *) dstAddr
+ + dstImageOffsets[dstZoffset + img]
+ + dstYoffset * dstRowStride / sizeof(uint64_t)
+ + dstXoffset;
+ const uint64_t *src
+ = (const uint64_t *) _mesa_image_address(dims, srcPacking, srcAddr,
+ srcWidth, srcHeight,
+ srcFormat, srcType,
+ img, 0, 0);
+ for (row = 0; row < srcHeight; row++) {
+ /* The unpack functions with:
+ * dstType = GL_FLOAT_32_UNSIGNED_INT_24_8_REV
+ * only write their own dword, so the other dword (stencil
+ * or depth) is preserved. */
+ if (srcFormat != GL_STENCIL_INDEX)
+ _mesa_unpack_depth_span(ctx, srcWidth,
+ GL_FLOAT_32_UNSIGNED_INT_24_8_REV, /* dst type */
+ dstRow, /* dst addr */
+ 1.0f, srcType, src, srcPacking);
+
+ if (srcFormat != GL_DEPTH_COMPONENT)
+ _mesa_unpack_stencil_span(ctx, srcWidth,
+ GL_FLOAT_32_UNSIGNED_INT_24_8_REV, /* dst type */
+ dstRow, /* dst addr */
+ srcType, src, srcPacking,
+ ctx->_ImageTransferState);
+
+ src += srcRowStride;
+ dstRow += dstRowStride / sizeof(uint64_t);
+ }
+ }
+ }
+ return GL_TRUE;
+}
+
/**
* Table mapping MESA_FORMAT_* to _mesa_texstore_*()
@@ -4419,6 +4487,9 @@ texstore_funcs[MESA_FORMAT_COUNT] =
{ MESA_FORMAT_RGB9_E5_FLOAT, _mesa_texstore_rgb9_e5 },
{ MESA_FORMAT_R11_G11_B10_FLOAT, _mesa_texstore_r11_g11_b10f },
+
+ { MESA_FORMAT_Z32_FLOAT, _mesa_texstore_z32 },
+ { MESA_FORMAT_Z32_FLOAT_X24S8, _mesa_texstore_z32f_x24s8 },
};
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index 1c4fd82ba..dd069a3a4 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -580,7 +580,7 @@ _mesa_update_shader_textures_used(struct gl_program *prog)
if (prog->SamplersUsed & (1 << s)) {
GLuint unit = prog->SamplerUnits[s];
GLuint tgt = prog->SamplerTargets[s];
- assert(unit < MAX_TEXTURE_IMAGE_UNITS);
+ assert(unit < Elements(prog->TexturesUsed));
assert(tgt < NUM_TEXTURE_TARGETS);
prog->TexturesUsed[unit] |= (1 << tgt);
}
@@ -674,7 +674,7 @@ set_program_uniform(struct gl_context *ctx, struct gl_program *program,
GLuint texUnit = ((GLuint *) values)[i];
/* check that the sampler (tex unit index) is legal */
- if (texUnit >= ctx->Const.MaxTextureImageUnits) {
+ if (texUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glUniform1(invalid sampler/tex unit index for '%s')",
param->Name);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index 181fedd2b..117000ba7 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -381,7 +381,8 @@ check_clear_depth_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuff
assert(rb->Format == MESA_FORMAT_S8 ||
rb->Format == MESA_FORMAT_Z24_S8 ||
- rb->Format == MESA_FORMAT_S8_Z24);
+ rb->Format == MESA_FORMAT_S8_Z24 ||
+ rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
if (ctx->Scissor.Enabled &&
(ctx->Scissor.X != 0 ||
@@ -436,7 +437,8 @@ check_clear_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb
assert(rb->Format == MESA_FORMAT_S8 ||
rb->Format == MESA_FORMAT_Z24_S8 ||
- rb->Format == MESA_FORMAT_S8_Z24);
+ rb->Format == MESA_FORMAT_S8_Z24 ||
+ rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
if (maskStencil)
return GL_TRUE;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index d61d7ac22..dca332464 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -812,6 +812,7 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
for (row = 0; row < height; row++) {
GLubyte sValues[MAX_WIDTH];
GLuint zValues[MAX_WIDTH];
+ GLfloat *zValuesFloat = (GLfloat*)zValues;
GLenum destType = GL_UNSIGNED_BYTE;
const GLvoid *source = _mesa_image_address2d(&clippedUnpack, pixels,
width, height,
@@ -822,7 +823,11 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
ctx->_ImageTransferState);
if (format == GL_DEPTH_STENCIL) {
- _mesa_unpack_depth_span(ctx, spanWidth, GL_UNSIGNED_INT, zValues,
+ GLenum ztype =
+ pt->resource->format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED ?
+ GL_FLOAT : GL_UNSIGNED_INT;
+
+ _mesa_unpack_depth_span(ctx, spanWidth, ztype, zValues,
(1 << 24) - 1, type, source,
&clippedUnpack);
}
@@ -887,6 +892,26 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
}
}
break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ if (format == GL_DEPTH_STENCIL) {
+ uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
+ GLfloat *destf = (GLfloat*)dest;
+ GLint k;
+ assert(usage == PIPE_TRANSFER_WRITE);
+ for (k = 0; k < spanWidth; k++) {
+ destf[k*2] = zValuesFloat[k];
+ dest[k*2+1] = sValues[k] & 0xff;
+ }
+ }
+ else {
+ uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
+ GLint k;
+ assert(usage == PIPE_TRANSFER_READ_WRITE);
+ for (k = 0; k < spanWidth; k++) {
+ dest[k*2+1] = sValues[k] & 0xff;
+ }
+ }
+ break;
default:
assert(0);
}
@@ -994,14 +1019,23 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
GL_NONE, GL_NONE,
PIPE_TEXTURE_2D,
0, PIPE_BIND_SAMPLER_VIEW);
- if (tex_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED)
- stencil_format = PIPE_FORMAT_X24S8_USCALED;
- else if (tex_format == PIPE_FORMAT_S8_USCALED_Z24_UNORM)
- stencil_format = PIPE_FORMAT_S8X24_USCALED;
- else
- stencil_format = PIPE_FORMAT_S8_USCALED;
- if (stencil_format == PIPE_FORMAT_NONE)
- goto stencil_fallback;
+
+ switch (tex_format) {
+ case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+ stencil_format = PIPE_FORMAT_X24S8_USCALED;
+ break;
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ stencil_format = PIPE_FORMAT_S8X24_USCALED;
+ break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ stencil_format = PIPE_FORMAT_X32_S8X24_USCALED;
+ break;
+ case PIPE_FORMAT_S8_USCALED:
+ stencil_format = PIPE_FORMAT_S8_USCALED;
+ break;
+ default:
+ goto stencil_fallback;
+ }
}
/* Mesa state should be up to date by now */
@@ -1188,6 +1222,18 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
assert(usage == PIPE_TRANSFER_WRITE);
memcpy(dst, src, width);
break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ {
+ uint *dst4 = (uint *) dst;
+ int j;
+ dst4++;
+ assert(usage == PIPE_TRANSFER_READ_WRITE);
+ for (j = 0; j < width; j++) {
+ *dst4 = src[j] & 0xff;
+ dst4 += 2;
+ }
+ }
+ break;
default:
assert(0);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
index 67926e392..e2b29fe30 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
@@ -151,6 +151,24 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
}
}
break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ if (format == GL_DEPTH_STENCIL) {
+ const uint *src = (uint *) (stmap + srcY * pt->stride);
+ const GLfloat *srcf = (const GLfloat*)src;
+ GLint k;
+ for (k = 0; k < width; k++) {
+ zValues[k] = srcf[k*2];
+ sValues[k] = src[k*2+1] & 0xff;
+ }
+ }
+ else {
+ const uint *src = (uint *) (stmap + srcY * pt->stride);
+ GLint k;
+ for (k = 0; k < width; k++) {
+ sValues[k] = src[k*2+1] & 0xff;
+ }
+ }
+ break;
default:
assert(0);
}
@@ -159,7 +177,7 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
dest = _mesa_image_address2d(packing, pixels, width, height,
format, type, j, 0);
if (format == GL_DEPTH_STENCIL) {
- _mesa_pack_depth_stencil_span(ctx, width, dest,
+ _mesa_pack_depth_stencil_span(ctx, width, type, dest,
zValues, sValues, packing);
}
else {
@@ -568,6 +586,31 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h
dst += dstStride;
}
}
+ else if (pformat == PIPE_FORMAT_Z32_FLOAT) {
+ for (i = 0; i < height; i++) {
+ GLfloat zfloat[MAX_WIDTH];
+ pipe_get_tile_raw(pipe, trans, 0, y, width, 1, zfloat, 0);
+ y += yStep;
+ _mesa_pack_depth_span(ctx, width, dst, type,
+ zfloat, &clippedPacking);
+ dst += dstStride;
+ }
+ }
+ else if (pformat == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED) {
+ assert(format == GL_DEPTH_COMPONENT);
+ for (i = 0; i < height; i++) {
+ GLfloat zfloat[MAX_WIDTH]; /* Z32 */
+ GLfloat zfloat2[MAX_WIDTH*2]; /* Z32X32 */
+ pipe_get_tile_raw(pipe, trans, 0, y, width, 1, zfloat2, 0);
+ y += yStep;
+ for (j = 0; j < width; j++) {
+ zfloat[j] = zfloat2[j*2];
+ }
+ _mesa_pack_depth_span(ctx, width, dst, type,
+ zfloat, &clippedPacking);
+ dst += dstStride;
+ }
+ }
else {
/* RGBA format */
/* Do a row at a time to flip image data vertically */
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index d3aebe526..99b231d97 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -607,4 +607,15 @@ void st_init_extensions(struct st_context *st)
if (screen->get_param(screen, PIPE_CAP_SM3)) {
ctx->Extensions.ARB_shader_texture_lod = GL_TRUE;
}
+
+ if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL |
+ PIPE_BIND_SAMPLER_VIEW) &&
+ screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL |
+ PIPE_BIND_SAMPLER_VIEW)) {
+ ctx->Extensions.ARB_depth_buffer_float = GL_TRUE;
+ }
}
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index fa5d8f505..bd4f0860c 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -68,42 +68,70 @@ GLenum
st_format_datatype(enum pipe_format format)
{
const struct util_format_description *desc;
+ int i;
desc = util_format_description(format);
assert(desc);
+ /* Find the first non-VOID channel. */
+ for (i = 0; i < 4; i++) {
+ if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
+ break;
+ }
+ }
+
if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) {
if (format == PIPE_FORMAT_B5G5R5A1_UNORM ||
format == PIPE_FORMAT_B5G6R5_UNORM) {
return GL_UNSIGNED_SHORT;
}
+ else if (format == PIPE_FORMAT_R11G11B10_FLOAT ||
+ format == PIPE_FORMAT_R9G9B9E5_FLOAT) {
+ return GL_FLOAT;
+ }
else if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
format == PIPE_FORMAT_S8_USCALED_Z24_UNORM ||
format == PIPE_FORMAT_Z24X8_UNORM ||
format == PIPE_FORMAT_X8Z24_UNORM) {
return GL_UNSIGNED_INT_24_8;
}
+ else if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED) {
+ return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+ }
else {
const GLuint size = format_max_bits(format);
+
+ assert(i < 4);
+ if (i == 4)
+ return GL_NONE;
+
if (size == 8) {
- if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
return GL_UNSIGNED_BYTE;
else
return GL_BYTE;
}
else if (size == 16) {
- if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+ return GL_HALF_FLOAT;
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
return GL_UNSIGNED_SHORT;
else
return GL_SHORT;
}
- else {
- assert( size <= 32 );
- if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
+ else if (size <= 32) {
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+ return GL_FLOAT;
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
return GL_UNSIGNED_INT;
else
return GL_INT;
}
+ else {
+ assert(size == 64);
+ assert(desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT);
+ return GL_DOUBLE;
+ }
}
}
else if (format == PIPE_FORMAT_UYVY) {
@@ -180,6 +208,10 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
return PIPE_FORMAT_Z24X8_UNORM;
case MESA_FORMAT_S8:
return PIPE_FORMAT_S8_USCALED;
+ case MESA_FORMAT_Z32_FLOAT:
+ return PIPE_FORMAT_Z32_FLOAT;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ return PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED;
case MESA_FORMAT_YCBCR:
return PIPE_FORMAT_UYVY;
#if FEATURE_texture_s3tc
@@ -402,6 +434,10 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
return MESA_FORMAT_X8_Z24;
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
return MESA_FORMAT_S8_Z24;
+ case PIPE_FORMAT_Z32_FLOAT:
+ return MESA_FORMAT_Z32_FLOAT;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ return MESA_FORMAT_Z32_FLOAT_X24S8;
case PIPE_FORMAT_UYVY:
return MESA_FORMAT_YCBCR;
@@ -759,6 +795,10 @@ static const struct format_mapping format_map[] = {
{ GL_DEPTH_COMPONENT, 0 },
{ DEFAULT_DEPTH_FORMATS }
},
+ {
+ { GL_DEPTH_COMPONENT32F, 0 },
+ { PIPE_FORMAT_Z32_FLOAT, 0 }
+ },
/* stencil formats */
{
@@ -775,6 +815,10 @@ static const struct format_mapping format_map[] = {
{ GL_DEPTH_STENCIL_EXT, GL_DEPTH24_STENCIL8_EXT, 0 },
{ PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_S8_USCALED_Z24_UNORM, 0 }
},
+ {
+ { GL_DEPTH32F_STENCIL8, 0 },
+ { PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, 0 }
+ },
/* sRGB formats */
{
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index a8c4b5c3f..7bd82aae2 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -918,6 +918,15 @@ st_manager_add_color_renderbuffer(struct st_context *st,
return FALSE;
st_framebuffer_update_attachments(stfb);
+
+ /*
+ * Force a call to the state tracker manager to validate the
+ * new renderbuffer. It might be that there is a window system
+ * renderbuffer available.
+ */
+ if(stfb->iface)
+ stfb->iface_stamp = p_atomic_read(&stfb->iface->stamp) - 1;
+
st_invalidate_state(st->ctx, _NEW_BUFFERS);
return TRUE;
diff --git a/mesalib/src/mesa/swrast/s_blit.c b/mesalib/src/mesa/swrast/s_blit.c
index 3516a41bf..7f53f19eb 100644
--- a/mesalib/src/mesa/swrast/s_blit.c
+++ b/mesalib/src/mesa/swrast/s_blit.c
@@ -568,9 +568,6 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
};
GLint i;
- if (!ctx->DrawBuffer->_NumColorDrawBuffers)
- return;
-
if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1,
&dstX0, &dstY0, &dstX1, &dstY1)) {
return;
diff --git a/mesalib/src/mesa/swrast/s_readpix.c b/mesalib/src/mesa/swrast/s_readpix.c
index 214f2ea1a..66ca39293 100644
--- a/mesalib/src/mesa/swrast/s_readpix.c
+++ b/mesalib/src/mesa/swrast/s_readpix.c
@@ -446,7 +446,7 @@ read_depth_stencil_pixels(struct gl_context *ctx,
GLfloat depthVals[MAX_WIDTH];
_swrast_read_depth_span_float(ctx, depthRb, width, x, y + i,
depthVals);
- _mesa_pack_depth_stencil_span(ctx, width, depthStencilDst,
+ _mesa_pack_depth_stencil_span(ctx, width, type, depthStencilDst,
depthVals, stencilVals, packing);
}
}