Checkpoint intel_renderbuffer removal.

Remove surface ptr from gl_renderbuffer.
Use st_renderbuffer in most places.
More clean-up.
This commit is contained in:
Brian
2007-08-09 12:59:11 -06:00
parent 36fc648ddd
commit f5713c7d2e
8 changed files with 107 additions and 92 deletions

View File

@@ -38,6 +38,7 @@
#include "vblank.h" #include "vblank.h"
#include "pipe/p_context.h" #include "pipe/p_context.h"
#include "state_tracker/st_cb_fbo.h"
#define FILE_DEBUG_FLAG DEBUG_BLIT #define FILE_DEBUG_FLAG DEBUG_BLIT
@@ -106,12 +107,17 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv,
const struct pipe_surface *backSurf; const struct pipe_surface *backSurf;
const struct pipe_region *backRegion; const struct pipe_region *backRegion;
int srcpitch; int srcpitch;
struct st_renderbuffer *strb;
/* blit from back color buffer if it exists, else front buffer */ /* blit from back color buffer if it exists, else front buffer */
if (intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer) strb = st_renderbuffer(intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
backSurf = intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer->surface; if (strb) {
else backSurf = strb->surface;
backSurf = intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer->surface; }
else {
strb = st_renderbuffer(intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
backSurf = strb->surface;
}
backRegion = backSurf->region; backRegion = backSurf->region;
srcpitch = backRegion->pitch; srcpitch = backRegion->pitch;

View File

@@ -2269,8 +2269,6 @@ struct gl_renderbuffer
GLubyte StencilBits; GLubyte StencilBits;
GLvoid *Data; /**< This may not be used by some kinds of RBs */ GLvoid *Data; /**< This may not be used by some kinds of RBs */
struct pipe_surface *surface;
/* Used to wrap one renderbuffer around another: */ /* Used to wrap one renderbuffer around another: */
struct gl_renderbuffer *Wrapped; struct gl_renderbuffer *Wrapped;

View File

@@ -1067,9 +1067,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoValues = put_mono_values_ubyte; rb->PutMonoValues = put_mono_values_ubyte;
rb->StencilBits = 8 * sizeof(GLubyte); rb->StencilBits = 8 * sizeof(GLubyte);
pixelSize = sizeof(GLubyte); pixelSize = sizeof(GLubyte);
#if 0
if (!rb->surface) if (!rb->surface)
rb->surface = (struct pipe_surface *) rb->surface = (struct pipe_surface *)
pipe->surface_alloc(pipe, PIPE_FORMAT_U_S8); pipe->surface_alloc(pipe, PIPE_FORMAT_U_S8);
#endif
break; break;
case GL_STENCIL_INDEX16_EXT: case GL_STENCIL_INDEX16_EXT:
rb->_ActualFormat = GL_STENCIL_INDEX16_EXT; rb->_ActualFormat = GL_STENCIL_INDEX16_EXT;
@@ -1100,9 +1102,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutValues = put_values_ushort; rb->PutValues = put_values_ushort;
rb->PutMonoValues = put_mono_values_ushort; rb->PutMonoValues = put_mono_values_ushort;
rb->DepthBits = 8 * sizeof(GLushort); rb->DepthBits = 8 * sizeof(GLushort);
#if 0
if (!rb->surface) if (!rb->surface)
rb->surface = (struct pipe_surface *) rb->surface = (struct pipe_surface *)
pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z16); pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z16);
#endif
pixelSize = sizeof(GLushort); pixelSize = sizeof(GLushort);
break; break;
case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT24:
@@ -1125,9 +1129,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->_ActualFormat = GL_DEPTH_COMPONENT32; rb->_ActualFormat = GL_DEPTH_COMPONENT32;
rb->DepthBits = 32; rb->DepthBits = 32;
} }
#if 0
if (!rb->surface) if (!rb->surface)
rb->surface = (struct pipe_surface *) rb->surface = (struct pipe_surface *)
pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z32); pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z32);
#endif
pixelSize = sizeof(GLuint); pixelSize = sizeof(GLuint);
break; break;
case GL_DEPTH_STENCIL_EXT: case GL_DEPTH_STENCIL_EXT:
@@ -1145,9 +1151,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoValues = put_mono_values_uint; rb->PutMonoValues = put_mono_values_uint;
rb->DepthBits = 24; rb->DepthBits = 24;
rb->StencilBits = 8; rb->StencilBits = 8;
#if 0
if (!rb->surface) if (!rb->surface)
rb->surface = (struct pipe_surface *) rb->surface = (struct pipe_surface *)
pipe->surface_alloc(pipe, PIPE_FORMAT_S8_Z24); pipe->surface_alloc(pipe, PIPE_FORMAT_S8_Z24);
#endif
pixelSize = sizeof(GLuint); pixelSize = sizeof(GLuint);
break; break;
case GL_COLOR_INDEX8_EXT: case GL_COLOR_INDEX8_EXT:
@@ -1210,7 +1218,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
ASSERT(rb->PutMonoValues); ASSERT(rb->PutMonoValues);
/* free old buffer storage */ /* free old buffer storage */
if (rb->surface) { if (0/**rb->surface**/) {
/* pipe_surface/region */ /* pipe_surface/region */
} }
else if (rb->Data) { else if (rb->Data) {
@@ -1221,8 +1229,9 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
if (width > 0 && height > 0) { if (width > 0 && height > 0) {
/* allocate new buffer storage */ /* allocate new buffer storage */
if (rb->surface) { if (0/**rb->surface**/) {
/* pipe_surface/region */ /* pipe_surface/region */
#if 0
if (rb->surface->region) { if (rb->surface->region) {
pipe->region_unmap(pipe, rb->surface->region); pipe->region_unmap(pipe, rb->surface->region);
pipe->region_release(pipe, &rb->surface->region); pipe->region_release(pipe, &rb->surface->region);
@@ -1231,6 +1240,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
/* XXX probably don't want to really map here */ /* XXX probably don't want to really map here */
pipe->region_map(pipe, rb->surface->region); pipe->region_map(pipe, rb->surface->region);
rb->Data = rb->surface->region->map; rb->Data = rb->surface->region->map;
#endif
} }
else { else {
/* legacy renderbuffer (this will go away) */ /* legacy renderbuffer (this will go away) */

View File

@@ -260,8 +260,6 @@ struct pipe_surface
GLuint offset; /**< offset from start of region, in bytes */ GLuint offset; /**< offset from start of region, in bytes */
GLint refcount; GLint refcount;
void *rb; /**< Ptr back to renderbuffer (temporary?) */
/** get block/tile of pixels from surface */ /** get block/tile of pixels from surface */
void (*get_tile)(struct pipe_surface *ps, void (*get_tile)(struct pipe_surface *ps,
GLuint x, GLuint y, GLuint w, GLuint h, GLfloat *p); GLuint x, GLuint y, GLuint w, GLuint h, GLfloat *p);

View File

@@ -33,6 +33,7 @@
#include "st_context.h" #include "st_context.h"
#include "st_atom.h" #include "st_atom.h"
#include "st_cb_fbo.h"
#include "pipe/p_context.h" #include "pipe/p_context.h"
@@ -44,7 +45,7 @@ static void
update_framebuffer_state( struct st_context *st ) update_framebuffer_state( struct st_context *st )
{ {
struct pipe_framebuffer_state framebuffer; struct pipe_framebuffer_state framebuffer;
struct gl_renderbuffer *rb; struct st_renderbuffer *strb;
GLuint i; GLuint i;
memset(&framebuffer, 0, sizeof(framebuffer)); memset(&framebuffer, 0, sizeof(framebuffer));
@@ -54,21 +55,23 @@ update_framebuffer_state( struct st_context *st )
*/ */
framebuffer.num_cbufs = st->ctx->DrawBuffer->_NumColorDrawBuffers[0]; framebuffer.num_cbufs = st->ctx->DrawBuffer->_NumColorDrawBuffers[0];
for (i = 0; i < framebuffer.num_cbufs; i++) { for (i = 0; i < framebuffer.num_cbufs; i++) {
rb = st->ctx->DrawBuffer->_ColorDrawBuffers[0][i]; strb = st_renderbuffer(st->ctx->DrawBuffer->_ColorDrawBuffers[0][i]);
assert(rb->surface); assert(strb->surface);
framebuffer.cbufs[i] = rb->surface; framebuffer.cbufs[i] = strb->surface;
} }
rb = st->ctx->DrawBuffer->_DepthBuffer; strb = st_renderbuffer(st->ctx->DrawBuffer->_DepthBuffer);
if (rb) { if (strb) {
assert(rb->Wrapped->surface); strb = st_renderbuffer(strb->Base.Wrapped);
framebuffer.zbuf = rb->Wrapped->surface; assert(strb->surface);
framebuffer.zbuf = strb->surface;
} }
rb = st->ctx->DrawBuffer->_StencilBuffer; strb = st_renderbuffer(st->ctx->DrawBuffer->_StencilBuffer);
if (rb) { if (strb) {
assert(rb->Wrapped->surface); strb = st_renderbuffer(strb->Base.Wrapped);
framebuffer.sbuf = rb->Wrapped->surface; assert(strb->surface);
framebuffer.sbuf = strb->surface;
} }
if (memcmp(&framebuffer, &st->state.framebuffer, sizeof(framebuffer)) != 0) { if (memcmp(&framebuffer, &st->state.framebuffer, sizeof(framebuffer)) != 0) {

View File

@@ -37,6 +37,7 @@
#include "st_atom.h" #include "st_atom.h"
#include "st_context.h" #include "st_context.h"
#include "st_cb_clear.h" #include "st_cb_clear.h"
#include "st_cb_fbo.h"
#include "st_program.h" #include "st_program.h"
#include "st_public.h" #include "st_public.h"
#include "pipe/p_context.h" #include "pipe/p_context.h"
@@ -288,6 +289,8 @@ clear_with_quad(GLcontext *ctx, GLuint x0, GLuint y0,
static void static void
clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{ {
struct st_renderbuffer *strb = st_renderbuffer(rb);
if (ctx->Color.ColorMask[0] && if (ctx->Color.ColorMask[0] &&
ctx->Color.ColorMask[1] && ctx->Color.ColorMask[1] &&
ctx->Color.ColorMask[2] && ctx->Color.ColorMask[2] &&
@@ -296,8 +299,8 @@ clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{ {
/* clear whole buffer w/out masking */ /* clear whole buffer w/out masking */
GLuint clearValue GLuint clearValue
= color_value(rb->surface->format, ctx->Color.ClearColor); = color_value(strb->surface->format, ctx->Color.ClearColor);
ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
} }
else { else {
/* masking or scissoring */ /* masking or scissoring */
@@ -314,14 +317,16 @@ clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
static void static void
clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{ {
struct st_renderbuffer *strb = st_renderbuffer(rb);
if (!ctx->Scissor.Enabled) { if (!ctx->Scissor.Enabled) {
/* clear whole buffer w/out masking */ /* clear whole buffer w/out masking */
GLuint clearValue GLuint clearValue
= color_value(rb->surface->format, ctx->Accum.ClearColor); = color_value(strb->surface->format, ctx->Accum.ClearColor);
/* Note that clearValue is 32 bits but the accum buffer will /* Note that clearValue is 32 bits but the accum buffer will
* typically be 64bpp... * typically be 64bpp...
*/ */
ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
} }
else { else {
/* scissoring */ /* scissoring */
@@ -339,11 +344,13 @@ clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
static void static void
clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{ {
struct st_renderbuffer *strb = st_renderbuffer(rb);
if (!ctx->Scissor.Enabled && if (!ctx->Scissor.Enabled &&
!is_depth_stencil_format(rb->surface->format)) { !is_depth_stencil_format(strb->surface->format)) {
/* clear whole depth buffer w/out masking */ /* clear whole depth buffer w/out masking */
GLuint clearValue = depth_value(rb->surface->format, ctx->Depth.Clear); GLuint clearValue = depth_value(strb->surface->format, ctx->Depth.Clear);
ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
} }
else { else {
/* masking or scissoring or combined z/stencil buffer */ /* masking or scissoring or combined z/stencil buffer */
@@ -360,14 +367,15 @@ clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
static void static void
clear_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) clear_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{ {
struct st_renderbuffer *strb = st_renderbuffer(rb);
const GLuint stencilMax = (1 << rb->StencilBits) - 1; const GLuint stencilMax = (1 << rb->StencilBits) - 1;
GLboolean maskStencil = ctx->Stencil.WriteMask[0] != stencilMax; GLboolean maskStencil = ctx->Stencil.WriteMask[0] != stencilMax;
if (!maskStencil && !ctx->Scissor.Enabled && if (!maskStencil && !ctx->Scissor.Enabled &&
!is_depth_stencil_format(rb->surface->format)) { !is_depth_stencil_format(strb->surface->format)) {
/* clear whole stencil buffer w/out masking */ /* clear whole stencil buffer w/out masking */
GLuint clearValue = ctx->Stencil.Clear; GLuint clearValue = ctx->Stencil.Clear;
ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
} }
else { else {
/* masking or scissoring */ /* masking or scissoring */
@@ -384,16 +392,17 @@ clear_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
static void static void
clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{ {
struct st_renderbuffer *strb = st_renderbuffer(rb);
const GLuint stencilMax = 1 << rb->StencilBits; const GLuint stencilMax = 1 << rb->StencilBits;
GLboolean maskStencil = ctx->Stencil.WriteMask[0] != stencilMax; GLboolean maskStencil = ctx->Stencil.WriteMask[0] != stencilMax;
assert(is_depth_stencil_format(rb->surface->format)); assert(is_depth_stencil_format(strb->surface->format));
if (!maskStencil && !ctx->Scissor.Enabled) { if (!maskStencil && !ctx->Scissor.Enabled) {
/* clear whole buffer w/out masking */ /* clear whole buffer w/out masking */
GLuint clearValue = depth_value(rb->surface->format, ctx->Depth.Clear); GLuint clearValue = depth_value(strb->surface->format, ctx->Depth.Clear);
switch (rb->surface->format) { switch (strb->surface->format) {
case PIPE_FORMAT_S8_Z24: case PIPE_FORMAT_S8_Z24:
clearValue |= ctx->Stencil.Clear << 24; clearValue |= ctx->Stencil.Clear << 24;
break; break;
@@ -406,7 +415,7 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
assert(0); assert(0);
} }
ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
} }
else { else {
/* masking or scissoring */ /* masking or scissoring */

View File

@@ -46,29 +46,6 @@
#include "st_cb_teximage.h" #include "st_cb_teximage.h"
/**
* Derived renderbuffer class. Just need to add a pointer to the
* pipe surface.
*/
struct st_renderbuffer
{
struct gl_renderbuffer Base;
#if 0
struct pipe_surface *surface;
#endif
};
/**
* Cast wrapper.
*/
static INLINE struct st_renderbuffer *
st_renderbuffer(struct gl_renderbuffer *rb)
{
return (struct st_renderbuffer *) rb;
}
struct pipe_format_info struct pipe_format_info
{ {
GLuint format; GLuint format;
@@ -168,29 +145,29 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
cpp = info->size; cpp = info->size;
if (!strb->Base.surface) { if (!strb->surface) {
strb->Base.surface = pipe->surface_alloc(pipe, pipeFormat); strb->surface = pipe->surface_alloc(pipe, pipeFormat);
if (!strb->Base.surface) if (!strb->surface)
return GL_FALSE; return GL_FALSE;
} }
/* free old region */ /* free old region */
if (strb->Base.surface->region) { if (strb->surface->region) {
pipe->region_release(pipe, &strb->Base.surface->region); pipe->region_release(pipe, &strb->surface->region);
} }
/* Choose a pitch to match hardware requirements: /* Choose a pitch to match hardware requirements:
*/ */
pitch = ((cpp * width + 63) & ~63) / cpp; /* XXX fix: device-specific */ pitch = ((cpp * width + 63) & ~63) / cpp; /* XXX fix: device-specific */
strb->Base.surface->region = pipe->region_alloc(pipe, cpp, pitch, height); strb->surface->region = pipe->region_alloc(pipe, cpp, pitch, height);
if (!strb->Base.surface->region) if (!strb->surface->region)
return GL_FALSE; /* out of memory, try s/w buffer? */ return GL_FALSE; /* out of memory, try s/w buffer? */
ASSERT(strb->Base.surface->region->buffer); ASSERT(strb->surface->region->buffer);
strb->Base.Width = strb->Base.surface->width = width; strb->Base.Width = strb->surface->width = width;
strb->Base.Height = strb->Base.surface->height = height; strb->Base.Height = strb->surface->height = height;
return GL_TRUE; return GL_TRUE;
} }
@@ -206,11 +183,11 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
struct pipe_context *pipe = ctx->st->pipe; struct pipe_context *pipe = ctx->st->pipe;
struct st_renderbuffer *strb = st_renderbuffer(rb); struct st_renderbuffer *strb = st_renderbuffer(rb);
ASSERT(strb); ASSERT(strb);
if (strb && strb->Base.surface) { if (strb && strb->surface) {
if (rb->surface->region) { if (strb->surface->region) {
pipe->region_release(pipe, &strb->Base.surface->region); pipe->region_release(pipe, &strb->surface->region);
} }
free(strb->Base.surface); free(strb->surface);
} }
free(strb); free(strb);
} }
@@ -285,28 +262,28 @@ st_new_renderbuffer_fb(struct pipe_region *region, GLuint width, GLuint height)
struct gl_renderbuffer * struct gl_renderbuffer *
st_new_renderbuffer_fb(GLuint intFormat) st_new_renderbuffer_fb(GLuint intFormat)
{ {
struct st_renderbuffer *irb; struct st_renderbuffer *strb;
irb = CALLOC_STRUCT(st_renderbuffer); strb = CALLOC_STRUCT(st_renderbuffer);
if (!irb) { if (!strb) {
_mesa_error(NULL, GL_OUT_OF_MEMORY, "creating renderbuffer"); _mesa_error(NULL, GL_OUT_OF_MEMORY, "creating renderbuffer");
return NULL; return NULL;
} }
_mesa_init_renderbuffer(&irb->Base, 0); _mesa_init_renderbuffer(&strb->Base, 0);
irb->Base.ClassID = 0x42; /* XXX temp */ strb->Base.ClassID = 0x42; /* XXX temp */
irb->Base.InternalFormat = intFormat; strb->Base.InternalFormat = intFormat;
switch (intFormat) { switch (intFormat) {
case GL_RGB5: case GL_RGB5:
case GL_RGBA8: case GL_RGBA8:
irb->Base._BaseFormat = GL_RGBA; strb->Base._BaseFormat = GL_RGBA;
break; break;
case GL_DEPTH_COMPONENT16: case GL_DEPTH_COMPONENT16:
irb->Base._BaseFormat = GL_DEPTH_COMPONENT; strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
break; break;
case GL_DEPTH24_STENCIL8_EXT: case GL_DEPTH24_STENCIL8_EXT:
irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT; strb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
break; break;
default: default:
_mesa_problem(NULL, _mesa_problem(NULL,
@@ -315,15 +292,14 @@ st_new_renderbuffer_fb(GLuint intFormat)
} }
/* st-specific methods */ /* st-specific methods */
irb->Base.Delete = st_renderbuffer_delete; strb->Base.Delete = st_renderbuffer_delete;
irb->Base.AllocStorage = st_renderbuffer_alloc_storage; strb->Base.AllocStorage = st_renderbuffer_alloc_storage;
irb->Base.GetPointer = null_get_pointer; strb->Base.GetPointer = null_get_pointer;
/* span routines set in alloc_storage function */
irb->Base.surface = NULL;/*intel_new_surface(intFormat);*/ /* surface is allocate in alloc_renderbuffer_storage() */
/*irb->Base.surface->rb = irb;*/ strb->surface = NULL;
return &irb->Base; return &strb->Base;
} }
#endif #endif

View File

@@ -30,10 +30,25 @@
#define ST_CB_FBO_H #define ST_CB_FBO_H
/*
extern struct gl_renderbuffer * /**
st_new_renderbuffer_fb(struct pipe_region *region, GLuint width, GLuint height); * Derived renderbuffer class. Just need to add a pointer to the
*/ * pipe surface.
*/
struct st_renderbuffer
{
struct gl_renderbuffer Base;
struct pipe_surface *surface;
};
static INLINE struct st_renderbuffer *
st_renderbuffer(struct gl_renderbuffer *rb)
{
return (struct st_renderbuffer *) rb;
}
extern struct gl_renderbuffer * extern struct gl_renderbuffer *
st_new_renderbuffer_fb(GLuint intFormat); st_new_renderbuffer_fb(GLuint intFormat);