mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
Use ReadBlockUnsafe for Shader Cache
This commit is contained in:
parent
ef381e6924
commit
6fc562a9aa
1 changed files with 7 additions and 5 deletions
|
@ -38,13 +38,14 @@ GPUVAddr GetShaderAddress(Maxwell::ShaderProgram program) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the shader program code from memory for the specified address
|
/// Gets the shader program code from memory for the specified address
|
||||||
ProgramCode GetShaderCode(const u8* host_ptr) {
|
ProgramCode GetShaderCode(const GPUVAddr gpu_addr, const u8* host_ptr) {
|
||||||
|
auto& memory_manager{Core::System::GetInstance().GPU().MemoryManager()};
|
||||||
ProgramCode program_code(VideoCommon::Shader::MAX_PROGRAM_LENGTH);
|
ProgramCode program_code(VideoCommon::Shader::MAX_PROGRAM_LENGTH);
|
||||||
ASSERT_OR_EXECUTE(host_ptr != nullptr, {
|
ASSERT_OR_EXECUTE(host_ptr != nullptr, {
|
||||||
std::fill(program_code.begin(), program_code.end(), 0);
|
std::fill(program_code.begin(), program_code.end(), 0);
|
||||||
return program_code;
|
return program_code;
|
||||||
});
|
});
|
||||||
std::memcpy(program_code.data(), host_ptr, program_code.size() * sizeof(u64));
|
memory_manager.ReadBlockUnsafe(gpu_addr, program_code.data(), program_code.size() * sizeof(u64));
|
||||||
return program_code;
|
return program_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,11 +498,12 @@ Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
|
||||||
|
|
||||||
if (!shader) {
|
if (!shader) {
|
||||||
// No shader found - create a new one
|
// No shader found - create a new one
|
||||||
ProgramCode program_code{GetShaderCode(host_ptr)};
|
ProgramCode program_code{GetShaderCode(program_addr, host_ptr)};
|
||||||
ProgramCode program_code_b;
|
ProgramCode program_code_b;
|
||||||
if (program == Maxwell::ShaderProgram::VertexA) {
|
if (program == Maxwell::ShaderProgram::VertexA) {
|
||||||
program_code_b = GetShaderCode(
|
const GPUVAddr program_addr_b{GetShaderAddress(Maxwell::ShaderProgram::VertexB)};
|
||||||
memory_manager.GetPointer(GetShaderAddress(Maxwell::ShaderProgram::VertexB)));
|
program_code_b =
|
||||||
|
GetShaderCode(program_addr_b, memory_manager.GetPointer(program_addr_b));
|
||||||
}
|
}
|
||||||
const u64 unique_identifier = GetUniqueIdentifier(program, program_code, program_code_b);
|
const u64 unique_identifier = GetUniqueIdentifier(program, program_code, program_code_b);
|
||||||
const VAddr cpu_addr{*memory_manager.GpuToCpuAddress(program_addr)};
|
const VAddr cpu_addr{*memory_manager.GpuToCpuAddress(program_addr)};
|
||||||
|
|
Loading…
Reference in a new issue