Skip to content

Commit 18244f4

Browse files
llyyrkasper93
authored andcommitted
vulkan/swapchain: prefer BGRA UNORM and RGBA FLOAT formats on Apple
Only VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_A2R10G10B10_UNORM_PACK32 and VK_FORMAT_R16G16B16A16_SFLOAT formats support direct-to-display rendering on Apple, so give them a little score bump to prefer picking them This also reworks the score bump added in a4cd3d1 to be more in line with other format related score bumps
1 parent ea8cc49 commit 18244f4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/vulkan/swapchain.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,26 @@ static bool pick_surf_format(pl_swapchain sw, const struct pl_color_space *hint)
227227
default: // skip any other format
228228
continue;
229229
}
230+
#ifdef __APPLE__
231+
// On Apple hardware, only these formats allow direct-to-display
232+
// rendering, so give them a slight score boost to tie-break against
233+
// other formats
234+
switch (p->formats.elem[i].format) {
235+
case VK_FORMAT_B8G8R8A8_UNORM:
236+
case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
237+
case VK_FORMAT_R16G16B16A16_SFLOAT:
238+
score += 5;
239+
break;
240+
default:
241+
break;
242+
}
243+
#else
244+
// On other platforms, it doesn't matter in theory but some drivers
245+
// or hardware may have limited support for BGR formats, so prefer
246+
// RGB instead.
230247
if (pl_fmt_is_ordered(plfmt))
231-
score += 500;
248+
score += 5;
249+
#endif
232250
if (pl_color_primaries_is_wide_gamut(space.primaries) == wide_gamut)
233251
score += 1000;
234252
if (space.primaries == hint->primaries)

0 commit comments

Comments
 (0)