diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2021-10-27 16:58:41 -0400 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2021-11-03 20:15:49 +0000 |
commit | 2b4ae31cec79c632c499c5fff209d5c16a88cde8 (patch) | |
tree | c1e3b4dfe7b717542d66150981fb21ef4e2d7b89 | |
parent | 23ad2decbb652aee6ff7b6a6cca464506b0aeee2 (diff) | |
download | mesa-2b4ae31cec79c632c499c5fff209d5c16a88cde8.tar.gz |
zink: force float dest types on some alu results
these aren't exact matches in spirv, so set the expected result type
to float where necessary
cc: mesa-stable
fixes #5567
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13562>
(cherry picked from commit 73af67883ddf6faec9c0e76f8c174fb450817179)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 21 |
2 files changed, 16 insertions, 7 deletions
diff --git a/.pick_status.json b/.pick_status.json index b8903719a06..e0f72117ba2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -562,7 +562,7 @@ "description": "zink: force float dest types on some alu results", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, 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 4c2532e9dc2..42dd8d07c99 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 @@ -1566,11 +1566,11 @@ get_alu_src(struct ntv_context *ctx, nir_alu_instr *alu, unsigned src) } static SpvId -store_alu_result(struct ntv_context *ctx, nir_alu_instr *alu, SpvId result) +store_alu_result(struct ntv_context *ctx, nir_alu_instr *alu, SpvId result, bool force_float) { assert(!alu->dest.saturate); return store_dest(ctx, &alu->dest.dest, result, - nir_op_infos[alu->op].output_type); + force_float ? nir_type_float : nir_op_infos[alu->op].output_type); } static SpvId @@ -1632,6 +1632,7 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) SpvId dest_type = get_dest_type(ctx, &alu->dest.dest, nir_op_infos[alu->op].output_type); + bool force_float = false; unsigned bit_size = nir_dest_bit_size(alu->dest.dest); unsigned num_components = nir_dest_num_components(alu->dest.dest); @@ -1716,6 +1717,13 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) result = emit_builtin_unop(ctx, spirv_op, dest_type, src[0]); \ break; +#define BUILTIN_UNOPF(nir_op, spirv_op) \ + case nir_op: \ + assert(nir_op_infos[alu->op].num_inputs == 1); \ + result = emit_builtin_unop(ctx, spirv_op, get_dest_type(ctx, &alu->dest.dest, nir_type_float), src[0]); \ + force_float = true; \ + break; + BUILTIN_UNOP(nir_op_iabs, GLSLstd450SAbs) BUILTIN_UNOP(nir_op_fabs, GLSLstd450FAbs) BUILTIN_UNOP(nir_op_fsqrt, GLSLstd450Sqrt) @@ -1734,10 +1742,11 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) BUILTIN_UNOP(nir_op_ufind_msb, GLSLstd450FindUMsb) BUILTIN_UNOP(nir_op_find_lsb, GLSLstd450FindILsb) BUILTIN_UNOP(nir_op_ifind_msb, GLSLstd450FindSMsb) - BUILTIN_UNOP(nir_op_pack_half_2x16, GLSLstd450PackHalf2x16) - BUILTIN_UNOP(nir_op_unpack_half_2x16, GLSLstd450UnpackHalf2x16) - BUILTIN_UNOP(nir_op_pack_64_2x32, GLSLstd450PackDouble2x32) + BUILTIN_UNOPF(nir_op_pack_half_2x16, GLSLstd450PackHalf2x16) + BUILTIN_UNOPF(nir_op_unpack_half_2x16, GLSLstd450UnpackHalf2x16) + BUILTIN_UNOPF(nir_op_pack_64_2x32, GLSLstd450PackDouble2x32) #undef BUILTIN_UNOP +#undef BUILTIN_UNOPF case nir_op_frcp: assert(nir_op_infos[alu->op].num_inputs == 1); @@ -1889,7 +1898,7 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) if (alu->exact) spirv_builder_emit_decoration(&ctx->builder, result, SpvDecorationNoContraction); - store_alu_result(ctx, alu, result); + store_alu_result(ctx, alu, result, force_float); } static void |