[Mesa-dev] [PATCH 7/7] radeonsi: disable SPI color outputs the shader doesn't write

Nicolai Hähnle nhaehnle at gmail.com
Tue Jan 19 13:06:43 PST 2016


Apart from two comments on patch #2, the series is

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

On 19.01.2016 11:11, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>   src/gallium/drivers/radeonsi/si_shader.h        |  4 ++++
>   src/gallium/drivers/radeonsi/si_state_shaders.c | 12 ++++++++++++
>   2 files changed, 16 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
> index f49290a..50375e2 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.h
> +++ b/src/gallium/drivers/radeonsi/si_shader.h
> @@ -213,6 +213,10 @@ struct si_shader_selector {
>
>   	/* PS parameters. */
>   	unsigned	db_shader_control;
> +	/* Set 0xf or 0x0 (4 bits) per each written output.
> +	 * ANDed with spi_shader_col_format.
> +	 */
> +	unsigned	colors_written_4bit;
>
>   	/* masks of "get_unique_index" bits */
>   	uint64_t	outputs_written;
> diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
> index 80126f2..9daa924 100644
> --- a/src/gallium/drivers/radeonsi/si_state_shaders.c
> +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
> @@ -646,6 +646,12 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
>   		if (sctx->b.chip_class <= CIK && sctx->b.family != CHIP_HAWAII)
>   			key->ps.color_is_int8 = sctx->framebuffer.color_is_int8;
>
> +		/* Disable unwritten outputs (if WRITE_ALL_CBUFS isn't enabled). */
> +		if (!key->ps.last_cbuf) {
> +			key->ps.spi_shader_col_format &= sel->colors_written_4bit;
> +			key->ps.color_is_int8 &= sel->info.colors_written;
> +		}
> +
>   		if (rs) {
>   			bool is_poly = (sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES &&
>   					sctx->current_rast_prim <= PIPE_PRIM_POLYGON) ||
> @@ -830,6 +836,12 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
>   		}
>   		sel->esgs_itemsize = util_last_bit64(sel->outputs_written) * 16;
>   		break;
> +
> +	case PIPE_SHADER_FRAGMENT:
> +		for (i = 0; i < 8; i++)
> +			if (sel->info.colors_written & (1 << i))
> +				sel->colors_written_4bit |= 0xf << (4 * i);
> +		break;
>   	}
>
>   	/* DB_SHADER_CONTROL */
>


More information about the mesa-dev mailing list