Replace gl_renderbuffer.ComponentSizes[] with separate RedBits, GreenBits,

BlueBits, etc fields.
This commit is contained in:
Brian Paul
2005-09-22 05:19:57 +00:00
parent f1e2826856
commit 676d0accf5
7 changed files with 49 additions and 44 deletions

View File

@@ -100,7 +100,7 @@ driNewRenderbuffer(GLenum format, GLvoid *addr,
} }
/* XXX if we were allocating a user-created renderbuffer, we'd have /* XXX if we were allocating a user-created renderbuffer, we'd have
* to fill in the ComponentSizes[] array too. * to fill in the Red/Green/Blue/.../Bits values too.
*/ */
drb->Base.AllocStorage = driRenderbufferStorage; drb->Base.AllocStorage = driRenderbufferStorage;

View File

@@ -130,7 +130,7 @@ xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode,
xrb->Base._BaseFormat = GL_COLOR_INDEX; xrb->Base._BaseFormat = GL_COLOR_INDEX;
xrb->Base.DataType = GL_UNSIGNED_INT; xrb->Base.DataType = GL_UNSIGNED_INT;
} }
xrb->Base.ComponentSizes[0] = 0; /* XXX fix? */ /* only need to set Red/Green/EtcBits fields for user-created RBs */
} }
return xrb; return xrb;
} }

View File

