video_core, kernel: added gfx eop event handling

This commit is contained in:
psucien 2024-05-07 22:46:54 +02:00
parent 96cf59efea
commit 4206ec3c94
5 changed files with 60 additions and 8 deletions

View File

@ -30,8 +30,26 @@ static inline u32* WriteTrailingNop(u32* cmdbuf) {
return cmdbuf + data_block_size + 1 /* header */; return cmdbuf + data_block_size + 1 /* header */;
} }
int PS4_SYSV_ABI sceGnmAddEqEvent() { s32 PS4_SYSV_ABI sceGnmAddEqEvent(SceKernelEqueue eq, u64 id, void* udata) {
LOG_ERROR(Lib_GnmDriver, "(STUBBED) called"); LOG_TRACE(Lib_GnmDriver, "called");
ASSERT_MSG(id == SceKernelEvent::Type::GfxEop);
if (!eq) {
return ORBIS_KERNEL_ERROR_EBADF;
}
EqueueEvent kernel_event{};
kernel_event.event.ident = id;
kernel_event.event.filter = EVFILT_GRAPHICS_CORE;
kernel_event.event.flags = 1;
kernel_event.event.fflags = 0;
kernel_event.event.data = id;
kernel_event.event.udata = udata;
eq->addEvent(kernel_event);
liverpool->eop_callback = [=]() {
eq->triggerEvent(SceKernelEvent::Type::GfxEop, EVFILT_GRAPHICS_CORE, nullptr);
};
return ORBIS_OK; return ORBIS_OK;
} }
@ -131,8 +149,15 @@ int PS4_SYSV_ABI sceGnmDebugHardwareStatus() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceGnmDeleteEqEvent() { s32 PS4_SYSV_ABI sceGnmDeleteEqEvent(SceKernelEqueue eq, u64 id) {
LOG_ERROR(Lib_GnmDriver, "(STUBBED) called"); LOG_TRACE(Lib_GnmDriver, "called");
ASSERT_MSG(id == SceKernelEvent::Type::GfxEop);
if (!eq) {
return ORBIS_KERNEL_ERROR_EBADF;
}
eq->removeEvent(id);
return ORBIS_OK; return ORBIS_OK;
} }

View File

