blob: c5dd2c86890867deda5354f8ebe85eea72c8b3d9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright 2023 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <functional>
#include <memory>
#include <boost/serialization/access.hpp>
#include "core/hle/service/gsp/gsp_interrupt.h"
namespace Service::GSP {
struct Command;
struct FrameBufferInfo;
} // namespace Service::GSP
namespace Core {
class System;
}
namespace Pica {
class DebugContext;
class PicaCore;
struct RegsLcd;
union ColorFill;
} // namespace Pica
namespace Frontend {
class EmuWindow;
}
namespace VideoCore {
/// Measured on hardware to be 2240568 timer cycles or 4481136 ARM11 cycles
constexpr u64 FRAME_TICKS = 4481136ull;
class GraphicsDebugger;
class RendererBase;
/**
* The GPU class is the high level interface to the video_core for core services.
*/
class GPU {
public:
explicit GPU(Core::System& system, Frontend::EmuWindow& emu_window,
Frontend::EmuWindow* secondary_window);
~GPU();
/// Sets the function to call for signalling GSP interrupts.
void SetInterruptHandler(Service::GSP::InterruptHandler handler);
/// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
void FlushRegion(PAddr addr, u32 size);
/// Notify rasterizer that any caches of the specified region should be invalidated
void InvalidateRegion(PAddr addr, u32 size);
/// Flushes and invalidates all memory in the rasterizer cache and removes any leftover state.
void ClearAll(bool flush);
/// Executes the provided GSP command.
void Execute(const Service::GSP::Command& command);
/// Updates GPU display framebuffer configuration using the specified parameters.
void SetBufferSwap(u32 screen_id, const Service::GSP::FrameBufferInfo& info);
/// Sets the LCD color fill configuration for the top and bottom screens.
void SetColorFill(const Pica::ColorFill& fill);
/// Reads a word from the GPU virtual address.
u32 ReadReg(VAddr addr);
/// Writes the provided value to the GPU virtual address.
void WriteReg(VAddr addr, u32 data);
/// Synchronizes fixed function renderer state with PICA registers.
void Sync();
/// Returns a mutable reference to the renderer.
[[nodiscard]] VideoCore::RendererBase& Renderer();
/// Returns a mutable reference to the PICA GPU.
[[nodiscard]] Pica::PicaCore& PicaCore();
/// Returns an immutable reference to the PICA GPU.
[[nodiscard]] const Pica::PicaCore& PicaCore() const;
/// Returns a mutable reference to the pica debugging context.
[[nodiscard]] Pica::DebugContext& DebugContext();
/// Returns a mutable reference to the GSP command debugger.
[[nodiscard]] GraphicsDebugger& Debugger();
private:
void SubmitCmdList(u32 index);
void MemoryFill(u32 index);
void MemoryTransfer();
void VBlankCallback(uintptr_t user_data, s64 cycles_late);
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const u32 file_version);
private:
struct Impl;
std::unique_ptr<Impl> impl;
PAddr VirtualToPhysicalAddress(VAddr addr);
};
} // namespace VideoCore
|