[Mesa-dev] [PATCH 5/8] radeonsi: don't interpolate colors if flatshading is enabled
Marek Olšák
maraeo at gmail.com
Thu Jun 30 23:28:44 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
use v_interp_mov for those
---
src/gallium/drivers/radeonsi/si_shader.c | 13 ++++++++++++-
src/gallium/drivers/radeonsi/si_shader.h | 2 +-
src/gallium/drivers/radeonsi/si_state_shaders.c | 1 +
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 10dd12a..a408dee 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1528,6 +1528,11 @@ static void declare_input_fs(
interp_param = get_interp_param(ctx, interp_param_idx);
}
+ if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
+ decl->Interp.Interpolate == TGSI_INTERPOLATE_COLOR &&
+ ctx->shader->key.ps.prolog.flatshade_colors)
+ interp_param = NULL; /* load the constant color */
+
interp_fs_input(ctx, input_index, decl->Semantic.Name,
decl->Semantic.Index, shader->selector->info.num_inputs,
shader->selector->info.colors_read, interp_param,
@@ -6455,6 +6460,7 @@ void si_dump_shader_key(unsigned shader, union si_shader_key *key, FILE *f)
case PIPE_SHADER_FRAGMENT:
fprintf(f, " prolog.color_two_side = %u\n", key->ps.prolog.color_two_side);
+ fprintf(f, " prolog.flatshade_colors = %u\n", key->ps.prolog.flatshade_colors);
fprintf(f, " prolog.poly_stipple = %u\n", key->ps.prolog.poly_stipple);
fprintf(f, " prolog.force_persp_sample_interp = %u\n", key->ps.prolog.force_persp_sample_interp);
fprintf(f, " prolog.force_linear_sample_interp = %u\n", key->ps.prolog.force_linear_sample_interp);
@@ -7597,6 +7603,7 @@ static bool si_shader_select_ps_parts(struct si_screen *sscreen,
}
for (i = 0; i < 2; i++) {
+ unsigned interp = info->input_interpolate[color[i]];
unsigned location = info->input_interpolate_loc[color[i]];
if (!(info->colors_read & (0xf << i*4)))
@@ -7604,7 +7611,11 @@ static bool si_shader_select_ps_parts(struct si_screen *sscreen,
prolog_key.ps_prolog.color_attr_index[i] = color[i];
- switch (info->input_interpolate[color[i]]) {
+ if (shader->key.ps.prolog.flatshade_colors &&
+ interp == TGSI_INTERPOLATE_COLOR)
+ interp = TGSI_INTERPOLATE_CONSTANT;
+
+ switch (interp) {
case TGSI_INTERPOLATE_CONSTANT:
prolog_key.ps_prolog.color_interp_vgpr_index[i] = -1;
break;
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index 3b7b3e1..14ef4e7 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -311,7 +311,7 @@ struct si_tcs_epilog_bits {
/* Common PS bits between the shader key and the prolog key. */
struct si_ps_prolog_bits {
unsigned color_two_side:1;
- /* TODO: add a flatshade bit that skips interpolation for colors */
+ unsigned flatshade_colors:1;
unsigned poly_stipple:1;
unsigned force_persp_sample_interp:1;
unsigned force_linear_sample_interp:1;
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 42ebf69..766ef2c 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -924,6 +924,7 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
bool is_line = !is_poly && sctx->current_rast_prim != PIPE_PRIM_POINTS;
key->ps.prolog.color_two_side = rs->two_side && sel->info.colors_read;
+ key->ps.prolog.flatshade_colors = rs->flatshade && sel->info.colors_read;
if (sctx->queued.named.blend) {
key->ps.epilog.alpha_to_one = sctx->queued.named.blend->alpha_to_one &&
--
2.7.4
More information about the mesa-dev
mailing list