From ed9391df3f6fde4cb0ac85f3fa4d5fc4409555a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 14 Aug 2020 19:13:21 -0400 Subject: [PATCH] radeonsi: get color interpolation info from shader_info Reviewed-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Connor Abbott Part-of: --- src/gallium/drivers/radeonsi/si_shader.c | 4 ++-- src/gallium/drivers/radeonsi/si_shader.h | 4 +++- src/gallium/drivers/radeonsi/si_shader_nir.c | 25 ++++++++++++-------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index b6b11292d7a..0558cda194a 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -2143,8 +2143,8 @@ void si_get_ps_prolog_key(struct si_shader *shader, union si_shader_part_key *ke } for (unsigned i = 0; i < 2; i++) { - unsigned interp = info->input_interpolate[color[i]]; - unsigned location = info->input_interpolate_loc[color[i]]; + unsigned interp = info->color_interpolate[i]; + unsigned location = info->color_interpolate_loc[i]; if (!(info->colors_read & (0xf << i * 4))) continue; diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index b46a48380e0..95b0c050339 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -324,13 +324,15 @@ struct si_shader_info { ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */ ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS]; ubyte input_interpolate[PIPE_MAX_SHADER_INPUTS]; - ubyte input_interpolate_loc[PIPE_MAX_SHADER_INPUTS]; ubyte input_usage_mask[PIPE_MAX_SHADER_INPUTS]; ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */ ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; ubyte output_usagemask[PIPE_MAX_SHADER_OUTPUTS]; ubyte output_streams[PIPE_MAX_SHADER_OUTPUTS]; + ubyte color_interpolate[2]; + ubyte color_interpolate_loc[2]; + ubyte processor; int constbuf0_num_slots; diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 19c9332408a..c4578d529a6 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -598,6 +598,15 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf unreachable("Unknow depth layout"); } } + + info->color_interpolate[0] = tgsi_get_interp_mode(nir->info.fs.color0_interp, true); + info->color_interpolate[1] = tgsi_get_interp_mode(nir->info.fs.color1_interp, true); + info->color_interpolate_loc[0] = nir->info.fs.color0_sample ? TGSI_INTERPOLATE_LOC_SAMPLE : + nir->info.fs.color0_centroid ? TGSI_INTERPOLATE_LOC_CENTROID : + TGSI_INTERPOLATE_LOC_CENTER; + info->color_interpolate_loc[1] = nir->info.fs.color1_sample ? TGSI_INTERPOLATE_LOC_SAMPLE : + nir->info.fs.color1_centroid ? TGSI_INTERPOLATE_LOC_CENTROID : + TGSI_INTERPOLATE_LOC_CENTER; } if (gl_shader_stage_is_compute(nir->info.stage)) { @@ -647,16 +656,6 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf if (semantic_name == TGSI_SEMANTIC_PRIMID) info->uses_primid = true; - if (semantic_name == TGSI_SEMANTIC_COLOR) { - /* We only need this for color inputs. */ - if (variable->data.sample) - info->input_interpolate_loc[i] = TGSI_INTERPOLATE_LOC_SAMPLE; - else if (variable->data.centroid) - info->input_interpolate_loc[i] = TGSI_INTERPOLATE_LOC_CENTROID; - else - info->input_interpolate_loc[i] = TGSI_INTERPOLATE_LOC_CENTER; - } - enum glsl_base_type base_type = glsl_get_base_type(glsl_without_array(variable->type)); switch (variable->data.interpolation) { @@ -853,8 +852,14 @@ static void si_nir_lower_color(nir_shader *nir) if (var->data.location == VARYING_SLOT_COL0) { def = nir_load_color0(&b); + nir->info.fs.color0_interp = var->data.interpolation; + nir->info.fs.color0_sample = var->data.sample; + nir->info.fs.color0_centroid = var->data.centroid; } else if (var->data.location == VARYING_SLOT_COL1) { def = nir_load_color1(&b); + nir->info.fs.color1_interp = var->data.interpolation; + nir->info.fs.color1_sample = var->data.sample; + nir->info.fs.color1_centroid = var->data.centroid; } else { continue; } -- 2.30.2