diff options
| author | 2021-05-21 21:42:48 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:33 -0400 | |
| commit | c8414e686f30b3bec7f179ee7ab800f223f8ece0 (patch) | |
| tree | 73e86260d181d7022eacdc7821b6d41b3b47e13b /src/shader_recompiler | |
| parent | glasm: Reorder unreachable image atomic insts (diff) | |
| download | yuzu-c8414e686f30b3bec7f179ee7ab800f223f8ece0.tar.gz yuzu-c8414e686f30b3bec7f179ee7ab800f223f8ece0.tar.xz yuzu-c8414e686f30b3bec7f179ee7ab800f223f8ece0.zip | |
glasm: Implement image atomics
Diffstat (limited to 'src/shader_recompiler')
| -rw-r--r-- | src/shader_recompiler/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | 153 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_image_atomic.cpp | 165 |
3 files changed, 153 insertions, 166 deletions
diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt index 0d55924a7..becdb7d54 100644 --- a/src/shader_recompiler/CMakeLists.txt +++ b/src/shader_recompiler/CMakeLists.txt | |||
| @@ -13,7 +13,6 @@ add_library(shader_recompiler STATIC | |||
| 13 | backend/glasm/emit_glasm_convert.cpp | 13 | backend/glasm/emit_glasm_convert.cpp |
| 14 | backend/glasm/emit_glasm_floating_point.cpp | 14 | backend/glasm/emit_glasm_floating_point.cpp |
| 15 | backend/glasm/emit_glasm_image.cpp | 15 | backend/glasm/emit_glasm_image.cpp |
| 16 | backend/glasm/emit_glasm_image_atomic.cpp | ||
| 17 | backend/glasm/emit_glasm_instructions.h | 16 | backend/glasm/emit_glasm_instructions.h |
| 18 | backend/glasm/emit_glasm_integer.cpp | 17 | backend/glasm/emit_glasm_integer.cpp |
| 19 | backend/glasm/emit_glasm_logical.cpp | 18 | backend/glasm/emit_glasm_logical.cpp |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp index 385ca51ac..a7def0897 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | |||
| @@ -205,6 +205,16 @@ std::string_view FormatStorage(ImageFormat format) { | |||
| 205 | } | 205 | } |
| 206 | throw InvalidArgument("Invalid image format {}", format); | 206 | throw InvalidArgument("Invalid image format {}", format); |
| 207 | } | 207 | } |
| 208 | |||
| 209 | template <typename T> | ||
| 210 | void ImageAtomic(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, T value, | ||
| 211 | std::string_view op) { | ||
| 212 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 213 | const std::string_view type{TextureType(info)}; | ||
| 214 | const std::string image{Image(ctx, info, index)}; | ||
| 215 | const Register ret{ctx.reg_alloc.Define(inst)}; | ||
| 216 | ctx.Add("ATOMIM.{} {},{},{},{},{};", op, ret, value, coord, image, type); | ||
| 217 | } | ||
| 208 | } // Anonymous namespace | 218 | } // Anonymous namespace |
| 209 | 219 | ||
| 210 | void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 220 | void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| @@ -590,6 +600,61 @@ void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Re | |||
| 590 | ctx.Add("STOREIM.{} {},{},{},{};", format, image, color, coord, type); | 600 | ctx.Add("STOREIM.{} {},{},{},{};", format, image, color, coord, type); |
| 591 | } | 601 | } |
| 592 | 602 | ||
| 603 | void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 604 | ScalarU32 value) { | ||
| 605 | ImageAtomic(ctx, inst, index, coord, value, "ADD.U32"); | ||
| 606 | } | ||
| 607 | |||
| 608 | void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 609 | ScalarS32 value) { | ||
| 610 | ImageAtomic(ctx, inst, index, coord, value, "MIN.S32"); | ||
| 611 | } | ||
| 612 | |||
| 613 | void EmitImageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 614 | ScalarU32 value) { | ||
| 615 | ImageAtomic(ctx, inst, index, coord, value, "MIN.U32"); | ||
| 616 | } | ||
| 617 | |||
| 618 | void EmitImageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 619 | ScalarS32 value) { | ||
| 620 | ImageAtomic(ctx, inst, index, coord, value, "MAX.S32"); | ||
| 621 | } | ||
| 622 | |||
| 623 | void EmitImageAtomicUMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 624 | ScalarU32 value) { | ||
| 625 | ImageAtomic(ctx, inst, index, coord, value, "MAX.U32"); | ||
| 626 | } | ||
| 627 | |||
| 628 | void EmitImageAtomicInc32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 629 | ScalarU32 value) { | ||
| 630 | ImageAtomic(ctx, inst, index, coord, value, "IWRAP.U32"); | ||
| 631 | } | ||
| 632 | |||
| 633 | void EmitImageAtomicDec32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 634 | ScalarU32 value) { | ||
| 635 | ImageAtomic(ctx, inst, index, coord, value, "DWRAP.U32"); | ||
| 636 | } | ||
| 637 | |||
| 638 | void EmitImageAtomicAnd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 639 | ScalarU32 value) { | ||
| 640 | ImageAtomic(ctx, inst, index, coord, value, "AND.U32"); | ||
| 641 | } | ||
| 642 | |||
| 643 | void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 644 | ScalarU32 value) { | ||
| 645 | ImageAtomic(ctx, inst, index, coord, value, "OR.U32"); | ||
| 646 | } | ||
| 647 | |||
| 648 | void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord, | ||
| 649 | ScalarU32 value) { | ||
| 650 | ImageAtomic(ctx, inst, index, coord, value, "XOR.U32"); | ||
| 651 | } | ||
| 652 | |||
| 653 | void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 654 | Register coord, ScalarU32 value) { | ||
| 655 | ImageAtomic(ctx, inst, index, coord, value, "EXCH.U32"); | ||
| 656 | } | ||
| 657 | |||
| 593 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { | 658 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { |
| 594 | throw LogicError("Unreachable instruction"); | 659 | throw LogicError("Unreachable instruction"); |
| 595 | } | 660 | } |
| @@ -686,4 +751,92 @@ void EmitBoundImageWrite(EmitContext&) { | |||
| 686 | throw LogicError("Unreachable instruction"); | 751 | throw LogicError("Unreachable instruction"); |
| 687 | } | 752 | } |
| 688 | 753 | ||
| 754 | void EmitBindlessImageAtomicIAdd32(EmitContext&) { | ||
| 755 | throw LogicError("Unreachable instruction"); | ||
| 756 | } | ||
| 757 | |||
| 758 | void EmitBindlessImageAtomicSMin32(EmitContext&) { | ||
| 759 | throw LogicError("Unreachable instruction"); | ||
| 760 | } | ||
| 761 | |||
| 762 | void EmitBindlessImageAtomicUMin32(EmitContext&) { | ||
| 763 | throw LogicError("Unreachable instruction"); | ||
| 764 | } | ||
| 765 | |||
| 766 | void EmitBindlessImageAtomicSMax32(EmitContext&) { | ||
| 767 | throw LogicError("Unreachable instruction"); | ||
| 768 | } | ||
| 769 | |||
| 770 | void EmitBindlessImageAtomicUMax32(EmitContext&) { | ||
| 771 | throw LogicError("Unreachable instruction"); | ||
| 772 | } | ||
| 773 | |||
| 774 | void EmitBindlessImageAtomicInc32(EmitContext&) { | ||
| 775 | throw LogicError("Unreachable instruction"); | ||
| 776 | } | ||
| 777 | |||
| 778 | void EmitBindlessImageAtomicDec32(EmitContext&) { | ||
| 779 | throw LogicError("Unreachable instruction"); | ||
| 780 | } | ||
| 781 | |||
| 782 | void EmitBindlessImageAtomicAnd32(EmitContext&) { | ||
| 783 | throw LogicError("Unreachable instruction"); | ||
| 784 | } | ||
| 785 | |||
| 786 | void EmitBindlessImageAtomicOr32(EmitContext&) { | ||
| 787 | throw LogicError("Unreachable instruction"); | ||
| 788 | } | ||
| 789 | |||
| 790 | void EmitBindlessImageAtomicXor32(EmitContext&) { | ||
| 791 | throw LogicError("Unreachable instruction"); | ||
| 792 | } | ||
| 793 | |||
| 794 | void EmitBindlessImageAtomicExchange32(EmitContext&) { | ||
| 795 | throw LogicError("Unreachable instruction"); | ||
| 796 | } | ||
| 797 | |||
| 798 | void EmitBoundImageAtomicIAdd32(EmitContext&) { | ||
| 799 | throw LogicError("Unreachable instruction"); | ||
| 800 | } | ||
| 801 | |||
| 802 | void EmitBoundImageAtomicSMin32(EmitContext&) { | ||
| 803 | throw LogicError("Unreachable instruction"); | ||
| 804 | } | ||
| 805 | |||
| 806 | void EmitBoundImageAtomicUMin32(EmitContext&) { | ||
| 807 | throw LogicError("Unreachable instruction"); | ||
| 808 | } | ||
| 809 | |||
| 810 | void EmitBoundImageAtomicSMax32(EmitContext&) { | ||
| 811 | throw LogicError("Unreachable instruction"); | ||
| 812 | } | ||
| 813 | |||
| 814 | void EmitBoundImageAtomicUMax32(EmitContext&) { | ||
| 815 | throw LogicError("Unreachable instruction"); | ||
| 816 | } | ||
| 817 | |||
| 818 | void EmitBoundImageAtomicInc32(EmitContext&) { | ||
| 819 | throw LogicError("Unreachable instruction"); | ||
| 820 | } | ||
| 821 | |||
| 822 | void EmitBoundImageAtomicDec32(EmitContext&) { | ||
| 823 | throw LogicError("Unreachable instruction"); | ||
| 824 | } | ||
| 825 | |||
| 826 | void EmitBoundImageAtomicAnd32(EmitContext&) { | ||
| 827 | throw LogicError("Unreachable instruction"); | ||
| 828 | } | ||
| 829 | |||
| 830 | void EmitBoundImageAtomicOr32(EmitContext&) { | ||
| 831 | throw LogicError("Unreachable instruction"); | ||
| 832 | } | ||
| 833 | |||
| 834 | void EmitBoundImageAtomicXor32(EmitContext&) { | ||
| 835 | throw LogicError("Unreachable instruction"); | ||
| 836 | } | ||
| 837 | |||
| 838 | void EmitBoundImageAtomicExchange32(EmitContext&) { | ||
| 839 | throw LogicError("Unreachable instruction"); | ||
| 840 | } | ||
| 841 | |||
| 689 | } // namespace Shader::Backend::GLASM | 842 | } // namespace Shader::Backend::GLASM |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image_atomic.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image_atomic.cpp deleted file mode 100644 index f82cf9ffc..000000000 --- a/src/shader_recompiler/backend/glasm/emit_glasm_image_atomic.cpp +++ /dev/null | |||
| @@ -1,165 +0,0 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "shader_recompiler/backend/glasm/emit_context.h" | ||
| 6 | #include "shader_recompiler/backend/glasm/emit_glasm_instructions.h" | ||
| 7 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 8 | |||
| 9 | namespace Shader::Backend::GLASM { | ||
| 10 | |||
| 11 | void EmitImageAtomicIAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 12 | [[maybe_unused]] const IR::Value& index, | ||
| 13 | [[maybe_unused]] Register coords, [[maybe_unused]] ScalarU32 value) { | ||
| 14 | throw NotImplementedException("GLASM instruction"); | ||
| 15 | } | ||
| 16 | |||
| 17 | void EmitImageAtomicSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 18 | [[maybe_unused]] const IR::Value& index, | ||
| 19 | [[maybe_unused]] Register coords, [[maybe_unused]] ScalarS32 value) { | ||
| 20 | throw NotImplementedException("GLASM instruction"); | ||
| 21 | } | ||
| 22 | |||
| 23 | void EmitImageAtomicUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 24 | [[maybe_unused]] const IR::Value& index, | ||
| 25 | [[maybe_unused]] Register coords, [[maybe_unused]] ScalarU32 value) { | ||
| 26 | throw NotImplementedException("GLASM instruction"); | ||
| 27 | } | ||
| 28 | |||
| 29 | void EmitImageAtomicSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 30 | [[maybe_unused]] const IR::Value& index, | ||
| 31 | [[maybe_unused]] Register coords, [[maybe_unused]] ScalarS32 value) { | ||
| 32 | throw NotImplementedException("GLASM instruction"); | ||
| 33 | } | ||
| 34 | |||
| 35 | void EmitImageAtomicUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 36 | [[maybe_unused]] const IR::Value& index, | ||
| 37 | [[maybe_unused]] Register coords, [[maybe_unused]] ScalarU32 value) { | ||
| 38 | throw NotImplementedException("GLASM instruction"); | ||
| 39 | } | ||
| 40 | |||
| 41 | void EmitImageAtomicInc32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 42 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 43 | [[maybe_unused]] ScalarU32 value) { | ||
| 44 | throw NotImplementedException("GLASM instruction"); | ||
| 45 | } | ||
| 46 | |||
| 47 | void EmitImageAtomicDec32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 48 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 49 | [[maybe_unused]] ScalarU32 value) { | ||
| 50 | throw NotImplementedException("GLASM instruction"); | ||
| 51 | } | ||
| 52 | |||
| 53 | void EmitImageAtomicAnd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 54 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 55 | [[maybe_unused]] ScalarU32 value) { | ||
| 56 | throw NotImplementedException("GLASM instruction"); | ||
| 57 | } | ||
| 58 | |||
| 59 | void EmitImageAtomicOr32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 60 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 61 | [[maybe_unused]] ScalarU32 value) { | ||
| 62 | throw NotImplementedException("GLASM instruction"); | ||
| 63 | } | ||
| 64 | |||
| 65 | void EmitImageAtomicXor32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 66 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 67 | [[maybe_unused]] ScalarU32 value) { | ||
| 68 | throw NotImplementedException("GLASM instruction"); | ||
| 69 | } | ||
| 70 | |||
| 71 | void EmitImageAtomicExchange32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 72 | [[maybe_unused]] const IR::Value& index, | ||
| 73 | [[maybe_unused]] Register coords, [[maybe_unused]] ScalarU32 value) { | ||
| 74 | throw NotImplementedException("GLASM instruction"); | ||
| 75 | } | ||
| 76 | |||
| 77 | void EmitBindlessImageAtomicIAdd32(EmitContext&) { | ||
| 78 | throw LogicError("Unreachable instruction"); | ||
| 79 | } | ||
| 80 | |||
| 81 | void EmitBindlessImageAtomicSMin32(EmitContext&) { | ||
| 82 | throw LogicError("Unreachable instruction"); | ||
| 83 | } | ||
| 84 | |||
| 85 | void EmitBindlessImageAtomicUMin32(EmitContext&) { | ||
| 86 | throw LogicError("Unreachable instruction"); | ||
| 87 | } | ||
| 88 | |||
| 89 | void EmitBindlessImageAtomicSMax32(EmitContext&) { | ||
| 90 | throw LogicError("Unreachable instruction"); | ||
| 91 | } | ||
| 92 | |||
| 93 | void EmitBindlessImageAtomicUMax32(EmitContext&) { | ||
| 94 | throw LogicError("Unreachable instruction"); | ||
| 95 | } | ||
| 96 | |||
| 97 | void EmitBindlessImageAtomicInc32(EmitContext&) { | ||
| 98 | throw LogicError("Unreachable instruction"); | ||
| 99 | } | ||
| 100 | |||
| 101 | void EmitBindlessImageAtomicDec32(EmitContext&) { | ||
| 102 | throw LogicError("Unreachable instruction"); | ||
| 103 | } | ||
| 104 | |||
| 105 | void EmitBindlessImageAtomicAnd32(EmitContext&) { | ||
| 106 | throw LogicError("Unreachable instruction"); | ||
| 107 | } | ||
| 108 | |||
| 109 | void EmitBindlessImageAtomicOr32(EmitContext&) { | ||
| 110 | throw LogicError("Unreachable instruction"); | ||
| 111 | } | ||
| 112 | |||
| 113 | void EmitBindlessImageAtomicXor32(EmitContext&) { | ||
| 114 | throw LogicError("Unreachable instruction"); | ||
| 115 | } | ||
| 116 | |||
| 117 | void EmitBindlessImageAtomicExchange32(EmitContext&) { | ||
| 118 | throw LogicError("Unreachable instruction"); | ||
| 119 | } | ||
| 120 | |||
| 121 | void EmitBoundImageAtomicIAdd32(EmitContext&) { | ||
| 122 | throw LogicError("Unreachable instruction"); | ||
| 123 | } | ||
| 124 | |||
| 125 | void EmitBoundImageAtomicSMin32(EmitContext&) { | ||
| 126 | throw LogicError("Unreachable instruction"); | ||
| 127 | } | ||
| 128 | |||
| 129 | void EmitBoundImageAtomicUMin32(EmitContext&) { | ||
| 130 | throw LogicError("Unreachable instruction"); | ||
| 131 | } | ||
| 132 | |||
| 133 | void EmitBoundImageAtomicSMax32(EmitContext&) { | ||
| 134 | throw LogicError("Unreachable instruction"); | ||
| 135 | } | ||
| 136 | |||
| 137 | void EmitBoundImageAtomicUMax32(EmitContext&) { | ||
| 138 | throw LogicError("Unreachable instruction"); | ||
| 139 | } | ||
| 140 | |||
| 141 | void EmitBoundImageAtomicInc32(EmitContext&) { | ||
| 142 | throw LogicError("Unreachable instruction"); | ||
| 143 | } | ||
| 144 | |||
| 145 | void EmitBoundImageAtomicDec32(EmitContext&) { | ||
| 146 | throw LogicError("Unreachable instruction"); | ||
| 147 | } | ||
| 148 | |||
| 149 | void EmitBoundImageAtomicAnd32(EmitContext&) { | ||
| 150 | throw LogicError("Unreachable instruction"); | ||
| 151 | } | ||
| 152 | |||
| 153 | void EmitBoundImageAtomicOr32(EmitContext&) { | ||
| 154 | throw LogicError("Unreachable instruction"); | ||
| 155 | } | ||
| 156 | |||
| 157 | void EmitBoundImageAtomicXor32(EmitContext&) { | ||
| 158 | throw LogicError("Unreachable instruction"); | ||
| 159 | } | ||
| 160 | |||
| 161 | void EmitBoundImageAtomicExchange32(EmitContext&) { | ||
| 162 | throw LogicError("Unreachable instruction"); | ||
| 163 | } | ||
| 164 | |||
| 165 | } // namespace Shader::Backend::GLASM | ||