diff options
| author | 2015-09-12 18:47:15 -0400 | |
|---|---|---|
| committer | 2016-02-05 17:17:26 -0500 | |
| commit | 4369767c721e9633fc6cd9c49b6142ff9b2fa8ea (patch) | |
| tree | 73de949ed45824b61537d14ff98ec0cf0308a3a0 /src | |
| parent | pica: Add pica_types module and move float24 definition. (diff) | |
| download | yuzu-4369767c721e9633fc6cd9c49b6142ff9b2fa8ea.tar.gz yuzu-4369767c721e9633fc6cd9c49b6142ff9b2fa8ea.tar.xz yuzu-4369767c721e9633fc6cd9c49b6142ff9b2fa8ea.zip | |
pica: Add decodings for distance attenuation and LUT registers.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/pica.h | 105 |
1 files changed, 104 insertions, 1 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index b8db7869a..81a568e88 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -643,7 +643,110 @@ struct Regs { | |||
| 643 | } | 643 | } |
| 644 | } | 644 | } |
| 645 | 645 | ||
| 646 | INSERT_PADDING_WORDS(0xe0); | 646 | INSERT_PADDING_WORDS(0x20); |
| 647 | |||
| 648 | struct { | ||
| 649 | union LightColor { | ||
| 650 | BitField< 0, 10, u32> b; | ||
| 651 | BitField<10, 10, u32> g; | ||
| 652 | BitField<20, 10, u32> r; | ||
| 653 | |||
| 654 | Math::Vec3f ToVec3f() const { | ||
| 655 | return Math::MakeVec((f32)r / 255.f, (f32)g / 255.f, (f32)b / 255.f); | ||
| 656 | } | ||
| 657 | }; | ||
| 658 | |||
| 659 | struct LightSrc { | ||
| 660 | LightColor specular_0; // material.specular_0 * light.specular_0 | ||
| 661 | LightColor specular_1; // material.specular_1 * light.specular_1 | ||
| 662 | LightColor diffuse; // material.diffuse * light.diffuse | ||
| 663 | LightColor ambient; // material.ambient * light.ambient | ||
| 664 | |||
| 665 | struct { | ||
| 666 | // Encoded as 16-bit floating point | ||
| 667 | u16 x; | ||
| 668 | u16 y; | ||
| 669 | u16 z; | ||
| 670 | u16 unk; | ||
| 671 | |||
| 672 | INSERT_PADDING_WORDS(0x3); | ||
| 673 | |||
| 674 | // 1.f if 0, otherwise 0.f | ||
| 675 | BitField<0, 1, u32> w; | ||
| 676 | } position; | ||
| 677 | |||
| 678 | |||
| 679 | BitField<0, 20, u32> dist_atten_bias; | ||
| 680 | BitField<0, 20, u32> dist_atten_scale; | ||
| 681 | |||
| 682 | INSERT_PADDING_WORDS(0x4); | ||
| 683 | }; | ||
| 684 | static_assert(sizeof(LightSrc) == 0x10 * sizeof(u32), "LightSrc structure must be 0x10 words"); | ||
| 685 | |||
| 686 | LightSrc light[8]; | ||
| 687 | LightColor global_ambient; // emission + (material.ambient * lighting.ambient) | ||
| 688 | INSERT_PADDING_WORDS(0x1); | ||
| 689 | BitField<0, 3, u32> src_num; // number of enabled lights - 1 | ||
| 690 | INSERT_PADDING_WORDS(0x1); | ||
| 691 | |||
| 692 | union { | ||
| 693 | // Each bit specifies whether distance attenuation should be applied for the | ||
| 694 | // corresponding light | ||
| 695 | |||
| 696 | BitField<24, 1, u32> light_0; | ||
| 697 | BitField<25, 1, u32> light_1; | ||
| 698 | BitField<26, 1, u32> light_2; | ||
| 699 | BitField<27, 1, u32> light_3; | ||
| 700 | BitField<28, 1, u32> light_4; | ||
| 701 | BitField<29, 1, u32> light_5; | ||
| 702 | BitField<30, 1, u32> light_6; | ||
| 703 | BitField<31, 1, u32> light_7; | ||
| 704 | |||
| 705 | bool IsEnabled(unsigned index) const { | ||
| 706 | const unsigned enable[] = { light_0, light_1, light_2, light_3, light_4, light_5, light_6, light_7 }; | ||
| 707 | return enable[index] == 0; | ||
| 708 | } | ||
| 709 | } dist_atten_enable; | ||
| 710 | |||
| 711 | union { | ||
| 712 | BitField<0, 8, u32> index; ///< Index at which to set data in the LUT | ||
| 713 | BitField<8, 5, u32> type; ///< Type of LUT for which to set data | ||
| 714 | } lut_config; | ||
| 715 | |||
| 716 | BitField<0, 1, u32> disable; | ||
| 717 | INSERT_PADDING_WORDS(0x1); | ||
| 718 | |||
| 719 | // When data is written to any of these registers, it gets written to the lookup table of | ||
| 720 | // the selected type at the selected index, specified above in the `lut_config` register. | ||
| 721 | // With each write, `lut_config.index` is incremented. It does not matter which of these | ||
| 722 | // registers is written to, the behavior will be the same. | ||
| 723 | u32 lut_data[8]; | ||
| 724 | |||
| 725 | INSERT_PADDING_WORDS(0x9); | ||
| 726 | |||
| 727 | union { | ||
| 728 | // There are 8 light enable "slots", corresponding to the total number of lights | ||
| 729 | // supported by Pica. For N enabled lights (specified by register 0x1c2, or 'src_num' | ||
| 730 | // above), the first N slots below will be set to integers within the range of 0-7, | ||
| 731 | // corresponding to the actual light that is enabled for each slot. | ||
| 732 | |||
| 733 | BitField< 0, 3, u32> slot_0; | ||
| 734 | BitField< 4, 3, u32> slot_1; | ||
| 735 | BitField< 8, 3, u32> slot_2; | ||
| 736 | BitField<12, 3, u32> slot_3; | ||
| 737 | BitField<16, 3, u32> slot_4; | ||
| 738 | BitField<20, 3, u32> slot_5; | ||
| 739 | BitField<24, 3, u32> slot_6; | ||
| 740 | BitField<28, 3, u32> slot_7; | ||
| 741 | |||
| 742 | unsigned GetNum(unsigned index) const { | ||
| 743 | const unsigned enable_slots[] = { slot_0, slot_1, slot_2, slot_3, slot_4, slot_5, slot_6, slot_7 }; | ||
| 744 | return enable_slots[index]; | ||
| 745 | } | ||
| 746 | } light_enable; | ||
| 747 | } lighting; | ||
| 748 | |||
| 749 | INSERT_PADDING_WORDS(0x26); | ||
| 647 | 750 | ||
| 648 | enum class VertexAttributeFormat : u64 { | 751 | enum class VertexAttributeFormat : u64 { |
| 649 | BYTE = 0, | 752 | BYTE = 0, |