From: Erik Faye-Lund Date: Mon, 3 Feb 2020 16:39:37 +0000 (+0100) Subject: zink: implement nir_texop_txf_ms X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4f90e818c8678a17203d5035c6e26427704e56db;p=mesa.git zink: implement nir_texop_txf_ms Part-of: --- diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index ccd5aa737bd..09a5d6b607a 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -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, diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c index 101eed1aafa..bc5d08091b1 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c @@ -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); diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h index d0843b8ff79..9d29699127c 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h @@ -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,