Skip to content

Commit

Permalink
Renderer: Improve null renderer performance (#646)
Browse files Browse the repository at this point in the history
* Renderer: Improve null renderer performance

* Update frontend_sdl.cpp
  • Loading branch information
wheremyfoodat authored Nov 24, 2024
1 parent 1a40dec commit 4df171a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions include/renderer_null/renderer_null.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class RendererNull final : public Renderer {
void screenshot(const std::string& name) override;
void deinitGraphicsContext() override;

// Tell the GPU core that we'll handle vertex fetch & shader execution in the renderer in order to speed up execution.
// Of course, we don't do this and geometry is never actually processed, since this is the null renderer.
virtual bool prepareForDraw(ShaderUnit& shaderUnit, PICA::DrawAcceleration* accel) override { return true; };

#ifdef PANDA3DS_FRONTEND_QT
virtual void initGraphicsContext([[maybe_unused]] GL::Context* context) override {}
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/panda_sdl/frontend_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ FrontendSDL::FrontendSDL() : keyboardMappings(InputMappings::defaultKeyboardMapp
}

const EmulatorConfig& config = emu.getConfig();
// We need OpenGL for software rendering or for OpenGL if it's enabled
bool needOpenGL = config.rendererType == RendererType::Software;
// We need OpenGL for software rendering/null renderer or for the OpenGL renderer if it's enabled.
bool needOpenGL = config.rendererType == RendererType::Software || config.rendererType == RendererType::Null;
#ifdef PANDA3DS_ENABLE_OPENGL
needOpenGL = needOpenGL || (config.rendererType == RendererType::OpenGL);
#endif
Expand Down Expand Up @@ -58,11 +58,11 @@ FrontendSDL::FrontendSDL() : keyboardMappings(InputMappings::defaultKeyboardMapp
emu.setOutputSize(windowWidth, windowHeight);

if (needOpenGL) {
// Demand 3.3 core for software renderer, or 4.1 core for OpenGL renderer (max available on MacOS)
// Demand 4.1 core for OpenGL renderer (max available on MacOS), 3.3 for the software & null renderers
// MacOS gets mad if we don't explicitly demand a core profile
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, config.rendererType == RendererType::Software ? 3 : 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, config.rendererType == RendererType::Software ? 3 : 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, config.rendererType == RendererType::OpenGL ? 4 : 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, config.rendererType == RendererType::OpenGL ? 1 : 3);
window = SDL_CreateWindow(windowTitle, windowX, windowY, windowWidth, windowHeight, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);

if (window == nullptr) {
Expand Down

0 comments on commit 4df171a

Please sign in to comment.