aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_rast_priv.h
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2013-05-01 17:54:08 +0200
committerRoland Scheidegger <[email protected]>2013-05-03 21:36:20 +0200
commitae507b6260f00638b63c22de811cc63b379698bb (patch)
tree55dfcd9f6f8559916bdde5f4e6ae7e4f3fe51468 /src/gallium/drivers/llvmpipe/lp_rast_priv.h
parente495d88453076a4fe552502d66d6a3869ab70e4a (diff)
llvmpipe: get rid of depth swizzling.
Eliminating this we no longer need to copy between linear and swizzled layout. This is probably not quite ideal since it's a bit more work for now, could do some optimizations by moving depth testing outside the fragment shader loop (but tricky for early depth test as we don't have neither the mask nor the interpolated z in the right order handy). The large amount of tile/untile code is no longer needed will be deleted in next commit. No piglit regressions. v2: change a forgotten LAYOUT_NONE to LAYOUT_LINEAR. v3: fix (bogus) uninitialized variable warnings, add comments, fix a bad type Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_rast_priv.h')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast_priv.h105
1 files changed, 66 insertions, 39 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index c0f41f69fe2..7d01da15113 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -140,48 +140,39 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
/**
- * Get the pointer to a 4x4 depth/stencil block.
- * We'll map the z/stencil buffer on demand here.
- * Note that this may be called even when there's no z/stencil buffer - return
- * NULL in that case.
- * \param x, y location of 4x4 block in window coords
+ * Get pointer to the unswizzled color tile
*/
-static INLINE void *
-lp_rast_get_depth_block_pointer(struct lp_rasterizer_task *task,
- unsigned x, unsigned y)
+static INLINE uint8_t *
+lp_rast_get_unswizzled_color_tile_pointer(struct lp_rasterizer_task *task,
+ unsigned buf, enum lp_texture_usage usage)
{
const struct lp_scene *scene = task->scene;
- void *depth;
+ unsigned format_bytes;
- assert(x < scene->tiles_x * TILE_SIZE);
- assert(y < scene->tiles_y * TILE_SIZE);
- assert((x % TILE_VECTOR_WIDTH) == 0);
- assert((y % TILE_VECTOR_HEIGHT) == 0);
+ assert(task->x < scene->tiles_x * TILE_SIZE);
+ assert(task->y < scene->tiles_y * TILE_SIZE);
+ assert(task->x % TILE_SIZE == 0);
+ assert(task->y % TILE_SIZE == 0);
+ assert(buf < scene->fb.nr_cbufs);
- if (!scene->zsbuf.map) {
- /* Either out of memory or no zsbuf. Can't tell without access
- * to the state. Just use dummy tile memory, but don't print
- * the oom warning as this most likely because there is no
- * zsbuf.
- */
- return lp_dummy_tile;
- }
+ if (!task->color_tiles[buf]) {
+ struct pipe_surface *cbuf = scene->fb.cbufs[buf];
+ assert(cbuf);
- depth = (scene->zsbuf.map +
- scene->zsbuf.stride * y +
- scene->zsbuf.blocksize * x * TILE_VECTOR_HEIGHT);
+ format_bytes = util_format_get_blocksize(cbuf->format);
+ task->color_tiles[buf] = scene->cbufs[buf].map + scene->cbufs[buf].stride * task->y + format_bytes * task->x;
+ }
- assert(lp_check_alignment(depth, 16));
- return depth;
+ return task->color_tiles[buf];
}
/**
- * Get pointer to the unswizzled color tile
+ * Get pointer to the unswizzled depth tile
*/
static INLINE uint8_t *
-lp_rast_get_unswizzled_color_tile_pointer(struct lp_rasterizer_task *task,
- unsigned buf, enum lp_texture_usage usage)
+lp_rast_get_unswizzled_depth_tile_pointer(struct lp_rasterizer_task *task,
+ enum lp_texture_usage usage)
{
const struct lp_scene *scene = task->scene;
unsigned format_bytes;
@@ -190,17 +181,16 @@ lp_rast_get_unswizzled_color_tile_pointer(struct lp_rasterizer_task *task,
assert(task->y < scene->tiles_y * TILE_SIZE);
assert(task->x % TILE_SIZE == 0);
assert(task->y % TILE_SIZE == 0);
- assert(buf < scene->fb.nr_cbufs);
- if (!task->color_tiles[buf]) {
- struct pipe_surface *cbuf = scene->fb.cbufs[buf];
- assert(cbuf);
+ if (!task->depth_tile) {
+ struct pipe_surface *dbuf = scene->fb.zsbuf;
+ assert(dbuf);
- format_bytes = util_format_get_blocksize(cbuf->format);
- task->color_tiles[buf] = scene->cbufs[buf].map + scene->cbufs[buf].stride * task->y + format_bytes * task->x;
+ format_bytes = util_format_get_blocksize(dbuf->format);
+ task->depth_tile = scene->zsbuf.map + scene->zsbuf.stride * task->y + format_bytes * task->x;
}
- return task->color_tiles[buf];
+ return task->depth_tile;
}
@@ -237,6 +227,38 @@ lp_rast_get_unswizzled_color_block_pointer(struct lp_rasterizer_task *task,
}
+/**
+ * Get the pointer to an unswizzled 4x4 depth block (within an unswizzled 64x64 tile).
+ * \param x, y location of 4x4 block in window coords
+ */
+static INLINE uint8_t *
+lp_rast_get_unswizzled_depth_block_pointer(struct lp_rasterizer_task *task,
+ unsigned x, unsigned y)
+{
+ unsigned px, py, pixel_offset, format_bytes;
+ uint8_t *depth;
+
+ assert(x < task->scene->tiles_x * TILE_SIZE);
+ assert(y < task->scene->tiles_y * TILE_SIZE);
+ assert((x % TILE_VECTOR_WIDTH) == 0);
+ assert((y % TILE_VECTOR_HEIGHT) == 0);
+
+ format_bytes = util_format_get_blocksize(task->scene->fb.zsbuf->format);
+
+ depth = lp_rast_get_unswizzled_depth_tile_pointer(task, LP_TEX_USAGE_READ_WRITE);
+ assert(depth);
+
+ px = x % TILE_SIZE;
+ py = y % TILE_SIZE;
+ pixel_offset = px * format_bytes + py * task->scene->zsbuf.stride;
+
+ depth = depth + pixel_offset;
+
+ assert(lp_check_alignment(depth, llvmpipe_get_format_alignment(task->scene->fb.zsbuf->format)));
+ return depth;
+}
+
+
/**
* Shade all pixels in a 4x4 block. The fragment code omits the
@@ -253,7 +275,8 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
struct lp_fragment_shader_variant *variant = state->variant;
uint8_t *color[PIPE_MAX_COLOR_BUFS];
unsigned stride[PIPE_MAX_COLOR_BUFS];
- void *depth;
+ void *depth = NULL;
+ unsigned depth_stride = 0;
unsigned i;
/* color buffer */
@@ -263,7 +286,10 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
color[i] = lp_rast_get_unswizzled_color_block_pointer(task, i, x, y);
}
- depth = lp_rast_get_depth_block_pointer(task, x, y);
+ if (scene->zsbuf.map) {
+ depth = lp_rast_get_unswizzled_depth_block_pointer(task, x, y);
+ depth_stride = scene->zsbuf.stride;
+ }
/* run shader on 4x4 block */
BEGIN_JIT_CALL(state, task);
@@ -277,7 +303,8 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
depth,
0xffff,
&task->thread_data,
- stride );
+ stride,
+ depth_stride);
END_JIT_CALL();
}