From fde7e3c499f3a460b62c0aca34159aa1d3e340a1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 27 Oct 2024 14:19:18 +0100 Subject: Fix for prime systems --- src/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index ec23cac..3d367fa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,11 +33,31 @@ static void sigint_handler(int signal) { running = 0; } +static void disable_prime_run() { + unsetenv("__NV_PRIME_RENDER_OFFLOAD"); + unsetenv("__NV_PRIME_RENDER_OFFLOAD_PROVIDER"); + unsetenv("__GLX_VENDOR_LIBRARY_NAME"); + unsetenv("__VK_LAYER_NV_optimus"); +} + int main(int argc, char **argv) { (void)argc; (void)argv; setlocale(LC_ALL, "C"); // Sigh... stupid C + // Cant get window texture when prime-run is used + disable_prime_run(); + + // Stop nvidia driver from buffering frames + setenv("__GL_MaxFramesAllowed", "1", true); + // If this is set to 1 then cuGraphicsGLRegisterImage will fail for egl context with error: invalid OpenGL or DirectX context, + // so we overwrite it + setenv("__GL_THREADED_OPTIMIZATIONS", "0", true); + // Some people set this to force all applications to vsync on nvidia, but this makes eglSwapBuffers never return. + unsetenv("__GL_SYNC_TO_VBLANK"); + // Same as above, but for amd/intel + unsetenv("vblank_mode"); + signal(SIGINT, sigint_handler); gsr::GsrInfo gsr_info; -- cgit v1.2.3