summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_fbo.c18
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_fbo.h14
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_surface.c231
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c8
-rw-r--r--src/mesa/drivers/x11/xm_surface.c288
-rw-r--r--src/mesa/drivers/x11/xmesaP.h14
6 files changed, 234 insertions, 339 deletions
diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c
index a09db46163..5a93eb7ad1 100644
--- a/src/mesa/drivers/dri/i915tex/intel_fbo.c
+++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c
@@ -289,6 +289,12 @@ 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
+
/* This sets the Get/PutRow/Value functions */
intel_set_span_functions(&irb->Base);
@@ -451,6 +457,12 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height,
return irb;
}
+
+/**
+ * Create a new renderbuffer which corresponds to an X window buffer
+ * (color, depth, stencil, etc) - not a user-created GL renderbuffer.
+ * The internal format is set at creation time and does not change.
+ */
struct gl_renderbuffer *
intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat)
{
@@ -472,6 +484,9 @@ intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat)
irb->Base.GetPointer = intel_get_pointer;
/* span routines set in alloc_storage function */
+ irb->Base.surface = intel_new_surface(intFormat);
+ irb->Base.surface->rb = irb;
+
return &irb->Base;
}
@@ -500,6 +515,9 @@ intel_new_renderbuffer(GLcontext * ctx, GLuint name)
irb->Base.GetPointer = intel_get_pointer;
/* span routines set in alloc_storage function */
+ irb->Base.surface = intel_new_surface(0 /*unknown format*/);
+ irb->Base.surface->rb = irb;
+
return &irb->Base;
}
diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.h b/src/mesa/drivers/dri/i915tex/intel_fbo.h
index 1642ce774f..86c8106084 100644
--- a/src/mesa/drivers/dri/i915tex/intel_fbo.h
+++ b/src/mesa/drivers/dri/i915tex/intel_fbo.h
@@ -38,17 +38,6 @@ struct intel_region;
/**
- * Intel "pipe" surface. This is kind of a temporary thing as
- * renderbuffers and surfaces should eventually become one.
- */
-struct intel_surface
-{
- struct softpipe_surface surface; /**< base class */
- struct intel_renderbuffer *rb; /**< ptr back to matching renderbuffer */
-};
-
-
-/**
* Intel framebuffer, derived from gl_framebuffer.
*/
struct intel_framebuffer
@@ -129,5 +118,8 @@ extern struct intel_region *intel_get_rb_region(struct gl_framebuffer *fb,
+extern struct pipe_surface *
+intel_new_surface(GLuint intFormat);
+
#endif /* INTEL_FBO_H */
diff --git a/src/mesa/drivers/dri/i915tex/intel_surface.c b/src/mesa/drivers/dri/i915tex/intel_surface.c
index 3be902cf9c..043c5aa5fe 100644
--- a/src/mesa/drivers/dri/i915tex/intel_surface.c
+++ b/src/mesa/drivers/dri/i915tex/intel_surface.c
@@ -23,27 +23,33 @@
* XXX a lof of this is a temporary kludge
*/
+/**
+ * Note: the arithmetic/addressing in these functions is a little
+ * tricky since we need to invert the Y axis.
+ */
static void
read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y,
GLfloat (*rrrr)[QUAD_SIZE])
{
- struct intel_surface *is = (struct intel_surface *) sps;
- struct intel_renderbuffer *irb = is->rb;
- const GLubyte *src = (const GLubyte *) irb->region->map
- + (y * irb->region->pitch + x) * irb->region->cpp;
+ const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp;
+ const GLint invY = sps->surface.height - y - 1;
+ const GLubyte *src = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp;
GLfloat *dst = (GLfloat *) rrrr;
GLubyte temp[16];
- GLuint i, j;
+ GLuint j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_A8_R8_G8_B8);
- memcpy(temp, src, 8);
- memcpy(temp + 8, src + irb->region->pitch * irb->region->cpp, 8);
+ memcpy(temp + 8, src, 8);
+ memcpy(temp + 0, src + bytesPerRow, 8);
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- dst[j * 4 + i] = UBYTE_TO_FLOAT(temp[i * 4 + j]);
- }
+ for (j = 0; j < 4; j++) {
+ dst[0 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 2]); /*R*/
+ dst[1 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 1]); /*G*/
+ dst[2 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 0]); /*B*/
+ dst[3 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 3]); /*A*/
}
}
@@ -52,45 +58,128 @@ static void
write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y,
GLfloat (*rrrr)[QUAD_SIZE])
{
- struct intel_surface *is = (struct intel_surface *) sps;
- struct intel_renderbuffer *irb = is->rb;
const GLfloat *src = (const GLfloat *) rrrr;
- GLubyte *dst = (GLubyte *) irb->region->map
- + (y * irb->region->pitch + x) * irb->region->cpp;
+ const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp;
+ const GLint invY = sps->surface.height - y - 1;
+ GLubyte *dst = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp;
GLubyte temp[16];
- GLuint i, j;
+ GLuint j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_A8_R8_G8_B8);
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + i], src[i * 4 + j]);
- }
+ for (j = 0; j < 4; j++) {
+ UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 2], src[0 * 4 + j]); /*R*/
+ UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 1], src[1 * 4 + j]); /*G*/
+ UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 0], src[2 * 4 + j]); /*B*/
+ UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 3], src[3 * 4 + j]); /*A*/
}
- memcpy(dst, temp, 8);
- memcpy(dst + irb->region->pitch * irb->region->cpp, temp + 8, 8);
+ memcpy(dst, temp + 8, 8);
+ memcpy(dst + bytesPerRow, temp + 0, 8);
}
+static void
+read_quad_z24(struct softpipe_surface *sps,
+ GLint x, GLint y, GLuint zzzz[QUAD_SIZE])
+{
+ 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);
+
+ 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;
+}
+
+static void
+write_quad_z24(struct softpipe_surface *sps,
+ GLint x, GLint y, const GLuint zzzz[QUAD_SIZE])
+{
+ 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);
+
+ 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[0] = (dst[0] & mask) | zzzz[2];
+ dst[1] = (dst[1] & mask) | zzzz[3];
+}
+
+
+static void
+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);
+
+ assert(sps->surface.format == PIPE_FORMAT_Z24_S8);
+
+ /* extract high byte */
+ ssss[0] = src[0] >> 24;
+ ssss[1] = src[1] >> 24;
+ ssss[2] = src[-sps->surface.width] >> 24;
+ ssss[3] = src[-sps->surface.width + 1] >> 24;
+}
+
+static void
+write_quad_stencil(struct softpipe_surface *sps,
+ GLint x, GLint y, const GLubyte ssss[QUAD_SIZE])
+{
+ 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);
+
+ 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[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 intel_surface *is = (struct intel_surface *) pb;
- struct intel_renderbuffer *irb = is->rb;
- GET_CURRENT_CONTEXT(ctx);
- struct intel_context *intel = intel_context(ctx);
-
+ 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);
- intelFinish(&intel->ctx);
-
/*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_region_map(intel->intelScreen, 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;
}
@@ -98,69 +187,67 @@ map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode)
static void
unmap_surface_buffer(struct pipe_buffer *pb)
{
- struct intel_surface *is = (struct intel_surface *) pb;
- struct intel_renderbuffer *irb = is->rb;
- GET_CURRENT_CONTEXT(ctx);
- struct intel_context *intel = intel_context(ctx);
+ 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_region_unmap(intel->intelScreen, irb->region);
}
pb->ptr = NULL;
+ sps->surface.stride = 0;
+ sps->surface.cpp = 0;
+ sps->surface.ptr = NULL;
+
/*UNLOCK_HARDWARE(intel);*/
}
struct pipe_surface *
-xmesa_get_color_surface(GLcontext *ctx, GLuint i)
+intel_new_surface(GLuint intFormat)
{
- struct intel_context *intel = intel_context(ctx);
- struct intel_framebuffer *intel_fb;
- struct intel_renderbuffer *intel_rb;
-
- intel_fb = (struct intel_framebuffer *) ctx->DrawBuffer;
- intel_rb = intel_fb->color_rb[1];
-
- if (!intel_rb->surface) {
- /* create surface and attach to intel_rb */
- struct intel_surface *is;
- is = CALLOC_STRUCT(intel_surface);
- if (is) {
- is->surface.surface.width = intel_rb->Base.Width;
- is->surface.surface.height = intel_rb->Base.Height;
-
- is->surface.read_quad_f_swz = read_quad_f_swz;
- is->surface.write_quad_f_swz = write_quad_f_swz;
-
- is->surface.surface.buffer.map = map_surface_buffer;
- is->surface.surface.buffer.unmap = unmap_surface_buffer;
-
- is->rb = intel_rb;
- }
- intel_rb->surface = is;
+ struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface);
+ if (!sps)
+ return NULL;
+
+ sps->surface.width = 0; /* set in intel_alloc_renderbuffer_storage() */
+ sps->surface.height = 0;
+
+ if (intFormat == GL_RGBA8) {
+ sps->surface.format = PIPE_FORMAT_U_A8_R8_G8_B8;
+ sps->read_quad_f_swz = read_quad_f_swz;
+ sps->write_quad_f_swz = write_quad_f_swz;
}
- else {
- /* update surface size */
- struct intel_surface *is = intel_rb->surface;
- is->surface.surface.width = intel_rb->Base.Width;
- is->surface.surface.height = intel_rb->Base.Height;
- /* sanity check */
- assert(is->surface.surface.buffer.map == map_surface_buffer);
+ else if (intFormat == GL_RGB5) {
+ sps->surface.format = PIPE_FORMAT_U_R5_G6_B5;
+
}
+ else if (intFormat == GL_DEPTH_COMPONENT16) {
+ sps->surface.format = PIPE_FORMAT_U_Z16;
- return &intel_rb->surface->surface.surface;
-}
+ }
+ else if (intFormat == GL_DEPTH24_STENCIL8_EXT) {
+ sps->surface.format = PIPE_FORMAT_Z24_S8;
+ sps->read_quad_z = read_quad_z24;
+ sps->write_quad_z = write_quad_z24;
+ sps->read_quad_stencil = read_quad_stencil;
+ sps->write_quad_stencil = write_quad_stencil;
+ }
+ else {
+ /* TBD / unknown */
+ }
-struct pipe_surface *
-xmesa_get_z_surface(GLcontext *ctx)
-{
- /* XXX fix */
- return NULL;
+ sps->surface.buffer.map = map_surface_buffer;
+ sps->surface.buffer.unmap = unmap_surface_buffer;
+
+ return &sps->surface;
}
+
struct pipe_surface *
xmesa_get_stencil_surface(GLcontext *ctx)
{
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
index 51d183bb43..8fbd9a783b 100644
--- a/src/mesa/drivers/x11/xm_buffer.c
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -35,6 +35,7 @@
#include "imports.h"
#include "framebuffer.h"
#include "renderbuffer.h"
+#include "pipe/p_state.h"
#if defined(USE_XSHM) && !defined(XFree86Server)
@@ -268,6 +269,8 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->Height = height;
rb->InternalFormat = internalFormat;
+ rb->surface->resize(rb->surface, width, height);
+
return GL_TRUE;
}
@@ -317,6 +320,8 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
xrb->origin4 = NULL;
}
+ rb->surface->resize(rb->surface, width, height);
+
return GL_TRUE;
}
@@ -352,6 +357,9 @@ 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 9d6db2b5ce..17f5f28a9d 100644
--- a/src/mesa/drivers/x11/xm_surface.c
+++ b/src/mesa/drivers/x11/xm_surface.c
@@ -24,7 +24,7 @@
/**
- * \file xm_surface.h
+ * \file xm_surface.c
* Code to allow the softpipe code to write to X windows/buffers.
* This is a bit of a hack for now. We've basically got two different
* abstractions for color buffers: gl_renderbuffer and softpipe_surface.
@@ -48,31 +48,11 @@
#include "pipe/softpipe/sp_surface.h"
-/**
- * An xm_surface is derived from a softpipe_surface
- */
-struct xmesa_surface
-{
- struct softpipe_surface sps;
- struct xmesa_renderbuffer *xrb; /** ptr back to matching xmesa_renderbuffer */
- struct gl_renderbuffer *rb; /* ptr to matching gl_renderbuffer */
-};
-
-
-/**
- * Cast wrapper
- */
-static INLINE struct xmesa_surface *
-xmesa_surface(struct softpipe_surface *sps)
-{
- return (struct xmesa_surface *) sps;
-}
-
-
static void *
map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode)
{
/* no-op */
+ return NULL;
}
@@ -83,6 +63,13 @@ unmap_surface_buffer(struct pipe_buffer *pb)
}
+static INLINE struct xmesa_renderbuffer *
+xmesa_rb(struct softpipe_surface *sps)
+{
+ return (struct xmesa_renderbuffer *) sps->surface.rb;
+}
+
+
/**
* quad reading/writing
* These functions are just wrappers around the existing renderbuffer
@@ -90,11 +77,10 @@ unmap_surface_buffer(struct pipe_buffer *pb)
*/
static void
-read_quad_f(struct softpipe_surface *gs, GLint x, GLint y,
+read_quad_f(struct softpipe_surface *sps, GLint x, GLint y,
GLfloat (*rgba)[NUM_CHANNELS])
{
- struct xmesa_surface *xmsurf = xmesa_surface(gs);
- struct xmesa_renderbuffer *xrb = xmsurf->xrb;
+ struct xmesa_renderbuffer *xrb = xmesa_rb(sps);
GLubyte temp[16];
GLfloat *dst = (GLfloat *) rgba;
GLuint i;
@@ -107,11 +93,10 @@ read_quad_f(struct softpipe_surface *gs, GLint x, GLint y,
}
static void
-read_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y,
+read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y,
GLfloat (*rrrr)[QUAD_SIZE])
{
- struct xmesa_surface *xmsurf = xmesa_surface(gs);
- struct xmesa_renderbuffer *xrb = xmsurf->xrb;
+ struct xmesa_renderbuffer *xrb = xmesa_rb(sps);
GLubyte temp[16];
GLfloat *dst = (GLfloat *) rrrr;
GLuint i, j;
@@ -126,11 +111,10 @@ read_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y,
}
static void
-write_quad_f(struct softpipe_surface *gs, GLint x, GLint y,
+write_quad_f(struct softpipe_surface *sps, GLint x, GLint y,
GLfloat (*rgba)[NUM_CHANNELS])
{
- struct xmesa_surface *xmsurf = xmesa_surface(gs);
- struct xmesa_renderbuffer *xrb = xmsurf->xrb;
+ struct xmesa_renderbuffer *xrb = xmesa_rb(sps);
GLubyte temp[16];
const GLfloat *src = (const GLfloat *) rgba;
GLuint i;
@@ -143,11 +127,10 @@ write_quad_f(struct softpipe_surface *gs, GLint x, GLint y,
}
static void
-write_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y,
+write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y,
GLfloat (*rrrr)[QUAD_SIZE])
{
- struct xmesa_surface *xmsurf = xmesa_surface(gs);
- struct xmesa_renderbuffer *xrb = xmsurf->xrb;
+ struct xmesa_renderbuffer *xrb = xmesa_rb(sps);
GLubyte temp[16];
const GLfloat *src = (const GLfloat *) rrrr;
GLuint i, j;
@@ -162,251 +145,70 @@ write_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y,
}
static void
-read_quad_ub(struct softpipe_surface *gs, GLint x, GLint y,
+read_quad_ub(struct softpipe_surface *sps, GLint x, GLint y,
GLubyte (*rgba)[NUM_CHANNELS])
{
- struct xmesa_surface *xmsurf = xmesa_surface(gs);
- struct xmesa_renderbuffer *xrb = xmsurf->xrb;
+ struct xmesa_renderbuffer *xrb = xmesa_rb(sps);
GET_CURRENT_CONTEXT(ctx);
xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, rgba);
xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, rgba + 2);
}
static void
-write_quad_ub(struct softpipe_surface *gs, GLint x, GLint y,
+write_quad_ub(struct softpipe_surface *sps, GLint x, GLint y,
GLubyte (*rgba)[NUM_CHANNELS])
{
- struct xmesa_surface *xmsurf = xmesa_surface(gs);
- struct xmesa_renderbuffer *xrb = xmsurf->xrb;
+ struct xmesa_renderbuffer *xrb = xmesa_rb(sps);
GET_CURRENT_CONTEXT(ctx);
xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, rgba);
xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, rgba + 2);
}
static void
-write_mono_row_ub(struct softpipe_surface *gs, GLuint count, GLint x, GLint y,
+write_mono_row_ub(struct softpipe_surface *sps, GLuint count, GLint x, GLint y,
GLubyte rgba[NUM_CHANNELS])
{
- struct xmesa_surface *xmsurf = xmesa_surface(gs);
- struct xmesa_renderbuffer *xrb = xmsurf->xrb;
+ struct xmesa_renderbuffer *xrb = xmesa_rb(sps);
GET_CURRENT_CONTEXT(ctx);
xrb->Base.PutMonoRow(ctx, &xrb->Base, count, x, y, rgba, NULL);
}
-static struct xmesa_surface *
-create_surface(XMesaContext xmctx, struct xmesa_renderbuffer *xrb)
-{
- struct xmesa_surface *xmsurf;
-
- xmsurf = CALLOC_STRUCT(xmesa_surface);
- if (xmsurf) {
- xmsurf->xrb = xrb;
- xmsurf->sps.surface.width = xrb->Base.Width;
- xmsurf->sps.surface.height = xrb->Base.Height;
-
- xmsurf->sps.read_quad_f = read_quad_f;
- xmsurf->sps.read_quad_f_swz = read_quad_f_swz;
- xmsurf->sps.read_quad_ub = read_quad_ub;
- xmsurf->sps.write_quad_f = write_quad_f;
- xmsurf->sps.write_quad_f_swz = write_quad_f_swz;
- xmsurf->sps.write_quad_ub = write_quad_ub;
- xmsurf->sps.write_mono_row_ub = write_mono_row_ub;
-
- xmsurf->sps.surface.buffer.map = map_surface_buffer;
- xmsurf->sps.surface.buffer.unmap = unmap_surface_buffer;
-
-#if 0
- if (xrb->ximage) {
- xmsurf->sps.surface.ptr = (GLubyte *) xrb->ximage->data;
- xmsurf->sps.surface.stride = xrb->ximage->bytes_per_line;
- xmsurf->sps.surface.cpp = xrb->ximage->depth;
-
- }
-#endif
- }
- return xmsurf;
-}
-
-
-static void
-free_surface(struct softpipe_surface *sps)
-{
- /* XXX may need to do more in the future */
- free(sps);
-}
-
-
-/**
- * Return generic surface pointer corresponding to the current color buffer.
- */
-struct pipe_surface *
-xmesa_get_color_surface(GLcontext *ctx, GLuint buf)
-{
- XMesaContext xmctx = XMESA_CONTEXT(ctx);
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][buf];
- struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb);
- struct softpipe_surface *sps = (struct softpipe_surface *) xrb->pSurface;
-
- if (!sps) {
- xrb->pSurface = create_surface(xmctx, xrb);
- }
- else if (sps->surface.width != rb->Width ||
- sps->surface.height != rb->Height) {
- free_surface(sps);
- xrb->pSurface = create_surface(xmctx, xrb);
- }
-
- return (struct pipe_surface *) xrb->pSurface;
-}
-
-
-
-
-static void
-read_quad_z(struct softpipe_surface *sps,
- GLint x, GLint y, GLuint zzzz[QUAD_SIZE])
-{
- struct xmesa_surface *xmsurf = xmesa_surface(sps);
- struct gl_renderbuffer *rb = xmsurf->rb;
- GLushort temp[4];
- GLuint i;
- GET_CURRENT_CONTEXT(ctx);
- rb->GetRow(ctx, rb, 2, x, y, temp);
- rb->GetRow(ctx, rb, 2, x, y + 1, temp + 2);
- /* convert from GLushort to GLuint */
- for (i = 0; i < 4; i++) {
- zzzz[i] = temp[i];
- }
-}
-
-static void
-write_quad_z(struct softpipe_surface *sps,
- GLint x, GLint y, const GLuint zzzz[QUAD_SIZE])
-{
- struct xmesa_surface *xmsurf = xmesa_surface(sps);
- struct gl_renderbuffer *rb = xmsurf->rb;
- GLushort temp[4];
- GLuint i;
- GET_CURRENT_CONTEXT(ctx);
- /* convert from GLuint to GLushort */
- for (i = 0; i < 4; i++) {
- temp[i] = zzzz[i];
- }
- rb->PutRow(ctx, rb, 2, x, y, temp, NULL);
- rb->PutRow(ctx, rb, 2, x, y + 1, temp + 2, NULL);
-}
-
-
-static struct xmesa_surface *
-create_z_surface(XMesaContext xmctx, struct gl_renderbuffer *rb)
-{
- struct xmesa_surface *xmsurf;
-
- xmsurf = CALLOC_STRUCT(xmesa_surface);
- if (xmsurf) {
- xmsurf->sps.surface.format = PIPE_FORMAT_U_Z16;
- xmsurf->sps.surface.width = rb->Width;
- xmsurf->sps.surface.height = rb->Height;
- xmsurf->sps.read_quad_z = read_quad_z;
- xmsurf->sps.write_quad_z = write_quad_z;
- xmsurf->rb = rb;
- }
- return xmsurf;
-}
-
-
-
-
static void
-read_quad_stencil(struct softpipe_surface *sps,
- GLint x, GLint y, GLubyte ssss[QUAD_SIZE])
+resize_surface(struct pipe_surface *ps, GLuint width, GLuint height)
{
- struct xmesa_surface *xmsurf = xmesa_surface(sps);
- struct gl_renderbuffer *rb = xmsurf->rb;
- GET_CURRENT_CONTEXT(ctx);
- rb->GetRow(ctx, rb, 2, x, y, ssss);
- rb->GetRow(ctx, rb, 2, x, y + 1, ssss + 2);
-}
-
-static void
-write_quad_stencil(struct softpipe_surface *sps,
- GLint x, GLint y, const GLubyte ssss[QUAD_SIZE])
-{
- struct xmesa_surface *xmsurf = xmesa_surface(sps);
- struct gl_renderbuffer *rb = xmsurf->rb;
- GET_CURRENT_CONTEXT(ctx);
- rb->PutRow(ctx, rb, 2, x, y, ssss, NULL);
- rb->PutRow(ctx, rb, 2, x, y + 1, ssss + 2, NULL);
-}
-
-static struct xmesa_surface *
-create_stencil_surface(XMesaContext xmctx, struct gl_renderbuffer *rb)
-{
- struct xmesa_surface *xmsurf;
-
- xmsurf = CALLOC_STRUCT(xmesa_surface);
- if (xmsurf) {
- xmsurf->sps.surface.format = PIPE_FORMAT_U_S8;
- xmsurf->sps.surface.width = rb->Width;
- xmsurf->sps.surface.height = rb->Height;
- xmsurf->sps.read_quad_stencil = read_quad_stencil;
- xmsurf->sps.write_quad_stencil = write_quad_stencil;
- xmsurf->rb = rb;
- }
- return xmsurf;
+ ps->width = width;
+ ps->height = height;
}
-
-
/**
- * Return a pipe_surface that wraps the current Z/depth buffer.
- * XXX this is pretty much a total hack until gl_renderbuffers and
- * pipe_surfaces are merged...
+ * Called to create a pipe_surface for each X renderbuffer.
*/
struct pipe_surface *
-xmesa_get_z_surface(GLcontext *ctx)
+xmesa_new_surface(struct xmesa_renderbuffer *xrb)
{
- XMesaContext xmctx = XMESA_CONTEXT(ctx);
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_DepthBuffer;
- static struct xmesa_surface *xms = NULL;
+ struct softpipe_surface *sps;
- if (!rb)
+ sps = CALLOC_STRUCT(softpipe_surface);
+ if (!sps)
return NULL;
- if (!xms) {
- xms = create_z_surface(xmctx, rb);
- }
- else if (xms->sps.surface.width != rb->Width ||
- xms->sps.surface.height != rb->Height) {
- free_surface(&xms->sps);
- xms = create_z_surface(xmctx, rb);
- }
-
- return (struct pipe_surface *) &xms->sps.surface;
-}
+ sps->surface.rb = xrb;
+ sps->surface.width = xrb->Base.Width;
+ sps->surface.height = xrb->Base.Height;
+ sps->read_quad_f = read_quad_f;
+ sps->read_quad_f_swz = read_quad_f_swz;
+ sps->read_quad_ub = read_quad_ub;
+ sps->write_quad_f = write_quad_f;
+ sps->write_quad_f_swz = write_quad_f_swz;
+ sps->write_quad_ub = write_quad_ub;
+ sps->write_mono_row_ub = write_mono_row_ub;
-struct pipe_surface *
-xmesa_get_stencil_surface(GLcontext *ctx)
-{
- XMesaContext xmctx = XMESA_CONTEXT(ctx);
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_StencilBuffer;
- static struct xmesa_surface *xms = NULL;
+ sps->surface.buffer.map = map_surface_buffer;
+ sps->surface.buffer.unmap = unmap_surface_buffer;
+ sps->surface.resize = resize_surface;
- if (!rb)
- return NULL;
-
- if (!xms) {
- xms = create_stencil_surface(xmctx, rb);
- }
- else if (xms->sps.surface.width != rb->Width ||
- xms->sps.surface.height != rb->Height) {
- free_surface(&xms->sps);
- xms = create_stencil_surface(xmctx, rb);
- }
-
- return (struct pipe_surface *) &xms->sps.surface;
+ return &sps->surface;
}
-
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 8648b19939..daf6a3f942 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -585,23 +585,11 @@ extern void xmesa_register_swrast_functions( GLcontext *ctx );
#define ENABLE_EXT_timer_query 0 /* may not have 64-bit GLuint64EXT */
#endif
-#if 0
-GLboolean xmesa_get_cbuf_details( GLcontext *ctx,
- void **ptr,
- GLuint *cpp,
- GLint *stride,
- GLuint *format );
-#endif
struct pipe_surface;
-struct pipe_surface *
-xmesa_get_color_surface(GLcontext *ctx, GLuint buf);
-
-struct pipe_surface *
-xmesa_get_z_surface(GLcontext *ctx);
struct pipe_surface *
-xmesa_get_stencil_surface(GLcontext *ctx);
+xmesa_new_surface(struct xmesa_renderbuffer *xrb);
#endif