mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 19:00:14 -05:00
shader_jit_x64: Specify shader main offset at runtime.
This commit is contained in:
parent
c9d10de644
commit
a5a74eb121
3 changed files with 6 additions and 10 deletions
|
@ -36,8 +36,7 @@ void Setup(UnitState<false>& state) {
|
||||||
#ifdef ARCHITECTURE_x86_64
|
#ifdef ARCHITECTURE_x86_64
|
||||||
if (VideoCore::g_shader_jit_enabled) {
|
if (VideoCore::g_shader_jit_enabled) {
|
||||||
u64 cache_key = (Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^
|
u64 cache_key = (Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^
|
||||||
Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data)) ^
|
Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data)));
|
||||||
g_state.regs.vs.main_offset);
|
|
||||||
|
|
||||||
auto iter = shader_map.find(cache_key);
|
auto iter = shader_map.find(cache_key);
|
||||||
if (iter != shader_map.end()) {
|
if (iter != shader_map.end()) {
|
||||||
|
@ -98,7 +97,7 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr
|
||||||
|
|
||||||
#ifdef ARCHITECTURE_x86_64
|
#ifdef ARCHITECTURE_x86_64
|
||||||
if (VideoCore::g_shader_jit_enabled)
|
if (VideoCore::g_shader_jit_enabled)
|
||||||
jit_shader->Run(&state.registers);
|
jit_shader->Run(&state.registers, g_state.regs.vs.main_offset);
|
||||||
else
|
else
|
||||||
RunInterpreter(state);
|
RunInterpreter(state);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -838,9 +838,7 @@ void JitCompiler::Compile() {
|
||||||
fixup_branches.clear();
|
fixup_branches.clear();
|
||||||
|
|
||||||
// Jump to start of the shader program
|
// Jump to start of the shader program
|
||||||
if (g_state.regs.vs.main_offset != 0) {
|
JMPptr(R(ABI_PARAM2));
|
||||||
fixup_branches.push_back({ J(true), g_state.regs.vs.main_offset });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compile entire program
|
// Compile entire program
|
||||||
Compile_Block(static_cast<unsigned>(g_state.vs.program_code.size()));
|
Compile_Block(static_cast<unsigned>(g_state.vs.program_code.size()));
|
||||||
|
|
|
@ -25,8 +25,6 @@ namespace Shader {
|
||||||
/// Memory allocated for each compiled shader (64Kb)
|
/// Memory allocated for each compiled shader (64Kb)
|
||||||
constexpr size_t MAX_SHADER_SIZE = 1024 * 64;
|
constexpr size_t MAX_SHADER_SIZE = 1024 * 64;
|
||||||
|
|
||||||
using CompiledShader = void(void* registers);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64
|
* This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64
|
||||||
* code that can be executed on the host machine directly.
|
* code that can be executed on the host machine directly.
|
||||||
|
@ -35,8 +33,8 @@ class JitCompiler : public Gen::XCodeBlock {
|
||||||
public:
|
public:
|
||||||
JitCompiler();
|
JitCompiler();
|
||||||
|
|
||||||
void Run(void* registers) const {
|
void Run(void* registers, unsigned offset) const {
|
||||||
program(registers);
|
program(registers, code_ptr[offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Compile();
|
void Compile();
|
||||||
|
@ -111,6 +109,7 @@ private:
|
||||||
/// Branches that need to be fixed up once the entire shader program is compiled
|
/// Branches that need to be fixed up once the entire shader program is compiled
|
||||||
std::vector<std::pair<Gen::FixupBranch, unsigned>> fixup_branches;
|
std::vector<std::pair<Gen::FixupBranch, unsigned>> fixup_branches;
|
||||||
|
|
||||||
|
using CompiledShader = void(void* registers, const u8* start_addr);
|
||||||
CompiledShader* program = nullptr;
|
CompiledShader* program = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue