diff --git a/src/dawn/utils/GLFWUtils.cpp b/src/dawn/utils/GLFWUtils.cpp index 74e8c73f5d..3ba577f72c 100644 --- a/src/dawn/utils/GLFWUtils.cpp +++ b/src/dawn/utils/GLFWUtils.cpp @@ -67,41 +67,38 @@ wgpu::Surface CreateSurfaceForWindow(const wgpu::Instance& instance, GLFWwindow* std::unique_ptr SetupWindowAndGetSurfaceDescriptorCocoa(GLFWwindow* window); std::unique_ptr SetupWindowAndGetSurfaceDescriptor(GLFWwindow* window) { - switch (glfwGetPlatform()) { #if DAWN_PLATFORM_IS(WINDOWS) - case GLFW_PLATFORM_WIN32: { - std::unique_ptr desc = - std::make_unique(); - desc->hwnd = glfwGetWin32Window(window); - desc->hinstance = GetModuleHandle(nullptr); - return std::move(desc); - } -#endif -#if defined(DAWN_ENABLE_BACKEND_METAL) - case GLFW_PLATFORM_COCOA: - return SetupWindowAndGetSurfaceDescriptorCocoa(window); -#endif -#if defined(DAWN_USE_WAYLAND) - case GLFW_PLATFORM_WAYLAND: { - std::unique_ptr desc = - std::make_unique(); - desc->display = glfwGetWaylandDisplay(); - desc->surface = glfwGetWaylandWindow(window); - return std::move(desc); - } + std::unique_ptr desc = + std::make_unique(); + desc->hwnd = glfwGetWin32Window(window); + desc->hinstance = GetModuleHandle(nullptr); + return std::move(desc); +#elif defined(DAWN_ENABLE_BACKEND_METAL) + return SetupWindowAndGetSurfaceDescriptorCocoa(window); +#elif defined(DAWN_USE_WAYLAND) || defined(DAWN_USE_X11) +#if defined(GLFW_PLATFORM_WAYLAND) && defined(DAWN_USE_WAYLAND) + if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) { + std::unique_ptr desc = + std::make_unique(); + desc->display = glfwGetWaylandDisplay(); + desc->surface = glfwGetWaylandWindow(window); + return std::move(desc); + } else // NOLINT(readability/braces) #endif #if defined(DAWN_USE_X11) - case GLFW_PLATFORM_X11: { - std::unique_ptr desc = - std::make_unique(); - desc->display = glfwGetX11Display(); - desc->window = glfwGetX11Window(window); - return std::move(desc); - } -#endif - default: - return nullptr; + { + std::unique_ptr desc = + std::make_unique(); + desc->display = glfwGetX11Display(); + desc->window = glfwGetX11Window(window); + return std::move(desc); } +#else + { return nullptr; } +#endif +#else + return nullptr; +#endif } } // namespace utils