mirror of https://git.suyu.dev/suyu/suyu
nvhost_ctrl: Refactor usage of gpu.LockSync()
This seems to only be used to protect a later gpu function call. So we can move the lock into that call instead.
This commit is contained in:
parent
427bf76e62
commit
6c0d902373
|
@ -111,7 +111,6 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
|
||||||
event.event->GetWritableEvent().Signal();
|
event.event->GetWritableEvent().Signal();
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
auto lock = gpu.LockSync();
|
|
||||||
const u32 current_syncpoint_value = event.fence.value;
|
const u32 current_syncpoint_value = event.fence.value;
|
||||||
const s32 diff = current_syncpoint_value - params.threshold;
|
const s32 diff = current_syncpoint_value - params.threshold;
|
||||||
if (diff >= 0) {
|
if (diff >= 0) {
|
||||||
|
@ -132,23 +131,24 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
|
||||||
}
|
}
|
||||||
|
|
||||||
EventState status = events_interface.status[event_id];
|
EventState status = events_interface.status[event_id];
|
||||||
if (event_id < MaxNvEvents || status == EventState::Free || status == EventState::Registered) {
|
const bool bad_parameter = status != EventState::Free && status != EventState::Registered;
|
||||||
events_interface.SetEventStatus(event_id, EventState::Waiting);
|
if (bad_parameter) {
|
||||||
events_interface.assigned_syncpt[event_id] = params.syncpt_id;
|
|
||||||
events_interface.assigned_value[event_id] = target_value;
|
|
||||||
if (is_async) {
|
|
||||||
params.value = params.syncpt_id << 4;
|
|
||||||
} else {
|
|
||||||
params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
|
|
||||||
}
|
|
||||||
params.value |= event_id;
|
|
||||||
event.event->GetWritableEvent().Clear();
|
|
||||||
gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value);
|
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
return NvResult::Timeout;
|
return NvResult::BadParameter;
|
||||||
}
|
}
|
||||||
|
events_interface.SetEventStatus(event_id, EventState::Waiting);
|
||||||
|
events_interface.assigned_syncpt[event_id] = params.syncpt_id;
|
||||||
|
events_interface.assigned_value[event_id] = target_value;
|
||||||
|
if (is_async) {
|
||||||
|
params.value = params.syncpt_id << 4;
|
||||||
|
} else {
|
||||||
|
params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
|
||||||
|
}
|
||||||
|
params.value |= event_id;
|
||||||
|
event.event->GetWritableEvent().Clear();
|
||||||
|
gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value);
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
return NvResult::BadParameter;
|
return NvResult::Timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_ctrl::IocCtrlEventRegister(const std::vector<u8>& input, std::vector<u8>& output) {
|
NvResult nvhost_ctrl::IocCtrlEventRegister(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||||
|
|
|
@ -262,6 +262,7 @@ struct GPU::Impl {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) {
|
void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) {
|
||||||
|
std::lock_guard lock{sync_mutex};
|
||||||
auto& interrupt = syncpt_interrupts.at(syncpoint_id);
|
auto& interrupt = syncpt_interrupts.at(syncpoint_id);
|
||||||
bool contains = std::any_of(interrupt.begin(), interrupt.end(),
|
bool contains = std::any_of(interrupt.begin(), interrupt.end(),
|
||||||
[value](u32 in_value) { return in_value == value; });
|
[value](u32 in_value) { return in_value == value; });
|
||||||
|
@ -300,10 +301,6 @@ struct GPU::Impl {
|
||||||
return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den;
|
return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::unique_lock<std::mutex> LockSync() {
|
|
||||||
return std::unique_lock{sync_mutex};
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] bool IsAsync() const {
|
[[nodiscard]] bool IsAsync() const {
|
||||||
return is_async;
|
return is_async;
|
||||||
}
|
}
|
||||||
|
@ -862,10 +859,6 @@ u64 GPU::GetTicks() const {
|
||||||
return impl->GetTicks();
|
return impl->GetTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock<std::mutex> GPU::LockSync() {
|
|
||||||
return impl->LockSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GPU::IsAsync() const {
|
bool GPU::IsAsync() const {
|
||||||
return impl->IsAsync();
|
return impl->IsAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,22 +5,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "video_core/cdma_pusher.h"
|
#include "video_core/cdma_pusher.h"
|
||||||
#include "video_core/framebuffer_config.h"
|
#include "video_core/framebuffer_config.h"
|
||||||
|
|
||||||
using CacheAddr = std::uintptr_t;
|
|
||||||
[[nodiscard]] inline CacheAddr ToCacheAddr(const void* host_ptr) {
|
|
||||||
return reinterpret_cast<CacheAddr>(host_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] inline u8* FromCacheAddr(CacheAddr cache_addr) {
|
|
||||||
return reinterpret_cast<u8*>(cache_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Frontend {
|
namespace Frontend {
|
||||||
class EmuWindow;
|
class EmuWindow;
|
||||||
|
@ -230,8 +220,6 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] u64 GetTicks() const;
|
[[nodiscard]] u64 GetTicks() const;
|
||||||
|
|
||||||
[[nodiscard]] std::unique_lock<std::mutex> LockSync();
|
|
||||||
|
|
||||||
[[nodiscard]] bool IsAsync() const;
|
[[nodiscard]] bool IsAsync() const;
|
||||||
|
|
||||||
[[nodiscard]] bool UseNvdec() const;
|
[[nodiscard]] bool UseNvdec() const;
|
||||||
|
|
Loading…
Reference in New Issue