Remove requirement for glfw 3.4
Only try to use `glfwGetPlatform()` to distinguish X11 and Wayland if GLFW 3.4 is present. This fixes the build with older GLFW versions. Change-Id: Ia986933eeb3f049336bcd06c71b326f92a1da284 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93262 Commit-Queue: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
d45b920aed
commit
f02e091683
|
@ -67,41 +67,38 @@ wgpu::Surface CreateSurfaceForWindow(const wgpu::Instance& instance, GLFWwindow*
|
||||||
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorCocoa(GLFWwindow* window);
|
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorCocoa(GLFWwindow* window);
|
||||||
|
|
||||||
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(GLFWwindow* window) {
|
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(GLFWwindow* window) {
|
||||||
switch (glfwGetPlatform()) {
|
|
||||||
#if DAWN_PLATFORM_IS(WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
case GLFW_PLATFORM_WIN32: {
|
|
||||||
std::unique_ptr<wgpu::SurfaceDescriptorFromWindowsHWND> desc =
|
std::unique_ptr<wgpu::SurfaceDescriptorFromWindowsHWND> desc =
|
||||||
std::make_unique<wgpu::SurfaceDescriptorFromWindowsHWND>();
|
std::make_unique<wgpu::SurfaceDescriptorFromWindowsHWND>();
|
||||||
desc->hwnd = glfwGetWin32Window(window);
|
desc->hwnd = glfwGetWin32Window(window);
|
||||||
desc->hinstance = GetModuleHandle(nullptr);
|
desc->hinstance = GetModuleHandle(nullptr);
|
||||||
return std::move(desc);
|
return std::move(desc);
|
||||||
}
|
#elif defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
#endif
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
|
||||||
case GLFW_PLATFORM_COCOA:
|
|
||||||
return SetupWindowAndGetSurfaceDescriptorCocoa(window);
|
return SetupWindowAndGetSurfaceDescriptorCocoa(window);
|
||||||
#endif
|
#elif defined(DAWN_USE_WAYLAND) || defined(DAWN_USE_X11)
|
||||||
#if defined(DAWN_USE_WAYLAND)
|
#if defined(GLFW_PLATFORM_WAYLAND) && defined(DAWN_USE_WAYLAND)
|
||||||
case GLFW_PLATFORM_WAYLAND: {
|
if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) {
|
||||||
std::unique_ptr<wgpu::SurfaceDescriptorFromWaylandSurface> desc =
|
std::unique_ptr<wgpu::SurfaceDescriptorFromWaylandSurface> desc =
|
||||||
std::make_unique<wgpu::SurfaceDescriptorFromWaylandSurface>();
|
std::make_unique<wgpu::SurfaceDescriptorFromWaylandSurface>();
|
||||||
desc->display = glfwGetWaylandDisplay();
|
desc->display = glfwGetWaylandDisplay();
|
||||||
desc->surface = glfwGetWaylandWindow(window);
|
desc->surface = glfwGetWaylandWindow(window);
|
||||||
return std::move(desc);
|
return std::move(desc);
|
||||||
}
|
} else // NOLINT(readability/braces)
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_USE_X11)
|
#if defined(DAWN_USE_X11)
|
||||||
case GLFW_PLATFORM_X11: {
|
{
|
||||||
std::unique_ptr<wgpu::SurfaceDescriptorFromXlibWindow> desc =
|
std::unique_ptr<wgpu::SurfaceDescriptorFromXlibWindow> desc =
|
||||||
std::make_unique<wgpu::SurfaceDescriptorFromXlibWindow>();
|
std::make_unique<wgpu::SurfaceDescriptorFromXlibWindow>();
|
||||||
desc->display = glfwGetX11Display();
|
desc->display = glfwGetX11Display();
|
||||||
desc->window = glfwGetX11Window(window);
|
desc->window = glfwGetX11Window(window);
|
||||||
return std::move(desc);
|
return std::move(desc);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
{ return nullptr; }
|
||||||
#endif
|
#endif
|
||||||
default:
|
#else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
Loading…
Reference in New Issue