From 1462da2a70f371219c4ecc287e04b283c8f29128 Mon Sep 17 00:00:00 2001 From: Amber Date: Thu, 9 Feb 2023 14:04:46 +0100 Subject: [PATCH] nir: allow nir_lower_fb_read to support multiple render targets Signed-off-by: Amber Amber Part-of: --- src/compiler/nir/nir_lower_fb_read.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/compiler/nir/nir_lower_fb_read.c b/src/compiler/nir/nir_lower_fb_read.c index a8ce888..3a35a0f 100644 --- a/src/compiler/nir/nir_lower_fb_read.c +++ b/src/compiler/nir/nir_lower_fb_read.c @@ -56,16 +56,6 @@ nir_lower_fb_read_instr(nir_builder *b, nir_instr *instr, UNUSED void *cb_data) if (intr->intrinsic != nir_intrinsic_load_output) return false; - /* TODO KHR_blend_equation_advanced is limited to non-MRT - * scenarios.. but possible there are other extensions - * where this pass would be useful that do support MRT? - * - * I guess for now I'll leave that as an exercise for the - * reader. - */ - if (nir_intrinsic_base(intr) != 0 || nir_src_as_uint(intr->src[0]) != 0) - return false; - b->cursor = nir_before_instr(&intr->instr); nir_ssa_def *fragcoord = nir_load_frag_coord(b); @@ -73,7 +63,7 @@ nir_lower_fb_read_instr(nir_builder *b, nir_instr *instr, UNUSED void *cb_data) fragcoord = nir_f2i32(b, fragcoord); - nir_tex_instr *tex = nir_tex_instr_create(b->shader, 2); + nir_tex_instr *tex = nir_tex_instr_create(b->shader, 3); tex->op = nir_texop_txf_ms_fb; tex->sampler_dim = GLSL_SAMPLER_DIM_2D; tex->coord_components = 2; @@ -82,6 +72,9 @@ nir_lower_fb_read_instr(nir_builder *b, nir_instr *instr, UNUSED void *cb_data) tex->src[0].src = nir_src_for_ssa(nir_channels(b, fragcoord, 0x3)); tex->src[1].src_type = nir_tex_src_ms_index; tex->src[1].src = nir_src_for_ssa(sampid); + struct nir_io_semantics io = nir_intrinsic_io_semantics(intr); + tex->src[2].src = nir_src_for_ssa(nir_imm_intN_t(b, io.location - FRAG_RESULT_DATA0, 32)); + tex->src[2].src_type = nir_tex_src_texture_handle; nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL); nir_builder_instr_insert(b, &tex->instr); -- 2.7.4