diff --git a/include/PICA/dynapica/shader_rec_emitter_arm64.hpp b/include/PICA/dynapica/shader_rec_emitter_arm64.hpp index 67678c90..b73401f3 100644 --- a/include/PICA/dynapica/shader_rec_emitter_arm64.hpp +++ b/include/PICA/dynapica/shader_rec_emitter_arm64.hpp @@ -118,9 +118,7 @@ class ShaderEmitter : private oaknut::CodeBlock, public oaknut::CodeGenerator { // PC must be a valid entrypoint here. It doesn't have that much overhead in this case, so we use std::array<>::at() to assert it does InstructionCallback getInstructionCallback(u32 pc) { - // Cast away the constness because casting to a function pointer is hard otherwise. Legal as long as we don't write to *ptr - uint8_t* ptr = instructionLabels.at(pc).xptr(); - return reinterpret_cast(ptr); + return reinterpret_cast(oaknut::CodeBlock::ptr() + instructionLabels.at(pc).offset()); } PrologueCallback getPrologueCallback() { return prologueCb; } diff --git a/src/core/PICA/dynapica/shader_rec_emitter_arm64.cpp b/src/core/PICA/dynapica/shader_rec_emitter_arm64.cpp index bbda0948..dce66270 100644 --- a/src/core/PICA/dynapica/shader_rec_emitter_arm64.cpp +++ b/src/core/PICA/dynapica/shader_rec_emitter_arm64.cpp @@ -39,7 +39,7 @@ void ShaderEmitter::compile(const PICAShader& shaderUnit) { align(16); l(prologueLabel); - prologueCb = prologueLabel.xptr(); + prologueCb = prreinterpret_cast(oaknut::CodeBlock::ptr() + prologueLabel.offset()); // Set state pointer to the proper pointer // state pointer is volatile, no need to preserve it @@ -407,8 +407,9 @@ void ShaderEmitter::storeRegister(QReg source, const PICAShader& shader, u32 des if (writeMask == 0xf) { // No lanes are masked, just use STR STR(source, statePointer, offset); } else { - LDR(scratch1, statePointer, offset); // Load current value - LDR(scratch2, blendMasks.xptr() + writeMask * 16); // Load write mask for blending + blendMaskPointer = reinterpret_cast(oaknut::CodeBlock::ptr() + blendMasks.offset()); + LDR(scratch1, statePointer, offset); // Load current value + LDR(scratch2, blendMaskPointer + writeMask * 16); // Load write mask for blending BSL(scratch2.B16(), source.B16(), scratch1.B16()); // Scratch2 = (Source & mask) | (original & ~mask) STR(scratch2, statePointer, offset); // Write it back