diff options
| author | 2024-02-03 14:42:53 -0500 | |
|---|---|---|
| committer | 2024-02-05 12:01:09 -0500 | |
| commit | f296a9ce9a1a144d322d54d4628dba6f8a800cb7 (patch) | |
| tree | 214bd606c9d711bde3544bb1ea1bb493bbdf270a /src/shader_recompiler | |
| parent | Merge pull request #12901 from Kelebek1/timezone_firmware_fix (diff) | |
| download | yuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.tar.gz yuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.tar.xz yuzu-f296a9ce9a1a144d322d54d4628dba6f8a800cb7.zip | |
shader_recompiler: use only ConstOffset for OpImageFetch
Diffstat (limited to 'src/shader_recompiler')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | 41 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | 4 |
2 files changed, 7 insertions, 38 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: | |||
| 60 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); | 60 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | explicit ImageOperands(Id lod, Id ms) { | 63 | explicit ImageOperands(EmitContext& ctx, const IR::Value& offset, Id lod, Id ms) { |
| 64 | if (Sirit::ValidId(lod)) { | 64 | if (Sirit::ValidId(lod)) { |
| 65 | Add(spv::ImageOperandsMask::Lod, lod); | 65 | Add(spv::ImageOperandsMask::Lod, lod); |
| 66 | } | 66 | } |
| 67 | AddOffset(ctx, offset, ImageFetchOffsetAllowed); | ||
| 67 | if (Sirit::ValidId(ms)) { | 68 | if (Sirit::ValidId(ms)) { |
| 68 | Add(spv::ImageOperandsMask::Sample, ms); | 69 | Add(spv::ImageOperandsMask::Sample, ms); |
| 69 | } | 70 | } |
| @@ -311,37 +312,6 @@ Id ImageGatherSubpixelOffset(EmitContext& ctx, const IR::TextureInstInfo& info, | |||
| 311 | return coords; | 312 | return coords; |
| 312 | } | 313 | } |
| 313 | } | 314 | } |
| 314 | |||
| 315 | void AddOffsetToCoordinates(EmitContext& ctx, const IR::TextureInstInfo& info, Id& coords, | ||
| 316 | Id offset) { | ||
| 317 | if (!Sirit::ValidId(offset)) { | ||
| 318 | return; | ||
| 319 | } | ||
| 320 | |||
| 321 | Id result_type{}; | ||
| 322 | switch (info.type) { | ||
| 323 | case TextureType::Buffer: | ||
| 324 | case TextureType::Color1D: | ||
| 325 | case TextureType::ColorArray1D: { | ||
| 326 | result_type = ctx.U32[1]; | ||
| 327 | break; | ||
| 328 | } | ||
| 329 | case TextureType::Color2D: | ||
| 330 | case TextureType::Color2DRect: | ||
| 331 | case TextureType::ColorArray2D: { | ||
| 332 | result_type = ctx.U32[2]; | ||
| 333 | break; | ||
| 334 | } | ||
| 335 | case TextureType::Color3D: { | ||
| 336 | result_type = ctx.U32[3]; | ||
| 337 | break; | ||
| 338 | } | ||
| 339 | case TextureType::ColorCube: | ||
| 340 | case TextureType::ColorArrayCube: | ||
| 341 | return; | ||
| 342 | } | ||
| 343 | coords = ctx.OpIAdd(result_type, coords, offset); | ||
| 344 | } | ||
| 345 | } // Anonymous namespace | 315 | } // Anonymous namespace |
| 346 | 316 | ||
| 347 | Id EmitBindlessImageSampleImplicitLod(EmitContext&) { | 317 | Id EmitBindlessImageSampleImplicitLod(EmitContext&) { |
| @@ -524,10 +494,9 @@ Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, | |||
| 524 | operands.Span()); | 494 | operands.Span()); |
| 525 | } | 495 | } |
| 526 | 496 | ||
| 527 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, | 497 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 528 | Id lod, Id ms) { | 498 | const IR::Value& offset, Id lod, Id ms) { |
| 529 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 499 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| 530 | AddOffsetToCoordinates(ctx, info, coords, offset); | ||
| 531 | if (info.type == TextureType::Buffer) { | 500 | if (info.type == TextureType::Buffer) { |
| 532 | lod = Id{}; | 501 | lod = Id{}; |
| 533 | } | 502 | } |
| @@ -535,7 +504,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c | |||
| 535 | // This image is multisampled, lod must be implicit | 504 | // This image is multisampled, lod must be implicit |
| 536 | lod = Id{}; | 505 | lod = Id{}; |
| 537 | } | 506 | } |
| 538 | const ImageOperands operands(lod, ms); | 507 | const ImageOperands operands(ctx, offset, lod, ms); |
| 539 | return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], | 508 | return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], |
| 540 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); | 509 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); |
| 541 | } | 510 | } |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 5c01b1012..08fcabd58 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | |||
| @@ -537,8 +537,8 @@ Id EmitImageGather(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id | |||
| 537 | const IR::Value& offset, const IR::Value& offset2); | 537 | const IR::Value& offset, const IR::Value& offset2); |
| 538 | Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 538 | Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 539 | const IR::Value& offset, const IR::Value& offset2, Id dref); | 539 | const IR::Value& offset, const IR::Value& offset2, Id dref); |
| 540 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, | 540 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 541 | Id lod, Id ms); | 541 | const IR::Value& offset, Id lod, Id ms); |
| 542 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod, | 542 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod, |
| 543 | const IR::Value& skip_mips); | 543 | const IR::Value& skip_mips); |
| 544 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); | 544 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); |