[PICA] Start implementing shader interpreter

This commit is contained in:
wheremyfoodat 2022-09-23 02:43:51 +03:00
parent 4b3c7955dd
commit 057aa57422
5 changed files with 32 additions and 6 deletions

View file

@ -71,7 +71,9 @@ void GPU::drawArrays() {
for (int attrCount = 0; attrCount < totalAttribCount; attrCount++) {
// Check if attribute is fixed or not
if (fixedAttribMask & (1 << attrCount)) { // Fixed attribute
vec4f& fixedAttr = shaderUnit.vs.fixedAttributes[attrCount]; // TODO: Is this how it works?
vec4f& inputAttr = shaderUnit.vs.attributes[attrCount];
std::memcpy(&inputAttr, &fixedAttr, sizeof(vec4f)); // Copy fixed attr to input attr
} else { // Non-fixed attribute
auto& attr = attributeInfo[attrCount]; // Get information for this attribute
u64 attrCfg = attr.getConfigFull(); // Get config1 | (config2 << 32)
@ -113,5 +115,7 @@ void GPU::drawArrays() {
printf("Attribute %d, type: %d, component count: %d\n", attrCount, attribType, componentCount);
}
}
shaderUnit.vs.run(); // Run vertex shader for vertex
}
}

View file

@ -0,0 +1,14 @@
#include "PICA/shader.hpp"
void PICAShader::run() {
u32 pc = 0; // Program counter
while (true) {
const u32 instruction = loadedShader[pc++];
const u32 opcode = instruction >> 26; // Top 6 bits are the opcode
switch (opcode) {
default:Helpers::panic("Unimplemented PICA instruction %08X (Opcode = %02X)", instruction, opcode);
}
}
}