Skip to content

Simple bug fix in SDL_render #12027

Closed
Closed
@ThrudTheBarbarian

Description

@ThrudTheBarbarian

Looks like the colourspace logic is initialising the wrong colourspace before testing things...

Simple patch (really doesn't seem necessary to fork/create branch/create pull-request, it's only 1 line :)

diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 06c0381ca..eed841561 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1634,7 +1634,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
         }
     }
 
-    texture_colorspace = SDL_GetSurfaceColorspace(surface);
+    surface_colorspace = SDL_GetSurfaceColorspace(surface);
 
     // Try to have the best pixel format for the texture
     // No alpha, but a colorkey => promote to alpha

The first reference to the colourspace is later on down the file, line 1700 at this moment in time, where tests on surface_colorspace are used to determine texture_colorspace

    if (surface_colorspace == SDL_COLORSPACE_SRGB_LINEAR ||
        SDL_COLORSPACETRANSFER(surface_colorspace) == SDL_TRANSFER_CHARACTERISTICS_PQ) {
        if (SDL_ISPIXELFORMAT_FLOAT(format)) {
            texture_colorspace = SDL_COLORSPACE_SRGB_LINEAR;
        } else if (SDL_ISPIXELFORMAT_10BIT(format)) {
            texture_colorspace = SDL_COLORSPACE_HDR10;
        } else {
            texture_colorspace = SDL_COLORSPACE_SRGB;
        }
    }

So it's pretty clear the intent was to set surface_colorspace not texture_colorspace

Seems that re-implementing the render api to work on top of the GPU API can have some benefits after all :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions