diff options
Diffstat (limited to 'src/video_core/pica_state.h')
| -rw-r--r-- | src/video_core/pica_state.h | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/src/video_core/pica_state.h b/src/video_core/pica_state.h deleted file mode 100644 index c6634a0bc..000000000 --- a/src/video_core/pica_state.h +++ /dev/null | |||
| @@ -1,159 +0,0 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include "common/bit_field.h" | ||
| 9 | #include "common/common_types.h" | ||
| 10 | #include "common/vector_math.h" | ||
| 11 | #include "video_core/geometry_pipeline.h" | ||
| 12 | #include "video_core/primitive_assembly.h" | ||
| 13 | #include "video_core/regs.h" | ||
| 14 | #include "video_core/shader/shader.h" | ||
| 15 | |||
| 16 | namespace Pica { | ||
| 17 | |||
| 18 | /// Struct used to describe current Pica state | ||
| 19 | struct State { | ||
| 20 | State(); | ||
| 21 | void Reset(); | ||
| 22 | |||
| 23 | /// Pica registers | ||
| 24 | Regs regs; | ||
| 25 | |||
| 26 | Shader::ShaderSetup vs; | ||
| 27 | Shader::ShaderSetup gs; | ||
| 28 | |||
| 29 | Shader::AttributeBuffer input_default_attributes; | ||
| 30 | |||
| 31 | struct ProcTex { | ||
| 32 | union ValueEntry { | ||
| 33 | u32 raw; | ||
| 34 | |||
| 35 | // LUT value, encoded as 12-bit fixed point, with 12 fraction bits | ||
| 36 | BitField<0, 12, u32> value; // 0.0.12 fixed point | ||
| 37 | |||
| 38 | // Difference between two entry values. Used for efficient interpolation. | ||
| 39 | // 0.0.12 fixed point with two's complement. The range is [-0.5, 0.5). | ||
| 40 | // Note: the type of this is different from the one of lighting LUT | ||
| 41 | BitField<12, 12, s32> difference; | ||
| 42 | |||
| 43 | float ToFloat() const { | ||
| 44 | return static_cast<float>(value) / 4095.f; | ||
| 45 | } | ||
| 46 | |||
| 47 | float DiffToFloat() const { | ||
| 48 | return static_cast<float>(difference) / 4095.f; | ||
| 49 | } | ||
| 50 | }; | ||
| 51 | |||
| 52 | union ColorEntry { | ||
| 53 | u32 raw; | ||
| 54 | BitField<0, 8, u32> r; | ||
| 55 | BitField<8, 8, u32> g; | ||
| 56 | BitField<16, 8, u32> b; | ||
| 57 | BitField<24, 8, u32> a; | ||
| 58 | |||
| 59 | Math::Vec4<u8> ToVector() const { | ||
| 60 | return {static_cast<u8>(r), static_cast<u8>(g), static_cast<u8>(b), | ||
| 61 | static_cast<u8>(a)}; | ||
| 62 | } | ||
| 63 | }; | ||
| 64 | |||
| 65 | union ColorDifferenceEntry { | ||
| 66 | u32 raw; | ||
| 67 | BitField<0, 8, s32> r; // half of the difference between two ColorEntry | ||
| 68 | BitField<8, 8, s32> g; | ||
| 69 | BitField<16, 8, s32> b; | ||
| 70 | BitField<24, 8, s32> a; | ||
| 71 | |||
| 72 | Math::Vec4<s32> ToVector() const { | ||
| 73 | return Math::Vec4<s32>{r, g, b, a} * 2; | ||
| 74 | } | ||
| 75 | }; | ||
| 76 | |||
| 77 | std::array<ValueEntry, 128> noise_table; | ||
| 78 | std::array<ValueEntry, 128> color_map_table; | ||
| 79 | std::array<ValueEntry, 128> alpha_map_table; | ||
| 80 | std::array<ColorEntry, 256> color_table; | ||
| 81 | std::array<ColorDifferenceEntry, 256> color_diff_table; | ||
| 82 | } proctex; | ||
| 83 | |||
| 84 | struct Lighting { | ||
| 85 | union LutEntry { | ||
| 86 | // Used for raw access | ||
| 87 | u32 raw; | ||
| 88 | |||
| 89 | // LUT value, encoded as 12-bit fixed point, with 12 fraction bits | ||
| 90 | BitField<0, 12, u32> value; // 0.0.12 fixed point | ||
| 91 | |||
| 92 | // Used for efficient interpolation. | ||
| 93 | BitField<12, 11, u32> difference; // 0.0.11 fixed point | ||
| 94 | BitField<23, 1, u32> neg_difference; | ||
| 95 | |||
| 96 | float ToFloat() const { | ||
| 97 | return static_cast<float>(value) / 4095.f; | ||
| 98 | } | ||
| 99 | |||
| 100 | float DiffToFloat() const { | ||
| 101 | float diff = static_cast<float>(difference) / 2047.f; | ||
| 102 | return neg_difference ? -diff : diff; | ||
| 103 | } | ||
| 104 | }; | ||
| 105 | |||
| 106 | std::array<std::array<LutEntry, 256>, 24> luts; | ||
| 107 | } lighting; | ||
| 108 | |||
| 109 | struct { | ||
| 110 | union LutEntry { | ||
| 111 | // Used for raw access | ||
| 112 | u32 raw; | ||
| 113 | |||
| 114 | BitField<0, 13, s32> difference; // 1.1.11 fixed point | ||
| 115 | BitField<13, 11, u32> value; // 0.0.11 fixed point | ||
| 116 | |||
| 117 | float ToFloat() const { | ||
| 118 | return static_cast<float>(value) / 2047.0f; | ||
| 119 | } | ||
| 120 | |||
| 121 | float DiffToFloat() const { | ||
| 122 | return static_cast<float>(difference) / 2047.0f; | ||
| 123 | } | ||
| 124 | }; | ||
| 125 | |||
| 126 | std::array<LutEntry, 128> lut; | ||
| 127 | } fog; | ||
| 128 | |||
| 129 | /// Current Pica command list | ||
| 130 | struct { | ||
| 131 | const u32* head_ptr; | ||
| 132 | const u32* current_ptr; | ||
| 133 | u32 length; | ||
| 134 | } cmd_list; | ||
| 135 | |||
| 136 | /// Struct used to describe immediate mode rendering state | ||
| 137 | struct ImmediateModeState { | ||
| 138 | // Used to buffer partial vertices for immediate-mode rendering. | ||
| 139 | Shader::AttributeBuffer input_vertex; | ||
| 140 | // Index of the next attribute to be loaded into `input_vertex`. | ||
| 141 | u32 current_attribute = 0; | ||
| 142 | // Indicates the immediate mode just started and the geometry pipeline needs to reconfigure | ||
| 143 | bool reset_geometry_pipeline = true; | ||
| 144 | } immediate; | ||
| 145 | |||
| 146 | // the geometry shader needs to be kept in the global state because some shaders relie on | ||
| 147 | // preserved register value across shader invocation. | ||
| 148 | // TODO: also bring the three vertex shader units here and implement the shader scheduler. | ||
| 149 | Shader::GSUnitState gs_unit; | ||
| 150 | |||
| 151 | GeometryPipeline geometry_pipeline; | ||
| 152 | |||
| 153 | // This is constructed with a dummy triangle topology | ||
| 154 | PrimitiveAssembler<Shader::OutputVertex> primitive_assembler; | ||
| 155 | }; | ||
| 156 | |||
| 157 | extern State g_state; ///< Current Pica state | ||
| 158 | |||
| 159 | } // namespace | ||