diff options
| author | 2021-03-24 23:41:55 +0100 | |
|---|---|---|
| committer | 2021-07-22 21:51:24 -0400 | |
| commit | c7c518e280d1ac04adb08d45145690fd06ac7b18 (patch) | |
| tree | 1bce4c12238600828bef6bdf0c92da6f69c054b1 /src/shader_recompiler/ir_opt | |
| parent | shader: Implement SHFL (diff) | |
| download | yuzu-c7c518e280d1ac04adb08d45145690fd06ac7b18.tar.gz yuzu-c7c518e280d1ac04adb08d45145690fd06ac7b18.tar.xz yuzu-c7c518e280d1ac04adb08d45145690fd06ac7b18.zip | |
shader: Implement TLD4 and TLD4_B
Diffstat (limited to 'src/shader_recompiler/ir_opt')
| -rw-r--r-- | src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | 8 | ||||
| -rw-r--r-- | src/shader_recompiler/ir_opt/constant_propagation_pass.cpp | 12 | ||||
| -rw-r--r-- | src/shader_recompiler/ir_opt/texture_pass.cpp | 10 |
3 files changed, 29 insertions, 1 deletions
diff --git a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp index 61cc314c7..6fe06fda8 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -352,14 +352,20 @@ void VisitUsages(Info& info, IR::Inst& inst) { | |||
| 352 | case IR::Opcode::BindlessImageSampleExplicitLod: | 352 | case IR::Opcode::BindlessImageSampleExplicitLod: |
| 353 | case IR::Opcode::BindlessImageSampleDrefImplicitLod: | 353 | case IR::Opcode::BindlessImageSampleDrefImplicitLod: |
| 354 | case IR::Opcode::BindlessImageSampleDrefExplicitLod: | 354 | case IR::Opcode::BindlessImageSampleDrefExplicitLod: |
| 355 | case IR::Opcode::BindlessImageGather: | ||
| 356 | case IR::Opcode::BindlessImageGatherDref: | ||
| 355 | case IR::Opcode::BoundImageSampleImplicitLod: | 357 | case IR::Opcode::BoundImageSampleImplicitLod: |
| 356 | case IR::Opcode::BoundImageSampleExplicitLod: | 358 | case IR::Opcode::BoundImageSampleExplicitLod: |
| 357 | case IR::Opcode::BoundImageSampleDrefImplicitLod: | 359 | case IR::Opcode::BoundImageSampleDrefImplicitLod: |
| 358 | case IR::Opcode::BoundImageSampleDrefExplicitLod: | 360 | case IR::Opcode::BoundImageSampleDrefExplicitLod: |
| 361 | case IR::Opcode::BoundImageGather: | ||
| 362 | case IR::Opcode::BoundImageGatherDref: | ||
| 359 | case IR::Opcode::ImageSampleImplicitLod: | 363 | case IR::Opcode::ImageSampleImplicitLod: |
| 360 | case IR::Opcode::ImageSampleExplicitLod: | 364 | case IR::Opcode::ImageSampleExplicitLod: |
| 361 | case IR::Opcode::ImageSampleDrefImplicitLod: | 365 | case IR::Opcode::ImageSampleDrefImplicitLod: |
| 362 | case IR::Opcode::ImageSampleDrefExplicitLod: { | 366 | case IR::Opcode::ImageSampleDrefExplicitLod: |
| 367 | case IR::Opcode::ImageGather: | ||
| 368 | case IR::Opcode::ImageGatherDref: { | ||
| 363 | const TextureType type{inst.Flags<IR::TextureInstInfo>().type}; | 369 | const TextureType type{inst.Flags<IR::TextureInstInfo>().type}; |
| 364 | info.uses_sampled_1d |= type == TextureType::Color1D || type == TextureType::ColorArray1D || | 370 | info.uses_sampled_1d |= type == TextureType::Color1D || type == TextureType::ColorArray1D || |
| 365 | type == TextureType::Shadow1D || type == TextureType::ShadowArray1D; | 371 | type == TextureType::Shadow1D || type == TextureType::ShadowArray1D; |
diff --git a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp index 3dab424f6..28060dccf 100644 --- a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp +++ b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp | |||
| @@ -403,6 +403,18 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) { | |||
| 403 | return (base >> shift) & ((1U << count) - 1); | 403 | return (base >> shift) & ((1U << count) - 1); |
| 404 | }); | 404 | }); |
| 405 | return; | 405 | return; |
| 406 | case IR::Opcode::BitFieldSExtract: | ||
| 407 | FoldWhenAllImmediates(inst, [](s32 base, u32 shift, u32 count) { | ||
| 408 | const size_t back_shift = static_cast<size_t>(shift) + static_cast<size_t>(count); | ||
| 409 | if (back_shift > Common::BitSize<s32>()) { | ||
| 410 | throw LogicError("Undefined result in {}({}, {}, {})", IR::Opcode::BitFieldSExtract, | ||
| 411 | base, shift, count); | ||
| 412 | } | ||
| 413 | const size_t left_shift = Common::BitSize<s32>() - back_shift; | ||
| 414 | return static_cast<u32>(static_cast<s32>(base << left_shift) >> | ||
| 415 | static_cast<size_t>(Common::BitSize<s32>() - count)); | ||
| 416 | }); | ||
| 417 | return; | ||
| 406 | case IR::Opcode::BranchConditional: | 418 | case IR::Opcode::BranchConditional: |
| 407 | return FoldBranchConditional(inst); | 419 | return FoldBranchConditional(inst); |
| 408 | default: | 420 | default: |
diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index 2c8164b8a..454ac3e71 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp | |||
| @@ -45,6 +45,12 @@ IR::Opcode IndexedInstruction(const IR::Inst& inst) { | |||
| 45 | case IR::Opcode::BoundImageSampleDrefExplicitLod: | 45 | case IR::Opcode::BoundImageSampleDrefExplicitLod: |
| 46 | case IR::Opcode::BindlessImageSampleDrefExplicitLod: | 46 | case IR::Opcode::BindlessImageSampleDrefExplicitLod: |
| 47 | return IR::Opcode::ImageSampleDrefExplicitLod; | 47 | return IR::Opcode::ImageSampleDrefExplicitLod; |
| 48 | case IR::Opcode::BindlessImageGather: | ||
| 49 | case IR::Opcode::BoundImageGather: | ||
| 50 | return IR::Opcode::ImageGather; | ||
| 51 | case IR::Opcode::BindlessImageGatherDref: | ||
| 52 | case IR::Opcode::BoundImageGatherDref: | ||
| 53 | return IR::Opcode::ImageGatherDref; | ||
| 48 | default: | 54 | default: |
| 49 | return IR::Opcode::Void; | 55 | return IR::Opcode::Void; |
| 50 | } | 56 | } |
| @@ -56,11 +62,15 @@ bool IsBindless(const IR::Inst& inst) { | |||
| 56 | case IR::Opcode::BindlessImageSampleExplicitLod: | 62 | case IR::Opcode::BindlessImageSampleExplicitLod: |
| 57 | case IR::Opcode::BindlessImageSampleDrefImplicitLod: | 63 | case IR::Opcode::BindlessImageSampleDrefImplicitLod: |
| 58 | case IR::Opcode::BindlessImageSampleDrefExplicitLod: | 64 | case IR::Opcode::BindlessImageSampleDrefExplicitLod: |
| 65 | case IR::Opcode::BindlessImageGather: | ||
| 66 | case IR::Opcode::BindlessImageGatherDref: | ||
| 59 | return true; | 67 | return true; |
| 60 | case IR::Opcode::BoundImageSampleImplicitLod: | 68 | case IR::Opcode::BoundImageSampleImplicitLod: |
| 61 | case IR::Opcode::BoundImageSampleExplicitLod: | 69 | case IR::Opcode::BoundImageSampleExplicitLod: |
| 62 | case IR::Opcode::BoundImageSampleDrefImplicitLod: | 70 | case IR::Opcode::BoundImageSampleDrefImplicitLod: |
| 63 | case IR::Opcode::BoundImageSampleDrefExplicitLod: | 71 | case IR::Opcode::BoundImageSampleDrefExplicitLod: |
| 72 | case IR::Opcode::BoundImageGather: | ||
| 73 | case IR::Opcode::BoundImageGatherDref: | ||
| 64 | return false; | 74 | return false; |
| 65 | default: | 75 | default: |
| 66 | throw InvalidArgument("Invalid opcode {}", inst.Opcode()); | 76 | throw InvalidArgument("Invalid opcode {}", inst.Opcode()); |