From 4576d754c98e3fb5d413e294d48fb70a893defcf Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 17:17:44 -0600 Subject: Lots of improvements to the surface-related code. Z testing now works with i915 driver. Add gl_renderbuffer::surface pointer (and reverse pointer). Remove intel_surface and xmesa_surface types - no longer used. --- src/mesa/main/renderbuffer.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/mesa/main/renderbuffer.c') diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 6f1d7c3960..a1412ef007 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -49,6 +49,9 @@ #include "rbadaptors.h" +#include "pipe/softpipe/sp_z_surface.h" +#include "pipe/p_state.h" + /* 32-bit color index format. Not a public format. */ #define COLOR_INDEX32 0x424243 @@ -1091,6 +1094,7 @@ _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(16); pixelSize = sizeof(GLushort); break; case GL_DEPTH_COMPONENT24: @@ -1193,13 +1197,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; -- cgit v1.2.3 From 9bc1c92a0b809c6b60d5e4a2c8909f5f98528919 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 21:39:57 -0600 Subject: 32 and z24s8 softpipe buffers --- src/mesa/main/renderbuffer.c | 8 +- src/mesa/pipe/p_defines.h | 28 +++--- src/mesa/pipe/softpipe/sp_z_surface.c | 159 ++++++++++++++++++++++++++++++---- src/mesa/pipe/softpipe/sp_z_surface.h | 2 +- 4 files changed, 164 insertions(+), 33 deletions(-) (limited to 'src/mesa/main/renderbuffer.c') diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index a1412ef007..a900de169e 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -51,6 +51,7 @@ #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. */ @@ -1094,7 +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(16); + rb->surface + = (struct pipe_surface *) softpipe_new_z_surface(PIPE_FORMAT_U_Z16); pixelSize = sizeof(GLushort); break; case GL_DEPTH_COMPONENT24: @@ -1117,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: @@ -1134,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: diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index 1b799f1451..58f01758e3 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -132,19 +132,21 @@ /** * Texture/surface image formats (preliminary) */ -#define PIPE_FORMAT_U_R8_G8_B8_A8 0 /**< ubyte[4] RGBA */ -#define PIPE_FORMAT_U_A8_R8_G8_B8 1 /**< ubyte[4] ARGB */ -#define PIPE_FORMAT_U_R5_G6_B5 2 /**< 5/6/5 RGB */ -#define PIPE_FORMAT_U_L8 3 /**< ubyte luminance */ -#define PIPE_FORMAT_U_A8 4 /**< ubyte alpha */ -#define PIPE_FORMAT_U_I8 5 /**< ubyte intensity */ -#define PIPE_FORMAT_U_L8_A8 6 /**< ubyte luminance, alpha */ -#define PIPE_FORMAT_U_Z16 7 /**< ushort Z/depth */ -#define PIPE_FORMAT_F_Z32 8 /**< float Z/depth */ -#define PIPE_FORMAT_YCBCR 9 -#define PIPE_FORMAT_YCBCR_REV 10 -#define PIPE_FORMAT_U_S8 11 /**< 8-bit stencil */ -#define PIPE_FORMAT_Z24_S8 12 /**< 24-bit Z + 8-bit stencil */ +#define PIPE_FORMAT_NONE 0 /**< unstructured */ +#define PIPE_FORMAT_U_R8_G8_B8_A8 1 /**< ubyte[4] RGBA */ +#define PIPE_FORMAT_U_A8_R8_G8_B8 2 /**< ubyte[4] ARGB */ +#define PIPE_FORMAT_U_R5_G6_B5 3 /**< 5/6/5 RGB */ +#define PIPE_FORMAT_U_L8 4 /**< ubyte luminance */ +#define PIPE_FORMAT_U_A8 5 /**< ubyte alpha */ +#define PIPE_FORMAT_U_I8 6 /**< ubyte intensity */ +#define PIPE_FORMAT_U_L8_A8 7 /**< ubyte luminance, alpha */ +#define PIPE_FORMAT_YCBCR 8 +#define PIPE_FORMAT_YCBCR_REV 9 +#define PIPE_FORMAT_U_Z16 10 /**< ushort Z/depth */ +#define PIPE_FORMAT_U_Z32 11 /**< uint Z/depth */ +#define PIPE_FORMAT_F_Z32 12 /**< float Z/depth */ +#define PIPE_FORMAT_Z24_S8 13 /**< 24-bit Z + 8-bit stencil */ +#define PIPE_FORMAT_U_S8 14 /**< 8-bit stencil */ /** diff --git a/src/mesa/pipe/softpipe/sp_z_surface.c b/src/mesa/pipe/softpipe/sp_z_surface.c index 662a4a15ee..744737cb6c 100644 --- a/src/mesa/pipe/softpipe/sp_z_surface.c +++ b/src/mesa/pipe/softpipe/sp_z_surface.c @@ -36,38 +36,48 @@ #include "main/imports.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" +#include "sp_context.h" #include "sp_surface.h" #include "sp_z_surface.h" static void* -z16_map(struct pipe_buffer *pb, GLuint access_mode) +z_map(struct pipe_buffer *pb, GLuint access_mode) { struct softpipe_surface *sps = (struct softpipe_surface *) pb; sps->surface.ptr = pb->ptr; + sps->surface.stride = sps->surface.width; return pb->ptr; } static void -z16_unmap(struct pipe_buffer *pb) +z_unmap(struct pipe_buffer *pb) { struct softpipe_surface *sps = (struct softpipe_surface *) pb; sps->surface.ptr = NULL; + sps->surface.stride = 0; } static void -z16_resize(struct pipe_surface *ps, GLuint width, GLuint height) +z_resize(struct pipe_surface *ps, GLuint width, GLuint height) { struct softpipe_surface *sps = (struct softpipe_surface *) ps; if (sps->surface.buffer.ptr) free(sps->surface.buffer.ptr); - ps->buffer.ptr = (GLubyte *) malloc(width * height * sizeof(GLushort)); + sps->surface.stride = sps->surface.width; + if (sps->surface.format == PIPE_FORMAT_U_Z16) + sps->surface.cpp = 2; + else if (sps->surface.format == PIPE_FORMAT_U_Z32 || + sps->surface.format == PIPE_FORMAT_Z24_S8) + sps->surface.cpp = 4; + else + assert(0); + + ps->buffer.ptr = (GLubyte *) malloc(width * height * sps->surface.cpp); ps->width = width; ps->height = height; - sps->surface.stride = sps->surface.width; - sps->surface.cpp = 2; } static void @@ -77,10 +87,12 @@ z16_read_quad_z(struct softpipe_surface *sps, const GLushort *src = (GLushort *) sps->surface.ptr + y * sps->surface.stride + x; + assert(sps->surface.format == PIPE_FORMAT_U_Z16); + /* converting GLushort to GLuint: */ zzzz[0] = src[0]; zzzz[1] = src[1]; - zzzz[2] = src[sps->surface.width]; + zzzz[2] = src[sps->surface.width + 0]; zzzz[3] = src[sps->surface.width + 1]; } @@ -90,29 +102,140 @@ z16_write_quad_z(struct softpipe_surface *sps, { GLushort *dst = (GLushort *) sps->surface.ptr + y * sps->surface.stride + x; + assert(sps->surface.format == PIPE_FORMAT_U_Z16); + /* converting GLuint to GLushort: */ dst[0] = zzzz[0]; dst[1] = zzzz[1]; - dst[sps->surface.width] = zzzz[2]; + dst[sps->surface.width + 0] = zzzz[2]; + dst[sps->surface.width + 1] = zzzz[3]; +} + +static void +z32_read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + const GLuint *src + = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z32); + + zzzz[0] = src[0]; + zzzz[1] = src[1]; + zzzz[2] = src[sps->surface.width + 0]; + zzzz[3] = src[sps->surface.width + 1]; +} + +static void +z32_write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + GLuint *dst = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z32); + + dst[0] = zzzz[0]; + dst[1] = zzzz[1]; + dst[sps->surface.width + 0] = zzzz[2]; dst[sps->surface.width + 1] = zzzz[3]; } +static void +z24s8_read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + const GLuint *src + = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + zzzz[0] = src[0] >> 8; + zzzz[1] = src[1] >> 8; + zzzz[2] = src[sps->surface.width + 0] >> 8; + zzzz[3] = src[sps->surface.width + 1] >> 8; +} + +static void +z24s8_write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + GLuint *dst = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(zzzz[0] <= 0xffffff); + + dst[0] = (dst[0] & 0xff) | (zzzz[0] << 8); + dst[1] = (dst[1] & 0xff) | (zzzz[1] << 8); + dst += sps->surface.width; + dst[0] = (dst[0] & 0xff) | (zzzz[2] << 8); + dst[1] = (dst[1] & 0xff) | (zzzz[3] << 8); +} + +static void +z24s8_read_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) +{ + const GLuint *src + = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + ssss[0] = src[0] & 0xff; + ssss[1] = src[1] & 0xff; + ssss[2] = src[sps->surface.width + 0] & 0xff; + ssss[3] = src[sps->surface.width + 1] & 0xff; +} + +static void +z24s8_write_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) +{ + GLuint *dst = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + dst[0] = (dst[0] & 0xffffff00) | ssss[0]; + dst[1] = (dst[1] & 0xffffff00) | ssss[1]; + dst += sps->surface.width; + dst[0] = (dst[0] & 0xffffff00) | ssss[2]; + dst[1] = (dst[1] & 0xffffff00) | ssss[3]; +} + + + +/** + * Create a new software-based Z buffer. + * \param format one of the PIPE_FORMAT_z* formats + */ struct softpipe_surface * -softpipe_new_z_surface(GLuint depth) +softpipe_new_z_surface(GLuint format) { struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface); if (!sps) return NULL; - /* XXX ignoring depth param for now */ - - sps->surface.format = PIPE_FORMAT_U_Z16; - - sps->surface.resize = z16_resize; - sps->surface.buffer.map = z16_map; - sps->surface.buffer.unmap = z16_unmap; - sps->read_quad_z = z16_read_quad_z; - sps->write_quad_z = z16_write_quad_z; + sps->surface.format = format; + sps->surface.resize = z_resize; + sps->surface.buffer.map = z_map; + sps->surface.buffer.unmap = z_unmap; + + if (format == PIPE_FORMAT_U_Z16) { + sps->read_quad_z = z16_read_quad_z; + sps->write_quad_z = z16_write_quad_z; + } + else if (format == PIPE_FORMAT_U_Z32) { + sps->read_quad_z = z32_read_quad_z; + sps->write_quad_z = z32_write_quad_z; + } + else if (format == PIPE_FORMAT_Z24_S8) { + sps->read_quad_z = z24s8_read_quad_z; + sps->write_quad_z = z24s8_write_quad_z; + sps->read_quad_stencil = z24s8_read_quad_stencil; + sps->write_quad_stencil = z24s8_write_quad_stencil; + } + else { + assert(0); + } return sps; } diff --git a/src/mesa/pipe/softpipe/sp_z_surface.h b/src/mesa/pipe/softpipe/sp_z_surface.h index 9c3c43ca57..6a8d89a7c1 100644 --- a/src/mesa/pipe/softpipe/sp_z_surface.h +++ b/src/mesa/pipe/softpipe/sp_z_surface.h @@ -31,7 +31,7 @@ extern struct softpipe_surface * -softpipe_new_z_surface(GLuint depth); +softpipe_new_z_surface(GLuint format); #endif /* SP_Z_SURFACE_H */ -- cgit v1.2.3 From 20adf45c23dd9ec86a1439ad87c1473395bbb1a7 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 31 Jul 2007 17:42:03 -0600 Subject: 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. --- src/mesa/drivers/dri/i915pipe/intel_fbo.c | 3 +- src/mesa/drivers/dri/i915pipe/intel_surface.c | 85 ++-------- src/mesa/drivers/x11/xm_buffer.c | 13 +- src/mesa/drivers/x11/xm_surface.c | 42 ++--- src/mesa/drivers/x11/xmesaP.h | 2 +- src/mesa/main/renderbuffer.c | 54 +++--- src/mesa/pipe/p_context.h | 8 + src/mesa/pipe/p_state.h | 53 ++---- src/mesa/pipe/softpipe/sp_context.c | 19 ++- src/mesa/pipe/softpipe/sp_region.c | 105 ++++++++++++ src/mesa/pipe/softpipe/sp_region.h | 40 +++++ src/mesa/pipe/softpipe/sp_surface.c | 236 ++++++++++++++++++++++++-- src/mesa/pipe/softpipe/sp_surface.h | 7 +- src/mesa/pipe/softpipe/sp_z_surface.c | 138 ++++++--------- src/mesa/sources | 3 +- 15 files changed, 538 insertions(+), 270 deletions(-) create mode 100644 src/mesa/pipe/softpipe/sp_region.c create mode 100644 src/mesa/pipe/softpipe/sp_region.h (limited to 'src/mesa/main/renderbuffer.c') diff --git a/src/mesa/drivers/dri/i915pipe/intel_fbo.c b/src/mesa/drivers/dri/i915pipe/intel_fbo.c index bac2ef8467..1470ce7d82 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_fbo.c +++ b/src/mesa/drivers/dri/i915pipe/intel_fbo.c @@ -291,11 +291,10 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, rb->Width = width; rb->Height = height; -#if 1 /* update the surface's size too */ rb->surface->width = width; rb->surface->height = height; -#endif + rb->surface->region = irb->region; /* This sets the Get/PutRow/Value functions */ intel_set_span_functions(&irb->Base); diff --git a/src/mesa/drivers/dri/i915pipe/intel_surface.c b/src/mesa/drivers/dri/i915pipe/intel_surface.c index 58f5cb5f96..936c9cb5e7 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_surface.c +++ b/src/mesa/drivers/dri/i915pipe/intel_surface.c @@ -33,9 +33,9 @@ static void read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { - const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp; + const GLint bytesPerRow = sps->surface.region->pitch * sps->surface.region->cpp; const GLint invY = sps->surface.height - y - 1; - const GLubyte *src = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp; + const GLubyte *src = sps->surface.region->map + invY * bytesPerRow + x * sps->surface.region->cpp; GLfloat *dst = (GLfloat *) rrrr; GLubyte temp[16]; GLuint j; @@ -59,9 +59,9 @@ write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { const GLfloat *src = (const GLfloat *) rrrr; - const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp; + const GLint bytesPerRow = sps->surface.region->pitch * sps->surface.region->cpp; const GLint invY = sps->surface.height - y - 1; - GLubyte *dst = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp; + GLubyte *dst = sps->surface.region->map + invY * bytesPerRow + x * sps->surface.region->cpp; GLubyte temp[16]; GLuint j; @@ -87,16 +87,16 @@ read_quad_z24(struct softpipe_surface *sps, static const GLuint mask = 0xffffff; const GLint invY = sps->surface.height - y - 1; const GLuint *src - = (GLuint *) (sps->surface.ptr - + (invY * sps->surface.stride + x) * sps->surface.cpp); + = (GLuint *) (sps->surface.region->map + + (invY * sps->surface.region->pitch + x) * sps->surface.region->cpp); assert(sps->surface.format == PIPE_FORMAT_Z24_S8); /* extract lower three bytes */ zzzz[0] = src[0] & mask; zzzz[1] = src[1] & mask; - zzzz[2] = src[-sps->surface.stride] & mask; - zzzz[3] = src[-sps->surface.stride + 1] & mask; + zzzz[2] = src[-sps->surface.region->pitch] & mask; + zzzz[3] = src[-sps->surface.region->pitch + 1] & mask; } static void @@ -106,15 +106,15 @@ write_quad_z24(struct softpipe_surface *sps, static const GLuint mask = 0xff000000; const GLint invY = sps->surface.height - y - 1; GLuint *dst - = (GLuint *) (sps->surface.ptr - + (invY * sps->surface.stride + x) * sps->surface.cpp); + = (GLuint *) (sps->surface.region->map + + (invY * sps->surface.region->pitch + x) * sps->surface.region->cpp); assert(sps->surface.format == PIPE_FORMAT_Z24_S8); /* write lower three bytes */ dst[0] = (dst[0] & mask) | zzzz[0]; dst[1] = (dst[1] & mask) | zzzz[1]; - dst -= sps->surface.stride; + dst -= sps->surface.region->pitch; dst[0] = (dst[0] & mask) | zzzz[2]; dst[1] = (dst[1] & mask) | zzzz[3]; } @@ -125,15 +125,15 @@ read_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) { const GLint invY = sps->surface.height - y - 1; - const GLuint *src = (const GLuint *) (sps->surface.ptr - + (invY * sps->surface.stride + x) * sps->surface.cpp); + const GLuint *src = (const GLuint *) (sps->surface.region->map + + (invY * sps->surface.region->pitch + x) * sps->surface.region->cpp); assert(sps->surface.format == PIPE_FORMAT_Z24_S8); /* extract high byte */ ssss[0] = src[0] >> 24; ssss[1] = src[1] >> 24; - src -= sps->surface.stride; + src -= sps->surface.region->pitch; ssss[2] = src[0] >> 24; ssss[3] = src[1] >> 24; } @@ -144,68 +144,20 @@ write_quad_stencil(struct softpipe_surface *sps, { static const GLuint mask = 0x00ffffff; const GLint invY = sps->surface.height - y - 1; - GLuint *dst = (GLuint *) (sps->surface.ptr - + (invY * sps->surface.stride + x) * sps->surface.cpp); + GLuint *dst = (GLuint *) (sps->surface.region->map + + (invY * sps->surface.region->pitch + x) * sps->surface.region->cpp); assert(sps->surface.format == PIPE_FORMAT_Z24_S8); /* write high byte */ dst[0] = (dst[0] & mask) | (ssss[0] << 24); dst[1] = (dst[1] & mask) | (ssss[1] << 24); - dst -= sps->surface.stride; + dst -= sps->surface.region->pitch; dst[0] = (dst[0] & mask) | (ssss[2] << 24); dst[1] = (dst[1] & mask) | (ssss[3] << 24); } -static void * -map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) pb; - struct intel_renderbuffer *irb = (struct intel_renderbuffer *) sps->surface.rb; - assert(access_mode == PIPE_MAP_READ_WRITE); - - /*LOCK_HARDWARE(intel);*/ - - if (irb->region) { - GET_CURRENT_CONTEXT(ctx); - struct intel_context *intel = intel_context(ctx); -#if 0 - intelFinish(&intel->ctx); /* XXX need this? */ -#endif - intel->pipe->region_map(intel->pipe, irb->region); - } - pb->ptr = irb->region->map; - - sps->surface.stride = irb->region->pitch; - sps->surface.cpp = irb->region->cpp; - sps->surface.ptr = irb->region->map; - - return pb->ptr; -} - - -static void -unmap_surface_buffer(struct pipe_buffer *pb) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) pb; - struct intel_renderbuffer *irb = (struct intel_renderbuffer *) sps->surface.rb; - - if (irb->region) { - GET_CURRENT_CONTEXT(ctx); - struct intel_context *intel = intel_context(ctx); - intel->pipe->region_unmap(intel->pipe, irb->region); - } - pb->ptr = NULL; - - sps->surface.stride = 0; - sps->surface.cpp = 0; - sps->surface.ptr = NULL; - - /*UNLOCK_HARDWARE(intel);*/ -} - - struct pipe_surface * intel_new_surface(GLuint intFormat) { @@ -241,8 +193,5 @@ intel_new_surface(GLuint intFormat) } - sps->surface.buffer.map = map_surface_buffer; - sps->surface.buffer.unmap = unmap_surface_buffer; - return &sps->surface; } diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 8fbd9a783b..5bba52da48 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -269,7 +269,10 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->Height = height; rb->InternalFormat = internalFormat; - rb->surface->resize(rb->surface, width, height); + if (!xrb->Base.surface) + xrb->Base.surface = xmesa_new_surface(ctx, xrb); + xrb->Base.surface->width = width; + xrb->Base.surface->height = height; return GL_TRUE; } @@ -320,7 +323,10 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, xrb->origin4 = NULL; } - rb->surface->resize(rb->surface, width, height); + if (!xrb->Base.surface) + xrb->Base.surface = xmesa_new_surface(ctx, xrb); + xrb->Base.surface->width = width; + xrb->Base.surface->height = height; return GL_TRUE; } @@ -357,9 +363,6 @@ xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, xrb->Base.IndexBits = visual->indexBits; } /* only need to set Red/Green/EtcBits fields for user-created RBs */ - - xrb->Base.surface = xmesa_new_surface(xrb); - } return xrb; } diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 17f5f28a9d..e8e795c00f 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -42,25 +42,11 @@ #include "framebuffer.h" #include "renderbuffer.h" -#include "pipe/p_state.h" +#include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/softpipe/sp_context.h" #include "pipe/softpipe/sp_surface.h" - - -static void * -map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode) -{ - /* no-op */ - return NULL; -} - - -static void -unmap_surface_buffer(struct pipe_buffer *pb) -{ - /* no-op */ -} +#include "state_tracker/st_context.h" static INLINE struct xmesa_renderbuffer * @@ -174,27 +160,22 @@ write_mono_row_ub(struct softpipe_surface *sps, GLuint count, GLint x, GLint y, } -static void -resize_surface(struct pipe_surface *ps, GLuint width, GLuint height) -{ - ps->width = width; - ps->height = height; -} - - /** * Called to create a pipe_surface for each X renderbuffer. + * Note: this is being used instead of pipe->surface_alloc() since we + * have special/unique quad read/write functions for X. */ struct pipe_surface * -xmesa_new_surface(struct xmesa_renderbuffer *xrb) +xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb) { + struct pipe_context *pipe = ctx->st->pipe; struct softpipe_surface *sps; sps = CALLOC_STRUCT(softpipe_surface); if (!sps) return NULL; - sps->surface.rb = xrb; + sps->surface.rb = xrb; /* XXX only needed for quad funcs above */ sps->surface.width = xrb->Base.Width; sps->surface.height = xrb->Base.Height; @@ -206,9 +187,12 @@ xmesa_new_surface(struct xmesa_renderbuffer *xrb) sps->write_quad_ub = write_quad_ub; sps->write_mono_row_ub = write_mono_row_ub; - sps->surface.buffer.map = map_surface_buffer; - sps->surface.buffer.unmap = unmap_surface_buffer; - sps->surface.resize = resize_surface; + /* Note, the region we allocate doesn't actually have any storage + * since we're drawing into an XImage or Pixmap. + * The region's size will get set in the xmesa_alloc_front/back_storage() + * functions. + */ + sps->surface.region = pipe->region_alloc(pipe, 0, 0, 0); return &sps->surface; } diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index daf6a3f942..098b9218ae 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -589,7 +589,7 @@ extern void xmesa_register_swrast_functions( GLcontext *ctx ); struct pipe_surface; struct pipe_surface * -xmesa_new_surface(struct xmesa_renderbuffer *xrb); +xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb); #endif diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index a900de169e..7c35575d12 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; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index bfae55a4ba..b48c7775de 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -116,6 +116,14 @@ struct pipe_context { const struct pipe_viewport_state * ); + /* + * Surface functions + * This might go away... + */ + struct pipe_surface *(*surface_alloc)(struct pipe_context *pipe, + GLuint format); + + /* * Memory region functions * Some of these may go away... diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index d81c3f1778..0767fc2fcb 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -233,51 +233,17 @@ struct pipe_sampler_state /*** - *** Non-state Objects + *** Resource Objects ***/ -/** - * A mappable buffer (vertex data, pixel data, etc) - * XXX replace with "intel_region". - */ -struct pipe_buffer -{ - void (*buffer_data)(struct pipe_buffer *pb, GLuint size, const void *src); - void (*buffer_sub_data)(struct pipe_buffer *pb, GLuint offset, GLuint size, - const void *src); - void *(*map)(struct pipe_buffer *pb, GLuint access_mode); - void (*unmap)(struct pipe_buffer *pb); - GLubyte *ptr; /**< address, only valid while mapped */ - GLuint mode; /**< PIPE_MAP_x, only valid while mapped */ -}; - - -/** - * 2D surface. - * May be a renderbuffer, texture mipmap level, etc. - */ -struct pipe_surface -{ - struct pipe_buffer buffer; /**< surfaces can be mapped */ - GLuint format:5; /**< PIPE_FORMAT_x */ - GLuint width, height; - - GLint stride, cpp; - GLubyte *ptr; /**< only valid while mapped, may not equal buffer->ptr */ - - void *rb; /**< Ptr back to renderbuffer (temporary?) */ - - void (*resize)(struct pipe_surface *ps, GLuint width, GLuint height); -}; - - struct _DriBufferObject; struct intel_buffer_object; struct pipe_region { struct _DriBufferObject *buffer; /**< buffer manager's buffer ID */ + GLuint refcount; /**< Reference count for region */ GLuint cpp; /**< bytes per pixel */ GLuint pitch; /**< in pixels */ @@ -290,6 +256,21 @@ struct pipe_region struct intel_buffer_object *pbo; /* zero-copy uploads */ }; + +/** + * 2D surface. + * May be a renderbuffer, texture mipmap level, etc. + */ +struct pipe_surface +{ + struct pipe_region *region; + GLuint format:5; /**< PIPE_FORMAT_x */ + GLuint width, height; + + void *rb; /**< Ptr back to renderbuffer (temporary?) */ +}; + + /** * Texture object. * Mipmap levels, cube faces, 3D slices can be accessed as surfaces. diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 8655aa83fd..002fe73b59 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -35,6 +35,7 @@ #include "pipe/p_defines.h" #include "sp_context.h" #include "sp_clear.h" +#include "sp_region.h" #include "sp_state.h" #include "sp_surface.h" #include "sp_prim_setup.h" @@ -42,18 +43,16 @@ static void map_surfaces(struct softpipe_context *sp) { + struct pipe_context *pipe = &sp->pipe; GLuint i; for (i = 0; i < sp->framebuffer.num_cbufs; i++) { - struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.cbufs[i]); - struct pipe_buffer *buf = &sps->surface.buffer; - buf->map(buf, PIPE_MAP_READ_WRITE); + struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.cbufs[i]); pipe->region_map(pipe, sps->surface.region); } if (sp->framebuffer.zbuf) { struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.zbuf); - struct pipe_buffer *buf = &sps->surface.buffer; - buf->map(buf, PIPE_MAP_READ_WRITE); + pipe->region_map(pipe, sps->surface.region); } /* XXX depth & stencil bufs */ @@ -62,18 +61,17 @@ static void map_surfaces(struct softpipe_context *sp) static void unmap_surfaces(struct softpipe_context *sp) { + struct pipe_context *pipe = &sp->pipe; GLuint i; for (i = 0; i < sp->framebuffer.num_cbufs; i++) { struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.cbufs[i]); - struct pipe_buffer *buf = &sps->surface.buffer; - buf->unmap(buf); + pipe->region_unmap(pipe, sps->surface.region); } if (sp->framebuffer.zbuf) { struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.zbuf); - struct pipe_buffer *buf = &sps->surface.buffer; - buf->unmap(buf); + pipe->region_unmap(pipe, sps->surface.region); } /* XXX depth & stencil bufs */ } @@ -161,6 +159,9 @@ struct pipe_context *softpipe_create( void ) softpipe->draw = draw_create(); draw_set_setup_stage(softpipe->draw, sp_draw_render_stage(softpipe)); + sp_init_region_functions(softpipe); + sp_init_surface_functions(softpipe); + /* * XXX we could plug GL selection/feedback into the drawing pipeline * by specifying a different setup/render stage. diff --git a/src/mesa/pipe/softpipe/sp_region.c b/src/mesa/pipe/softpipe/sp_region.c new file mode 100644 index 0000000000..04ae5e94f9 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_region.c @@ -0,0 +1,105 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * Software-based region allocation and management. + * A hardware driver would override these functions. + */ + + +#include "sp_context.h" +#include "sp_region.h" +#include "sp_surface.h" +#include "main/imports.h" + + +static struct pipe_region * +sp_region_alloc(struct pipe_context *pipe, + GLuint cpp, GLuint pitch, GLuint height) +{ + struct pipe_region *region = CALLOC_STRUCT(pipe_region); + if (!region) + return NULL; + + region->refcount = 1; + region->cpp = cpp; + region->pitch = pitch; + region->height = height; + region->map = malloc(cpp * pitch * height); + + return region; +} + + +static void +sp_region_release(struct pipe_context *pipe, struct pipe_region **region) +{ + assert((*region)->refcount > 0); + (*region)->refcount--; + + if ((*region)->refcount == 0) { + assert((*region)->map_refcount == 0); + +#if 0 + if ((*region)->pbo) + (*region)->pbo->region = NULL; + (*region)->pbo = NULL; +#endif + + free(*region); + } + *region = NULL; +} + + + +static GLubyte * +sp_region_map(struct pipe_context *pipe, struct pipe_region *region) +{ + region->map_refcount++; + return region->map; +} + + +static void +sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region) +{ + region->map_refcount--; +} + + +void +sp_init_region_functions(struct softpipe_context *sp) +{ + sp->pipe.region_alloc = sp_region_alloc; + sp->pipe.region_release = sp_region_release; + + sp->pipe.region_map = sp_region_map; + sp->pipe.region_unmap = sp_region_unmap; + + /* XXX lots of other region functions needed... */ +} diff --git a/src/mesa/pipe/softpipe/sp_region.h b/src/mesa/pipe/softpipe/sp_region.h new file mode 100644 index 0000000000..432746b27f --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_region.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef SP_REGION_H +#define SP_REGION_H + + +struct softpipe_context; + + +extern void +sp_init_region_functions(struct softpipe_context *sp); + + +#endif /* SP_REGION_H */ diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index 16bbacb12b..cf89d28941 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -28,8 +28,22 @@ #include "sp_context.h" #include "sp_state.h" #include "sp_surface.h" -#include "sp_headers.h" +#include "pipe/p_defines.h" +#include "main/imports.h" + +/** + * Softpipe surface functions. + * Basically, create surface of a particular type, then plug in default + * read/write_quad functions. + * Note that these quad funcs assume the buffer/region is in a linear + * layout with Y=0=bottom. + * If we had swizzled/AOS buffers the read/write functions could be + * simplified a lot.... + */ + + +#if 000 /* OLD... should be recycled... */ static void rgba8_read_quad_f( struct softpipe_surface *gs, GLint x, GLint y, GLfloat (*rgba)[NUM_CHANNELS] ) @@ -98,9 +112,6 @@ static void rgba8_write_quad_f_swz( struct softpipe_surface *gs, } } - - - static void rgba8_read_quad_ub( struct softpipe_surface *gs, GLint x, GLint y, GLubyte (*rgba)[NUM_CHANNELS] ) @@ -118,7 +129,6 @@ static void rgba8_read_quad_ub( struct softpipe_surface *gs, } } - static void rgba8_write_quad_ub( struct softpipe_surface *gs, GLint x, GLint y, GLubyte (*rgba)[NUM_CHANNELS] ) @@ -136,18 +146,216 @@ static void rgba8_write_quad_ub( struct softpipe_surface *gs, } } +#endif + + + +static void +z16_read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + const GLushort *src + = (GLushort *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z16); + + /* converting GLushort to GLuint: */ + zzzz[0] = src[0]; + zzzz[1] = src[1]; + src += sps->surface.region->pitch; + zzzz[2] = src[0]; + zzzz[3] = src[1]; +} + +static void +z16_write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + GLushort *dst = (GLushort *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z16); + + /* converting GLuint to GLushort: */ + dst[0] = zzzz[0]; + dst[1] = zzzz[1]; + dst += sps->surface.region->pitch; + dst[0] = zzzz[2]; + dst[1] = zzzz[3]; +} + +static void +z32_read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + const GLuint *src + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z32); + + zzzz[0] = src[0]; + zzzz[1] = src[1]; + src += sps->surface.region->pitch; + zzzz[2] = src[0]; + zzzz[3] = src[1]; +} + +static void +z32_write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z32); + + dst[0] = zzzz[0]; + dst[1] = zzzz[1]; + dst += sps->surface.region->pitch; + dst[0] = zzzz[2]; + dst[1] = zzzz[3]; +} + +static void +z24s8_read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + const GLuint *src + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + zzzz[0] = src[0] >> 8; + zzzz[1] = src[1] >> 8; + src += sps->surface.region->pitch; + zzzz[2] = src[0] >> 8; + zzzz[3] = src[1] >> 8; +} + +static void +z24s8_write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(zzzz[0] <= 0xffffff); + + dst[0] = (dst[0] & 0xff) | (zzzz[0] << 8); + dst[1] = (dst[1] & 0xff) | (zzzz[1] << 8); + dst += sps->surface.region->pitch; + dst[0] = (dst[0] & 0xff) | (zzzz[2] << 8); + dst[1] = (dst[1] & 0xff) | (zzzz[3] << 8); +} + +static void +z24s8_read_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) +{ + const GLuint *src + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + ssss[0] = src[0] & 0xff; + ssss[1] = src[1] & 0xff; + src += sps->surface.region->pitch; + ssss[2] = src[0] & 0xff; + ssss[3] = src[1] & 0xff; +} +static void +z24s8_write_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) +{ + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + dst[0] = (dst[0] & 0xffffff00) | ssss[0]; + dst[1] = (dst[1] & 0xffffff00) | ssss[1]; + dst += sps->surface.region->pitch; + dst[0] = (dst[0] & 0xffffff00) | ssss[2]; + dst[1] = (dst[1] & 0xffffff00) | ssss[3]; +} -struct softpipe_surface_type gs_rgba8 = { - G_SURFACE_RGBA_8888, - rgba8_read_quad_f, - rgba8_read_quad_f_swz, - rgba8_read_quad_ub, - rgba8_write_quad_f, - rgba8_write_quad_f_swz, - rgba8_write_quad_ub, -}; +static void +s8_read_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) +{ + const GLubyte *src + = sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_S8); + + ssss[0] = src[0]; + ssss[1] = src[1]; + src += sps->surface.region->pitch; + ssss[2] = src[0]; + ssss[3] = src[1]; +} + +static void +s8_write_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) +{ + GLubyte *dst + = sps->surface.region->map + y * sps->surface.region->pitch + x; + assert(sps->surface.format == PIPE_FORMAT_U_S8); + dst[0] = ssss[0]; + dst[1] = ssss[1]; + dst += sps->surface.region->pitch; + dst[0] = ssss[2]; + dst[1] = ssss[3]; +} + + + +static void +init_quad_funcs(struct softpipe_surface *sps) +{ + switch (sps->surface.format) { + case PIPE_FORMAT_U_Z16: + sps->read_quad_z = z16_read_quad_z; + sps->write_quad_z = z16_write_quad_z; + break; + case PIPE_FORMAT_U_Z32: + sps->read_quad_z = z32_read_quad_z; + sps->write_quad_z = z32_write_quad_z; + break; + case PIPE_FORMAT_Z24_S8: + sps->read_quad_z = z24s8_read_quad_z; + sps->write_quad_z = z24s8_write_quad_z; + sps->read_quad_stencil = z24s8_read_quad_stencil; + sps->write_quad_stencil = z24s8_write_quad_stencil; + break; + case PIPE_FORMAT_U_S8: + sps->read_quad_stencil = s8_read_quad_stencil; + sps->write_quad_stencil = s8_write_quad_stencil; + break; + default: + assert(0); + } +} + + +static struct pipe_surface * +sp_surface_alloc(struct pipe_context *pipe, GLenum format) +{ + struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface); + if (!sps) + return NULL; + + sps->surface.format = format; + init_quad_funcs(sps); + + return &sps->surface; +} + + +void +sp_init_surface_functions(struct softpipe_context *sp) +{ + sp->pipe.surface_alloc = sp_surface_alloc; +} diff --git a/src/mesa/pipe/softpipe/sp_surface.h b/src/mesa/pipe/softpipe/sp_surface.h index 3ba732cebe..e8466256db 100644 --- a/src/mesa/pipe/softpipe/sp_surface.h +++ b/src/mesa/pipe/softpipe/sp_surface.h @@ -35,8 +35,7 @@ #include "sp_headers.h" struct softpipe_surface; - -#define G_SURFACE_RGBA_8888 0x1 +struct softpipe_context; /** @@ -98,4 +97,8 @@ softpipe_surface(struct pipe_surface *ps) } +extern void +sp_init_surface_functions(struct softpipe_context *sp); + + #endif /* SP_SURFACE_H */ diff --git a/src/mesa/pipe/softpipe/sp_z_surface.c b/src/mesa/pipe/softpipe/sp_z_surface.c index 744737cb6c..7ff1a0cbc8 100644 --- a/src/mesa/pipe/softpipe/sp_z_surface.c +++ b/src/mesa/pipe/softpipe/sp_z_surface.c @@ -40,75 +40,35 @@ #include "sp_surface.h" #include "sp_z_surface.h" -static void* -z_map(struct pipe_buffer *pb, GLuint access_mode) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) pb; - sps->surface.ptr = pb->ptr; - sps->surface.stride = sps->surface.width; - return pb->ptr; -} - -static void -z_unmap(struct pipe_buffer *pb) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) pb; - sps->surface.ptr = NULL; - sps->surface.stride = 0; -} - -static void -z_resize(struct pipe_surface *ps, GLuint width, GLuint height) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) ps; - - if (sps->surface.buffer.ptr) - free(sps->surface.buffer.ptr); - - sps->surface.stride = sps->surface.width; - if (sps->surface.format == PIPE_FORMAT_U_Z16) - sps->surface.cpp = 2; - else if (sps->surface.format == PIPE_FORMAT_U_Z32 || - sps->surface.format == PIPE_FORMAT_Z24_S8) - sps->surface.cpp = 4; - else - assert(0); - - ps->buffer.ptr = (GLubyte *) malloc(width * height * sps->surface.cpp); - ps->width = width; - ps->height = height; - -} - static void z16_read_quad_z(struct softpipe_surface *sps, GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) { const GLushort *src - = (GLushort *) sps->surface.ptr + y * sps->surface.stride + x; + = (GLushort *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_U_Z16); /* converting GLushort to GLuint: */ zzzz[0] = src[0]; zzzz[1] = src[1]; - zzzz[2] = src[sps->surface.width + 0]; - zzzz[3] = src[sps->surface.width + 1]; + zzzz[2] = src[sps->surface.region->pitch + 0]; + zzzz[3] = src[sps->surface.region->pitch + 1]; } static void z16_write_quad_z(struct softpipe_surface *sps, GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) { - GLushort *dst = (GLushort *) sps->surface.ptr + y * sps->surface.stride + x; + GLushort *dst = (GLushort *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_U_Z16); /* converting GLuint to GLushort: */ dst[0] = zzzz[0]; dst[1] = zzzz[1]; - dst[sps->surface.width + 0] = zzzz[2]; - dst[sps->surface.width + 1] = zzzz[3]; + dst[sps->surface.region->pitch + 0] = zzzz[2]; + dst[sps->surface.region->pitch + 1] = zzzz[3]; } static void @@ -116,28 +76,28 @@ z32_read_quad_z(struct softpipe_surface *sps, GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) { const GLuint *src - = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_U_Z32); zzzz[0] = src[0]; zzzz[1] = src[1]; - zzzz[2] = src[sps->surface.width + 0]; - zzzz[3] = src[sps->surface.width + 1]; + zzzz[2] = src[sps->surface.region->pitch + 0]; + zzzz[3] = src[sps->surface.region->pitch + 1]; } static void z32_write_quad_z(struct softpipe_surface *sps, GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) { - GLuint *dst = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_U_Z32); dst[0] = zzzz[0]; dst[1] = zzzz[1]; - dst[sps->surface.width + 0] = zzzz[2]; - dst[sps->surface.width + 1] = zzzz[3]; + dst[sps->surface.region->pitch + 0] = zzzz[2]; + dst[sps->surface.region->pitch + 1] = zzzz[3]; } static void @@ -145,28 +105,28 @@ z24s8_read_quad_z(struct softpipe_surface *sps, GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) { const GLuint *src - = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_Z24_S8); zzzz[0] = src[0] >> 8; zzzz[1] = src[1] >> 8; - zzzz[2] = src[sps->surface.width + 0] >> 8; - zzzz[3] = src[sps->surface.width + 1] >> 8; + zzzz[2] = src[sps->surface.region->pitch + 0] >> 8; + zzzz[3] = src[sps->surface.region->pitch + 1] >> 8; } static void z24s8_write_quad_z(struct softpipe_surface *sps, GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) { - GLuint *dst = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_Z24_S8); assert(zzzz[0] <= 0xffffff); dst[0] = (dst[0] & 0xff) | (zzzz[0] << 8); dst[1] = (dst[1] & 0xff) | (zzzz[1] << 8); - dst += sps->surface.width; + dst += sps->surface.region->pitch; dst[0] = (dst[0] & 0xff) | (zzzz[2] << 8); dst[1] = (dst[1] & 0xff) | (zzzz[3] << 8); } @@ -176,32 +136,65 @@ z24s8_read_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) { const GLuint *src - = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_Z24_S8); ssss[0] = src[0] & 0xff; ssss[1] = src[1] & 0xff; - ssss[2] = src[sps->surface.width + 0] & 0xff; - ssss[3] = src[sps->surface.width + 1] & 0xff; + ssss[2] = src[sps->surface.region->pitch + 0] & 0xff; + ssss[3] = src[sps->surface.region->pitch + 1] & 0xff; } static void z24s8_write_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) { - GLuint *dst = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_Z24_S8); dst[0] = (dst[0] & 0xffffff00) | ssss[0]; dst[1] = (dst[1] & 0xffffff00) | ssss[1]; - dst += sps->surface.width; + dst += sps->surface.region->pitch; dst[0] = (dst[0] & 0xffffff00) | ssss[2]; dst[1] = (dst[1] & 0xffffff00) | ssss[3]; } +static void +s8_read_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) +{ + const GLubyte *src + = sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_S8); + + ssss[0] = src[0]; + ssss[1] = src[1]; + src += sps->surface.region->pitch; + ssss[2] = src[0]; + ssss[3] = src[1]; +} + +static void +s8_write_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) +{ + GLubyte *dst + = sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_S8); + + dst[0] = ssss[0]; + dst[1] = ssss[1]; + dst += sps->surface.region->pitch; + dst[0] = ssss[2]; + dst[1] = ssss[3]; +} + + /** * Create a new software-based Z buffer. @@ -215,27 +208,6 @@ softpipe_new_z_surface(GLuint format) return NULL; sps->surface.format = format; - sps->surface.resize = z_resize; - sps->surface.buffer.map = z_map; - sps->surface.buffer.unmap = z_unmap; - - if (format == PIPE_FORMAT_U_Z16) { - sps->read_quad_z = z16_read_quad_z; - sps->write_quad_z = z16_write_quad_z; - } - else if (format == PIPE_FORMAT_U_Z32) { - sps->read_quad_z = z32_read_quad_z; - sps->write_quad_z = z32_write_quad_z; - } - else if (format == PIPE_FORMAT_Z24_S8) { - sps->read_quad_z = z24s8_read_quad_z; - sps->write_quad_z = z24s8_write_quad_z; - sps->read_quad_stencil = z24s8_read_quad_stencil; - sps->write_quad_stencil = z24s8_write_quad_stencil; - } - else { - assert(0); - } return sps; } diff --git a/src/mesa/sources b/src/mesa/sources index 32c2ff2350..3b820b71f0 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -157,6 +157,7 @@ VF_SOURCES = \ SOFTPIPE_SOURCES = \ pipe/softpipe/sp_clear.c \ pipe/softpipe/sp_context.c \ + pipe/softpipe/sp_region.c \ pipe/softpipe/sp_quad.c \ pipe/softpipe/sp_quad_alpha_test.c \ pipe/softpipe/sp_quad_blend.c \ @@ -176,7 +177,7 @@ SOFTPIPE_SOURCES = \ pipe/softpipe/sp_state_sampler.c \ pipe/softpipe/sp_state_setup.c \ pipe/softpipe/sp_state_surface.c \ - pipe/softpipe/sp_z_surface.c \ + pipe/softpipe/sp_surface.c \ pipe/softpipe/sp_prim_setup.c DRAW_SOURCES = \ -- cgit v1.2.3 From d28661870a92f0beccd018855030146e01efb02e Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 31 Jul 2007 17:55:32 -0600 Subject: sp_z_surface.h is dead --- src/mesa/main/renderbuffer.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/main/renderbuffer.c') diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 7c35575d12..9509df3159 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -49,7 +49,6 @@ #include "rbadaptors.h" -#include "pipe/softpipe/sp_z_surface.h" #include "pipe/p_state.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" -- cgit v1.2.3 From 5fd46065915d3958569ebb590104b69886352157 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 1 Aug 2007 13:04:58 -0600 Subject: s/Z24_S8/S8_Z24/ (stencil is in the high byte) --- src/mesa/main/renderbuffer.c | 2 +- src/mesa/pipe/p_defines.h | 2 +- src/mesa/pipe/softpipe/sp_clear.c | 2 +- src/mesa/pipe/softpipe/sp_quad_depth_test.c | 2 +- src/mesa/pipe/softpipe/sp_surface.c | 61 +++++++++++++++-------------- 5 files changed, 36 insertions(+), 33 deletions(-) (limited to 'src/mesa/main/renderbuffer.c') diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 9509df3159..d89704196a 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -1147,7 +1147,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->StencilBits = 8; if (!rb->surface) rb->surface = (struct pipe_surface *) - pipe->surface_alloc(pipe, PIPE_FORMAT_Z24_S8); + pipe->surface_alloc(pipe, PIPE_FORMAT_S8_Z24); pixelSize = sizeof(GLuint); break; case GL_COLOR_INDEX8_EXT: diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index 58f01758e3..c92895342e 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -145,7 +145,7 @@ #define PIPE_FORMAT_U_Z16 10 /**< ushort Z/depth */ #define PIPE_FORMAT_U_Z32 11 /**< uint Z/depth */ #define PIPE_FORMAT_F_Z32 12 /**< float Z/depth */ -#define PIPE_FORMAT_Z24_S8 13 /**< 24-bit Z + 8-bit stencil */ +#define PIPE_FORMAT_S8_Z24 13 /**< 8-bit stencil + 24-bit Z */ #define PIPE_FORMAT_U_S8 14 /**< 8-bit stencil */ diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c index 40b1156715..6266d124be 100644 --- a/src/mesa/pipe/softpipe/sp_clear.c +++ b/src/mesa/pipe/softpipe/sp_clear.c @@ -105,7 +105,7 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, case PIPE_FORMAT_U_Z32: clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffffff); break; - case PIPE_FORMAT_Z24_S8: + case PIPE_FORMAT_S8_Z24: clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff); break; default: diff --git a/src/mesa/pipe/softpipe/sp_quad_depth_test.c b/src/mesa/pipe/softpipe/sp_quad_depth_test.c index a26bd51d84..3a8df33e67 100644 --- a/src/mesa/pipe/softpipe/sp_quad_depth_test.c +++ b/src/mesa/pipe/softpipe/sp_quad_depth_test.c @@ -59,7 +59,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad) */ if (sps->surface.format == PIPE_FORMAT_U_Z16) scale = 65535.0; - else if (sps->surface.format == PIPE_FORMAT_Z24_S8) + else if (sps->surface.format == PIPE_FORMAT_S8_Z24) scale = (float) ((1 << 24) - 1); else assert(0); /* XXX fix this someday */ diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index cf89d28941..819243ae6e 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -215,66 +215,69 @@ z32_write_quad_z(struct softpipe_surface *sps, } static void -z24s8_read_quad_z(struct softpipe_surface *sps, +s8z24_read_quad_z(struct softpipe_surface *sps, GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) { + static const GLuint mask = 0x00ffffff; const GLuint *src = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; - assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(sps->surface.format == PIPE_FORMAT_S8_Z24); - zzzz[0] = src[0] >> 8; - zzzz[1] = src[1] >> 8; + zzzz[0] = src[0] & mask; + zzzz[1] = src[1] & mask; src += sps->surface.region->pitch; - zzzz[2] = src[0] >> 8; - zzzz[3] = src[1] >> 8; + zzzz[2] = src[0] & mask; + zzzz[3] = src[1] & mask; } static void -z24s8_write_quad_z(struct softpipe_surface *sps, +s8z24_write_quad_z(struct softpipe_surface *sps, GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) { + static const GLuint mask = 0xff000000; GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; - assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(sps->surface.format == PIPE_FORMAT_S8_Z24); assert(zzzz[0] <= 0xffffff); - dst[0] = (dst[0] & 0xff) | (zzzz[0] << 8); - dst[1] = (dst[1] & 0xff) | (zzzz[1] << 8); + dst[0] = (dst[0] & mask) | zzzz[0]; + dst[1] = (dst[1] & mask) | zzzz[1]; dst += sps->surface.region->pitch; - dst[0] = (dst[0] & 0xff) | (zzzz[2] << 8); - dst[1] = (dst[1] & 0xff) | (zzzz[3] << 8); + dst[0] = (dst[0] & mask) | zzzz[2]; + dst[1] = (dst[1] & mask) | zzzz[3]; } static void -z24s8_read_quad_stencil(struct softpipe_surface *sps, +s8z24_read_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) { const GLuint *src = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; - assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(sps->surface.format == PIPE_FORMAT_S8_Z24); - ssss[0] = src[0] & 0xff; - ssss[1] = src[1] & 0xff; + ssss[0] = src[0] >> 24; + ssss[1] = src[1] >> 24; src += sps->surface.region->pitch; - ssss[2] = src[0] & 0xff; - ssss[3] = src[1] & 0xff; + ssss[2] = src[0] >> 24; + ssss[3] = src[1] >> 24; } static void -z24s8_write_quad_stencil(struct softpipe_surface *sps, +s8z24_write_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) { + static const GLuint mask = 0x00ffffff; GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; - assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(sps->surface.format == PIPE_FORMAT_S8_Z24); - dst[0] = (dst[0] & 0xffffff00) | ssss[0]; - dst[1] = (dst[1] & 0xffffff00) | ssss[1]; + dst[0] = (dst[0] & mask) | (ssss[0] << 24); + dst[1] = (dst[1] & mask) | (ssss[1] << 24); dst += sps->surface.region->pitch; - dst[0] = (dst[0] & 0xffffff00) | ssss[2]; - dst[1] = (dst[1] & 0xffffff00) | ssss[3]; + dst[0] = (dst[0] & mask) | (ssss[2] << 24); + dst[1] = (dst[1] & mask) | (ssss[3] << 24); } @@ -324,11 +327,11 @@ init_quad_funcs(struct softpipe_surface *sps) sps->read_quad_z = z32_read_quad_z; sps->write_quad_z = z32_write_quad_z; break; - case PIPE_FORMAT_Z24_S8: - sps->read_quad_z = z24s8_read_quad_z; - sps->write_quad_z = z24s8_write_quad_z; - sps->read_quad_stencil = z24s8_read_quad_stencil; - sps->write_quad_stencil = z24s8_write_quad_stencil; + case PIPE_FORMAT_S8_Z24: + sps->read_quad_z = s8z24_read_quad_z; + sps->write_quad_z = s8z24_write_quad_z; + sps->read_quad_stencil = s8z24_read_quad_stencil; + sps->write_quad_stencil = s8z24_write_quad_stencil; break; case PIPE_FORMAT_U_S8: sps->read_quad_stencil = s8_read_quad_stencil; -- cgit v1.2.3 From f5713c7d2e7ba8e1170fd9b1dd95379662ab6117 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 9 Aug 2007 12:59:11 -0600 Subject: Checkpoint intel_renderbuffer removal. Remove surface ptr from gl_renderbuffer. Use st_renderbuffer in most places. More clean-up. --- src/mesa/drivers/dri/intel_winsys/intel_blit.c | 14 +++-- src/mesa/main/mtypes.h | 2 - src/mesa/main/renderbuffer.c | 14 ++++- src/mesa/pipe/p_state.h | 2 - src/mesa/state_tracker/st_atom_framebuffer.c | 27 +++++---- src/mesa/state_tracker/st_cb_clear.c | 35 +++++++---- src/mesa/state_tracker/st_cb_fbo.c | 82 +++++++++----------------- src/mesa/state_tracker/st_cb_fbo.h | 23 ++++++-- 8 files changed, 107 insertions(+), 92 deletions(-) (limited to 'src/mesa/main/renderbuffer.c') diff --git a/src/mesa/drivers/dri/intel_winsys/intel_blit.c b/src/mesa/drivers/dri/intel_winsys/intel_blit.c index 48bbbbeac9..aa4135ed2d 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_blit.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_blit.c @@ -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; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d70df5d945..0a64e0c58c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -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; diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index d89704196a..e7aeea8e3e 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -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) */ diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 2dcd2db868..ee29e38a48 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -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); diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 7edd044ad9..f054eb8f21 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -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) { diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index d862f7ba46..4da3a2500d 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -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 */ diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 3cd1fbe851..02bdb5aba5 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -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 diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h index 7f52ab10d7..b2e7ba810c 100644 --- a/src/mesa/state_tracker/st_cb_fbo.h +++ b/src/mesa/state_tracker/st_cb_fbo.h @@ -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); -- cgit v1.2.3 From 6349bd3112116841326885550188224af87ec15c Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 10 Aug 2007 11:16:53 -0600 Subject: remove some temporary hacks --- src/mesa/main/renderbuffer.c | 50 +++----------------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) (limited to 'src/mesa/main/renderbuffer.c') diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index e7aeea8e3e..d576a7a121 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -49,9 +49,6 @@ #include "rbadaptors.h" -#include "pipe/p_state.h" -#include "pipe/p_context.h" -#include "pipe/p_defines.h" #include "state_tracker/st_context.h" @@ -950,7 +947,6 @@ _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 */ @@ -1067,11 +1063,6 @@ _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; @@ -1102,11 +1093,6 @@ _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: @@ -1129,11 +1115,6 @@ _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: @@ -1151,11 +1132,6 @@ _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: @@ -1218,34 +1194,14 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, ASSERT(rb->PutMonoValues); /* free old buffer storage */ - if (0/**rb->surface**/) { - /* pipe_surface/region */ - } - else if (rb->Data) { - /* legacy renderbuffer (this will go away) */ + if (rb->Data) { _mesa_free(rb->Data); + rb->Data = NULL; } - rb->Data = NULL; if (width > 0 && height > 0) { /* allocate new buffer storage */ - 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); - } - 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; -#endif - } - else { - /* legacy renderbuffer (this will go away) */ - rb->Data = malloc(width * height * pixelSize); - } + rb->Data = malloc(width * height * pixelSize); if (rb->Data == NULL) { rb->Width = 0; -- cgit v1.2.3 From 00d90fe845de46649528e3599c0eb42203e78309 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 10 Jun 2008 12:07:38 -0600 Subject: gallium: remove stray include of st_context.h --- src/mesa/main/renderbuffer.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/mesa/main/renderbuffer.c') diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index d576a7a121..3c37d05b40 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -49,8 +49,6 @@ #include "rbadaptors.h" -#include "state_tracker/st_context.h" - /* 32-bit color index format. Not a public format. */ #define COLOR_INDEX32 0x424243 -- cgit v1.2.3