diff options
author | Marek Olšák <maraeo@gmail.com> | 2011-01-28 01:01:01 +0100 |
---|---|---|
committer | Marek Olšák <maraeo@gmail.com> | 2011-01-28 01:04:51 +0100 |
commit | 2050f2ab96f923112d3475a655b31c8f5145a800 (patch) | |
tree | 620884683ee9c64212168d4d986661e82d16d1bf /src/gallium/drivers/r300/r300_texture_desc.c | |
parent | 82e60236a950100bda7e00308c9b57861274608c (diff) | |
download | external_mesa3d-2050f2ab96f923112d3475a655b31c8f5145a800.zip external_mesa3d-2050f2ab96f923112d3475a655b31c8f5145a800.tar.gz external_mesa3d-2050f2ab96f923112d3475a655b31c8f5145a800.tar.bz2 |
r300g: fix and re-enable 8x8 zbuffer compression mode
Also cleanup the whole thing.
Diffstat (limited to 'src/gallium/drivers/r300/r300_texture_desc.c')
-rw-r--r-- | src/gallium/drivers/r300/r300_texture_desc.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/gallium/drivers/r300/r300_texture_desc.c b/src/gallium/drivers/r300/r300_texture_desc.c index bc33871..83469f7 100644 --- a/src/gallium/drivers/r300/r300_texture_desc.c +++ b/src/gallium/drivers/r300/r300_texture_desc.c @@ -334,6 +334,63 @@ static void r300_setup_cbzb_flags(struct r300_screen *rscreen, desc->cbzb_allowed[i] = first_level_valid && desc->macrotile[i]; } +#define ALIGN_DIVUP(x, y) (((x) + (y) - 1) / (y)) + +static void r300_setup_zmask_flags(struct r300_screen *screen, + struct r300_texture_desc *desc) +{ + /* The tile size of 1 DWORD is: + * + * GPU Pipes 4x4 mode 8x8 mode + * ------------------------------------------ + * R580 4P/1Z 32x32 64x64 + * RV570 3P/1Z 48x16 96x32 + * RV530 1P/2Z 32x16 64x32 + * 1P/1Z 16x16 32x32 + */ + static unsigned num_blocks_x_per_dw[4] = {4, 8, 12, 8}; + static unsigned num_blocks_y_per_dw[4] = {4, 4, 4, 8}; + + if (util_format_is_depth_or_stencil(desc->b.b.format) && + util_format_get_blocksizebits(desc->b.b.format) == 32 && + desc->microtile) { + unsigned i, pipes; + + if (screen->caps.family == CHIP_FAMILY_RV530) { + pipes = screen->caps.num_z_pipes; + } else { + pipes = screen->caps.num_frag_pipes; + } + + for (i = 0; i <= desc->b.b.last_level; i++) { + unsigned numdw, compsize; + + /* The 8x8 compression mode needs macrotiling. */ + compsize = screen->caps.z_compress == R300_ZCOMP_8X8 && + desc->macrotile[i] ? 8 : 4; + + /* Get the zbuffer size (with the aligned width and height). */ + numdw = align(desc->stride_in_pixels[i], + num_blocks_x_per_dw[pipes-1] * compsize) * + align(u_minify(desc->b.b.height0, i), + num_blocks_y_per_dw[pipes-1] * compsize); + + /* Convert pixels -> dwords. */ + numdw = ALIGN_DIVUP(numdw, num_blocks_x_per_dw[pipes-1] * compsize * + num_blocks_y_per_dw[pipes-1] * compsize); + + /* Check that we have enough ZMASK memory. */ + if (numdw <= screen->caps.zmask_ram * pipes) { + desc->zmask_dwords[i] = numdw; + desc->zcomp8x8[i] = compsize == 8; + } else { + desc->zmask_dwords[i] = 0; + desc->zcomp8x8[i] = FALSE; + } + } + } +} + static void r300_setup_tiling(struct r300_screen *screen, struct r300_texture_desc *desc) { @@ -439,6 +496,7 @@ boolean r300_texture_desc_init(struct r300_screen *rscreen, } r300_texture_3d_fix_mipmapping(rscreen, desc); + r300_setup_zmask_flags(rscreen, desc); if (max_buffer_size) { /* Make sure the buffer we got is large enough. */ |