Check no GL context is created on the GLFW window.
While forgoing GLFW_NO_API might work on some OSes (macOS) it will
cause issues on others (Linux and Vulkan) so we should validate that
the user of webgpu_glfw doesn't forget to set that hint.
Bug: dawn:1910
Change-Id: I087b927731655c5f8f2ddd7be3c16c723b8589ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/140400
Commit-Queue: Fr <beaufort.francois@gmail.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/glfw/utils.cpp b/src/dawn/glfw/utils.cpp
index 3a123ad..01e8fd7 100644
--- a/src/dawn/glfw/utils.cpp
+++ b/src/dawn/glfw/utils.cpp
@@ -17,6 +17,7 @@
#include <utility>
#include "GLFW/glfw3.h"
+#include "dawn/common/Log.h"
#include "dawn/common/Platform.h"
#include "webgpu/webgpu_glfw.h"
@@ -48,6 +49,11 @@
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorCocoa(GLFWwindow* window);
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(GLFWwindow* window) {
+ if (glfwGetWindowAttrib(window, GLFW_CLIENT_API) != GLFW_NO_API) {
+ dawn::ErrorLog() << "GL context was created on the window. Disable context creation by "
+ "setting the GLFW_CLIENT_API hint to GLFW_NO_API.";
+ return nullptr;
+ }
#if DAWN_PLATFORM_IS(WINDOWS)
std::unique_ptr<wgpu::SurfaceDescriptorFromWindowsHWND> desc =
std::make_unique<wgpu::SurfaceDescriptorFromWindowsHWND>();