From f49a101170883b6f582b1ccfd1dc21a489974549 Mon Sep 17 00:00:00 2001 From: offtkp Date: Wed, 31 Jul 2024 04:06:26 +0300 Subject: [PATCH] More whoopsies???!? --- CMakeLists.txt | 2 +- include/renderer_gl/renderer_gl.hpp | 2 +- src/core/renderer_gl/async_compiler.cpp | 3 +-- src/core/renderer_gl/renderer_gl.cpp | 5 ++--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d34200f1..c9795d86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION endif() if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo) + set(CMAKE_BUILD_TYPE Release) endif() project(Alber) diff --git a/include/renderer_gl/renderer_gl.hpp b/include/renderer_gl/renderer_gl.hpp index 9395648c..85dfe683 100644 --- a/include/renderer_gl/renderer_gl.hpp +++ b/include/renderer_gl/renderer_gl.hpp @@ -25,7 +25,7 @@ class GPU; // Cached recompiled fragment shader struct CachedProgram { - OpenGL::Program program; + OpenGL::Program program {}; GLuint uboBinding = 0; bool ready = false; }; diff --git a/src/core/renderer_gl/async_compiler.cpp b/src/core/renderer_gl/async_compiler.cpp index 41e311fe..800aec49 100644 --- a/src/core/renderer_gl/async_compiler.cpp +++ b/src/core/renderer_gl/async_compiler.cpp @@ -82,8 +82,7 @@ void AsyncCompilerState::Start() { } } - // Sleep for a bit to avoid excessive CPU usage - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + std::this_thread::yield(); } Frontend::AsyncCompiler::destroyContext(contextCreationUserdata, context); diff --git a/src/core/renderer_gl/renderer_gl.cpp b/src/core/renderer_gl/renderer_gl.cpp index 5414f040..ecf40602 100644 --- a/src/core/renderer_gl/renderer_gl.cpp +++ b/src/core/renderer_gl/renderer_gl.cpp @@ -27,6 +27,7 @@ namespace { void initializeProgramEntry(GLStateManager& gl, CachedProgram& programEntry) { OpenGL::Program& program = programEntry.program; + program.use(); // Init sampler objects. Texture 0 goes in texture unit 0, texture 1 in TU 1, texture 2 in TU 2, and the light maps go in TU 3 glUniform1i(OpenGL::uniformLocation(program, "u_tex0"), 0); @@ -477,7 +478,6 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span v programEntry.ready = true; programEntry.program.createFromBinary(compiledProgram->binary, compiledProgram->binaryFormat); - programEntry.program.use(); initializeProgramEntry(gl, programEntry); delete compiledProgram; @@ -492,6 +492,7 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span v } else if (!shaderCache[fsConfig].ready) { usingUbershader = true; } + usingUbershader = true; } if (usingUbershader) { @@ -917,8 +918,6 @@ OpenGL::Program& RendererGL::getSpecializedShader(const PICA::FragmentConfig& fs OpenGL::Shader fragShader({fs.c_str(), fs.size()}, OpenGL::Fragment); program.create({defaultShadergenVs, fragShader}); - gl.useProgram(program); - fragShader.free(); initializeProgramEntry(gl, programEntry);