mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-07 11:31:39 +12:00
[PICA] Shader uploads
This commit is contained in:
parent
36a30da78d
commit
5993dc4759
11 changed files with 105 additions and 9 deletions
41
include/PICA/shader.hpp
Normal file
41
include/PICA/shader.hpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include "helpers.hpp"
|
||||
|
||||
class PICAShader {
|
||||
int bufferIndex; // Index of the next instruction to overwrite
|
||||
|
||||
public:
|
||||
std::array<u32, 512> loadedShader; // Currently loaded & active shader
|
||||
std::array<u32, 512> bufferedShader; // Shader to be transferred when the SH_CODETRANSFER_END reg gets written to
|
||||
|
||||
u32 boolUniform;
|
||||
std::array<u32, 4> intUniforms;
|
||||
std::array<u32, 8> floatUniforms;
|
||||
|
||||
void reset() {
|
||||
loadedShader.fill(0);
|
||||
bufferedShader.fill(0);
|
||||
|
||||
intUniforms.fill(0);
|
||||
floatUniforms.fill(0);
|
||||
boolUniform = 0;
|
||||
bufferIndex = 0;
|
||||
}
|
||||
|
||||
void finalize() {
|
||||
std::memcpy(&loadedShader[0], &bufferedShader[0], 512 * sizeof(u32));
|
||||
}
|
||||
|
||||
void setBufferIndex(u32 offset) {
|
||||
if (offset != 0) Helpers::panic("Is this register 9 or 11 bit?");
|
||||
bufferIndex = (offset >> 2) & 511;
|
||||
}
|
||||
|
||||
void uploadWord(u32 word) {
|
||||
bufferedShader[bufferIndex++] = word;
|
||||
bufferIndex &= 511;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue