More shader->GLSL recompiler work

This commit is contained in:
wheremyfoodat 2024-07-24 02:00:45 +03:00
parent c319e59545
commit be75fa43a3
3 changed files with 176 additions and 6 deletions

View file

@ -58,6 +58,10 @@ namespace ShaderOpcodes {
};
}
namespace PICA::ShaderGen {
class ShaderDecompiler;
};
// Note: All PICA f24 vec4 registers must have the alignas(16) specifier to make them easier to access in SSE/NEON code in the JIT
class PICAShader {
using f24 = Floats::f24;
@ -135,6 +139,7 @@ class PICAShader {
// Add these as friend classes for the JIT so it has access to all important state
friend class ShaderJIT;
friend class ShaderEmitter;
friend class PICA::ShaderGen::ShaderDecompiler;
vec4f getSource(u32 source);
vec4f& getDest(u32 dest);

View file

@ -101,6 +101,16 @@ namespace PICA::ShaderGen {
void writeAttributes();
std::string getSource(u32 source, u32 index) const;
std::string getDest(u32 dest) const;
std::string getSwizzlePattern(u32 swizzle) const;
std::string getDestSwizzle(u32 destinationMask) const;
void setDest(u32 operandDescriptor, const std::string& dest, const std::string& value);
// Returns if the instruction uses the typical register encodings most instructions use
// With some exceptions like MAD/MADI, and the control flow instructions which are completely different
bool usesCommonEncoding(u32 instruction) const;
public:
ShaderDecompiler(PICAShader& shader, EmulatorConfig& config, u32 entrypoint, API api, Language language)
: shader(shader), entrypoint(entrypoint), config(config), api(api), language(language), decompiledShader("") {}