[PICA] Implement drawArrays, get our first triangle data

This commit is contained in:
wheremyfoodat 2022-09-22 04:03:55 +03:00
parent eb536ee147
commit 00d82ca6ed
4 changed files with 21 additions and 0 deletions

View file

@ -10,6 +10,8 @@ class GPU {
ShaderUnit shaderUnit;
std::array<u32, regNum> regs; // GPU internal registers
void drawArrays();
public:
GPU(Memory& mem) : mem(mem) {}
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control);

View file

@ -2,6 +2,12 @@
namespace PICAInternalRegs {
enum : u32 {
// Draw command regs
VertexCountReg = 0x228,
VertexOffsetReg = 0x22A,
SignalDrawArrays = 0x22E,
// Vertex shader registers
VertexShaderTransferEnd = 0x2BF,
VertexShaderTransferIndex = 0x2CB,
VertexShaderData0 = 0x2CC,

View file

@ -1,4 +1,5 @@
#include "PICA/gpu.hpp"
#include "PICA/regs.hpp"
#include <cstdio>
void GPU::reset() {
@ -9,4 +10,11 @@ void GPU::reset() {
void GPU::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {
printf("GPU: Clear buffer\nStart: %08X End: %08X\nValue: %08X Control: %08X\n", startAddress, endAddress, value, control);
}
void GPU::drawArrays() {
const u32 vertexCount = regs[PICAInternalRegs::VertexCountReg];
const u32 vertexOffset = regs[PICAInternalRegs::VertexOffsetReg];
printf("PICA::DrawArrays(vertex count = %d, vertexOffset = %d)\n", vertexCount, vertexOffset);
}

View file

@ -34,10 +34,15 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
u32 currentValue = regs[index];
u32 newValue = (currentValue & ~mask) | (value & mask); // Only overwrite the bits specified by "mask"
regs[index] = newValue;
// TODO: Figure out if things like the shader index use the unmasked value or the masked one
// We currently use the unmasked value like Citra does
switch (index) {
case SignalDrawArrays:
if (value != 0) drawArrays();
break;
case VertexShaderTransferEnd:
if (value != 0) shaderUnit.vs.finalize();
break;