summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorBrian <brian@i915.localnet.net>2007-07-31 17:42:03 -0600
committerBrian <brian@i915.localnet.net>2007-07-31 17:42:03 -0600
commit20adf45c23dd9ec86a1439ad87c1473395bbb1a7 (patch)
treeeee17a4b7b1572651c2b20661b26b82def9cdd34 /src/mesa/drivers
parent2f245bce420c7a6c6928c4927d0f9a5701cde17f (diff)
Redesign pipe_surface in terms of pipe_region.
struct pipe_buffer goes away. Added basic region functions to softpipe to allocate/release malloc'd regions. Surface-related code is fairly coherent now.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_fbo.c3
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_surface.c85
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c13
-rw-r--r--src/mesa/drivers/x11/xm_surface.c42
-rw-r--r--src/mesa/drivers/x11/xmesaP.h2
5 files changed, 40 insertions, 105 deletions
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