[PICA interpreter] Implement dp4, end

This commit is contained in:
wheremyfoodat 2022-09-23 15:49:56 +03:00
parent ce07b7e5e0
commit 75070ca6ef
3 changed files with 49 additions and 9 deletions

View file

@ -12,7 +12,9 @@ enum class ShaderType {
namespace ShaderOpcodes {
enum : u32 {
MOV = 0x13
DP4 = 0x02,
MOV = 0x13,
END = 0x22
};
}
@ -31,11 +33,13 @@ class PICAShader {
std::array<vec4f, 16> tempRegisters;
ShaderType type;
// Shader opcodes
void mov(u32 instruction);
vec4f getSource(u32 source);
vec4f& getDest(u32 dest);
// Shader opcodes
void dp4(u32 instruction);
void mov(u32 instruction);
// src1, src2 and src3 have different negation & component swizzle bits in the operand descriptor
// https://problemkaputt.github.io/gbatek.htm#3dsgpushaderinstructionsetopcodesummary in the
// "Shader Operand Descriptors" section
@ -75,6 +79,14 @@ class PICAShader {
return ret;
}
template <int sourceIndex>
vec4f getSourceSwizzled(u32 source, u32 opDescriptor) {
vec4f srcVector = getSource(source);
srcVector = swizzle<sourceIndex>(srcVector, opDescriptor);
return srcVector;
}
public:
std::array<u32, 512> loadedShader; // Currently loaded & active shader
std::array<u32, 512> bufferedShader; // Shader to be transferred when the SH_CODETRANSFER_END reg gets written to