mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
[PICA] Implement int uniforms
This commit is contained in:
parent
4cda023c22
commit
a5c6fb858f
5 changed files with 25 additions and 3 deletions
|
@ -50,6 +50,11 @@ namespace PICAInternalRegs {
|
||||||
PrimitiveConfig = 0x25E,
|
PrimitiveConfig = 0x25E,
|
||||||
|
|
||||||
// Vertex shader registers
|
// Vertex shader registers
|
||||||
|
VertexIntUniform0 = 0x2B1,
|
||||||
|
VertexIntUniform1 = 0x2B2,
|
||||||
|
VertexIntUniform2 = 0x2B3,
|
||||||
|
VertexIntUniform3 = 0x2B4,
|
||||||
|
|
||||||
VertexShaderTransferEnd = 0x2BF,
|
VertexShaderTransferEnd = 0x2BF,
|
||||||
VertexFloatUniformIndex = 0x2C0,
|
VertexFloatUniformIndex = 0x2C0,
|
||||||
VertexFloatUniformData0 = 0x2C1,
|
VertexFloatUniformData0 = 0x2C1,
|
||||||
|
|
|
@ -35,6 +35,8 @@ class PICAShader {
|
||||||
std::array<u32, 128> operandDescriptors;
|
std::array<u32, 128> operandDescriptors;
|
||||||
std::array<vec4f, 16> tempRegisters; // General purpose registers the shader can use for temp values
|
std::array<vec4f, 16> tempRegisters; // General purpose registers the shader can use for temp values
|
||||||
OpenGL::Vector<s32, 2> addrRegister; // Address register
|
OpenGL::Vector<s32, 2> addrRegister; // Address register
|
||||||
|
u32 pc = 0; // Program counter: Index of the next instruction we're going to execute
|
||||||
|
|
||||||
u32 loopCounter;
|
u32 loopCounter;
|
||||||
ShaderType type;
|
ShaderType type;
|
||||||
|
|
||||||
|
@ -102,7 +104,7 @@ public:
|
||||||
std::array<u32, 512> bufferedShader; // Shader to be transferred when the SH_CODETRANSFER_END reg gets written to
|
std::array<u32, 512> bufferedShader; // Shader to be transferred when the SH_CODETRANSFER_END reg gets written to
|
||||||
|
|
||||||
u32 boolUniform;
|
u32 boolUniform;
|
||||||
std::array<u32, 4> intUniforms;
|
std::array<OpenGL::Vector<u8, 4>, 4> intUniforms;
|
||||||
std::array<vec4f, 96> floatUniforms;
|
std::array<vec4f, 96> floatUniforms;
|
||||||
|
|
||||||
std::array<vec4f, 16> fixedAttributes; // Fixed vertex attributes
|
std::array<vec4f, 16> fixedAttributes; // Fixed vertex attributes
|
||||||
|
@ -164,6 +166,14 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uploadIntUniform(int index, u32 word) {
|
||||||
|
auto& u = intUniforms[index];
|
||||||
|
u.x() = word & 0xff;
|
||||||
|
u.y() = (word >> 8) & 0xff;
|
||||||
|
u.z() = (word >> 16) & 0xff;
|
||||||
|
u.w() = (word >> 24) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
|
@ -100,6 +100,10 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
|
||||||
shaderUnit.vs.uploadDescriptor(value);
|
shaderUnit.vs.uploadDescriptor(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VertexIntUniform0: case VertexIntUniform1: case VertexIntUniform2: case VertexIntUniform3:
|
||||||
|
shaderUnit.vs.uploadIntUniform(index - VertexIntUniform0, value);
|
||||||
|
break;
|
||||||
|
|
||||||
case VertexShaderTransferEnd:
|
case VertexShaderTransferEnd:
|
||||||
if (value != 0) shaderUnit.vs.finalize();
|
if (value != 0) shaderUnit.vs.finalize();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "PICA/shader.hpp"
|
#include "PICA/shader.hpp"
|
||||||
|
|
||||||
void PICAShader::run() {
|
void PICAShader::run() {
|
||||||
u32 pc = 0; // Program counter
|
pc = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const u32 instruction = loadedShader[pc++];
|
const u32 instruction = loadedShader[pc++];
|
||||||
|
|
|
@ -10,7 +10,6 @@ void PICAShader::reset() {
|
||||||
bufferedShader.fill(0);
|
bufferedShader.fill(0);
|
||||||
operandDescriptors.fill(0);
|
operandDescriptors.fill(0);
|
||||||
|
|
||||||
intUniforms.fill(0);
|
|
||||||
boolUniform = 0;
|
boolUniform = 0;
|
||||||
bufferIndex = 0;
|
bufferIndex = 0;
|
||||||
floatUniformIndex = 0;
|
floatUniformIndex = 0;
|
||||||
|
@ -24,6 +23,10 @@ void PICAShader::reset() {
|
||||||
outputs.fill(zero);
|
outputs.fill(zero);
|
||||||
tempRegisters.fill(zero);
|
tempRegisters.fill(zero);
|
||||||
|
|
||||||
|
for (auto& e : intUniforms) {
|
||||||
|
e.x() = e.y() = e.z() = e.w() = 0;
|
||||||
|
}
|
||||||
|
|
||||||
addrRegister.x() = 0;
|
addrRegister.x() = 0;
|
||||||
addrRegister.y() = 0;
|
addrRegister.y() = 0;
|
||||||
loopCounter = 0;
|
loopCounter = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue