mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-09 07:35:41 +12:00
Properly flush shader cache
This commit is contained in:
parent
fe53214c86
commit
11c9279329
3 changed files with 42 additions and 25 deletions
|
@ -140,9 +140,9 @@ std::string FragmentGenerator::generate(const PICARegs& regs) {
|
||||||
float alphaOp3 = 0.0;
|
float alphaOp3 = 0.0;
|
||||||
)";
|
)";
|
||||||
|
|
||||||
ret += R"(
|
|
||||||
// Get original depth value by converting from [near, far] = [0, 1] to [-1, 1]
|
// Get original depth value by converting from [near, far] = [0, 1] to [-1, 1]
|
||||||
// We do this by converting to [0, 2] first and subtracting 1 to go to [-1, 1]
|
// We do this by converting to [0, 2] first and subtracting 1 to go to [-1, 1]
|
||||||
|
ret += R"(
|
||||||
float z_over_w = gl_FragCoord.z * 2.0f - 1.0f;
|
float z_over_w = gl_FragCoord.z * 2.0f - 1.0f;
|
||||||
float depth = z_over_w * depthScale + depthOffset;
|
float depth = z_over_w * depthScale + depthOffset;
|
||||||
)";
|
)";
|
||||||
|
@ -343,7 +343,7 @@ void FragmentGenerator::getSource(std::string& shader, TexEnvConfig::Source sour
|
||||||
|
|
||||||
// Lighting
|
// Lighting
|
||||||
case TexEnvConfig::Source::PrimaryFragmentColor:
|
case TexEnvConfig::Source::PrimaryFragmentColor:
|
||||||
case TexEnvConfig::Source::SecondaryFragmentColor: shader += "vec4(0.0, 0.0, 0.0, 1.0)"; break;
|
case TexEnvConfig::Source::SecondaryFragmentColor: shader += "vec4(1.0, 1.0, 1.0, 1.0)"; break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Helpers::warn("Unimplemented TEV source: %d", static_cast<int>(source));
|
Helpers::warn("Unimplemented TEV source: %d", static_cast<int>(source));
|
||||||
|
|
|
@ -23,6 +23,11 @@ void RendererGL::reset() {
|
||||||
colourBufferCache.reset();
|
colourBufferCache.reset();
|
||||||
textureCache.reset();
|
textureCache.reset();
|
||||||
|
|
||||||
|
for (auto& shader : shaderCache) {
|
||||||
|
shader.second.program.free();
|
||||||
|
}
|
||||||
|
shaderCache.clear();
|
||||||
|
|
||||||
// Init the colour/depth buffer settings to some random defaults on reset
|
// Init the colour/depth buffer settings to some random defaults on reset
|
||||||
colourBufferLoc = 0;
|
colourBufferLoc = 0;
|
||||||
colourBufferFormat = PICA::ColorFmt::RGBA8;
|
colourBufferFormat = PICA::ColorFmt::RGBA8;
|
||||||
|
@ -899,6 +904,11 @@ void RendererGL::deinitGraphicsContext() {
|
||||||
depthBufferCache.reset();
|
depthBufferCache.reset();
|
||||||
colourBufferCache.reset();
|
colourBufferCache.reset();
|
||||||
|
|
||||||
|
for (auto& shader : shaderCache) {
|
||||||
|
shader.second.program.free();
|
||||||
|
}
|
||||||
|
shaderCache.clear();
|
||||||
|
|
||||||
// All other GL objects should be invalidated automatically and be recreated by the next call to initGraphicsContext
|
// All other GL objects should be invalidated automatically and be recreated by the next call to initGraphicsContext
|
||||||
// TODO: Make it so that depth and colour buffers get written back to 3DS memory
|
// TODO: Make it so that depth and colour buffers get written back to 3DS memory
|
||||||
printf("RendererGL::DeinitGraphicsContext called\n");
|
printf("RendererGL::DeinitGraphicsContext called\n");
|
||||||
|
|
7
third_party/opengl/opengl.hpp
vendored
7
third_party/opengl/opengl.hpp
vendored
|
@ -424,6 +424,13 @@ namespace OpenGL {
|
||||||
GLuint handle() const { return m_handle; }
|
GLuint handle() const { return m_handle; }
|
||||||
bool exists() const { return m_handle != 0; }
|
bool exists() const { return m_handle != 0; }
|
||||||
void use() const { glUseProgram(m_handle); }
|
void use() const { glUseProgram(m_handle); }
|
||||||
|
|
||||||
|
void free() {
|
||||||
|
if (exists()) {
|
||||||
|
glDeleteProgram(m_handle);
|
||||||
|
m_handle = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void dispatchCompute(GLuint groupsX = 1, GLuint groupsY = 1, GLuint groupsZ = 1) {
|
static void dispatchCompute(GLuint groupsX = 1, GLuint groupsY = 1, GLuint groupsZ = 1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue