Cleanup for #98

This commit is contained in:
wheremyfoodat 2023-07-15 04:56:43 +03:00
parent 2f45714240
commit 7b6cd90d36
10 changed files with 95 additions and 33 deletions

View file

@ -49,6 +49,7 @@ class ShaderEmitter : public Xbyak::CodeGenerator {
const u32 opcode = instruction >> 26;
return (opcode == ShaderOpcodes::CALL) || (opcode == ShaderOpcodes::CALLC) || (opcode == ShaderOpcodes::CALLU);
}
// Scan the shader code for call instructions to fill up the returnPCs vector before starting compilation
void scanForCalls(const PICAShader& shaderUnit);
@ -106,9 +107,11 @@ class ShaderEmitter : public Xbyak::CodeGenerator {
MAKE_LOG_FUNCTION(log, shaderJITLogger)
public:
using InstructionCallback = const void (*)(PICAShader& shaderUnit); // Callback type used for instructions
// Callback type used for instructions
using InstructionCallback = const void (*)(PICAShader& shaderUnit);
// Callback type used for the JIT prologue. This is what the caller will call
using PrologueCallback = const void (*)(PICAShader& shaderUnit, InstructionCallback cb);
PrologueCallback prologueCb = nullptr;
// Initialize our emitter with "allocSize" bytes of RWX memory

View file

@ -103,7 +103,9 @@ class GPU {
// TODO: Emulate the transfer engine & its registers
// Then this can be emulated by just writing the appropriate values there
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) { renderer->clearBuffer(startAddress, endAddress, value, control); }
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {
renderer->clearBuffer(startAddress, endAddress, value, control);
}
// TODO: Emulate the transfer engine & its registers
// Then this can be emulated by just writing the appropriate values there

View file

@ -7,7 +7,10 @@
#include "PICA/pica_hash.hpp"
#include "helpers.hpp"
enum class ShaderType { Vertex, Geometry };
enum class ShaderType {
Vertex,
Geometry,
};
namespace ShaderOpcodes {
enum : u32 {
@ -221,11 +224,13 @@ class PICAShader {
void finalize() { std::memcpy(&loadedShader[0], &bufferedShader[0], 4096 * sizeof(u32)); }
void setBufferIndex(u32 index) { bufferIndex = index & 0xfff; }
void setOpDescriptorIndex(u32 index) { opDescriptorIndex = index & 0x7f; }
void uploadWord(u32 word) {
if (bufferIndex >= 4095) Helpers::panic("o no, shader upload overflew");
if (bufferIndex >= 4095) {
Helpers::panic("o no, shader upload overflew");
}
bufferedShader[bufferIndex++] = word;
bufferIndex &= 0xfff;
@ -247,7 +252,9 @@ class PICAShader {
void uploadFloatUniform(u32 word) {
floatUniformBuffer[floatUniformWordCount++] = word;
if (floatUniformIndex >= 96) Helpers::panic("[PICA] Tried to write float uniform %d", floatUniformIndex);
if (floatUniformIndex >= 96) {
Helpers::panic("[PICA] Tried to write float uniform %d", floatUniformIndex);
}
if ((f32UniformTransfer && floatUniformWordCount >= 4) || (!f32UniformTransfer && floatUniformWordCount >= 3)) {
vec4f& uniform = floatUniforms[floatUniformIndex++];