Browse Source

llvmpipe: Cleanup depth-stencil clears.

Only cosmetic changes. No actual practical difference.
tags/snb-magic
José Fonseca 15 years ago
parent
commit
9fe510ef35

+ 25
- 9
src/gallium/drivers/llvmpipe/lp_rast.c View File

@@ -211,8 +211,8 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task,
const union lp_rast_cmd_arg arg)
{
const struct lp_scene *scene = task->scene;
unsigned clear_value = arg.clear_zstencil.value;
unsigned clear_mask = arg.clear_zstencil.mask;
uint32_t clear_value = arg.clear_zstencil.value;
uint32_t clear_mask = arg.clear_zstencil.mask;
const unsigned height = TILE_SIZE / TILE_VECTOR_HEIGHT;
const unsigned width = TILE_SIZE * TILE_VECTOR_HEIGHT;
const unsigned block_size = scene->zsbuf.blocksize;
@@ -220,7 +220,8 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task,
uint8_t *dst;
unsigned i, j;

LP_DBG(DEBUG_RAST, "%s 0x%x%x\n", __FUNCTION__, clear_value, clear_mask);
LP_DBG(DEBUG_RAST, "%s: value=0x%08x, mask=0x%08x\n",
__FUNCTION__, clear_value, clear_mask);

/*
* Clear the aera of the swizzled depth/depth buffer matching this tile, in
@@ -232,16 +233,31 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task,

dst = task->depth_tile;

clear_value &= clear_mask;

switch (block_size) {
case 1:
assert(clear_mask == 0xff);
memset(dst, (uint8_t) clear_value, height * width);
break;
case 2:
for (i = 0; i < height; i++) {
uint16_t *row = (uint16_t *)dst;
for (j = 0; j < width; j++)
*row++ = (uint16_t) clear_value;
dst += dst_stride;
if (clear_mask == 0xffff) {
for (i = 0; i < height; i++) {
uint16_t *row = (uint16_t *)dst;
for (j = 0; j < width; j++)
*row++ = (uint16_t) clear_value;
dst += dst_stride;
}
}
else {
for (i = 0; i < height; i++) {
uint16_t *row = (uint16_t *)dst;
for (j = 0; j < width; j++) {
uint16_t tmp = ~clear_mask & *row;
*row++ = clear_value | tmp;
}
dst += dst_stride;
}
}
break;
case 4:
@@ -258,7 +274,7 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task,
uint32_t *row = (uint32_t *)dst;
for (j = 0; j < width; j++) {
uint32_t tmp = ~clear_mask & *row;
*row++ = (clear_value & clear_mask) | tmp;
*row++ = clear_value | tmp;
}
dst += dst_stride;
}

+ 2
- 2
src/gallium/drivers/llvmpipe/lp_rast.h View File

@@ -149,8 +149,8 @@ union lp_rast_cmd_arg {
const struct lp_rast_state *set_state;
uint8_t clear_color[4];
struct {
unsigned value;
unsigned mask;
uint32_t value;
uint32_t mask;
} clear_zstencil;
struct lp_fence *fence;
struct llvmpipe_query *query_obj;

+ 7
- 4
src/gallium/drivers/llvmpipe/lp_setup.c View File

@@ -377,16 +377,19 @@ lp_setup_try_clear( struct lp_setup_context *setup,
}

if (flags & PIPE_CLEAR_DEPTHSTENCIL) {
unsigned zmask = (flags & PIPE_CLEAR_DEPTH) ? ~0 : 0;
unsigned smask = (flags & PIPE_CLEAR_STENCIL) ? ~0 : 0;
uint32_t zmask = (flags & PIPE_CLEAR_DEPTH) ? ~0 : 0;
uint32_t smask = (flags & PIPE_CLEAR_STENCIL) ? ~0 : 0;

zsvalue = util_pack_z_stencil(setup->fb.zsbuf->format,
depth,
stencil);

zsmask = util_pack_uint_z_stencil(setup->fb.zsbuf->format,

zsmask = util_pack_mask_z_stencil(setup->fb.zsbuf->format,
zmask,
smask);

zsvalue &= zsmask;
}

if (setup->state == SETUP_ACTIVE) {
@@ -431,7 +434,7 @@ lp_setup_try_clear( struct lp_setup_context *setup,
if (flags & PIPE_CLEAR_COLOR) {
memcpy(setup->clear.color.clear_color,
&color_arg,
sizeof color_arg);
sizeof setup->clear.color.clear_color);
}
}

Loading…
Cancel
Save