diff options
| author | 2024-02-15 18:38:56 -0500 | |
|---|---|---|
| committer | 2024-02-15 18:38:56 -0500 | |
| commit | cb29aa04731e58ee78f8e0e66239c862fe9e559b (patch) | |
| tree | df88c847eec09bf9b4ed16e6df382f7a1bac1b6b | |
| parent | Merge pull request #12996 from german77/settings-ipc (diff) | |
| download | yuzu-cb29aa04731e58ee78f8e0e66239c862fe9e559b.tar.gz yuzu-cb29aa04731e58ee78f8e0e66239c862fe9e559b.tar.xz yuzu-cb29aa04731e58ee78f8e0e66239c862fe9e559b.zip | |
Revert "shader_recompiler: use only ConstOffset for OpImageFetch"
This reverts commit f296a9ce9a1a144d322d54d4628dba6f8a800cb7.
| -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, 38 insertions, 7 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 44281e407..64a4e0e55 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
| @@ -60,11 +60,10 @@ public: | |||
| 60 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); | 60 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | explicit ImageOperands(EmitContext& ctx, const IR::Value& offset, Id lod, Id ms) { | 63 | explicit ImageOperands(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); | ||
| 68 | if (Sirit::ValidId(ms)) { | 67 | if (Sirit::ValidId(ms)) { |
| 69 | Add(spv::ImageOperandsMask::Sample, ms); | 68 | Add(spv::ImageOperandsMask::Sample, ms); |
| 70 | } | 69 | } |
| @@ -312,6 +311,37 @@ Id ImageGatherSubpixelOffset(EmitContext& ctx, const IR::TextureInstInfo& info, | |||
| 312 | return coords; | 311 | return coords; |
| 313 | } | 312 | } |
| 314 | } | 313 | } |
| 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 | } | ||
| 315 | } // Anonymous namespace | 345 | } // Anonymous namespace |
| 316 | 346 | ||
| 317 | Id EmitBindlessImageSampleImplicitLod(EmitContext&) { | 347 | Id EmitBindlessImageSampleImplicitLod(EmitContext&) { |
| @@ -494,9 +524,10 @@ Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, | |||
| 494 | operands.Span()); | 524 | operands.Span()); |
| 495 | } | 525 | } |
| 496 | 526 | ||
| 497 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 527 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, |
| 498 | const IR::Value& offset, Id lod, Id ms) { | 528 | Id lod, Id ms) { |
| 499 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 529 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| 530 | AddOffsetToCoordinates(ctx, info, coords, offset); | ||
| 500 | if (info.type == TextureType::Buffer) { | 531 | if (info.type == TextureType::Buffer) { |
| 501 | lod = Id{}; | 532 | lod = Id{}; |
| 502 | } | 533 | } |
| @@ -504,7 +535,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c | |||
| 504 | // This image is multisampled, lod must be implicit | 535 | // This image is multisampled, lod must be implicit |
| 505 | lod = Id{}; | 536 | lod = Id{}; |
| 506 | } | 537 | } |
| 507 | const ImageOperands operands(ctx, offset, lod, ms); | 538 | const ImageOperands operands(lod, ms); |
| 508 | return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], | 539 | return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], |
| 509 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); | 540 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); |
| 510 | } | 541 | } |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 08fcabd58..5c01b1012 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, | 540 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, |
| 541 | const IR::Value& offset, Id lod, Id ms); | 541 | 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); |