summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-05-19 07:05:24 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:32 +0200
commit4a22942f452dd1bba5e10d20217a0bfbf214dacb (patch)
treeb54e2cde969a5e44f08181745d5d4a3549f7e295 /src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
parentglasm: Implement IADD.CC (diff)
downloadyuzu-4a22942f452dd1bba5e10d20217a0bfbf214dacb.tar
yuzu-4a22942f452dd1bba5e10d20217a0bfbf214dacb.tar.gz
yuzu-4a22942f452dd1bba5e10d20217a0bfbf214dacb.tar.bz2
yuzu-4a22942f452dd1bba5e10d20217a0bfbf214dacb.tar.lz
yuzu-4a22942f452dd1bba5e10d20217a0bfbf214dacb.tar.xz
yuzu-4a22942f452dd1bba5e10d20217a0bfbf214dacb.tar.zst
yuzu-4a22942f452dd1bba5e10d20217a0bfbf214dacb.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_image.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
index 7b95505e2..333a003c9 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
@@ -43,7 +43,11 @@ struct ScopedRegister {
std::string Texture(EmitContext& ctx, IR::TextureInstInfo info,
[[maybe_unused]] const IR::Value& index) {
// FIXME: indexed reads
- return fmt::format("texture[{}]", ctx.texture_bindings.at(info.descriptor_index));
+ if (info.type == TextureType::Buffer) {
+ return fmt::format("texture[{}]", ctx.texture_buffer_bindings.at(info.descriptor_index));
+ } else {
+ return fmt::format("texture[{}]", ctx.texture_bindings.at(info.descriptor_index));
+ }
}
std::string_view TextureType(IR::TextureInstInfo info) {
@@ -421,11 +425,28 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde
StoreSparse(ctx, sparse_inst);
}
-void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
- [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coord,
- [[maybe_unused]] Register offset, [[maybe_unused]] Register lod,
- [[maybe_unused]] Register ms) {
- throw NotImplementedException("GLASM instruction");
+void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
+ const IR::Value& coord, const IR::Value& offset, ScalarS32 lod, ScalarS32 ms) {
+ const auto info{inst.Flags<IR::TextureInstInfo>()};
+ const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
+ const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
+ const std::string_view type{TextureType(info)};
+ const std::string texture{Texture(ctx, info, index)};
+ const std::string offset_vec{Offset(ctx, offset)};
+ const auto [coord_vec, coord_alloc]{Coord(ctx, coord)};
+ const Register ret{ctx.reg_alloc.Define(inst)};
+ if (info.type == TextureType::Buffer) {
+ ctx.Add("TXF.F{} {},{},{},{}{};", sparse_mod, ret, coord_vec, texture, type, offset_vec);
+ } else if (ms.type != Type::Void) {
+ ctx.Add("MOV.S {}.w,{};"
+ "TXFMS.F{} {},{},{},{}{};",
+ coord_vec, ms, sparse_mod, ret, coord_vec, texture, type, offset_vec);
+ } else {
+ ctx.Add("MOV.S {}.w,{};"
+ "TXF.F{} {},{},{},{}{};",
+ coord_vec, lod, sparse_mod, ret, coord_vec, texture, type, offset_vec);
+ }
+ StoreSparse(ctx, sparse_inst);
}
void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,