* \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.
+ * abstractions for color buffers: gl_renderbuffer and pipe_surface.
* They'll need to get merged someday...
* For now, they're separate things that point to each other.
*/
} while(0)
-static INLINE struct xmesa_surface *
-xmesa_surf(struct softpipe_surface *sps)
-{
- return (struct xmesa_surface *) sps;
-}
-
-
static INLINE struct xmesa_surface *
xmesa_surface(struct pipe_surface *ps)
{
static INLINE struct xmesa_renderbuffer *
-xmesa_rb(struct softpipe_surface *sps)
+xmesa_rb(struct pipe_surface *ps)
{
- struct xmesa_surface *xms = xmesa_surf(sps);
+ struct xmesa_surface *xms = xmesa_surface(ps);
return xms->xrb;
}
xms->surface.format = pipeFormat;
xms->surface.refcount = 1;
-#if 0
- /* some of the functions plugged in by this call will get overridden */
- softpipe_init_surface_funcs(&xms->surface);
-#endif
-
-#if 0
- switch (pipeFormat) {
- case PIPE_FORMAT_U_A8_R8_G8_B8:
- xms->surface.get_tile = get_tile;
- xms->surface.put_tile = put_tile;
- break;
- case PIPE_FORMAT_S8_Z24:
- break;
- default:
- abort();
- }
-#endif
-
/* 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()
xms->surface.format = pipeFormat;
xms->surface.refcount = 1;
-#if 0
- /*
- * This is really just a softpipe surface, not an XImage/Pixmap surface.
- */
- softpipe_init_surface_funcs(&xms->surface);
-#endif
+
return &xms->surface;
}
void
xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value)
{
- struct xmesa_renderbuffer *xrb = xmesa_rb((struct softpipe_surface *) ps);
+ struct xmesa_renderbuffer *xrb = xmesa_rb(ps);
/* XXX actually, we should just discard any cached tiles from this
* surface since we don't want to accidentally re-use them after clearing.
{
struct softpipe_context *sp = softpipe_context(pipe);
- struct softpipe_surface *sps = softpipe_surface(ps);
- if (sps == sp_tile_cache_get_surface(sp->cbuf_cache[0])) {
+ if (ps == sp_tile_cache_get_surface(sp->cbuf_cache[0])) {
float clear[4];
clear[0] = 0.2; /* XXX hack */
clear[1] = 0.2;
unsigned clearValue)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- struct softpipe_surface *sps = softpipe_surface(ps);
unsigned x, y, w, h;
softpipe_update_derived(softpipe); /* not needed?? */
assert(w <= ps->region->pitch);
assert(h <= ps->region->height);
- if (sps == sp_tile_cache_get_surface(softpipe->zbuf_cache)) {
+ if (ps == sp_tile_cache_get_surface(softpipe->zbuf_cache)) {
float clear[4];
clear[0] = 1.0; /* XXX hack */
sp_tile_cache_clear(softpipe->zbuf_cache, clear);
}
- else if (sps == sp_tile_cache_get_surface(softpipe->cbuf_cache[0])) {
+ else if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[0])) {
float clear[4];
clear[0] = 0.2; /* XXX hack */
clear[1] = 0.2; /* XXX hack */
#if 0
- sp_clear_tile_cache(sps, clearValue);
+ sp_clear_tile_cache(ps, clearValue);
#endif
}
#include "sp_quad.h"
-struct softpipe_surface;
struct softpipe_winsys;
struct draw_context;
struct draw_stage;
sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
- struct softpipe_surface *sps = softpipe_surface(softpipe->framebuffer.zbuf);
- const uint format = sps->surface.format;
+ struct pipe_surface *ps = softpipe->framebuffer.zbuf;
+ const uint format = ps->format;
unsigned bzzzz[QUAD_SIZE]; /**< Z values fetched from depth buffer */
unsigned qzzzz[QUAD_SIZE]; /**< Z values from the quad */
unsigned zmask = 0;
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe, softpipe->zbuf_cache, quad->x0, quad->y0);
- assert(sps); /* shouldn't get here if there's no zbuffer */
+ assert(ps); /* shouldn't get here if there's no zbuffer */
/*
* Convert quad's float depth values to int depth values (qzzzz).
stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
- struct softpipe_surface *sps = softpipe_surface(softpipe->framebuffer.sbuf);
+ struct pipe_surface *ps = softpipe->framebuffer.sbuf;
unsigned func, zFailOp, zPassOp, failOp;
ubyte ref, wrtMask, valMask;
ubyte stencilVals[QUAD_SIZE];
valMask = softpipe->depth_stencil->stencil.value_mask[0];
}
- assert(sps); /* shouldn't get here if there's no stencil buffer */
+ assert(ps); /* shouldn't get here if there's no stencil buffer */
/* get stencil values from cached tile */
- switch (sps->surface.format) {
+ switch (ps->format) {
case PIPE_FORMAT_S8_Z24:
for (j = 0; j < QUAD_SIZE; j++) {
int x = quad->x0 % TILE_SIZE + (j & 1);
}
/* put new stencil values into cached tile */
- switch (sps->surface.format) {
+ switch (ps->format) {
case PIPE_FORMAT_S8_Z24:
for (j = 0; j < QUAD_SIZE; j++) {
int x = quad->x0 % TILE_SIZE + (j & 1);
const struct pipe_framebuffer_state *fb)
{
struct softpipe_context *sp = softpipe_context(pipe);
- struct softpipe_surface *sps;
+ struct pipe_surface *ps;
uint i;
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
/* flush old */
sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
/* unmap old */
- sps = softpipe_surface(sp->framebuffer.cbufs[i]);
- if (sps && sps->surface.region)
- pipe->region_unmap(pipe, sps->surface.region);
+ ps = sp->framebuffer.cbufs[i];
+ if (ps && ps->region)
+ pipe->region_unmap(pipe, ps->region);
/* map new */
- sps = softpipe_surface(fb->cbufs[i]);
- if (sps)
- pipe->region_map(pipe, sps->surface.region);
+ ps = fb->cbufs[i];
+ if (ps)
+ pipe->region_map(pipe, ps->region);
/* assign new */
sp->framebuffer.cbufs[i] = fb->cbufs[i];
/* update cache */
- sp_tile_cache_set_surface(sp->cbuf_cache[i], sps);
+ sp_tile_cache_set_surface(sp->cbuf_cache[i], ps);
}
}
/* flush old */
sp_flush_tile_cache(sp, sp->zbuf_cache);
/* unmap old */
- sps = softpipe_surface(sp->framebuffer.zbuf);
- if (sps && sps->surface.region)
- pipe->region_unmap(pipe, sps->surface.region);
+ ps = sp->framebuffer.zbuf;
+ if (ps && ps->region)
+ pipe->region_unmap(pipe, ps->region);
if (sp->framebuffer.sbuf == sp->framebuffer.zbuf) {
/* combined z/stencil */
sp->framebuffer.sbuf = NULL;
}
/* map new */
- sps = softpipe_surface(fb->zbuf);
- if (sps)
- pipe->region_map(pipe, sps->surface.region);
+ ps = fb->zbuf;
+ if (ps)
+ pipe->region_map(pipe, ps->region);
/* assign new */
sp->framebuffer.zbuf = fb->zbuf;
/* update cache */
- sp_tile_cache_set_surface(sp->zbuf_cache, sps);
+ sp_tile_cache_set_surface(sp->zbuf_cache, ps);
}
/* XXX combined depth/stencil here */
/* flush old */
sp_flush_tile_cache(sp, sp->sbuf_cache_sep);
/* unmap old */
- sps = softpipe_surface(sp->framebuffer.sbuf);
- if (sps && sps->surface.region)
- pipe->region_unmap(pipe, sps->surface.region);
+ ps = sp->framebuffer.sbuf;
+ if (ps && ps->region)
+ pipe->region_unmap(pipe, ps->region);
/* map new */
- sps = softpipe_surface(fb->sbuf);
- if (sps && fb->sbuf != fb->zbuf)
- pipe->region_map(pipe, sps->surface.region);
+ ps = fb->sbuf;
+ if (ps && fb->sbuf != fb->zbuf)
+ pipe->region_map(pipe, ps->region);
/* assign new */
sp->framebuffer.sbuf = fb->sbuf;
if (fb->sbuf != fb->zbuf) {
/* separate stencil buf */
sp->sbuf_cache = sp->sbuf_cache_sep;
- sp_tile_cache_set_surface(sp->sbuf_cache, sps);
+ sp_tile_cache_set_surface(sp->sbuf_cache, ps);
}
else {
/* combined depth/stencil */
sp->sbuf_cache = sp->zbuf_cache;
- sp_tile_cache_set_surface(sp->sbuf_cache, sps);
+ sp_tile_cache_set_surface(sp->sbuf_cache, ps);
}
}
}
-/**
- * Initialize the quad_read/write and get/put_tile() methods.
- */
-void
-softpipe_init_surface_funcs(struct softpipe_surface *sps)
-{
- assert(sps->surface.format);
-#if 0
- switch (sps->surface.format) {
- case PIPE_FORMAT_U_A8_R8_G8_B8:
- sps->get_tile = a8r8g8b8_get_tile;
- sps->put_tile = a8r8g8b8_put_tile;
- break;
- case PIPE_FORMAT_U_A1_R5_G5_B5:
- sps->get_tile = a1r5g5b5_get_tile;
- break;
- case PIPE_FORMAT_U_L8:
- sps->get_tile = l8_get_tile;
- break;
- case PIPE_FORMAT_U_A8:
- sps->get_tile = a8_get_tile;
- break;
- case PIPE_FORMAT_U_I8:
- sps->get_tile = i8_get_tile;
- break;
- case PIPE_FORMAT_U_A8_L8:
- sps->get_tile = a8_l8_get_tile;
- break;
-
- case PIPE_FORMAT_S_R16_G16_B16_A16:
- sps->get_tile = r16g16b16a16_get_tile;
- sps->put_tile = r16g16b16a16_put_tile;
- break;
-
- case PIPE_FORMAT_U_Z16:
- sps->get_tile = z16_get_tile;
- break;
- case PIPE_FORMAT_U_Z32:
- sps->get_tile = z32_get_tile;
- break;
- case PIPE_FORMAT_S8_Z24:
- sps->get_tile = s8z24_get_tile;
- break;
- case PIPE_FORMAT_U_S8:
- break;
- default:
- assert(0);
- }
-#endif
-}
-
-
-static struct pipe_surface *
-softpipe_surface_alloc(struct pipe_context *pipe, unsigned pipeFormat)
-{
- struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface);
- if (!sps)
- return NULL;
-
- assert(pipeFormat < PIPE_FORMAT_COUNT);
-
- sps->surface.format = pipeFormat;
- sps->surface.refcount = 1;
- softpipe_init_surface_funcs(sps);
-
- return &sps->surface;
-}
-
-
-
-
-
/**
* Called via pipe->get_tex_surface()
* XXX is this in the right place?
void
sp_init_surface_functions(struct softpipe_context *sp)
{
-#if 0
- sp->pipe.surface_alloc = softpipe_surface_alloc;
-#endif
sp->pipe.get_tile = softpipe_get_tile;
sp->pipe.put_tile = softpipe_put_tile;
#include "pipe/p_state.h"
struct pipe_context;
-struct softpipe_surface;
struct softpipe_context;
struct softpipe_tile_cache;
-/**
- * Softpipe surface is derived from pipe_surface.
- */
-struct softpipe_surface {
- struct pipe_surface surface;
-
-#if 0
- /* XXX these are temporary here */
- void (*get_tile)(struct pipe_surface *ps,
- uint x, uint y, uint w, uint h, float *p);
- void (*put_tile)(struct pipe_surface *ps,
- uint x, uint y, uint w, uint h, const float *p);
-#endif
-};
-
extern struct pipe_surface *
softpipe_get_tex_surface(struct pipe_context *pipe,
struct pipe_mipmap_tree *mt,
uint x, uint y, uint w, uint h,
const float *p);
-extern void
-softpipe_init_surface_funcs(struct softpipe_surface *sps);
-
-
-/** Cast wrapper */
-static INLINE struct softpipe_surface *
-softpipe_surface(struct pipe_surface *ps)
-{
- return (struct softpipe_surface *) ps;
-}
-
extern void
sp_init_surface_functions(struct softpipe_context *sp);
struct softpipe_tile_cache
{
- struct softpipe_surface *surface; /**< the surface we're caching */
+ struct pipe_surface *surface; /**< the surface we're caching */
struct pipe_mipmap_tree *texture; /**< if caching a texture */
struct softpipe_cached_tile entries[NUM_ENTRIES];
uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32];
void
sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
- struct softpipe_surface *sps)
+ struct pipe_surface *ps)
{
- tc->surface = sps;
+ tc->surface = ps;
}
-struct softpipe_surface *
+struct pipe_surface *
sp_tile_cache_get_surface(struct softpipe_tile_cache *tc)
{
return tc->surface;
struct softpipe_tile_cache *tc)
{
struct pipe_context *pipe = &softpipe->pipe;
- struct pipe_surface *ps = &tc->surface->surface;
+ struct pipe_surface *ps = tc->surface;
boolean is_depth_stencil;
int inuse = 0, pos;
struct softpipe_tile_cache *tc, int x, int y)
{
struct pipe_context *pipe = &softpipe->pipe;
- struct pipe_surface *ps = &tc->surface->surface;
+ struct pipe_surface *ps = tc->surface;
boolean is_depth_stencil
= (ps->format == PIPE_FORMAT_S8_Z24 ||
ps->format == PIPE_FORMAT_U_Z16 ||
extern void
sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
- struct softpipe_surface *sps);
+ struct pipe_surface *sps);
-extern struct softpipe_surface *
+extern struct pipe_surface *
sp_tile_cache_get_surface(struct softpipe_tile_cache *tc);
extern void