radv/gfx11: don't create texop_samples_identical

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19375>
This commit is contained in:
Rhys Perry
2022-10-25 16:00:10 +01:00
committed by Marge Bot
parent d31e5c8efc
commit b9a3d8b0ab
4 changed files with 39 additions and 32 deletions

View File

@@ -593,11 +593,10 @@ radv_meta_build_nir_fs_noop(struct radv_device *dev)
void
radv_meta_build_resolve_shader_core(nir_builder *b, bool is_integer, int samples,
nir_variable *input_img, nir_variable *color,
nir_ssa_def *img_coord)
nir_ssa_def *img_coord, enum amd_gfx_level gfx_level)
{
/* do a txf_ms on each sample */
nir_ssa_def *tmp;
bool inserted_if = false;
nir_ssa_def *input_img_deref = &nir_build_deref_var(b, input_img)->dest.ssa;
@@ -619,7 +618,12 @@ radv_meta_build_resolve_shader_core(nir_builder *b, bool is_integer, int samples
tmp = &tex->dest.ssa;
if (!is_integer && samples > 1) {
if (is_integer || samples <= 1) {
nir_store_var(b, color, &tex->dest.ssa, 0xf);
return;
}
if (gfx_level < GFX11) {
nir_tex_instr *tex_all_same = nir_tex_instr_create(b->shader, 2);
tex_all_same->sampler_dim = GLSL_SAMPLER_DIM_MS;
tex_all_same->op = nir_texop_samples_identical;
@@ -636,35 +640,36 @@ radv_meta_build_resolve_shader_core(nir_builder *b, bool is_integer, int samples
nir_ssa_def *not_all_same = nir_inot(b, &tex_all_same->dest.ssa);
nir_push_if(b, not_all_same);
for (int i = 1; i < samples; i++) {
nir_tex_instr *tex_add = nir_tex_instr_create(b->shader, 3);
tex_add->sampler_dim = GLSL_SAMPLER_DIM_MS;
tex_add->op = nir_texop_txf_ms;
tex_add->src[0].src_type = nir_tex_src_coord;
tex_add->src[0].src = nir_src_for_ssa(img_coord);
tex_add->src[1].src_type = nir_tex_src_ms_index;
tex_add->src[1].src = nir_src_for_ssa(nir_imm_int(b, i));
tex_add->src[2].src_type = nir_tex_src_texture_deref;
tex_add->src[2].src = nir_src_for_ssa(input_img_deref);
tex_add->dest_type = nir_type_float32;
tex_add->is_array = false;
tex_add->coord_components = 2;
nir_ssa_dest_init(&tex_add->instr, &tex_add->dest, 4, 32, "tex");
nir_builder_instr_insert(b, &tex_add->instr);
tmp = nir_fadd(b, tmp, &tex_add->dest.ssa);
}
tmp = nir_fdiv(b, tmp, nir_imm_float(b, samples));
nir_store_var(b, color, tmp, 0xf);
nir_push_else(b, NULL);
inserted_if = true;
}
nir_store_var(b, color, &tex->dest.ssa, 0xf);
if (inserted_if)
for (int i = 1; i < samples; i++) {
nir_tex_instr *tex_add = nir_tex_instr_create(b->shader, 3);
tex_add->sampler_dim = GLSL_SAMPLER_DIM_MS;
tex_add->op = nir_texop_txf_ms;
tex_add->src[0].src_type = nir_tex_src_coord;
tex_add->src[0].src = nir_src_for_ssa(img_coord);
tex_add->src[1].src_type = nir_tex_src_ms_index;
tex_add->src[1].src = nir_src_for_ssa(nir_imm_int(b, i));
tex_add->src[2].src_type = nir_tex_src_texture_deref;
tex_add->src[2].src = nir_src_for_ssa(input_img_deref);
tex_add->dest_type = nir_type_float32;
tex_add->is_array = false;
tex_add->coord_components = 2;
nir_ssa_dest_init(&tex_add->instr, &tex_add->dest, 4, 32, "tex");
nir_builder_instr_insert(b, &tex_add->instr);
tmp = nir_fadd(b, tmp, &tex_add->dest.ssa);
}
tmp = nir_fdiv(b, tmp, nir_imm_float(b, samples));
nir_store_var(b, color, tmp, 0xf);
if (gfx_level < GFX11) {
nir_push_else(b, NULL);
nir_store_var(b, color, &tex->dest.ssa, 0xf);
nir_pop_if(b, NULL);
}
}
nir_ssa_def *

View File

@@ -268,7 +268,7 @@ nir_shader *radv_meta_build_nir_fs_noop(struct radv_device *dev);
void radv_meta_build_resolve_shader_core(nir_builder *b, bool is_integer, int samples,
nir_variable *input_img, nir_variable *color,
nir_ssa_def *img_coord);
nir_ssa_def *img_coord, enum amd_gfx_level gfx_level);
nir_ssa_def *radv_meta_load_descriptor(nir_builder *b, unsigned desc_set, unsigned binding);

View File

@@ -88,7 +88,8 @@ build_resolve_compute_shader(struct radv_device *dev, bool is_integer, bool is_s
nir_variable *color = nir_local_variable_create(b.impl, glsl_vec4_type(), "color");
radv_meta_build_resolve_shader_core(&b, is_integer, samples, input_img, color, src_coord);
radv_meta_build_resolve_shader_core(&b, is_integer, samples, input_img, color, src_coord,
dev->physical_device->rad_info.gfx_level);
nir_ssa_def *outval = nir_load_var(&b, color);
if (is_srgb)

View File

@@ -56,7 +56,8 @@ build_resolve_fragment_shader(struct radv_device *dev, bool is_integer, int samp
nir_ssa_def *img_coord = nir_channels(&b, nir_iadd(&b, pos_int, src_offset), 0x3);
nir_variable *color = nir_local_variable_create(b.impl, glsl_vec4_type(), "color");
radv_meta_build_resolve_shader_core(&b, is_integer, samples, input_img, color, img_coord);
radv_meta_build_resolve_shader_core(&b, is_integer, samples, input_img, color, img_coord,
dev->physical_device->rad_info.gfx_level);
nir_ssa_def *outval = nir_load_var(&b, color);
nir_store_var(&b, color_out, outval, 0xf);