summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/engines/fermi_2d.cpp7
-rw-r--r--src/video_core/engines/fermi_2d.h28
-rw-r--r--src/video_core/gpu.cpp2
3 files changed, 34 insertions, 3 deletions
diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp
index 7aab163dc..87634da21 100644
--- a/src/video_core/engines/fermi_2d.cpp
+++ b/src/video_core/engines/fermi_2d.cpp
@@ -7,7 +7,12 @@
7namespace Tegra { 7namespace Tegra {
8namespace Engines { 8namespace Engines {
9 9
10void Fermi2D::WriteReg(u32 method, u32 value) {} 10Fermi2D::Fermi2D(MemoryManager& memory_manager) : memory_manager(memory_manager) {}
11
12void Fermi2D::WriteReg(u32 method, u32 value) {
13 ASSERT_MSG(method < Regs::NUM_REGS,
14 "Invalid Fermi2D register, increase the size of the Regs structure");
15}
11 16
12} // namespace Engines 17} // namespace Engines
13} // namespace Tegra 18} // namespace Tegra
diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h
index 8967ddede..a97f5bb28 100644
--- a/src/video_core/engines/fermi_2d.h
+++ b/src/video_core/engines/fermi_2d.h
@@ -4,19 +4,45 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
8#include "common/assert.h"
9#include "common/common_funcs.h"
7#include "common/common_types.h" 10#include "common/common_types.h"
11#include "video_core/memory_manager.h"
8 12
9namespace Tegra { 13namespace Tegra {
10namespace Engines { 14namespace Engines {
11 15
16#define FERMI2D_REG_INDEX(field_name) \
17 (offsetof(Tegra::Engines::Fermi2D::Regs, field_name) / sizeof(u32))
18
12class Fermi2D final { 19class Fermi2D final {
13public: 20public:
14 Fermi2D() = default; 21 explicit Fermi2D(MemoryManager& memory_manager);
15 ~Fermi2D() = default; 22 ~Fermi2D() = default;
16 23
17 /// Write the value to the register identified by method. 24 /// Write the value to the register identified by method.
18 void WriteReg(u32 method, u32 value); 25 void WriteReg(u32 method, u32 value);
26
27 struct Regs {
28 static constexpr size_t NUM_REGS = 0x258;
29
30 union {
31 struct {
32 INSERT_PADDING_WORDS(0x258);
33 };
34 std::array<u32, NUM_REGS> reg_array;
35 };
36 } regs{};
37
38 MemoryManager& memory_manager;
19}; 39};
20 40
41#define ASSERT_REG_POSITION(field_name, position) \
42 static_assert(offsetof(Fermi2D::Regs, field_name) == position * 4, \
43 "Field " #field_name " has invalid position")
44
45#undef ASSERT_REG_POSITION
46
21} // namespace Engines 47} // namespace Engines
22} // namespace Tegra 48} // namespace Tegra
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 9463cd5d6..351d21711 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -12,7 +12,7 @@ namespace Tegra {
12GPU::GPU() { 12GPU::GPU() {
13 memory_manager = std::make_unique<MemoryManager>(); 13 memory_manager = std::make_unique<MemoryManager>();
14 maxwell_3d = std::make_unique<Engines::Maxwell3D>(*memory_manager); 14 maxwell_3d = std::make_unique<Engines::Maxwell3D>(*memory_manager);
15 fermi_2d = std::make_unique<Engines::Fermi2D>(); 15 fermi_2d = std::make_unique<Engines::Fermi2D>(*memory_manager);
16 maxwell_compute = std::make_unique<Engines::MaxwellCompute>(); 16 maxwell_compute = std::make_unique<Engines::MaxwellCompute>();
17} 17}
18 18