summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-10-08 20:27:27 -0600
committerBrian Paul <brianp@vmware.com>2009-10-08 20:27:27 -0600
commit45e76d2665b38ba3787548310efc59e969124c01 (patch)
tree7a1ab9b61bbd0eb03e7154f6f000db58b8eab4f4
parent74d61d03b54d72217d463c248468cdcd09320efc (diff)
mesa: remove a bunch of gl_renderbuffer fields
_ActualFormat is replaced by Format (MESA_FORMAT_x). ColorEncoding, ComponentType, RedBits, GreenBits, BlueBits, etc. are all replaced by MESA_FORMAT_x queries.
-rw-r--r--src/mesa/drivers/dri/common/drirenderbuffer.c23
-rw-r--r--src/mesa/drivers/dri/i915/i915_texstate.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffers.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c14
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c105
-rw-r--r--src/mesa/drivers/dri/intel/intel_span.c21
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_format.c2
-rw-r--r--src/mesa/drivers/dri/r200/r200_state_init.c10
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.c10
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_common_context.c14
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_fbo.c102
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_span.c20
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_state_init.c10
-rw-r--r--src/mesa/drivers/dri/sis/sis_dd.c9
-rw-r--r--src/mesa/drivers/dri/swrast/swrast.c23
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.c5
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c19
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c8
-rw-r--r--src/mesa/drivers/x11/xm_dd.c4
-rw-r--r--src/mesa/main/depthstencil.c344
-rw-r--r--src/mesa/main/fbobject.c190
-rw-r--r--src/mesa/main/framebuffer.c70
-rw-r--r--src/mesa/main/mtypes.h12
-rw-r--r--src/mesa/main/rbadaptors.c18
-rw-r--r--src/mesa/main/renderbuffer.c243
-rw-r--r--src/mesa/main/texrender.c17
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c13
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c14
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c9
-rw-r--r--src/mesa/state_tracker/st_format.c103
-rw-r--r--src/mesa/state_tracker/st_format.h7
-rw-r--r--src/mesa/swrast/s_clear.c8
-rw-r--r--src/mesa/swrast/s_depth.c13
-rw-r--r--src/mesa/swrast/s_triangle.c2
34 files changed, 709 insertions, 757 deletions
diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.c b/src/mesa/drivers/dri/common/drirenderbuffer.c
index 15af99136c..6fa1c6caa0 100644
--- a/src/mesa/drivers/dri/common/drirenderbuffer.c
+++ b/src/mesa/drivers/dri/common/drirenderbuffer.c
@@ -1,5 +1,6 @@
#include "main/mtypes.h"
+#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/imports.h"
@@ -83,47 +84,37 @@ driNewRenderbuffer(GLenum format, GLvoid *addr,
if (format == GL_RGBA || format == GL_RGB5 || format == GL_RGBA8) {
/* Color */
- drb->Base._BaseFormat = GL_RGBA;
drb->Base.DataType = GL_UNSIGNED_BYTE;
if (format == GL_RGB5) {
- drb->Base.RedBits = 5;
- drb->Base.GreenBits = 6;
- drb->Base.BlueBits = 5;
+ drb->Base.Format = MESA_FORMAT_RGB565;
}
else {
- drb->Base.RedBits =
- drb->Base.GreenBits =
- drb->Base.BlueBits =
- drb->Base.AlphaBits = 8;
+ drb->Base.Format = MESA_FORMAT_ARGB8888;
}
}
else if (format == GL_DEPTH_COMPONENT16) {
/* Depth */
- drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
/* we always Get/Put 32-bit Z values */
drb->Base.DataType = GL_UNSIGNED_INT;
- drb->Base.DepthBits = 16;
+ drb->Base.Format = MESA_FORMAT_Z16;
}
else if (format == GL_DEPTH_COMPONENT24) {
/* Depth */
- drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
/* we always Get/Put 32-bit Z values */
drb->Base.DataType = GL_UNSIGNED_INT;
- drb->Base.DepthBits = 24;
+ drb->Base.Format = MESA_FORMAT_Z32;
}
else if (format == GL_DEPTH_COMPONENT32) {
/* Depth */
- drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
/* we always Get/Put 32-bit Z values */
drb->Base.DataType = GL_UNSIGNED_INT;
- drb->Base.DepthBits = 32;
+ drb->Base.Format = MESA_FORMAT_Z32;
}
else {
/* Stencil */
ASSERT(format == GL_STENCIL_INDEX8_EXT);
- drb->Base._BaseFormat = GL_STENCIL_INDEX;
drb->Base.DataType = GL_UNSIGNED_BYTE;
- drb->Base.StencilBits = 8;
+ drb->Base.Format = MESA_FORMAT_S8;
}
/* XXX if we were allocating a user-created renderbuffer, we'd have
diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c
index 03ed8a6311..e441e287eb 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -80,7 +80,7 @@ translate_texture_format(GLuint mesa_format, GLuint internal_format,
return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
case MESA_FORMAT_RGBA_DXT5:
return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
- case MESA_FORMAT_S8_Z24:
+ case MESA_FORMAT_Z24_S8:
return (MAPSURF_32BIT | MT_32BIT_xI824);
default:
fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format);
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c
index e7357e78c5..fce227e9d9 100644
--- a/src/mesa/drivers/dri/intel/intel_buffers.c
+++ b/src/mesa/drivers/dri/intel/intel_buffers.c
@@ -257,7 +257,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
irbStencil = intel_renderbuffer(fb->_StencilBuffer->Wrapped);
if (irbStencil && irbStencil->region) {
- ASSERT(irbStencil->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+ ASSERT(irbStencil->Base.Format == MESA_FORMAT_Z24_S8);
FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
}
else {
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index d49d95768d..6820393e00 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -189,19 +189,7 @@ intelGetString(GLcontext * ctx, GLenum name)
static unsigned
intel_bits_per_pixel(const struct intel_renderbuffer *rb)
{
- switch (rb->Base._ActualFormat) {
- case GL_RGB5:
- case GL_DEPTH_COMPONENT16:
- return 16;
- case GL_RGB8:
- case GL_RGBA8:
- case GL_DEPTH_COMPONENT24:
- case GL_DEPTH24_STENCIL8_EXT:
- case GL_STENCIL_INDEX8_EXT:
- return 32;
- default:
- return 0;
- }
+ return _mesa_get_format_bytes(rb->Base.Format) * 8;
}
void
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 3b4b90f2dc..292cccf7f2 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -114,11 +114,8 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
- rb->_ActualFormat = GL_RGB5;
+ rb->Format = MESA_FORMAT_RGB565;
rb->DataType = GL_UNSIGNED_BYTE;
- rb->RedBits = 5;
- rb->GreenBits = 6;
- rb->BlueBits = 5;
irb->texformat = MESA_FORMAT_RGB565;
cpp = 2;
break;
@@ -127,12 +124,8 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- rb->_ActualFormat = GL_RGB8;
+ rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
- rb->RedBits = 8;
- rb->GreenBits = 8;
- rb->BlueBits = 8;
- rb->AlphaBits = 0;
irb->texformat = MESA_FORMAT_ARGB8888; /* XXX: Need xrgb8888 */
cpp = 4;
break;
@@ -144,12 +137,8 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- rb->_ActualFormat = GL_RGBA8;
+ rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
- rb->RedBits = 8;
- rb->GreenBits = 8;
- rb->BlueBits = 8;
- rb->AlphaBits = 8;
irb->texformat = MESA_FORMAT_ARGB8888;
cpp = 4;
break;
@@ -159,36 +148,31 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_STENCIL_INDEX8_EXT:
case GL_STENCIL_INDEX16_EXT:
/* alloc a depth+stencil buffer */
- rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ rb->Format = MESA_FORMAT_Z24_S8;
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->StencilBits = 8;
cpp = 4;
- irb->texformat = MESA_FORMAT_S8_Z24;
+ irb->texformat = MESA_FORMAT_Z24_S8;
break;
case GL_DEPTH_COMPONENT16:
- rb->_ActualFormat = GL_DEPTH_COMPONENT16;
+ rb->Format = MESA_FORMAT_Z16;
rb->DataType = GL_UNSIGNED_SHORT;
- rb->DepthBits = 16;
cpp = 2;
irb->texformat = MESA_FORMAT_Z16;
break;
case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
- rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ rb->Format = MESA_FORMAT_Z24_S8;
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->DepthBits = 24;
cpp = 4;
- irb->texformat = MESA_FORMAT_S8_Z24;
+ irb->texformat = MESA_FORMAT_Z24_S8;
break;
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ rb->Format = MESA_FORMAT_Z24_S8;
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->DepthBits = 24;
- rb->StencilBits = 8;
cpp = 4;
- irb->texformat = MESA_FORMAT_S8_Z24;
+ irb->texformat = MESA_FORMAT_Z24_S8;
break;
default:
_mesa_problem(ctx,
@@ -196,6 +180,8 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
return GL_FALSE;
}
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
intelFlush(ctx);
/* free old region */
@@ -245,7 +231,7 @@ intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
ASSERT(rb->Name == 0);
rb->Width = width;
rb->Height = height;
- rb->_ActualFormat = internalFormat;
+ rb->InternalFormat = internalFormat;
return GL_TRUE;
}
@@ -324,62 +310,46 @@ intel_create_renderbuffer(GLenum intFormat)
switch (intFormat) {
case GL_RGB5:
- irb->Base._ActualFormat = GL_RGB5;
- irb->Base._BaseFormat = GL_RGBA;
- irb->Base.RedBits = 5;
- irb->Base.GreenBits = 6;
- irb->Base.BlueBits = 5;
+ irb->Base.Format = MESA_FORMAT_RGB565;
+ irb->Base._BaseFormat = GL_RGB;
irb->Base.DataType = GL_UNSIGNED_BYTE;
irb->texformat = MESA_FORMAT_RGB565;
break;
case GL_RGB8:
- irb->Base._ActualFormat = GL_RGB8;
+ irb->Base.Format = MESA_FORMAT_ARGB8888; /* XXX: NEED XRGB8888 */
irb->Base._BaseFormat = GL_RGB;
- irb->Base.RedBits = 8;
- irb->Base.GreenBits = 8;
- irb->Base.BlueBits = 8;
- irb->Base.AlphaBits = 0;
irb->Base.DataType = GL_UNSIGNED_BYTE;
irb->texformat = MESA_FORMAT_ARGB8888; /* XXX: NEED XRGB8888 */
break;
case GL_RGBA8:
- irb->Base._ActualFormat = GL_RGBA8;
+ irb->Base.Format = MESA_FORMAT_ARGB8888;
irb->Base._BaseFormat = GL_RGBA;
- irb->Base.RedBits = 8;
- irb->Base.GreenBits = 8;
- irb->Base.BlueBits = 8;
- irb->Base.AlphaBits = 8;
irb->Base.DataType = GL_UNSIGNED_BYTE;
irb->texformat = MESA_FORMAT_ARGB8888;
break;
case GL_STENCIL_INDEX8_EXT:
- irb->Base._ActualFormat = GL_STENCIL_INDEX8_EXT;
+ irb->Base.Format = MESA_FORMAT_Z24_S8;
irb->Base._BaseFormat = GL_STENCIL_INDEX;
- irb->Base.StencilBits = 8;
irb->Base.DataType = GL_UNSIGNED_BYTE;
- irb->texformat = MESA_FORMAT_S8_Z24;
+ irb->texformat = MESA_FORMAT_Z24_S8;
break;
case GL_DEPTH_COMPONENT16:
- irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
+ irb->Base.Format = MESA_FORMAT_Z16;
irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- irb->Base.DepthBits = 16;
irb->Base.DataType = GL_UNSIGNED_SHORT;
irb->texformat = MESA_FORMAT_Z16;
break;
case GL_DEPTH_COMPONENT24:
- irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ irb->Base.Format = MESA_FORMAT_Z24_S8;
irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- irb->Base.DepthBits = 24;
irb->Base.DataType = GL_UNSIGNED_INT;
- irb->texformat = MESA_FORMAT_S8_Z24;
+ irb->texformat = MESA_FORMAT_Z24_S8;
break;
case GL_DEPTH24_STENCIL8_EXT:
- irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
- irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
- irb->Base.DepthBits = 24;
- irb->Base.StencilBits = 8;
+ irb->Base.Format = MESA_FORMAT_Z24_S8;
+ irb->Base._BaseFormat = GL_DEPTH_STENCIL;
irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
- irb->texformat = MESA_FORMAT_S8_Z24;
+ irb->texformat = MESA_FORMAT_Z24_S8;
break;
default:
_mesa_problem(NULL,
@@ -468,38 +438,26 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
gl_format texFormat;
if (texImage->TexFormat == MESA_FORMAT_ARGB8888) {
- irb->Base._ActualFormat = GL_RGBA8;
- irb->Base._BaseFormat = GL_RGBA;
irb->Base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to RGBA8 texture OK\n");
}
else if (texImage->TexFormat == MESA_FORMAT_RGB565) {
- irb->Base._ActualFormat = GL_RGB5;
- irb->Base._BaseFormat = GL_RGB;
irb->Base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to RGB5 texture OK\n");
}
else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) {
- irb->Base._ActualFormat = GL_RGB5_A1;
- irb->Base._BaseFormat = GL_RGBA;
irb->Base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to ARGB1555 texture OK\n");
}
else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) {
- irb->Base._ActualFormat = GL_RGBA4;
- irb->Base._BaseFormat = GL_RGBA;
irb->Base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to ARGB4444 texture OK\n");
}
else if (texImage->TexFormat == MESA_FORMAT_Z16) {
- irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
- irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
irb->Base.DataType = GL_UNSIGNED_SHORT;
DBG("Render to DEPTH16 texture OK\n");
}
- else if (texImage->TexFormat == MESA_FORMAT_S8_Z24) {
- irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
- irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
+ else if (texImage->TexFormat == MESA_FORMAT_Z24_S8) {
irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
DBG("Render to DEPTH_STENCIL texture OK\n");
}
@@ -508,17 +466,14 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
return GL_FALSE;
}
+ irb->Base.Format = texImage->TexFormat;
+
texFormat = texImage->TexFormat;
- irb->Base.InternalFormat = irb->Base._ActualFormat;
+ irb->Base.InternalFormat = texImage->InternalFormat;
+ irb->Base._BaseFormat = _mesa_base_fbo_format(ctx, irb->Base.InternalFormat);
irb->Base.Width = texImage->Width;
irb->Base.Height = texImage->Height;
- irb->Base.RedBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE);
- irb->Base.GreenBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE);
- irb->Base.BlueBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE);
- irb->Base.AlphaBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE);
- irb->Base.DepthBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE_ARB);
- irb->Base.StencilBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_STENCIL_SIZE_EXT);
irb->Base.Delete = intel_delete_renderbuffer;
irb->Base.AllocStorage = intel_nop_alloc_storage;
diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c
index 5bbcce6fe4..540ebca15c 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -621,7 +621,7 @@ intel_set_span_functions(struct intel_context *intel,
}
break;
case MESA_FORMAT_ARGB8888:
- if (rb->AlphaBits == 0) { /* XXX: Need xRGB8888 Mesa format */
+ if (0 /*rb->AlphaBits == 0*/) { /* XXX: Need xRGB8888 Mesa format */
/* 8888 RGBx */
switch (tiling) {
case I915_TILING_NONE:
@@ -665,26 +665,13 @@ intel_set_span_functions(struct intel_context *intel,
break;
}
break;
- case MESA_FORMAT_S8_Z24:
+ case MESA_FORMAT_Z24_S8:
/* There are a few different ways SW asks us to access the S8Z24 data:
* Z24 depth-only depth reads
* S8Z24 depth reads
* S8Z24 stencil reads.
*/
- if (rb->_ActualFormat == GL_DEPTH_COMPONENT24) {
- switch (tiling) {
- case I915_TILING_NONE:
- default:
- intelInitDepthPointers_z24(rb);
- break;
- case I915_TILING_X:
- intel_XTile_InitDepthPointers_z24(rb);
- break;
- case I915_TILING_Y:
- intel_YTile_InitDepthPointers_z24(rb);
- break;
- }
- } else if (rb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+ if (rb->Format == MESA_FORMAT_Z24_S8) {
switch (tiling) {
case I915_TILING_NONE:
default:
@@ -697,7 +684,7 @@ intel_set_span_functions(struct intel_context *intel,
intel_YTile_InitDepthPointers_z24_s8(rb);
break;
}
- } else if (rb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
+ } else if (rb->Format == MESA_FORMAT_S8) {
switch (tiling) {
case I915_TILING_NONE:
default:
diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c
index eca0f6d572..a71590d3ef 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_format.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_format.c
@@ -153,7 +153,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
#endif
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- return MESA_FORMAT_S8_Z24;
+ return MESA_FORMAT_Z24_S8;
#ifndef I915
case GL_SRGB_EXT:
diff --git a/src/mesa/drivers/dri/r200/r200_state_init.c b/src/mesa/drivers/dri/r200/r200_state_init.c
index 7697306d88..68bfeea701 100644
--- a/src/mesa/drivers/dri/r200/r200_state_init.c
+++ b/src/mesa/drivers/dri/r200/r200_state_init.c
@@ -529,16 +529,18 @@ static void ctx_emit_cs(GLcontext *ctx, struct radeon_state_atom *atom)
atom->cmd[CTX_RB3D_CNTL] &= ~(0xf << 10);
if (rrb->cpp == 4)
atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB8888;
- else switch (rrb->base._ActualFormat) {
- case GL_RGB5:
+ else switch (rrb->base.Format) {
+ case MESA_FORMAT_RGB565:
atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_RGB565;
break;
- case GL_RGBA4:
+ case MESA_FORMAT_ARGB4444:
atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB4444;
break;
- case GL_RGB5_A1:
+ case MESA_FORMAT_ARGB1555:
atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB1555;
break;
+ default:
+ _mesa_problem(ctx, "Unexpected format in ctx_emit_cs");
}
cbpitch = (rrb->pitch / rrb->cpp);
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
index da5b7ba642..1e2a54f634 100644
--- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c
+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
@@ -279,16 +279,18 @@ static void emit_cb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
cbpitch = (rrb->pitch / rrb->cpp);
if (rrb->cpp == 4)
cbpitch |= R300_COLOR_FORMAT_ARGB8888;
- else switch (rrb->base._ActualFormat) {
- case GL_RGB5:
+ else switch (rrb->base.Format) {
+ case MESA_FORMAT_RGB565:
cbpitch |= R300_COLOR_FORMAT_RGB565;
break;
- case GL_RGBA4:
+ case MESA_FORMAT_ARGB4444:
cbpitch |= R300_COLOR_FORMAT_ARGB4444;
break;
- case GL_RGB5_A1:
+ case MESA_FORMAT_ARGB1555:
cbpitch |= R300_COLOR_FORMAT_ARGB1555;
break;
+ default:
+ _mesa_problem(ctx, "unexpected format in emit_cb_offset()");
}
if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c
index 6b9b1e3c5e..fe99644907 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c
@@ -496,19 +496,7 @@ radeon_make_renderbuffer_current(radeonContextPtr radeon,
static unsigned
radeon_bits_per_pixel(const struct radeon_renderbuffer *rb)
{
- switch (rb->base._ActualFormat) {
- case GL_RGB5:
- case GL_DEPTH_COMPONENT16:
- return 16;
- case GL_RGB8:
- case GL_RGBA8:
- case GL_DEPTH_COMPONENT24:
- case GL_DEPTH24_STENCIL8_EXT:
- case GL_STENCIL_INDEX8_EXT:
- return 32;
- default:
- return 0;
- }
+ return _mesa_get_format_bytes(rb->base.Format) * 8;
}
void
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 3f4f382d6c..796dd1b423 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -90,11 +90,8 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
- rb->_ActualFormat = GL_RGB5;
+ rb->Format = MESA_FORMAT_RGB565;
rb->DataType = GL_UNSIGNED_BYTE;
- rb->RedBits = 5;
- rb->GreenBits = 6;
- rb->BlueBits = 5;
cpp = 2;
break;
case GL_RGB:
@@ -102,12 +99,8 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- rb->_ActualFormat = GL_RGB8;
+ rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
- rb->RedBits = 8;
- rb->GreenBits = 8;
- rb->BlueBits = 8;
- rb->AlphaBits = 0;
cpp = 4;
break;
case GL_RGBA:
@@ -118,12 +111,8 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- rb->_ActualFormat = GL_RGBA8;
+ rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
- rb->RedBits = 8;
- rb->GreenBits = 8;
- rb->BlueBits = 8;
- rb->AlphaBits = 8;
cpp = 4;
break;
case GL_STENCIL_INDEX:
@@ -132,31 +121,26 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_STENCIL_INDEX8_EXT:
case GL_STENCIL_INDEX16_EXT:
/* alloc a depth+stencil buffer */
- rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ rb->Format = MESA_FORMAT_Z24_S8;
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->StencilBits = 8;
cpp = 4;
break;
case GL_DEPTH_COMPONENT16:
- rb->_ActualFormat = GL_DEPTH_COMPONENT16;
+ rb->Format = MESA_FORMAT_Z16;
rb->DataType = GL_UNSIGNED_SHORT;
- rb->DepthBits = 16;
cpp = 2;
break;
case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
- rb->_ActualFormat = GL_DEPTH_COMPONENT24;
+ rb->Format = MESA_FORMAT_Z32;
rb->DataType = GL_UNSIGNED_INT;
- rb->DepthBits = 24;
cpp = 4;
break;
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ rb->Format = MESA_FORMAT_Z24_S8;
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->DepthBits = 24;
- rb->StencilBits = 8;
cpp = 4;
break;
default:
@@ -165,6 +149,8 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
return GL_FALSE;
}
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
if (ctx->Driver.Flush)
ctx->Driver.Flush(ctx); /* +r6/r7 */
@@ -212,7 +198,7 @@ radeon_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
ASSERT(rb->Name == 0);
rb->Width = width;
rb->Height = height;
- rb->_ActualFormat = internalFormat;
+ rb->InternalFormat = internalFormat;
return GL_TRUE;
}
@@ -269,55 +255,32 @@ radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv)
/* XXX format junk */
switch (format) {
case GL_RGB5:
- rrb->base._ActualFormat = GL_RGB5;
- rrb->base._BaseFormat = GL_RGBA;
- rrb->base.RedBits = 5;
- rrb->base.GreenBits = 6;
- rrb->base.BlueBits = 5;
rrb->base.DataType = GL_UNSIGNED_BYTE;
+ rrb->base._BaseFormat = GL_RGB;
break;
case GL_RGB8:
- rrb->base._ActualFormat = GL_RGB8;
- rrb->base._BaseFormat = GL_RGB;
- rrb->base.RedBits = 8;
- rrb->base.GreenBits = 8;
- rrb->base.BlueBits = 8;
- rrb->base.AlphaBits = 0;
rrb->base.DataType = GL_UNSIGNED_BYTE;
+ rrb->base._BaseFormat = GL_RGB;
break;
case GL_RGBA8:
- rrb->base._ActualFormat = GL_RGBA8;
- rrb->base._BaseFormat = GL_RGBA;
- rrb->base.RedBits = 8;
- rrb->base.GreenBits = 8;
- rrb->base.BlueBits = 8;
- rrb->base.AlphaBits = 8;
rrb->base.DataType = GL_UNSIGNED_BYTE;
+ rrb->base._BaseFormat = GL_RGBA;
break;
case GL_STENCIL_INDEX8_EXT:
- rrb->base._ActualFormat = GL_STENCIL_INDEX8_EXT;
- rrb->base._BaseFormat = GL_STENCIL_INDEX;
- rrb->base.StencilBits = 8;
rrb->base.DataType = GL_UNSIGNED_BYTE;
+ rrb->base._BaseFormat = GL_STENCIL_INDEX;
break;
case GL_DEPTH_COMPONENT16:
- rrb->base._ActualFormat = GL_DEPTH_COMPONENT16;
- rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
- rrb->base.DepthBits = 16;
rrb->base.DataType = GL_UNSIGNED_SHORT;
+ rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH_COMPONENT24:
- rrb->base._ActualFormat = GL_DEPTH_COMPONENT24;
- rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
- rrb->base.DepthBits = 24;
rrb->base.DataType = GL_UNSIGNED_INT;
+ rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
break;
case GL_DEPTH24_STENCIL8_EXT:
- rrb->base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
- rrb->base._BaseFormat = GL_DEPTH_STENCIL_EXT;
- rrb->base.DepthBits = 24;
- rrb->base.StencilBits = 8;
rrb->base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+ rrb->base._BaseFormat = GL_STENCIL_INDEX;
break;
default:
fprintf(stderr, "%s: Unknown format 0x%04x\n", __FUNCTION__, format);
@@ -390,44 +353,26 @@ radeon_update_wrapper(GLcontext *ctx, struct radeon_renderbuffer *rrb,
restart:
if (texImage->TexFormat == MESA_FORMAT_ARGB8888) {
- rrb->cpp = 4;
- rrb->base._ActualFormat = GL_RGBA8;
- rrb->base._BaseFormat = GL_RGBA;
rrb->base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to RGBA8 texture OK\n");
}
else if (texImage->TexFormat == MESA_FORMAT_RGB565) {
- rrb->cpp = 2;
- rrb->base._ActualFormat = GL_RGB5;
- rrb->base._BaseFormat = GL_RGB;
rrb->base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to RGB5 texture OK\n");
}
else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) {
- rrb->cpp = 2;
- rrb->base._ActualFormat = GL_RGB5_A1;
- rrb->base._BaseFormat = GL_RGBA;
rrb->base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to ARGB1555 texture OK\n");
}
else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) {
- rrb->cpp = 2;
- rrb->base._ActualFormat = GL_RGBA4;
- rrb->base._BaseFormat = GL_RGBA;
rrb->base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to ARGB1555 texture OK\n");
}
else if (texImage->TexFormat == MESA_FORMAT_Z16) {
- rrb->cpp = 2;
- rrb->base._ActualFormat = GL_DEPTH_COMPONENT16;
- rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
rrb->base.DataType = GL_UNSIGNED_SHORT;
DBG("Render to DEPTH16 texture OK\n");
}
else if (texImage->TexFormat == MESA_FORMAT_S8_Z24) {
- rrb->cpp = 4;
- rrb->base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
- rrb->base._BaseFormat = GL_DEPTH_STENCIL_EXT;
rrb->base.DataType = GL_UNSIGNED_INT_24_8_EXT;
DBG("Render to DEPTH_STENCIL texture OK\n");
}
@@ -448,16 +393,15 @@ restart:
texFormat = texImage->TexFormat;
+ rrb->base.Format = texFormat;
+
+ rrb->cpp = _mesa_get_format_bytes(texFormat);
rrb->pitch = texImage->Width * rrb->cpp;
- rrb->base.InternalFormat = rrb->base._ActualFormat;
+ rrb->base.InternalFormat = texImage->InternalFormat;
+ rrb->base._BaseFormat = _mesa_base_fbo_format(ctx, rrb->base.InternalFormat);
+
rrb->base.Width = texImage->Width;
rrb->base.Height = texImage->Height;
- rrb->base.RedBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE);
- rrb->base.GreenBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE);
- rrb->base.BlueBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE);
- rrb->base.AlphaBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE);
- rrb->base.DepthBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE_ARB);
- rrb->base.StencilBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_STENCIL_SIZE_EXT);
rrb->base.Delete = radeon_delete_renderbuffer;
rrb->base.AllocStorage = radeon_nop_alloc_storage;
diff --git a/src/mesa/drivers/dri/radeon/radeon_span.c b/src/mesa/drivers/dri/radeon/radeon_span.c
index 0c49c3713a..055f77a24b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_span.c
+++ b/src/mesa/drivers/dri/radeon/radeon_span.c
@@ -864,25 +864,25 @@ void radeonInitSpanFuncs(GLcontext * ctx)
*/
static void radeonSetSpanFunctions(struct radeon_renderbuffer *rrb)
{
- if (rrb->base._ActualFormat == GL_RGB5) {
+ if (rrb->base.Format == MESA_FORMAT_RGB565) {
radeonInitPointers_RGB565(&rrb->base);
- } else if (rrb->base._ActualFormat == GL_RGB8) {
+ } else if (rrb->base.Format == MESA_FORMAT_RGBA8888) { /* XXX */
radeonInitPointers_xRGB8888(&rrb->base);
- } else if (rrb->base._ActualFormat == GL_RGBA8) {
+ } else if (rrb->base.Format == MESA_FORMAT_RGBA8888) {
radeonInitPointers_ARGB8888(&rrb->base);
- } else if (rrb->base._ActualFormat == GL_RGBA4) {
+ } else if (rrb->base.Format == MESA_FORMAT_ARGB4444) {
radeonInitPointers_ARGB4444(&rrb->base);
- } else if (rrb->base._ActualFormat == GL_RGB5_A1) {
+ } else if (rrb->base.Format == MESA_FORMAT_ARGB1555) {
radeonInitPointers_ARGB1555(&rrb->base);
- } else if (rrb->base._ActualFormat == GL_DEPTH_COMPONENT16) {
+ } else if (rrb->base.Format == MESA_FORMAT_Z16) {
radeonInitDepthPointers_z16(&rrb->base);
- } else if (rrb->base._ActualFormat == GL_DEPTH_COMPONENT24) {
+ } else if (rrb->base.Format == GL_DEPTH_COMPONENT32) { /* XXX */
radeonInitDepthPointers_z24(&rrb->base);
- } else if (rrb->base._ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+ } else if (rrb->base.Format == MESA_FORMAT_Z24_S8) {
radeonInitDepthPointers_z24_s8(&rrb->base);
- } else if (rrb->base._ActualFormat == GL_STENCIL_INDEX8_EXT) {
+ } else if (rrb->base.Format == MESA_FORMAT_S8) {
radeonInitStencilPointers_z24_s8(&rrb->base);
} else {
- fprintf(stderr, "radeonSetSpanFunctions: bad actual format: 0x%04X\n", rrb->base._ActualFormat);
+ fprintf(stderr, "radeonSetSpanFunctions: bad actual format: 0x%04X\n", rrb->base.Format);
}
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_state_init.c b/src/mesa/drivers/dri/radeon/radeon_state_init.c
index f3ad0dd17a..2d19220d8a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state_init.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state_init.c
@@ -440,16 +440,18 @@ static void ctx_emit_cs(GLcontext *ctx, struct radeon_state_atom *atom)
atom->cmd[CTX_RB3D_CNTL] &= ~(0xf << 10);
if (rrb->cpp == 4)
atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB8888;
- else switch (rrb->base._ActualFormat) {
- case GL_RGB5:
+ else switch (rrb->base.Format) {
+ case MESA_FORMAT_RGB565:
atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_RGB565;
break;
- case GL_RGBA4:
+ case MESA_FORMAT_ARGB4444:
atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB4444;
break;
- case GL_RGB5_A1:
+ case MESA_FORMAT_ARGB1555:
atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB1555;
break;
+ default:
+ _mesa_problem(ctx, "unexpected format in ctx_emit_cs()");
}
cbpitch = (rrb->pitch / rrb->cpp);
diff --git a/src/mesa/drivers/dri/sis/sis_dd.c b/src/mesa/drivers/dri/sis/sis_dd.c
index bddc4a9285..217d77557f 100644
--- a/src/mesa/drivers/dri/sis/sis_dd.c
+++ b/src/mesa/drivers/dri/sis/sis_dd.c
@@ -41,6 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "sis_tris.h"
#include "swrast/swrast.h"
+#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
@@ -142,25 +143,25 @@ sisInitRenderbuffer(struct gl_renderbuffer *rb, GLenum format)
if (format == GL_RGBA) {
/* Color */
- rb->_BaseFormat = GL_RGBA;
+ rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
}
else if (format == GL_DEPTH_COMPONENT16) {
/* Depth */
- rb->_BaseFormat = GL_DEPTH_COMPONENT;
/* we always Get/Put 32-bit Z values */
+ rb->Format = MESA_FORMAT_Z16;
rb->DataType = GL_UNSIGNED_INT;
}
else if (format == GL_DEPTH_COMPONENT24) {
/* Depth */
- rb->_BaseFormat = GL_DEPTH_COMPONENT;
/* we always Get/Put 32-bit Z values */
+ rb->Format = MESA_FORMAT_Z32;
rb->DataType = GL_UNSIGNED_INT;
}
else {
/* Stencil */
ASSERT(format == GL_STENCIL_INDEX8_EXT);
- rb->_BaseFormat = GL_STENCIL_INDEX;
+ rb->Format = MESA_FORMAT_S8;
rb->DataType = GL_UNSIGNED_BYTE;
}
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index f4947daa06..a8d1a95bbe 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -33,6 +33,7 @@
#include "main/context.h"
#include "main/extensions.h"
+#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/imports.h"
#include "main/renderbuffer.h"
@@ -378,50 +379,38 @@ swrast_new_renderbuffer(const GLvisual *visual, GLboolean front)
switch (pixel_format) {
case PF_A8R8G8B8:
+ xrb->Base.Format = MESA_FORMAT_ARGB8888;
xrb->Base.InternalFormat = GL_RGBA;
xrb->Base._BaseFormat = GL_RGBA;
xrb->Base.DataType = GL_UNSIGNED_BYTE;
- xrb->Base.RedBits = 8 * sizeof(GLubyte);
- xrb->Base.GreenBits = 8 * sizeof(GLubyte);
- xrb->Base.BlueBits = 8 * sizeof(GLubyte);
- xrb->Base.AlphaBits = 8 * sizeof(GLubyte);
xrb->bpp = 32;
break;
case PF_X8R8G8B8:
+ xrb->Base.Format = MESA_FORMAT_ARGB8888; /* XXX */
xrb->Base.InternalFormat = GL_RGB;
xrb->Base._BaseFormat = GL_RGB;
xrb->Base.DataType = GL_UNSIGNED_BYTE;
- xrb->Base.RedBits = 8 * sizeof(GLubyte);
- xrb->Base.GreenBits = 8 * sizeof(GLubyte);
- xrb->Base.BlueBits = 8 * sizeof(GLubyte);
- xrb->Base.AlphaBits = 0;
xrb->bpp = 32;
break;
case PF_R5G6B5:
+ xrb->Base.Format = MESA_FORMAT_RGB565;
xrb->Base.InternalFormat = GL_RGB;
xrb->Base._BaseFormat = GL_RGB;
xrb->Base.DataType = GL_UNSIGNED_BYTE;
- xrb->Base.RedBits = 5 * sizeof(GLubyte);
- xrb->Base.GreenBits = 6 * sizeof(GLubyte);
- xrb->Base.BlueBits = 5 * sizeof(GLubyte);
- xrb->Base.AlphaBits = 0;
xrb->bpp = 16;
break;
case PF_R3G3B2:
+ xrb->Base.Format = MESA_FORMAT_RGB332;
xrb->Base.InternalFormat = GL_RGB;
xrb->Base._BaseFormat = GL_RGB;
xrb->Base.DataType = GL_UNSIGNED_BYTE;
- xrb->Base.RedBits = 3 * sizeof(GLubyte);
- xrb->Base.GreenBits = 3 * sizeof(GLubyte);
- xrb->Base.BlueBits = 2 * sizeof(GLubyte);
- xrb->Base.AlphaBits = 0;
xrb->bpp = 8;
break;
case PF_CI8:
+ xrb->Base.Format = MESA_FORMAT_CI8;
xrb->Base.InternalFormat = GL_COLOR_INDEX8_EXT;
xrb->Base._BaseFormat = GL_COLOR_INDEX;
xrb->Base.DataType = GL_UNSIGNED_BYTE;
- xrb->Base.IndexBits = 8 * sizeof(GLubyte);
xrb->bpp = 8;
break;
default:
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
index 6eb19ac079..e7b6b030d1 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.c
+++ b/src/mesa/drivers/dri/unichrome/via_context.c
@@ -32,6 +32,7 @@
#include "main/glheader.h"
#include "main/context.h"
+#include "main/formats.h"
#include "main/matrix.h"
#include "main/state.h"
#include "main/simple_list.h"
@@ -163,24 +164,28 @@ viaInitRenderbuffer(struct via_renderbuffer *vrb, GLenum format,
if (format == GL_RGBA) {
/* Color */
rb->_BaseFormat = GL_RGBA;
+ rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
}
else if (format == GL_DEPTH_COMPONENT16) {
/* Depth */
rb->_BaseFormat = GL_DEPTH_COMPONENT;
/* we always Get/Put 32-bit Z values */
+ rb->Format = MESA_FORMAT_Z16;
rb->DataType = GL_UNSIGNED_INT;
}
else if (format == GL_DEPTH_COMPONENT24) {
/* Depth */
rb->_BaseFormat = GL_DEPTH_COMPONENT;
/* we always Get/Put 32-bit Z values */
+ rb->Format = MESA_FORMAT_Z32;
rb->DataType = GL_UNSIGNED_INT;
}
else {
/* Stencil */
ASSERT(format == GL_STENCIL_INDEX8_EXT);
rb->_BaseFormat = GL_STENCIL_INDEX;
+ rb->Format = MESA_FORMAT_S8;
rb->DataType = GL_UNSIGNED_BYTE;
}
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 692657a5df..bac8a9ef14 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -37,6 +37,7 @@
#include "GL/osmesa.h"
#include "main/context.h"
#include "main/extensions.h"
+#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/imports.h"
#include "main/mtypes.h"
@@ -840,11 +841,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
else
bpc = 32;
- rb->RedBits =
- rb->GreenBits =
- rb->BlueBits =
- rb->AlphaBits = bpc;
-
/* Note: we can ignoring internalFormat for "window-system" renderbuffers */
(void) internalFormat;
@@ -876,7 +872,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutValues = put_values_RGBA32;
rb->PutMonoValues = put_mono_values_RGBA32;
}
- rb->RedBits = rb->GreenBits = rb->BlueBits = rb->AlphaBits = bpc;
}
else if (osmesa->format == OSMESA_BGRA) {
if (rb->DataType == GL_UNSIGNED_BYTE) {
@@ -906,7 +901,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutValues = put_values_BGRA32;
rb->PutMonoValues = put_mono_values_BGRA32;
}
- rb->RedBits = rb->GreenBits = rb->BlueBits = rb->AlphaBits = bpc;
}
else if (osmesa->format == OSMESA_ARGB) {
if (rb->DataType == GL_UNSIGNED_BYTE) {
@@ -936,7 +930,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutValues = put_values_ARGB32;
rb->PutMonoValues = put_mono_values_ARGB32;
}
- rb->RedBits = rb->GreenBits = rb->BlueBits = rb->AlphaBits = bpc;
}
else if (osmesa->format == OSMESA_RGB) {
if (rb->DataType == GL_UNSIGNED_BYTE) {
@@ -966,7 +959,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutValues = put_values_RGB32;
rb->PutMonoValues = put_mono_values_RGB32;
}
- rb->RedBits = rb->GreenBits = rb->BlueBits = bpc;
}
else if (osmesa->format == OSMESA_BGR) {
if (rb->DataType == GL_UNSIGNED_BYTE) {
@@ -996,7 +988,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutValues = put_values_BGR32;
rb->PutMonoValues = put_mono_values_BGR32;
}
- rb->RedBits = rb->GreenBits = rb->BlueBits = bpc;
}
else if (osmesa->format == OSMESA_RGB_565) {
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
@@ -1007,9 +998,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_RGB_565;
rb->PutValues = put_values_RGB_565;
rb->PutMonoValues = put_mono_values_RGB_565;
- rb->RedBits = 5;
- rb->GreenBits = 6;
- rb->BlueBits = 5;
}
else if (osmesa->format == OSMESA_COLOR_INDEX) {
rb->GetRow = get_row_CI;
@@ -1018,7 +1006,6 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_CI;
rb->PutValues = put_values_CI;
rb->PutMonoValues = put_mono_values_CI;
- rb->IndexBits = 8;
}
else {
_mesa_problem(ctx, "bad pixel format in osmesa renderbuffer_storage");
@@ -1048,13 +1035,13 @@ new_osmesa_renderbuffer(GLcontext *ctx, GLenum format, GLenum type)
if (format == OSMESA_COLOR_INDEX) {
rb->InternalFormat = GL_COLOR_INDEX;
- rb->_ActualFormat = GL_COLOR_INDEX8_EXT;
+ rb->Format = MESA_FORMAT_CI8;
rb->_BaseFormat = GL_COLOR_INDEX;
rb->DataType = GL_UNSIGNED_BYTE;
}
else {
rb->InternalFormat = GL_RGBA;
- rb->_ActualFormat = GL_RGBA;
+ rb->Format = MESA_FORMAT_RGBA8888;
rb->_BaseFormat = GL_RGBA;
rb->DataType = type;
}
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
index 821e2a8e08..bf38629289 100644
--- a/src/mesa/drivers/x11/xm_buffer.c
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -32,6 +32,7 @@
#include "glxheader.h"
#include "xmesaP.h"
#include "main/imports.h"
+#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
@@ -338,18 +339,15 @@ xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
if (visual->rgbMode) {
xrb->Base.InternalFormat = GL_RGBA;
+ xrb->Base.Format = MESA_FORMAT_RGBA8888;
xrb->Base._BaseFormat = GL_RGBA;
xrb->Base.DataType = GL_UNSIGNED_BYTE;
- xrb->Base.RedBits = visual->redBits;
- xrb->Base.GreenBits = visual->greenBits;
- xrb->Base.BlueBits = visual->blueBits;
- xrb->Base.AlphaBits = visual->alphaBits;
}
else {
xrb->Base.InternalFormat = GL_COLOR_INDEX;
+ xrb->Base.Format = MESA_FORMAT_CI8;
xrb->Base._BaseFormat = GL_COLOR_INDEX;
xrb->Base.DataType = GL_UNSIGNED_INT;
- xrb->Base.IndexBits = visual->indexBits;
}
/* only need to set Red/Green/EtcBits fields for user-created RBs */
}
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index d757e50b5a..a27d7045ab 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -448,7 +448,7 @@ can_do_DrawPixels_8R8G8B(GLcontext *ctx, GLenum format, GLenum type)
struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped);
if (xrb &&
xrb->pixmap && /* drawing to pixmap or window */
- xrb->Base.AlphaBits == 0) {
+ _mesa_get_format_bits(xrb->Base.Format, GL_ALPHA_BITS) == 0) {
return GL_TRUE;
}
}
@@ -582,7 +582,7 @@ can_do_DrawPixels_5R6G5B(GLcontext *ctx, GLenum format, GLenum type)
struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped);
if (xrb &&
xrb->pixmap && /* drawing to pixmap or window */
- xrb->Base.AlphaBits == 0) {
+ _mesa_get_format_bits(xrb->Base.Format, GL_ALPHA_BITS) == 0) {
return GL_TRUE;
}
}
diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
index 7be2aacaf2..803dc6c75e 100644
--- a/src/mesa/main/depthstencil.c
+++ b/src/mesa/main/depthstencil.c
@@ -26,6 +26,7 @@
#include "imports.h"
#include "context.h"
#include "fbobject.h"
+#include "formats.h"
#include "mtypes.h"
#include "depthstencil.h"
#include "renderbuffer.h"
@@ -40,8 +41,8 @@
* a combined Z+stencil buffer! That implies we need three different sets
* of Get/Put functions.
*
- * We solve this by wrapping the Z24_S8 renderbuffer with depth and stencil
- * adaptors, each with the right kind of depth/stencil Get/Put functions.
+ * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and
+ * stencil adaptors, each with the right kind of depth/stencil Get/Put functions.
*/
@@ -62,8 +63,8 @@ nop_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb, GLint x, GLint y)
static void
delete_wrapper(struct gl_renderbuffer *rb)
{
- ASSERT(rb->_ActualFormat == GL_DEPTH_COMPONENT24 ||
- rb->_ActualFormat == GL_STENCIL_INDEX8_EXT);
+ ASSERT(rb->Format == MESA_FORMAT_Z24_S8 ||
+ rb->Format == MESA_FORMAT_S8_Z24);
_mesa_reference_renderbuffer(&rb->Wrapped, NULL);
_mesa_free(rb);
}
@@ -82,7 +83,8 @@ alloc_wrapper_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
(void) internalFormat;
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 ||
+ dsrb->Format == MESA_FORMAT_S8_Z24);
retVal = dsrb->AllocStorage(ctx, dsrb, dsrb->InternalFormat, width, height);
if (retVal) {
@@ -108,14 +110,21 @@ get_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
GLuint *dst = (GLuint *) values;
const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
if (!src) {
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
src = temp;
}
- for (i = 0; i < count; i++) {
- dst[i] = src[i] >> 8;
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ dst[i] = src[i] >> 8;
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ dst[i] = src[i] & 0xffffff;
+ }
}
}
@@ -127,13 +136,20 @@ get_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
GLuint temp[MAX_WIDTH], i;
GLuint *dst = (GLuint *) values;
ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
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] >> 8;
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ dst[i] = temp[i] >> 8;
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ dst[i] = temp[i] & 0xffffff;
+ }
}
}
@@ -145,14 +161,23 @@ put_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
const GLuint *src = (const GLuint *) values;
GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
if (dst) {
/* direct access */
GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = (src[i] << 8) | (dst[i] & 0xff);
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = (src[i] << 8) | (dst[i] & 0xff);
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = (src[i] & 0xffffff) | (dst[i] & 0xff000000);
+ }
}
}
}
@@ -160,9 +185,19 @@ put_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
/* get, modify, put */
GLuint temp[MAX_WIDTH], i;
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (src[i] << 8) | (temp[i] & 0xff);
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (src[i] << 8) | (temp[i] & 0xff);
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000);
+ }
}
}
dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
@@ -174,17 +209,27 @@ put_mono_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
GLint x, GLint y, const void *value, const GLubyte *mask)
{
struct gl_renderbuffer *dsrb = z24rb->Wrapped;
- const GLuint shiftedVal = *((GLuint *) value) << 8;
GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
if (dst) {
/* direct access */
GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = shiftedVal | (dst[i] & 0xff);
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ const GLuint shiftedVal = *((GLuint *) value) << 8;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = shiftedVal | (dst[i] & 0xff);
+ }
+ }
+ }
+ else {
+ const GLuint shiftedVal = *((GLuint *) value);
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = shiftedVal | (dst[i] & 0xff000000);
+ }
}
}
}
@@ -192,9 +237,21 @@ put_mono_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
/* get, modify, put */
GLuint temp[MAX_WIDTH], i;
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = shiftedVal | (temp[i] & 0xff);
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ const GLuint shiftedVal = *((GLuint *) value) << 8;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = shiftedVal | (temp[i] & 0xff);
+ }
+ }
+ }
+ else {
+ const GLuint shiftedVal = *((GLuint *) value);
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = shiftedVal | (temp[i] & 0xff000000);
+ }
}
}
dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
@@ -209,15 +266,25 @@ put_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
struct gl_renderbuffer *dsrb = z24rb->Wrapped;
const GLuint *src = (const GLuint *) values;
ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
/* direct access */
GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
- *dst = (src[i] << 8) | (*dst & 0xff);
+ 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]);
+ *dst = (src[i] << 8) | (*dst & 0xff);
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+ *dst = (src[i] & 0xffffff) | (*dst & 0xff000000);
+ }
}
}
}
@@ -225,9 +292,19 @@ put_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
/* get, modify, put */
GLuint temp[MAX_WIDTH], i;
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (src[i] << 8) | (temp[i] & 0xff);
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (src[i] << 8) | (temp[i] & 0xff);
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000);
+ }
}
}
dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
@@ -241,12 +318,23 @@ put_mono_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb,
{
struct gl_renderbuffer *dsrb = z24rb->Wrapped;
GLuint temp[MAX_WIDTH], i;
- const GLuint shiftedVal = *((GLuint *) value) << 8;
/* get, modify, put */
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = shiftedVal | (temp[i] & 0xff);
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ const GLuint shiftedVal = *((GLuint *) value) << 8;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = shiftedVal | (temp[i] & 0xff);
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ const GLuint shiftedVal = *((GLuint *) value);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = shiftedVal | (temp[i] & 0xff000000);
+ }
}
}
dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
@@ -264,7 +352,8 @@ _mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx,
{
struct gl_renderbuffer *z24rb;
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 ||
+ dsrb->Format == MESA_FORMAT_S8_Z24);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
z24rb = _mesa_new_renderbuffer(ctx, 0);
@@ -277,10 +366,9 @@ _mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx,
z24rb->Width = dsrb->Width;
z24rb->Height = dsrb->Height;
z24rb->InternalFormat = GL_DEPTH_COMPONENT24;
- z24rb->_ActualFormat = GL_DEPTH_COMPONENT24;
+ z24rb->Format = MESA_FORMAT_Z24_S8;
z24rb->_BaseFormat = GL_DEPTH_COMPONENT;
z24rb->DataType = GL_UNSIGNED_INT;
- z24rb->DepthBits = 24;
z24rb->Data = NULL;
z24rb->Delete = delete_wrapper;
z24rb->AllocStorage = alloc_wrapper_storage;
@@ -310,14 +398,21 @@ get_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
GLubyte *dst = (GLubyte *) values;
const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
if (!src) {
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
src = temp;
}
- for (i = 0; i < count; i++) {
- dst[i] = src[i] & 0xff;
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ dst[i] = src[i] & 0xff;
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ dst[i] = src[i] >> 24;
+ }
}
}
@@ -329,13 +424,20 @@ get_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
GLuint temp[MAX_WIDTH], i;
GLubyte *dst = (GLubyte *) values;
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
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] & 0xff;
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ dst[i] = temp[i] & 0xff;
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ dst[i] = temp[i] >> 24;
+ }
}
}
@@ -347,14 +449,23 @@ put_row_s8(GLcontext *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->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
if (dst) {
/* direct access */
GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = (dst[i] & 0xffffff00) | src[i];
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = (dst[i] & 0xffffff00) | src[i];
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = (dst[i] & 0xffffff) | (src[i] << 24);
+ }
}
}
}
@@ -362,9 +473,19 @@ put_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
/* get, modify, put */
GLuint temp[MAX_WIDTH], i;
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (temp[i] & 0xffffff00) | src[i];
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (temp[i] & 0xffffff00) | src[i];
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (temp[i] & 0xffffff) | (src[i] << 24);
+ }
}
}
dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
@@ -379,14 +500,23 @@ put_mono_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
const GLubyte val = *((GLubyte *) value);
GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
if (dst) {
/* direct access */
GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = (dst[i] & 0xffffff00) | val;
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = (dst[i] & 0xffffff00) | val;
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = (dst[i] & 0xffffff) | (val << 24);
+ }
}
}
}
@@ -394,9 +524,19 @@ put_mono_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
/* get, modify, put */
GLuint temp[MAX_WIDTH], i;
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (temp[i] & 0xffffff00) | val;
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (temp[i] & 0xffffff00) | val;
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (temp[i] & 0xffffff) | (val << 24);
+ }
}
}
dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
@@ -411,15 +551,25 @@ put_values_s8(GLcontext *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->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
/* direct access */
GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
- *dst = (*dst & 0xffffff00) | src[i];
+ 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]);
+ *dst = (*dst & 0xffffff00) | src[i];
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+ *dst = (*dst & 0xffffff) | (src[i] << 24);
+ }
}
}
}
@@ -427,9 +577,19 @@ put_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
/* get, modify, put */
GLuint temp[MAX_WIDTH], i;
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (temp[i] & 0xffffff00) | src[i];
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (temp[i] & 0xffffff00) | src[i];
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (temp[i] & 0xffffff) | (src[i] << 24);
+ }
}
}
dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
@@ -446,9 +606,19 @@ put_mono_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count,
const GLubyte val = *((GLubyte *) value);
/* get, modify, put */
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (temp[i] & 0xffffff) | val;
+ if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (temp[i] & 0xffffff00) | val;
+ }
+ }
+ }
+ else {
+ assert(dsrb->Format == MESA_FORMAT_S8_Z24);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i] = (temp[i] & 0xffffff) | (val << 24);
+ }
}
}
dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
@@ -465,7 +635,8 @@ _mesa_new_s8_renderbuffer_wrapper(GLcontext *ctx, struct gl_renderbuffer *dsrb)
{
struct gl_renderbuffer *s8rb;
- ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 ||
+ dsrb->Format == MESA_FORMAT_S8_Z24);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
s8rb = _mesa_new_renderbuffer(ctx, 0);
@@ -478,10 +649,9 @@ _mesa_new_s8_renderbuffer_wrapper(GLcontext *ctx, struct gl_renderbuffer *dsrb)
s8rb->Width = dsrb->Width;
s8rb->Height = dsrb->Height;
s8rb->InternalFormat = GL_STENCIL_INDEX8_EXT;
- s8rb->_ActualFormat = GL_STENCIL_INDEX8_EXT;
+ s8rb->Format = MESA_FORMAT_S8;
s8rb->_BaseFormat = GL_STENCIL_INDEX;
s8rb->DataType = GL_UNSIGNED_BYTE;
- s8rb->StencilBits = 8;
s8rb->Data = NULL;
s8rb->Delete = delete_wrapper;
s8rb->AllocStorage = alloc_wrapper_storage;
@@ -528,10 +698,10 @@ _mesa_extract_stencil(GLcontext *ctx,
ASSERT(dsRb);
ASSERT(stencilRb);
- ASSERT(dsRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+ ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8);
ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- ASSERT(stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT ||
- stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT);
+ ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 ||
+ stencilRb->Format == MESA_FORMAT_S8);
ASSERT(dsRb->Width == stencilRb->Width);
ASSERT(dsRb->Height == stencilRb->Height);
@@ -541,7 +711,7 @@ _mesa_extract_stencil(GLcontext *ctx,
for (row = 0; row < height; row++) {
GLuint depthStencil[MAX_WIDTH];
dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil);
- if (stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
+ if (stencilRb->Format == MESA_FORMAT_S8) {
/* 8bpp stencil */
GLubyte stencil[MAX_WIDTH];
GLuint i;
@@ -553,7 +723,7 @@ _mesa_extract_stencil(GLcontext *ctx,
else {
/* 32bpp stencil */
/* the 24 depth bits will be ignored */
- ASSERT(stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+ ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8);
ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
stencilRb->PutRow(ctx, stencilRb, width, 0, row, depthStencil, NULL);
}
@@ -577,10 +747,10 @@ _mesa_insert_stencil(GLcontext *ctx,
ASSERT(dsRb);
ASSERT(stencilRb);
- ASSERT(dsRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+ ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8);
ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- ASSERT(stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT ||
- stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT);
+ ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 ||
+ stencilRb->Format == MESA_FORMAT_S8);
ASSERT(dsRb->Width == stencilRb->Width);
ASSERT(dsRb->Height == stencilRb->Height);
@@ -593,7 +763,7 @@ _mesa_insert_stencil(GLcontext *ctx,
dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil);
- if (stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
+ if (stencilRb->Format == MESA_FORMAT_S8) {
/* 8bpp stencil */
GLubyte stencil[MAX_WIDTH];
GLuint i;
@@ -605,7 +775,7 @@ _mesa_insert_stencil(GLcontext *ctx,
else {
/* 32bpp stencil buffer */
GLuint stencil[MAX_WIDTH], i;
- ASSERT(stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+ ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8);
ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT);
stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil);
for (i = 0; i < width; i++) {
@@ -631,7 +801,7 @@ _mesa_promote_stencil(GLcontext *ctx, struct gl_renderbuffer *stencilRb)
GLubyte *data;
GLint i, j, k;
- ASSERT(stencilRb->_ActualFormat == GL_STENCIL_INDEX8_EXT);
+ ASSERT(stencilRb->Format == MESA_FORMAT_S8);
ASSERT(stencilRb->Data);
data = (GLubyte *) stencilRb->Data;
@@ -650,6 +820,4 @@ _mesa_promote_stencil(GLcontext *ctx, struct gl_renderbuffer *stencilRb)
stencilRb->PutRow(ctx, stencilRb, width, 0, i, depthStencil, NULL);
}
_mesa_free(data);
-
- stencilRb->_BaseFormat = GL_DEPTH_STENCIL_EXT;
}
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 6610725de8..c2b7458f57 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -48,7 +48,7 @@
/** Set this to 1 to help debug FBO incompleteness problems */
-#define DEBUG_FBO 0
+#define DEBUG_FBO 1
/**
@@ -416,10 +416,9 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
}
else {
ASSERT(format == GL_STENCIL);
- ASSERT(att->Renderbuffer->StencilBits);
if (ctx->Extensions.EXT_packed_depth_stencil &&
ctx->Extensions.ARB_depth_texture &&
- att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
+ baseFormat == GL_DEPTH_STENCIL_EXT) {
/* OK */
}
else {
@@ -431,6 +430,9 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
}
}
else if (att->Type == GL_RENDERBUFFER_EXT) {
+ const GLenum baseFormat =
+ _mesa_get_format_base_format(att->Renderbuffer->Format);
+
ASSERT(att->Renderbuffer);
if (!att->Renderbuffer->InternalFormat ||
att->Renderbuffer->Width < 1 ||
@@ -440,24 +442,19 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
return;
}
if (format == GL_COLOR) {
- if (att->Renderbuffer->_BaseFormat != GL_RGB &&
- att->Renderbuffer->_BaseFormat != GL_RGBA) {
+ if (baseFormat != GL_RGB &&
+ baseFormat != GL_RGBA) {
att_incomplete("bad renderbuffer color format");
att->Complete = GL_FALSE;
return;
}
- ASSERT(att->Renderbuffer->RedBits);
- ASSERT(att->Renderbuffer->GreenBits);
- ASSERT(att->Renderbuffer->BlueBits);
}
else if (format == GL_DEPTH) {
- if (att->Renderbuffer->_BaseFormat == GL_DEPTH_COMPONENT) {
- ASSERT(att->Renderbuffer->DepthBits);
+ if (baseFormat == GL_DEPTH_COMPONENT) {
/* OK */
}
else if (ctx->Extensions.EXT_packed_depth_stencil &&
- att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
- ASSERT(att->Renderbuffer->DepthBits);
+ baseFormat == GL_DEPTH_STENCIL_EXT) {
/* OK */
}
else {
@@ -468,13 +465,11 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
}
else {
assert(format == GL_STENCIL);
- if (att->Renderbuffer->_BaseFormat == GL_STENCIL_INDEX) {
- ASSERT(att->Renderbuffer->StencilBits);
+ if (baseFormat == GL_STENCIL_INDEX) {
/* OK */
}
else if (ctx->Extensions.EXT_packed_depth_stencil &&
- att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
- ASSERT(att->Renderbuffer->StencilBits);
+ baseFormat == GL_DEPTH_STENCIL_EXT) {
/* OK */
}
else {
@@ -980,42 +975,27 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,
}
/* These MUST get set by the AllocStorage func */
- rb->_ActualFormat = 0;
- rb->RedBits =
- rb->GreenBits =
- rb->BlueBits =
- rb->AlphaBits =
- rb->IndexBits =
- rb->DepthBits =
- rb->StencilBits = 0;
+ rb->Format = MESA_FORMAT_NONE;
rb->NumSamples = samples;
/* Now allocate the storage */
ASSERT(rb->AllocStorage);
if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
/* No error - check/set fields now */
- assert(rb->_ActualFormat);
+ assert(rb->Format != MESA_FORMAT_NONE);
assert(rb->Width == (GLuint) width);
assert(rb->Height == (GLuint) height);
- assert(rb->RedBits || rb->GreenBits || rb->BlueBits || rb->AlphaBits ||
- rb->DepthBits || rb->StencilBits || rb->IndexBits);
rb->InternalFormat = internalFormat;
- rb->_BaseFormat = baseFormat;
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+ assert(rb->_BaseFormat != 0);
}
else {
/* Probably ran out of memory - clear the fields */
rb->Width = 0;
rb->Height = 0;
+ rb->Format = MESA_FORMAT_NONE;
rb->InternalFormat = GL_NONE;
- rb->_ActualFormat = GL_NONE;
rb->_BaseFormat = GL_NONE;
- rb->RedBits =
- rb->GreenBits =
- rb->BlueBits =
- rb->AlphaBits =
- rb->IndexBits =
- rb->DepthBits =
- rb->StencilBits =
rb->NumSamples = 0;
}
@@ -1028,6 +1008,53 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,
}
+/**
+ * Helper function for _mesa_GetRenderbufferParameterivEXT() and
+ * _mesa_GetFramebufferAttachmentParameterivEXT()
+ * We have to be careful to respect the base format. For example, if a
+ * renderbuffer/texture was created with internalFormat=GL_RGB but the
+ * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE
+ * we need to return zero.
+ */
+static GLint
+get_component_bits(GLenum pname, GLenum baseFormat, gl_format format)
+{
+ switch (pname) {
+ case GL_RENDERBUFFER_RED_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+ case GL_RENDERBUFFER_GREEN_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+ case GL_RENDERBUFFER_BLUE_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+ if (baseFormat == GL_RGB || baseFormat == GL_RGBA)
+ return _mesa_get_format_bits(format, pname);
+ else
+ return 0;
+ case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+ if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA)
+ return _mesa_get_format_bits(format, pname);
+ else
+ return 0;
+ case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+ if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL)
+ return _mesa_get_format_bits(format, pname);
+ else
+ return 0;
+ case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+ if (baseFormat == GL_STENCIL_INDEX || baseFormat == GL_DEPTH_STENCIL)
+ return _mesa_get_format_bits(format, pname);
+ else
+ return 0;
+ default:
+ return 0;
+ }
+}
+
+
+
void GLAPIENTRY
_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height)
@@ -1084,22 +1111,12 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
*params = rb->InternalFormat;
return;
case GL_RENDERBUFFER_RED_SIZE_EXT:
- *params = rb->RedBits;
- break;
case GL_RENDERBUFFER_GREEN_SIZE_EXT:
- *params = rb->GreenBits;
- break;
case GL_RENDERBUFFER_BLUE_SIZE_EXT:
- *params = rb->BlueBits;
- break;
case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
- *params = rb->AlphaBits;
- break;
case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
- *params = rb->DepthBits;
- break;
case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
- *params = rb->StencilBits;
+ *params = get_component_bits(pname, rb->_BaseFormat, rb->Format);
break;
case GL_RENDERBUFFER_SAMPLES:
if (ctx->Extensions.ARB_framebuffer_object) {
@@ -1706,7 +1723,9 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
/* make sure the renderbuffer is a depth/stencil format */
- if (rb->_BaseFormat != GL_DEPTH_STENCIL) {
+ const GLenum baseFormat =
+ _mesa_get_format_base_format(att->Renderbuffer->Format);
+ if (baseFormat != GL_DEPTH_STENCIL) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glFramebufferRenderbufferEXT(renderbuffer"
" is not DEPTH_STENCIL format)");
@@ -1862,7 +1881,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
"glGetFramebufferAttachmentParameterivEXT(pname)");
}
else {
- *params = att->Renderbuffer->ColorEncoding;
+ *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format);
}
return;
case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
@@ -1872,61 +1891,44 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
return;
}
else {
- *params = att->Renderbuffer->ComponentType;
+ gl_format format = att->Renderbuffer->Format;
+ if (format == MESA_FORMAT_CI8 || format == MESA_FORMAT_S8) {
+ /* special cases */
+ *params = GL_INDEX;
+ }
+ else {
+ *params = _mesa_get_format_datatype(format);
+ }
}
return;
case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
- if (!ctx->Extensions.ARB_framebuffer_object) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameterivEXT(pname)");
- }
- else {
- *params = att->Renderbuffer->RedBits;
- }
- return;
case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
- if (!ctx->Extensions.ARB_framebuffer_object) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameterivEXT(pname)");
- }
- else {
- *params = att->Renderbuffer->GreenBits;
- }
- return;
case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
- if (!ctx->Extensions.ARB_framebuffer_object) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameterivEXT(pname)");
- }
- else {
- *params = att->Renderbuffer->BlueBits;
- }
- return;
case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
- if (!ctx->Extensions.ARB_framebuffer_object) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameterivEXT(pname)");
- }
- else {
- *params = att->Renderbuffer->AlphaBits;
- }
- return;
case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+ case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
if (!ctx->Extensions.ARB_framebuffer_object) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetFramebufferAttachmentParameterivEXT(pname)");
}
- else {
- *params = att->Renderbuffer->DepthBits;
+ else if (att->Texture) {
+ const struct gl_texture_image *texImage =
+ _mesa_select_tex_image(ctx, att->Texture, att->Texture->Target,
+ att->TextureLevel);
+ if (texImage) {
+ *params = get_component_bits(pname, texImage->_BaseFormat,
+ texImage->TexFormat);
+ }
+ else {
+ *params = 0;
+ }
}
- return;
- case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
- if (!ctx->Extensions.ARB_framebuffer_object) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameterivEXT(pname)");
+ else if (att->Renderbuffer) {
+ *params = get_component_bits(pname, att->Renderbuffer->_BaseFormat,
+ att->Renderbuffer->Format);
}
else {
- *params = att->Renderbuffer->StencilBits;
+ *params = 0;
}
return;
default:
@@ -2053,7 +2055,8 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
struct gl_renderbuffer *drawRb = drawFb->_StencilBuffer;
if (!readRb ||
!drawRb ||
- readRb->StencilBits != drawRb->StencilBits) {
+ _mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) !=
+ _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBlitFramebufferEXT(stencil buffer size mismatch");
return;
@@ -2065,7 +2068,8 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
struct gl_renderbuffer *drawRb = drawFb->_DepthBuffer;
if (!readRb ||
!drawRb ||
- readRb->DepthBits != drawRb->DepthBits) {
+ _mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) !=
+ _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBlitFramebufferEXT(depth buffer size mismatch");
return;
@@ -2093,7 +2097,7 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
/* color formats must match */
if (colorReadRb &&
colorDrawRb &&
- colorReadRb->_ActualFormat != colorDrawRb->_ActualFormat) {
+ colorReadRb->Format != colorDrawRb->Format) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBlitFramebufferEXT(bad src/dst multisample pixel formats");
return;
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index dc79b8ca61..154dedacd5 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -35,6 +35,7 @@
#include "buffers.h"
#include "context.h"
#include "depthstencil.h"
+#include "formats.h"
#include "macros.h"
#include "mtypes.h"
#include "fbobject.h"
@@ -281,7 +282,6 @@ _mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb,
struct gl_renderbuffer *rb = att->Renderbuffer;
/* only resize if size is changing */
if (rb->Width != width || rb->Height != height) {
- /* could just as well pass rb->_ActualFormat here */
if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) {
ASSERT(rb->Width == width);
ASSERT(rb->Height == height);
@@ -523,19 +523,22 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
for (i = 0; i < BUFFER_COUNT; i++) {
if (fb->Attachment[i].Renderbuffer) {
const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
- if (rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB) {
- fb->Visual.redBits = rb->RedBits;
- fb->Visual.greenBits = rb->GreenBits;
- fb->Visual.blueBits = rb->BlueBits;
- fb->Visual.alphaBits = rb->AlphaBits;
+ const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
+ const gl_format fmt = rb->Format;
+
+ if (baseFormat == GL_RGBA || baseFormat == GL_RGB) {
+ fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS);
+ fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS);
+ fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS);
+ fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS);
fb->Visual.rgbBits = fb->Visual.redBits
+ fb->Visual.greenBits + fb->Visual.blueBits;
fb->Visual.floatMode = GL_FALSE;
fb->Visual.samples = rb->NumSamples;
break;
}
- else if (rb->_BaseFormat == GL_COLOR_INDEX) {
- fb->Visual.indexBits = rb->IndexBits;
+ else if (baseFormat == GL_COLOR_INDEX) {
+ fb->Visual.indexBits = _mesa_get_format_bits(fmt, GL_INDEX_BITS);
fb->Visual.rgbMode = GL_FALSE;
break;
}
@@ -543,27 +546,30 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
}
if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
+ const struct gl_renderbuffer *rb =
+ fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ const gl_format fmt = rb->Format;
fb->Visual.haveDepthBuffer = GL_TRUE;
- fb->Visual.depthBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->DepthBits;
+ fb->Visual.depthBits = _mesa_get_format_bits(fmt, GL_DEPTH_BITS);
}
if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) {
+ const struct gl_renderbuffer *rb =
+ fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ const gl_format fmt = rb->Format;
fb->Visual.haveStencilBuffer = GL_TRUE;
- fb->Visual.stencilBits
- = fb->Attachment[BUFFER_STENCIL].Renderbuffer->StencilBits;
+ fb->Visual.stencilBits = _mesa_get_format_bits(fmt, GL_STENCIL_BITS);
}
if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) {
+ const struct gl_renderbuffer *rb =
+ fb->Attachment[BUFFER_ACCUM].Renderbuffer;
+ const gl_format fmt = rb->Format;
fb->Visual.haveAccumBuffer = GL_TRUE;
- fb->Visual.accumRedBits
- = fb->Attachment[BUFFER_ACCUM].Renderbuffer->RedBits;
- fb->Visual.accumGreenBits
- = fb->Attachment[BUFFER_ACCUM].Renderbuffer->GreenBits;
- fb->Visual.accumBlueBits
- = fb->Attachment[BUFFER_ACCUM].Renderbuffer->BlueBits;
- fb->Visual.accumAlphaBits
- = fb->Attachment[BUFFER_ACCUM].Renderbuffer->AlphaBits;
+ fb->Visual.accumRedBits = _mesa_get_format_bits(fmt, GL_RED_BITS);
+ fb->Visual.accumGreenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS);
+ fb->Visual.accumBlueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS);
+ fb->Visual.accumAlphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS);
}
compute_depth_max(fb);
@@ -592,11 +598,11 @@ _mesa_update_depth_buffer(GLcontext *ctx,
depthRb = fb->Attachment[attIndex].Renderbuffer;
- if (depthRb && depthRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+ if (depthRb && depthRb->_BaseFormat == GL_DEPTH_STENCIL) {
/* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
if (!fb->_DepthBuffer
|| fb->_DepthBuffer->Wrapped != depthRb
- || fb->_DepthBuffer->_BaseFormat != GL_DEPTH_COMPONENT) {
+ || _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);
@@ -633,11 +639,11 @@ _mesa_update_stencil_buffer(GLcontext *ctx,
stencilRb = fb->Attachment[attIndex].Renderbuffer;
- if (stencilRb && stencilRb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+ if (stencilRb && stencilRb->_BaseFormat == GL_DEPTH_STENCIL) {
/* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */
if (!fb->_StencilBuffer
|| fb->_StencilBuffer->Wrapped != stencilRb
- || fb->_StencilBuffer->_BaseFormat != GL_STENCIL_INDEX) {
+ || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) {
/* need to update wrapper */
struct gl_renderbuffer *wrapper
= _mesa_new_s8_renderbuffer_wrapper(ctx, stencilRb);
@@ -854,30 +860,32 @@ _mesa_source_buffer_exists(GLcontext *ctx, GLenum format)
if (ctx->ReadBuffer->_ColorReadBuffer == NULL) {
return GL_FALSE;
}
- ASSERT(ctx->ReadBuffer->_ColorReadBuffer->RedBits > 0 ||
- ctx->ReadBuffer->_ColorReadBuffer->IndexBits > 0);
+ ASSERT(_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_RED_BITS) > 0 ||
+ _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_INDEX_BITS) > 0);
break;
case GL_DEPTH:
case GL_DEPTH_COMPONENT:
if (!att[BUFFER_DEPTH].Renderbuffer) {
return GL_FALSE;
}
- ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);
+ /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/
break;
case GL_STENCIL:
case GL_STENCIL_INDEX:
if (!att[BUFFER_STENCIL].Renderbuffer) {
return GL_FALSE;
}
- ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);
+ /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/
break;
case GL_DEPTH_STENCIL_EXT:
if (!att[BUFFER_DEPTH].Renderbuffer ||
!att[BUFFER_STENCIL].Renderbuffer) {
return GL_FALSE;
}
+ /*
ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);
ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);
+ */
break;
default:
_mesa_problem(ctx,
@@ -932,22 +940,24 @@ _mesa_dest_buffer_exists(GLcontext *ctx, GLenum format)
if (!att[BUFFER_DEPTH].Renderbuffer) {
return GL_FALSE;
}
- ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);
+ /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/
break;
case GL_STENCIL:
case GL_STENCIL_INDEX:
if (!att[BUFFER_STENCIL].Renderbuffer) {
return GL_FALSE;
}
- ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);
+ /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/
break;
case GL_DEPTH_STENCIL_EXT:
if (!att[BUFFER_DEPTH].Renderbuffer ||
!att[BUFFER_STENCIL].Renderbuffer) {
return GL_FALSE;
}
+ /*
ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);
ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);
+ */
break;
default:
_mesa_problem(ctx,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8e6e0d09be..5bbb12ea70 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2089,19 +2089,9 @@ struct gl_renderbuffer
GLint RefCount;
GLuint Width, Height;
GLenum InternalFormat; /**< The user-specified format */
- GLenum _ActualFormat; /**< The driver-chosen format */
GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
GL_STENCIL_INDEX. */
- GLenum ColorEncoding; /**< GL_LINEAR or GL_SRGB */
- GLenum ComponentType; /**< GL_FLOAT, GL_INT, GL_UNSIGNED_INT,
- GL_UNSIGNED_NORMALIZED or GL_INDEX */
- GLubyte RedBits; /**< Bits of red per pixel */
- GLubyte GreenBits;
- GLubyte BlueBits;
- GLubyte AlphaBits;
- GLubyte IndexBits;
- GLubyte DepthBits;
- GLubyte StencilBits;
+ GLuint Format; /**< The actual format: MESA_FORMAT_x */
GLubyte NumSamples;
GLenum DataType; /**< Type of values passed to the Get/Put functions */
diff --git a/src/mesa/main/rbadaptors.c b/src/mesa/main/rbadaptors.c
index c1ac0606c8..1060c5796e 100644
--- a/src/mesa/main/rbadaptors.c
+++ b/src/mesa/main/rbadaptors.c
@@ -218,14 +218,10 @@ _mesa_new_renderbuffer_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb8)
_glthread_UNLOCK_MUTEX(rb8->Mutex);
rb16->InternalFormat = rb8->InternalFormat;
- rb16->_ActualFormat = rb8->_ActualFormat;
+ rb16->Format = rb8->Format; /* XXX is this right? */
rb16->_BaseFormat = rb8->_BaseFormat;
rb16->DataType = GL_UNSIGNED_SHORT;
/* Note: passing through underlying bits/channel */
- rb16->RedBits = rb8->RedBits;
- rb16->GreenBits = rb8->GreenBits;
- rb16->BlueBits = rb8->BlueBits;
- rb16->AlphaBits = rb8->AlphaBits;
rb16->Wrapped = rb8;
rb16->AllocStorage = AllocStorage_wrapper;
@@ -385,14 +381,10 @@ _mesa_new_renderbuffer_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb8)
_glthread_UNLOCK_MUTEX(rb8->Mutex);
rb32->InternalFormat = rb8->InternalFormat;
- rb32->_ActualFormat = rb8->_ActualFormat;
+ rb32->Format = rb8->Format; /* XXX is this right? */
rb32->_BaseFormat = rb8->_BaseFormat;
rb32->DataType = GL_FLOAT;
/* Note: passing through underlying bits/channel */
- rb32->RedBits = rb8->RedBits;
- rb32->GreenBits = rb8->GreenBits;
- rb32->BlueBits = rb8->BlueBits;
- rb32->AlphaBits = rb8->AlphaBits;
rb32->Wrapped = rb8;
rb32->AllocStorage = AllocStorage_wrapper;
@@ -552,14 +544,10 @@ _mesa_new_renderbuffer_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb16)
_glthread_UNLOCK_MUTEX(rb16->Mutex);
rb32->InternalFormat = rb16->InternalFormat;
- rb32->_ActualFormat = rb16->_ActualFormat;
+ rb32->Format = rb16->Format; /* XXX is this right? */
rb32->_BaseFormat = rb16->_BaseFormat;
rb32->DataType = GL_FLOAT;
/* Note: passing through underlying bits/channel */
- rb32->RedBits = rb16->RedBits;
- rb32->GreenBits = rb16->GreenBits;
- rb32->BlueBits = rb16->BlueBits;
- rb32->AlphaBits = rb16->AlphaBits;
rb32->Wrapped = rb16;
rb32->AllocStorage = AllocStorage_wrapper;
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index 38be8266e0..409fd8634a 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -43,6 +43,8 @@
#include "glheader.h"
#include "imports.h"
#include "context.h"
+#include "fbobject.h"
+#include "formats.h"
#include "mtypes.h"
#include "fbobject.h"
#include "renderbuffer.h"
@@ -72,7 +74,7 @@ get_pointer_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb,
if (!rb->Data)
return NULL;
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- /* Can't assert _ActualFormat since these funcs may be used for serveral
+ /* Can't assert rb->Format since these funcs may be used for serveral
* different formats (GL_ALPHA8, GL_STENCIL_INDEX8, etc).
*/
return (GLubyte *) rb->Data + y * rb->Width + x;
@@ -448,7 +450,7 @@ static void *
get_pointer_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb,
GLint x, GLint y)
{
- ASSERT(rb->_ActualFormat == GL_RGB8);
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
/* No direct access since this buffer is RGB but caller will be
* treating it as if it were RGBA.
*/
@@ -463,7 +465,7 @@ get_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLubyte *src = (const GLubyte *) rb->Data + 3 * (y * rb->Width + x);
GLubyte *dst = (GLubyte *) values;
GLuint i;
- ASSERT(rb->_ActualFormat == GL_RGB8);
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
for (i = 0; i < count; i++) {
dst[i * 4 + 0] = src[i * 3 + 0];
@@ -480,7 +482,7 @@ get_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
{
GLubyte *dst = (GLubyte *) values;
GLuint i;
- ASSERT(rb->_ActualFormat == GL_RGB8);
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
for (i = 0; i < count; i++) {
const GLubyte *src
@@ -501,7 +503,7 @@ put_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLubyte *src = (const GLubyte *) values;
GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
GLuint i;
- ASSERT(rb->_ActualFormat == GL_RGB8);
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
@@ -521,7 +523,7 @@ put_row_rgb_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLubyte *src = (const GLubyte *) values;
GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
GLuint i;
- ASSERT(rb->_ActualFormat == GL_RGB8);
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
@@ -542,7 +544,7 @@ put_mono_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLubyte val1 = ((const GLubyte *) value)[1];
const GLubyte val2 = ((const GLubyte *) value)[2];
GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
- ASSERT(rb->_ActualFormat == GL_RGB8);
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
if (!mask && val0 == val1 && val1 == val2) {
/* optimized case */
@@ -569,7 +571,7 @@ put_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
/* note: incoming values are RGB+A! */
const GLubyte *src = (const GLubyte *) values;
GLuint i;
- ASSERT(rb->_ActualFormat == GL_RGB8);
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
@@ -592,7 +594,7 @@ put_mono_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb,
const GLubyte val1 = ((const GLubyte *) value)[1];
const GLubyte val2 = ((const GLubyte *) value)[2];
GLuint i;
- ASSERT(rb->_ActualFormat == GL_RGB8);
+ ASSERT(rb->Format == MESA_FORMAT_RGB888);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
@@ -617,7 +619,7 @@ get_pointer_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb,
if (!rb->Data)
return NULL;
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->_ActualFormat == GL_RGBA8);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
return (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
}
@@ -628,7 +630,7 @@ get_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
{
const GLubyte *src = (const GLubyte *) rb->Data + 4 * (y * rb->Width + x);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->_ActualFormat == GL_RGBA8);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
_mesa_memcpy(values, src, 4 * count * sizeof(GLubyte));
}
@@ -641,7 +643,7 @@ get_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
GLuint *dst = (GLuint *) values;
GLuint i;
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->_ActualFormat == GL_RGBA8);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
for (i = 0; i < count; i++) {
const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
dst[i] = *src;
@@ -657,7 +659,7 @@ put_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLuint *src = (const GLuint *) values;
GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->_ActualFormat == GL_RGBA8);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
if (mask) {
GLuint i;
for (i = 0; i < count; i++) {
@@ -681,7 +683,7 @@ put_row_rgb_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
GLuint i;
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->_ActualFormat == GL_RGBA8);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
dst[i * 4 + 0] = src[i * 3 + 0];
@@ -701,7 +703,7 @@ put_mono_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLuint val = *((const GLuint *) value);
GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->_ActualFormat == GL_RGBA8);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
if (!mask && val == 0) {
/* common case */
_mesa_bzero(dst, count * 4 * sizeof(GLubyte));
@@ -735,7 +737,7 @@ put_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLuint *src = (const GLuint *) values;
GLuint i;
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->_ActualFormat == GL_RGBA8);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
@@ -754,7 +756,7 @@ put_mono_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb,
const GLuint val = *((const GLuint *) value);
GLuint i;
ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->_ActualFormat == GL_RGBA8);
+ ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
@@ -947,15 +949,6 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
{
GLuint pixelSize;
- /* first clear these fields */
- rb->RedBits =
- rb->GreenBits =
- rb->BlueBits =
- rb->AlphaBits =
- rb->IndexBits =
- rb->DepthBits =
- rb->StencilBits = 0;
-
switch (internalFormat) {
case GL_RGB:
case GL_R3_G3_B2:
@@ -965,8 +958,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- rb->_ActualFormat = GL_RGB8;
- rb->_BaseFormat = GL_RGB;
+ rb->Format = MESA_FORMAT_RGB888;
rb->DataType = GL_UNSIGNED_BYTE;
rb->GetPointer = get_pointer_ubyte3;
rb->GetRow = get_row_ubyte3;
@@ -976,10 +968,6 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ubyte3;
rb->PutValues = put_values_ubyte3;
rb->PutMonoValues = put_mono_values_ubyte3;
- rb->RedBits = 8 * sizeof(GLubyte);
- rb->GreenBits = 8 * sizeof(GLubyte);
- rb->BlueBits = 8 * sizeof(GLubyte);
- rb->AlphaBits = 0;
pixelSize = 3 * sizeof(GLubyte);
break;
case GL_RGBA:
@@ -987,8 +975,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
case GL_RGBA4:
case GL_RGB5_A1:
case GL_RGBA8:
- rb->_ActualFormat = GL_RGBA8;
- rb->_BaseFormat = GL_RGBA;
+#if 1
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+#endif
+ rb->Format = MESA_FORMAT_RGBA8888;
rb->DataType = GL_UNSIGNED_BYTE;
rb->GetPointer = get_pointer_ubyte4;
rb->GetRow = get_row_ubyte4;
@@ -998,18 +989,12 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ubyte4;
rb->PutValues = put_values_ubyte4;
rb->PutMonoValues = put_mono_values_ubyte4;
- rb->RedBits = 8 * sizeof(GLubyte);
- rb->GreenBits = 8 * sizeof(GLubyte);
- rb->BlueBits = 8 * sizeof(GLubyte);
- rb->AlphaBits = 8 * sizeof(GLubyte);
pixelSize = 4 * sizeof(GLubyte);
break;
- case GL_RGB10_A2:
- case GL_RGBA12:
case GL_RGBA16:
- rb->_ActualFormat = GL_RGBA16;
- rb->_BaseFormat = GL_RGBA;
- rb->DataType = GL_UNSIGNED_SHORT;
+ /* for accum buffer */
+ rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
+ rb->DataType = GL_SHORT;
rb->GetPointer = get_pointer_ushort4;
rb->GetRow = get_row_ushort4;
rb->GetValues = get_values_ushort4;
@@ -1018,16 +1003,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ushort4;
rb->PutValues = put_values_ushort4;
rb->PutMonoValues = put_mono_values_ushort4;
- rb->RedBits = 8 * sizeof(GLushort);
- rb->GreenBits = 8 * sizeof(GLushort);
- rb->BlueBits = 8 * sizeof(GLushort);
- rb->AlphaBits = 8 * sizeof(GLushort);
pixelSize = 4 * sizeof(GLushort);
break;
-#if 00
+#if 0
case GL_ALPHA8:
- rb->_ActualFormat = GL_ALPHA8;
- rb->_BaseFormat = GL_RGBA; /* Yes, not GL_ALPHA! */
+ rb->Format = MESA_FORMAT_A8;
rb->DataType = GL_UNSIGNED_BYTE;
rb->GetPointer = get_pointer_alpha8;
rb->GetRow = get_row_alpha8;
@@ -1037,10 +1017,6 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_alpha8;
rb->PutValues = put_values_alpha8;
rb->PutMonoValues = put_mono_values_alpha8;
- rb->RedBits = 0; /*red*/
- rb->GreenBits = 0; /*green*/
- rb->BlueBits = 0; /*blue*/
- rb->AlphaBits = 8 * sizeof(GLubyte);
pixelSize = sizeof(GLubyte);
break;
#endif
@@ -1048,8 +1024,8 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
case GL_STENCIL_INDEX1_EXT:
case GL_STENCIL_INDEX4_EXT:
case GL_STENCIL_INDEX8_EXT:
- rb->_ActualFormat = GL_STENCIL_INDEX8_EXT;
- rb->_BaseFormat = GL_STENCIL_INDEX;
+ case GL_STENCIL_INDEX16_EXT:
+ rb->Format = MESA_FORMAT_S8;
rb->DataType = GL_UNSIGNED_BYTE;
rb->GetPointer = get_pointer_ubyte;
rb->GetRow = get_row_ubyte;
@@ -1059,28 +1035,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ubyte;
rb->PutValues = put_values_ubyte;
rb->PutMonoValues = put_mono_values_ubyte;
- rb->StencilBits = 8 * sizeof(GLubyte);
pixelSize = sizeof(GLubyte);
break;
- case GL_STENCIL_INDEX16_EXT:
- rb->_ActualFormat = GL_STENCIL_INDEX16_EXT;
- rb->_BaseFormat = GL_STENCIL_INDEX;
- rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetPointer = get_pointer_ushort;
- rb->GetRow = get_row_ushort;
- rb->GetValues = get_values_ushort;
- rb->PutRow = put_row_ushort;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_ushort;
- rb->PutValues = put_values_ushort;
- rb->PutMonoValues = put_mono_values_ushort;
- rb->StencilBits = 8 * sizeof(GLushort);
- pixelSize = sizeof(GLushort);
- break;
case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT16:
- rb->_ActualFormat = GL_DEPTH_COMPONENT16;
- rb->_BaseFormat = GL_DEPTH_COMPONENT;
+ rb->Format = MESA_FORMAT_Z16;
rb->DataType = GL_UNSIGNED_SHORT;
rb->GetPointer = get_pointer_ushort;
rb->GetRow = get_row_ushort;
@@ -1090,12 +1049,10 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ushort;
rb->PutValues = put_values_ushort;
rb->PutMonoValues = put_mono_values_ushort;
- rb->DepthBits = 8 * sizeof(GLushort);
pixelSize = sizeof(GLushort);
break;
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
- rb->_BaseFormat = GL_DEPTH_COMPONENT;
rb->DataType = GL_UNSIGNED_INT;
rb->GetPointer = get_pointer_uint;
rb->GetRow = get_row_uint;
@@ -1105,20 +1062,12 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_uint;
rb->PutValues = put_values_uint;
rb->PutMonoValues = put_mono_values_uint;
- if (internalFormat == GL_DEPTH_COMPONENT24) {
- rb->_ActualFormat = GL_DEPTH_COMPONENT24;
- rb->DepthBits = 24;
- }
- else {
- rb->_ActualFormat = GL_DEPTH_COMPONENT32;
- rb->DepthBits = 32;
- }
+ rb->Format = MESA_FORMAT_Z32;
pixelSize = sizeof(GLuint);
break;
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
- rb->_BaseFormat = GL_DEPTH_STENCIL_EXT;
+ rb->Format = MESA_FORMAT_Z24_S8;
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
rb->GetPointer = get_pointer_uint;
rb->GetRow = get_row_uint;
@@ -1128,13 +1077,12 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_uint;
rb->PutValues = put_values_uint;
rb->PutMonoValues = put_mono_values_uint;
- rb->DepthBits = 24;
- rb->StencilBits = 8;
pixelSize = sizeof(GLuint);
break;
case GL_COLOR_INDEX8_EXT:
- rb->_ActualFormat = GL_COLOR_INDEX8_EXT;
- rb->_BaseFormat = GL_COLOR_INDEX;
+ case GL_COLOR_INDEX16_EXT:
+ case COLOR_INDEX32:
+ rb->Format = MESA_FORMAT_CI8;
rb->DataType = GL_UNSIGNED_BYTE;
rb->GetPointer = get_pointer_ubyte;
rb->GetRow = get_row_ubyte;
@@ -1144,39 +1092,8 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ubyte;
rb->PutValues = put_values_ubyte;
rb->PutMonoValues = put_mono_values_ubyte;
- rb->IndexBits = 8 * sizeof(GLubyte);
pixelSize = sizeof(GLubyte);
break;
- case GL_COLOR_INDEX16_EXT:
- rb->_ActualFormat = GL_COLOR_INDEX16_EXT;
- rb->_BaseFormat = GL_COLOR_INDEX;
- rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetPointer = get_pointer_ushort;
- rb->GetRow = get_row_ushort;
- rb->GetValues = get_values_ushort;
- rb->PutRow = put_row_ushort;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_ushort;
- rb->PutValues = put_values_ushort;
- rb->PutMonoValues = put_mono_values_ushort;
- rb->IndexBits = 8 * sizeof(GLushort);
- pixelSize = sizeof(GLushort);
- break;
- case COLOR_INDEX32:
- rb->_ActualFormat = COLOR_INDEX32;
- rb->_BaseFormat = GL_COLOR_INDEX;
- rb->DataType = GL_UNSIGNED_INT;
- rb->GetPointer = get_pointer_uint;
- rb->GetRow = get_row_uint;
- rb->GetValues = get_values_uint;
- rb->PutRow = put_row_uint;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_uint;
- rb->PutValues = put_values_uint;
- rb->PutMonoValues = put_mono_values_uint;
- rb->IndexBits = 8 * sizeof(GLuint);
- pixelSize = sizeof(GLuint);
- break;
default:
_mesa_problem(ctx, "Bad internalFormat in _mesa_soft_renderbuffer_storage");
return GL_FALSE;
@@ -1213,6 +1130,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->Width = width;
rb->Height = height;
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, rb->InternalFormat);
return GL_TRUE;
}
@@ -1239,7 +1157,7 @@ alloc_storage_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb,
GLenum internalFormat, GLuint width, GLuint height)
{
ASSERT(arb != arb->Wrapped);
- ASSERT(arb->_ActualFormat == GL_ALPHA8);
+ ASSERT(arb->Format == MESA_FORMAT_A8);
/* first, pass the call to the wrapped RGB buffer */
if (!arb->Wrapped->AllocStorage(ctx, arb->Wrapped, internalFormat,
@@ -1439,8 +1357,8 @@ put_mono_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb,
static void
copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src)
{
- ASSERT(dst->_ActualFormat == GL_ALPHA8);
- ASSERT(src->_ActualFormat == GL_ALPHA8);
+ ASSERT(dst->Format == MESA_FORMAT_A8);
+ ASSERT(src->Format == MESA_FORMAT_A8);
ASSERT(dst->Width == src->Width);
ASSERT(dst->Height == src->Height);
@@ -1486,16 +1404,7 @@ _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
rb->Width = 0;
rb->Height = 0;
rb->InternalFormat = GL_NONE;
- rb->_ActualFormat = GL_NONE;
- rb->_BaseFormat = GL_NONE;
-
- rb->ComponentType = GL_UNSIGNED_NORMALIZED; /* ARB_fbo */
- rb->ColorEncoding = GL_LINEAR; /* ARB_fbo */
-
- rb->RedBits = rb->GreenBits = rb->BlueBits = rb->AlphaBits = 0;
- rb->IndexBits = 0;
- rb->DepthBits = 0;
- rb->StencilBits = 0;
+ rb->Format = MESA_FORMAT_NONE;
rb->DataType = GL_NONE;
rb->Data = NULL;
@@ -1612,18 +1521,15 @@ _mesa_add_color_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
if (rgbBits <= 8) {
if (alphaBits)
- rb->_ActualFormat = GL_RGBA8;
+ rb->Format = MESA_FORMAT_RGBA8888;
else
- rb->_ActualFormat = GL_RGB8;
+ rb->Format = MESA_FORMAT_RGB888;
}
else {
assert(rgbBits <= 16);
- if (alphaBits)
- rb->_ActualFormat = GL_RGBA16;
- else
- rb->_ActualFormat = GL_RGBA16; /* don't really have RGB16 yet */
+ rb->Format = MESA_FORMAT_NONE; /*XXX RGBA16;*/
}
- rb->InternalFormat = rb->_ActualFormat;
+ rb->InternalFormat = GL_RGBA;
rb->AllocStorage = _mesa_soft_renderbuffer_storage;
_mesa_add_renderbuffer(fb, b, rb);
@@ -1677,15 +1583,9 @@ _mesa_add_color_index_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
return GL_FALSE;
}
- if (indexBits <= 8) {
- /* only support GLuint for now */
- /*rb->InternalFormat = GL_COLOR_INDEX8_EXT;*/
- rb->_ActualFormat = COLOR_INDEX32;
- }
- else {
- rb->_ActualFormat = COLOR_INDEX32;
- }
- rb->InternalFormat = rb->_ActualFormat;
+ assert(indexBits <= 8);
+ rb->Format = MESA_FORMAT_CI8;
+ rb->InternalFormat = GL_COLOR_INDEX;
rb->AllocStorage = _mesa_soft_renderbuffer_storage;
_mesa_add_renderbuffer(fb, b, rb);
@@ -1758,8 +1658,7 @@ _mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
* values.
*/
arb->InternalFormat = arb->Wrapped->InternalFormat;
- arb->_ActualFormat = GL_ALPHA8;
- arb->_BaseFormat = arb->Wrapped->_BaseFormat;
+ arb->Format = MESA_FORMAT_A8;
arb->DataType = arb->Wrapped->DataType;
arb->AllocStorage = alloc_storage_alpha8;
arb->Delete = delete_renderbuffer_alpha8;
@@ -1833,15 +1732,13 @@ _mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
}
if (depthBits <= 16) {
- rb->_ActualFormat = GL_DEPTH_COMPONENT16;
- }
- else if (depthBits <= 24) {
- rb->_ActualFormat = GL_DEPTH_COMPONENT24;
+ rb->Format = MESA_FORMAT_Z16;
+ rb->InternalFormat = GL_DEPTH_COMPONENT16;
}
else {
- rb->_ActualFormat = GL_DEPTH_COMPONENT32;
+ rb->Format = MESA_FORMAT_Z32;
+ rb->InternalFormat = GL_DEPTH_COMPONENT32;
}
- rb->InternalFormat = rb->_ActualFormat;
rb->AllocStorage = _mesa_soft_renderbuffer_storage;
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
@@ -1878,14 +1775,9 @@ _mesa_add_stencil_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
return GL_FALSE;
}
- if (stencilBits <= 8) {
- rb->_ActualFormat = GL_STENCIL_INDEX8_EXT;
- }
- else {
- /* not really supported (see s_stencil.c code) */
- rb->_ActualFormat = GL_STENCIL_INDEX16_EXT;
- }
- rb->InternalFormat = rb->_ActualFormat;
+ assert(stencilBits <= 8);
+ rb->Format = MESA_FORMAT_S8;
+ rb->InternalFormat = GL_STENCIL_INDEX8;
rb->AllocStorage = _mesa_soft_renderbuffer_storage;
_mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
@@ -1923,7 +1815,7 @@ _mesa_add_accum_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
return GL_FALSE;
}
- rb->_ActualFormat = GL_RGBA16;
+ rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
rb->InternalFormat = GL_RGBA16;
rb->AllocStorage = _mesa_soft_renderbuffer_storage;
_mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb);
@@ -1967,13 +1859,9 @@ _mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
return GL_FALSE;
}
- if (colorBits <= 8) {
- rb->_ActualFormat = GL_RGBA8;
- }
- else {
- rb->_ActualFormat = GL_RGBA16;
- }
- rb->InternalFormat = rb->_ActualFormat;
+ assert (colorBits <= 8);
+ rb->Format = MESA_FORMAT_RGBA8888;
+ rb->InternalFormat = GL_RGBA;
rb->AllocStorage = _mesa_soft_renderbuffer_storage;
_mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb);
@@ -2071,6 +1959,8 @@ void
_mesa_add_renderbuffer(struct gl_framebuffer *fb,
GLuint bufferName, struct gl_renderbuffer *rb)
{
+ GLenum baseFormat;
+
assert(fb);
assert(rb);
assert(bufferName < BUFFER_COUNT);
@@ -2095,7 +1985,8 @@ _mesa_add_renderbuffer(struct gl_framebuffer *fb,
* 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) {
+ baseFormat = _mesa_get_format_base_format(rb->Format);
+ if (baseFormat == GL_RGBA) {
if (CHAN_BITS == 16 && rb->DataType == GL_UNSIGNED_BYTE) {
GET_CURRENT_CONTEXT(ctx);
rb = _mesa_new_renderbuffer_16wrap8(ctx, rb);
@@ -2202,7 +2093,7 @@ _mesa_new_depthstencil_renderbuffer(GLcontext *ctx, GLuint name)
/* init fields not covered by _mesa_new_renderbuffer() */
dsrb->InternalFormat = GL_DEPTH24_STENCIL8_EXT;
- dsrb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ dsrb->Format = MESA_FORMAT_Z24_S8;
dsrb->AllocStorage = _mesa_soft_renderbuffer_storage;
return dsrb;
diff --git a/src/mesa/main/texrender.c b/src/mesa/main/texrender.c
index c8b532acbb..e2432be6ca 100644
--- a/src/mesa/main/texrender.c
+++ b/src/mesa/main/texrender.c
@@ -497,30 +497,23 @@ update_wrapper(GLcontext *ctx, const struct gl_renderbuffer_attachment *att)
trb->Base.InternalFormat = trb->TexImage->InternalFormat;
/* XXX may need more special cases here */
if (trb->TexImage->TexFormat == MESA_FORMAT_Z24_S8) {
- trb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ trb->Base.Format = MESA_FORMAT_Z24_S8;
trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
}
else if (trb->TexImage->TexFormat == MESA_FORMAT_Z16) {
- trb->Base._ActualFormat = GL_DEPTH_COMPONENT;
+ trb->Base.Format = MESA_FORMAT_Z16;
trb->Base.DataType = GL_UNSIGNED_SHORT;
}
else if (trb->TexImage->TexFormat == MESA_FORMAT_Z32) {
- trb->Base._ActualFormat = GL_DEPTH_COMPONENT;
+ trb->Base.Format = MESA_FORMAT_Z32;
trb->Base.DataType = GL_UNSIGNED_INT;
}
else {
- trb->Base._ActualFormat = trb->TexImage->InternalFormat;
+ trb->Base.Format = trb->TexImage->TexFormat;
trb->Base.DataType = CHAN_TYPE;
}
- trb->Base._BaseFormat = trb->TexImage->_BaseFormat;
trb->Base.Data = trb->TexImage->Data;
-
- trb->Base.RedBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE);
- trb->Base.GreenBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE);
- trb->Base.BlueBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE);
- trb->Base.AlphaBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE);
- trb->Base.DepthBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE_ARB);
- trb->Base.StencilBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_STENCIL_SIZE_EXT);
+ trb->Base._BaseFormat = _mesa_base_fbo_format(ctx, trb->Base.InternalFormat);
}
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 8a8c99f7e1..f015b12368 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -34,6 +34,7 @@
*/
#include "main/glheader.h"
+#include "main/formats.h"
#include "main/macros.h"
#include "shader/prog_instruction.h"
#include "st_context.h"
@@ -300,10 +301,14 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
static INLINE GLboolean
check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
{
- const GLuint stencilMax = (1 << rb->StencilBits) - 1;
+ const GLuint stencilMax = 0xff;
GLboolean maskStencil
= (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
+ assert(rb->Format == MESA_FORMAT_S8 ||
+ rb->Format == MESA_FORMAT_Z24_S8 ||
+ rb->Format == MESA_FORMAT_S8_Z24);
+
if (ctx->Scissor.Enabled &&
(ctx->Scissor.X != 0 ||
ctx->Scissor.Y != 0 ||
@@ -350,10 +355,14 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
{
const struct st_renderbuffer *strb = st_renderbuffer(rb);
const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
- const GLuint stencilMax = (1 << rb->StencilBits) - 1;
+ const GLuint stencilMax = 0xff;
const GLboolean maskStencil
= (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
+ assert(rb->Format == MESA_FORMAT_S8 ||
+ rb->Format == MESA_FORMAT_Z24_S8 ||
+ rb->Format == MESA_FORMAT_S8_Z24);
+
if (maskStencil)
return TRUE;
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index fe0a121493..7899d745aa 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -64,13 +64,7 @@ init_renderbuffer_bits(struct st_renderbuffer *strb,
assert( 0 );
}
- strb->Base._ActualFormat = info.base_format;
- strb->Base.RedBits = info.red_bits;
- strb->Base.GreenBits = info.green_bits;
- strb->Base.BlueBits = info.blue_bits;
- strb->Base.AlphaBits = info.alpha_bits;
- strb->Base.DepthBits = info.depth_bits;
- strb->Base.StencilBits = info.stencil_bits;
+ strb->Base.Format = info.mesa_format;
strb->Base.DataType = st_format_datatype(pipeFormat);
return info.size;
@@ -270,30 +264,24 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
case PIPE_FORMAT_A4R4G4B4_UNORM:
case PIPE_FORMAT_R5G6B5_UNORM:
strb->Base.InternalFormat = GL_RGBA;
- strb->Base._BaseFormat = GL_RGBA;
break;
case PIPE_FORMAT_Z16_UNORM:
strb->Base.InternalFormat = GL_DEPTH_COMPONENT16;
- strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
break;
case PIPE_FORMAT_Z32_UNORM:
strb->Base.InternalFormat = GL_DEPTH_COMPONENT32;
- strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
break;
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_Z24S8_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
case PIPE_FORMAT_Z24X8_UNORM:
strb->Base.InternalFormat = GL_DEPTH24_STENCIL8_EXT;
- strb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
break;
case PIPE_FORMAT_S8_UNORM:
strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT;
- strb->Base._BaseFormat = GL_STENCIL_INDEX;
break;
case PIPE_FORMAT_R16G16B16A16_SNORM:
strb->Base.InternalFormat = GL_RGBA16;
- strb->Base._BaseFormat = GL_RGBA;
break;
default:
_mesa_problem(NULL,
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index dc3ab61425..01b8e5fd77 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -31,6 +31,7 @@
#include "main/convolve.h"
#endif
#include "main/enums.h"
+#include "main/formats.h"
#include "main/image.h"
#include "main/imports.h"
#include "main/macros.h"
@@ -1397,8 +1398,8 @@ static unsigned
compatible_src_dst_formats(const struct gl_renderbuffer *src,
const struct gl_texture_image *dst)
{
- const GLenum srcFormat = src->_BaseFormat;
- const GLenum dstLogicalFormat = dst->_BaseFormat;
+ const GLenum srcFormat = _mesa_get_format_base_format(src->Format);
+ const GLenum dstLogicalFormat = _mesa_get_format_base_format(dst->TexFormat);
if (srcFormat == dstLogicalFormat) {
/* This is the same as matching_base_formats, which should
@@ -1524,7 +1525,9 @@ st_copy_texsubimage(GLcontext *ctx,
* framebuffer's alpha values). We can't do that with the blit or
* textured-quad paths.
*/
- matching_base_formats = (strb->Base._BaseFormat == texImage->_BaseFormat);
+ matching_base_formats =
+ (_mesa_get_format_base_format(strb->Base.Format) ==
+ _mesa_get_format_base_format(texImage->TexFormat));
format_writemask = compatible_src_dst_formats(&strb->Base, texImage);
if (ctx->_ImageTransferState == 0x0) {
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 6f76e2d8c0..aa71b91ec8 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -99,10 +99,11 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
if (format == PIPE_FORMAT_A1R5G5B5_UNORM || format == PIPE_FORMAT_R5G6B5_UNORM) {
pinfo->datatype = GL_UNSIGNED_SHORT;
}
+ else if (format == PIPE_FORMAT_S8Z24_UNORM) {
+ pinfo->datatype = GL_UNSIGNED_INT_24_8;
+ }
else {
- GLuint size;
-
- size = format_max_bits( info );
+ const GLuint size = format_max_bits( info );
if (size == 8) {
if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
pinfo->datatype = GL_UNSIGNED_BYTE;
@@ -150,24 +151,10 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
pinfo->red_bits = 0;
}
- /* Base format */
- if (pinfo->depth_bits) {
- if (pinfo->stencil_bits) {
- pinfo->base_format = GL_DEPTH_STENCIL_EXT;
- }
- else {
- pinfo->base_format = GL_DEPTH_COMPONENT;
- }
- }
- else if (pinfo->stencil_bits) {
- pinfo->base_format = GL_STENCIL_INDEX;
- }
- else {
- pinfo->base_format = GL_RGBA;
- }
+ pinfo->mesa_format = st_pipe_format_to_mesa_format(format);
}
else if (pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR) {
- pinfo->base_format = GL_YCBCR_MESA;
+ pinfo->mesa_format = MESA_FORMAT_YCBCR;
pinfo->datatype = GL_UNSIGNED_SHORT;
pinfo->size = 2; /* two bytes per "texel" */
}
@@ -224,7 +211,7 @@ st_format_datatype(enum pipe_format format)
enum pipe_format
-st_mesa_format_to_pipe_format(GLuint mesaFormat)
+st_mesa_format_to_pipe_format(gl_format mesaFormat)
{
switch (mesaFormat) {
/* fix this */
@@ -293,6 +280,82 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
}
}
+
+gl_format
+st_pipe_format_to_mesa_format(enum pipe_format pipeFormat)
+{
+ switch (pipeFormat) {
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ return MESA_FORMAT_ARGB8888;
+ case PIPE_FORMAT_A1R5G5B5_UNORM:
+ return MESA_FORMAT_ARGB1555;
+ case PIPE_FORMAT_A4R4G4B4_UNORM:
+ return MESA_FORMAT_ARGB4444;
+ case PIPE_FORMAT_R5G6B5_UNORM:
+ return MESA_FORMAT_RGB565;
+ case PIPE_FORMAT_A8L8_UNORM:
+ return MESA_FORMAT_AL88;
+ case PIPE_FORMAT_A8_UNORM:
+ return MESA_FORMAT_A8;
+ case PIPE_FORMAT_L8_UNORM:
+ return MESA_FORMAT_L8;
+ case PIPE_FORMAT_I8_UNORM:
+ return MESA_FORMAT_I8;
+ case PIPE_FORMAT_Z16_UNORM:
+ return MESA_FORMAT_Z16;
+ case PIPE_FORMAT_Z32_UNORM:
+ return MESA_FORMAT_Z32;
+ case PIPE_FORMAT_Z24S8_UNORM:
+ return MESA_FORMAT_Z24_S8;
+ case PIPE_FORMAT_S8Z24_UNORM:
+ return MESA_FORMAT_S8_Z24;
+ case PIPE_FORMAT_S8_UNORM:
+ return MESA_FORMAT_S8;
+
+ case PIPE_FORMAT_YCBCR:
+ return MESA_FORMAT_YCBCR;
+ case PIPE_FORMAT_R16G16B16A16_SNORM:
+ return MESA_FORMAT_SIGNED_RGBA_16;
+
+#if FEATURE_texture_s3tc
+ case PIPE_FORMAT_DXT1_RGB:
+ return MESA_FORMAT_RGB_DXT1;
+ case PIPE_FORMAT_DXT1_RGBA:
+ return MESA_FORMAT_RGBA_DXT1;
+ case PIPE_FORMAT_DXT3_RGBA:
+ return MESA_FORMAT_RGBA_DXT3;
+ case PIPE_FORMAT_DXT5_RGBA:
+ return MESA_FORMAT_RGBA_DXT5;
+#if FEATURE_EXT_texture_sRGB
+ case PIPE_FORMAT_DXT1_SRGB:
+ return MESA_FORMAT_SRGB_DXT1;
+ case PIPE_FORMAT_DXT1_SRGBA:
+ return MESA_FORMAT_SRGBA_DXT1;
+ case PIPE_FORMAT_DXT3_SRGBA:
+ return MESA_FORMAT_SRGBA_DXT3;
+ case PIPE_FORMAT_DXT5_SRGBA:
+ return MESA_FORMAT_SRGBA_DXT5;
+#endif
+#endif
+#if FEATURE_EXT_texture_sRGB
+ case PIPE_FORMAT_A8L8_SRGB:
+ return MESA_FORMAT_SLA8;
+ case PIPE_FORMAT_L8_SRGB:
+ return MESA_FORMAT_SL8;
+ case PIPE_FORMAT_R8G8B8_SRGB:
+ return MESA_FORMAT_SRGB8;
+ case PIPE_FORMAT_R8G8B8A8_SRGB:
+ return MESA_FORMAT_SRGBA8;
+ case PIPE_FORMAT_A8R8G8B8_SRGB:
+ return MESA_FORMAT_SARGB8;
+#endif
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+
/**
* Find an RGBA format supported by the context/winsys.
*/
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 1a8c6ea98f..97422bb199 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -34,7 +34,7 @@
struct pipe_format_info
{
enum pipe_format format;
- GLenum base_format;
+ gl_format mesa_format;
GLenum datatype;
GLubyte red_bits;
GLubyte green_bits;
@@ -61,7 +61,10 @@ st_format_datatype(enum pipe_format format);
extern enum pipe_format
-st_mesa_format_to_pipe_format(GLuint mesaFormat);
+st_mesa_format_to_pipe_format(gl_format mesaFormat);
+
+extern gl_format
+st_pipe_format_to_mesa_format(enum pipe_format pipeFormat);
extern enum pipe_format
diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c
index 35080fd394..002718ded8 100644
--- a/src/mesa/swrast/s_clear.c
+++ b/src/mesa/swrast/s_clear.c
@@ -24,6 +24,7 @@
#include "main/glheader.h"
#include "main/colormac.h"
+#include "main/formats.h"
#include "main/macros.h"
#include "main/imports.h"
#include "main/mtypes.h"
@@ -211,9 +212,6 @@ clear_ci_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
ASSERT(!ctx->Visual.rgbMode);
- ASSERT((ctx->Color.IndexMask & ((1 << rb->IndexBits) - 1))
- == (GLuint) ((1 << rb->IndexBits) - 1));
-
ASSERT(rb->PutMonoRow);
/* setup clear value */
@@ -264,8 +262,8 @@ clear_color_buffers(GLcontext *ctx)
}
else {
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
- const GLuint indexBits = (1 << rb->IndexBits) - 1;
- if ((ctx->Color.IndexMask & indexBits) == indexBits) {
+ const GLuint indexMask = (1 << _mesa_get_format_bits(rb->Format, GL_INDEX_BITS)) - 1;
+ if ((ctx->Color.IndexMask & indexMask) == indexMask) {
masking = GL_FALSE;
}
else {
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 1a428fb1a2..8073a61197 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -25,6 +25,7 @@
#include "main/glheader.h"
#include "main/context.h"
+#include "main/formats.h"
#include "main/macros.h"
#include "main/imports.h"
#include "main/fbobject.h"
@@ -1298,11 +1299,15 @@ void
_swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb,
GLint n, GLint x, GLint y, GLuint depth[] )
{
+ GLuint depthBits;
+
if (!rb) {
/* really only doing this to prevent FP exceptions later */
_mesa_bzero(depth, n * sizeof(GLfloat));
}
+ depthBits = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS);
+
ASSERT(rb->_BaseFormat == GL_DEPTH_COMPONENT);
if (y < 0 || y >= (GLint) rb->Height ||
@@ -1334,8 +1339,8 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb,
if (rb->DataType == GL_UNSIGNED_INT) {
rb->GetRow(ctx, rb, n, x, y, depth);
- if (rb->DepthBits < 32) {
- GLuint shift = 32 - rb->DepthBits;
+ if (depthBits < 32) {
+ GLuint shift = 32 - depthBits;
GLint i;
for (i = 0; i < n; i++) {
GLuint z = depth[i];
@@ -1347,14 +1352,14 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb,
GLushort temp[MAX_WIDTH];
GLint i;
rb->GetRow(ctx, rb, n, x, y, temp);
- if (rb->DepthBits == 16) {
+ if (depthBits == 16) {
for (i = 0; i < n; i++) {
GLuint z = temp[i];
depth[i] = (z << 16) | z;
}
}
else {
- GLuint shift = 16 - rb->DepthBits;
+ GLuint shift = 16 - depthBits;
for (i = 0; i < n; i++) {
GLuint z = temp[i];
depth[i] = (z << (shift + 16)) | (z << shift); /* XXX lsb bits? */
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index f28f2c9307..005d7a4c82 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -891,7 +891,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
return; \
}
#define RENDER_SPAN( span ) \
- if (rb->DepthBits <= 16) { \
+ if (rb->Format == MESA_FORMAT_Z16) { \
GLuint i; \
const GLushort *zRow = (const GLushort *) \
rb->GetPointer(ctx, rb, span.x, span.y); \