Remove surface ptr from gl_renderbuffer.
Use st_renderbuffer in most places.
More clean-up.
#include "vblank.h"
#include "pipe/p_context.h"
+#include "state_tracker/st_cb_fbo.h"
#define FILE_DEBUG_FLAG DEBUG_BLIT
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;
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;
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;
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:
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:
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:
ASSERT(rb->PutMonoValues);
/* free old buffer storage */
- if (rb->surface) {
+ if (0/**rb->surface**/) {
/* pipe_surface/region */
}
else if (rb->Data) {
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);
/* 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) */
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);
#include "st_context.h"
#include "st_atom.h"
+#include "st_cb_fbo.h"
#include "pipe/p_context.h"
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));
*/
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) {
#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"
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] &&
{
/* 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 */
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 */
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 */
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 */
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;
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 */
#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;
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;
}
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);
}
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,
}
/* 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
#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);