Checkpoint intel_renderbuffer removal.
Remove surface ptr from gl_renderbuffer. Use st_renderbuffer in most places. More clean-up.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "vblank.h"
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "state_tracker/st_cb_fbo.h"
|
||||
|
||||
|
||||
#define FILE_DEBUG_FLAG DEBUG_BLIT
|
||||
@@ -106,12 +107,17 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv,
|
||||
const struct pipe_surface *backSurf;
|
||||
const struct pipe_region *backRegion;
|
||||
int srcpitch;
|
||||
struct st_renderbuffer *strb;
|
||||
|
||||
/* blit from back color buffer if it exists, else front buffer */
|
||||
if (intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer)
|
||||
backSurf = intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer->surface;
|
||||
else
|
||||
backSurf = intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer->surface;
|
||||
strb = st_renderbuffer(intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
|
||||
if (strb) {
|
||||
backSurf = strb->surface;
|
||||
}
|
||||
else {
|
||||
strb = st_renderbuffer(intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
|
||||
backSurf = strb->surface;
|
||||
}
|
||||
|
||||
backRegion = backSurf->region;
|
||||
srcpitch = backRegion->pitch;
|
||||
|
@@ -2269,8 +2269,6 @@ struct gl_renderbuffer
|
||||
GLubyte StencilBits;
|
||||
GLvoid *Data; /**< This may not be used by some kinds of RBs */
|
||||
|
||||
struct pipe_surface *surface;
|
||||
|
||||
/* Used to wrap one renderbuffer around another: */
|
||||
struct gl_renderbuffer *Wrapped;
|
||||
|
||||
|
@@ -1067,9 +1067,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
rb->PutMonoValues = put_mono_values_ubyte;
|
||||
rb->StencilBits = 8 * sizeof(GLubyte);
|
||||
pixelSize = sizeof(GLubyte);
|
||||
#if 0
|
||||
if (!rb->surface)
|
||||
rb->surface = (struct pipe_surface *)
|
||||
pipe->surface_alloc(pipe, PIPE_FORMAT_U_S8);
|
||||
#endif
|
||||
break;
|
||||
case 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->PutMonoValues = put_mono_values_ushort;
|
||||
rb->DepthBits = 8 * sizeof(GLushort);
|
||||
#if 0
|
||||
if (!rb->surface)
|
||||
rb->surface = (struct pipe_surface *)
|
||||
pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z16);
|
||||
#endif
|
||||
pixelSize = sizeof(GLushort);
|
||||
break;
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
@@ -1125,9 +1129,11 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
rb->_ActualFormat = GL_DEPTH_COMPONENT32;
|
||||
rb->DepthBits = 32;
|
||||
}
|
||||
#if 0
|
||||
if (!rb->surface)
|
||||
rb->surface = (struct pipe_surface *)
|
||||
pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z32);
|
||||
#endif
|
||||
pixelSize = sizeof(GLuint);
|
||||
break;
|
||||
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->DepthBits = 24;
|
||||
rb->StencilBits = 8;
|
||||
#if 0
|
||||
if (!rb->surface)
|
||||
rb->surface = (struct pipe_surface *)
|
||||
pipe->surface_alloc(pipe, PIPE_FORMAT_S8_Z24);
|
||||
#endif
|
||||
pixelSize = sizeof(GLuint);
|
||||
break;
|
||||
case GL_COLOR_INDEX8_EXT:
|
||||
@@ -1210,7 +1218,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
ASSERT(rb->PutMonoValues);
|
||||
|
||||
/* free old buffer storage */
|
||||
if (rb->surface) {
|
||||
if (0/**rb->surface**/) {
|
||||
/* pipe_surface/region */
|
||||
}
|
||||
else if (rb->Data) {
|
||||
@@ -1221,8 +1229,9 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
|
||||
if (width > 0 && height > 0) {
|
||||
/* allocate new buffer storage */
|
||||
if (rb->surface) {
|
||||
if (0/**rb->surface**/) {
|
||||
/* pipe_surface/region */
|
||||
#if 0
|
||||
if (rb->surface->region) {
|
||||
pipe->region_unmap(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 */
|
||||
pipe->region_map(pipe, rb->surface->region);
|
||||
rb->Data = rb->surface->region->map;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* legacy renderbuffer (this will go away) */
|
||||
|
@@ -260,8 +260,6 @@ struct pipe_surface
|
||||
GLuint offset; /**< offset from start of region, in bytes */
|
||||
GLint refcount;
|
||||
|
||||
void *rb; /**< Ptr back to renderbuffer (temporary?) */
|
||||
|
||||
/** get block/tile of pixels from surface */
|
||||
void (*get_tile)(struct pipe_surface *ps,
|
||||
GLuint x, GLuint y, GLuint w, GLuint h, GLfloat *p);
|
||||
|
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "st_context.h"
|
||||
#include "st_atom.h"
|
||||
#include "st_cb_fbo.h"
|
||||
#include "pipe/p_context.h"
|
||||
|
||||
|
||||
@@ -44,7 +45,7 @@ static void
|
||||
update_framebuffer_state( struct st_context *st )
|
||||
{
|
||||
struct pipe_framebuffer_state framebuffer;
|
||||
struct gl_renderbuffer *rb;
|
||||
struct st_renderbuffer *strb;
|
||||
GLuint i;
|
||||
|
||||
memset(&framebuffer, 0, sizeof(framebuffer));
|
||||
@@ -54,21 +55,23 @@ update_framebuffer_state( struct st_context *st )
|
||||
*/
|
||||
framebuffer.num_cbufs = st->ctx->DrawBuffer->_NumColorDrawBuffers[0];
|
||||
for (i = 0; i < framebuffer.num_cbufs; i++) {
|
||||
rb = st->ctx->DrawBuffer->_ColorDrawBuffers[0][i];
|
||||
assert(rb->surface);
|
||||
framebuffer.cbufs[i] = rb->surface;
|
||||
strb = st_renderbuffer(st->ctx->DrawBuffer->_ColorDrawBuffers[0][i]);
|
||||
assert(strb->surface);
|
||||
framebuffer.cbufs[i] = strb->surface;
|
||||
}
|
||||
|
||||
rb = st->ctx->DrawBuffer->_DepthBuffer;
|
||||
if (rb) {
|
||||
assert(rb->Wrapped->surface);
|
||||
framebuffer.zbuf = rb->Wrapped->surface;
|
||||
strb = st_renderbuffer(st->ctx->DrawBuffer->_DepthBuffer);
|
||||
if (strb) {
|
||||
strb = st_renderbuffer(strb->Base.Wrapped);
|
||||
assert(strb->surface);
|
||||
framebuffer.zbuf = strb->surface;
|
||||
}
|
||||
|
||||
rb = st->ctx->DrawBuffer->_StencilBuffer;
|
||||
if (rb) {
|
||||
assert(rb->Wrapped->surface);
|
||||
framebuffer.sbuf = rb->Wrapped->surface;
|
||||
strb = st_renderbuffer(st->ctx->DrawBuffer->_StencilBuffer);
|
||||
if (strb) {
|
||||
strb = st_renderbuffer(strb->Base.Wrapped);
|
||||
assert(strb->surface);
|
||||
framebuffer.sbuf = strb->surface;
|
||||
}
|
||||
|
||||
if (memcmp(&framebuffer, &st->state.framebuffer, sizeof(framebuffer)) != 0) {
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include "st_atom.h"
|
||||
#include "st_context.h"
|
||||
#include "st_cb_clear.h"
|
||||
#include "st_cb_fbo.h"
|
||||
#include "st_program.h"
|
||||
#include "st_public.h"
|
||||
#include "pipe/p_context.h"
|
||||
@@ -288,6 +289,8 @@ clear_with_quad(GLcontext *ctx, GLuint x0, GLuint y0,
|
||||
static void
|
||||
clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
{
|
||||
struct st_renderbuffer *strb = st_renderbuffer(rb);
|
||||
|
||||
if (ctx->Color.ColorMask[0] &&
|
||||
ctx->Color.ColorMask[1] &&
|
||||
ctx->Color.ColorMask[2] &&
|
||||
@@ -296,8 +299,8 @@ clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
{
|
||||
/* clear whole buffer w/out masking */
|
||||
GLuint clearValue
|
||||
= color_value(rb->surface->format, ctx->Color.ClearColor);
|
||||
ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue);
|
||||
= color_value(strb->surface->format, ctx->Color.ClearColor);
|
||||
ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
|
||||
}
|
||||
else {
|
||||
/* masking or scissoring */
|
||||
@@ -314,14 +317,16 @@ clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
static void
|
||||
clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
{
|
||||
struct st_renderbuffer *strb = st_renderbuffer(rb);
|
||||
|
||||
if (!ctx->Scissor.Enabled) {
|
||||
/* clear whole buffer w/out masking */
|
||||
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
|
||||
* typically be 64bpp...
|
||||
*/
|
||||
ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue);
|
||||
ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
|
||||
}
|
||||
else {
|
||||
/* scissoring */
|
||||
@@ -339,11 +344,13 @@ clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
static void
|
||||
clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
{
|
||||
struct st_renderbuffer *strb = st_renderbuffer(rb);
|
||||
|
||||
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 */
|
||||
GLuint clearValue = depth_value(rb->surface->format, ctx->Depth.Clear);
|
||||
ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue);
|
||||
GLuint clearValue = depth_value(strb->surface->format, ctx->Depth.Clear);
|
||||
ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
|
||||
}
|
||||
else {
|
||||
/* masking or scissoring or combined z/stencil buffer */
|
||||
@@ -360,14 +367,15 @@ clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
static void
|
||||
clear_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
{
|
||||
struct st_renderbuffer *strb = st_renderbuffer(rb);
|
||||
const GLuint stencilMax = (1 << rb->StencilBits) - 1;
|
||||
GLboolean maskStencil = ctx->Stencil.WriteMask[0] != stencilMax;
|
||||
|
||||
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 */
|
||||
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 {
|
||||
/* masking or scissoring */
|
||||
@@ -384,16 +392,17 @@ clear_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
static void
|
||||
clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
{
|
||||
struct st_renderbuffer *strb = st_renderbuffer(rb);
|
||||
const GLuint stencilMax = 1 << rb->StencilBits;
|
||||
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) {
|
||||
/* 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:
|
||||
clearValue |= ctx->Stencil.Clear << 24;
|
||||
break;
|
||||
@@ -406,7 +415,7 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
assert(0);
|
||||
}
|
||||
|
||||
ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue);
|
||||
ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
|
||||
}
|
||||
else {
|
||||
/* masking or scissoring */
|
||||
|
@@ -46,29 +46,6 @@
|
||||
#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
|
||||
{
|
||||
GLuint format;
|
||||
@@ -168,29 +145,29 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
|
||||
|
||||
cpp = info->size;
|
||||
|
||||
if (!strb->Base.surface) {
|
||||
strb->Base.surface = pipe->surface_alloc(pipe, pipeFormat);
|
||||
if (!strb->Base.surface)
|
||||
if (!strb->surface) {
|
||||
strb->surface = pipe->surface_alloc(pipe, pipeFormat);
|
||||
if (!strb->surface)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* free old region */
|
||||
if (strb->Base.surface->region) {
|
||||
pipe->region_release(pipe, &strb->Base.surface->region);
|
||||
if (strb->surface->region) {
|
||||
pipe->region_release(pipe, &strb->surface->region);
|
||||
}
|
||||
|
||||
/* Choose a pitch to match hardware requirements:
|
||||
*/
|
||||
pitch = ((cpp * width + 63) & ~63) / cpp; /* XXX fix: device-specific */
|
||||
|
||||
strb->Base.surface->region = pipe->region_alloc(pipe, cpp, pitch, height);
|
||||
if (!strb->Base.surface->region)
|
||||
strb->surface->region = pipe->region_alloc(pipe, cpp, pitch, height);
|
||||
if (!strb->surface->region)
|
||||
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.Height = strb->Base.surface->height = height;
|
||||
strb->Base.Width = strb->surface->width = width;
|
||||
strb->Base.Height = strb->surface->height = height;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
@@ -206,11 +183,11 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
|
||||
struct pipe_context *pipe = ctx->st->pipe;
|
||||
struct st_renderbuffer *strb = st_renderbuffer(rb);
|
||||
ASSERT(strb);
|
||||
if (strb && strb->Base.surface) {
|
||||
if (rb->surface->region) {
|
||||
pipe->region_release(pipe, &strb->Base.surface->region);
|
||||
if (strb && strb->surface) {
|
||||
if (strb->surface->region) {
|
||||
pipe->region_release(pipe, &strb->surface->region);
|
||||
}
|
||||
free(strb->Base.surface);
|
||||
free(strb->surface);
|
||||
}
|
||||
free(strb);
|
||||
}
|
||||
@@ -285,28 +262,28 @@ st_new_renderbuffer_fb(struct pipe_region *region, GLuint width, GLuint height)
|
||||
struct gl_renderbuffer *
|
||||
st_new_renderbuffer_fb(GLuint intFormat)
|
||||
{
|
||||
struct st_renderbuffer *irb;
|
||||
struct st_renderbuffer *strb;
|
||||
|
||||
irb = CALLOC_STRUCT(st_renderbuffer);
|
||||
if (!irb) {
|
||||
strb = CALLOC_STRUCT(st_renderbuffer);
|
||||
if (!strb) {
|
||||
_mesa_error(NULL, GL_OUT_OF_MEMORY, "creating renderbuffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_mesa_init_renderbuffer(&irb->Base, 0);
|
||||
irb->Base.ClassID = 0x42; /* XXX temp */
|
||||
irb->Base.InternalFormat = intFormat;
|
||||
_mesa_init_renderbuffer(&strb->Base, 0);
|
||||
strb->Base.ClassID = 0x42; /* XXX temp */
|
||||
strb->Base.InternalFormat = intFormat;
|
||||
|
||||
switch (intFormat) {
|
||||
case GL_RGB5:
|
||||
case GL_RGBA8:
|
||||
irb->Base._BaseFormat = GL_RGBA;
|
||||
strb->Base._BaseFormat = GL_RGBA;
|
||||
break;
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
|
||||
strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
|
||||
break;
|
||||
case GL_DEPTH24_STENCIL8_EXT:
|
||||
irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
|
||||
strb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(NULL,
|
||||
@@ -315,15 +292,14 @@ st_new_renderbuffer_fb(GLuint intFormat)
|
||||
}
|
||||
|
||||
/* st-specific methods */
|
||||
irb->Base.Delete = st_renderbuffer_delete;
|
||||
irb->Base.AllocStorage = st_renderbuffer_alloc_storage;
|
||||
irb->Base.GetPointer = null_get_pointer;
|
||||
/* span routines set in alloc_storage function */
|
||||
strb->Base.Delete = st_renderbuffer_delete;
|
||||
strb->Base.AllocStorage = st_renderbuffer_alloc_storage;
|
||||
strb->Base.GetPointer = null_get_pointer;
|
||||
|
||||
irb->Base.surface = NULL;/*intel_new_surface(intFormat);*/
|
||||
/*irb->Base.surface->rb = irb;*/
|
||||
/* surface is allocate in alloc_renderbuffer_storage() */
|
||||
strb->surface = NULL;
|
||||
|
||||
return &irb->Base;
|
||||
return &strb->Base;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -30,10 +30,25 @@
|
||||
#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 *
|
||||
st_new_renderbuffer_fb(GLuint intFormat);
|
||||
|
||||
|
Reference in New Issue
Block a user