Separate renderer and PICA completely

This commit is contained in:
wheremyfoodat 2023-01-01 22:06:54 +02:00
parent 9f792c2cf5
commit 57ef4e25e7
6 changed files with 65 additions and 37 deletions

View file

@ -6,6 +6,7 @@
using namespace Floats;
GPU::GPU(Memory& mem) : mem(mem) {
GPU::GPU(Memory& mem) : mem(mem), renderer(regs) {
vram = new u8[vramSize];
}
@ -49,12 +50,13 @@ void GPU::drawArrays() {
const u32 primType = (primConfig >> 8) & 3;
if (primType != 0 && primType != 1) Helpers::panic("[PICA] Tried to draw unimplemented shape %d\n", primType);
if (vertexCount > vertexBufferSize) Helpers::panic("[PICA] vertexCount > vertexBufferSize");
if (vertexCount > Renderer::vertexBufferSize) Helpers::panic("[PICA] vertexCount > vertexBufferSize");
if ((primType == 0 && vertexCount % 3) || (primType == 1 && vertexCount < 3)) {
Helpers::panic("Invalid vertex count for primitive. Type: %d, vert count: %d\n", primType, vertexCount);
}
Vertex vertices[vertexBufferSize];
Vertex vertices[Renderer::vertexBufferSize];
// Get the configuration for the index buffer, used only for indexed drawing
u32 indexBufferConfig = regs[PICAInternalRegs::IndexBufferConfig];
@ -157,7 +159,7 @@ void GPU::drawArrays() {
OpenGL::Triangle, OpenGL::TriangleStrip, OpenGL::TriangleFan, OpenGL::LineStrip
};
const auto shape = primTypes[primType];
drawVertices(shape, vertices, vertexCount);
renderer.drawVertices(shape, vertices, vertexCount);
}
void GPU::fireDMA(u32 dest, u32 source, u32 size) {