mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-17 19:21:30 +12:00
[PICA] Implement mul
This commit is contained in:
parent
f22d389591
commit
61212c9341
2 changed files with 24 additions and 0 deletions
|
@ -14,6 +14,7 @@ namespace ShaderOpcodes {
|
||||||
enum : u32 {
|
enum : u32 {
|
||||||
ADD = 0x00,
|
ADD = 0x00,
|
||||||
DP4 = 0x02,
|
DP4 = 0x02,
|
||||||
|
MUL = 0x08,
|
||||||
MOV = 0x13,
|
MOV = 0x13,
|
||||||
END = 0x22
|
END = 0x22
|
||||||
};
|
};
|
||||||
|
@ -41,6 +42,7 @@ class PICAShader {
|
||||||
void add(u32 instruction);
|
void add(u32 instruction);
|
||||||
void dp4(u32 instruction);
|
void dp4(u32 instruction);
|
||||||
void mov(u32 instruction);
|
void mov(u32 instruction);
|
||||||
|
void mul(u32 instruction);
|
||||||
|
|
||||||
// src1, src2 and src3 have different negation & component swizzle bits in the operand descriptor
|
// src1, src2 and src3 have different negation & component swizzle bits in the operand descriptor
|
||||||
// https://problemkaputt.github.io/gbatek.htm#3dsgpushaderinstructionsetopcodesummary in the
|
// https://problemkaputt.github.io/gbatek.htm#3dsgpushaderinstructionsetopcodesummary in the
|
||||||
|
|
|
@ -12,6 +12,7 @@ void PICAShader::run() {
|
||||||
case ShaderOpcodes::DP4: dp4(instruction); break;
|
case ShaderOpcodes::DP4: dp4(instruction); break;
|
||||||
case ShaderOpcodes::END: return; // Stop running shader
|
case ShaderOpcodes::END: return; // Stop running shader
|
||||||
case ShaderOpcodes::MOV: mov(instruction); break;
|
case ShaderOpcodes::MOV: mov(instruction); break;
|
||||||
|
case ShaderOpcodes::MUL: mul(instruction); break;
|
||||||
default:Helpers::panic("Unimplemented PICA instruction %08X (Opcode = %02X)", instruction, opcode);
|
default:Helpers::panic("Unimplemented PICA instruction %08X (Opcode = %02X)", instruction, opcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +59,27 @@ void PICAShader::add(u32 instruction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PICAShader::mul(u32 instruction) {
|
||||||
|
const u32 operandDescriptor = operandDescriptors[instruction & 0x7f];
|
||||||
|
const u32 src1 = (instruction >> 12) & 0x7f;
|
||||||
|
const u32 src2 = (instruction >> 7) & 0x1f; // src2 coming first because PICA moment
|
||||||
|
const u32 idx = (instruction >> 19) & 3;
|
||||||
|
const u32 dest = (instruction >> 21) & 0x1f;
|
||||||
|
|
||||||
|
if (idx) Helpers::panic("[PICA] MUL: idx != 0");
|
||||||
|
vec4f srcVec1 = getSourceSwizzled<1>(src1, operandDescriptor);
|
||||||
|
vec4f srcVec2 = getSourceSwizzled<2>(src2, operandDescriptor);
|
||||||
|
|
||||||
|
vec4f& destVector = getDest(dest);
|
||||||
|
|
||||||
|
u32 componentMask = operandDescriptor & 0xf;
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
if (componentMask & (1 << i)) {
|
||||||
|
destVector[3 - i] = srcVec1[3 - i] * srcVec2[3 - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PICAShader::mov(u32 instruction) {
|
void PICAShader::mov(u32 instruction) {
|
||||||
const u32 operandDescriptor = operandDescriptors[instruction & 0x7f];
|
const u32 operandDescriptor = operandDescriptors[instruction & 0x7f];
|
||||||
const u32 src = (instruction >> 12) & 0x7f;
|
const u32 src = (instruction >> 12) & 0x7f;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue