aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-07-31 17:42:03 -0600
committerBrian <[email protected]>2007-07-31 17:42:03 -0600
commit20adf45c23dd9ec86a1439ad87c1473395bbb1a7 (patch)
treeeee17a4b7b1572651c2b20661b26b82def9cdd34 /src/mesa/main
parent2f245bce420c7a6c6928c4927d0f9a5701cde17f (diff)
Redesign pipe_surface in terms of pipe_region.
struct pipe_buffer goes away. Added basic region functions to softpipe to allocate/release malloc'd regions. Surface-related code is fairly coherent now.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/renderbuffer.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index a900de169e5..7c35575d12e 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -51,7 +51,9 @@
#include "pipe/softpipe/sp_z_surface.h"
#include "pipe/p_state.h"
+#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "state_tracker/st_context.h"
/* 32-bit color index format. Not a public format. */
@@ -949,6 +951,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat,
GLuint width, GLuint height)
{
+ struct pipe_context *pipe = ctx->st->pipe;
GLuint pixelSize;
/* first clear these fields */
@@ -1065,6 +1068,9 @@ _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 (!rb->surface)
+ rb->surface = (struct pipe_surface *)
+ pipe->surface_alloc(pipe, PIPE_FORMAT_U_S8);
break;
case GL_STENCIL_INDEX16_EXT:
rb->_ActualFormat = GL_STENCIL_INDEX16_EXT;
@@ -1095,8 +1101,9 @@ _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);
- rb->surface
- = (struct pipe_surface *) softpipe_new_z_surface(PIPE_FORMAT_U_Z16);
+ if (!rb->surface)
+ rb->surface = (struct pipe_surface *)
+ pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z16);
pixelSize = sizeof(GLushort);
break;
case GL_DEPTH_COMPONENT24:
@@ -1119,8 +1126,9 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->_ActualFormat = GL_DEPTH_COMPONENT32;
rb->DepthBits = 32;
}
- rb->surface
- = (struct pipe_surface *) softpipe_new_z_surface(PIPE_FORMAT_U_Z32);
+ if (!rb->surface)
+ rb->surface = (struct pipe_surface *)
+ pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z32);
pixelSize = sizeof(GLuint);
break;
case GL_DEPTH_STENCIL_EXT:
@@ -1138,8 +1146,9 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoValues = put_mono_values_uint;
rb->DepthBits = 24;
rb->StencilBits = 8;
- rb->surface
- = (struct pipe_surface *) softpipe_new_z_surface(PIPE_FORMAT_Z24_S8);
+ if (!rb->surface)
+ rb->surface = (struct pipe_surface *)
+ pipe->surface_alloc(pipe, PIPE_FORMAT_Z24_S8);
pixelSize = sizeof(GLuint);
break;
case GL_COLOR_INDEX8_EXT:
@@ -1202,28 +1211,33 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
ASSERT(rb->PutMonoValues);
/* free old buffer storage */
- if (rb->Data) {
- if (rb->surface) {
- /* pipe surface */
- }
- else {
- /* legacy renderbuffer */
- _mesa_free(rb->Data);
- }
- rb->Data = NULL;
+ if (rb->surface) {
+ /* pipe_surface/region */
}
+ else if (rb->Data) {
+ /* legacy renderbuffer (this will go away) */
+ _mesa_free(rb->Data);
+ }
+ rb->Data = NULL;
if (width > 0 && height > 0) {
/* allocate new buffer storage */
if (rb->surface) {
- /* pipe surface */
- rb->surface->resize(rb->surface, width, height);
- rb->Data = rb->surface->buffer.ptr;
+ /* pipe_surface/region */
+ if (rb->surface->region) {
+ pipe->region_unmap(pipe, rb->surface->region);
+ pipe->region_release(pipe, &rb->surface->region);
+ }
+ rb->surface->region = pipe->region_alloc(pipe, pixelSize, width, height);
+ /* XXX probably don't want to really map here */
+ pipe->region_map(pipe, rb->surface->region);
+ rb->Data = rb->surface->region->map;
}
else {
- /* legacy renderbuffer */
- rb->Data = _mesa_malloc(width * height * pixelSize);
+ /* legacy renderbuffer (this will go away) */
+ rb->Data = malloc(width * height * pixelSize);
}
+
if (rb->Data == NULL) {
rb->Width = 0;
rb->Height = 0;