From d5eea4b58c5739d594a3703e560c14fdc5f02996 Mon Sep 17 00:00:00 2001 From: wheremyfoodat Date: Thu, 8 Jun 2023 22:44:57 +0300 Subject: [PATCH] [ShaderJIT] Add const qualifier to JIT callbacks --- .../PICA/dynapica/shader_rec_emitter_x64.hpp | 4 ++-- .../PICA/dynapica/shader_rec_emitter_x64.cpp | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/PICA/dynapica/shader_rec_emitter_x64.hpp b/include/PICA/dynapica/shader_rec_emitter_x64.hpp index 5b73e63b..16b7bc89 100644 --- a/include/PICA/dynapica/shader_rec_emitter_x64.hpp +++ b/include/PICA/dynapica/shader_rec_emitter_x64.hpp @@ -35,9 +35,9 @@ class ShaderEmitter : public Xbyak::CodeGenerator { void scanForCalls(const PICAShader& shader); public: - using InstructionCallback = void(*)(PICAShader& shaderUnit); // Callback type used for instructions + 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 - using PrologueCallback = void(*)(PICAShader& shaderUnit, InstructionCallback cb); + using PrologueCallback = const void(*)(PICAShader& shaderUnit, InstructionCallback cb); PrologueCallback prologueCb; // Initialize our emitter with "allocSize" bytes of RWX memory diff --git a/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp b/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp index 6179df0b..0182a032 100644 --- a/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp +++ b/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp @@ -1,11 +1,17 @@ #if defined(PANDA3DS_DYNAPICA_SUPPORTED) && defined(PANDA3DS_X64_HOST) #include "PICA/dynapica/shader_rec_emitter_x64.hpp" +#include +#include + using namespace Xbyak; using namespace Xbyak::util; // Register that points to PICA state static constexpr Reg64 statePointer = rbp; +static constexpr Xmm scratch1 = xmm0; +static constexpr Xmm scratch2 = xmm1; +static constexpr Xmm scratch3 = xmm2; void ShaderEmitter::compile(const PICAShader& shaderUnit) { // Emit prologue first @@ -65,9 +71,27 @@ void ShaderEmitter::compileInstruction(const PICAShader& shaderUnit) { const u32 opcode = instruction >> 26; switch (opcode) { + case ShaderOpcodes::MOV: recMOV(shaderUnit, instruction); break; default: Helpers::panic("ShaderJIT: Unimplemented PICA opcode %X", opcode); } } +void ShaderEmitter::loadRegister(Xmm dest, const PICAShader& shader, u32 srcReg, u32 index) { + +} + +void ShaderEmitter::recMOV(const PICAShader& shader, u32 instruction) { + const u32 operandDescriptor = shader.operandDescriptors[instruction & 0x7f]; + u32 src = (instruction >> 12) & 0x7f; + const u32 idx = (instruction >> 19) & 3; + const u32 dest = (instruction >> 21) & 0x1f; + + src = getIndexedSource(src, idx); + vec4f srcVector = getSourceSwizzled<1>(src, operandDescriptor); + vec4f& destVector = getDest(dest); + + u32 componentMask = operandDescriptor & 0xf; +} + #endif \ No newline at end of file