early-access version 2174

This commit is contained in:
pineappleEA
2021-11-01 05:47:44 +01:00
parent b37854dccc
commit 03951516e2
23 changed files with 11363 additions and 5251 deletions

View File

@@ -98,7 +98,7 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
if (syncpoint_manager.IsSyncpointExpired(params.syncpt_id, params.threshold)) {
params.value = syncpoint_manager.GetSyncpointMin(params.syncpt_id);
std::memcpy(output.data(), &params, sizeof(params));
events_interface.fails[event_id] = 0;
events_interface.failed[event_id] = false;
return NvResult::Success;
}
@@ -106,35 +106,36 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
syncpoint_manager.IsSyncpointExpired(params.syncpt_id, params.threshold)) {
params.value = new_value;
std::memcpy(output.data(), &params, sizeof(params));
events_interface.fails[event_id] = 0;
events_interface.failed[event_id] = false;
return NvResult::Success;
}
auto& event = events_interface.events[event_id];
auto& gpu = system.GPU();
const u32 target_value = syncpoint_manager.GetSyncpointMax(params.syncpt_id);
// This is mostly to take into account unimplemented features. As synced
// gpu is always synced.
if (!gpu.IsAsync()) {
event.event->GetWritableEvent().Signal();
return NvResult::Success;
}
const u32 current_syncpoint_value = event.fence.value;
const s32 diff = current_syncpoint_value - params.threshold;
if (diff >= 0) {
event.event->GetWritableEvent().Signal();
params.value = current_syncpoint_value;
std::memcpy(output.data(), &params, sizeof(params));
events_interface.failed[event_id] = false;
return NvResult::Success;
}
const u32 target_value = current_syncpoint_value - diff;
if (!is_async) {
params.value = 0;
}
const auto check_failing = [&]() {
if (events_interface.fails[event_id] > 1) {
{
auto lk = system.StallCPU();
gpu.WaitFence(params.syncpt_id, target_value);
system.UnstallCPU();
}
std::memcpy(output.data(), &params, sizeof(params));
events_interface.fails[event_id] = 0;
return true;
}
return false;
};
if (params.timeout == 0) {
if (check_failing()) {
return NvResult::Success;
}
std::memcpy(output.data(), &params, sizeof(params));
return NvResult::Timeout;
}
@@ -153,7 +154,15 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
}
params.value |= event_id;
if (check_failing()) {
event.event->GetWritableEvent().Clear();
if (events_interface.failed[event_id]) {
{
auto lk = system.StallCPU();
gpu.WaitFence(params.syncpt_id, target_value);
system.UnstallCPU();
}
std::memcpy(output.data(), &params, sizeof(params));
events_interface.failed[event_id] = false;
return NvResult::Success;
}
gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value);
@@ -211,7 +220,7 @@ NvResult nvhost_ctrl::IocCtrlClearEventWait(const std::vector<u8>& input, std::v
if (events_interface.status[event_id] == EventState::Waiting) {
events_interface.LiberateEvent(event_id);
}
events_interface.fails[event_id]++;
events_interface.failed[event_id] = true;
syncpoint_manager.RefreshSyncpoint(events_interface.events[event_id].fence.id);

View File

@@ -50,7 +50,7 @@ struct EventInterface {
// Tells if an NVEvent is registered or not
std::array<bool, MaxNvEvents> registered{};
// Tells the NVEvent that it has failed.
std::array<u32, MaxNvEvents> fails{};
std::array<bool, MaxNvEvents> failed{};
// When an NVEvent is waiting on GPU interrupt, this is the sync_point
// associated with it.
std::array<u32, MaxNvEvents> assigned_syncpt{};