diff options
| author | 2021-05-15 18:16:39 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:31 -0400 | |
| commit | 9fb2ea08e84f7194136f5a2f320dd3de04e8ca5d (patch) | |
| tree | fe1fd5c571c684cd92cffeaef5768a58feae2500 /src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | |
| parent | glasm: Implement some graphics instructions on GLASM (diff) | |
| download | yuzu-9fb2ea08e84f7194136f5a2f320dd3de04e8ca5d.tar.gz yuzu-9fb2ea08e84f7194136f5a2f320dd3de04e8ca5d.tar.xz yuzu-9fb2ea08e84f7194136f5a2f320dd3de04e8ca5d.zip | |
glasm: Initial (broken) implementation of TEX on GLASM
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_glasm_image.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp index e69de29bb..a32d01925 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | |||
| @@ -0,0 +1,221 @@ | |||
| 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/modifiers.h" | ||
| 8 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 9 | |||
| 10 | namespace Shader::Backend::GLASM { | ||
| 11 | |||
| 12 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { | ||
| 13 | throw LogicError("Unreachable instruction"); | ||
| 14 | } | ||
| 15 | |||
| 16 | void EmitBindlessImageSampleExplicitLod(EmitContext&) { | ||
| 17 | throw LogicError("Unreachable instruction"); | ||
| 18 | } | ||
| 19 | |||
| 20 | void EmitBindlessImageSampleDrefImplicitLod(EmitContext&) { | ||
| 21 | throw LogicError("Unreachable instruction"); | ||
| 22 | } | ||
| 23 | |||
| 24 | void EmitBindlessImageSampleDrefExplicitLod(EmitContext&) { | ||
| 25 | throw LogicError("Unreachable instruction"); | ||
| 26 | } | ||
| 27 | |||
| 28 | void EmitBindlessImageGather(EmitContext&) { | ||
| 29 | throw LogicError("Unreachable instruction"); | ||
| 30 | } | ||
| 31 | |||
| 32 | void EmitBindlessImageGatherDref(EmitContext&) { | ||
| 33 | throw LogicError("Unreachable instruction"); | ||
| 34 | } | ||
| 35 | |||
| 36 | void EmitBindlessImageFetch(EmitContext&) { | ||
| 37 | throw LogicError("Unreachable instruction"); | ||
| 38 | } | ||
| 39 | |||
| 40 | void EmitBindlessImageQueryDimensions(EmitContext&) { | ||
| 41 | throw LogicError("Unreachable instruction"); | ||
| 42 | } | ||
| 43 | |||
| 44 | void EmitBindlessImageQueryLod(EmitContext&) { | ||
| 45 | throw LogicError("Unreachable instruction"); | ||
| 46 | } | ||
| 47 | |||
| 48 | void EmitBindlessImageGradient(EmitContext&) { | ||
| 49 | throw LogicError("Unreachable instruction"); | ||
| 50 | } | ||
| 51 | |||
| 52 | void EmitBindlessImageRead(EmitContext&) { | ||
| 53 | throw LogicError("Unreachable instruction"); | ||
| 54 | } | ||
| 55 | |||
| 56 | void EmitBindlessImageWrite(EmitContext&) { | ||
| 57 | throw LogicError("Unreachable instruction"); | ||
| 58 | } | ||
| 59 | |||
| 60 | void EmitBoundImageSampleImplicitLod(EmitContext&) { | ||
| 61 | throw LogicError("Unreachable instruction"); | ||
| 62 | } | ||
| 63 | |||
| 64 | void EmitBoundImageSampleExplicitLod(EmitContext&) { | ||
| 65 | throw LogicError("Unreachable instruction"); | ||
| 66 | } | ||
| 67 | |||
| 68 | void EmitBoundImageSampleDrefImplicitLod(EmitContext&) { | ||
| 69 | throw LogicError("Unreachable instruction"); | ||
| 70 | } | ||
| 71 | |||
| 72 | void EmitBoundImageSampleDrefExplicitLod(EmitContext&) { | ||
| 73 | throw LogicError("Unreachable instruction"); | ||
| 74 | } | ||
| 75 | |||
| 76 | void EmitBoundImageGather(EmitContext&) { | ||
| 77 | throw LogicError("Unreachable instruction"); | ||
| 78 | } | ||
| 79 | |||
| 80 | void EmitBoundImageGatherDref(EmitContext&) { | ||
| 81 | throw LogicError("Unreachable instruction"); | ||
| 82 | } | ||
| 83 | |||
| 84 | void EmitBoundImageFetch(EmitContext&) { | ||
| 85 | throw LogicError("Unreachable instruction"); | ||
| 86 | } | ||
| 87 | |||
| 88 | void EmitBoundImageQueryDimensions(EmitContext&) { | ||
| 89 | throw LogicError("Unreachable instruction"); | ||
| 90 | } | ||
| 91 | |||
| 92 | void EmitBoundImageQueryLod(EmitContext&) { | ||
| 93 | throw LogicError("Unreachable instruction"); | ||
| 94 | } | ||
| 95 | |||
| 96 | void EmitBoundImageGradient(EmitContext&) { | ||
| 97 | throw LogicError("Unreachable instruction"); | ||
| 98 | } | ||
| 99 | |||
| 100 | void EmitBoundImageRead(EmitContext&) { | ||
| 101 | throw LogicError("Unreachable instruction"); | ||
| 102 | } | ||
| 103 | |||
| 104 | void EmitBoundImageWrite(EmitContext&) { | ||
| 105 | throw LogicError("Unreachable instruction"); | ||
| 106 | } | ||
| 107 | |||
| 108 | std::string Texture([[maybe_unused]] EmitContext& ctx, IR::TextureInstInfo info, | ||
| 109 | [[maybe_unused]] const IR::Value& index) { | ||
| 110 | // FIXME | ||
| 111 | return fmt::format("texture[{}]", info.descriptor_index); | ||
| 112 | } | ||
| 113 | |||
| 114 | void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 115 | Register coords, Register bias_lc, | ||
| 116 | [[maybe_unused]] const IR::Value& offset) { | ||
| 117 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 118 | const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)}; | ||
| 119 | const std::string_view op{info.has_bias ? "TXB" : "TEX"}; | ||
| 120 | const std::string_view lod_clamp{info.has_lod_clamp ? ".LODCLAMP" : ""}; | ||
| 121 | const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""}; | ||
| 122 | const std::string texture{Texture(ctx, info, index)}; | ||
| 123 | const Register ret{ctx.reg_alloc.Define(inst)}; | ||
| 124 | // FIXME | ||
| 125 | const bool separate{info.type == TextureType::ColorArrayCube}; | ||
| 126 | if (separate) { | ||
| 127 | ctx.Add("{}.F{}{} {},{},{},{},2D;", op, lod_clamp, sparse_mod, ret, coords, bias_lc, | ||
| 128 | texture); | ||
| 129 | } else { | ||
| 130 | ctx.Add("MOV.F {}.w,{}.x;" | ||
| 131 | "{}.F{}{} {},{},{},2D;", | ||
| 132 | coords, bias_lc, op, lod_clamp, sparse_mod, ret, coords, texture); | ||
| 133 | } | ||
| 134 | if (sparse_inst) { | ||
| 135 | const Register sparse_ret{ctx.reg_alloc.Define(*sparse_inst)}; | ||
| 136 | ctx.Add("MOV.S {},-1;" | ||
| 137 | "MOV.S {}(NONRESIDENT),0;", | ||
| 138 | sparse_ret, sparse_ret); | ||
| 139 | sparse_inst->Invalidate(); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 144 | [[maybe_unused]] const IR::Value& index, | ||
| 145 | [[maybe_unused]] Register coords, [[maybe_unused]] Register lod_lc, | ||
| 146 | [[maybe_unused]] const IR::Value& offset) { | ||
| 147 | throw NotImplementedException("GLASM instruction"); | ||
| 148 | } | ||
| 149 | |||
| 150 | void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx, | ||
| 151 | [[maybe_unused]] IR::Inst& inst, | ||
| 152 | [[maybe_unused]] const IR::Value& index, | ||
| 153 | [[maybe_unused]] Register coords, | ||
| 154 | [[maybe_unused]] Register dref, | ||
| 155 | [[maybe_unused]] Register bias_lc, | ||
| 156 | [[maybe_unused]] const IR::Value& offset) { | ||
| 157 | throw NotImplementedException("GLASM instruction"); | ||
| 158 | } | ||
| 159 | |||
| 160 | void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx, | ||
| 161 | [[maybe_unused]] IR::Inst& inst, | ||
| 162 | [[maybe_unused]] const IR::Value& index, | ||
| 163 | [[maybe_unused]] Register coords, | ||
| 164 | [[maybe_unused]] Register dref, | ||
| 165 | [[maybe_unused]] Register lod_lc, | ||
| 166 | [[maybe_unused]] const IR::Value& offset) { | ||
| 167 | throw NotImplementedException("GLASM instruction"); | ||
| 168 | } | ||
| 169 | |||
| 170 | void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 171 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 172 | [[maybe_unused]] const IR::Value& offset, | ||
| 173 | [[maybe_unused]] const IR::Value& offset2) { | ||
| 174 | throw NotImplementedException("GLASM instruction"); | ||
| 175 | } | ||
| 176 | |||
| 177 | void EmitImageGatherDref([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 178 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 179 | [[maybe_unused]] const IR::Value& offset, | ||
| 180 | [[maybe_unused]] const IR::Value& offset2, | ||
| 181 | [[maybe_unused]] Register dref) { | ||
| 182 | throw NotImplementedException("GLASM instruction"); | ||
| 183 | } | ||
| 184 | |||
| 185 | void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 186 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 187 | [[maybe_unused]] Register offset, [[maybe_unused]] Register lod, | ||
| 188 | [[maybe_unused]] Register ms) { | ||
| 189 | throw NotImplementedException("GLASM instruction"); | ||
| 190 | } | ||
| 191 | |||
| 192 | void EmitImageQueryDimensions([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 193 | [[maybe_unused]] const IR::Value& index, | ||
| 194 | [[maybe_unused]] Register lod) { | ||
| 195 | throw NotImplementedException("GLASM instruction"); | ||
| 196 | } | ||
| 197 | |||
| 198 | void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 199 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords) { | ||
| 200 | throw NotImplementedException("GLASM instruction"); | ||
| 201 | } | ||
| 202 | |||
| 203 | void EmitImageGradient([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 204 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 205 | [[maybe_unused]] Register derivates, [[maybe_unused]] Register offset, | ||
| 206 | [[maybe_unused]] Register lod_clamp) { | ||
| 207 | throw NotImplementedException("GLASM instruction"); | ||
| 208 | } | ||
| 209 | |||
| 210 | void EmitImageRead([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 211 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords) { | ||
| 212 | throw NotImplementedException("GLASM instruction"); | ||
| 213 | } | ||
| 214 | |||
| 215 | void EmitImageWrite([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 216 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | ||
| 217 | [[maybe_unused]] Register color) { | ||
| 218 | throw NotImplementedException("GLASM instruction"); | ||
| 219 | } | ||
| 220 | |||
| 221 | } // namespace Shader::Backend::GLASM | ||