summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
diff options
context:
space:
mode:
authorGravatar ameerj2021-06-05 02:41:29 -0400
committerGravatar ameerj2021-07-22 21:51:37 -0400
commit421847cf1e33d5b95c9aa272bf3cf69afda3d964 (patch)
treea7fd72bf902697a9a32c18f023b0fb282a7029bf /src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
parentglsl: Fix image gather logic (diff)
downloadyuzu-421847cf1e33d5b95c9aa272bf3cf69afda3d964.tar.gz
yuzu-421847cf1e33d5b95c9aa272bf3cf69afda3d964.tar.xz
yuzu-421847cf1e33d5b95c9aa272bf3cf69afda3d964.zip
glsl: Implement image atomics and set layer
along with some more cleanup/oversight fixes
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_image.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_image.cpp188
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
104std::string PtpOffsets(const IR::Value& offset, const IR::Value& offset2) { 116std::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
543void 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
551void 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
559void 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
567void 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
575void 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
583void EmitImageAtomicInc32(EmitContext&, IR::Inst&, const IR::Value&, std::string_view,
584 std::string_view) {
585 NotImplemented();
586}
587
588void EmitImageAtomicDec32(EmitContext&, IR::Inst&, const IR::Value&, std::string_view,
589 std::string_view) {
590 NotImplemented();
591}
592
593void 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
601void 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
609void 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
617void 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
531void EmitBindlessImageSampleImplicitLod(EmitContext&) { 625void EmitBindlessImageSampleImplicitLod(EmitContext&) {
532 NotImplemented(); 626 NotImplemented();
533} 627}
@@ -624,4 +718,92 @@ void EmitBoundImageWrite(EmitContext&) {
624 NotImplemented(); 718 NotImplemented();
625} 719}
626 720
721void EmitBindlessImageAtomicIAdd32(EmitContext&) {
722 NotImplemented();
723}
724
725void EmitBindlessImageAtomicSMin32(EmitContext&) {
726 NotImplemented();
727}
728
729void EmitBindlessImageAtomicUMin32(EmitContext&) {
730 NotImplemented();
731}
732
733void EmitBindlessImageAtomicSMax32(EmitContext&) {
734 NotImplemented();
735}
736
737void EmitBindlessImageAtomicUMax32(EmitContext&) {
738 NotImplemented();
739}
740
741void EmitBindlessImageAtomicInc32(EmitContext&) {
742 NotImplemented();
743}
744
745void EmitBindlessImageAtomicDec32(EmitContext&) {
746 NotImplemented();
747}
748
749void EmitBindlessImageAtomicAnd32(EmitContext&) {
750 NotImplemented();
751}
752
753void EmitBindlessImageAtomicOr32(EmitContext&) {
754 NotImplemented();
755}
756
757void EmitBindlessImageAtomicXor32(EmitContext&) {
758 NotImplemented();
759}
760
761void EmitBindlessImageAtomicExchange32(EmitContext&) {
762 NotImplemented();
763}
764
765void EmitBoundImageAtomicIAdd32(EmitContext&) {
766 NotImplemented();
767}
768
769void EmitBoundImageAtomicSMin32(EmitContext&) {
770 NotImplemented();
771}
772
773void EmitBoundImageAtomicUMin32(EmitContext&) {
774 NotImplemented();
775}
776
777void EmitBoundImageAtomicSMax32(EmitContext&) {
778 NotImplemented();
779}
780
781void EmitBoundImageAtomicUMax32(EmitContext&) {
782 NotImplemented();
783}
784
785void EmitBoundImageAtomicInc32(EmitContext&) {
786 NotImplemented();
787}
788
789void EmitBoundImageAtomicDec32(EmitContext&) {
790 NotImplemented();
791}
792
793void EmitBoundImageAtomicAnd32(EmitContext&) {
794 NotImplemented();
795}
796
797void EmitBoundImageAtomicOr32(EmitContext&) {
798 NotImplemented();
799}
800
801void EmitBoundImageAtomicXor32(EmitContext&) {
802 NotImplemented();
803}
804
805void EmitBoundImageAtomicExchange32(EmitContext&) {
806 NotImplemented();
807}
808
627} // namespace Shader::Backend::GLSL 809} // namespace Shader::Backend::GLSL