summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-05-04 21:44:02 -0600
committerBrian Paul <[email protected]>2010-05-04 21:59:54 -0600
commit36b3a8bd5a317ab297f44b19fd14c7e76ec2fc77 (patch)
treebfe114293c6f28c1e0e9c8b6d4f13b459b4333c9
parent719f7049bb2c7f5ca886055c9cd15b2805bd8e97 (diff)
osmesa: fix OSMesa for CHAN_BITS=32
CHAN_BITS=16 still broken. NOTE: this is a candidate for back-porting to the 7.8 stable branch.
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index e20507ae92f..e376f12bc3a 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -1004,7 +1004,20 @@ new_osmesa_renderbuffer(GLcontext *ctx, GLenum format, GLenum type)
rb->AllocStorage = osmesa_renderbuffer_storage;
rb->InternalFormat = GL_RGBA;
- rb->Format = MESA_FORMAT_RGBA8888;
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ rb->Format = MESA_FORMAT_RGBA8888;
+ break;
+ case GL_UNSIGNED_SHORT:
+ rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
+ break;
+ case GL_FLOAT:
+ rb->Format = MESA_FORMAT_RGBA_FLOAT32;
+ break;
+ default:
+ assert(0 && "Unexpected type in new_osmesa_renderbuffer()");
+ rb->Format = MESA_FORMAT_RGBA8888;
+ }
rb->_BaseFormat = GL_RGBA;
rb->DataType = type;
}
@@ -1167,11 +1180,9 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
return NULL;
}
- /* create front color buffer in user-provided memory (no back buffer) */
- osmesa->rb = new_osmesa_renderbuffer(&osmesa->mesa, format, type);
- _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, osmesa->rb);
- assert(osmesa->rb->RefCount == 2);
-
+ /* Create depth/stencil/accum buffers. We'll create the color
+ * buffer later in OSMesaMakeCurrent().
+ */
_mesa_add_soft_renderbuffers(osmesa->gl_buffer,
GL_FALSE, /* color */
osmesa->gl_visual->haveDepthBuffer,
@@ -1308,11 +1319,23 @@ OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type,
*/
_glapi_check_multithread();
+
+ /* Create a front/left color buffer which wraps the user-provided buffer.
+ * There is no back color buffer.
+ * If the user tries to use a 8, 16 or 32-bit/channel buffer that
+ * doesn't match what Mesa was compiled for (CHAN_BITS) the
+ * _mesa_add_renderbuffer() function will create a "wrapper" renderbuffer
+ * that converts rendering from CHAN_BITS to the user-requested channel
+ * size.
+ */
+ osmesa->rb = new_osmesa_renderbuffer(&osmesa->mesa, osmesa->format, type);
+ _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, osmesa->rb);
+ assert(osmesa->rb->RefCount == 2);
+
/* Set renderbuffer fields. Set width/height = 0 to force
* osmesa_renderbuffer_storage() being called by _mesa_resize_framebuffer()
*/
osmesa->rb->Data = buffer;
- osmesa->rb->DataType = type;
osmesa->rb->Width = osmesa->rb->Height = 0;
/* Set the framebuffer's size. This causes the