VideoOut event cleanup (#2849)

* Readable VideoOutEvent data packing

Inspired by the work of former shadPS4 devs and mostly based on red_prig's current code.

* Apply DceData struct to sceVideoOutGetEventCount

Makes the code easier to read

* Update equeue.h

* Update main.cpp

* Update equeue.h

* Proper struct names

* Fix hint mask

Thanks to red_prig for catching my mistake here.

* Clang

* Fix header discrepancy
This commit is contained in:
Stephen Miller 2025-04-27 01:04:17 -05:00 committed by GitHub
parent e816bc4b99
commit c09fff2da6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 16 deletions

View file

@ -61,6 +61,18 @@ struct SceKernelEvent {
void* udata = nullptr; /* opaque user data identifier */
};
struct OrbisVideoOutEventHint {
u64 event_id : 8;
u64 video_id : 8;
u64 flip_arg : 48;
};
struct OrbisVideoOutEventData {
u64 time : 12;
u64 count : 4;
u64 flip_arg : 48;
};
struct EqueueEvent {
SceKernelEvent event;
void* data = nullptr;
@ -84,19 +96,18 @@ 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) {
if (data != nullptr) {
auto event_data = static_cast<OrbisVideoOutEventData>(event.data);
auto event_hint_raw = reinterpret_cast<u64>(data);
auto event_hint = static_cast<OrbisVideoOutEventHint>(event_hint_raw);
if (event_hint.event_id == event.ident && event.ident != 0xfe) {
auto time = Common::FencedRDTSC();
auto mask = 0xF000;
if ((static_cast<u32>(event.data) & 0xF000) != 0xF000) {
mask = (static_cast<u32>(event.data) + 0x1000) & 0xF000;
auto counter = event_data.count;
if (counter != 0xf) {
counter++;
}
event.data = (mask | static_cast<u64>(static_cast<u32>(time) & 0xFFF) |
(hint & 0xFFFFFFFFFFFF0000));
event.data =
(time & 0xfff) | (counter << 0xc) | (event_hint_raw & 0xffffffffffff0000);
}
}
}