Skip to content

Commit

Permalink
Shader decompiler: Add FLR/SLT/SLTI/SGE/SGEI
Browse files Browse the repository at this point in the history
  • Loading branch information
wheremyfoodat committed Jul 28, 2024
1 parent 6c738e8 commit d125180
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/PICA/pica_vert_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ namespace PICA {
outputCount = regs[PICA::InternalRegs::ShaderOutputCount] & 7;
outputMask = regs[PICA::InternalRegs::VertexShaderOutputMask];
for (int i = 0; i < outputCount; i++) {
outmaps[i] = regs[PICA::InternalRegs::ShaderOutmap0 + i];
// Mask out unused bits
outmaps[i] = regs[PICA::InternalRegs::ShaderOutmap0 + i] & 0x1F1F1F1F;
}
}
};
Expand Down
7 changes: 7 additions & 0 deletions src/core/PICA/shader_decompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,16 @@ void ShaderDecompiler::compileInstruction(u32& pc, bool& finished) {

case ShaderOpcodes::DP3: setDest(operandDescriptor, dest, fmt::format("vec4(dot({}.xyz, {}.xyz))", src1, src2)); break;
case ShaderOpcodes::DP4: setDest(operandDescriptor, dest, fmt::format("vec4(dot({}, {}))", src1, src2)); break;
case ShaderOpcodes::FLR: setDest(operandDescriptor, dest, fmt::format("floor({})", src1)); break;
case ShaderOpcodes::RSQ: setDest(operandDescriptor, dest, fmt::format("vec4(inversesqrt({}.x))", src1)); break;
case ShaderOpcodes::RCP: setDest(operandDescriptor, dest, fmt::format("vec4(1.0 / {}.x)", src1)); break;

case ShaderOpcodes::SLT:
case ShaderOpcodes::SLTI: setDest(operandDescriptor, dest, fmt::format("vec4(lessThan({}, {}))", src1, src2)); break;

case ShaderOpcodes::SGE:
case ShaderOpcodes::SGEI: setDest(operandDescriptor, dest, fmt::format("vec4(greaterThanEqual({}, {}))", src1, src2)); break;

case ShaderOpcodes::CMP1:
case ShaderOpcodes::CMP2: {
static constexpr std::array<const char*, 8> operators = {
Expand Down
2 changes: 0 additions & 2 deletions src/core/renderer_gl/renderer_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,6 @@ bool RendererGL::prepareForDraw(ShaderUnit& shaderUnit, bool isImmediateMode) {
usingAcceleratedShader = emulatorConfig->accelerateShaders && !isImmediateMode && !usingUbershader;

if (usingAcceleratedShader) {
auto shaderCodeHash = shaderUnit.vs.getCodeHash();
auto opdescHash = shaderUnit.vs.getOpdescHash();
PICA::VertConfig vertexConfig(shaderUnit.vs, regs, usingUbershader);

std::optional<OpenGL::Shader>& shader = shaderCache.vertexShaderCache[vertexConfig];
Expand Down

0 comments on commit d125180

Please sign in to comment.