[dawn] fix quickstart with cmake example
Change-Id: Ie0793b2fc396e02e0aa37430058dcc6c89b0ccb2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/230234
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/docs/quickstart-cmake.md b/docs/quickstart-cmake.md
index fc9513d..113aa18 100644
--- a/docs/quickstart-cmake.md
+++ b/docs/quickstart-cmake.md
@@ -79,20 +79,19 @@
// Synchronously request the adapter.
wgpu::RequestAdapterOptions options = {};
wgpu::Adapter adapter;
- wgpu::RequestAdapterCallbackInfo callbackInfo = {};
- callbackInfo.nextInChain = nullptr;
- callbackInfo.mode = wgpu::CallbackMode::WaitAnyOnly;
- callbackInfo.callback = [](WGPURequestAdapterStatus status,
- WGPUAdapter adapter, const char *message,
- void *userdata) {
- if (status != WGPURequestAdapterStatus_Success) {
+
+ auto callback = [](wgpu::RequestAdapterStatus status, wgpu::Adapter adapter, const char *message, void *userdata) {
+ if (status != wgpu::RequestAdapterStatus::Success) {
std::cerr << "Failed to get an adapter:" << message;
return;
}
- *static_cast<wgpu::Adapter *>(userdata) = wgpu::Adapter::Acquire(adapter);
+ *static_cast<wgpu::Adapter *>(userdata) = adapter;
};
- callbackInfo.userdata = &adapter;
- instance.WaitAny(instance.RequestAdapter(&options, callbackInfo), UINT64_MAX);
+
+
+ auto callbackMode = wgpu::CallbackMode::WaitAnyOnly;
+ void *userdata = &adapter;
+ instance.WaitAny(instance.RequestAdapter(&options, callbackMode, callback, userdata), UINT64_MAX);
if (adapter == nullptr) {
std::cerr << "RequestAdapter failed!\n";
return EXIT_FAILURE;
diff --git a/include/webgpu/webgpu_cpp_print.h b/include/webgpu/webgpu_cpp_print.h
new file mode 100644
index 0000000..da922f8
--- /dev/null
+++ b/include/webgpu/webgpu_cpp_print.h
@@ -0,0 +1,33 @@
+// Copyright 2025 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef INCLUDE_WEBGPU_WEBGPU_CPP_PRINT_H_
+#define INCLUDE_WEBGPU_WEBGPU_CPP_PRINT_H_
+
+#include "dawn/webgpu_cpp_print.h"
+
+#endif // INCLUDE_WEBGPU_WEBGPU_CPP_PRINT_H_
diff --git a/src/dawn/CMakeLists.txt b/src/dawn/CMakeLists.txt
index 316414a..8ca696d 100644
--- a/src/dawn/CMakeLists.txt
+++ b/src/dawn/CMakeLists.txt
@@ -67,6 +67,7 @@
UTILITY_TARGET dawn_internal_config
HEADERS
"${DAWN_INCLUDE_DIR}/webgpu/webgpu_cpp.h"
+ "${DAWN_INCLUDE_DIR}/webgpu/webgpu_cpp_print.h"
"${DAWN_INCLUDE_DIR}/webgpu/webgpu_enum_class_bitmasks.h"
${DAWNCPP_HEADERS_GEN_HEADERS}
DEPENDS