@ -4,6 +4,7 @@
#pragma once #pragma once
#include "common/types.h" #include "common/types.h"
#include "core/libraries/kernel/event_queues.h"
namespace Core::Loader { namespace Core::Loader {
class SymbolsResolver; class SymbolsResolver;
@ -11,7 +12,9 @@ class SymbolsResolver;
namespace Libraries::GnmDriver { namespace Libraries::GnmDriver {
int PS4_SYSV_ABI sceGnmAddEqEvent(); using namespace Kernel;
s32 PS4_SYSV_ABI sceGnmAddEqEvent(SceKernelEqueue eq, u64 id, void* udata);
int PS4_SYSV_ABI sceGnmAreSubmitsAllowed(); int PS4_SYSV_ABI sceGnmAreSubmitsAllowed();
int PS4_SYSV_ABI sceGnmBeginWorkload(); int PS4_SYSV_ABI sceGnmBeginWorkload();
s32 PS4_SYSV_ABI sceGnmComputeWaitOnAddress(u32* cmdbuf, u32 size, uintptr_t addr, u32 mask, s32 PS4_SYSV_ABI sceGnmComputeWaitOnAddress(u32* cmdbuf, u32 size, uintptr_t addr, u32 mask,
@ -28,7 +31,7 @@ int PS4_SYSV_ABI sceGnmDebuggerSetAddressWatch();
int PS4_SYSV_ABI sceGnmDebuggerWriteGds(); int PS4_SYSV_ABI sceGnmDebuggerWriteGds();
int PS4_SYSV_ABI sceGnmDebuggerWriteSqIndirectRegister(); int PS4_SYSV_ABI sceGnmDebuggerWriteSqIndirectRegister();
int PS4_SYSV_ABI sceGnmDebugHardwareStatus(); int PS4_SYSV_ABI sceGnmDebugHardwareStatus();
int PS4_SYSV_ABI sceGnmDeleteEqEvent(); s32 PS4_SYSV_ABI sceGnmDeleteEqEvent(SceKernelEqueue eq, u64 id);
int PS4_SYSV_ABI sceGnmDestroyWorkloadStream(); int PS4_SYSV_ABI sceGnmDestroyWorkloadStream();
int PS4_SYSV_ABI sceGnmDingDong(); int PS4_SYSV_ABI sceGnmDingDong();
int PS4_SYSV_ABI sceGnmDingDongForWorkload(); int PS4_SYSV_ABI sceGnmDingDongForWorkload();

View File

@ -20,6 +20,14 @@ int EqueueInternal::addEvent(const EqueueEvent& event) {
return 0; return 0;
} }
int EqueueInternal::removeEvent(u64 id) {
const auto& event_q = std::find_if(m_events.cbegin(), m_events.cend(),
[id](auto& ev) { return ev.event.ident == id; });
ASSERT(event_q != m_events.cend());
m_events.erase(event_q);
return 0;
}
int EqueueInternal::waitForEvents(SceKernelEvent* ev, int num, u32 micros) { int EqueueInternal::waitForEvents(SceKernelEvent* ev, int num, u32 micros) {
std::unique_lock lock{m_mutex}; std::unique_lock lock{m_mutex};
int ret = 0; int ret = 0;

View File

@ -42,11 +42,22 @@ using ResetFunc = void (*)(EqueueEvent* event);
using DeleteFunc = void (*)(EqueueInternal* eq, EqueueEvent* event); using DeleteFunc = void (*)(EqueueInternal* eq, EqueueEvent* event);
struct SceKernelEvent { struct SceKernelEvent {
enum Type : u64 {
Compute0RelMem = 0x00,
Compute1RelMem = 0x01,
Compute2RelMem = 0x02,
Compute3RelMem = 0x03,
Compute4RelMem = 0x04,
Compute5RelMem = 0x05,
Compute6RelMem = 0x06,
GfxEop = 0x40
};
u64 ident = 0; /* identifier for this event */ u64 ident = 0; /* identifier for this event */
s16 filter = 0; /* filter for event */ s16 filter = 0; /* filter for event */
u16 flags = 0; u16 flags = 0;
u32 fflags = 0; u32 fflags = 0;
s64 data = 0; u64 data = 0;
void* udata = nullptr; /* opaque user data identifier */ void* udata = nullptr; /* opaque user data identifier */
}; };
@ -80,6 +91,7 @@ public:
this->m_name = m_name; this->m_name = m_name;
} }
int addEvent(const EqueueEvent& event); int addEvent(const EqueueEvent& event);
int removeEvent(u64 id);
int waitForEvents(SceKernelEvent* ev, int num, u32 micros); int waitForEvents(SceKernelEvent* ev, int num, u32 micros);
bool triggerEvent(u64 ident, s16 filter, void* trigger_data); bool triggerEvent(u64 ident, s16 filter, void* trigger_data);
int getTriggeredEvents(SceKernelEvent* ev, int num); int getTriggeredEvents(SceKernelEvent* ev, int num);

View File

@ -3,10 +3,12 @@
#pragma once #pragma once
#include <array>
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/types.h" #include "common/types.h"
#include <array>
#include <functional>
namespace AmdGpu { namespace AmdGpu {
#define GFX6_3D_REG_INDEX(field_name) (offsetof(AmdGpu::Liverpool::Regs, field_name) / sizeof(u32)) #define GFX6_3D_REG_INDEX(field_name) (offsetof(AmdGpu::Liverpool::Regs, field_name) / sizeof(u32))
@ -611,6 +613,8 @@ public:
Liverpool(); Liverpool();
void ProcessCmdList(u32* cmdbuf, u32 size_in_bytes); void ProcessCmdList(u32* cmdbuf, u32 size_in_bytes);
std::function<void(void)> eop_callback{};
}; };
static_assert(GFX6_3D_REG_INDEX(ps_program) == 0x2C08); static_assert(GFX6_3D_REG_INDEX(ps_program) == 0x2C08);