[Shader JIT] Attempt to add CALLC/JMPC/JMPU/LOOP

This commit is contained in:
wheremyfoodat 2023-06-11 23:43:47 +03:00
parent 71fd8de92f
commit 137b652840
3 changed files with 107 additions and 3 deletions

View file

@ -3,6 +3,7 @@
// Only do anything if we're on an x64 target with JIT support enabled
#if defined(PANDA3DS_DYNAPICA_SUPPORTED) && defined(PANDA3DS_X64_HOST)
#include "helpers.hpp"
#include "logger.hpp"
#include "PICA/shader.hpp"
#include "xbyak/xbyak.h"
#include "xbyak/xbyak_util.h"
@ -31,6 +32,8 @@ class ShaderEmitter : public Xbyak::CodeGenerator {
Label negateVector;
u32 recompilerPC = 0; // PC the recompiler is currently recompiling @
u32 loopLevel = 0; // The current loop nesting level (0 = not in a loop)
bool haveSSE4_1 = false; // Shows if the CPU supports SSE4.1
bool haveAVX = false; // Shows if the CPU supports AVX (NOT AVX2, NOT AVX512. Regular AVX)
@ -39,6 +42,9 @@ class ShaderEmitter : public Xbyak::CodeGenerator {
// Compile instruction "instr"
void compileInstruction(const PICAShader& shaderUnit);
// Get the offset to be added to the rsp register to get the current return address
size_t getStackOffsetOfReturnPC();
bool isCall(u32 instruction) {
const u32 opcode = instruction >> 26;
return (opcode == ShaderOpcodes::CALL) || (opcode == ShaderOpcodes::CALLC) || (opcode == ShaderOpcodes::CALLU);
@ -91,6 +97,8 @@ class ShaderEmitter : public Xbyak::CodeGenerator {
void recSLT(const PICAShader& shader, u32 instruction);
void recSLTI(const PICAShader& shader, u32 instruction);
MAKE_LOG_FUNCTION(log, shaderJITLogger)
public:
using InstructionCallback = const void(*)(PICAShader& shaderUnit); // Callback type used for instructions
// Callback type used for the JIT prologue. This is what the caller will call