summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2024-02-03 20:42:53 +0100
committerLiam <byteslice@airmail.cc>2024-02-05 18:01:09 +0100
commitf296a9ce9a1a144d322d54d4628dba6f8a800cb7 (patch)
tree214bd606c9d711bde3544bb1ea1bb493bbdf270a /src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
parentMerge pull request #12901 from Kelebek1/timezone_firmware_fix (diff)
downloadyuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.tar
yuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.tar.gz
yuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.tar.bz2
yuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.tar.lz
yuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.tar.xz
yuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.tar.zst
yuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.zip
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_image.cpp')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_image.cpp41
1 files changed, 5 insertions, 36 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
index 64a4e0e55..44281e407 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
@@ -60,10 +60,11 @@ public:
Add(spv::ImageOperandsMask::ConstOffsets, offsets);
}
- explicit ImageOperands(Id lod, Id ms) {
+ explicit ImageOperands(EmitContext& ctx, const IR::Value& offset, Id lod, Id ms) {
if (Sirit::ValidId(lod)) {
Add(spv::ImageOperandsMask::Lod, lod);
}
+ AddOffset(ctx, offset, ImageFetchOffsetAllowed);
if (Sirit::ValidId(ms)) {
Add(spv::ImageOperandsMask::Sample, ms);
}
@@ -311,37 +312,6 @@ Id ImageGatherSubpixelOffset(EmitContext& ctx, const IR::TextureInstInfo& info,
return coords;
}
}
-
-void AddOffsetToCoordinates(EmitContext& ctx, const IR::TextureInstInfo& info, Id& coords,
- Id offset) {
- if (!Sirit::ValidId(offset)) {
- return;
- }
-
- Id result_type{};
- switch (info.type) {
- case TextureType::Buffer:
- case TextureType::Color1D:
- case TextureType::ColorArray1D: {
- result_type = ctx.U32[1];
- break;
- }
- case TextureType::Color2D:
- case TextureType::Color2DRect:
- case TextureType::ColorArray2D: {
- result_type = ctx.U32[2];
- break;
- }
- case TextureType::Color3D: {
- result_type = ctx.U32[3];
- break;
- }
- case TextureType::ColorCube:
- case TextureType::ColorArrayCube:
- return;
- }
- coords = ctx.OpIAdd(result_type, coords, offset);
-}
} // Anonymous namespace
Id EmitBindlessImageSampleImplicitLod(EmitContext&) {
@@ -524,10 +494,9 @@ Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index,
operands.Span());
}
-Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset,
- Id lod, Id ms) {
+Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
+ const IR::Value& offset, Id lod, Id ms) {
const auto info{inst->Flags<IR::TextureInstInfo>()};
- AddOffsetToCoordinates(ctx, info, coords, offset);
if (info.type == TextureType::Buffer) {
lod = Id{};
}
@@ -535,7 +504,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c
// This image is multisampled, lod must be implicit
lod = Id{};
}
- const ImageOperands operands(lod, ms);
+ const ImageOperands operands(ctx, offset, lod, ms);
return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4],
TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span());
}