summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_glasm_image.cpp')
-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 {
43std::string Texture(EmitContext& ctx, IR::TextureInstInfo info, 43std::string Texture(EmitContext& ctx, IR::TextureInstInfo info,
44 [[maybe_unused]] const IR::Value& index) { 44 [[maybe_unused]] const IR::Value& index) {
45 // FIXME: indexed reads 45 // FIXME: indexed reads
46 return fmt::format("texture[{}]", ctx.texture_bindings.at(info.descriptor_index)); 46 if (info.type == TextureType::Buffer) {
47 return fmt::format("texture[{}]", ctx.texture_buffer_bindings.at(info.descriptor_index));
48 } else {
49 return fmt::format("texture[{}]", ctx.texture_bindings.at(info.descriptor_index));
50 }
47} 51}
48 52
49std::string_view TextureType(IR::TextureInstInfo info) { 53std::string_view TextureType(IR::TextureInstInfo info) {
@@ -421,11 +425,28 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde
421 StoreSparse(ctx, sparse_inst); 425 StoreSparse(ctx, sparse_inst);
422} 426}
423 427
424void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 428void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
425 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coord, 429 const IR::Value& coord, const IR::Value& offset, ScalarS32 lod, ScalarS32 ms) {
426 [[maybe_unused]] Register offset, [[maybe_unused]] Register lod, 430 const auto info{inst.Flags<IR::TextureInstInfo>()};
427 [[maybe_unused]] Register ms) { 431 const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
428 throw NotImplementedException("GLASM instruction"); 432 const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
433 const std::string_view type{TextureType(info)};
434 const std::string texture{Texture(ctx, info, index)};
435 const std::string offset_vec{Offset(ctx, offset)};
436 const auto [coord_vec, coord_alloc]{Coord(ctx, coord)};
437 const Register ret{ctx.reg_alloc.Define(inst)};
438 if (info.type == TextureType::Buffer) {
439 ctx.Add("TXF.F{} {},{},{},{}{};", sparse_mod, ret, coord_vec, texture, type, offset_vec);
440 } else if (ms.type != Type::Void) {
441 ctx.Add("MOV.S {}.w,{};"
442 "TXFMS.F{} {},{},{},{}{};",
443 coord_vec, ms, sparse_mod, ret, coord_vec, texture, type, offset_vec);
444 } else {
445 ctx.Add("MOV.S {}.w,{};"
446 "TXF.F{} {},{},{},{}{};",
447 coord_vec, lod, sparse_mod, ret, coord_vec, texture, type, offset_vec);
448 }
449 StoreSparse(ctx, sparse_inst);
429} 450}
430 451
431void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, 452void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,