SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Regression: "Window framebuffer support not available" error if software renderer is explicitly enforced in the SDL_HINT_RENDER_DRIVER

Open oo8dev opened this issue 2 years ago • 7 comments

How to reproduce:

Method 1: testdrawchessboard.c:

int main() {
   SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
   (...)

or just running via

SDL_RENDER_DRIVER=software ./test/testdrawchessboard

(Parameter 'window' is invalid)

oo8dev avatar Jul 01 '24 06:07 oo8dev

What platform are you seeing this on? Are you testing with the latest code? I tested on Windows both with and without forcing the rendering path, and in each case the software renderer wasn't used and the window surface was successfully created.

slouken avatar Jul 03 '24 21:07 slouken

It's Linux, tested again with the latest commit (https://github.com/libsdl-org/SDL/commit/9d47daef0a674b06f97be383f67b6e7bf406f41b):

SDL_RENDER_DRIVER=software ./test/testdrawchessboard
ERROR: Render creation for surface fail : Parameter 'window' is invalid

SDL_RENDER_DRIVER=opengl and others work just fine.

oo8dev avatar Jul 04 '24 13:07 oo8dev

I just tested and that same setup works fine here.

That error message means that SDL_CreateSoftwareRenderer() failed, which doesn't make any sense because the hint shouldn't affect that, and there is never any window in that code path. Can you debug that function to see what's happening?

slouken avatar Jul 04 '24 14:07 slouken

Differences between the environment flag and without it: In testdrawchessboard.c:133, SDL_GetWindowSurface(window) returns null instead of SDL_Surface In SDL_video.c:3371, SDL_CreateWindowFramebuffer returns null instead of SDL_Surface In SDL_video.c:3311, ShouldAttemptTextureFramebuffer is false, thus created_framebuffer is never set, returning null

image

Removing this piece of code (which was introduced in https://github.com/libsdl-org/SDL/commit/5c8d92e4d08cb47feb0e5a911c43263d69325bdb ) mitigates this issue.

oo8dev avatar Jul 05 '24 06:07 oo8dev

SDL_CreateSoftwareRenderer fails here:

SDL_render.c, SDL_CreateRendererWithProperties:

    if ((!window && !surface) || (window && surface)) {
        SDL_InvalidParamError("window");
        goto error;
    }

Parameter window is null here, because SDL_GetProperty(props, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER, NULL) returns a null pointer here.

surface is null here because SDL_GetWindowSurface() returns null before calling this function, and SDL_SetProperty is set with a null surface.

oo8dev avatar Jul 05 '24 06:07 oo8dev

Okay, I'm able to reproduce this on Wayland, thanks!

slouken avatar Jul 05 '24 15:07 slouken

Fixed, thanks!

slouken avatar Jul 05 '24 15:07 slouken