@@ -747,7 +747,7 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
case GL_RENDERBUFFER_RED_SIZE_EXT: case GL_RENDERBUFFER_RED_SIZE_EXT:
if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB || if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB ||
ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) { ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) {
*params = ctx->CurrentRenderbuffer->ComponentSizes[0]; *params = ctx->CurrentRenderbuffer->RedBits;
} }
else { else {
*params = 0; *params = 0;
@@ -756,7 +756,7 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
case GL_RENDERBUFFER_GREEN_SIZE_EXT: case GL_RENDERBUFFER_GREEN_SIZE_EXT:
if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB || if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB ||
ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) { ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) {
*params = ctx->CurrentRenderbuffer->ComponentSizes[1]; *params = ctx->CurrentRenderbuffer->GreenBits;
} }
else { else {
*params = 0; *params = 0;
@@ -765,7 +765,7 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
case GL_RENDERBUFFER_BLUE_SIZE_EXT: case GL_RENDERBUFFER_BLUE_SIZE_EXT:
if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB || if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB ||
ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) { ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) {
*params = ctx->CurrentRenderbuffer->ComponentSizes[2]; *params = ctx->CurrentRenderbuffer->BlueBits;
} }
else { else {
*params = 0; *params = 0;
@@ -774,7 +774,7 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
case GL_RENDERBUFFER_ALPHA_SIZE_EXT: case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB || if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB ||
ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) { ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) {
*params = ctx->CurrentRenderbuffer->ComponentSizes[3]; *params = ctx->CurrentRenderbuffer->AlphaBits;
} }
else { else {
*params = 0; *params = 0;
@@ -782,7 +782,7 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
break; break;
case GL_RENDERBUFFER_DEPTH_SIZE_EXT: case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
if (ctx->CurrentRenderbuffer->_BaseFormat == GL_DEPTH_COMPONENT) { if (ctx->CurrentRenderbuffer->_BaseFormat == GL_DEPTH_COMPONENT) {
*params = ctx->CurrentRenderbuffer->ComponentSizes[0]; *params = ctx->CurrentRenderbuffer->DepthBits;
} }
else { else {
*params = 0; *params = 0;
@@ -790,7 +790,7 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
break; break;
case GL_RENDERBUFFER_STENCIL_SIZE_EXT: case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
if (ctx->CurrentRenderbuffer->_BaseFormat == GL_STENCIL_INDEX) { if (ctx->CurrentRenderbuffer->_BaseFormat == GL_STENCIL_INDEX) {
*params = ctx->CurrentRenderbuffer->ComponentSizes[0]; *params = ctx->CurrentRenderbuffer->StencilBits;
} }
else { else {
*params = 0; *params = 0;

View File

@@ -329,13 +329,13 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) { if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) {
fb->Visual.redBits fb->Visual.redBits
= fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->ComponentSizes[0]; = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->RedBits;
fb->Visual.greenBits fb->Visual.greenBits
= fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->ComponentSizes[1]; = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->GreenBits;
fb->Visual.blueBits fb->Visual.blueBits
= fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->ComponentSizes[2]; = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->BlueBits;
fb->Visual.alphaBits fb->Visual.alphaBits
= fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->ComponentSizes[3]; = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->AlphaBits;
fb->Visual.rgbBits fb->Visual.rgbBits
= fb->Visual.redBits + fb->Visual.greenBits + fb->Visual.blueBits; = fb->Visual.redBits + fb->Visual.greenBits + fb->Visual.blueBits;
fb->Visual.floatMode = GL_FALSE; fb->Visual.floatMode = GL_FALSE;
@@ -344,13 +344,13 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
fb->Visual.haveDepthBuffer = GL_TRUE; fb->Visual.haveDepthBuffer = GL_TRUE;
fb->Visual.depthBits fb->Visual.depthBits
= fb->Attachment[BUFFER_DEPTH].Renderbuffer->ComponentSizes[0]; = fb->Attachment[BUFFER_DEPTH].Renderbuffer->DepthBits;
} }
if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) { if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) {
fb->Visual.haveStencilBuffer = GL_TRUE; fb->Visual.haveStencilBuffer = GL_TRUE;
fb->Visual.stencilBits fb->Visual.stencilBits
= fb->Attachment[BUFFER_STENCIL].Renderbuffer->ComponentSizes[0]; = fb->Attachment[BUFFER_STENCIL].Renderbuffer->StencilBits;
} }
compute_depth_max(fb); compute_depth_max(fb);

View File

@@ -2055,7 +2055,13 @@ struct gl_renderbuffer
GLenum _BaseFormat; /* Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or */ GLenum _BaseFormat; /* Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or */
/* GL_STENCIL_INDEX. */ /* GL_STENCIL_INDEX. */
GLenum DataType; /* Type of values passed to the Get/Put functions */ GLenum DataType; /* Type of values passed to the Get/Put functions */
GLubyte ComponentSizes[4]; /* bits per component or channel */ GLubyte RedBits; /**< Bits per image component */
GLubyte GreenBits;
GLubyte BlueBits;
GLubyte AlphaBits;
GLubyte IndexBits;
GLubyte DepthBits;
GLubyte StencilBits;
GLvoid *Data; GLvoid *Data;
/* Delete this renderbuffer */ /* Delete this renderbuffer */

View File

@@ -937,10 +937,10 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ubyte3; rb->PutMonoRow = put_mono_row_ubyte3;
rb->PutValues = put_values_ubyte3; rb->PutValues = put_values_ubyte3;
rb->PutMonoValues = put_mono_values_ubyte3; rb->PutMonoValues = put_mono_values_ubyte3;
rb->ComponentSizes[0] = 8 * sizeof(GLubyte); rb->RedBits = 8 * sizeof(GLubyte);
rb->ComponentSizes[1] = 8 * sizeof(GLubyte); rb->GreenBits = 8 * sizeof(GLubyte);
rb->ComponentSizes[2] = 8 * sizeof(GLubyte); rb->BlueBits = 8 * sizeof(GLubyte);
rb->ComponentSizes[3] = 0; rb->AlphaBits = 0;
pixelSize = 3 * sizeof(GLubyte); pixelSize = 3 * sizeof(GLubyte);
break; break;
case GL_RGBA: case GL_RGBA:
@@ -958,10 +958,10 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ubyte4; rb->PutMonoRow = put_mono_row_ubyte4;
rb->PutValues = put_values_ubyte4; rb->PutValues = put_values_ubyte4;
rb->PutMonoValues = put_mono_values_ubyte4; rb->PutMonoValues = put_mono_values_ubyte4;
rb->ComponentSizes[0] = 8 * sizeof(GLubyte); rb->RedBits = 8 * sizeof(GLubyte);
rb->ComponentSizes[1] = 8 * sizeof(GLubyte); rb->GreenBits = 8 * sizeof(GLubyte);
rb->ComponentSizes[2] = 8 * sizeof(GLubyte); rb->BlueBits = 8 * sizeof(GLubyte);
rb->ComponentSizes[3] = 8 * sizeof(GLubyte); rb->AlphaBits = 8 * sizeof(GLubyte);
pixelSize = 4 * sizeof(GLubyte); pixelSize = 4 * sizeof(GLubyte);
break; break;
case GL_RGB10_A2: case GL_RGB10_A2:
@@ -977,10 +977,10 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ushort4; rb->PutMonoRow = put_mono_row_ushort4;
rb->PutValues = put_values_ushort4; rb->PutValues = put_values_ushort4;
rb->PutMonoValues = put_mono_values_ushort4; rb->PutMonoValues = put_mono_values_ushort4;
rb->ComponentSizes[0] = 8 * sizeof(GLushort); rb->RedBits = 8 * sizeof(GLushort);
rb->ComponentSizes[1] = 8 * sizeof(GLushort); rb->GreenBits = 8 * sizeof(GLushort);
rb->ComponentSizes[2] = 8 * sizeof(GLushort); rb->BlueBits = 8 * sizeof(GLushort);
rb->ComponentSizes[3] = 8 * sizeof(GLushort); rb->AlphaBits = 8 * sizeof(GLushort);
pixelSize = 4 * sizeof(GLushort); pixelSize = 4 * sizeof(GLushort);
break; break;
#if 00 #if 00
@@ -995,10 +995,10 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_alpha8; rb->PutMonoRow = put_mono_row_alpha8;
rb->PutValues = put_values_alpha8; rb->PutValues = put_values_alpha8;
rb->PutMonoValues = put_mono_values_alpha8; rb->PutMonoValues = put_mono_values_alpha8;
rb->ComponentSizes[0] = 0; /*red*/ rb->RedBits = 0; /*red*/
rb->ComponentSizes[1] = 0; /*green*/ rb->GreenBits = 0; /*green*/
rb->ComponentSizes[2] = 0; /*blue*/ rb->BlueBits = 0; /*blue*/
rb->ComponentSizes[3] = 8 * sizeof(GLubyte); rb->AlphaBits = 8 * sizeof(GLubyte);
pixelSize = sizeof(GLubyte); pixelSize = sizeof(GLubyte);
break; break;
#endif #endif
@@ -1016,7 +1016,7 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ubyte; rb->PutMonoRow = put_mono_row_ubyte;
rb->PutValues = put_values_ubyte; rb->PutValues = put_values_ubyte;
rb->PutMonoValues = put_mono_values_ubyte; rb->PutMonoValues = put_mono_values_ubyte;
rb->ComponentSizes[0] = 8 * sizeof(GLubyte); rb->StencilBits = 8 * sizeof(GLubyte);
pixelSize = sizeof(GLubyte); pixelSize = sizeof(GLubyte);
break; break;
case GL_STENCIL_INDEX16_EXT: case GL_STENCIL_INDEX16_EXT:
@@ -1030,7 +1030,7 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ushort; rb->PutMonoRow = put_mono_row_ushort;
rb->PutValues = put_values_ushort; rb->PutValues = put_values_ushort;
rb->PutMonoValues = put_mono_values_ushort; rb->PutMonoValues = put_mono_values_ushort;
rb->ComponentSizes[0] = 8 * sizeof(GLushort); rb->StencilBits = 8 * sizeof(GLushort);
pixelSize = sizeof(GLushort); pixelSize = sizeof(GLushort);
break; break;
case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT:
@@ -1045,7 +1045,7 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ushort; rb->PutMonoRow = put_mono_row_ushort;
rb->PutValues = put_values_ushort; rb->PutValues = put_values_ushort;
rb->PutMonoValues = put_mono_values_ushort; rb->PutMonoValues = put_mono_values_ushort;
rb->ComponentSizes[0] = 8 * sizeof(GLushort); rb->DepthBits = 8 * sizeof(GLushort);
pixelSize = sizeof(GLushort); pixelSize = sizeof(GLushort);
break; break;
case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT24:
@@ -1060,7 +1060,7 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_uint; rb->PutMonoRow = put_mono_row_uint;
rb->PutValues = put_values_uint; rb->PutValues = put_values_uint;
rb->PutMonoValues = put_mono_values_uint; rb->PutMonoValues = put_mono_values_uint;
rb->ComponentSizes[0] = 8 * sizeof(GLuint); rb->DepthBits = 8 * sizeof(GLuint);
pixelSize = sizeof(GLuint); pixelSize = sizeof(GLuint);
break; break;
case GL_COLOR_INDEX8_EXT: case GL_COLOR_INDEX8_EXT:
@@ -1074,7 +1074,7 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ubyte; rb->PutMonoRow = put_mono_row_ubyte;
rb->PutValues = put_values_ubyte; rb->PutValues = put_values_ubyte;
rb->PutMonoValues = put_mono_values_ubyte; rb->PutMonoValues = put_mono_values_ubyte;
rb->ComponentSizes[0] = 8 * sizeof(GLubyte); rb->IndexBits = 8 * sizeof(GLubyte);
pixelSize = sizeof(GLubyte); pixelSize = sizeof(GLubyte);
break; break;
case GL_COLOR_INDEX16_EXT: case GL_COLOR_INDEX16_EXT:
@@ -1088,7 +1088,7 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ushort; rb->PutMonoRow = put_mono_row_ushort;
rb->PutValues = put_values_ushort; rb->PutValues = put_values_ushort;
rb->PutMonoValues = put_mono_values_ushort; rb->PutMonoValues = put_mono_values_ushort;
rb->ComponentSizes[0] = 8 * sizeof(GLushort); rb->IndexBits = 8 * sizeof(GLushort);
pixelSize = sizeof(GLushort); pixelSize = sizeof(GLushort);
break; break;
case COLOR_INDEX32: case COLOR_INDEX32:
@@ -1102,7 +1102,7 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_uint; rb->PutMonoRow = put_mono_row_uint;
rb->PutValues = put_values_uint; rb->PutValues = put_values_uint;
rb->PutMonoValues = put_mono_values_uint; rb->PutMonoValues = put_mono_values_uint;
rb->ComponentSizes[0] = 8 * sizeof(GLuint); rb->IndexBits = 8 * sizeof(GLuint);
pixelSize = sizeof(GLuint); pixelSize = sizeof(GLuint);
break; break;
default: default:
@@ -1118,7 +1118,6 @@ soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
ASSERT(rb->PutMonoRow); ASSERT(rb->PutMonoRow);
ASSERT(rb->PutValues); ASSERT(rb->PutValues);
ASSERT(rb->PutMonoValues); ASSERT(rb->PutMonoValues);
ASSERT(rb->ComponentSizes[0] > 0);
/* free old buffer storage */ /* free old buffer storage */
if (rb->Data) if (rb->Data)
@@ -1399,10 +1398,10 @@ _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
rb->InternalFormat = GL_NONE; rb->InternalFormat = GL_NONE;
rb->_BaseFormat = GL_NONE; rb->_BaseFormat = GL_NONE;
rb->DataType = GL_NONE; rb->DataType = GL_NONE;
rb->ComponentSizes[0] = 0; rb->RedBits = rb->GreenBits = rb->BlueBits = rb->AlphaBits = 0;
rb->ComponentSizes[1] = 0; rb->IndexBits = 0;
rb->ComponentSizes[2] = 0; rb->DepthBits = 0;
rb->ComponentSizes[3] = 0; rb->StencilBits = 0;
rb->Data = NULL; rb->Data = NULL;
rb->GetPointer = nop_get_pointer; rb->GetPointer = nop_get_pointer;

View File

@@ -1127,7 +1127,7 @@ _swrast_write_stencil_span(GLcontext *ctx, GLint n, GLint x, GLint y,
void void
_swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) _swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
{ {
const GLubyte stencilBits = rb->ComponentSizes[0]; const GLubyte stencilBits = ctx->DrawBuffer->Visual.stencilBits;
const GLuint mask = ctx->Stencil.WriteMask[0]; const GLuint mask = ctx->Stencil.WriteMask[0];
const GLuint invMask = ~mask; const GLuint invMask = ~mask;
const GLuint clearVal = (ctx->Stencil.Clear & mask); const GLuint clearVal = (ctx->Stencil.Clear & mask);