The _rgba versions are temporary until the state tracker is updated.
switch (pipeFormat) {
case PIPE_FORMAT_U_A8_R8_G8_B8:
- xms->surface.surface.get_tile = get_tile;
- xms->surface.surface.put_tile = put_tile;
+ xms->surface.get_tile = get_tile;
+ xms->surface.put_tile = put_tile;
break;
case PIPE_FORMAT_S8_Z24:
break;
#include "i915_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
-//#include "main/imports.h"
struct i915_surface
* Share it someday.
*/
static void
-i915_get_tile(struct pipe_surface *ps,
- unsigned x, unsigned y, unsigned w, unsigned h, float *p)
+i915_get_tile_rgba(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h, float *p)
{
const unsigned *src
= ((const unsigned *) (ps->region->map + ps->offset))
static void
-i915_put_tile(struct pipe_surface *ps,
- unsigned x, unsigned y, unsigned w, unsigned h, const float *p)
+i915_put_tile_rgba(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h, const float *p)
{
/* any need to put tiles into i915 surfaces? */
assert(0);
surf->surface.format = format;
surf->surface.refcount = 1;
- surf->surface.get_tile = i915_get_tile;
- surf->surface.put_tile = i915_put_tile;
+ // surf->surface.get_tile = i915_get_tile;
+ // surf->surface.put_tile = i915_put_tile;
return &surf->surface;
}
i915_init_surface_functions(struct i915_context *i915)
{
i915->pipe.surface_alloc = i915_surface_alloc;
+ i915->pipe.get_tile_rgba = i915_get_tile_rgba;
+ i915->pipe.put_tile_rgba = i915_put_tile_rgba;
}
unsigned face, unsigned level,
unsigned zslice);
+ /** Get a block of raw pixel data from a surface */
+ void (*get_tile)(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ void *p, int dst_stride);
+ /** Put a block of raw pixel data into a surface */
+ void (*put_tile)(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ const void *p, int src_stride);
+
+ /* XXX temporary here, move these to softpipe */
+ void (*get_tile_rgba)(struct pipe_context *pipe, struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h, float *p);
+ void (*put_tile_rgba)(struct pipe_context *pipe, struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h, const float *p);
+
+
/*
* Memory region functions
* Some of these may go away...
unsigned width, height;
unsigned offset; /**< offset from start of region, in bytes */
unsigned refcount;
-
- /**
- * Get block/tile of pixels from surface as floats
- * If color surface, return float[4]. If depth surface, return float[1].
- */
- void (*get_tile)(struct pipe_surface *ps,
- uint x, uint y, uint w, uint h, float *p);
-
- /**
- * Put block/tile of pixels into surface as floats
- * If color surface, data is float[4]. If depth surface, data is float[1].
- */
- void (*put_tile)(struct pipe_surface *ps,
- uint x, uint y, uint w, uint h, const float *p);
-
- /** As above, but data is raw pixel data */
- void (*get_tile_raw)(struct pipe_surface *ps,
- uint x, uint y, uint w, uint h, void *p);
- /** As above, but data is raw pixel data */
- void (*put_tile_raw)(struct pipe_surface *ps,
- uint x, uint y, uint w, uint h, const void *p);
};
uint i;
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
- sp_flush_tile_cache(sp->cbuf_cache[i]);
- sp_flush_tile_cache(sp->zbuf_cache);
- sp_flush_tile_cache(sp->sbuf_cache);
+ sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
+ sp_flush_tile_cache(sp, sp->zbuf_cache);
+ sp_flush_tile_cache(sp, sp->sbuf_cache);
for (i = 0; i < sp->framebuffer.num_cbufs; i++) {
struct pipe_surface *ps = sp->framebuffer.cbufs[i];
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
if (softpipe->cbuf_cache[i])
- sp_flush_tile_cache(softpipe->cbuf_cache[i]);
+ sp_flush_tile_cache(softpipe, softpipe->cbuf_cache[i]);
if (softpipe->zbuf_cache)
- sp_flush_tile_cache(softpipe->zbuf_cache);
+ sp_flush_tile_cache(softpipe, softpipe->zbuf_cache);
if (softpipe->sbuf_cache)
- sp_flush_tile_cache(softpipe->sbuf_cache);
+ sp_flush_tile_cache(softpipe, softpipe->sbuf_cache);
/* Need this call for hardware buffers before swapbuffers.
*
uint *dst4 = (uint *) dst;
uint *res4 = (uint *) res;
struct softpipe_cached_tile *
- tile = sp_get_cached_tile(softpipe->cbuf_cache[0], quad->x0, quad->y0);
+ tile = sp_get_cached_tile(softpipe, softpipe->cbuf_cache[0],
+ quad->x0, quad->y0);
uint i, j;
/* get/swizzle dest colors */
static const float zero[4] = { 0, 0, 0, 0 };
static const float one[4] = { 1, 1, 1, 1 };
float source[4][QUAD_SIZE], dest[4][QUAD_SIZE];
- struct softpipe_cached_tile *
- tile = sp_get_cached_tile(softpipe->cbuf_cache[0], quad->x0, quad->y0);
+ struct softpipe_cached_tile *tile
+ = sp_get_cached_tile(softpipe, softpipe->cbuf_cache[0],
+ quad->x0, quad->y0);
uint i, j;
if (softpipe->blend->logicop_enable) {
{
struct softpipe_context *softpipe = qs->softpipe;
float dest[4][QUAD_SIZE];
- struct softpipe_cached_tile *
- tile = sp_get_cached_tile(softpipe->cbuf_cache[0], quad->x0, quad->y0);
+ struct softpipe_cached_tile *tile
+ = sp_get_cached_tile(softpipe,
+ softpipe->cbuf_cache[0], quad->x0, quad->y0);
uint i, j;
/* get/swizzle dest colors */
unsigned zmask = 0;
unsigned j;
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe->zbuf_cache, quad->x0, quad->y0);
+ = sp_get_cached_tile(softpipe, softpipe->zbuf_cache, quad->x0, quad->y0);
assert(sps); /* shouldn't get here if there's no zbuffer */
{
struct softpipe_context *softpipe = qs->softpipe;
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe->cbuf_cache[0], quad->x0, quad->y0);
+ = sp_get_cached_tile(softpipe, softpipe->cbuf_cache[0],
+ quad->x0, quad->y0);
/* in-tile pos: */
const int itx = quad->x0 % TILE_SIZE;
const int ity = quad->y0 % TILE_SIZE;
ubyte ref, wrtMask, valMask;
ubyte stencilVals[QUAD_SIZE];
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe->sbuf_cache, quad->x0, quad->y0);
+ = sp_get_cached_tile(softpipe, softpipe->sbuf_cache, quad->x0, quad->y0);
uint j;
/* choose front or back face function, operator, etc */
/* check if changing cbuf */
if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) {
/* flush old */
- sp_flush_tile_cache(sp->cbuf_cache[i]);
+ sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
/* unmap old */
sps = softpipe_surface(sp->framebuffer.cbufs[i]);
if (sps && sps->surface.region)
/* zbuf changing? */
if (sp->framebuffer.zbuf != fb->zbuf) {
/* flush old */
- sp_flush_tile_cache(sp->zbuf_cache);
+ sp_flush_tile_cache(sp, sp->zbuf_cache);
/* unmap old */
sps = softpipe_surface(sp->framebuffer.zbuf);
if (sps && sps->surface.region)
/* sbuf changing? */
if (sp->framebuffer.sbuf != fb->sbuf) {
/* flush old */
- sp_flush_tile_cache(sp->sbuf_cache_sep);
+ sp_flush_tile_cache(sp, sp->sbuf_cache_sep);
/* unmap old */
sps = softpipe_surface(sp->framebuffer.sbuf);
if (sps && sps->surface.region)
switch (sps->surface.format) {
case PIPE_FORMAT_U_A8_R8_G8_B8:
- sps->surface.get_tile = a8r8g8b8_get_tile;
- sps->surface.put_tile = a8r8g8b8_put_tile;
+ sps->get_tile = a8r8g8b8_get_tile;
+ sps->put_tile = a8r8g8b8_put_tile;
break;
case PIPE_FORMAT_U_A1_R5_G5_B5:
- sps->surface.get_tile = a1r5g5b5_get_tile;
+ sps->get_tile = a1r5g5b5_get_tile;
break;
case PIPE_FORMAT_U_L8:
- sps->surface.get_tile = l8_get_tile;
+ sps->get_tile = l8_get_tile;
break;
case PIPE_FORMAT_U_A8:
- sps->surface.get_tile = a8_get_tile;
+ sps->get_tile = a8_get_tile;
break;
case PIPE_FORMAT_U_I8:
- sps->surface.get_tile = i8_get_tile;
+ sps->get_tile = i8_get_tile;
break;
case PIPE_FORMAT_U_A8_L8:
- sps->surface.get_tile = a8_l8_get_tile;
+ sps->get_tile = a8_l8_get_tile;
break;
case PIPE_FORMAT_S_R16_G16_B16_A16:
- sps->surface.get_tile = r16g16b16a16_get_tile;
- sps->surface.put_tile = r16g16b16a16_put_tile;
+ sps->get_tile = r16g16b16a16_get_tile;
+ sps->put_tile = r16g16b16a16_put_tile;
break;
case PIPE_FORMAT_U_Z16:
- sps->surface.get_tile = z16_get_tile;
- sps->surface.get_tile_raw = get_tile_raw16;
- sps->surface.put_tile_raw = put_tile_raw16;
+ sps->get_tile = z16_get_tile;
+ sps->get_tile_raw = get_tile_raw16;
+ sps->put_tile_raw = put_tile_raw16;
break;
case PIPE_FORMAT_U_Z32:
- sps->surface.get_tile = z32_get_tile;
- sps->surface.get_tile_raw = get_tile_raw32;
- sps->surface.put_tile_raw = put_tile_raw32;
+ sps->get_tile = z32_get_tile;
+ sps->get_tile_raw = get_tile_raw32;
+ sps->put_tile_raw = put_tile_raw32;
break;
case PIPE_FORMAT_S8_Z24:
- sps->surface.get_tile = s8z24_get_tile;
- sps->surface.get_tile_raw = get_tile_raw32;
- sps->surface.put_tile_raw = put_tile_raw32;
+ sps->get_tile = s8z24_get_tile;
+ sps->get_tile_raw = get_tile_raw32;
+ sps->put_tile_raw = put_tile_raw32;
break;
case PIPE_FORMAT_U_S8:
- sps->surface.get_tile_raw = get_tile_raw8;
- sps->surface.put_tile_raw = put_tile_raw8;
+ sps->get_tile_raw = get_tile_raw8;
+ sps->put_tile_raw = put_tile_raw8;
break;
default:
assert(0);
}
+static void
+get_tile_generic(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ void *p, int dst_stride)
+{
+ struct softpipe_surface *sps = softpipe_surface(ps);
+ sps->get_tile_raw(ps, x, y, w, h, p);
+}
+
+
+static void
+put_tile_generic(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ const void *p, int src_stride)
+{
+ struct softpipe_surface *sps = softpipe_surface(ps);
+ sps->put_tile_raw(ps, x, y, w, h, p);
+}
+
+
+static void
+get_tile_rgba_generic(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ float *p)
+{
+ struct softpipe_surface *sps = softpipe_surface(ps);
+ sps->get_tile(ps, x, y, w, h, p);
+}
+
+
+static void
+put_tile_rgba_generic(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ const float *p)
+{
+ struct softpipe_surface *sps = softpipe_surface(ps);
+ sps->put_tile(ps, x, y, w, h, p);
+}
+
+
+
void
sp_init_surface_functions(struct softpipe_context *sp)
{
sp->pipe.surface_alloc = softpipe_surface_alloc;
+
+ sp->pipe.get_tile = get_tile_generic;
+ sp->pipe.put_tile = put_tile_generic;
+
+ sp->pipe.get_tile_rgba = get_tile_rgba_generic;
+ sp->pipe.put_tile_rgba = put_tile_rgba_generic;
}
struct softpipe_surface {
struct pipe_surface surface;
- /* no softpipe-specific extras now */
+ 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);
+ void (*get_tile_raw)(struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h, void *p);
+ void (*put_tile_raw)(struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h, const void *p);
};
void
-sp_flush_tile_cache(struct softpipe_tile_cache *tc)
+sp_flush_tile_cache(struct softpipe_context *softpipe,
+ struct softpipe_tile_cache *tc)
{
+ struct pipe_context *pipe = &softpipe->pipe;
struct pipe_surface *ps = &tc->surface->surface;
boolean is_depth_stencil;
int inuse = 0, pos;
struct softpipe_cached_tile *tile = tc->entries + pos;
if (tile->x >= 0) {
if (is_depth_stencil) {
- ps->put_tile_raw(ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- tile->data.depth32);
+ pipe->put_tile(pipe, ps,
+ tile->x, tile->y, TILE_SIZE, TILE_SIZE,
+ tile->data.depth32, 0/*STRIDE*/);
}
else {
- ps->put_tile(ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
+ pipe->put_tile_rgba(pipe, ps,
+ tile->x, tile->y, TILE_SIZE, TILE_SIZE,
+ (float *) tile->data.color);
}
tile->x = tile->y = -1; /* mark as empty */
struct softpipe_cached_tile *
-sp_get_cached_tile(struct softpipe_tile_cache *tc, int x, int y)
+sp_get_cached_tile(struct softpipe_context *softpipe,
+ struct softpipe_tile_cache *tc, int x, int y)
{
+ struct pipe_context *pipe = &softpipe->pipe;
struct pipe_surface *ps = &tc->surface->surface;
boolean is_depth_stencil
= (ps->format == PIPE_FORMAT_S8_Z24 ||
if (tile->x != -1) {
/* put dirty tile back in framebuffer */
if (is_depth_stencil) {
- ps->put_tile_raw(ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- tile->data.depth32);
+ pipe->put_tile(pipe, ps,
+ tile->x, tile->y, TILE_SIZE, TILE_SIZE,
+ tile->data.depth32, 0 /*STRIDE*/);
}
else {
- ps->put_tile(ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
+ pipe->put_tile_rgba(pipe, ps,
+ tile->x, tile->y, TILE_SIZE, TILE_SIZE,
+ (float *) tile->data.color);
}
}
else {
/* get new tile from framebuffer */
if (is_depth_stencil) {
- ps->get_tile_raw(ps,
- tile_x, tile_y, TILE_SIZE, TILE_SIZE,
- tile->data.depth32);
+ pipe->get_tile(pipe, ps,
+ tile_x, tile_y, TILE_SIZE, TILE_SIZE,
+ tile->data.depth32, 0/*STRIDE*/);
}
else {
- ps->get_tile(ps,
- tile_x, tile_y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
+ pipe->get_tile_rgba(pipe, ps,
+ tile_x, tile_y, TILE_SIZE, TILE_SIZE,
+ (float *) tile->data.color);
}
}
struct pipe_surface *ps
= pipe->get_tex_surface(pipe, tc->texture, face, level, z);
- ps->get_tile(ps,
- tile_x, tile_y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
+ pipe->get_tile_rgba(pipe, ps,
+ tile_x, tile_y, TILE_SIZE, TILE_SIZE,
+ (float *) tile->data.color);
pipe_surface_reference(&ps, NULL);
struct pipe_mipmap_tree *texture);
extern void
-sp_flush_tile_cache(struct softpipe_tile_cache *tc);
+sp_flush_tile_cache(struct softpipe_context *softpipe,
+ struct softpipe_tile_cache *tc);
extern void
sp_tile_cache_clear(struct softpipe_tile_cache *tc, const float value[4]);
extern struct softpipe_cached_tile *
-sp_get_cached_tile(struct softpipe_tile_cache *tc, int x, int y);
+sp_get_cached_tile(struct softpipe_context *softpipe,
+ struct softpipe_tile_cache *tc, int x, int y);
extern const struct softpipe_cached_tile *
sp_get_cached_tile_tex(struct pipe_context *pipe,
accBuf[i * 4 + 3] = a;
}
- acc_ps->put_tile(acc_ps, xpos, ypos, width, height, accBuf);
+ pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
free(accBuf);
(void) pipe->region_map(pipe, acc_ps->region);
- acc_ps->get_tile(acc_ps, xpos, ypos, width, height, accBuf);
+ pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
for (i = 0; i < 4 * width * height; i++) {
accBuf[i] = accBuf[i] * scale + bias;
}
- acc_ps->put_tile(acc_ps, xpos, ypos, width, height, accBuf);
+ pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
free(accBuf);
colorMap = pipe->region_map(pipe, color_ps->region);
accMap = pipe->region_map(pipe, acc_ps->region);
- color_ps->get_tile(color_ps, xpos, ypos, width, height, colorBuf);
- acc_ps->get_tile(acc_ps, xpos, ypos, width, height, accBuf);
+ pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf);
+ pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
for (i = 0; i < 4 * width * height; i++) {
accBuf[i] = accBuf[i] + colorBuf[i] * value;
}
- acc_ps->put_tile(acc_ps, xpos, ypos, width, height, accBuf);
+ pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
free(colorBuf);
free(accBuf);
(void) pipe->region_map(pipe, color_ps->region);
(void) pipe->region_map(pipe, acc_ps->region);
- color_ps->get_tile(color_ps, xpos, ypos, width, height, buf);
+ pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf);
for (i = 0; i < 4 * width * height; i++) {
buf[i] = buf[i] * value;
}
- acc_ps->put_tile(acc_ps, xpos, ypos, width, height, buf);
+ pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf);
free(buf);
(void) pipe->region_map(pipe, color_ps->region);
(void) pipe->region_map(pipe, acc_ps->region);
- acc_ps->get_tile(acc_ps, xpos, ypos, width, height, abuf);
+ pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf);
if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) {
cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- color_ps->get_tile(color_ps, xpos, ypos, width, height, cbuf);
+ pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, cbuf);
}
for (i = 0; i < width * height; i++) {
}
}
- color_ps->put_tile(color_ps, xpos, ypos, width, height, abuf);
+ pipe->put_tile_rgba(pipe, color_ps, xpos, ypos, width, height, abuf);
free(abuf);
if (cbuf)
(void) pipe->region_map(pipe, psRead->region);
(void) pipe->region_map(pipe, psTex->region);
- psRead->get_tile(psRead, srcx, srcy, width, height, buf);
- psTex->put_tile(psTex, 0, 0, width, height, buf);
+ pipe->get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf);
+ pipe->put_tile_rgba(pipe, psTex, 0, 0, width, height, buf);
pipe->region_unmap(pipe, psRead->region);
pipe->region_unmap(pipe, psTex->region);
/* Do a row at a time to flip image data vertically */
for (i = 0; i < height; i++) {
- strb->surface->get_tile(strb->surface, x, y, width, 1, df);
+ pipe->get_tile_rgba(pipe, strb->surface, x, y, width, 1, df);
y += yStep;
df += dfStride;
if (!dfStride) {
/* do copy row by row */
for (row = 0; row < height; row++) {
- src_surf->get_tile(src_surf, srcX, srcY + row, width, 1, data);
+ pipe->get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, data);
/* XXX we're ignoring convolution for now */
if (ctx->_ImageTransferState) {
width, (GLfloat (*)[4])data);
}
- dest_surf->put_tile(dest_surf, destX, destY, width, 1, data);
+ pipe->put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, data);
destY += yStep;
}