diff options
| author | 2019-12-26 22:14:10 -0300 | |
|---|---|---|
| committer | 2020-02-28 17:56:41 -0300 | |
| commit | eed789d0d134fbeef1c16f9829b5c1b4b7dabb17 (patch) | |
| tree | 4a7dba754df1a71c29de64cfaab34b56b0d72dff /src | |
| parent | gl_state: Remove completely (diff) | |
| download | yuzu-eed789d0d134fbeef1c16f9829b5c1b4b7dabb17.tar.gz yuzu-eed789d0d134fbeef1c16f9829b5c1b4b7dabb17.tar.xz yuzu-eed789d0d134fbeef1c16f9829b5c1b4b7dabb17.zip | |
video_core: Reintroduce dirty flags infrastructure
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/video_core/dirty_flags.h | 28 | ||||
| -rw-r--r-- | src/video_core/dma_pusher.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/engines/kepler_compute.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/engines/kepler_memory.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 14 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/rasterizer_interface.h | 3 |
10 files changed, 72 insertions, 1 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index a82faf127..218508126 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -174,6 +174,7 @@ struct System::Impl { | |||
| 174 | } | 174 | } |
| 175 | interrupt_manager = std::make_unique<Core::Hardware::InterruptManager>(system); | 175 | interrupt_manager = std::make_unique<Core::Hardware::InterruptManager>(system); |
| 176 | gpu_core = VideoCore::CreateGPU(system); | 176 | gpu_core = VideoCore::CreateGPU(system); |
| 177 | renderer->Rasterizer().SetupDirtyFlags(); | ||
| 177 | 178 | ||
| 178 | is_powered_on = true; | 179 | is_powered_on = true; |
| 179 | exit_lock = false; | 180 | exit_lock = false; |
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index b89752882..18b774ac7 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.h | ||
| 5 | dma_pusher.cpp | 6 | dma_pusher.cpp |
| 6 | dma_pusher.h | 7 | dma_pusher.h |
| 7 | engines/const_buffer_engine_interface.h | 8 | engines/const_buffer_engine_interface.h |
diff --git a/src/video_core/dirty_flags.h b/src/video_core/dirty_flags.h new file mode 100644 index 000000000..d9058bcab --- /dev/null +++ b/src/video_core/dirty_flags.h | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | // Copyright 2019 yuzu 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 "common/common_types.h" | ||
| 8 | |||
| 9 | namespace VideoCommon::Dirty { | ||
| 10 | |||
| 11 | enum : u8 { | ||
| 12 | NullEntry = 0, | ||
| 13 | |||
| 14 | RenderTargets, | ||
| 15 | ColorBuffer0, | ||
| 16 | ColorBuffer1, | ||
| 17 | ColorBuffer2, | ||
| 18 | ColorBuffer3, | ||
| 19 | ColorBuffer4, | ||
| 20 | ColorBuffer5, | ||
| 21 | ColorBuffer6, | ||
| 22 | ColorBuffer7, | ||
| 23 | ZetaBuffer, | ||
| 24 | |||
| 25 | LastCommonEntry, | ||
| 26 | }; | ||
| 27 | |||
| 28 | } // namespace VideoCommon::Dirty | ||
diff --git a/src/video_core/dma_pusher.cpp b/src/video_core/dma_pusher.cpp index a42d37c81..713c14182 100644 --- a/src/video_core/dma_pusher.cpp +++ b/src/video_core/dma_pusher.cpp | |||
| @@ -21,6 +21,9 @@ MICROPROFILE_DEFINE(DispatchCalls, "GPU", "Execute command buffer", MP_RGB(128, | |||
| 21 | void DmaPusher::DispatchCalls() { | 21 | void DmaPusher::DispatchCalls() { |
| 22 | MICROPROFILE_SCOPE(DispatchCalls); | 22 | MICROPROFILE_SCOPE(DispatchCalls); |
| 23 | 23 | ||
| 24 | // On entering GPU code, assume all memory may be touched by the ARM core. | ||
| 25 | gpu.Maxwell3D().OnMemoryWrite(); | ||
| 26 | |||
| 24 | dma_pushbuffer_subindex = 0; | 27 | dma_pushbuffer_subindex = 0; |
| 25 | 28 | ||
| 26 | while (Core::System::GetInstance().IsPoweredOn()) { | 29 | while (Core::System::GetInstance().IsPoweredOn()) { |
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp index 254ad6810..ae52afa79 100644 --- a/src/video_core/engines/kepler_compute.cpp +++ b/src/video_core/engines/kepler_compute.cpp | |||
| @@ -38,6 +38,9 @@ void KeplerCompute::CallMethod(const GPU::MethodCall& method_call) { | |||
| 38 | case KEPLER_COMPUTE_REG_INDEX(data_upload): { | 38 | case KEPLER_COMPUTE_REG_INDEX(data_upload): { |
| 39 | const bool is_last_call = method_call.IsLastCall(); | 39 | const bool is_last_call = method_call.IsLastCall(); |
| 40 | upload_state.ProcessData(method_call.argument, is_last_call); | 40 | upload_state.ProcessData(method_call.argument, is_last_call); |
| 41 | if (is_last_call) { | ||
| 42 | system.GPU().Maxwell3D().OnMemoryWrite(); | ||
| 43 | } | ||
| 41 | break; | 44 | break; |
| 42 | } | 45 | } |
| 43 | case KEPLER_COMPUTE_REG_INDEX(launch): | 46 | case KEPLER_COMPUTE_REG_INDEX(launch): |
diff --git a/src/video_core/engines/kepler_memory.cpp b/src/video_core/engines/kepler_memory.cpp index b504b450e..597872e43 100644 --- a/src/video_core/engines/kepler_memory.cpp +++ b/src/video_core/engines/kepler_memory.cpp | |||
| @@ -33,6 +33,9 @@ void KeplerMemory::CallMethod(const GPU::MethodCall& method_call) { | |||
| 33 | case KEPLERMEMORY_REG_INDEX(data): { | 33 | case KEPLERMEMORY_REG_INDEX(data): { |
| 34 | const bool is_last_call = method_call.IsLastCall(); | 34 | const bool is_last_call = method_call.IsLastCall(); |
| 35 | upload_state.ProcessData(method_call.argument, is_last_call); | 35 | upload_state.ProcessData(method_call.argument, is_last_call); |
| 36 | if (is_last_call) { | ||
| 37 | system.GPU().Maxwell3D().OnMemoryWrite(); | ||
| 38 | } | ||
| 36 | break; | 39 | break; |
| 37 | } | 40 | } |
| 38 | } | 41 | } |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 7a6bf764c..db710bf35 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -26,6 +26,8 @@ Maxwell3D::Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& raste | |||
| 26 | MemoryManager& memory_manager) | 26 | MemoryManager& memory_manager) |
| 27 | : system{system}, rasterizer{rasterizer}, memory_manager{memory_manager}, | 27 | : system{system}, rasterizer{rasterizer}, memory_manager{memory_manager}, |
| 28 | macro_interpreter{*this}, upload_state{memory_manager, regs.upload} { | 28 | macro_interpreter{*this}, upload_state{memory_manager, regs.upload} { |
| 29 | dirty.flags.flip(); | ||
| 30 | |||
| 29 | InitializeRegisterDefaults(); | 31 | InitializeRegisterDefaults(); |
| 30 | } | 32 | } |
| 31 | 33 | ||
| @@ -158,7 +160,13 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 158 | ASSERT_MSG(method < Regs::NUM_REGS, | 160 | ASSERT_MSG(method < Regs::NUM_REGS, |
| 159 | "Invalid Maxwell3D register, increase the size of the Regs structure"); | 161 | "Invalid Maxwell3D register, increase the size of the Regs structure"); |
| 160 | 162 | ||
| 161 | regs.reg_array[method] = method_call.argument; | 163 | if (regs.reg_array[method] != method_call.argument) { |
| 164 | regs.reg_array[method] = method_call.argument; | ||
| 165 | |||
| 166 | for (const auto& table : dirty.tables) { | ||
| 167 | dirty.flags[table[method]] = true; | ||
| 168 | } | ||
| 169 | } | ||
| 162 | 170 | ||
| 163 | switch (method) { | 171 | switch (method) { |
| 164 | case MAXWELL3D_REG_INDEX(macros.data): { | 172 | case MAXWELL3D_REG_INDEX(macros.data): { |
| @@ -243,6 +251,9 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 243 | case MAXWELL3D_REG_INDEX(data_upload): { | 251 | case MAXWELL3D_REG_INDEX(data_upload): { |
| 244 | const bool is_last_call = method_call.IsLastCall(); | 252 | const bool is_last_call = method_call.IsLastCall(); |
| 245 | upload_state.ProcessData(method_call.argument, is_last_call); | 253 | upload_state.ProcessData(method_call.argument, is_last_call); |
| 254 | if (is_last_call) { | ||
| 255 | OnMemoryWrite(); | ||
| 256 | } | ||
| 246 | break; | 257 | break; |
| 247 | } | 258 | } |
| 248 | default: | 259 | default: |
| @@ -549,6 +560,7 @@ void Maxwell3D::FinishCBData() { | |||
| 549 | 560 | ||
| 550 | const u32 id = cb_data_state.id; | 561 | const u32 id = cb_data_state.id; |
| 551 | memory_manager.WriteBlock(address, cb_data_state.buffer[id].data(), size); | 562 | memory_manager.WriteBlock(address, cb_data_state.buffer[id].data(), size); |
| 563 | OnMemoryWrite(); | ||
| 552 | 564 | ||
| 553 | cb_data_state.id = null_cb_data; | 565 | cb_data_state.id = null_cb_data; |
| 554 | cb_data_state.current = null_cb_data; | 566 | cb_data_state.current = null_cb_data; |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index b0fb0fb7d..72848b1e8 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <bitset> | 8 | #include <bitset> |
| 9 | #include <limits> | ||
| 9 | #include <optional> | 10 | #include <optional> |
| 10 | #include <type_traits> | 11 | #include <type_traits> |
| 11 | #include <unordered_map> | 12 | #include <unordered_map> |
| @@ -1274,6 +1275,13 @@ public: | |||
| 1274 | return execute_on; | 1275 | return execute_on; |
| 1275 | } | 1276 | } |
| 1276 | 1277 | ||
| 1278 | /// Notify a memory write has happened. | ||
| 1279 | void OnMemoryWrite() { | ||
| 1280 | for (const u8 store : dirty.on_write_stores) { | ||
| 1281 | dirty.flags[store] = true; | ||
| 1282 | } | ||
| 1283 | } | ||
| 1284 | |||
| 1277 | enum class MMEDrawMode : u32 { | 1285 | enum class MMEDrawMode : u32 { |
| 1278 | Undefined, | 1286 | Undefined, |
| 1279 | Array, | 1287 | Array, |
| @@ -1289,6 +1297,12 @@ public: | |||
| 1289 | u32 gl_end_count{}; | 1297 | u32 gl_end_count{}; |
| 1290 | } mme_draw; | 1298 | } mme_draw; |
| 1291 | 1299 | ||
| 1300 | struct { | ||
| 1301 | std::bitset<std::numeric_limits<u8>::max()> flags; | ||
| 1302 | std::array<std::array<u8, Regs::NUM_REGS>, 3> tables{}; | ||
| 1303 | std::array<u8, 32> on_write_stores{}; | ||
| 1304 | } dirty; | ||
| 1305 | |||
| 1292 | private: | 1306 | private: |
| 1293 | void InitializeRegisterDefaults(); | 1307 | void InitializeRegisterDefaults(); |
| 1294 | 1308 | ||
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index ae51765a6..c2610f992 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp | |||
| @@ -56,6 +56,9 @@ void MaxwellDMA::HandleCopy() { | |||
| 56 | return; | 56 | return; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | // All copies here update the main memory, so mark all rasterizer states as invalid. | ||
| 60 | system.GPU().Maxwell3D().OnMemoryWrite(); | ||
| 61 | |||
| 59 | if (regs.exec.is_dst_linear && regs.exec.is_src_linear) { | 62 | if (regs.exec.is_dst_linear && regs.exec.is_src_linear) { |
| 60 | // When the enable_2d bit is disabled, the copy is performed as if we were copying a 1D | 63 | // When the enable_2d bit is disabled, the copy is performed as if we were copying a 1D |
| 61 | // buffer of length `x_count`, otherwise we copy a 2D image of dimensions (x_count, | 64 | // buffer of length `x_count`, otherwise we copy a 2D image of dimensions (x_count, |
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index f18eaf4bc..3e4514b94 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h | |||
| @@ -89,6 +89,9 @@ public: | |||
| 89 | virtual void LoadDiskResources(const std::atomic_bool& stop_loading = false, | 89 | virtual void LoadDiskResources(const std::atomic_bool& stop_loading = false, |
| 90 | const DiskResourceLoadCallback& callback = {}) {} | 90 | const DiskResourceLoadCallback& callback = {}) {} |
| 91 | 91 | ||
| 92 | /// Initializes renderer dirty flags | ||
| 93 | virtual void SetupDirtyFlags() {} | ||
| 94 | |||
| 92 | /// Grant access to the Guest Driver Profile for recording/obtaining info on the guest driver. | 95 | /// Grant access to the Guest Driver Profile for recording/obtaining info on the guest driver. |
| 93 | GuestDriverProfile& AccessGuestDriverProfile() { | 96 | GuestDriverProfile& AccessGuestDriverProfile() { |
| 94 | return guest_driver_profile; | 97 | return guest_driver_profile; |