From 0951638a7b928b4aad64a05a6a58fc5e903a297e Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Fri, 10 Jan 2025 12:05:19 -0500 Subject: [PATCH] Map D3D12/Metal FNA3D values to SDL_GPU equivalents --- src/FNA3D.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/FNA3D.c b/src/FNA3D.c index 05cf6a35..25eb8480 100644 --- a/src/FNA3D.c +++ b/src/FNA3D.c @@ -145,15 +145,40 @@ uint32_t FNA3D_PrepareWindowAttributes(void) uint32_t result = 0; uint32_t i; const char *hint = SDL_GetHint("FNA3D_FORCE_DRIVER"); + const char *gpuhint; /* We used to have our own Vulkan renderer, but that work is now in SDL * instead. For maximum compatibility, alias this to SDL_GPU! + * + * And hey, since we're here, let's do this for D3D12/Metal too. * -flibit */ #ifdef USE_SDL3 - if ((hint != NULL) && (SDL_strcasecmp(hint, "Vulkan") == 0)) + if (hint != NULL) { - hint = "SDLGPU"; + gpuhint = NULL; + if (SDL_strcasecmp(hint, "Vulkan") == 0) + { + gpuhint = "vulkan"; + } + else if (SDL_strcasecmp(hint, "D3D12") == 0) + { + gpuhint = "direct3d12"; + } + else if (SDL_strcasecmp(hint, "Metal") == 0) + { + gpuhint = "metal"; + } + + if (gpuhint != NULL) + { + hint = "SDLGPU"; + SDL_SetHintWithPriority( + SDL_HINT_GPU_DRIVER, + gpuhint, + SDL_HINT_OVERRIDE + ); + } } #endif