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:
@@ -1492,7 +1492,7 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst
|
|||||||
LLVMBuilderRef builder = gallivm->builder;
|
LLVMBuilderRef builder = gallivm->builder;
|
||||||
LLVMValueRef coords[5];
|
LLVMValueRef coords[5];
|
||||||
LLVMValueRef offsets[3] = { NULL };
|
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_sampler_params params;
|
||||||
struct lp_derivatives derivs;
|
struct lp_derivatives derivs;
|
||||||
unsigned sample_key = 0;
|
unsigned sample_key = 0;
|
||||||
@@ -1607,6 +1607,8 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nir_tex_src_ms_index:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
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.coords = coords;
|
||||||
params.texel = texel;
|
params.texel = texel;
|
||||||
params.lod = explicit_lod;
|
params.lod = explicit_lod;
|
||||||
|
params.ms_index = ms_index;
|
||||||
bld_base->tex(bld_base, ¶ms);
|
bld_base->tex(bld_base, ¶ms);
|
||||||
assign_dest(bld_base, &instr->dest, texel);
|
assign_dest(bld_base, &instr->dest, texel);
|
||||||
}
|
}
|
||||||
|
@@ -2456,6 +2456,7 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld,
|
|||||||
LLVMValueRef explicit_lod = NULL;
|
LLVMValueRef explicit_lod = NULL;
|
||||||
LLVMValueRef coords[5];
|
LLVMValueRef coords[5];
|
||||||
LLVMValueRef offsets[3] = { NULL };
|
LLVMValueRef offsets[3] = { NULL };
|
||||||
|
LLVMValueRef ms_index = NULL;
|
||||||
struct lp_sampler_params params;
|
struct lp_sampler_params params;
|
||||||
enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR;
|
enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR;
|
||||||
unsigned dims, i;
|
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);
|
explicit_lod = lp_build_emit_fetch(&bld->bld_base, inst, 0, 3);
|
||||||
lod_property = lp_build_lod_property(&bld->bld_base, inst, 0);
|
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)
|
* XXX: for real msaa support, the w component (or src2.x for sample_i_ms)
|
||||||
* would be the sample index.
|
* would be the sample index.
|
||||||
@@ -2557,6 +2565,7 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld,
|
|||||||
params.derivs = NULL;
|
params.derivs = NULL;
|
||||||
params.lod = explicit_lod;
|
params.lod = explicit_lod;
|
||||||
params.texel = texel;
|
params.texel = texel;
|
||||||
|
params.ms_index = ms_index;
|
||||||
|
|
||||||
bld->sampler->emit_tex_sample(bld->sampler,
|
bld->sampler->emit_tex_sample(bld->sampler,
|
||||||
bld->bld_base.base.gallivm,
|
bld->bld_base.base.gallivm,
|
||||||
|
Reference in New Issue
Block a user