summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-05-19 03:40:29 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-05-19 03:40:29 +0000
commit6a74f65c5876228cab96753d559d7d41fb465785 (patch)
tree974a8ba08e562b1ae05292b1ba6f2f97fe779288
parentd2e5598cd32786bf77a46dcc4cd27d8c0ec278af (diff)
install renderbuffer adaptors when color channel sizes need to be reduced
-rw-r--r--src/mesa/main/renderbuffer.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index d043237e53..0999ed5954 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -47,6 +47,8 @@
#include "fbobject.h"
#include "renderbuffer.h"
+#include "rbadaptors.h"
+
/* 32-bit color index format. Not a public format. */
#define COLOR_INDEX32 0x424243
@@ -2046,6 +2048,25 @@ _mesa_add_renderbuffer(struct gl_framebuffer *fb,
assert(!rb->Name);
}
+ /* If Mesa's compiled with deep color channels (16 or 32 bits / channel)
+ * and the device driver is expecting 8-bit values (GLubyte), we can
+ * use a "renderbuffer adaptor/wrapper" to do the necessary conversions.
+ */
+ if (rb->_BaseFormat == GL_RGBA) {
+ if (CHAN_BITS == 16 && rb->DataType == GL_UNSIGNED_BYTE) {
+ GET_CURRENT_CONTEXT(ctx);
+ rb = _mesa_new_renderbuffer_16wrap8(ctx, rb);
+ }
+ else if (CHAN_BITS == 32 && rb->DataType == GL_UNSIGNED_BYTE) {
+ GET_CURRENT_CONTEXT(ctx);
+ rb = _mesa_new_renderbuffer_32wrap8(ctx, rb);
+ }
+ else if (CHAN_BITS == 32 && rb->DataType == GL_UNSIGNED_SHORT) {
+ GET_CURRENT_CONTEXT(ctx);
+ rb = _mesa_new_renderbuffer_32wrap16(ctx, rb);
+ }
+ }
+
fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT;
fb->Attachment[bufferName].Complete = GL_TRUE;
fb->Attachment[bufferName].Renderbuffer = rb;