PICA decompiler: Cache VS uniforms

This commit is contained in:
wheremyfoodat 2024-07-29 01:27:13 +03:00
parent 7209740418
commit 0d6bef2d70
4 changed files with 18 additions and 2 deletions

View file

@ -133,6 +133,10 @@ class PICAShader {
Hash lastCodeHash = 0; // Last hash computed for the shader code (Used for the JIT caching mechanism)
Hash lastOpdescHash = 0; // Last hash computed for the operand descriptors (Also used for the JIT)
public:
bool uniformsDirty = false;
protected:
bool codeHashDirty = false;
bool opdescHashDirty = false;
@ -283,6 +287,7 @@ class PICAShader {
uniform[2] = f24::fromRaw(((floatUniformBuffer[0] & 0xff) << 16) | (floatUniformBuffer[1] >> 16));
uniform[3] = f24::fromRaw(floatUniformBuffer[0] >> 8);
}
uniformsDirty = true;
}
}
@ -294,6 +299,12 @@ class PICAShader {
u[1] = getBits<8, 8>(word);
u[2] = getBits<16, 8>(word);
u[3] = getBits<24, 8>(word);
uniformsDirty = true;
}
void uploadBoolUniform(u32 value) {
boolUniform = value;
uniformsDirty = true;
}
void run();

View file

@ -301,7 +301,7 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
}
case VertexBoolUniform: {
shaderUnit.vs.boolUniform = value & 0xffff;
shaderUnit.vs.uploadBoolUniform(value & 0xffff);
break;
}

View file

@ -34,4 +34,5 @@ void PICAShader::reset() {
codeHashDirty = true;
opdescHashDirty = true;
uniformsDirty = true;
}

View file

@ -987,7 +987,11 @@ bool RendererGL::prepareForDraw(ShaderUnit& shaderUnit, bool isImmediateMode) {
} else {
generatedVertexShader = &(*shader);
gl.bindUBO(hwShaderUniformUBO);
glBufferSubData(GL_UNIFORM_BUFFER, 0, PICAShader::totalUniformSize(), shaderUnit.vs.getUniformPointer());
if (shaderUnit.vs.uniformsDirty) {
shaderUnit.vs.uniformsDirty = false;
glBufferSubData(GL_UNIFORM_BUFFER, 0, PICAShader::totalUniformSize(), shaderUnit.vs.getUniformPointer());
}
}
}