summaryrefslogtreecommitdiff
path: root/src/video_core/dirty_flags.cpp
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-02-21 01:56:00 -0300
committerGravatar ReinUsesLisp2020-02-28 17:56:43 -0300
commitac204754d4fe2aaae214025d8f1f40bcb938d74f (patch)
tree2d22f37fa52eda5fd66d7420e2c4c674c7b863c1 /src/video_core/dirty_flags.cpp
parentvk_rasterizer: Pass Maxwell registers to dynamic updates (diff)
downloadyuzu-ac204754d4fe2aaae214025d8f1f40bcb938d74f.tar.gz
yuzu-ac204754d4fe2aaae214025d8f1f40bcb938d74f.tar.xz
yuzu-ac204754d4fe2aaae214025d8f1f40bcb938d74f.zip
dirty_flags: Deduplicate code between OpenGL and Vulkan
Diffstat (limited to 'src/video_core/dirty_flags.cpp')
-rw-r--r--src/video_core/dirty_flags.cpp46
1 files changed, 46 insertions, 0 deletions
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
14namespace VideoCommon::Dirty {
15
16using Tegra::Engines::Maxwell3D;
17
18void 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
26void 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