diff options
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_image.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | 188 |
1 files changed, 185 insertions, 3 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp index f022c5f30..e3a69e3a5 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | |||
| @@ -45,7 +45,7 @@ std::string CastToIntVec(std::string_view value, const IR::TextureInstInfo& info | |||
| 45 | case TextureType::ColorArrayCube: | 45 | case TextureType::ColorArrayCube: |
| 46 | return fmt::format("ivec4({})", value); | 46 | return fmt::format("ivec4({})", value); |
| 47 | default: | 47 | default: |
| 48 | throw NotImplementedException("Offset type {}", info.type.Value()); | 48 | throw NotImplementedException("Integer cast for TextureType {}", info.type.Value()); |
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | 51 | ||
| @@ -64,7 +64,7 @@ std::string TexelFetchCastToInt(std::string_view value, const IR::TextureInstInf | |||
| 64 | case TextureType::ColorArrayCube: | 64 | case TextureType::ColorArrayCube: |
| 65 | return fmt::format("ivec4({})", value); | 65 | return fmt::format("ivec4({})", value); |
| 66 | default: | 66 | default: |
| 67 | throw NotImplementedException("Offset type {}", info.type.Value()); | 67 | throw NotImplementedException("TexelFetchCast type {}", info.type.Value()); |
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| 70 | 70 | ||
| @@ -98,7 +98,19 @@ std::string GetOffsetVec(EmitContext& ctx, const IR::Value& offset) { | |||
| 98 | break; | 98 | break; |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | return ctx.var_alloc.Consume(offset); | 101 | const auto offset_str{ctx.var_alloc.Consume(offset)}; |
| 102 | switch (offset.Type()) { | ||
| 103 | case IR::Type::U32: | ||
| 104 | return fmt::format("int({})", offset_str); | ||
| 105 | case IR::Type::U32x2: | ||
| 106 | return fmt::format("ivec2({})", offset_str); | ||
| 107 | case IR::Type::U32x3: | ||
| 108 | return fmt::format("ivec3({})", offset_str); | ||
| 109 | case IR::Type::U32x4: | ||
| 110 | return fmt::format("ivec4({})", offset_str); | ||
| 111 | default: | ||
| 112 | throw NotImplementedException("Offset type {}", offset.Type()); | ||
| 113 | } | ||
| 102 | } | 114 | } |
| 103 | 115 | ||
| 104 | std::string PtpOffsets(const IR::Value& offset, const IR::Value& offset2) { | 116 | std::string PtpOffsets(const IR::Value& offset, const IR::Value& offset2) { |
| @@ -528,6 +540,88 @@ void EmitImageWrite([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst | |||
| 528 | ctx.Add("imageStore({},{},{});", image, TexelFetchCastToInt(coords, info), color); | 540 | ctx.Add("imageStore({},{},{});", image, TexelFetchCastToInt(coords, info), color); |
| 529 | } | 541 | } |
| 530 | 542 | ||
| 543 | void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 544 | std::string_view coords, std::string_view value) { | ||
| 545 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 546 | const auto image{Image(ctx, info, index)}; | ||
| 547 | ctx.AddU32("{}=imageAtomicAdd({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | ||
| 548 | value); | ||
| 549 | } | ||
| 550 | |||
| 551 | void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 552 | std::string_view coords, std::string_view value) { | ||
| 553 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 554 | const auto image{Image(ctx, info, index)}; | ||
| 555 | ctx.AddU32("{}=imageAtomicMin({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info), | ||
| 556 | value); | ||
| 557 | } | ||
| 558 | |||
| 559 | void EmitImageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 560 | std::string_view coords, std::string_view value) { | ||
| 561 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 562 | const auto image{Image(ctx, info, index)}; | ||
| 563 | ctx.AddU32("{}=imageAtomicMin({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info), | ||
| 564 | value); | ||
| 565 | } | ||
| 566 | |||
| 567 | void EmitImageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 568 | std::string_view coords, std::string_view value) { | ||
| 569 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 570 | const auto image{Image(ctx, info, index)}; | ||
| 571 | ctx.AddU32("{}=imageAtomicMax({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info), | ||
| 572 | value); | ||
| 573 | } | ||
| 574 | |||
| 575 | void EmitImageAtomicUMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 576 | std::string_view coords, std::string_view value) { | ||
| 577 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 578 | const auto image{Image(ctx, info, index)}; | ||
| 579 | ctx.AddU32("{}=imageAtomicMax({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info), | ||
| 580 | value); | ||
| 581 | } | ||
| 582 | |||
| 583 | void EmitImageAtomicInc32(EmitContext&, IR::Inst&, const IR::Value&, std::string_view, | ||
| 584 | std::string_view) { | ||
| 585 | NotImplemented(); | ||
| 586 | } | ||
| 587 | |||
| 588 | void EmitImageAtomicDec32(EmitContext&, IR::Inst&, const IR::Value&, std::string_view, | ||
| 589 | std::string_view) { | ||
| 590 | NotImplemented(); | ||
| 591 | } | ||
| 592 | |||
| 593 | void EmitImageAtomicAnd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 594 | std::string_view coords, std::string_view value) { | ||
| 595 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 596 | const auto image{Image(ctx, info, index)}; | ||
| 597 | ctx.AddU32("{}=imageAtomicAnd({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | ||
| 598 | value); | ||
| 599 | } | ||
| 600 | |||
| 601 | void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 602 | std::string_view coords, std::string_view value) { | ||
| 603 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 604 | const auto image{Image(ctx, info, index)}; | ||
| 605 | ctx.AddU32("{}=imageAtomicOr({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | ||
| 606 | value); | ||
| 607 | } | ||
| 608 | |||
| 609 | void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 610 | std::string_view coords, std::string_view value) { | ||
| 611 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 612 | const auto image{Image(ctx, info, index)}; | ||
| 613 | ctx.AddU32("{}=imageAtomicXor({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | ||
| 614 | value); | ||
| 615 | } | ||
| 616 | |||
| 617 | void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 618 | std::string_view coords, std::string_view value) { | ||
| 619 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 620 | const auto image{Image(ctx, info, index)}; | ||
| 621 | ctx.AddU32("{}=imageAtomicExchange({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | ||
| 622 | value); | ||
| 623 | } | ||
| 624 | |||
| 531 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { | 625 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { |
| 532 | NotImplemented(); | 626 | NotImplemented(); |
| 533 | } | 627 | } |
| @@ -624,4 +718,92 @@ void EmitBoundImageWrite(EmitContext&) { | |||
| 624 | NotImplemented(); | 718 | NotImplemented(); |
| 625 | } | 719 | } |
| 626 | 720 | ||
| 721 | void EmitBindlessImageAtomicIAdd32(EmitContext&) { | ||
| 722 | NotImplemented(); | ||
| 723 | } | ||
| 724 | |||
| 725 | void EmitBindlessImageAtomicSMin32(EmitContext&) { | ||
| 726 | NotImplemented(); | ||
| 727 | } | ||
| 728 | |||
| 729 | void EmitBindlessImageAtomicUMin32(EmitContext&) { | ||
| 730 | NotImplemented(); | ||
| 731 | } | ||
| 732 | |||
| 733 | void EmitBindlessImageAtomicSMax32(EmitContext&) { | ||
| 734 | NotImplemented(); | ||
| 735 | } | ||
| 736 | |||
| 737 | void EmitBindlessImageAtomicUMax32(EmitContext&) { | ||
| 738 | NotImplemented(); | ||
| 739 | } | ||
| 740 | |||
| 741 | void EmitBindlessImageAtomicInc32(EmitContext&) { | ||
| 742 | NotImplemented(); | ||
| 743 | } | ||
| 744 | |||
| 745 | void EmitBindlessImageAtomicDec32(EmitContext&) { | ||
| 746 | NotImplemented(); | ||
| 747 | } | ||
| 748 | |||
| 749 | void EmitBindlessImageAtomicAnd32(EmitContext&) { | ||
| 750 | NotImplemented(); | ||
| 751 | } | ||
| 752 | |||
| 753 | void EmitBindlessImageAtomicOr32(EmitContext&) { | ||
| 754 | NotImplemented(); | ||
| 755 | } | ||
| 756 | |||
| 757 | void EmitBindlessImageAtomicXor32(EmitContext&) { | ||
| 758 | NotImplemented(); | ||
| 759 | } | ||
| 760 | |||
| 761 | void EmitBindlessImageAtomicExchange32(EmitContext&) { | ||
| 762 | NotImplemented(); | ||
| 763 | } | ||
| 764 | |||
| 765 | void EmitBoundImageAtomicIAdd32(EmitContext&) { | ||
| 766 | NotImplemented(); | ||
| 767 | } | ||
| 768 | |||
| 769 | void EmitBoundImageAtomicSMin32(EmitContext&) { | ||
| 770 | NotImplemented(); | ||
| 771 | } | ||
| 772 | |||
| 773 | void EmitBoundImageAtomicUMin32(EmitContext&) { | ||
| 774 | NotImplemented(); | ||
| 775 | } | ||
| 776 | |||
| 777 | void EmitBoundImageAtomicSMax32(EmitContext&) { | ||
| 778 | NotImplemented(); | ||
| 779 | } | ||
| 780 | |||
| 781 | void EmitBoundImageAtomicUMax32(EmitContext&) { | ||
| 782 | NotImplemented(); | ||
| 783 | } | ||
| 784 | |||
| 785 | void EmitBoundImageAtomicInc32(EmitContext&) { | ||
| 786 | NotImplemented(); | ||
| 787 | } | ||
| 788 | |||
| 789 | void EmitBoundImageAtomicDec32(EmitContext&) { | ||
| 790 | NotImplemented(); | ||
| 791 | } | ||
| 792 | |||
| 793 | void EmitBoundImageAtomicAnd32(EmitContext&) { | ||
| 794 | NotImplemented(); | ||
| 795 | } | ||
| 796 | |||
| 797 | void EmitBoundImageAtomicOr32(EmitContext&) { | ||
| 798 | NotImplemented(); | ||
| 799 | } | ||
| 800 | |||
| 801 | void EmitBoundImageAtomicXor32(EmitContext&) { | ||
| 802 | NotImplemented(); | ||
| 803 | } | ||
| 804 | |||
| 805 | void EmitBoundImageAtomicExchange32(EmitContext&) { | ||
| 806 | NotImplemented(); | ||
| 807 | } | ||
| 808 | |||
| 627 | } // namespace Shader::Backend::GLSL | 809 | } // namespace Shader::Backend::GLSL |