[PICA] More progress on attribute parsing

This commit is contained in:
wheremyfoodat 2022-09-22 19:17:19 +03:00
parent 434c840aeb
commit 39bfeda586
4 changed files with 45 additions and 21 deletions

View file

@ -9,11 +9,13 @@ class GPU {
ShaderUnit shaderUnit;
u8* vram = nullptr;
static constexpr u32 totalAttribCount = 12; // Up to 12 vertex attributes
static constexpr u32 maxAttribCount = 12; // Up to 12 vertex attributes
static constexpr u32 regNum = 0x300;
static constexpr u32 vramSize = 6_MB;
std::array<u32, regNum> regs; // GPU internal registers
// Read a value of type T from physical address paddr
// This is necessary because vertex attribute fetching uses physical addresses
template<typename T>
T readPhysical(u32 paddr) {
if (paddr >= PhysicalAddrs::FCRAM && paddr <= PhysicalAddrs::FCRAMEnd) {
@ -26,6 +28,20 @@ class GPU {
}
}
// Get a pointer of type T* to the data starting from physical address paddr
template<typename T>
T* getPointerPhys(u32 paddr) {
if (paddr >= PhysicalAddrs::FCRAM && paddr <= PhysicalAddrs::FCRAMEnd) {
u8* fcram = mem.getFCRAM();
u32 index = paddr - PhysicalAddrs::FCRAM;
return (T*)&fcram[index];
}
else {
Helpers::panic("[PICA] Pointer to unimplemented paddr %08X", paddr);
}
}
template <bool indexed>
void drawArrays();
@ -37,7 +53,9 @@ class GPU {
int size = 0; // Bytes per vertex
};
std::array<AttribInfo, totalAttribCount> attributeInfo;
std::array<AttribInfo, maxAttribCount> attributeInfo; // Info for each of the 12 attributes
u32 totalAttribCount = 0; // Number of vertex attributes to send to VS
u32 fixedAttribMask = 0;
public:
GPU(Memory& mem);

View file

@ -4,6 +4,7 @@ namespace PICAInternalRegs {
enum : u32 {
// Geometry pipelin regs
VertexAttribLoc = 0x200,
AttribFormatHigh = 0x202,
IndexBufferConfig = 0x227,
VertexCountReg = 0x228,
VertexOffsetReg = 0x22A,