diff options
| -rw-r--r-- | src/video_core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/video_core/dirty_flags.cpp | 46 | ||||
| -rw-r--r-- | src/video_core/dirty_flags.h | 23 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state_tracker.cpp | 39 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_state_tracker.cpp | 41 |
5 files changed, 73 insertions, 77 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 06c174a5b..14f3b4569 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -2,6 +2,7 @@ add_library(video_core STATIC | |||
| 2 | buffer_cache/buffer_block.h | 2 | buffer_cache/buffer_block.h |
| 3 | buffer_cache/buffer_cache.h | 3 | buffer_cache/buffer_cache.h |
| 4 | buffer_cache/map_interval.h | 4 | buffer_cache/map_interval.h |
| 5 | dirty_flags.cpp | ||
| 5 | dirty_flags.h | 6 | dirty_flags.h |
| 6 | dma_pusher.cpp | 7 | dma_pusher.cpp |
| 7 | dma_pusher.h | 8 | dma_pusher.h |
diff --git a/src/video_core/dirty_flags.cpp b/src/video_core/dirty_flags.cpp new file mode 100644 index 000000000..4429f3405 --- /dev/null +++ b/src/video_core/dirty_flags.cpp | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <array> | ||
| 6 | #include <cstddef> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 9 | #include "video_core/dirty_flags.h" | ||
| 10 | |||
| 11 | #define OFF(field_name) MAXWELL3D_REG_INDEX(field_name) | ||
| 12 | #define NUM(field_name) (sizeof(::Tegra::Engines::Maxwell3D::Regs::field_name) / sizeof(u32)) | ||
| 13 | |||
| 14 | namespace VideoCommon::Dirty { | ||
| 15 | |||
| 16 | using Tegra::Engines::Maxwell3D; | ||
| 17 | |||
| 18 | void SetupCommonOnWriteStores(Tegra::Engines::Maxwell3D::DirtyState::Flags& store) { | ||
| 19 | store[RenderTargets] = true; | ||
| 20 | store[ZetaBuffer] = true; | ||
| 21 | for (std::size_t i = 0; i < Maxwell3D::Regs::NumRenderTargets; ++i) { | ||
| 22 | store[ColorBuffer0 + i] = true; | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | void SetupDirtyRenderTargets(Tegra::Engines::Maxwell3D::DirtyState::Tables& tables) { | ||
| 27 | static constexpr std::size_t num_per_rt = NUM(rt[0]); | ||
| 28 | static constexpr std::size_t begin = OFF(rt); | ||
| 29 | static constexpr std::size_t num = num_per_rt * Maxwell3D::Regs::NumRenderTargets; | ||
| 30 | for (std::size_t rt = 0; rt < Maxwell3D::Regs::NumRenderTargets; ++rt) { | ||
| 31 | FillBlock(tables[0], begin + rt * num_per_rt, num_per_rt, ColorBuffer0 + rt); | ||
| 32 | } | ||
| 33 | FillBlock(tables[1], begin, num, RenderTargets); | ||
| 34 | |||
| 35 | static constexpr std::array zeta_flags{ZetaBuffer, RenderTargets}; | ||
| 36 | for (std::size_t i = 0; i < std::size(zeta_flags); ++i) { | ||
| 37 | const u8 flag = zeta_flags[i]; | ||
| 38 | auto& table = tables[i]; | ||
| 39 | table[OFF(zeta_enable)] = flag; | ||
| 40 | table[OFF(zeta_width)] = flag; | ||
| 41 | table[OFF(zeta_height)] = flag; | ||
| 42 | FillBlock(table, OFF(zeta), NUM(zeta), flag); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | } // namespace VideoCommon::Dirty | ||
diff --git a/src/video_core/dirty_flags.h b/src/video_core/dirty_flags.h index d9058bcab..ed07dfc03 100644 --- a/src/video_core/dirty_flags.h +++ b/src/video_core/dirty_flags.h | |||
| @@ -4,7 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <algorithm> | ||
| 8 | #include <cstddef> | ||
| 9 | #include <iterator> | ||
| 10 | |||
| 7 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "video_core/engines/maxwell_3d.h" | ||
| 8 | 13 | ||
| 9 | namespace VideoCommon::Dirty { | 14 | namespace VideoCommon::Dirty { |
| 10 | 15 | ||
| @@ -25,4 +30,22 @@ enum : u8 { | |||
| 25 | LastCommonEntry, | 30 | LastCommonEntry, |
| 26 | }; | 31 | }; |
| 27 | 32 | ||
| 33 | template <typename Integer> | ||
| 34 | inline void FillBlock(Tegra::Engines::Maxwell3D::DirtyState::Table& table, std::size_t begin, | ||
| 35 | std::size_t num, Integer dirty_index) { | ||
| 36 | const auto it = std::begin(table) + begin; | ||
| 37 | std::fill(it, it + num, static_cast<u8>(dirty_index)); | ||
| 38 | } | ||
| 39 | |||
| 40 | template <typename Integer1, typename Integer2> | ||
| 41 | inline void FillBlock(Tegra::Engines::Maxwell3D::DirtyState::Tables& tables, std::size_t begin, | ||
| 42 | std::size_t num, Integer1 index_a, Integer2 index_b) { | ||
| 43 | FillBlock(tables[0], begin, num, index_a); | ||
| 44 | FillBlock(tables[1], begin, num, index_b); | ||
| 45 | } | ||
| 46 | |||
| 47 | void SetupCommonOnWriteStores(Tegra::Engines::Maxwell3D::DirtyState::Flags& store); | ||
| 48 | |||
| 49 | void SetupDirtyRenderTargets(Tegra::Engines::Maxwell3D::DirtyState::Tables& tables); | ||
| 50 | |||
| 28 | } // namespace VideoCommon::Dirty | 51 | } // namespace VideoCommon::Dirty |
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.cpp b/src/video_core/renderer_opengl/gl_state_tracker.cpp index d5088cfa5..1e43c9ec0 100644 --- a/src/video_core/renderer_opengl/gl_state_tracker.cpp +++ b/src/video_core/renderer_opengl/gl_state_tracker.cpp | |||
| @@ -26,39 +26,6 @@ using Regs = Maxwell3D::Regs; | |||
| 26 | using Tables = Maxwell3D::DirtyState::Tables; | 26 | using Tables = Maxwell3D::DirtyState::Tables; |
| 27 | using Table = Maxwell3D::DirtyState::Table; | 27 | using Table = Maxwell3D::DirtyState::Table; |
| 28 | 28 | ||
| 29 | template <typename Integer> | ||
| 30 | void FillBlock(Table& table, std::size_t begin, std::size_t num, Integer dirty_index) { | ||
| 31 | const auto it = std::begin(table) + begin; | ||
| 32 | std::fill(it, it + num, static_cast<u8>(dirty_index)); | ||
| 33 | } | ||
| 34 | |||
| 35 | template <typename Integer1, typename Integer2> | ||
| 36 | void FillBlock(Tables& tables, std::size_t begin, std::size_t num, Integer1 index_a, | ||
| 37 | Integer2 index_b) { | ||
| 38 | FillBlock(tables[0], begin, num, index_a); | ||
| 39 | FillBlock(tables[1], begin, num, index_b); | ||
| 40 | } | ||
| 41 | |||
| 42 | void SetupDirtyRenderTargets(Tables& tables) { | ||
| 43 | static constexpr std::size_t num_per_rt = NUM(rt[0]); | ||
| 44 | static constexpr std::size_t begin = OFF(rt); | ||
| 45 | static constexpr std::size_t num = num_per_rt * Regs::NumRenderTargets; | ||
| 46 | for (std::size_t rt = 0; rt < Regs::NumRenderTargets; ++rt) { | ||
| 47 | FillBlock(tables[0], begin + rt * num_per_rt, num_per_rt, ColorBuffer0 + rt); | ||
| 48 | } | ||
| 49 | FillBlock(tables[1], begin, num, RenderTargets); | ||
| 50 | |||
| 51 | static constexpr std::array zeta_flags{ZetaBuffer, RenderTargets}; | ||
| 52 | for (std::size_t i = 0; i < std::size(zeta_flags); ++i) { | ||
| 53 | const u8 flag = zeta_flags[i]; | ||
| 54 | auto& table = tables[i]; | ||
| 55 | table[OFF(zeta_enable)] = flag; | ||
| 56 | table[OFF(zeta_width)] = flag; | ||
| 57 | table[OFF(zeta_height)] = flag; | ||
| 58 | FillBlock(table, OFF(zeta), NUM(zeta), flag); | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | void SetupDirtyColorMasks(Tables& tables) { | 29 | void SetupDirtyColorMasks(Tables& tables) { |
| 63 | tables[0][OFF(color_mask_common)] = ColorMaskCommon; | 30 | tables[0][OFF(color_mask_common)] = ColorMaskCommon; |
| 64 | for (std::size_t rt = 0; rt < Regs::NumRenderTargets; ++rt) { | 31 | for (std::size_t rt = 0; rt < Regs::NumRenderTargets; ++rt) { |
| @@ -261,11 +228,7 @@ void StateTracker::Initialize() { | |||
| 261 | SetupDirtyMisc(tables); | 228 | SetupDirtyMisc(tables); |
| 262 | 229 | ||
| 263 | auto& store = dirty.on_write_stores; | 230 | auto& store = dirty.on_write_stores; |
| 264 | store[RenderTargets] = true; | 231 | SetupCommonOnWriteStores(store); |
| 265 | store[ZetaBuffer] = true; | ||
| 266 | for (std::size_t i = 0; i < Regs::NumRenderTargets; ++i) { | ||
| 267 | store[ColorBuffer0 + i] = true; | ||
| 268 | } | ||
| 269 | store[VertexBuffers] = true; | 232 | store[VertexBuffers] = true; |
| 270 | for (std::size_t i = 0; i < Regs::NumVertexArrays; ++i) { | 233 | for (std::size_t i = 0; i < Regs::NumVertexArrays; ++i) { |
| 271 | store[VertexBuffer0 + i] = true; | 234 | store[VertexBuffer0 + i] = true; |
diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.cpp b/src/video_core/renderer_vulkan/vk_state_tracker.cpp index 67229ffcc..d74e68b63 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.cpp +++ b/src/video_core/renderer_vulkan/vk_state_tracker.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| 11 | #include "video_core/dirty_flags.h" | ||
| 11 | #include "video_core/engines/maxwell_3d.h" | 12 | #include "video_core/engines/maxwell_3d.h" |
| 12 | #include "video_core/gpu.h" | 13 | #include "video_core/gpu.h" |
| 13 | #include "video_core/renderer_vulkan/vk_state_tracker.h" | 14 | #include "video_core/renderer_vulkan/vk_state_tracker.h" |
| @@ -38,39 +39,6 @@ Flags MakeInvalidationFlags() { | |||
| 38 | return flags; | 39 | return flags; |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | template <typename Integer> | ||
| 42 | void FillBlock(Table& table, std::size_t begin, std::size_t num, Integer dirty_index) { | ||
| 43 | const auto it = std::begin(table) + begin; | ||
| 44 | std::fill(it, it + num, static_cast<u8>(dirty_index)); | ||
| 45 | } | ||
| 46 | |||
| 47 | template <typename Integer1, typename Integer2> | ||
| 48 | void FillBlock(Tables& tables, std::size_t begin, std::size_t num, Integer1 index_a, | ||
| 49 | Integer2 index_b) { | ||
| 50 | FillBlock(tables[0], begin, num, index_a); | ||
| 51 | FillBlock(tables[1], begin, num, index_b); | ||
| 52 | } | ||
| 53 | |||
| 54 | void SetupDirtyRenderTargets(Tables& tables) { | ||
| 55 | static constexpr std::size_t num_per_rt = NUM(rt[0]); | ||
| 56 | static constexpr std::size_t begin = OFF(rt); | ||
| 57 | static constexpr std::size_t num = num_per_rt * Regs::NumRenderTargets; | ||
| 58 | for (std::size_t rt = 0; rt < Regs::NumRenderTargets; ++rt) { | ||
| 59 | FillBlock(tables[0], begin + rt * num_per_rt, num_per_rt, ColorBuffer0 + rt); | ||
| 60 | } | ||
| 61 | FillBlock(tables[1], begin, num, RenderTargets); | ||
| 62 | |||
| 63 | static constexpr std::array zeta_flags{ZetaBuffer, RenderTargets}; | ||
| 64 | for (std::size_t i = 0; i < std::size(zeta_flags); ++i) { | ||
| 65 | const u8 flag = zeta_flags[i]; | ||
| 66 | auto& table = tables[i]; | ||
| 67 | table[OFF(zeta_enable)] = flag; | ||
| 68 | table[OFF(zeta_width)] = flag; | ||
| 69 | table[OFF(zeta_height)] = flag; | ||
| 70 | FillBlock(table, OFF(zeta), NUM(zeta), flag); | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | void SetupDirtyViewports(Tables& tables) { | 42 | void SetupDirtyViewports(Tables& tables) { |
| 75 | FillBlock(tables[0], OFF(viewport_transform), NUM(viewport_transform), Viewports); | 43 | FillBlock(tables[0], OFF(viewport_transform), NUM(viewport_transform), Viewports); |
| 76 | FillBlock(tables[0], OFF(viewports), NUM(viewports), Viewports); | 44 | FillBlock(tables[0], OFF(viewports), NUM(viewports), Viewports); |
| @@ -123,12 +91,7 @@ void StateTracker::Initialize() { | |||
| 123 | SetupDirtyDepthBounds(tables); | 91 | SetupDirtyDepthBounds(tables); |
| 124 | SetupDirtyStencilProperties(tables); | 92 | SetupDirtyStencilProperties(tables); |
| 125 | 93 | ||
| 126 | auto& store = dirty.on_write_stores; | 94 | SetupCommonOnWriteStores(dirty.on_write_stores); |
| 127 | store[RenderTargets] = true; | ||
| 128 | store[ZetaBuffer] = true; | ||
| 129 | for (std::size_t i = 0; i < Regs::NumRenderTargets; ++i) { | ||
| 130 | store[ColorBuffer0 + i] = true; | ||
| 131 | } | ||
| 132 | } | 95 | } |
| 133 | 96 | ||
| 134 | void StateTracker::InvalidateCommandBufferState() { | 97 | void StateTracker::InvalidateCommandBufferState() { |