[Mesa-dev] [PATCH 1/3] radeonsi: assert that the DB format is valid

Christian König deathsimple at vodafone.de
Thu Nov 15 08:28:36 PST 2012


On 15.11.2012 17:00, alexdeucher at gmail.com wrote:
> From: Alex Deucher <alexander.deucher at amd.com>
>
> Rather than disabling the depth buffer.
I would still prefer to use *_INVALID as the invalid function return 
value here.

Just imagine a release build with an undetected bug, writing *_INVALID 
would still result in well defined hw behavior, while ~0 usually maps to 
something reserved. Of course additionally asserting on it still makes 
allot of sense.

Christian.

>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> ---
>   src/gallium/drivers/radeonsi/si_state.c |    9 +++------
>   1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
> index e7a4005..c5ae49a 100644
> --- a/src/gallium/drivers/radeonsi/si_state.c
> +++ b/src/gallium/drivers/radeonsi/si_state.c
> @@ -1687,6 +1687,8 @@ static void si_db(struct r600_context *rctx, struct si_pm4_state *pm4,
>   
>   	format = si_translate_dbformat(rtex->real_format);
>   
> +	assert(format != ~0U);
> +
>   	z_offs = r600_resource_va(rctx->context.screen, surf->base.texture);
>   	z_offs += rtex->surface.level[level].offset;
>   
> @@ -1739,12 +1741,7 @@ static void si_db(struct r600_context *rctx, struct si_pm4_state *pm4,
>   		       S_028008_SLICE_MAX(state->zsbuf->u.tex.last_layer));
>   
>   	si_pm4_set_reg(pm4, R_02803C_DB_DEPTH_INFO, 0x1);
> -	if (format != ~0U) {
> -		si_pm4_set_reg(pm4, R_028040_DB_Z_INFO, z_info);
> -
> -	} else {
> -		si_pm4_set_reg(pm4, R_028040_DB_Z_INFO, 0);
> -	}
> +	si_pm4_set_reg(pm4, R_028040_DB_Z_INFO, z_info);
>   
>   	if (rtex->surface.flags & RADEON_SURF_SBUFFER) {
>   		si_pm4_set_reg(pm4, R_028044_DB_STENCIL_INFO, s_info);



More information about the mesa-dev mailing list