zink: implement nir_texop_txf_ms
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5159>
This commit is contained in:
parent
caa83e4d79
commit
4f90e818c8
|
@ -1490,16 +1490,18 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
|
|||
tex->op == nir_texop_txl ||
|
||||
tex->op == nir_texop_txd ||
|
||||
tex->op == nir_texop_txf ||
|
||||
tex->op == nir_texop_txf_ms ||
|
||||
tex->op == nir_texop_txs);
|
||||
assert(tex->texture_index == tex->sampler_index);
|
||||
|
||||
SpvId coord = 0, proj = 0, bias = 0, lod = 0, dref = 0, dx = 0, dy = 0,
|
||||
offset = 0;
|
||||
offset = 0, sample = 0;
|
||||
unsigned coord_components = 0;
|
||||
for (unsigned i = 0; i < tex->num_srcs; i++) {
|
||||
switch (tex->src[i].src_type) {
|
||||
case nir_tex_src_coord:
|
||||
if (tex->op == nir_texop_txf)
|
||||
if (tex->op == nir_texop_txf ||
|
||||
tex->op == nir_texop_txf_ms)
|
||||
coord = get_src_int(ctx, &tex->src[i].src);
|
||||
else
|
||||
coord = get_src_float(ctx, &tex->src[i].src);
|
||||
|
@ -1525,6 +1527,7 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
|
|||
case nir_tex_src_lod:
|
||||
assert(nir_src_num_components(tex->src[i].src) == 1);
|
||||
if (tex->op == nir_texop_txf ||
|
||||
tex->op == nir_texop_txf_ms ||
|
||||
tex->op == nir_texop_txs)
|
||||
lod = get_src_int(ctx, &tex->src[i].src);
|
||||
else
|
||||
|
@ -1532,6 +1535,11 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
|
|||
assert(lod != 0);
|
||||
break;
|
||||
|
||||
case nir_tex_src_ms_index:
|
||||
assert(nir_src_num_components(tex->src[i].src) == 1);
|
||||
sample = get_src_int(ctx, &tex->src[i].src);
|
||||
break;
|
||||
|
||||
case nir_tex_src_comparator:
|
||||
assert(nir_src_num_components(tex->src[i].src) == 1);
|
||||
dref = get_src_float(ctx, &tex->src[i].src);
|
||||
|
@ -1606,10 +1614,11 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
|
|||
actual_dest_type = spirv_builder_type_float(&ctx->builder, 32);
|
||||
|
||||
SpvId result;
|
||||
if (tex->op == nir_texop_txf) {
|
||||
if (tex->op == nir_texop_txf ||
|
||||
tex->op == nir_texop_txf_ms) {
|
||||
SpvId image = spirv_builder_emit_image(&ctx->builder, image_type, load);
|
||||
result = spirv_builder_emit_image_fetch(&ctx->builder, dest_type,
|
||||
image, coord, lod);
|
||||
image, coord, lod, sample);
|
||||
} else {
|
||||
result = spirv_builder_emit_image_sample(&ctx->builder,
|
||||
actual_dest_type, load,
|
||||
|
|
|
@ -597,16 +597,27 @@ spirv_builder_emit_image_fetch(struct spirv_builder *b,
|
|||
SpvId result_type,
|
||||
SpvId image,
|
||||
SpvId coordinate,
|
||||
SpvId lod)
|
||||
SpvId lod,
|
||||
SpvId sample)
|
||||
{
|
||||
SpvId result = spirv_builder_new_id(b);
|
||||
|
||||
SpvId extra_operands[2];
|
||||
SpvImageOperandsMask operand_mask = SpvImageOperandsMaskNone;
|
||||
SpvId extra_operands[3];
|
||||
int num_extra_operands = 0;
|
||||
if (lod) {
|
||||
extra_operands[0] = SpvImageOperandsLodMask;
|
||||
extra_operands[1] = lod;
|
||||
num_extra_operands = 2;
|
||||
extra_operands[++num_extra_operands] = lod;
|
||||
operand_mask |= SpvImageOperandsLodMask;
|
||||
}
|
||||
if (sample) {
|
||||
extra_operands[++num_extra_operands] = sample;
|
||||
operand_mask |= SpvImageOperandsSampleMask;
|
||||
}
|
||||
|
||||
/* finalize num_extra_operands / extra_operands */
|
||||
if (num_extra_operands > 0) {
|
||||
extra_operands[0] = operand_mask;
|
||||
num_extra_operands++;
|
||||
}
|
||||
|
||||
spirv_buffer_prepare(&b->instructions, 5 + num_extra_operands);
|
||||
|
|
|
@ -230,7 +230,8 @@ spirv_builder_emit_image_fetch(struct spirv_builder *b,
|
|||
SpvId result_type,
|
||||
SpvId image,
|
||||
SpvId coordinate,
|
||||
SpvId lod);
|
||||
SpvId lod,
|
||||
SpvId sample);
|
||||
|
||||
SpvId
|
||||
spirv_builder_emit_image_query_size(struct spirv_builder *b,
|
||||
|
|
Loading…
Reference in New Issue