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 <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
This commit is contained in:
Dave Airlie
2020-03-10 09:51:17 +10:00
committed by Marge Bot
parent eb5919d9d8
commit ae95a08b9c
2 changed files with 13 additions and 1 deletions

View File

@@ -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, &params);
assign_dest(bld_base, &instr->dest, texel);
}

View File

@@ -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,