_ActualFormat is replaced by Format (MESA_FORMAT_x).
ColorEncoding, ComponentType, RedBits, GreenBits, BlueBits, etc. are
all replaced by MESA_FORMAT_x queries.
#include "main/mtypes.h"
+#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/imports.h"
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
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);
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 {
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
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;
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;
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;
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,
return GL_FALSE;
}
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
intelFlush(ctx);
/* free old region */
ASSERT(rb->Name == 0);
rb->Width = width;
rb->Height = height;
- rb->_ActualFormat = internalFormat;
+ rb->InternalFormat = internalFormat;
return GL_TRUE;
}
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,
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");
}
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;
}
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:
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:
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:
#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:
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);
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)
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
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:
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:
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:
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:
return GL_FALSE;
}
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
if (ctx->Driver.Flush)
ctx->Driver.Flush(ctx); /* +r6/r7 */
ASSERT(rb->Name == 0);
rb->Width = width;
rb->Height = height;
- rb->_ActualFormat = internalFormat;
+ rb->InternalFormat = internalFormat;
return GL_TRUE;
}
/* 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);
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");
}
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;
*/
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);
}
}
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);
#include "sis_tris.h"
#include "swrast/swrast.h"
+#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
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;
}
#include "main/context.h"
#include "main/extensions.h"
+#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/imports.h"
#include "main/renderbuffer.h"
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:
#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"
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;
}
#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"
else
bpc = 32;
- rb->RedBits =
- rb->GreenBits =
- rb->BlueBits =
- rb->AlphaBits = bpc;
-
/* Note: we can ignoring internalFormat for "window-system" renderbuffers */
(void) internalFormat;
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) {
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) {
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) {
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) {
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);
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;
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");
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;
}
#include "glxheader.h"
#include "xmesaP.h"
#include "main/imports.h"
+#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
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 */
}
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;
}
}
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;
}
}
#include "imports.h"
#include "context.h"
#include "fbobject.h"
+#include "formats.h"
#include "mtypes.h"
#include "depthstencil.h"
#include "renderbuffer.h"
* 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.
*/
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);
}
(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) {
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;
+ }
}
}
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;
+ }
}
}
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);
+ }
}
}
}
/* 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);
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);
+ }
}
}
}
/* 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);
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);
+ }
}
}
}
/* 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);
{
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);
{
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);
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;
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;
+ }
}
}
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;
+ }
}
}
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);
+ }
}
}
}
/* 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);
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);
+ }
}
}
}
/* 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);
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);
+ }
}
}
}
/* 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);
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);
{
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);
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;
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);
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;
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);
}
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);
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;
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++) {
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;
stencilRb->PutRow(ctx, stencilRb, width, 0, i, depthStencil, NULL);
}
_mesa_free(data);
-
- stencilRb->_BaseFormat = GL_DEPTH_STENCIL_EXT;
}
/** Set this to 1 to help debug FBO incompleteness problems */
-#define DEBUG_FBO 0
+#define DEBUG_FBO 1
/**
}
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 {
}
}
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 ||
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 {
}
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 {
}
/* 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;
}
}
+/**
+ * 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)
*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) {
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)");
"glGetFramebufferAttachmentParameterivEXT(pname)");
}
else {
- *params = att->Renderbuffer->ColorEncoding;
+ *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format);
}
return;
case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
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:
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;
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;
/* 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;
#include "buffers.h"
#include "context.h"
#include "depthstencil.h"
+#include "formats.h"
#include "macros.h"
#include "mtypes.h"
#include "fbobject.h"
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);
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;
}
}
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);
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);
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);
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,
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,
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 */
_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;
_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;
_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;
#include "glheader.h"
#include "imports.h"
#include "context.h"
+#include "fbobject.h"
+#include "formats.h"
#include "mtypes.h"
#include "fbobject.h"
#include "renderbuffer.h"
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;
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.
*/
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];
{
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
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]) {
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]) {
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 */
/* 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]) {
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]) {
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);
}
{
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));
}
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;
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++) {
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];
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));
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]);
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]);
{
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:
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;
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:
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;
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;
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;
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
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;
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;
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;
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;
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;
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;
rb->Width = width;
rb->Height = height;
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, rb->InternalFormat);
return GL_TRUE;
}
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,
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);
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;
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);
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);
* 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;
}
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);
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);
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);
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);
_mesa_add_renderbuffer(struct gl_framebuffer *fb,
GLuint bufferName, struct gl_renderbuffer *rb)
{
+ GLenum baseFormat;
+
assert(fb);
assert(rb);
assert(bufferName < BUFFER_COUNT);
* 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);
/* 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;
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);
}
*/
#include "main/glheader.h"
+#include "main/formats.h"
#include "main/macros.h"
#include "shader/prog_instruction.h"
#include "st_context.h"
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 ||
{
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;
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;
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,
#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"
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
* 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) {
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;
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" */
}
enum pipe_format
-st_mesa_format_to_pipe_format(GLuint mesaFormat)
+st_mesa_format_to_pipe_format(gl_format mesaFormat)
{
switch (mesaFormat) {
/* fix this */
}
}
+
+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.
*/
struct pipe_format_info
{
enum pipe_format format;
- GLenum base_format;
+ gl_format mesa_format;
GLenum datatype;
GLubyte red_bits;
GLubyte green_bits;
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
#include "main/glheader.h"
#include "main/colormac.h"
+#include "main/formats.h"
#include "main/macros.h"
#include "main/imports.h"
#include "main/mtypes.h"
ASSERT(!ctx->Visual.rgbMode);
- ASSERT((ctx->Color.IndexMask & ((1 << rb->IndexBits) - 1))
- == (GLuint) ((1 << rb->IndexBits) - 1));
-
ASSERT(rb->PutMonoRow);
/* setup clear value */
}
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 {
#include "main/glheader.h"
#include "main/context.h"
+#include "main/formats.h"
#include "main/macros.h"
#include "main/imports.h"
#include "main/fbobject.h"
_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 ||
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];
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? */
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); \