mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-21 11:26:56 +02:00
remove readback hacks, allows to read/write guest memory directly
This commit is contained in:
+6
-23
@@ -11,7 +11,6 @@
|
||||
#include "graphics/guest_gpu/pm4.h"
|
||||
#include "graphics/guest_gpu/gpu_defs.h"
|
||||
#include "graphics/guest_gpu/tile.h"
|
||||
#include "graphics/host_gpu/hostMemory.h"
|
||||
#include "graphics/host_gpu/objects/label.h"
|
||||
#include "graphics/host_gpu/renderer/render.h"
|
||||
#include "graphics/presentation/renderDoc.h"
|
||||
@@ -373,11 +372,6 @@ struct Label {
|
||||
uint64_t m_reserved[3];
|
||||
};
|
||||
|
||||
static bool is_readable_command_packet_range(const uint32_t* cmd, uint32_t num_dw) {
|
||||
return HostMemoryRangeIsReadable(reinterpret_cast<uintptr_t>(cmd),
|
||||
static_cast<uint64_t>(num_dw) * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI GraphicsInit(uint32_t* state, uint32_t ver) {
|
||||
PRINT_NAME();
|
||||
|
||||
@@ -3750,8 +3744,7 @@ static void flush_pending_graphics_segment_before_acb(const uint32_t* acb,
|
||||
if (!wait_addresses.empty() && Gen5::g_pending_graphics_segment.start != nullptr) {
|
||||
auto* scan = Gen5::g_pending_graphics_segment.start;
|
||||
auto* matched_end = Gen5::g_pending_graphics_segment.start;
|
||||
while (scan < Gen5::g_pending_graphics_segment.end &&
|
||||
Gen5::is_readable_command_packet_range(scan, 1)) {
|
||||
while (scan < Gen5::g_pending_graphics_segment.end) {
|
||||
auto cmd_id = *scan;
|
||||
if (cmd_id == 0x80000000u) {
|
||||
scan++;
|
||||
@@ -3763,8 +3756,7 @@ static void flush_pending_graphics_segment_before_acb(const uint32_t* acb,
|
||||
|
||||
auto len = KYTY_PM4_LEN(cmd_id);
|
||||
if (len == 0 ||
|
||||
len > static_cast<uint32_t>(Gen5::g_pending_graphics_segment.end - scan) ||
|
||||
!Gen5::is_readable_command_packet_range(scan, len)) {
|
||||
len > static_cast<uint32_t>(Gen5::g_pending_graphics_segment.end - scan)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3789,8 +3781,7 @@ static void flush_pending_graphics_segment_before_acb(const uint32_t* acb,
|
||||
Gen5::g_pending_graphics_segment.end > Gen5::g_pending_graphics_segment.start) {
|
||||
auto* scan = Gen5::g_pending_graphics_segment.start;
|
||||
auto* valid_end = Gen5::g_pending_graphics_segment.start;
|
||||
while (scan < Gen5::g_pending_graphics_segment.end &&
|
||||
Gen5::is_readable_command_packet_range(scan, 1)) {
|
||||
while (scan < Gen5::g_pending_graphics_segment.end) {
|
||||
auto cmd_id = *scan;
|
||||
if (cmd_id == 0x80000000u) {
|
||||
scan++;
|
||||
@@ -3803,8 +3794,7 @@ static void flush_pending_graphics_segment_before_acb(const uint32_t* acb,
|
||||
|
||||
auto len = KYTY_PM4_LEN(cmd_id);
|
||||
if (len == 0 ||
|
||||
len > static_cast<uint32_t>(Gen5::g_pending_graphics_segment.end - scan) ||
|
||||
!Gen5::is_readable_command_packet_range(scan, len)) {
|
||||
len > static_cast<uint32_t>(Gen5::g_pending_graphics_segment.end - scan)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3931,16 +3921,14 @@ int KYTY_SYSV_ABI GraphicsDriverSubmitMultiCommandBuffers(uint32_t queue, uint32
|
||||
}
|
||||
|
||||
static void submit_acb(uint32_t queue, uint32_t* acb, uint32_t size_in_dwords) {
|
||||
if (acb != nullptr && size_in_dwords >= 5 && Gen5::is_readable_command_packet_range(acb, 5)) {
|
||||
if (acb != nullptr && size_in_dwords >= 5) {
|
||||
auto descriptor_addr =
|
||||
static_cast<uint64_t>(acb[0]) | (static_cast<uint64_t>(acb[1]) << 32u);
|
||||
auto descriptor_size = acb[2];
|
||||
auto descriptor_flags = acb[3];
|
||||
auto descriptor_magic = acb[4];
|
||||
if (descriptor_addr != 0 && descriptor_size != 0 && descriptor_flags == 0 &&
|
||||
descriptor_magic == 0x5533ccaau &&
|
||||
Gen5::is_readable_command_packet_range(reinterpret_cast<uint32_t*>(descriptor_addr),
|
||||
descriptor_size)) {
|
||||
descriptor_magic == 0x5533ccaau) {
|
||||
LOGF("\t descriptor addr = 0x%016" PRIx64 "\n"
|
||||
"\t descriptor size = 0x%08" PRIx32 "\n"
|
||||
"\t descriptor magic = 0x%08" PRIx32 "\n",
|
||||
@@ -3976,11 +3964,6 @@ int KYTY_SYSV_ABI GraphicsDriverSubmitAcb(uint32_t queue, const Packet* packet)
|
||||
if (packet == nullptr) {
|
||||
return OK;
|
||||
}
|
||||
if (!Gen5::is_readable_command_packet_range(reinterpret_cast<const uint32_t*>(packet),
|
||||
sizeof(Packet) / sizeof(uint32_t))) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
LOGF("\t acb = 0x%016" PRIx64 "\n"
|
||||
"\t size = 0x%08" PRIx32 "\n"
|
||||
"\t flags = 0x%02" PRIx8 "\n",
|
||||
|
||||
Reference in New Issue
Block a user