diff options
| author | 2017-02-12 12:33:26 -0800 | |
|---|---|---|
| committer | 2017-02-12 12:33:26 -0800 | |
| commit | 443bb3d522916f9be2d27fc8b3d7b5cc942213df (patch) | |
| tree | 5a83052ad2f5888a282d4db2ef9b9f2d4e647a60 | |
| parent | citra-qt: Don't attempt to scan files with unsupported extensions (#2402) (diff) | |
| parent | VideoCore: Split u64 Pica reg unions into 2 separate u32 unions (diff) | |
| download | yuzu-443bb3d522916f9be2d27fc8b3d7b5cc942213df.tar.gz yuzu-443bb3d522916f9be2d27fc8b3d7b5cc942213df.tar.xz yuzu-443bb3d522916f9be2d27fc8b3d7b5cc942213df.zip | |
Merge pull request #2550 from yuriks/pica-refactor2
Small VideoCore cleanups
| -rw-r--r-- | src/citra_qt/debugger/graphics/graphics_cmdlists.cpp | 2 | ||||
| -rw-r--r-- | src/citra_qt/debugger/graphics/graphics_surface.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/clipper.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/command_processor.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.h | 4 | ||||
| -rw-r--r-- | src/video_core/pica.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/rasterizer.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/regs.cpp | 21 | ||||
| -rw-r--r-- | src/video_core/regs.h | 68 | ||||
| -rw-r--r-- | src/video_core/regs_lighting.h | 8 | ||||
| -rw-r--r-- | src/video_core/regs_pipeline.h | 78 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 30 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/pica_to_gl.h | 4 | ||||
| -rw-r--r-- | src/video_core/shader/shader.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/shader/shader.h | 3 |
19 files changed, 133 insertions, 140 deletions
diff --git a/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp index 536548f36..c68fe753b 100644 --- a/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp +++ b/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp | |||
| @@ -72,7 +72,7 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const { | |||
| 72 | if (role == Qt::DisplayRole) { | 72 | if (role == Qt::DisplayRole) { |
| 73 | switch (index.column()) { | 73 | switch (index.column()) { |
| 74 | case 0: | 74 | case 0: |
| 75 | return QString::fromLatin1(Pica::Regs::GetCommandName(write.cmd_id).c_str()); | 75 | return QString::fromLatin1(Pica::Regs::GetRegisterName(write.cmd_id)); |
| 76 | case 1: | 76 | case 1: |
| 77 | return QString("%1").arg(write.cmd_id, 3, 16, QLatin1Char('0')); | 77 | return QString("%1").arg(write.cmd_id, 3, 16, QLatin1Char('0')); |
| 78 | case 2: | 78 | case 2: |
diff --git a/src/citra_qt/debugger/graphics/graphics_surface.cpp b/src/citra_qt/debugger/graphics/graphics_surface.cpp index f83c1f96c..47d9924e1 100644 --- a/src/citra_qt/debugger/graphics/graphics_surface.cpp +++ b/src/citra_qt/debugger/graphics/graphics_surface.cpp | |||
| @@ -17,7 +17,8 @@ | |||
| 17 | #include "core/hw/gpu.h" | 17 | #include "core/hw/gpu.h" |
| 18 | #include "core/memory.h" | 18 | #include "core/memory.h" |
| 19 | #include "video_core/pica_state.h" | 19 | #include "video_core/pica_state.h" |
| 20 | #include "video_core/regs.h" | 20 | #include "video_core/regs_framebuffer.h" |
| 21 | #include "video_core/regs_texturing.h" | ||
| 21 | #include "video_core/texture/texture_decode.h" | 22 | #include "video_core/texture/texture_decode.h" |
| 22 | #include "video_core/utils.h" | 23 | #include "video_core/utils.h" |
| 23 | 24 | ||
diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp index 0f71bbd06..1e8e751ba 100644 --- a/src/video_core/clipper.cpp +++ b/src/video_core/clipper.cpp | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | #include "video_core/pica_state.h" | 15 | #include "video_core/pica_state.h" |
| 16 | #include "video_core/pica_types.h" | 16 | #include "video_core/pica_types.h" |
| 17 | #include "video_core/rasterizer.h" | 17 | #include "video_core/rasterizer.h" |
| 18 | #include "video_core/regs.h" | ||
| 19 | #include "video_core/shader/shader.h" | 18 | #include "video_core/shader/shader.h" |
| 20 | 19 | ||
| 21 | using Pica::Rasterizer::Vertex; | 20 | using Pica::Rasterizer::Vertex; |
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 91c0ca4e6..2e32ff905 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -21,6 +21,8 @@ | |||
| 21 | #include "video_core/primitive_assembly.h" | 21 | #include "video_core/primitive_assembly.h" |
| 22 | #include "video_core/rasterizer_interface.h" | 22 | #include "video_core/rasterizer_interface.h" |
| 23 | #include "video_core/regs.h" | 23 | #include "video_core/regs.h" |
| 24 | #include "video_core/regs_pipeline.h" | ||
| 25 | #include "video_core/regs_texturing.h" | ||
| 24 | #include "video_core/renderer_base.h" | 26 | #include "video_core/renderer_base.h" |
| 25 | #include "video_core/shader/shader.h" | 27 | #include "video_core/shader/shader.h" |
| 26 | #include "video_core/vertex_loader.h" | 28 | #include "video_core/vertex_loader.h" |
| @@ -49,19 +51,23 @@ MICROPROFILE_DEFINE(GPU_Drawing, "GPU", "Drawing", MP_RGB(50, 50, 240)); | |||
| 49 | static void WritePicaReg(u32 id, u32 value, u32 mask) { | 51 | static void WritePicaReg(u32 id, u32 value, u32 mask) { |
| 50 | auto& regs = g_state.regs; | 52 | auto& regs = g_state.regs; |
| 51 | 53 | ||
| 52 | if (id >= regs.NumIds()) | 54 | if (id >= Regs::NUM_REGS) { |
| 55 | LOG_ERROR(HW_GPU, | ||
| 56 | "Commandlist tried to write to invalid register 0x%03X (value: %08X, mask: %X)", | ||
| 57 | id, value, mask); | ||
| 53 | return; | 58 | return; |
| 59 | } | ||
| 54 | 60 | ||
| 55 | // TODO: Figure out how register masking acts on e.g. vs.uniform_setup.set_value | 61 | // TODO: Figure out how register masking acts on e.g. vs.uniform_setup.set_value |
| 56 | u32 old_value = regs[id]; | 62 | u32 old_value = regs.reg_array[id]; |
| 57 | 63 | ||
| 58 | const u32 write_mask = expand_bits_to_bytes[mask]; | 64 | const u32 write_mask = expand_bits_to_bytes[mask]; |
| 59 | 65 | ||
| 60 | regs[id] = (old_value & ~write_mask) | (value & write_mask); | 66 | regs.reg_array[id] = (old_value & ~write_mask) | (value & write_mask); |
| 61 | 67 | ||
| 62 | // Double check for is_pica_tracing to avoid call overhead | 68 | // Double check for is_pica_tracing to avoid call overhead |
| 63 | if (DebugUtils::IsPicaTracing()) { | 69 | if (DebugUtils::IsPicaTracing()) { |
| 64 | DebugUtils::OnPicaRegWrite({(u16)id, (u16)mask, regs[id]}); | 70 | DebugUtils::OnPicaRegWrite({(u16)id, (u16)mask, regs.reg_array[id]}); |
| 65 | } | 71 | } |
| 66 | 72 | ||
| 67 | if (g_debug_context) | 73 | if (g_debug_context) |
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index e164e83a1..47dbc8cc8 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -32,7 +32,9 @@ | |||
| 32 | #include "video_core/pica_state.h" | 32 | #include "video_core/pica_state.h" |
| 33 | #include "video_core/pica_types.h" | 33 | #include "video_core/pica_types.h" |
| 34 | #include "video_core/rasterizer_interface.h" | 34 | #include "video_core/rasterizer_interface.h" |
| 35 | #include "video_core/regs.h" | 35 | #include "video_core/regs_rasterizer.h" |
| 36 | #include "video_core/regs_shader.h" | ||
| 37 | #include "video_core/regs_texturing.h" | ||
| 36 | #include "video_core/renderer_base.h" | 38 | #include "video_core/renderer_base.h" |
| 37 | #include "video_core/shader/shader.h" | 39 | #include "video_core/shader/shader.h" |
| 38 | #include "video_core/texture/texture_decode.h" | 40 | #include "video_core/texture/texture_decode.h" |
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index fd94bdbb8..89e418e27 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h | |||
| @@ -17,7 +17,9 @@ | |||
| 17 | #include <vector> | 17 | #include <vector> |
| 18 | #include "common/common_types.h" | 18 | #include "common/common_types.h" |
| 19 | #include "common/vector_math.h" | 19 | #include "common/vector_math.h" |
| 20 | #include "video_core/regs.h" | 20 | #include "video_core/regs_rasterizer.h" |
| 21 | #include "video_core/regs_shader.h" | ||
| 22 | #include "video_core/regs_texturing.h" | ||
| 21 | 23 | ||
| 22 | namespace CiTrace { | 24 | namespace CiTrace { |
| 23 | class Recorder; | 25 | class Recorder; |
diff --git a/src/video_core/pica.cpp b/src/video_core/pica.cpp index 13f0a4ab9..b95148a6a 100644 --- a/src/video_core/pica.cpp +++ b/src/video_core/pica.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include <cstring> | 5 | #include <cstring> |
| 6 | #include "video_core/pica.h" | 6 | #include "video_core/pica.h" |
| 7 | #include "video_core/pica_state.h" | 7 | #include "video_core/pica_state.h" |
| 8 | #include "video_core/regs.h" | 8 | #include "video_core/regs_pipeline.h" |
| 9 | 9 | ||
| 10 | namespace Pica { | 10 | namespace Pica { |
| 11 | 11 | ||
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index ca09c9d0e..83a08ebd7 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -19,7 +19,9 @@ | |||
| 19 | #include "video_core/pica_state.h" | 19 | #include "video_core/pica_state.h" |
| 20 | #include "video_core/pica_types.h" | 20 | #include "video_core/pica_types.h" |
| 21 | #include "video_core/rasterizer.h" | 21 | #include "video_core/rasterizer.h" |
| 22 | #include "video_core/regs.h" | 22 | #include "video_core/regs_framebuffer.h" |
| 23 | #include "video_core/regs_rasterizer.h" | ||
| 24 | #include "video_core/regs_texturing.h" | ||
| 23 | #include "video_core/shader/shader.h" | 25 | #include "video_core/shader/shader.h" |
| 24 | #include "video_core/texture/texture_decode.h" | 26 | #include "video_core/texture/texture_decode.h" |
| 25 | #include "video_core/utils.h" | 27 | #include "video_core/utils.h" |
diff --git a/src/video_core/regs.cpp b/src/video_core/regs.cpp index f47e9e763..2699e710a 100644 --- a/src/video_core/regs.cpp +++ b/src/video_core/regs.cpp | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <iterator> | 6 | #include <iterator> |
| 6 | #include <unordered_map> | ||
| 7 | #include <utility> | 7 | #include <utility> |
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| @@ -474,19 +474,14 @@ static const std::pair<u16, const char*> register_names[] = { | |||
| 474 | {0x2DD, "GPUREG_VSH_OPDESCS_DATA7"}, | 474 | {0x2DD, "GPUREG_VSH_OPDESCS_DATA7"}, |
| 475 | }; | 475 | }; |
| 476 | 476 | ||
| 477 | std::string Regs::GetCommandName(int index) { | 477 | const char* Regs::GetRegisterName(u16 index) { |
| 478 | static std::unordered_map<u32, const char*> map; | 478 | auto found = std::lower_bound(std::begin(register_names), std::end(register_names), index, |
| 479 | 479 | [](auto p, auto i) { return p.first < i; }); | |
| 480 | if (map.empty()) { | 480 | if (found->first == index) { |
| 481 | map.insert(std::begin(register_names), std::end(register_names)); | 481 | return found->second; |
| 482 | } | ||
| 483 | |||
| 484 | // Return empty string if no match is found | ||
| 485 | auto it = map.find(index); | ||
| 486 | if (it != map.end()) { | ||
| 487 | return it->second; | ||
| 488 | } else { | 482 | } else { |
| 489 | return std::string(); | 483 | // Return empty string if no match is found |
| 484 | return ""; | ||
| 490 | } | 485 | } |
| 491 | } | 486 | } |
| 492 | 487 | ||
diff --git a/src/video_core/regs.h b/src/video_core/regs.h index f25edde27..86826088b 100644 --- a/src/video_core/regs.h +++ b/src/video_core/regs.h | |||
| @@ -45,46 +45,31 @@ namespace Pica { | |||
| 45 | #endif // _MSC_VER | 45 | #endif // _MSC_VER |
| 46 | 46 | ||
| 47 | struct Regs { | 47 | struct Regs { |
| 48 | INSERT_PADDING_WORDS(0x10); | 48 | static constexpr size_t NUM_REGS = 0x300; |
| 49 | u32 trigger_irq; | 49 | |
| 50 | INSERT_PADDING_WORDS(0x2f); | 50 | union { |
| 51 | RasterizerRegs rasterizer; | 51 | struct { |
| 52 | TexturingRegs texturing; | 52 | INSERT_PADDING_WORDS(0x10); |
| 53 | FramebufferRegs framebuffer; | 53 | u32 trigger_irq; |
| 54 | LightingRegs lighting; | 54 | INSERT_PADDING_WORDS(0x2f); |
| 55 | PipelineRegs pipeline; | 55 | RasterizerRegs rasterizer; |
| 56 | ShaderRegs gs; | 56 | TexturingRegs texturing; |
| 57 | ShaderRegs vs; | 57 | FramebufferRegs framebuffer; |
| 58 | INSERT_PADDING_WORDS(0x20); | 58 | LightingRegs lighting; |
| 59 | 59 | PipelineRegs pipeline; | |
| 60 | // Map register indices to names readable by humans | 60 | ShaderRegs gs; |
| 61 | // Used for debugging purposes, so performance is not an issue here | 61 | ShaderRegs vs; |
| 62 | static std::string GetCommandName(int index); | 62 | INSERT_PADDING_WORDS(0x20); |
| 63 | 63 | }; | |
| 64 | static constexpr size_t NumIds() { | 64 | std::array<u32, NUM_REGS> reg_array; |
| 65 | return sizeof(Regs) / sizeof(u32); | 65 | }; |
| 66 | } | 66 | |
| 67 | 67 | /// Map register indices to names readable by humans | |
| 68 | const u32& operator[](int index) const { | 68 | static const char* GetRegisterName(u16 index); |
| 69 | const u32* content = reinterpret_cast<const u32*>(this); | ||
| 70 | return content[index]; | ||
| 71 | } | ||
| 72 | |||
| 73 | u32& operator[](int index) { | ||
| 74 | u32* content = reinterpret_cast<u32*>(this); | ||
| 75 | return content[index]; | ||
| 76 | } | ||
| 77 | |||
| 78 | private: | ||
| 79 | /* | ||
| 80 | * Most physical addresses which Pica registers refer to are 8-byte aligned. | ||
| 81 | * This function should be used to get the address from a raw register value. | ||
| 82 | */ | ||
| 83 | static inline u32 DecodeAddressRegister(u32 register_value) { | ||
| 84 | return register_value * 8; | ||
| 85 | } | ||
| 86 | }; | 69 | }; |
| 87 | 70 | ||
| 71 | static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Regs struct has wrong size"); | ||
| 72 | |||
| 88 | // TODO: MSVC does not support using offsetof() on non-static data members even though this | 73 | // TODO: MSVC does not support using offsetof() on non-static data members even though this |
| 89 | // is technically allowed since C++11. This macro should be enabled once MSVC adds | 74 | // is technically allowed since C++11. This macro should be enabled once MSVC adds |
| 90 | // support for that. | 75 | // support for that. |
| @@ -154,11 +139,4 @@ ASSERT_REG_POSITION(vs, 0x2b0); | |||
| 154 | #undef ASSERT_REG_POSITION | 139 | #undef ASSERT_REG_POSITION |
| 155 | #endif // !defined(_MSC_VER) | 140 | #endif // !defined(_MSC_VER) |
| 156 | 141 | ||
| 157 | // The total number of registers is chosen arbitrarily, but let's make sure it's not some odd value | ||
| 158 | // anyway. | ||
| 159 | static_assert(sizeof(Regs) <= 0x300 * sizeof(u32), | ||
| 160 | "Register set structure larger than it should be"); | ||
| 161 | static_assert(sizeof(Regs) >= 0x300 * sizeof(u32), | ||
| 162 | "Register set structure smaller than it should be"); | ||
| 163 | |||
| 164 | } // namespace Pica | 142 | } // namespace Pica |
diff --git a/src/video_core/regs_lighting.h b/src/video_core/regs_lighting.h index 548a6c4d5..6793405d9 100644 --- a/src/video_core/regs_lighting.h +++ b/src/video_core/regs_lighting.h | |||
| @@ -34,7 +34,7 @@ struct LightingRegs { | |||
| 34 | * configurations that require more LUTs, more cycles are required on HW to perform lighting | 34 | * configurations that require more LUTs, more cycles are required on HW to perform lighting |
| 35 | * computations. | 35 | * computations. |
| 36 | */ | 36 | */ |
| 37 | enum class LightingConfig { | 37 | enum class LightingConfig : u32 { |
| 38 | Config0 = 0, ///< Reflect Red, Distribution 0, Spotlight | 38 | Config0 = 0, ///< Reflect Red, Distribution 0, Spotlight |
| 39 | Config1 = 1, ///< Reflect Red, Fresnel, Spotlight | 39 | Config1 = 1, ///< Reflect Red, Fresnel, Spotlight |
| 40 | Config2 = 2, ///< Reflect Red, Distribution 0/1 | 40 | Config2 = 2, ///< Reflect Red, Distribution 0/1 |
| @@ -48,7 +48,7 @@ struct LightingRegs { | |||
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | /// Selects which lighting components are affected by fresnel | 50 | /// Selects which lighting components are affected by fresnel |
| 51 | enum class LightingFresnelSelector { | 51 | enum class LightingFresnelSelector : u32 { |
| 52 | None = 0, ///< Fresnel is disabled | 52 | None = 0, ///< Fresnel is disabled |
| 53 | PrimaryAlpha = 1, ///< Primary (diffuse) lighting alpha is affected by fresnel | 53 | PrimaryAlpha = 1, ///< Primary (diffuse) lighting alpha is affected by fresnel |
| 54 | SecondaryAlpha = 2, ///< Secondary (specular) lighting alpha is affected by fresnel | 54 | SecondaryAlpha = 2, ///< Secondary (specular) lighting alpha is affected by fresnel |
| @@ -58,7 +58,7 @@ struct LightingRegs { | |||
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | /// Factor used to scale the output of a lighting LUT | 60 | /// Factor used to scale the output of a lighting LUT |
| 61 | enum class LightingScale { | 61 | enum class LightingScale : u32 { |
| 62 | Scale1 = 0, ///< Scale is 1x | 62 | Scale1 = 0, ///< Scale is 1x |
| 63 | Scale2 = 1, ///< Scale is 2x | 63 | Scale2 = 1, ///< Scale is 2x |
| 64 | Scale4 = 2, ///< Scale is 4x | 64 | Scale4 = 2, ///< Scale is 4x |
| @@ -68,7 +68,7 @@ struct LightingRegs { | |||
| 68 | Scale1_2 = 7, ///< Scale is 0.5x | 68 | Scale1_2 = 7, ///< Scale is 0.5x |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | enum class LightingLutInput { | 71 | enum class LightingLutInput : u32 { |
| 72 | NH = 0, // Cosine of the angle between the normal and half-angle vectors | 72 | NH = 0, // Cosine of the angle between the normal and half-angle vectors |
| 73 | VH = 1, // Cosine of the angle between the view and half-angle vectors | 73 | VH = 1, // Cosine of the angle between the view and half-angle vectors |
| 74 | NV = 2, // Cosine of the angle between the normal and the view vector | 74 | NV = 2, // Cosine of the angle between the normal and the view vector |
diff --git a/src/video_core/regs_pipeline.h b/src/video_core/regs_pipeline.h index 5844a66ee..0a4ec6e1e 100644 --- a/src/video_core/regs_pipeline.h +++ b/src/video_core/regs_pipeline.h | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | namespace Pica { | 14 | namespace Pica { |
| 15 | 15 | ||
| 16 | struct PipelineRegs { | 16 | struct PipelineRegs { |
| 17 | enum class VertexAttributeFormat : u64 { | 17 | enum class VertexAttributeFormat : u32 { |
| 18 | BYTE = 0, | 18 | BYTE = 0, |
| 19 | UBYTE = 1, | 19 | UBYTE = 1, |
| 20 | SHORT = 2, | 20 | SHORT = 2, |
| @@ -31,34 +31,37 @@ struct PipelineRegs { | |||
| 31 | // Descriptor for internal vertex attributes | 31 | // Descriptor for internal vertex attributes |
| 32 | union { | 32 | union { |
| 33 | BitField<0, 2, VertexAttributeFormat> format0; // size of one element | 33 | BitField<0, 2, VertexAttributeFormat> format0; // size of one element |
| 34 | BitField<2, 2, u64> size0; // number of elements minus 1 | 34 | BitField<2, 2, u32> size0; // number of elements minus 1 |
| 35 | BitField<4, 2, VertexAttributeFormat> format1; | 35 | BitField<4, 2, VertexAttributeFormat> format1; |
| 36 | BitField<6, 2, u64> size1; | 36 | BitField<6, 2, u32> size1; |
| 37 | BitField<8, 2, VertexAttributeFormat> format2; | 37 | BitField<8, 2, VertexAttributeFormat> format2; |
| 38 | BitField<10, 2, u64> size2; | 38 | BitField<10, 2, u32> size2; |
| 39 | BitField<12, 2, VertexAttributeFormat> format3; | 39 | BitField<12, 2, VertexAttributeFormat> format3; |
| 40 | BitField<14, 2, u64> size3; | 40 | BitField<14, 2, u32> size3; |
| 41 | BitField<16, 2, VertexAttributeFormat> format4; | 41 | BitField<16, 2, VertexAttributeFormat> format4; |
| 42 | BitField<18, 2, u64> size4; | 42 | BitField<18, 2, u32> size4; |
| 43 | BitField<20, 2, VertexAttributeFormat> format5; | 43 | BitField<20, 2, VertexAttributeFormat> format5; |
| 44 | BitField<22, 2, u64> size5; | 44 | BitField<22, 2, u32> size5; |
| 45 | BitField<24, 2, VertexAttributeFormat> format6; | 45 | BitField<24, 2, VertexAttributeFormat> format6; |
| 46 | BitField<26, 2, u64> size6; | 46 | BitField<26, 2, u32> size6; |
| 47 | BitField<28, 2, VertexAttributeFormat> format7; | 47 | BitField<28, 2, VertexAttributeFormat> format7; |
| 48 | BitField<30, 2, u64> size7; | 48 | BitField<30, 2, u32> size7; |
| 49 | BitField<32, 2, VertexAttributeFormat> format8; | 49 | }; |
| 50 | BitField<34, 2, u64> size8; | 50 | |
| 51 | BitField<36, 2, VertexAttributeFormat> format9; | 51 | union { |
| 52 | BitField<38, 2, u64> size9; | 52 | BitField<0, 2, VertexAttributeFormat> format8; |
| 53 | BitField<40, 2, VertexAttributeFormat> format10; | 53 | BitField<2, 2, u32> size8; |
| 54 | BitField<42, 2, u64> size10; | 54 | BitField<4, 2, VertexAttributeFormat> format9; |
| 55 | BitField<44, 2, VertexAttributeFormat> format11; | 55 | BitField<6, 2, u32> size9; |
| 56 | BitField<46, 2, u64> size11; | 56 | BitField<8, 2, VertexAttributeFormat> format10; |
| 57 | 57 | BitField<10, 2, u32> size10; | |
| 58 | BitField<48, 12, u64> attribute_mask; | 58 | BitField<12, 2, VertexAttributeFormat> format11; |
| 59 | BitField<14, 2, u32> size11; | ||
| 60 | |||
| 61 | BitField<16, 12, u32> attribute_mask; | ||
| 59 | 62 | ||
| 60 | // number of total attributes minus 1 | 63 | // number of total attributes minus 1 |
| 61 | BitField<60, 4, u64> max_attribute_index; | 64 | BitField<28, 4, u32> max_attribute_index; |
| 62 | }; | 65 | }; |
| 63 | 66 | ||
| 64 | inline VertexAttributeFormat GetFormat(int n) const { | 67 | inline VertexAttributeFormat GetFormat(int n) const { |
| @@ -69,7 +72,7 @@ struct PipelineRegs { | |||
| 69 | } | 72 | } |
| 70 | 73 | ||
| 71 | inline int GetNumElements(int n) const { | 74 | inline int GetNumElements(int n) const { |
| 72 | u64 sizes[] = {size0, size1, size2, size3, size4, size5, | 75 | u32 sizes[] = {size0, size1, size2, size3, size4, size5, |
| 73 | size6, size7, size8, size9, size10, size11}; | 76 | size6, size7, size8, size9, size10, size11}; |
| 74 | return (int)sizes[n] + 1; | 77 | return (int)sizes[n] + 1; |
| 75 | } | 78 | } |
| @@ -99,27 +102,30 @@ struct PipelineRegs { | |||
| 99 | u32 data_offset; | 102 | u32 data_offset; |
| 100 | 103 | ||
| 101 | union { | 104 | union { |
| 102 | BitField<0, 4, u64> comp0; | 105 | BitField<0, 4, u32> comp0; |
| 103 | BitField<4, 4, u64> comp1; | 106 | BitField<4, 4, u32> comp1; |
| 104 | BitField<8, 4, u64> comp2; | 107 | BitField<8, 4, u32> comp2; |
| 105 | BitField<12, 4, u64> comp3; | 108 | BitField<12, 4, u32> comp3; |
| 106 | BitField<16, 4, u64> comp4; | 109 | BitField<16, 4, u32> comp4; |
| 107 | BitField<20, 4, u64> comp5; | 110 | BitField<20, 4, u32> comp5; |
| 108 | BitField<24, 4, u64> comp6; | 111 | BitField<24, 4, u32> comp6; |
| 109 | BitField<28, 4, u64> comp7; | 112 | BitField<28, 4, u32> comp7; |
| 110 | BitField<32, 4, u64> comp8; | 113 | }; |
| 111 | BitField<36, 4, u64> comp9; | 114 | |
| 112 | BitField<40, 4, u64> comp10; | 115 | union { |
| 113 | BitField<44, 4, u64> comp11; | 116 | BitField<0, 4, u32> comp8; |
| 117 | BitField<4, 4, u32> comp9; | ||
| 118 | BitField<8, 4, u32> comp10; | ||
| 119 | BitField<12, 4, u32> comp11; | ||
| 114 | 120 | ||
| 115 | // bytes for a single vertex in this loader | 121 | // bytes for a single vertex in this loader |
| 116 | BitField<48, 8, u64> byte_count; | 122 | BitField<16, 8, u32> byte_count; |
| 117 | 123 | ||
| 118 | BitField<60, 4, u64> component_count; | 124 | BitField<28, 4, u32> component_count; |
| 119 | }; | 125 | }; |
| 120 | 126 | ||
| 121 | inline int GetComponent(int n) const { | 127 | inline int GetComponent(int n) const { |
| 122 | u64 components[] = {comp0, comp1, comp2, comp3, comp4, comp5, | 128 | u32 components[] = {comp0, comp1, comp2, comp3, comp4, comp5, |
| 123 | comp6, comp7, comp8, comp9, comp10, comp11}; | 129 | comp6, comp7, comp8, comp9, comp10, comp11}; |
| 124 | return (int)components[n]; | 130 | return (int)components[n]; |
| 125 | } | 131 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 75736c99f..4b1948a71 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -15,7 +15,9 @@ | |||
| 15 | #include "common/vector_math.h" | 15 | #include "common/vector_math.h" |
| 16 | #include "core/hw/gpu.h" | 16 | #include "core/hw/gpu.h" |
| 17 | #include "video_core/pica_state.h" | 17 | #include "video_core/pica_state.h" |
| 18 | #include "video_core/regs.h" | 18 | #include "video_core/regs_framebuffer.h" |
| 19 | #include "video_core/regs_rasterizer.h" | ||
| 20 | #include "video_core/regs_texturing.h" | ||
| 19 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 21 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 20 | #include "video_core/renderer_opengl/gl_shader_gen.h" | 22 | #include "video_core/renderer_opengl/gl_shader_gen.h" |
| 21 | #include "video_core/renderer_opengl/gl_shader_util.h" | 23 | #include "video_core/renderer_opengl/gl_shader_util.h" |
| @@ -26,18 +28,6 @@ MICROPROFILE_DEFINE(OpenGL_Drawing, "OpenGL", "Drawing", MP_RGB(128, 128, 192)); | |||
| 26 | MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(100, 100, 255)); | 28 | MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(100, 100, 255)); |
| 27 | MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100)); | 29 | MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100)); |
| 28 | 30 | ||
| 29 | static bool IsPassThroughTevStage(const Pica::TexturingRegs::TevStageConfig& stage) { | ||
| 30 | using TevStageConfig = Pica::TexturingRegs::TevStageConfig; | ||
| 31 | |||
| 32 | return (stage.color_op == TevStageConfig::Operation::Replace && | ||
| 33 | stage.alpha_op == TevStageConfig::Operation::Replace && | ||
| 34 | stage.color_source1 == TevStageConfig::Source::Previous && | ||
| 35 | stage.alpha_source1 == TevStageConfig::Source::Previous && | ||
| 36 | stage.color_modifier1 == TevStageConfig::ColorModifier::SourceColor && | ||
| 37 | stage.alpha_modifier1 == TevStageConfig::AlphaModifier::SourceAlpha && | ||
| 38 | stage.GetColorMultiplier() == 1 && stage.GetAlphaMultiplier() == 1); | ||
| 39 | } | ||
| 40 | |||
| 41 | RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) { | 31 | RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) { |
| 42 | // Create sampler objects | 32 | // Create sampler objects |
| 43 | for (size_t i = 0; i < texture_samplers.size(); ++i) { | 33 | for (size_t i = 0; i < texture_samplers.size(); ++i) { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index bfee911b6..ecf737438 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -19,7 +19,10 @@ | |||
| 19 | #include "video_core/pica_state.h" | 19 | #include "video_core/pica_state.h" |
| 20 | #include "video_core/pica_types.h" | 20 | #include "video_core/pica_types.h" |
| 21 | #include "video_core/rasterizer_interface.h" | 21 | #include "video_core/rasterizer_interface.h" |
| 22 | #include "video_core/regs.h" | 22 | #include "video_core/regs_framebuffer.h" |
| 23 | #include "video_core/regs_lighting.h" | ||
| 24 | #include "video_core/regs_rasterizer.h" | ||
| 25 | #include "video_core/regs_texturing.h" | ||
| 23 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" | 26 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" |
| 24 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 27 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 25 | #include "video_core/renderer_opengl/gl_state.h" | 28 | #include "video_core/renderer_opengl/gl_state.h" |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 4072ed49e..aea20c693 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -21,7 +21,8 @@ | |||
| 21 | #include "common/common_funcs.h" | 21 | #include "common/common_funcs.h" |
| 22 | #include "common/common_types.h" | 22 | #include "common/common_types.h" |
| 23 | #include "core/hw/gpu.h" | 23 | #include "core/hw/gpu.h" |
| 24 | #include "video_core/regs.h" | 24 | #include "video_core/regs_framebuffer.h" |
| 25 | #include "video_core/regs_texturing.h" | ||
| 25 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 26 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 26 | 27 | ||
| 27 | namespace MathUtil { | 28 | namespace MathUtil { |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 3ea25f302..7abdeba05 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -7,15 +7,19 @@ | |||
| 7 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/bit_field.h" | 8 | #include "common/bit_field.h" |
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "video_core/regs.h" | 10 | #include "video_core/regs_framebuffer.h" |
| 11 | #include "video_core/regs_lighting.h" | ||
| 12 | #include "video_core/regs_rasterizer.h" | ||
| 13 | #include "video_core/regs_texturing.h" | ||
| 11 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 14 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 12 | #include "video_core/renderer_opengl/gl_shader_gen.h" | 15 | #include "video_core/renderer_opengl/gl_shader_gen.h" |
| 13 | #include "video_core/renderer_opengl/gl_shader_util.h" | 16 | #include "video_core/renderer_opengl/gl_shader_util.h" |
| 14 | 17 | ||
| 15 | using Pica::Regs; | 18 | using Pica::FramebufferRegs; |
| 16 | using Pica::RasterizerRegs; | ||
| 17 | using Pica::LightingRegs; | 19 | using Pica::LightingRegs; |
| 18 | using TevStageConfig = Pica::TexturingRegs::TevStageConfig; | 20 | using Pica::RasterizerRegs; |
| 21 | using Pica::TexturingRegs; | ||
| 22 | using TevStageConfig = TexturingRegs::TevStageConfig; | ||
| 19 | 23 | ||
| 20 | namespace GLShader { | 24 | namespace GLShader { |
| 21 | 25 | ||
| @@ -48,10 +52,10 @@ static void AppendSource(std::string& out, const PicaShaderConfig& config, | |||
| 48 | case Source::Texture0: | 52 | case Source::Texture0: |
| 49 | // Only unit 0 respects the texturing type (according to 3DBrew) | 53 | // Only unit 0 respects the texturing type (according to 3DBrew) |
| 50 | switch (state.texture0_type) { | 54 | switch (state.texture0_type) { |
| 51 | case Pica::TexturingRegs::TextureConfig::Texture2D: | 55 | case TexturingRegs::TextureConfig::Texture2D: |
| 52 | out += "texture(tex[0], texcoord[0])"; | 56 | out += "texture(tex[0], texcoord[0])"; |
| 53 | break; | 57 | break; |
| 54 | case Pica::TexturingRegs::TextureConfig::Projection2D: | 58 | case TexturingRegs::TextureConfig::Projection2D: |
| 55 | out += "textureProj(tex[0], vec3(texcoord[0], texcoord0_w))"; | 59 | out += "textureProj(tex[0], vec3(texcoord[0], texcoord0_w))"; |
| 56 | break; | 60 | break; |
| 57 | default: | 61 | default: |
| @@ -278,8 +282,8 @@ static void AppendAlphaCombiner(std::string& out, TevStageConfig::Operation oper | |||
| 278 | } | 282 | } |
| 279 | 283 | ||
| 280 | /// Writes the if-statement condition used to evaluate alpha testing | 284 | /// Writes the if-statement condition used to evaluate alpha testing |
| 281 | static void AppendAlphaTestCondition(std::string& out, Pica::FramebufferRegs::CompareFunc func) { | 285 | static void AppendAlphaTestCondition(std::string& out, FramebufferRegs::CompareFunc func) { |
| 282 | using CompareFunc = Pica::FramebufferRegs::CompareFunc; | 286 | using CompareFunc = FramebufferRegs::CompareFunc; |
| 283 | switch (func) { | 287 | switch (func) { |
| 284 | case CompareFunc::Never: | 288 | case CompareFunc::Never: |
| 285 | out += "true"; | 289 | out += "true"; |
| @@ -309,7 +313,7 @@ static void AppendAlphaTestCondition(std::string& out, Pica::FramebufferRegs::Co | |||
| 309 | /// Writes the code to emulate the specified TEV stage | 313 | /// Writes the code to emulate the specified TEV stage |
| 310 | static void WriteTevStage(std::string& out, const PicaShaderConfig& config, unsigned index) { | 314 | static void WriteTevStage(std::string& out, const PicaShaderConfig& config, unsigned index) { |
| 311 | const auto stage = | 315 | const auto stage = |
| 312 | static_cast<const Pica::TexturingRegs::TevStageConfig>(config.state.tev_stages[index]); | 316 | static_cast<const TexturingRegs::TevStageConfig>(config.state.tev_stages[index]); |
| 313 | if (!IsPassThroughTevStage(stage)) { | 317 | if (!IsPassThroughTevStage(stage)) { |
| 314 | std::string index_name = std::to_string(index); | 318 | std::string index_name = std::to_string(index); |
| 315 | 319 | ||
| @@ -642,7 +646,7 @@ vec4 secondary_fragment_color = vec4(0.0); | |||
| 642 | )"; | 646 | )"; |
| 643 | 647 | ||
| 644 | // Do not do any sort of processing if it's obvious we're not going to pass the alpha test | 648 | // Do not do any sort of processing if it's obvious we're not going to pass the alpha test |
| 645 | if (state.alpha_test_func == Pica::FramebufferRegs::CompareFunc::Never) { | 649 | if (state.alpha_test_func == FramebufferRegs::CompareFunc::Never) { |
| 646 | out += "discard; }"; | 650 | out += "discard; }"; |
| 647 | return out; | 651 | return out; |
| 648 | } | 652 | } |
| @@ -661,7 +665,7 @@ vec4 secondary_fragment_color = vec4(0.0); | |||
| 661 | 665 | ||
| 662 | out += "float z_over_w = 1.0 - gl_FragCoord.z * 2.0;\n"; | 666 | out += "float z_over_w = 1.0 - gl_FragCoord.z * 2.0;\n"; |
| 663 | out += "float depth = z_over_w * depth_scale + depth_offset;\n"; | 667 | out += "float depth = z_over_w * depth_scale + depth_offset;\n"; |
| 664 | if (state.depthmap_enable == Pica::RasterizerRegs::DepthBuffering::WBuffering) { | 668 | if (state.depthmap_enable == RasterizerRegs::DepthBuffering::WBuffering) { |
| 665 | out += "depth /= gl_FragCoord.w;\n"; | 669 | out += "depth /= gl_FragCoord.w;\n"; |
| 666 | } | 670 | } |
| 667 | 671 | ||
| @@ -675,14 +679,14 @@ vec4 secondary_fragment_color = vec4(0.0); | |||
| 675 | for (size_t index = 0; index < state.tev_stages.size(); ++index) | 679 | for (size_t index = 0; index < state.tev_stages.size(); ++index) |
| 676 | WriteTevStage(out, config, (unsigned)index); | 680 | WriteTevStage(out, config, (unsigned)index); |
| 677 | 681 | ||
| 678 | if (state.alpha_test_func != Pica::FramebufferRegs::CompareFunc::Always) { | 682 | if (state.alpha_test_func != FramebufferRegs::CompareFunc::Always) { |
| 679 | out += "if ("; | 683 | out += "if ("; |
| 680 | AppendAlphaTestCondition(out, state.alpha_test_func); | 684 | AppendAlphaTestCondition(out, state.alpha_test_func); |
| 681 | out += ") discard;\n"; | 685 | out += ") discard;\n"; |
| 682 | } | 686 | } |
| 683 | 687 | ||
| 684 | // Append fog combiner | 688 | // Append fog combiner |
| 685 | if (state.fog_mode == Pica::TexturingRegs::FogMode::Fog) { | 689 | if (state.fog_mode == TexturingRegs::FogMode::Fog) { |
| 686 | // Get index into fog LUT | 690 | // Get index into fog LUT |
| 687 | if (state.fog_flip) { | 691 | if (state.fog_flip) { |
| 688 | out += "float fog_index = (1.0 - depth) * 128.0;\n"; | 692 | out += "float fog_index = (1.0 - depth) * 128.0;\n"; |
diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h index 4b98dafc4..93d7b0b71 100644 --- a/src/video_core/renderer_opengl/pica_to_gl.h +++ b/src/video_core/renderer_opengl/pica_to_gl.h | |||
| @@ -12,7 +12,9 @@ | |||
| 12 | #include "common/common_funcs.h" | 12 | #include "common/common_funcs.h" |
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "common/logging/log.h" | 14 | #include "common/logging/log.h" |
| 15 | #include "video_core/regs.h" | 15 | #include "video_core/regs_framebuffer.h" |
| 16 | #include "video_core/regs_lighting.h" | ||
| 17 | #include "video_core/regs_texturing.h" | ||
| 16 | 18 | ||
| 17 | using GLvec2 = std::array<GLfloat, 2>; | 19 | using GLvec2 = std::array<GLfloat, 2>; |
| 18 | using GLvec3 = std::array<GLfloat, 3>; | 20 | using GLvec3 = std::array<GLfloat, 3>; |
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 60c5b9ad5..67ed19ba8 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp | |||
| @@ -8,7 +8,8 @@ | |||
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "common/microprofile.h" | 9 | #include "common/microprofile.h" |
| 10 | #include "video_core/pica_state.h" | 10 | #include "video_core/pica_state.h" |
| 11 | #include "video_core/regs.h" | 11 | #include "video_core/regs_rasterizer.h" |
| 12 | #include "video_core/regs_shader.h" | ||
| 12 | #include "video_core/shader/shader.h" | 13 | #include "video_core/shader/shader.h" |
| 13 | #include "video_core/shader/shader_interpreter.h" | 14 | #include "video_core/shader/shader_interpreter.h" |
| 14 | #ifdef ARCHITECTURE_x86_64 | 15 | #ifdef ARCHITECTURE_x86_64 |
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index d52682479..38ea717ab 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h | |||
| @@ -13,7 +13,8 @@ | |||
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "common/vector_math.h" | 14 | #include "common/vector_math.h" |
| 15 | #include "video_core/pica_types.h" | 15 | #include "video_core/pica_types.h" |
| 16 | #include "video_core/regs.h" | 16 | #include "video_core/regs_rasterizer.h" |
| 17 | #include "video_core/regs_shader.h" | ||
| 17 | 18 | ||
| 18 | using nihstro::RegisterType; | 19 | using nihstro::RegisterType; |
| 19 | using nihstro::SourceRegister; | 20 | using nihstro::SourceRegister; |