summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp30
-rw-r--r--src/video_core/gpu.cpp9
-rw-r--r--src/video_core/gpu.h12
3 files changed, 16 insertions, 35 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index 775e76330..8b4867ca7 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -111,7 +111,6 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
111 event.event->GetWritableEvent().Signal(); 111 event.event->GetWritableEvent().Signal();
112 return NvResult::Success; 112 return NvResult::Success;
113 } 113 }
114 auto lock = gpu.LockSync();
115 const u32 current_syncpoint_value = event.fence.value; 114 const u32 current_syncpoint_value = event.fence.value;
116 const s32 diff = current_syncpoint_value - params.threshold; 115 const s32 diff = current_syncpoint_value - params.threshold;
117 if (diff >= 0) { 116 if (diff >= 0) {
@@ -132,23 +131,24 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
132 } 131 }
133 132
134 EventState status = events_interface.status[event_id]; 133 EventState status = events_interface.status[event_id];
135 if (event_id < MaxNvEvents || status == EventState::Free || status == EventState::Registered) { 134 const bool bad_parameter = status != EventState::Free && status != EventState::Registered;
136 events_interface.SetEventStatus(event_id, EventState::Waiting); 135 if (bad_parameter) {
137 events_interface.assigned_syncpt[event_id] = params.syncpt_id;
138 events_interface.assigned_value[event_id] = target_value;
139 if (is_async) {
140 params.value = params.syncpt_id << 4;
141 } else {
142 params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
143 }
144 params.value |= event_id;
145 event.event->GetWritableEvent().Clear();
146 gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value);
147 std::memcpy(output.data(), &params, sizeof(params)); 136 std::memcpy(output.data(), &params, sizeof(params));
148 return NvResult::Timeout; 137 return NvResult::BadParameter;
149 } 138 }
139 events_interface.SetEventStatus(event_id, EventState::Waiting);
140 events_interface.assigned_syncpt[event_id] = params.syncpt_id;
141 events_interface.assigned_value[event_id] = target_value;
142 if (is_async) {
143 params.value = params.syncpt_id << 4;
144 } else {
145 params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
146 }
147 params.value |= event_id;
148 event.event->GetWritableEvent().Clear();
149 gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value);
150 std::memcpy(output.data(), &params, sizeof(params)); 150 std::memcpy(output.data(), &params, sizeof(params));
151 return NvResult::BadParameter; 151 return NvResult::Timeout;
152} 152}
153 153
154NvResult nvhost_ctrl::IocCtrlEventRegister(const std::vector<u8>& input, std::vector<u8>& output) { 154NvResult nvhost_ctrl::IocCtrlEventRegister(const std::vector<u8>& input, std::vector<u8>& output) {
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 520675873..ab7c21a49 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -262,6 +262,7 @@ struct GPU::Impl {
262 } 262 }
263 263
264 void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) { 264 void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) {
265 std::lock_guard lock{sync_mutex};
265 auto& interrupt = syncpt_interrupts.at(syncpoint_id); 266 auto& interrupt = syncpt_interrupts.at(syncpoint_id);
266 bool contains = std::any_of(interrupt.begin(), interrupt.end(), 267 bool contains = std::any_of(interrupt.begin(), interrupt.end(),
267 [value](u32 in_value) { return in_value == value; }); 268 [value](u32 in_value) { return in_value == value; });
@@ -300,10 +301,6 @@ struct GPU::Impl {
300 return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den; 301 return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den;
301 } 302 }
302 303
303 [[nodiscard]] std::unique_lock<std::mutex> LockSync() {
304 return std::unique_lock{sync_mutex};
305 }
306
307 [[nodiscard]] bool IsAsync() const { 304 [[nodiscard]] bool IsAsync() const {
308 return is_async; 305 return is_async;
309 } 306 }
@@ -862,10 +859,6 @@ u64 GPU::GetTicks() const {
862 return impl->GetTicks(); 859 return impl->GetTicks();
863} 860}
864 861
865std::unique_lock<std::mutex> GPU::LockSync() {
866 return impl->LockSync();
867}
868
869bool GPU::IsAsync() const { 862bool GPU::IsAsync() const {
870 return impl->IsAsync(); 863 return impl->IsAsync();
871} 864}
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index 39b304823..05e5c94f3 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -5,22 +5,12 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <mutex>
9 8
10#include "common/bit_field.h" 9#include "common/bit_field.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
12#include "video_core/cdma_pusher.h" 11#include "video_core/cdma_pusher.h"
13#include "video_core/framebuffer_config.h" 12#include "video_core/framebuffer_config.h"
14 13
15using CacheAddr = std::uintptr_t;
16[[nodiscard]] inline CacheAddr ToCacheAddr(const void* host_ptr) {
17 return reinterpret_cast<CacheAddr>(host_ptr);
18}
19
20[[nodiscard]] inline u8* FromCacheAddr(CacheAddr cache_addr) {
21 return reinterpret_cast<u8*>(cache_addr);
22}
23
24namespace Core { 14namespace Core {
25namespace Frontend { 15namespace Frontend {
26class EmuWindow; 16class EmuWindow;
@@ -230,8 +220,6 @@ public:
230 220
231 [[nodiscard]] u64 GetTicks() const; 221 [[nodiscard]] u64 GetTicks() const;
232 222
233 [[nodiscard]] std::unique_lock<std::mutex> LockSync();
234
235 [[nodiscard]] bool IsAsync() const; 223 [[nodiscard]] bool IsAsync() const;
236 224
237 [[nodiscard]] bool UseNvdec() const; 225 [[nodiscard]] bool UseNvdec() const;