zink: handle min_lod texture operands

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14381>
This commit is contained in:
Mike Blumenkrantz
2022-01-14 11:22:43 -05:00
committed by Marge Bot
parent ac30051a5d
commit 30bd4ff72e
3 changed files with 17 additions and 3 deletions
@@ -2913,7 +2913,7 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
assert(tex->texture_index == tex->sampler_index);
SpvId coord = 0, proj = 0, bias = 0, lod = 0, dref = 0, dx = 0, dy = 0,
const_offset = 0, offset = 0, sample = 0, tex_offset = 0, bindless = 0;
const_offset = 0, offset = 0, sample = 0, tex_offset = 0, bindless = 0, min_lod = 0;
unsigned coord_components = 0;
nir_variable *bindless_var = NULL;
for (unsigned i = 0; i < tex->num_srcs; i++) {
@@ -2964,6 +2964,12 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
assert(bias != 0);
break;
case nir_tex_src_min_lod:
assert(nir_src_num_components(tex->src[i].src) == 1);
min_lod = get_src_float(ctx, &tex->src[i].src);
assert(min_lod != 0);
break;
case nir_tex_src_lod:
assert(nir_src_num_components(tex->src[i].src) == 1);
if (tex->op == nir_texop_txf ||
@@ -3143,6 +3149,8 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
SpvId result;
if (offset)
spirv_builder_emit_cap(&ctx->builder, SpvCapabilityImageGatherExtended);
if (min_lod)
spirv_builder_emit_cap(&ctx->builder, SpvCapabilityMinLod);
if (tex->op == nir_texop_txf ||
tex->op == nir_texop_txf_ms ||
tex->op == nir_texop_tg4) {
@@ -3164,7 +3172,7 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
coord,
proj != 0,
lod, bias, dref, dx, dy,
const_offset, offset, tex->is_sparse);
const_offset, offset, min_lod, tex->is_sparse);
}
spirv_builder_emit_decoration(&ctx->builder, result,
@@ -764,6 +764,7 @@ spirv_builder_emit_image_sample(struct spirv_builder *b,
SpvId dy,
SpvId const_offset,
SpvId offset,
SpvId min_lod,
bool sparse)
{
SpvId result = spirv_builder_new_id(b);
@@ -794,7 +795,7 @@ spirv_builder_emit_image_sample(struct spirv_builder *b,
}
SpvImageOperandsMask operand_mask = SpvImageOperandsMaskNone;
SpvId extra_operands[5];
SpvId extra_operands[6];
int num_extra_operands = 1;
if (bias) {
extra_operands[num_extra_operands++] = bias;
@@ -816,6 +817,10 @@ spirv_builder_emit_image_sample(struct spirv_builder *b,
extra_operands[num_extra_operands++] = offset;
operand_mask |= SpvImageOperandsOffsetMask;
}
if (min_lod) {
extra_operands[num_extra_operands++] = min_lod;
operand_mask |= SpvImageOperandsMinLodMask;
}
/* finalize num_extra_operands / extra_operands */
extra_operands[0] = operand_mask;
@@ -284,6 +284,7 @@ spirv_builder_emit_image_sample(struct spirv_builder *b,
SpvId dy,
SpvId const_offset,
SpvId offset,
SpvId min_lod,
bool sparse);
SpvId