aco: add support for texturing with clamped LOD
This is a requirement for the shaderResourceMinLod feature which allows to clamp LOD. This uses all image_sample_*_cl variants. All dEQP-VK.glsl.texture_functions.texture*clamp.* pass. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4989>
This commit is contained in:
parent
47a769143b
commit
aaf5706aa3
|
@ -8170,9 +8170,11 @@ void visit_tex(isel_context *ctx, nir_tex_instr *instr)
|
||||||
{
|
{
|
||||||
Builder bld(ctx->program, ctx->block);
|
Builder bld(ctx->program, ctx->block);
|
||||||
bool has_bias = false, has_lod = false, level_zero = false, has_compare = false,
|
bool has_bias = false, has_lod = false, level_zero = false, has_compare = false,
|
||||||
has_offset = false, has_ddx = false, has_ddy = false, has_derivs = false, has_sample_index = false;
|
has_offset = false, has_ddx = false, has_ddy = false, has_derivs = false, has_sample_index = false,
|
||||||
|
has_clamped_lod = false;
|
||||||
Temp resource, sampler, fmask_ptr, bias = Temp(), compare = Temp(), sample_index = Temp(),
|
Temp resource, sampler, fmask_ptr, bias = Temp(), compare = Temp(), sample_index = Temp(),
|
||||||
lod = Temp(), offset = Temp(), ddx = Temp(), ddy = Temp();
|
lod = Temp(), offset = Temp(), ddx = Temp(), ddy = Temp(),
|
||||||
|
clamped_lod = Temp();
|
||||||
std::vector<Temp> coords;
|
std::vector<Temp> coords;
|
||||||
std::vector<Temp> derivs;
|
std::vector<Temp> derivs;
|
||||||
nir_const_value *sample_index_cv = NULL;
|
nir_const_value *sample_index_cv = NULL;
|
||||||
|
@ -8208,6 +8210,10 @@ void visit_tex(isel_context *ctx, nir_tex_instr *instr)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case nir_tex_src_min_lod:
|
||||||
|
clamped_lod = get_ssa_temp(ctx, instr->src[i].src.ssa);
|
||||||
|
has_clamped_lod = true;
|
||||||
|
break;
|
||||||
case nir_tex_src_comparator:
|
case nir_tex_src_comparator:
|
||||||
if (instr->is_shadow) {
|
if (instr->is_shadow) {
|
||||||
compare = get_ssa_temp(ctx, instr->src[i].src.ssa);
|
compare = get_ssa_temp(ctx, instr->src[i].src.ssa);
|
||||||
|
@ -8608,6 +8614,8 @@ void visit_tex(isel_context *ctx, nir_tex_instr *instr)
|
||||||
args.emplace_back(sample_index);
|
args.emplace_back(sample_index);
|
||||||
if (has_lod)
|
if (has_lod)
|
||||||
args.emplace_back(lod);
|
args.emplace_back(lod);
|
||||||
|
if (has_clamped_lod)
|
||||||
|
args.emplace_back(clamped_lod);
|
||||||
|
|
||||||
Temp arg = bld.tmp(RegClass(RegType::vgpr, args.size()));
|
Temp arg = bld.tmp(RegClass(RegType::vgpr, args.size()));
|
||||||
aco_ptr<Instruction> vec{create_instruction<Pseudo_instruction>(aco_opcode::p_create_vector, Format::PSEUDO, args.size(), 1)};
|
aco_ptr<Instruction> vec{create_instruction<Pseudo_instruction>(aco_opcode::p_create_vector, Format::PSEUDO, args.size(), 1)};
|
||||||
|
@ -8652,7 +8660,21 @@ void visit_tex(isel_context *ctx, nir_tex_instr *instr)
|
||||||
// TODO: would be better to do this by adding offsets, but needs the opcodes ordered.
|
// TODO: would be better to do this by adding offsets, but needs the opcodes ordered.
|
||||||
aco_opcode opcode = aco_opcode::image_sample;
|
aco_opcode opcode = aco_opcode::image_sample;
|
||||||
if (has_offset) { /* image_sample_*_o */
|
if (has_offset) { /* image_sample_*_o */
|
||||||
|
if (has_clamped_lod) {
|
||||||
if (has_compare) {
|
if (has_compare) {
|
||||||
|
opcode = aco_opcode::image_sample_c_cl_o;
|
||||||
|
if (has_derivs)
|
||||||
|
opcode = aco_opcode::image_sample_c_d_cl_o;
|
||||||
|
if (has_bias)
|
||||||
|
opcode = aco_opcode::image_sample_c_b_cl_o;
|
||||||
|
} else {
|
||||||
|
opcode = aco_opcode::image_sample_cl_o;
|
||||||
|
if (has_derivs)
|
||||||
|
opcode = aco_opcode::image_sample_d_cl_o;
|
||||||
|
if (has_bias)
|
||||||
|
opcode = aco_opcode::image_sample_b_cl_o;
|
||||||
|
}
|
||||||
|
} else if (has_compare) {
|
||||||
opcode = aco_opcode::image_sample_c_o;
|
opcode = aco_opcode::image_sample_c_o;
|
||||||
if (has_derivs)
|
if (has_derivs)
|
||||||
opcode = aco_opcode::image_sample_c_d_o;
|
opcode = aco_opcode::image_sample_c_d_o;
|
||||||
|
@ -8673,6 +8695,20 @@ void visit_tex(isel_context *ctx, nir_tex_instr *instr)
|
||||||
if (has_lod)
|
if (has_lod)
|
||||||
opcode = aco_opcode::image_sample_l_o;
|
opcode = aco_opcode::image_sample_l_o;
|
||||||
}
|
}
|
||||||
|
} else if (has_clamped_lod) { /* image_sample_*_cl */
|
||||||
|
if (has_compare) {
|
||||||
|
opcode = aco_opcode::image_sample_c_cl;
|
||||||
|
if (has_derivs)
|
||||||
|
opcode = aco_opcode::image_sample_c_d_cl;
|
||||||
|
if (has_bias)
|
||||||
|
opcode = aco_opcode::image_sample_c_b_cl;
|
||||||
|
} else {
|
||||||
|
opcode = aco_opcode::image_sample_cl;
|
||||||
|
if (has_derivs)
|
||||||
|
opcode = aco_opcode::image_sample_d_cl;
|
||||||
|
if (has_bias)
|
||||||
|
opcode = aco_opcode::image_sample_b_cl;
|
||||||
|
}
|
||||||
} else { /* no offset */
|
} else { /* no offset */
|
||||||
if (has_compare) {
|
if (has_compare) {
|
||||||
opcode = aco_opcode::image_sample_c;
|
opcode = aco_opcode::image_sample_c;
|
||||||
|
|
Loading…
Reference in New Issue