mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
Hook up specialized shaders to GL renderer
This commit is contained in:
parent
67fe3214fe
commit
fc83d518e2
1 changed files with 27 additions and 16 deletions
|
@ -291,6 +291,9 @@ void RendererGL::setupStencilTest(bool stencilEnable) {
|
||||||
|
|
||||||
void RendererGL::setupTextureEnvState() {
|
void RendererGL::setupTextureEnvState() {
|
||||||
// TODO: Only update uniforms when the TEV config changed. Use an UBO potentially.
|
// TODO: Only update uniforms when the TEV config changed. Use an UBO potentially.
|
||||||
|
if (!usingUbershader) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr std::array<u32, 6> ioBases = {
|
static constexpr std::array<u32, 6> ioBases = {
|
||||||
PICA::InternalRegs::TexEnv0Source, PICA::InternalRegs::TexEnv1Source, PICA::InternalRegs::TexEnv2Source,
|
PICA::InternalRegs::TexEnv0Source, PICA::InternalRegs::TexEnv1Source, PICA::InternalRegs::TexEnv2Source,
|
||||||
|
@ -388,13 +391,17 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
|
||||||
OpenGL::Triangle,
|
OpenGL::Triangle,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (usingUbershader) {
|
||||||
|
gl.useProgram(triangleProgram);
|
||||||
|
} else {
|
||||||
OpenGL::Program& program = getSpecializedShader();
|
OpenGL::Program& program = getSpecializedShader();
|
||||||
|
gl.useProgram(program);
|
||||||
|
}
|
||||||
|
|
||||||
const auto primitiveTopology = primTypes[static_cast<usize>(primType)];
|
const auto primitiveTopology = primTypes[static_cast<usize>(primType)];
|
||||||
gl.disableScissor();
|
gl.disableScissor();
|
||||||
gl.bindVBO(vbo);
|
gl.bindVBO(vbo);
|
||||||
gl.bindVAO(vao);
|
gl.bindVAO(vao);
|
||||||
gl.useProgram(triangleProgram);
|
|
||||||
|
|
||||||
gl.enableClipPlane(0); // Clipping plane 0 is always enabled
|
gl.enableClipPlane(0); // Clipping plane 0 is always enabled
|
||||||
if (regs[PICA::InternalRegs::ClipEnable] & 1) {
|
if (regs[PICA::InternalRegs::ClipEnable] & 1) {
|
||||||
|
@ -420,6 +427,7 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
|
||||||
const bool depthMapEnable = regs[PICA::InternalRegs::DepthmapEnable] & 1;
|
const bool depthMapEnable = regs[PICA::InternalRegs::DepthmapEnable] & 1;
|
||||||
|
|
||||||
// Update depth uniforms
|
// Update depth uniforms
|
||||||
|
if (usingUbershader) {
|
||||||
if (oldDepthScale != depthScale) {
|
if (oldDepthScale != depthScale) {
|
||||||
oldDepthScale = depthScale;
|
oldDepthScale = depthScale;
|
||||||
glUniform1f(ubershaderData.depthScaleLoc, depthScale);
|
glUniform1f(ubershaderData.depthScaleLoc, depthScale);
|
||||||
|
@ -434,13 +442,16 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
|
||||||
oldDepthmapEnable = depthMapEnable;
|
oldDepthmapEnable = depthMapEnable;
|
||||||
glUniform1i(ubershaderData.depthmapEnableLoc, depthMapEnable);
|
glUniform1i(ubershaderData.depthmapEnableLoc, depthMapEnable);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setupTextureEnvState();
|
setupTextureEnvState();
|
||||||
bindTexturesToSlots();
|
bindTexturesToSlots();
|
||||||
|
|
||||||
|
if (usingUbershader) {
|
||||||
// Upload PICA Registers as a single uniform. The shader needs access to the rasterizer registers (for depth, starting from index 0x48)
|
// Upload PICA Registers as a single uniform. The shader needs access to the rasterizer registers (for depth, starting from index 0x48)
|
||||||
// The texturing and the fragment lighting registers. Therefore we upload them all in one go to avoid multiple slow uniform updates
|
// The texturing and the fragment lighting registers. Therefore we upload them all in one go to avoid multiple slow uniform updates
|
||||||
glUniform1uiv(ubershaderData.picaRegLoc, 0x200 - 0x48, ®s[0x48]);
|
glUniform1uiv(ubershaderData.picaRegLoc, 0x200 - 0x48, ®s[0x48]);
|
||||||
|
}
|
||||||
|
|
||||||
if (gpu.lightingLUTDirty) {
|
if (gpu.lightingLUTDirty) {
|
||||||
updateLightingLUT();
|
updateLightingLUT();
|
||||||
|
|
Loading…
Add table
Reference in a new issue