mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-20 11:35:45 +00:00
kernel: dce event code cleanup
This commit is contained in:
parent
4dfe05db24
commit
6c54a3ce60
4 changed files with 37 additions and 19 deletions
|
@ -61,6 +61,20 @@ struct SceKernelEvent {
|
|||
void* udata = nullptr; /* opaque user data identifier */
|
||||
};
|
||||
|
||||
union DceHint {
|
||||
u64 raw;
|
||||
u32 event_id : 8;
|
||||
u32 : 8;
|
||||
u64 flip_arg : 32;
|
||||
};
|
||||
|
||||
union DceData {
|
||||
u64 raw;
|
||||
u64 time : 12;
|
||||
u32 counter : 4;
|
||||
u64 hint : 48;
|
||||
};
|
||||
|
||||
struct EqueueEvent {
|
||||
SceKernelEvent event;
|
||||
void* data = nullptr;
|
||||
|
@ -85,19 +99,23 @@ struct EqueueEvent {
|
|||
void TriggerDisplay(void* data) {
|
||||
is_triggered = true;
|
||||
auto hint = reinterpret_cast<u64>(data);
|
||||
if (hint != 0) {
|
||||
auto hint_h = static_cast<u32>(hint >> 8) & 0xFFFFFF;
|
||||
auto ident_h = static_cast<u32>(event.ident >> 40);
|
||||
if ((static_cast<u32>(hint) & 0xFF) == event.ident && event.ident != 0xFE &&
|
||||
((hint_h ^ ident_h) & 0xFF) == 0) {
|
||||
auto time = Common::FencedRDTSC();
|
||||
auto mask = 0xF000;
|
||||
if ((static_cast<u32>(event.data) & 0xF000) != 0xF000) {
|
||||
mask = (static_cast<u32>(event.data) + 0x1000) & 0xF000;
|
||||
}
|
||||
event.data = (mask | static_cast<u64>(static_cast<u32>(time) & 0xFFF) |
|
||||
(hint & 0xFFFFFFFFFFFF0000));
|
||||
if (hint == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
DceHint dce_hint = *reinterpret_cast<DceHint*>(&hint);
|
||||
DceData dce_data = *reinterpret_cast<DceData*>(&event.data);
|
||||
|
||||
const auto hint_h = static_cast<u32>(hint >> 8) & 0xffffff;
|
||||
const auto ident_h = static_cast<u32>(event.ident << 8);
|
||||
if (dce_hint.event_id == event.ident && event.ident != 0xfe &&
|
||||
((hint_h ^ ident_h) & 0xff) == 0) {
|
||||
dce_data.time = Common::FencedRDTSC();
|
||||
if (dce_data.counter != 15) {
|
||||
dce_data.counter++;
|
||||
}
|
||||
dce_data.hint = dce_hint.raw;
|
||||
event.data = dce_data.raw;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode
|
|||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev) {
|
||||
s32 PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev) {
|
||||
if (ev == nullptr) {
|
||||
return ORBIS_VIDEO_OUT_ERROR_INVALID_ADDRESS;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ int PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev) {
|
|||
}
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, int64_t* data) {
|
||||
s32 PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, s64* data) {
|
||||
if (ev == nullptr || data == nullptr) {
|
||||
return ORBIS_VIDEO_OUT_ERROR_INVALID_ADDRESS;
|
||||
}
|
||||
|
@ -202,11 +202,11 @@ int PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, int64
|
|||
return ORBIS_VIDEO_OUT_ERROR_INVALID_EVENT;
|
||||
}
|
||||
|
||||
auto event_data = ev->data >> 0x10;
|
||||
const auto event_data = ev->data >> 16;
|
||||
if (ev->ident != static_cast<s32>(OrbisVideoOutInternalEventId::Flip) || ev->data == 0) {
|
||||
*data = event_data;
|
||||
} else {
|
||||
*data = event_data | 0xFFFF000000000000;
|
||||
*data = event_data | 0xffff000000000000;
|
||||
}
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
|
|
@ -127,8 +127,8 @@ s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutio
|
|||
s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index,
|
||||
const void* param);
|
||||
s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle);
|
||||
int PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev);
|
||||
int PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, int64_t* data);
|
||||
s32 PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev);
|
||||
s32 PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, s64* data);
|
||||
s32 PS4_SYSV_ABI sceVideoOutColorSettingsSetGamma(SceVideoOutColorSettings* settings, float gamma);
|
||||
s32 PS4_SYSV_ABI sceVideoOutAdjustColor(s32 handle, const SceVideoOutColorSettings* settings);
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ int main(int argc, char* argv[]) {
|
|||
// If no game directory is set and no command line argument, prompt for it
|
||||
if (Config::getGameInstallDirs().empty()) {
|
||||
std::cout << "Warning: No game folder set, please set it by calling shadps4"
|
||||
" with the --add-game-folder <folder_name> argument";
|
||||
" with the --add-game-folder <folder_name> argument\n";
|
||||
}
|
||||
|
||||
if (!has_game_argument) {
|
||||
|
|
Loading…
Add table
Reference in a new issue