summaryrefslogtreecommitdiff
path: root/src/mesa/main/renderbuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/renderbuffer.c')
-rw-r--r--src/mesa/main/renderbuffer.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index 6f1d7c3960..a900de169e 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -49,6 +49,10 @@
#include "rbadaptors.h"
+#include "pipe/softpipe/sp_z_surface.h"
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+
/* 32-bit color index format. Not a public format. */
#define COLOR_INDEX32 0x424243
@@ -1091,6 +1095,8 @@ _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);
pixelSize = sizeof(GLushort);
break;
case GL_DEPTH_COMPONENT24:
@@ -1113,6 +1119,8 @@ _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);
pixelSize = sizeof(GLuint);
break;
case GL_DEPTH_STENCIL_EXT:
@@ -1130,6 +1138,8 @@ _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);
pixelSize = sizeof(GLuint);
break;
case GL_COLOR_INDEX8_EXT:
@@ -1193,13 +1203,27 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
/* free old buffer storage */
if (rb->Data) {
- _mesa_free(rb->Data);
+ if (rb->surface) {
+ /* pipe surface */
+ }
+ else {
+ /* legacy renderbuffer */
+ _mesa_free(rb->Data);
+ }
rb->Data = NULL;
}
if (width > 0 && height > 0) {
/* allocate new buffer storage */
- rb->Data = _mesa_malloc(width * height * pixelSize);
+ if (rb->surface) {
+ /* pipe surface */
+ rb->surface->resize(rb->surface, width, height);
+ rb->Data = rb->surface->buffer.ptr;
+ }
+ else {
+ /* legacy renderbuffer */
+ rb->Data = _mesa_malloc(width * height * pixelSize);
+ }
if (rb->Data == NULL) {
rb->Width = 0;
rb->Height = 0;