summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/engines/shader_bytecode.h148
1 files changed, 147 insertions, 1 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index 6e555ea03..88b4d0bac 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -271,6 +271,15 @@ enum class TextureProcessMode : u64 {
271 LLA = 7 // Load LOD. The A is unknown, does not appear to differ with LL 271 LLA = 7 // Load LOD. The A is unknown, does not appear to differ with LL
272}; 272};
273 273
274enum class TextureMiscMode : u64 {
275 DC,
276 AOFFI, // Uses Offset
277 NDV,
278 NODEP,
279 MZ,
280 PTP,
281};
282
274enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 }; 283enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 };
275enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 }; 284enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 };
276 285
@@ -590,42 +599,127 @@ union Instruction {
590 BitField<28, 1, u64> array; 599 BitField<28, 1, u64> array;
591 BitField<29, 2, TextureType> texture_type; 600 BitField<29, 2, TextureType> texture_type;
592 BitField<31, 4, u64> component_mask; 601 BitField<31, 4, u64> component_mask;
602 BitField<49, 1, u64> nodep_flag;
603 BitField<50, 1, u64> dc_flag;
604 BitField<54, 1, u64> aoffi_flag;
593 BitField<55, 3, TextureProcessMode> process_mode; 605 BitField<55, 3, TextureProcessMode> process_mode;
594 606
595 bool IsComponentEnabled(std::size_t component) const { 607 bool IsComponentEnabled(std::size_t component) const {
596 return ((1ull << component) & component_mask) != 0; 608 return ((1ull << component) & component_mask) != 0;
597 } 609 }
610
611 TextureProcessMode GetTextureProcessMode() const {
612 return process_mode;
613 }
614
615 bool UsesMiscMode(TextureMiscMode mode) const {
616 switch (mode) {
617 case TextureMiscMode::DC:
618 return dc_flag != 0;
619 case TextureMiscMode::NODEP:
620 return nodep_flag != 0;
621 case TextureMiscMode::AOFFI:
622 return aoffi_flag != 0;
623 default:
624 break;
625 }
626 return false;
627 }
598 } tex; 628 } tex;
599 629
600 union { 630 union {
601 BitField<22, 6, TextureQueryType> query_type; 631 BitField<22, 6, TextureQueryType> query_type;
602 BitField<31, 4, u64> component_mask; 632 BitField<31, 4, u64> component_mask;
633 BitField<49, 1, u64> nodep_flag;
634
635 bool UsesMiscMode(TextureMiscMode mode) const {
636 switch (mode) {
637 case TextureMiscMode::NODEP:
638 return nodep_flag != 0;
639 default:
640 break;
641 }
642 return false;
643 }
603 } txq; 644 } txq;
604 645
605 union { 646 union {
606 BitField<28, 1, u64> array; 647 BitField<28, 1, u64> array;
607 BitField<29, 2, TextureType> texture_type; 648 BitField<29, 2, TextureType> texture_type;
608 BitField<31, 4, u64> component_mask; 649 BitField<31, 4, u64> component_mask;
650 BitField<35, 1, u64> ndv_flag;
651 BitField<49, 1, u64> nodep_flag;
609 652
610 bool IsComponentEnabled(std::size_t component) const { 653 bool IsComponentEnabled(std::size_t component) const {
611 return ((1ull << component) & component_mask) != 0; 654 return ((1ull << component) & component_mask) != 0;
612 } 655 }
656
657 bool UsesMiscMode(TextureMiscMode mode) const {
658 switch (mode) {
659 case TextureMiscMode::NDV:
660 return (ndv_flag != 0);
661 case TextureMiscMode::NODEP:
662 return (nodep_flag != 0);
663 default:
664 break;
665 }
666 return false;
667 }
613 } tmml; 668 } tmml;
614 669
615 union { 670 union {
616 BitField<28, 1, u64> array; 671 BitField<28, 1, u64> array;
617 BitField<29, 2, TextureType> texture_type; 672 BitField<29, 2, TextureType> texture_type;
673 BitField<35, 1, u64> ndv_flag;
674 BitField<49, 1, u64> nodep_flag;
675 BitField<50, 1, u64> dc_flag;
676 BitField<54, 2, u64> info;
618 BitField<56, 2, u64> component; 677 BitField<56, 2, u64> component;
678
679 bool UsesMiscMode(TextureMiscMode mode) const {
680 switch (mode) {
681 case TextureMiscMode::NDV:
682 return ndv_flag != 0;
683 case TextureMiscMode::NODEP:
684 return nodep_flag != 0;
685 case TextureMiscMode::DC:
686 return dc_flag != 0;
687 case TextureMiscMode::AOFFI:
688 return info == 1;
689 case TextureMiscMode::PTP:
690 return info == 2;
691 default:
692 break;
693 }
694 return false;
695 }
619 } tld4; 696 } tld4;
620 697
621 union { 698 union {
699 BitField<49, 1, u64> nodep_flag;
700 BitField<50, 1, u64> dc_flag;
701 BitField<51, 1, u64> aoffi_flag;
622 BitField<52, 2, u64> component; 702 BitField<52, 2, u64> component;
703
704 bool UsesMiscMode(TextureMiscMode mode) const {
705 switch (mode) {
706 case TextureMiscMode::DC:
707 return dc_flag != 0;
708 case TextureMiscMode::NODEP:
709 return nodep_flag != 0;
710 case TextureMiscMode::AOFFI:
711 return aoffi_flag != 0;
712 default:
713 break;
714 }
715 return false;
716 }
623 } tld4s; 717 } tld4s;
624 718
625 union { 719 union {
626 BitField<0, 8, Register> gpr0; 720 BitField<0, 8, Register> gpr0;
627 BitField<28, 8, Register> gpr28; 721 BitField<28, 8, Register> gpr28;
628 BitField<49, 1, u64> nodep; 722 BitField<49, 1, u64> nodep_flag;
629 BitField<50, 3, u64> component_mask_selector; 723 BitField<50, 3, u64> component_mask_selector;
630 BitField<53, 4, u64> texture_info; 724 BitField<53, 4, u64> texture_info;
631 725
@@ -645,6 +739,37 @@ union Instruction {
645 UNREACHABLE(); 739 UNREACHABLE();
646 } 740 }
647 741
742 TextureProcessMode GetTextureProcessMode() const {
743 switch (texture_info) {
744 case 0:
745 case 2:
746 case 6:
747 case 8:
748 case 9:
749 case 11:
750 return TextureProcessMode::LZ;
751 case 3:
752 case 5:
753 case 13:
754 return TextureProcessMode::LL;
755 default:
756 break;
757 }
758 return TextureProcessMode::None;
759 }
760
761 bool UsesMiscMode(TextureMiscMode mode) const {
762 switch (mode) {
763 case TextureMiscMode::DC:
764 return (texture_info >= 4 && texture_info <= 6) || texture_info == 9;
765 case TextureMiscMode::NODEP:
766 return nodep_flag != 0;
767 default:
768 break;
769 }
770 return false;
771 }
772
648 bool IsArrayTexture() const { 773 bool IsArrayTexture() const {
649 // TEXS only supports Texture2D arrays. 774 // TEXS only supports Texture2D arrays.
650 return texture_info >= 7 && texture_info <= 9; 775 return texture_info >= 7 && texture_info <= 9;
@@ -673,6 +798,7 @@ union Instruction {
673 } texs; 798 } texs;
674 799
675 union { 800 union {
801 BitField<49, 1, u64> nodep_flag;
676 BitField<53, 4, u64> texture_info; 802 BitField<53, 4, u64> texture_info;
677 803
678 TextureType GetTextureType() const { 804 TextureType GetTextureType() const {
@@ -693,6 +819,26 @@ union Instruction {
693 UNREACHABLE(); 819 UNREACHABLE();
694 } 820 }
695 821
822 TextureProcessMode GetTextureProcessMode() const {
823 if (texture_info == 1 || texture_info == 5 || texture_info == 12)
824 return TextureProcessMode::LL;
825 return TextureProcessMode::LZ;
826 }
827
828 bool UsesMiscMode(TextureMiscMode mode) const {
829 switch (mode) {
830 case TextureMiscMode::AOFFI:
831 return texture_info == 12 || texture_info == 4;
832 case TextureMiscMode::MZ:
833 return texture_info == 5;
834 case TextureMiscMode::NODEP:
835 return nodep_flag != 0;
836 default:
837 break;
838 }
839 return false;
840 }
841
696 bool IsArrayTexture() const { 842 bool IsArrayTexture() const {
697 // TEXS only supports Texture2D arrays. 843 // TEXS only supports Texture2D arrays.
698 return texture_info == 8; 844 return texture_info == 8;