mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 10:56:58 +02:00
remove readback hacks, allows to read/write guest memory directly
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include "graphics/shader/recompiler/SrtWalker.h"
|
||||
|
||||
#include "graphics/host_gpu/hostMemory.h"
|
||||
#include "graphics/shader/recompiler/ScalarProvenance.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace Libs::Graphics::ShaderRecompiler::IR {
|
||||
@@ -485,12 +485,14 @@ private:
|
||||
value.pc, base_aligned, relative));
|
||||
}
|
||||
}
|
||||
const auto read_memory =
|
||||
m_runtime.read_memory != nullptr ? m_runtime.read_memory : HostMemoryReadDword;
|
||||
if (!read_memory(m_runtime.userdata, address, result)) {
|
||||
if (m_runtime.read_memory != nullptr &&
|
||||
!m_runtime.read_memory(m_runtime.userdata, address, result)) {
|
||||
return Fail(
|
||||
error, fmt::format("ReadConst pc=0x{:08x} failed at 0x{:016x}", value.pc, address));
|
||||
}
|
||||
if (m_runtime.read_memory == nullptr) {
|
||||
std::memcpy(result, reinterpret_cast<const void*>(address), sizeof(*result));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "graphics/guest_gpu/graphicsRun.h"
|
||||
#include "graphics/guest_gpu/hardwareContext.h"
|
||||
#include "graphics/guest_gpu/gpu_defs.h"
|
||||
#include "graphics/host_gpu/hostMemory.h"
|
||||
#include "graphics/shader/recompiler/ShaderDecoder.h"
|
||||
#include "graphics/shader/recompiler/ShaderRecompiler.h"
|
||||
#include "graphics/shader/shaderVertexMetadata.h"
|
||||
@@ -785,31 +784,6 @@ static bool ShaderGetStaticInputInfoVS(const HW::VertexShaderInfo* regs,
|
||||
shader_addr);
|
||||
return false;
|
||||
}
|
||||
uint32_t max_semantic = 0;
|
||||
for (uint32_t i = 0; i < metadata.input_semantics_count; i++) {
|
||||
max_semantic =
|
||||
std::max(max_semantic, static_cast<uint32_t>(metadata.input_semantics[i].semantic));
|
||||
}
|
||||
if (!HostMemoryRangeIsReadable(reinterpret_cast<uint64_t>(attrib),
|
||||
static_cast<uint64_t>(max_semantic + 1) *
|
||||
sizeof(uint32_t))) {
|
||||
LOGF("ShaderGetInputInfoVS(): unreadable vertex attribute table shader=0x%016" PRIx64
|
||||
"\n",
|
||||
shader_addr);
|
||||
return false;
|
||||
}
|
||||
uint32_t max_buffer = 0;
|
||||
for (uint32_t i = 0; i < metadata.input_semantics_count; i++) {
|
||||
max_buffer = std::max(max_buffer, attrib[metadata.input_semantics[i].semantic] & 0x1fu);
|
||||
}
|
||||
if (!HostMemoryRangeIsReadable(reinterpret_cast<uint64_t>(buffer),
|
||||
static_cast<uint64_t>(max_buffer + 1) * 4 *
|
||||
sizeof(uint32_t))) {
|
||||
LOGF("ShaderGetInputInfoVS(): unreadable vertex buffer table shader=0x%016" PRIx64 "\n",
|
||||
shader_addr);
|
||||
return false;
|
||||
}
|
||||
|
||||
ShaderApplyAttribSemantics(info, metadata.input_semantics.data(),
|
||||
metadata.input_semantics_count, attrib, buffer);
|
||||
ShaderDetectBuffers(info);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "graphics/shader/shaderVertexMetadata.h"
|
||||
|
||||
#include "graphics/host_gpu/hostMemory.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
|
||||
@@ -16,10 +14,6 @@ bool Fail(std::string* error, const char* message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Readable(const void* data, uint64_t size) {
|
||||
return data != nullptr && HostMemoryRangeIsReadable(reinterpret_cast<uint64_t>(data), size);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool ShaderReadVertexMetadata(const ShaderMappedData& data, uint32_t max_user_sgprs,
|
||||
@@ -27,8 +21,8 @@ bool ShaderReadVertexMetadata(const ShaderMappedData& data, uint32_t max_user_sg
|
||||
if (metadata == nullptr) {
|
||||
return Fail(error, "missing vertex metadata output");
|
||||
}
|
||||
if (!Readable(data.user_data, sizeof(ShaderUserData))) {
|
||||
return Fail(error, "unreadable AGC user-data header");
|
||||
if (data.user_data == nullptr) {
|
||||
return Fail(error, "missing AGC user-data header");
|
||||
}
|
||||
|
||||
ShaderUserData user_data {};
|
||||
@@ -44,8 +38,8 @@ bool ShaderReadVertexMetadata(const ShaderMappedData& data, uint32_t max_user_sg
|
||||
const auto direct_size =
|
||||
static_cast<uint64_t>(user_data.direct_resource_count) * sizeof(uint16_t);
|
||||
if (direct_size != 0) {
|
||||
if (!Readable(user_data.direct_resource_offset, direct_size)) {
|
||||
return Fail(error, "unreadable AGC direct-resource offsets");
|
||||
if (user_data.direct_resource_offset == nullptr) {
|
||||
return Fail(error, "missing AGC direct-resource offsets");
|
||||
}
|
||||
std::memcpy(direct_offsets.data(), user_data.direct_resource_offset, direct_size);
|
||||
}
|
||||
@@ -84,8 +78,8 @@ bool ShaderReadVertexMetadata(const ShaderMappedData& data, uint32_t max_user_sg
|
||||
|
||||
const auto semantic_size =
|
||||
static_cast<uint64_t>(data.num_input_semantics) * sizeof(ShaderSemantic);
|
||||
if (!Readable(data.input_semantics, semantic_size)) {
|
||||
return Fail(error, "unreadable vertex input semantics");
|
||||
if (data.input_semantics == nullptr) {
|
||||
return Fail(error, "missing vertex input semantics");
|
||||
}
|
||||
std::memcpy(next.input_semantics.data(), data.input_semantics, semantic_size);
|
||||
next.input_semantics_count = data.num_input_semantics;
|
||||
|
||||
Reference in New Issue
Block a user