From ae95a08b9c366d5a8558e20c2c3a11558a9c0610 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 10 Mar 2020 09:51:17 +1000 Subject: [PATCH] gallivm/nir/tgsi: add multisample texture sampling. Both paths are required as u_blitter needs the TGSI path. This just hooks the instructions up to the sampling code. Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 5 ++++- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 218d46036e9..48440f73da5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1492,7 +1492,7 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst LLVMBuilderRef builder = gallivm->builder; LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; - LLVMValueRef explicit_lod = NULL, projector = NULL; + LLVMValueRef explicit_lod = NULL, projector = NULL, ms_index = NULL; struct lp_sampler_params params; struct lp_derivatives derivs; unsigned sample_key = 0; @@ -1607,6 +1607,8 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst break; } case nir_tex_src_ms_index: + sample_key |= LP_SAMPLER_FETCH_MS; + ms_index = cast_type(bld_base, get_src(bld_base, instr->src[i].src), nir_type_int, 32); break; default: assert(0); @@ -1668,6 +1670,7 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst params.coords = coords; params.texel = texel; params.lod = explicit_lod; + params.ms_index = ms_index; bld_base->tex(bld_base, ¶ms); assign_dest(bld_base, &instr->dest, texel); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 67c7cc7b270..efdce32d2d2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -2456,6 +2456,7 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, LLVMValueRef explicit_lod = NULL; LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; + LLVMValueRef ms_index = NULL; struct lp_sampler_params params; enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; unsigned dims, i; @@ -2517,6 +2518,13 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, explicit_lod = lp_build_emit_fetch(&bld->bld_base, inst, 0, 3); lod_property = lp_build_lod_property(&bld->bld_base, inst, 0); } + + if (target == TGSI_TEXTURE_2D_MSAA || + target == TGSI_TEXTURE_2D_ARRAY_MSAA) { + sample_key |= LP_SAMPLER_FETCH_MS; + ms_index = lp_build_emit_fetch(&bld->bld_base, inst, 0, 3); + } + /* * XXX: for real msaa support, the w component (or src2.x for sample_i_ms) * would be the sample index. @@ -2557,6 +2565,7 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, params.derivs = NULL; params.lod = explicit_lod; params.texel = texel; + params.ms_index = ms_index; bld->sampler->emit_tex_sample(bld->sampler, bld->bld_base.base.gallivm, -- 2.30.2