Skip to content

Commit

Permalink
The metal renderer doesn't actually support RGB texture formats
Browse files Browse the repository at this point in the history
Fixes #11576
  • Loading branch information
slouken committed Dec 6, 2024
1 parent 1a5b079 commit ffb9b30
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/render/metal/SDL_render_metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -650,22 +650,20 @@ static bool METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD

switch (texture->format) {
case SDL_PIXELFORMAT_ABGR8888:
case SDL_PIXELFORMAT_XBGR8888:
if (renderer->output_colorspace == SDL_COLORSPACE_SRGB_LINEAR) {
pixfmt = MTLPixelFormatRGBA8Unorm_sRGB;
} else {
pixfmt = MTLPixelFormatRGBA8Unorm;
}
break;
case SDL_PIXELFORMAT_ARGB8888:
case SDL_PIXELFORMAT_XRGB8888:
if (renderer->output_colorspace == SDL_COLORSPACE_SRGB_LINEAR) {
pixfmt = MTLPixelFormatBGRA8Unorm_sRGB;
} else {
pixfmt = MTLPixelFormatBGRA8Unorm;
}
break;
case SDL_PIXELFORMAT_XBGR2101010:
case SDL_PIXELFORMAT_ABGR2101010:
pixfmt = MTLPixelFormatRGB10A2Unorm;
break;
case SDL_PIXELFORMAT_IYUV:
Expand Down Expand Up @@ -1737,7 +1735,7 @@ static bool METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd
format = SDL_PIXELFORMAT_ABGR8888;
break;
case MTLPixelFormatRGB10A2Unorm:
format = SDL_PIXELFORMAT_XBGR2101010;
format = SDL_PIXELFORMAT_ABGR2101010;
break;
case MTLPixelFormatRGBA16Float:
format = SDL_PIXELFORMAT_RGBA64_FLOAT;
Expand Down Expand Up @@ -2179,9 +2177,7 @@ in case we want to use it later (recreating the renderer)
renderer->name = METAL_RenderDriver.name;
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_ARGB8888);
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_ABGR8888);
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_XRGB8888);
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_XBGR8888);
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_XBGR2101010);
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_ABGR2101010);
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_RGBA64_FLOAT);
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_RGBA128_FLOAT);
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_YV12);
Expand Down

0 comments on commit ffb9b30

Please sign in to comment.