summaryrefslogtreecommitdiff
path: root/src/mesa/main/texrender.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-03-08 09:58:54 -0700
committerBrian Paul <brianp@vmware.com>2010-03-08 10:00:29 -0700
commitfe25bee14f4df3ef87cc7fee67e610da9afc5eda (patch)
treeb01da4875b8ec674fe9c9907046fd8160b4b8fe8 /src/mesa/main/texrender.c
parent9458c2061ba5d8857217d9a7504b42ea17022897 (diff)
mesa: add additional missing z formats for render to texture
Allow render to texture for X8_Z24 and Z24_X8 formats. Replace big if/else with switch, etc.
Diffstat (limited to 'src/mesa/main/texrender.c')
-rw-r--r--src/mesa/main/texrender.c98
1 files changed, 83 insertions, 15 deletions
diff --git a/src/mesa/main/texrender.c b/src/mesa/main/texrender.c
index 9996a996c1..d29af5a5b2 100644
--- a/src/mesa/main/texrender.c
+++ b/src/mesa/main/texrender.c
@@ -84,6 +84,14 @@ texture_get_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
zValues[i] = ((GLuint) (flt * 0xffffff)) << 8;
}
}
+ else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
+ GLuint *zValues = (GLuint *) values;
+ for (i = 0; i < count; i++) {
+ GLfloat flt;
+ trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt);
+ zValues[i] = (GLuint) (flt * 0xffffff);
+ }
+ }
else {
_mesa_problem(ctx, "invalid rb->DataType in texture_get_row");
}
@@ -139,6 +147,15 @@ texture_get_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
zValues[i] = ((GLuint) (flt * 0xffffff)) << 8;
}
}
+ else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
+ GLuint *zValues = (GLuint *) values;
+ for (i = 0; i < count; i++) {
+ GLfloat flt;
+ trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset,
+ z, &flt);
+ zValues[i] = (GLuint) (flt * 0xffffff);
+ }
+ }
else {
_mesa_problem(ctx, "invalid rb->DataType in texture_get_values");
}
@@ -193,6 +210,15 @@ texture_put_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
}
}
}
+ else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
+ const GLuint *zValues = (const GLuint *) values;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff));
+ trb->Store(trb->TexImage, x + i, y, z, &flt);
+ }
+ }
+ }
else {
_mesa_problem(ctx, "invalid rb->DataType in texture_put_row");
}
@@ -246,6 +272,15 @@ texture_put_row_rgb(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
}
}
}
+ else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
+ const GLuint *zValues = (const GLuint *) values;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff));
+ trb->Store(trb->TexImage, x + i, y, z, &flt);
+ }
+ }
+ }
else {
_mesa_problem(ctx, "invalid rb->DataType in texture_put_row");
}
@@ -296,6 +331,15 @@ texture_put_mono_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
}
}
}
+ else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
+ const GLuint zValue = *((const GLuint *) value);
+ const GLfloat flt = (GLfloat) ((zValue & 0xffffff) * (1.0 / 0xffffff));
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x + i, y, z, &flt);
+ }
+ }
+ }
else {
_mesa_problem(ctx, "invalid rb->DataType in texture_put_mono_row");
}
@@ -346,6 +390,15 @@ texture_put_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
}
}
}
+ else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
+ const GLuint *zValues = (const GLuint *) values;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff));
+ trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt);
+ }
+ }
+ }
else {
_mesa_problem(ctx, "invalid rb->DataType in texture_put_values");
}
@@ -395,6 +448,15 @@ texture_put_mono_values(GLcontext *ctx, struct gl_renderbuffer *rb,
}
}
}
+ else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
+ const GLuint zValue = *((const GLuint *) value);
+ const GLfloat flt = (GLfloat) ((zValue & 0xffffff) * (1.0 / 0xffffff));
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt);
+ }
+ }
+ }
else {
_mesa_problem(ctx, "invalid rb->DataType in texture_put_mono_values");
}
@@ -491,29 +553,35 @@ update_wrapper(GLcontext *ctx, const struct gl_renderbuffer_attachment *att)
trb->Base.Width = trb->TexImage->Width;
trb->Base.Height = trb->TexImage->Height;
trb->Base.InternalFormat = trb->TexImage->InternalFormat;
+ trb->Base.Format = trb->TexImage->TexFormat;
+
/* XXX may need more special cases here */
- if (trb->TexImage->TexFormat == MESA_FORMAT_Z24_S8) {
- trb->Base.Format = MESA_FORMAT_Z24_S8;
+ switch (trb->TexImage->TexFormat) {
+ case MESA_FORMAT_Z24_S8:
trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
trb->Base._BaseFormat = GL_DEPTH_STENCIL;
- }
- else if (trb->TexImage->TexFormat == MESA_FORMAT_S8_Z24) {
- trb->Base.Format = MESA_FORMAT_S8_Z24;
- trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; /* not 8_24 */
+ break;
+ case MESA_FORMAT_S8_Z24:
+ trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA;
trb->Base._BaseFormat = GL_DEPTH_STENCIL;
- }
- else if (trb->TexImage->TexFormat == MESA_FORMAT_Z16) {
- trb->Base.Format = MESA_FORMAT_Z16;
+ break;
+ case MESA_FORMAT_Z24_X8:
+ trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+ trb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+ break;
+ case MESA_FORMAT_X8_Z24:
+ trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA;
+ trb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+ break;
+ case MESA_FORMAT_Z16:
trb->Base.DataType = GL_UNSIGNED_SHORT;
trb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- }
- else if (trb->TexImage->TexFormat == MESA_FORMAT_Z32) {
- trb->Base.Format = MESA_FORMAT_Z32;
+ break;
+ case MESA_FORMAT_Z32:
trb->Base.DataType = GL_UNSIGNED_INT;
trb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- }
- else {
- trb->Base.Format = trb->TexImage->TexFormat;
+ break;
+ default:
trb->Base.DataType = CHAN_TYPE;
trb->Base._BaseFormat = GL_RGBA;
}