From 6df445ab8ce4dc49c240cbccffdc31ed38eb75cd Mon Sep 17 00:00:00 2001 From: Leon Lysak Date: Mon, 17 Nov 2025 12:50:52 -0500 Subject: [PATCH] Update shader handling for macOS and iOS --- backends/imgui_impl_sdlgpu3.cpp | 35 +++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/backends/imgui_impl_sdlgpu3.cpp b/backends/imgui_impl_sdlgpu3.cpp index 8d8f0a4c4..dc0b395c3 100644 --- a/backends/imgui_impl_sdlgpu3.cpp +++ b/backends/imgui_impl_sdlgpu3.cpp @@ -452,14 +452,33 @@ static void ImGui_ImplSDLGPU3_CreateShaders() #ifdef __APPLE__ else { - vertex_shader_info.entrypoint = "main0"; - vertex_shader_info.format = SDL_GPU_SHADERFORMAT_METALLIB; - vertex_shader_info.code = metallib_vertex; - vertex_shader_info.code_size = sizeof(metallib_vertex); - fragment_shader_info.entrypoint = "main0"; - fragment_shader_info.format = SDL_GPU_SHADERFORMAT_METALLIB; - fragment_shader_info.code = metallib_fragment; - fragment_shader_info.code_size = sizeof(metallib_fragment); + #include + + #if TARGET_OS_OSX + /* macOS: using MSL source */ + vertex_shader_info.entrypoint = "main0"; + vertex_shader_info.format = SDL_GPU_SHADERFORMAT_MSL; + vertex_shader_info.code = msl_vertex; + vertex_shader_info.code_size = sizeof(msl_vertex); + + fragment_shader_info.entrypoint = "main0"; + fragment_shader_info.format = SDL_GPU_SHADERFORMAT_MSL; + fragment_shader_info.code = msl_fragment; + fragment_shader_info.code_size = sizeof(msl_fragment); + + #elif TARGET_OS_IPHONE + /* iOS device: using metallib blobs */ + vertex_shader_info.entrypoint = "main0"; + vertex_shader_info.format = SDL_GPU_SHADERFORMAT_METALLIB; + vertex_shader_info.code = metallib_vertex; + vertex_shader_info.code_size = sizeof(metallib_vertex); + + fragment_shader_info.entrypoint = "main0"; + fragment_shader_info.format = SDL_GPU_SHADERFORMAT_METALLIB; + fragment_shader_info.code = metallib_fragment; + fragment_shader_info.code_size = sizeof(metallib_fragment); + + #endif } #endif bd->VertexShader = SDL_CreateGPUShader(v->Device, &vertex_shader_info);