summaryrefslogtreecommitdiff
path: root/src/video_core/gpu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/gpu.cpp')
-rw-r--r--src/video_core/gpu.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 21007d8b2..1622332a4 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -29,7 +29,8 @@ u32 FramebufferConfig::BytesPerPixel(PixelFormat format) {
29 UNREACHABLE(); 29 UNREACHABLE();
30} 30}
31 31
32GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer) : renderer{renderer} { 32GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer, bool is_async)
33 : system{system}, renderer{renderer}, is_async{is_async} {
33 auto& rasterizer{renderer.Rasterizer()}; 34 auto& rasterizer{renderer.Rasterizer()};
34 memory_manager = std::make_unique<Tegra::MemoryManager>(system, rasterizer); 35 memory_manager = std::make_unique<Tegra::MemoryManager>(system, rasterizer);
35 dma_pusher = std::make_unique<Tegra::DmaPusher>(*this); 36 dma_pusher = std::make_unique<Tegra::DmaPusher>(*this);
@@ -74,6 +75,51 @@ const DmaPusher& GPU::DmaPusher() const {
74 return *dma_pusher; 75 return *dma_pusher;
75} 76}
76 77
78void GPU::IncrementSyncPoint(const u32 syncpoint_id) {
79 syncpoints[syncpoint_id]++;
80 std::lock_guard lock{sync_mutex};
81 if (!syncpt_interrupts[syncpoint_id].empty()) {
82 u32 value = syncpoints[syncpoint_id].load();
83 auto it = syncpt_interrupts[syncpoint_id].begin();
84 while (it != syncpt_interrupts[syncpoint_id].end()) {
85 if (value >= *it) {
86 TriggerCpuInterrupt(syncpoint_id, *it);
87 it = syncpt_interrupts[syncpoint_id].erase(it);
88 continue;
89 }
90 it++;
91 }
92 }
93}
94
95u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const {
96 return syncpoints[syncpoint_id].load();
97}
98
99void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) {
100 auto& interrupt = syncpt_interrupts[syncpoint_id];
101 bool contains = std::any_of(interrupt.begin(), interrupt.end(),
102 [value](u32 in_value) { return in_value == value; });
103 if (contains) {
104 return;
105 }
106 syncpt_interrupts[syncpoint_id].emplace_back(value);
107}
108
109bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) {
110 std::lock_guard lock{sync_mutex};
111 auto& interrupt = syncpt_interrupts[syncpoint_id];
112 const auto iter =
113 std::find_if(interrupt.begin(), interrupt.end(),
114 [value](u32 interrupt_value) { return value == interrupt_value; });
115
116 if (iter == interrupt.end()) {
117 return false;
118 }
119 interrupt.erase(iter);
120 return true;
121}
122
77u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { 123u32 RenderTargetBytesPerPixel(RenderTargetFormat format) {
78 ASSERT(format != RenderTargetFormat::NONE); 124 ASSERT(format != RenderTargetFormat::NONE);
79 125