diff options
| author | 2021-07-25 11:39:04 -0700 | |
|---|---|---|
| committer | 2021-07-25 11:39:04 -0700 | |
| commit | 98b26b6e126d4775fdf3f773fe8a8ac808a8ff8f (patch) | |
| tree | 816faa96c2c4d291825063433331a8ea4b3d08f1 /src/shader_recompiler/backend/glsl/emit_glsl_convert.cpp | |
| parent | Merge pull request #6699 from lat9nq/common-threads (diff) | |
| parent | shader: Support out of bound local memory reads and immediate writes (diff) | |
| download | yuzu-98b26b6e126d4775fdf3f773fe8a8ac808a8ff8f.tar.gz yuzu-98b26b6e126d4775fdf3f773fe8a8ac808a8ff8f.tar.xz yuzu-98b26b6e126d4775fdf3f773fe8a8ac808a8ff8f.zip | |
Merge pull request #6585 from ameerj/hades
Shader Decompiler Rewrite
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_convert.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_convert.cpp | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_convert.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_convert.cpp new file mode 100644 index 000000000..eeae6562c --- /dev/null +++ b/src/shader_recompiler/backend/glsl/emit_glsl_convert.cpp | |||
| @@ -0,0 +1,230 @@ | |||
| 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 <string_view> | ||
| 6 | |||
| 7 | #include "shader_recompiler/backend/glsl/emit_context.h" | ||
| 8 | #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" | ||
| 9 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 10 | |||
| 11 | namespace Shader::Backend::GLSL { | ||
| 12 | void EmitConvertS16F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 13 | [[maybe_unused]] std::string_view value) { | ||
| 14 | NotImplemented(); | ||
| 15 | } | ||
| 16 | |||
| 17 | void EmitConvertS16F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 18 | ctx.AddU32("{}=(int({})&0xffff)|(bitfieldExtract(int({}),31,1)<<15);", inst, value, value); | ||
| 19 | } | ||
| 20 | |||
| 21 | void EmitConvertS16F64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 22 | [[maybe_unused]] std::string_view value) { | ||
| 23 | NotImplemented(); | ||
| 24 | } | ||
| 25 | |||
| 26 | void EmitConvertS32F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 27 | [[maybe_unused]] std::string_view value) { | ||
| 28 | NotImplemented(); | ||
| 29 | } | ||
| 30 | |||
| 31 | void EmitConvertS32F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 32 | ctx.AddU32("{}=int({});", inst, value); | ||
| 33 | } | ||
| 34 | |||
| 35 | void EmitConvertS32F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 36 | ctx.AddU32("{}=int({});", inst, value); | ||
| 37 | } | ||
| 38 | |||
| 39 | void EmitConvertS64F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 40 | [[maybe_unused]] std::string_view value) { | ||
| 41 | NotImplemented(); | ||
| 42 | } | ||
| 43 | |||
| 44 | void EmitConvertS64F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 45 | ctx.AddU64("{}=int64_t({});", inst, value); | ||
| 46 | } | ||
| 47 | |||
| 48 | void EmitConvertS64F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 49 | ctx.AddU64("{}=int64_t({});", inst, value); | ||
| 50 | } | ||
| 51 | |||
| 52 | void EmitConvertU16F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 53 | [[maybe_unused]] std::string_view value) { | ||
| 54 | NotImplemented(); | ||
| 55 | } | ||
| 56 | |||
| 57 | void EmitConvertU16F32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 58 | [[maybe_unused]] std::string_view value) { | ||
| 59 | NotImplemented(); | ||
| 60 | } | ||
| 61 | |||
| 62 | void EmitConvertU16F64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 63 | [[maybe_unused]] std::string_view value) { | ||
| 64 | NotImplemented(); | ||
| 65 | } | ||
| 66 | |||
| 67 | void EmitConvertU32F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 68 | [[maybe_unused]] std::string_view value) { | ||
| 69 | NotImplemented(); | ||
| 70 | } | ||
| 71 | |||
| 72 | void EmitConvertU32F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 73 | ctx.AddU32("{}=uint({});", inst, value); | ||
| 74 | } | ||
| 75 | |||
| 76 | void EmitConvertU32F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 77 | ctx.AddU32("{}=uint({});", inst, value); | ||
| 78 | } | ||
| 79 | |||
| 80 | void EmitConvertU64F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 81 | [[maybe_unused]] std::string_view value) { | ||
| 82 | NotImplemented(); | ||
| 83 | } | ||
| 84 | |||
| 85 | void EmitConvertU64F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 86 | ctx.AddU64("{}=uint64_t({});", inst, value); | ||
| 87 | } | ||
| 88 | |||
| 89 | void EmitConvertU64F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 90 | ctx.AddU64("{}=uint64_t({});", inst, value); | ||
| 91 | } | ||
| 92 | |||
| 93 | void EmitConvertU64U32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 94 | ctx.AddU64("{}=uint64_t({});", inst, value); | ||
| 95 | } | ||
| 96 | |||
| 97 | void EmitConvertU32U64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 98 | ctx.AddU32("{}=uint({});", inst, value); | ||
| 99 | } | ||
| 100 | |||
| 101 | void EmitConvertF16F32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 102 | [[maybe_unused]] std::string_view value) { | ||
| 103 | NotImplemented(); | ||
| 104 | } | ||
| 105 | |||
| 106 | void EmitConvertF32F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 107 | [[maybe_unused]] std::string_view value) { | ||
| 108 | NotImplemented(); | ||
| 109 | } | ||
| 110 | |||
| 111 | void EmitConvertF32F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 112 | ctx.AddF32("{}=float({});", inst, value); | ||
| 113 | } | ||
| 114 | |||
| 115 | void EmitConvertF64F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 116 | ctx.AddF64("{}=double({});", inst, value); | ||
| 117 | } | ||
| 118 | |||
| 119 | void EmitConvertF16S8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 120 | [[maybe_unused]] std::string_view value) { | ||
| 121 | NotImplemented(); | ||
| 122 | } | ||
| 123 | |||
| 124 | void EmitConvertF16S16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 125 | [[maybe_unused]] std::string_view value) { | ||
| 126 | NotImplemented(); | ||
| 127 | } | ||
| 128 | |||
| 129 | void EmitConvertF16S32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 130 | [[maybe_unused]] std::string_view value) { | ||
| 131 | NotImplemented(); | ||
| 132 | } | ||
| 133 | |||
| 134 | void EmitConvertF16S64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 135 | [[maybe_unused]] std::string_view value) { | ||
| 136 | NotImplemented(); | ||
| 137 | } | ||
| 138 | |||
| 139 | void EmitConvertF16U8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 140 | [[maybe_unused]] std::string_view value) { | ||
| 141 | NotImplemented(); | ||
| 142 | } | ||
| 143 | |||
| 144 | void EmitConvertF16U16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 145 | [[maybe_unused]] std::string_view value) { | ||
| 146 | NotImplemented(); | ||
| 147 | } | ||
| 148 | |||
| 149 | void EmitConvertF16U32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 150 | [[maybe_unused]] std::string_view value) { | ||
| 151 | NotImplemented(); | ||
| 152 | } | ||
| 153 | |||
| 154 | void EmitConvertF16U64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 155 | [[maybe_unused]] std::string_view value) { | ||
| 156 | NotImplemented(); | ||
| 157 | } | ||
| 158 | |||
| 159 | void EmitConvertF32S8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 160 | [[maybe_unused]] std::string_view value) { | ||
| 161 | NotImplemented(); | ||
| 162 | } | ||
| 163 | |||
| 164 | void EmitConvertF32S16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 165 | [[maybe_unused]] std::string_view value) { | ||
| 166 | NotImplemented(); | ||
| 167 | } | ||
| 168 | |||
| 169 | void EmitConvertF32S32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 170 | ctx.AddF32("{}=float(int({}));", inst, value); | ||
| 171 | } | ||
| 172 | |||
| 173 | void EmitConvertF32S64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 174 | ctx.AddF32("{}=float(int64_t({}));", inst, value); | ||
| 175 | } | ||
| 176 | |||
| 177 | void EmitConvertF32U8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 178 | [[maybe_unused]] std::string_view value) { | ||
| 179 | NotImplemented(); | ||
| 180 | } | ||
| 181 | |||
| 182 | void EmitConvertF32U16(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 183 | ctx.AddF32("{}=float({}&0xffff);", inst, value); | ||
| 184 | } | ||
| 185 | |||
| 186 | void EmitConvertF32U32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 187 | ctx.AddF32("{}=float({});", inst, value); | ||
| 188 | } | ||
| 189 | |||
| 190 | void EmitConvertF32U64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 191 | ctx.AddF32("{}=float({});", inst, value); | ||
| 192 | } | ||
| 193 | |||
| 194 | void EmitConvertF64S8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 195 | [[maybe_unused]] std::string_view value) { | ||
| 196 | NotImplemented(); | ||
| 197 | } | ||
| 198 | |||
| 199 | void EmitConvertF64S16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 200 | [[maybe_unused]] std::string_view value) { | ||
| 201 | NotImplemented(); | ||
| 202 | } | ||
| 203 | |||
| 204 | void EmitConvertF64S32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 205 | ctx.AddF64("{}=double(int({}));", inst, value); | ||
| 206 | } | ||
| 207 | |||
| 208 | void EmitConvertF64S64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 209 | ctx.AddF64("{}=double(int64_t({}));", inst, value); | ||
| 210 | } | ||
| 211 | |||
| 212 | void EmitConvertF64U8([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 213 | [[maybe_unused]] std::string_view value) { | ||
| 214 | NotImplemented(); | ||
| 215 | } | ||
| 216 | |||
| 217 | void EmitConvertF64U16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 218 | [[maybe_unused]] std::string_view value) { | ||
| 219 | NotImplemented(); | ||
| 220 | } | ||
| 221 | |||
| 222 | void EmitConvertF64U32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 223 | ctx.AddF64("{}=double({});", inst, value); | ||
| 224 | } | ||
| 225 | |||
| 226 | void EmitConvertF64U64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | ||
| 227 | ctx.AddF64("{}=double({});", inst, value); | ||
| 228 | } | ||
| 229 | |||
| 230 | } // namespace Shader::Backend::GLSL | ||