mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-31 14:35:19 +00:00
Readable VideoOutEvent data packing
Inspired by the work of former shadPS4 devs and mostly based on red_prig's current code.
This commit is contained in:
parent
e816bc4b99
commit
f2cebf7284
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <bit>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/asio/steady_timer.hpp>
|
#include <boost/asio/steady_timer.hpp>
|
||||||
@ -61,6 +62,18 @@ struct SceKernelEvent {
|
|||||||
void* udata = nullptr; /* opaque user data identifier */
|
void* udata = nullptr; /* opaque user data identifier */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DceHint {
|
||||||
|
u64 event_id : 8;
|
||||||
|
u64 video_id : 8;
|
||||||
|
u64 flip_arg : 48;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DceData {
|
||||||
|
u64 time : 12;
|
||||||
|
u64 count : 4;
|
||||||
|
u64 flip_arg : 48;
|
||||||
|
};
|
||||||
|
|
||||||
struct EqueueEvent {
|
struct EqueueEvent {
|
||||||
SceKernelEvent event;
|
SceKernelEvent event;
|
||||||
void* data = nullptr;
|
void* data = nullptr;
|
||||||
@ -84,19 +97,17 @@ struct EqueueEvent {
|
|||||||
|
|
||||||
void TriggerDisplay(void* data) {
|
void TriggerDisplay(void* data) {
|
||||||
is_triggered = true;
|
is_triggered = true;
|
||||||
auto hint = reinterpret_cast<u64>(data);
|
if (data != nullptr) {
|
||||||
if (hint != 0) {
|
auto event_data = static_cast<DceData>(event.data);
|
||||||
auto hint_h = static_cast<u32>(hint >> 8) & 0xFFFFFF;
|
auto event_hint_raw = reinterpret_cast<u64>(data);
|
||||||
auto ident_h = static_cast<u32>(event.ident >> 40);
|
auto event_hint = static_cast<DceHint>(event_hint_raw);
|
||||||
if ((static_cast<u32>(hint) & 0xFF) == event.ident && event.ident != 0xFE &&
|
if (event_hint.event_id == event.ident && event.ident != 0xfe) {
|
||||||
((hint_h ^ ident_h) & 0xFF) == 0) {
|
|
||||||
auto time = Common::FencedRDTSC();
|
auto time = Common::FencedRDTSC();
|
||||||
auto mask = 0xF000;
|
auto counter = event_data.count;
|
||||||
if ((static_cast<u32>(event.data) & 0xF000) != 0xF000) {
|
if (counter != 0xf) {
|
||||||
mask = (static_cast<u32>(event.data) + 0x1000) & 0xF000;
|
counter++;
|
||||||
}
|
}
|
||||||
event.data = (mask | static_cast<u64>(static_cast<u32>(time) & 0xFFF) |
|
event.data = (time & 0xfff) | (counter << 12) | (event_hint_raw & 0xffffffffffff);
|
||||||
(hint & 0xFFFFFFFFFFFF0000));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user