r300g: do not use HiZ if HiZ RAM is not properly initialized

This commit is contained in:
Marek Olšák 2010-08-15 03:14:25 +02:00
parent 59c2230879
commit d5a86f9fc9
5 changed files with 23 additions and 18 deletions

View file

@ -172,6 +172,8 @@ static void r300_clear(struct pipe_context* pipe,
(struct pipe_framebuffer_state*)r300->fb_state.state;
struct r300_hyperz_state *hyperz =
(struct r300_hyperz_state*)r300->hyperz_state.state;
struct r300_texture *zstex =
fb->zsbuf ? r300_texture(fb->zsbuf->texture) : NULL;
uint32_t width = fb->width;
uint32_t height = fb->height;
boolean has_hyperz = r300->rws->get_value(r300->rws, R300_CAN_HYPERZ);
@ -184,11 +186,11 @@ static void r300_clear(struct pipe_context* pipe,
r300_depth_clear_value(fb->zsbuf->format, depth, stencil);
r300_mark_fb_state_dirty(r300, R300_CHANGED_ZCLEAR_FLAG);
if (r300_texture(fb->zsbuf->texture)->zmask_mem[fb->zsbuf->level]) {
if (zstex->zmask_mem[fb->zsbuf->level]) {
r300->zmask_clear.dirty = TRUE;
buffers &= ~PIPE_CLEAR_DEPTHSTENCIL;
}
if (r300->hiz_enable)
if (zstex->hiz_mem[fb->zsbuf->level])
r300->hiz_clear.dirty = TRUE;
}
@ -249,12 +251,13 @@ static void r300_clear(struct pipe_context* pipe,
r300_mark_fb_state_dirty(r300, R300_CHANGED_CBZB_FLAG);
}
/* Enable fastfill.
/* Enable fastfill and/or hiz.
*
* If we cleared the zmask, it's in use now. The Hyper-Z state update
* looks if zmask is in use and enables fastfill accordingly. */
if (fb->zsbuf &&
r300_texture(fb->zsbuf->texture)->zmask_in_use[fb->zsbuf->level]) {
* If we cleared zmask/hiz, it's in use now. The Hyper-Z state update
* looks if zmask/hiz is in use and enables fastfill accordingly. */
if (zstex &&
(zstex->zmask_in_use[fb->zsbuf->level] ||
zstex->hiz_in_use[fb->zsbuf->level])) {
r300->hyperz_state.dirty = TRUE;
}

View file

@ -398,6 +398,7 @@ struct r300_texture {
struct mem_block *hiz_mem[R300_MAX_TEXTURE_LEVELS];
struct mem_block *zmask_mem[R300_MAX_TEXTURE_LEVELS];
boolean zmask_in_use[R300_MAX_TEXTURE_LEVELS];
boolean hiz_in_use[R300_MAX_TEXTURE_LEVELS];
/* This is the level tiling flags were last time set for.
* It's used to prevent redundant tiling-flags changes from happening.*/
@ -568,7 +569,6 @@ struct r300_context {
#define R300_Z_COMPRESS_44 1
#define RV350_Z_COMPRESS_88 2
int z_compression;
boolean hiz_enable;
boolean cbzb_clear;
boolean z_decomp_rd;

View file

@ -1046,6 +1046,9 @@ void r300_emit_hiz_clear(struct r300_context *r300, unsigned size, void *state)
r300_emit_hiz_line_clear(r300, offset, stride, 0xffffffff);
}
z->current_func = -1;
/* Mark the current zbuffer's hiz ram as in use. */
tex->hiz_in_use[fb->zsbuf->level] = TRUE;
}
void r300_emit_zmask_clear(struct r300_context *r300, unsigned size, void *state)

View file

@ -131,7 +131,10 @@ static void r300_update_hyperz(struct r300_context* r300)
(struct r300_hyperz_state*)r300->hyperz_state.state;
struct pipe_framebuffer_state *fb =
(struct pipe_framebuffer_state*)r300->fb_state.state;
struct r300_texture *zstex =
fb->zsbuf ? r300_texture(fb->zsbuf->texture) : NULL;
boolean zmask_in_use = FALSE;
boolean hiz_in_use = FALSE;
z->gb_z_peq_config = 0;
z->zb_bw_cntl = 0;
@ -143,13 +146,14 @@ static void r300_update_hyperz(struct r300_context* r300)
return;
}
if (!fb->zsbuf)
if (!zstex)
return;
if (!r300->rws->get_value(r300->rws, R300_CAN_HYPERZ))
return;
zmask_in_use = r300_texture(fb->zsbuf->texture)->zmask_in_use[fb->zsbuf->level];
zmask_in_use = zstex->zmask_in_use[fb->zsbuf->level];
hiz_in_use = zstex->hiz_in_use[fb->zsbuf->level];
/* Z fastfill. */
if (zmask_in_use) {
@ -167,7 +171,7 @@ static void r300_update_hyperz(struct r300_context* r300)
if (r300->z_compression == RV350_Z_COMPRESS_88)
z->gb_z_peq_config |= R300_GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_8_8;
if (r300->hiz_enable) {
if (hiz_in_use) {
bool can_hiz = r300_can_hiz(r300);
if (can_hiz) {
z->zb_bw_cntl |= R300_HIZ_ENABLE;
@ -177,8 +181,8 @@ static void r300_update_hyperz(struct r300_context* r300)
}
}
/* R500-specific features and optimizations. */
if (r300->screen->caps.is_r500) {
/* XXX Are these bits really available on RV350? */
z->zb_bw_cntl |= R500_HIZ_FP_EXP_BITS_3;
z->zb_bw_cntl |=
R500_HIZ_EQUAL_REJECT_ENABLE |

View file

@ -752,7 +752,6 @@ static void
r300_mark_fb_state_dirty(r300, R300_CHANGED_FB_STATE);
r300->hiz_enable = false;
r300->z_compression = false;
if (state->zsbuf) {
@ -779,17 +778,13 @@ static void
/* work out whether we can support zmask features on this buffer */
r300_zmask_alloc_block(r300, zs_surf, compress);
if (tex->hiz_mem[level]) {
r300->hiz_enable = 1;
}
if (tex->zmask_mem[level]) {
/* compression causes hangs on 16-bit */
if (zbuffer_bpp == 24)
r300->z_compression = compress;
}
DBG(r300, DBG_HYPERZ,
"hyper-z features: hiz: %d @ %08x z-compression: %d z-fastfill: %d @ %08x\n", r300->hiz_enable,
"hyper-z features: hiz: %d @ %08x z-compression: %d z-fastfill: %d @ %08x\n", tex->hiz_mem[level] ? 1 : 0,
tex->hiz_mem[level] ? tex->hiz_mem[level]->ofs : 0xdeadbeef,
r300->z_compression, tex->zmask_mem[level] ? 1 : 0,
tex->zmask_mem[level] ? tex->zmask_mem[level]->ofs : 0xdeadbeef);