Force CPU-only non-GLX rendering on Linux?

Hi,

I was trying to use mozilla rr debugger to debug an SDL2 project, and I got some errors.

Then I created an issue to rr's repo and the maintainer of rr asked if there’s way to force CPU-only and non-GLX rendering?

I googled it and couldn’t find the answer.

Does anyone know the answer? Thanks

Force the software renderer with an environment variable. This will cover both SDL’s 2D render API and trying to use SDL_UpdateWindowSurface, which also checks this environment variable before trying to use OpenGL as a fast-path.

export SDL_RENDER_DRIVER=software

–ryan.

Thanks for the reply.

My SDL knowledge is very limited and I am trying to make a simple example work.

https://pastebin.com/Qnk5m5vr, this example doesn’t use SDL_UpdateWindowSurface and I don’t know if there’s call that can be replaced by SDL_UpdateWindowSurface. Since this example uses OpenGL, perhaps it is now a OpenGL thing?

Any SDL2 application could be doing graphics in one of three ways:

  1. Using surfaces (which would involve SDL_UpdateWindowSurface),
  2. or using an SDL_Renderer (which involves SDL_CreateRenderer/SDL_RenderPresent, …),
  3. or using OpenGL using SDL_GL_CreateContext.

These approaches can’t be mixed, so you just have to find out what approach it is for your application in question.

The third way will always use your system’s OpenGL driver and in that case, you need to get a software GL driver on a system level if you want output without 3d acceleration. Since SDL2/the application just uses the system’s OpenGL API in that case, it is out of SDL2’s hands how that is implemented and it’s purely a video driver implementation choice.

What ryan suggested would apply to applications using the second way. The first way (surfaces) doesn’t support 3d acceleration in the first place, so it’s always software rendering only. The code you posted uses the third way of rendering things.

1 Like

this example doesn’t use SDL_UpdateWindowSurface

Yes, because it’s using OpenGL directly.

If you use the 2D render API, and force it to use the software renderer, this will also tell it not to use OpenGL behind the scenes (just to get the image to the screen, but not for any actual rendering work, because even for software rendering, this tends to be the fastest way to get a block of pixels to the screen on many platforms, plus it lets things like the Steam Overlay work with the game).

While you can use SDL_UpdateWindowSurface if you definitely just want to manually manage every pixel in software, you almost certainly shouldn’t. Even for entirely software-rendered things, it’s best to use SDL’s render API to get them to the screen for a variety of reasons.