shader_jit_x64: Specify shader main offset at runtime.

master
bunnei 2016-03-26 21:02:15 +07:00
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
if (VideoCore::g_shader_jit_enabled) {
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)) ^
g_state.regs.vs.main_offset);
Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data)));
auto iter = shader_map.find(cache_key);
if (iter != shader_map.end()) {
@ -98,7 +97,7 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr
#ifdef ARCHITECTURE_x86_64
if (VideoCore::g_shader_jit_enabled)
jit_shader->Run(&state.registers);
jit_shader->Run(&state.registers, g_state.regs.vs.main_offset);
else
RunInterpreter(state);
#else

@ -838,9 +838,7 @@ void JitCompiler::Compile() {
fixup_branches.clear();
// Jump to start of the shader program
if (g_state.regs.vs.main_offset != 0) {
fixup_branches.push_back({ J(true), g_state.regs.vs.main_offset });
}
JMPptr(R(ABI_PARAM2));
// Compile entire program
Compile_Block(static_cast<unsigned>(g_state.vs.program_code.size()));

@ -25,8 +25,6 @@ namespace Shader {
/// Memory allocated for each compiled shader (64Kb)
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
* code that can be executed on the host machine directly.
@ -35,8 +33,8 @@ class JitCompiler : public Gen::XCodeBlock {
public:
JitCompiler();
void Run(void* registers) const {
program(registers);
void Run(void* registers, unsigned offset) const {
program(registers, code_ptr[offset]);
}
void Compile();
@ -111,6 +109,7 @@ private:
/// Branches that need to be fixed up once the entire shader program is compiled
std::vector<std::pair<Gen::FixupBranch, unsigned>> fixup_branches;
using CompiledShader = void(void* registers, const u8* start_addr);
CompiledShader* program = nullptr;
};