[dawn] Remove old overridden non-Future entries.
- Removes/renames remaining non-future entry points such as
- RequestAdapter
- RequestDevice
- Note that these are removed with a corresponding #define
macro to properly remove them in dependencies that may
directly override them in the proc table.
Bug: 369445924
Change-Id: I01f5dbad9cbaf97a90be2baa208993feb805ba3e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/218697
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
diff --git a/generator/templates/api.h b/generator/templates/api.h
index 132be07..0d764e6 100644
--- a/generator/templates/api.h
+++ b/generator/templates/api.h
@@ -40,6 +40,7 @@
#define WGPU_BREAKING_CHANGE_STRING_VIEW_LABELS
#define WGPU_BREAKING_CHANGE_STRING_VIEW_OUTPUT_STRUCTS
#define WGPU_BREAKING_CHANGE_STRING_VIEW_CALLBACKS
+#define WGPU_BREAKING_CHANGE_FUTURE_CALLBACK_TYPES
{% set API = metadata.c_prefix %}
#if defined({{API}}_SHARED_LIBRARY)
diff --git a/generator/templates/api_cpp.h b/generator/templates/api_cpp.h
index cf4a9e2..55a2c8e 100644
--- a/generator/templates/api_cpp.h
+++ b/generator/templates/api_cpp.h
@@ -524,7 +524,7 @@
} // namespace detail
//* Special callbacks that require some custom code generation.
-{% set SpecialCallbacks = ["device lost callback 2", "uncaptured error callback"] %}
+{% set SpecialCallbacks = ["device lost callback", "uncaptured error callback"] %}
{% for type in by_category["callback function"] if type.name.get() not in SpecialCallbacks %}
template <typename... T>
@@ -536,7 +536,7 @@
>, T...>::Callback;
{% endfor %}
template <typename... T>
-using DeviceLostCallback2 = typename detail::CallbackTypeBase<std::tuple<const Device&, DeviceLostReason, StringView>, T...>::Callback;
+using DeviceLostCallback = typename detail::CallbackTypeBase<std::tuple<const Device&, DeviceLostReason, StringView>, T...>::Callback;
template <typename... T>
using UncapturedErrorCallback = typename detail::CallbackTypeBase<std::tuple<const Device&, ErrorType, StringView>, T...>::Callback;
@@ -805,13 +805,13 @@
inline {{CppType}}(Init&& init);
template <typename F, typename T,
- typename Cb = DeviceLostCallback2<T>,
+ typename Cb = DeviceLostCallback<T>,
//* TODO(42241188): Remove once all clients use StringView versions of the callbacks
typename CbChar = void (const Device& device, DeviceLostReason reason, const char* message, T userdata),
typename = std::enable_if_t<std::is_convertible_v<F, Cb*> || std::is_convertible_v<F, CbChar*>>>
void SetDeviceLostCallback(CallbackMode callbackMode, F callback, T userdata);
template <typename L,
- typename Cb = DeviceLostCallback2<>,
+ typename Cb = DeviceLostCallback<>,
//* TODO(42241188): Remove once all clients use StringView versions of the callbacks
typename CbChar = std::function<void(const Device& device, DeviceLostReason reason, const char* message)>,
typename = std::enable_if_t<std::is_convertible_v<L, Cb> || std::is_convertible_v<L, CbChar>>>
@@ -970,11 +970,11 @@
template <typename F, typename T, typename Cb, typename CbChar, typename>
void {{CppType}}::SetDeviceLostCallback(CallbackMode callbackMode, F callback, T userdata) {
- assert(deviceLostCallbackInfo2.callback == nullptr);
+ assert(deviceLostCallbackInfo.callback == nullptr);
- deviceLostCallbackInfo2.mode = static_cast<WGPUCallbackMode>(callbackMode);
+ deviceLostCallbackInfo.mode = static_cast<WGPUCallbackMode>(callbackMode);
if constexpr (std::is_convertible_v<F, Cb*>) {
- deviceLostCallbackInfo2.callback = [](WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, void* callback_param, void* userdata_param) {
+ deviceLostCallbackInfo.callback = [](WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, void* callback_param, void* userdata_param) {
auto cb = reinterpret_cast<Cb*>(callback_param);
// We manually acquire and release the device to avoid changing any ref counts.
auto apiDevice = Device::Acquire(*device);
@@ -983,7 +983,7 @@
};
} else {
//* TODO(42241188): Remove once all clients use StringView versions of the callbacks
- deviceLostCallbackInfo2.callback = [](WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, void* callback_param, void* userdata_param) {
+ deviceLostCallbackInfo.callback = [](WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, void* callback_param, void* userdata_param) {
auto cb = reinterpret_cast<CbChar*>(callback_param);
// We manually acquire and release the device to avoid changing any ref counts.
auto apiDevice = Device::Acquire(*device);
@@ -991,44 +991,44 @@
apiDevice.MoveToCHandle();
};
}
- deviceLostCallbackInfo2.userdata1 = reinterpret_cast<void*>(+callback);
- deviceLostCallbackInfo2.userdata2 = reinterpret_cast<void*>(userdata);
+ deviceLostCallbackInfo.userdata1 = reinterpret_cast<void*>(+callback);
+ deviceLostCallbackInfo.userdata2 = reinterpret_cast<void*>(userdata);
}
template <typename L, typename Cb, typename CbChar, typename>
void {{CppType}}::SetDeviceLostCallback(CallbackMode callbackMode, L callback) {
- assert(deviceLostCallbackInfo2.callback == nullptr);
- using F = DeviceLostCallback2<void>;
+ assert(deviceLostCallbackInfo.callback == nullptr);
+ using F = DeviceLostCallback<void>;
- deviceLostCallbackInfo2.mode = static_cast<WGPUCallbackMode>(callbackMode);
+ deviceLostCallbackInfo.mode = static_cast<WGPUCallbackMode>(callbackMode);
if constexpr (std::is_convertible_v<L, F*>) {
- deviceLostCallbackInfo2.callback = [](WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, void* callback_param, void*) {
+ deviceLostCallbackInfo.callback = [](WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, void* callback_param, void*) {
auto cb = reinterpret_cast<F*>(callback_param);
// We manually acquire and release the device to avoid changing any ref counts.
auto apiDevice = Device::Acquire(*device);
(*cb)(apiDevice, static_cast<DeviceLostReason>(reason), message);
apiDevice.MoveToCHandle();
};
- deviceLostCallbackInfo2.userdata1 = reinterpret_cast<void*>(+callback);
- deviceLostCallbackInfo2.userdata2 = nullptr;
+ deviceLostCallbackInfo.userdata1 = reinterpret_cast<void*>(+callback);
+ deviceLostCallbackInfo.userdata2 = nullptr;
} else {
auto* lambda = new L(std::move(callback));
- deviceLostCallbackInfo2.callback = [](WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, void* callback_param, void*) {
+ deviceLostCallbackInfo.callback = [](WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, void* callback_param, void*) {
std::unique_ptr<L> the_lambda(reinterpret_cast<L*>(callback_param));
// We manually acquire and release the device to avoid changing any ref counts.
auto apiDevice = Device::Acquire(*device);
(*the_lambda)(apiDevice, static_cast<DeviceLostReason>(reason), detail::StringViewAdapter(message));
apiDevice.MoveToCHandle();
};
- deviceLostCallbackInfo2.userdata1 = reinterpret_cast<void*>(lambda);
- deviceLostCallbackInfo2.userdata2 = nullptr;
+ deviceLostCallbackInfo.userdata1 = reinterpret_cast<void*>(lambda);
+ deviceLostCallbackInfo.userdata2 = nullptr;
}
}
template <typename F, typename T, typename Cb, typename CbChar, typename>
void {{CppType}}::SetUncapturedErrorCallback(F callback, T userdata) {
if constexpr (std::is_convertible_v<F, Cb*>) {
- uncapturedErrorCallbackInfo2.callback = [](WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, void* callback_param, void* userdata_param) {
+ uncapturedErrorCallbackInfo.callback = [](WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, void* callback_param, void* userdata_param) {
auto cb = reinterpret_cast<Cb*>(callback_param);
// We manually acquire and release the device to avoid changing any ref counts.
auto apiDevice = Device::Acquire(*device);
@@ -1037,7 +1037,7 @@
};
} else {
//* TODO(42241188): Remove once all clients use StringView versions of the callbacks
- uncapturedErrorCallbackInfo2.callback = [](WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, void* callback_param, void* userdata_param) {
+ uncapturedErrorCallbackInfo.callback = [](WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, void* callback_param, void* userdata_param) {
auto cb = reinterpret_cast<CbChar*>(callback_param);
// We manually acquire and release the device to avoid changing any ref counts.
auto apiDevice = Device::Acquire(*device);
@@ -1045,8 +1045,8 @@
apiDevice.MoveToCHandle();
};
}
- uncapturedErrorCallbackInfo2.userdata1 = reinterpret_cast<void*>(+callback);
- uncapturedErrorCallbackInfo2.userdata2 = reinterpret_cast<void*>(userdata);
+ uncapturedErrorCallbackInfo.userdata1 = reinterpret_cast<void*>(+callback);
+ uncapturedErrorCallbackInfo.userdata2 = reinterpret_cast<void*>(userdata);
}
template <typename L, typename Cb, typename CbChar, typename>
@@ -1056,7 +1056,7 @@
static_assert(std::is_convertible_v<L, F*> || std::is_convertible_v<L, FChar*>, "Uncaptured error callback cannot be a binding lambda");
if constexpr (std::is_convertible_v<L, F*>) {
- uncapturedErrorCallbackInfo2.callback = [](WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, void* callback_param, void*) {
+ uncapturedErrorCallbackInfo.callback = [](WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, void* callback_param, void*) {
auto cb = reinterpret_cast<F*>(callback_param);
// We manually acquire and release the device to avoid changing any ref counts.
auto apiDevice = Device::Acquire(*device);
@@ -1065,7 +1065,7 @@
};
} else {
//* TODO(42241188): Remove once all clients use StringView versions of the callbacks
- uncapturedErrorCallbackInfo2.callback = [](WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, void* callback_param, void*) {
+ uncapturedErrorCallbackInfo.callback = [](WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, void* callback_param, void*) {
auto cb = reinterpret_cast<FChar*>(callback_param);
// We manually acquire and release the device to avoid changing any ref counts.
auto apiDevice = Device::Acquire(*device);
@@ -1073,8 +1073,8 @@
apiDevice.MoveToCHandle();
};
}
- uncapturedErrorCallbackInfo2.userdata1 = reinterpret_cast<void*>(+callback);
- uncapturedErrorCallbackInfo2.userdata2 = nullptr;
+ uncapturedErrorCallbackInfo.userdata1 = reinterpret_cast<void*>(+callback);
+ uncapturedErrorCallbackInfo.userdata2 = nullptr;
}
#if defined(__GNUC__) || defined(__clang__)
diff --git a/generator/templates/mock_api.cpp b/generator/templates/mock_api.cpp
index e976aef..2f304b8 100644
--- a/generator/templates/mock_api.cpp
+++ b/generator/templates/mock_api.cpp
@@ -79,11 +79,8 @@
//* - setLoggingCallback
{% set LegacyCallbackFunctions = ['set logging callback'] %}
-//* Manually implemented mock functions due to incompatibility.
-{% set ManuallyMockedFunctions = ['set device lost callback', 'set uncaptured error callback'] %}
-
{% for type in by_category["object"] %}
- {% for method in type.methods if method.name.get() not in ManuallyMockedFunctions %}
+ {% for method in type.methods %}
{% set Suffix = as_CppMethodSuffix(type.name, method.name) %}
{% if has_callback_arguments(method) %}
{{as_cType(method.return_type.name)}} ProcTableAsClass::{{Suffix}}(
@@ -220,50 +217,12 @@
{% endfor %}
// Manually implement some callback helpers for testing.
-void ProcTableAsClass::DeviceSetDeviceLostCallback(WGPUDevice device,
- WGPUDeviceLostCallback callback,
- void* userdata) {
- ProcTableAsClass::Object* object = reinterpret_cast<ProcTableAsClass::Object*>(device);
- object->mDeviceLostCallback = [](WGPUDevice const*, WGPUDeviceLostReason reason,
- WGPUStringView message, void* callback, void* userdata) {
- if (callback == nullptr) {
- return;
- }
- auto cb = reinterpret_cast<WGPUDeviceLostCallback>(callback);
- cb(reason, message, userdata);
- };
- object->mDeviceLostUserdata1 = reinterpret_cast<void*>(callback);
- object->mDeviceLostUserdata2 = userdata;
-
- OnDeviceSetDeviceLostCallback(device, callback, userdata);
-}
-void ProcTableAsClass::CallDeviceSetDeviceLostCallbackCallback(WGPUDevice device,
- WGPUDeviceLostReason reason,
- WGPUStringView message) {
+void ProcTableAsClass::CallDeviceLostCallback(WGPUDevice device, WGPUDeviceLostReason reason, WGPUStringView message) {
ProcTableAsClass::Object* object = reinterpret_cast<ProcTableAsClass::Object*>(device);
object->mDeviceLostCallback(&device, reason, message, object->mDeviceLostUserdata1,
object->mDeviceLostUserdata2);
}
-void ProcTableAsClass::DeviceSetUncapturedErrorCallback(WGPUDevice device,
- WGPUErrorCallback callback,
- void* userdata) {
- ProcTableAsClass::Object* object = reinterpret_cast<ProcTableAsClass::Object*>(device);
- object->mUncapturedErrorCallback = [](WGPUDevice const*, WGPUErrorType type,
- WGPUStringView message, void* callback, void* userdata) {
- if (callback == nullptr) {
- return;
- }
- auto cb = reinterpret_cast<WGPUErrorCallback>(callback);
- cb(type, message, userdata);
- };
- object->mUncapturedErrorUserdata1 = reinterpret_cast<void*>(callback);
- object->mUncapturedErrorUserdata2 = userdata;
-
- OnDeviceSetUncapturedErrorCallback(device, callback, userdata);
-}
-void ProcTableAsClass::CallDeviceSetUncapturedErrorCallbackCallback(WGPUDevice device,
- WGPUErrorType type,
- WGPUStringView message) {
+void ProcTableAsClass::CallDeviceUncapturedErrorCallback(WGPUDevice device, WGPUErrorType type, WGPUStringView message) {
ProcTableAsClass::Object* object = reinterpret_cast<ProcTableAsClass::Object*>(device);
object->mUncapturedErrorCallback(&device, type, message, object->mUncapturedErrorUserdata1,
object->mUncapturedErrorUserdata2);
diff --git a/generator/templates/mock_api.h b/generator/templates/mock_api.h
index f13ebdf..0284bfe 100644
--- a/generator/templates/mock_api.h
+++ b/generator/templates/mock_api.h
@@ -63,14 +63,11 @@
//* - setLoggingCallback
{%- set LegacyCallbackFunctions = ['set logging callback'] %}
- //* Manually implemented mock functions due to incompatibility.
- {% set ManuallyMockedFunctions = ['set device lost callback', 'set uncaptured error callback'] %}
-
{%- for type in by_category["object"] %}
virtual void {{as_MethodSuffix(type.name, Name("add ref"))}}({{as_cType(type.name)}} self) = 0;
virtual void {{as_MethodSuffix(type.name, Name("release"))}}({{as_cType(type.name)}} self) = 0;
- {% for method in type.methods if method.name.get() not in ManuallyMockedFunctions %}
+ {% for method in type.methods %}
{% set Suffix = as_CppMethodSuffix(type.name, method.name) %}
{% if not has_callback_arguments(method) and not has_callback_info(method) and not has_callbackInfoStruct(method) %}
virtual {{as_cType(method.return_type.name)}} {{Suffix}}(
@@ -144,24 +141,8 @@
{% endfor %}
// Manually implement some callback helpers for testing.
- void DeviceSetDeviceLostCallback(WGPUDevice device,
- WGPUDeviceLostCallback callback,
- void* userdata);
- virtual void OnDeviceSetDeviceLostCallback(WGPUDevice device,
- WGPUDeviceLostCallback callback,
- void* userdata) = 0;
- void CallDeviceSetDeviceLostCallbackCallback(WGPUDevice device,
- WGPUDeviceLostReason reason,
- WGPUStringView message);
- void DeviceSetUncapturedErrorCallback(WGPUDevice device,
- WGPUErrorCallback callback,
- void* userdata);
- virtual void OnDeviceSetUncapturedErrorCallback(WGPUDevice device,
- WGPUErrorCallback callback,
- void* userdata) = 0;
- void CallDeviceSetUncapturedErrorCallbackCallback(WGPUDevice device,
- WGPUErrorType type,
- WGPUStringView message);
+ void CallDeviceLostCallback(WGPUDevice device, WGPUDeviceLostReason reason, WGPUStringView message);
+ void CallDeviceUncapturedErrorCallback(WGPUDevice device, WGPUErrorType type, WGPUStringView message);
struct Object {
ProcTableAsClass* procs = nullptr;
@@ -187,7 +168,7 @@
{% endfor %}
{% endfor %}
// Manually implement some callback helpers for testing.
- WGPUDeviceLostCallback2 mDeviceLostCallback = nullptr;
+ WGPUDeviceLostCallback mDeviceLostCallback = nullptr;
void* mDeviceLostUserdata1 = 0;
void* mDeviceLostUserdata2 = 0;
WGPUUncapturedErrorCallback mUncapturedErrorCallback = nullptr;
@@ -242,16 +223,6 @@
), (override));
{% endfor %}
{% endfor %}
-
- // Manually implement some callback helpers for testing.
- MOCK_METHOD(void,
- OnDeviceSetDeviceLostCallback,
- (WGPUDevice device, WGPUDeviceLostCallback callback, void* userdata),
- (override));
- MOCK_METHOD(void,
- OnDeviceSetUncapturedErrorCallback,
- (WGPUDevice device, WGPUErrorCallback callback, void* userdata),
- (override));
};
#endif // MOCK_{{API}}_H
diff --git a/include/dawn/native/DawnNative.h b/include/dawn/native/DawnNative.h
index c6d3efd..cf8e3da 100644
--- a/include/dawn/native/DawnNative.h
+++ b/include/dawn/native/DawnNative.h
@@ -101,18 +101,6 @@
WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor);
WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr);
- void RequestDevice(const wgpu::DeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata);
- void RequestDevice(const WGPUDeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata);
- void RequestDevice(std::nullptr_t descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata) {
- RequestDevice(static_cast<const wgpu::DeviceDescriptor*>(descriptor), callback, userdata);
- }
-
// Returns the underlying WGPUAdapter object.
WGPUAdapter Get() const;
diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json
index ae82f5e..3067c48 100644
--- a/src/dawn/dawn.json
+++ b/src/dawn/dawn.json
@@ -81,15 +81,6 @@
]
},
"request adapter callback": {
- "category": "function pointer",
- "args": [
- {"name": "status", "type": "request adapter status"},
- {"name": "adapter", "type": "adapter", "optional": true},
- {"name": "message", "type": "string view"},
- {"name": "userdata", "type": "void *"}
- ]
- },
- "request adapter callback 2": {
"category": "callback function",
"args": [
{"name": "status", "type": "request adapter status"},
@@ -98,19 +89,10 @@
]
},
"request adapter callback info": {
- "category": "structure",
- "extensible": "in",
- "members": [
- {"name": "mode", "type": "callback mode"},
- {"name": "callback", "type": "request adapter callback"},
- {"name": "userdata", "type": "void *"}
- ]
- },
- "request adapter callback info 2": {
"category": "callback info",
"members": [
{"name": "mode", "type": "callback mode"},
- {"name": "callback", "type": "request adapter callback 2"}
+ {"name": "callback", "type": "request adapter callback"}
]
},
"request adapter status": {
@@ -163,16 +145,6 @@
},
{
"name": "request device",
- "args": [
- {"name": "descriptor", "type": "device descriptor", "annotation": "const*", "optional": true, "no_default": true},
- {"name": "callback", "type": "request device callback"},
- {"name": "userdata", "type": "void *"}
- ]
- },
- {
- "name": "request device f",
- "_comment": "TODO(crbug.com/dawn/2021): This is dawn/emscripten-only until we rename it to replace the old API. See bug for details.",
- "tags": ["dawn", "emscripten"],
"returns": "future",
"args": [
{"name": "options", "type": "device descriptor", "annotation": "const*", "optional": true, "no_default": true},
@@ -180,16 +152,6 @@
]
},
{
- "name": "request device 2",
- "_comment": "TODO(crbug.com/dawn/2021): This is dawn/emscripten-only until we rename it to replace the old API. See bug for details.",
- "tags": ["dawn", "emscripten"],
- "returns": "future",
- "args": [
- {"name": "options", "type": "device descriptor", "annotation": "const*", "optional": true, "no_default": true},
- {"name": "callback info", "type": "request device callback info 2"}
- ]
- },
- {
"name": "create device",
"tags": ["dawn"],
"returns": "device",
@@ -242,8 +204,8 @@
{"name": "required features", "type": "feature name", "annotation": "const*", "length": "required feature count", "default": "nullptr"},
{"name": "required limits", "type": "required limits", "annotation": "const*", "optional": true},
{"name": "default queue", "type": "queue descriptor"},
- {"name": "device lost callback info 2", "type": "device lost callback info 2"},
- {"name": "uncaptured error callback info 2", "type": "uncaptured error callback info 2"}
+ {"name": "device lost callback info", "type": "device lost callback info"},
+ {"name": "uncaptured error callback info", "type": "uncaptured error callback info"}
]
},
"dawn toggles descriptor": {
@@ -1481,23 +1443,6 @@
]
},
"device lost callback": {
- "category": "function pointer",
- "args": [
- {"name": "reason", "type": "device lost reason"},
- {"name": "message", "type": "string view"},
- {"name": "userdata", "type": "void *"}
- ]
- },
- "device lost callback new": {
- "category": "function pointer",
- "args": [
- {"name": "device", "type": "device", "annotation": "const*", "length": 1},
- {"name": "reason", "type": "device lost reason"},
- {"name": "message", "type": "string view"},
- {"name": "userdata", "type": "void *"}
- ]
- },
- "device lost callback 2": {
"category": "callback function",
"args": [
{"name": "device", "type": "device", "annotation": "const*", "length": 1},
@@ -1506,19 +1451,10 @@
]
},
"device lost callback info": {
- "category": "structure",
- "extensible": "in",
- "members": [
- {"name": "mode", "type": "callback mode", "default": "wait any only", "_comment": "TODO(crbug.com/dawn/2458) Default should be removed."},
- {"name": "callback", "type": "device lost callback new", "default": "nullptr"},
- {"name": "userdata", "type": "void *", "default": "nullptr"}
- ]
- },
- "device lost callback info 2": {
"category": "callback info",
"members": [
{"name": "mode", "type": "callback mode"},
- {"name": "callback", "type": "device lost callback 2", "default": "nullptr"}
+ {"name": "callback", "type": "device lost callback", "default": "nullptr"}
]
},
"device lost reason": {
@@ -1536,14 +1472,6 @@
"category": "native",
"wasm type": "d"
},
- "error callback": {
- "category": "function pointer",
- "args": [
- {"name": "type", "type": "error type"},
- {"name": "message", "type": "string view"},
- {"name": "userdata", "type": "void *"}
- ]
- },
"uncaptured error callback": {
"category": "callback function",
"args": [
@@ -1553,14 +1481,6 @@
]
},
"uncaptured error callback info": {
- "category": "structure",
- "extensible": "in",
- "members": [
- {"name": "callback", "type": "error callback", "default": "nullptr"},
- {"name": "userdata", "type": "void *", "default": "nullptr"}
- ]
- },
- "uncaptured error callback info 2": {
"category": "callback info",
"members": [
{"name": "callback", "type": "uncaptured error callback", "default": "nullptr"}
@@ -2445,16 +2365,6 @@
},
{
"name": "request adapter",
- "args": [
- {"name": "options", "type": "request adapter options", "annotation": "const*", "optional": true, "no_default": true},
- {"name": "callback", "type": "request adapter callback"},
- {"name": "userdata", "type": "void *"}
- ]
- },
- {
- "name": "request adapter f",
- "_comment": "TODO(crbug.com/dawn/2021): This is dawn/emscripten-only until we rename it to replace the old API. See bug for details.",
- "tags": ["dawn", "emscripten"],
"returns": "future",
"args": [
{"name": "options", "type": "request adapter options", "annotation": "const*", "optional": true, "no_default": true},
@@ -2462,16 +2372,6 @@
]
},
{
- "name": "request adapter 2",
- "_comment": "TODO(crbug.com/dawn/2021): This is dawn/emscripten-only until we rename it to replace the old API. See bug for details.",
- "tags": ["dawn", "emscripten"],
- "returns": "future",
- "args": [
- {"name": "options", "type": "request adapter options", "annotation": "const*", "optional": true, "no_default": true},
- {"name": "callback info", "type": "request adapter callback info 2"}
- ]
- },
- {
"name": "has WGSL language feature",
"returns": "bool",
"args": [
@@ -3289,16 +3189,6 @@
},
"request device callback": {
- "category": "function pointer",
- "_comment": "crbug.com/1234617: Revisit optional status of device once requestDevice can return lost devices",
- "args": [
- {"name": "status", "type": "request device status"},
- {"name": "device", "type": "device", "optional": true},
- {"name": "message", "type": "string view"},
- {"name": "userdata", "type": "void *"}
- ]
- },
- "request device callback 2": {
"category": "callback function",
"_comment": "crbug.com/1234617: Revisit optional status of device once requestDevice can return lost devices",
"args": [
@@ -3308,19 +3198,10 @@
]
},
"request device callback info": {
- "category": "structure",
- "extensible": "in",
- "members": [
- {"name": "mode", "type": "callback mode"},
- {"name": "callback", "type": "request device callback"},
- {"name": "userdata", "type": "void *"}
- ]
- },
- "request device callback info 2": {
"category": "callback info",
"members": [
{"name": "mode", "type": "callback mode"},
- {"name": "callback", "type": "request device callback 2"}
+ {"name": "callback", "type": "request device callback"}
]
},
diff --git a/src/dawn/dawn_wire.json b/src/dawn/dawn_wire.json
index cc67fcd..74521fd 100644
--- a/src/dawn/dawn_wire.json
+++ b/src/dawn/dawn_wire.json
@@ -113,8 +113,7 @@
{ "name": "event manager handle", "type": "ObjectHandle" },
{ "name": "future", "type": "future" },
{ "name": "adapter object handle", "type": "ObjectHandle", "handle_type": "adapter"},
- { "name": "options", "type": "request adapter options", "annotation": "const*", "optional": true },
- { "name": "userdata count", "type": "uint8_t", "_comment": "TODO(crbug.com/dawn/2509): Remove this once Chromium overrides the correct functions in the proc table."}
+ { "name": "options", "type": "request adapter options", "annotation": "const*", "optional": true }
],
"adapter request device": [
{ "name": "adapter id", "type": "ObjectId", "id_type": "adapter" },
@@ -122,8 +121,7 @@
{ "name": "future", "type": "future" },
{ "name": "device object handle", "type": "ObjectHandle", "handle_type": "device"},
{ "name": "device lost future", "type": "future" },
- { "name": "descriptor", "type": "device descriptor", "annotation": "const*" },
- { "name": "userdata count", "type": "uint8_t", "_comment": "TODO(crbug.com/dawn/2509): Remove this once Chromium overrides the correct functions in the proc table."}
+ { "name": "descriptor", "type": "device descriptor", "annotation": "const*" }
]
},
"return commands": {
@@ -221,8 +219,6 @@
"AdapterGetLimits",
"AdapterHasFeature",
"AdapterRequestDevice",
- "AdapterRequestDeviceF",
- "AdapterRequestDevice2",
"BufferMapAsync",
"BufferGetConstMappedRange",
"BufferGetMappedRange",
@@ -246,8 +242,6 @@
"InstanceHasWGSLLanguageFeature",
"InstanceCreateSurface",
"InstanceRequestAdapter",
- "InstanceRequestAdapterF",
- "InstanceRequestAdapter2",
"ShaderModuleGetCompilationInfo",
"QuerySetGetType",
"QuerySetGetCount",
diff --git a/src/dawn/fuzzers/DawnWireServerFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerFuzzer.cpp
index fcafa6e..00ec774 100644
--- a/src/dawn/fuzzers/DawnWireServerFuzzer.cpp
+++ b/src/dawn/fuzzers/DawnWireServerFuzzer.cpp
@@ -113,10 +113,8 @@
DawnProcTable procs = dawn::native::GetProcs();
// Override requestAdapter to find an adapter that the fuzzer supports.
- // TODO: crbug.com/42241461 - Remove overrides once older entry points are deprecated.
- static constexpr auto RequestAdapter = [](WGPUInstance cInstance,
- WGPURequestAdapterCallback2 callback, void* userdata1,
- void* userdata2) -> WGPUFuture {
+ procs.instanceRequestAdapter = [](WGPUInstance cInstance, const WGPURequestAdapterOptions*,
+ WGPURequestAdapterCallbackInfo callbackInfo) -> WGPUFuture {
std::vector<dawn::native::Adapter> adapters =
dawn::native::Instance(reinterpret_cast<dawn::native::InstanceBase*>(cInstance))
.EnumerateAdapters();
@@ -126,42 +124,17 @@
wgpu::Adapter adapter = cAdapter;
if (sAdapterSupported(adapter)) {
dawn::native::GetProcs().adapterAddRef(cAdapter);
- callback(WGPURequestAdapterStatus_Success, cAdapter, dawn::kEmptyOutputStringView,
- userdata1, userdata2);
+ callbackInfo.callback(WGPURequestAdapterStatus_Success, cAdapter,
+ dawn::kEmptyOutputStringView, callbackInfo.userdata1,
+ callbackInfo.userdata2);
return {};
}
}
- callback(WGPURequestAdapterStatus_Unavailable, nullptr,
- dawn::ToOutputStringView("No supported adapter."), userdata1, userdata2);
+ callbackInfo.callback(WGPURequestAdapterStatus_Unavailable, nullptr,
+ dawn::ToOutputStringView("No supported adapter."),
+ callbackInfo.userdata1, callbackInfo.userdata2);
return {};
};
- procs.instanceRequestAdapter = [](WGPUInstance cInstance, const WGPURequestAdapterOptions*,
- WGPURequestAdapterCallback callback, void* userdata) {
- RequestAdapter(
- cInstance,
- [](WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message,
- void* callback, void* userdata) {
- auto cb = reinterpret_cast<WGPURequestAdapterCallback>(callback);
- cb(status, adapter, message, userdata);
- },
- reinterpret_cast<void*>(callback), userdata);
- };
- procs.instanceRequestAdapterF = [](WGPUInstance cInstance, const WGPURequestAdapterOptions*,
- WGPURequestAdapterCallbackInfo callbackInfo) -> WGPUFuture {
- return RequestAdapter(
- cInstance,
- [](WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message,
- void* callback, void* userdata) {
- auto cb = reinterpret_cast<WGPURequestAdapterCallback>(callback);
- cb(status, adapter, message, userdata);
- },
- reinterpret_cast<void*>(callbackInfo.callback), callbackInfo.userdata);
- };
- procs.instanceRequestAdapter2 = [](WGPUInstance cInstance, const WGPURequestAdapterOptions*,
- WGPURequestAdapterCallbackInfo2 callbackInfo) -> WGPUFuture {
- return RequestAdapter(cInstance, callbackInfo.callback, callbackInfo.userdata1,
- callbackInfo.userdata2);
- };
dawnProcSetProcs(&procs);
diff --git a/src/dawn/native/Adapter.cpp b/src/dawn/native/Adapter.cpp
index 6e26b9f..22e9fcc 100644
--- a/src/dawn/native/Adapter.cpp
+++ b/src/dawn/native/Adapter.cpp
@@ -381,30 +381,10 @@
return {lostEvent, std::move(result)};
}
-void AdapterBase::APIRequestDevice(const DeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata) {
- // Default legacy callback mode for RequestDevice is spontaneous.
- APIRequestDeviceF(descriptor,
- {nullptr, wgpu::CallbackMode::AllowSpontaneous, callback, userdata});
-}
-
-Future AdapterBase::APIRequestDeviceF(const DeviceDescriptor* descriptor,
- const RequestDeviceCallbackInfo& callbackInfo) {
- return APIRequestDevice2(
- descriptor, {ToAPI(callbackInfo.nextInChain), ToAPI(callbackInfo.mode),
- [](WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message,
- void* callback, void* userdata) {
- auto cb = reinterpret_cast<WGPURequestDeviceCallback>(callback);
- cb(status, device, message, userdata);
- },
- reinterpret_cast<void*>(callbackInfo.callback), callbackInfo.userdata});
-}
-
-Future AdapterBase::APIRequestDevice2(const DeviceDescriptor* descriptor,
- const WGPURequestDeviceCallbackInfo2& callbackInfo) {
+Future AdapterBase::APIRequestDevice(const DeviceDescriptor* descriptor,
+ const WGPURequestDeviceCallbackInfo& callbackInfo) {
struct RequestDeviceEvent final : public EventManager::TrackedEvent {
- WGPURequestDeviceCallback2 mCallback;
+ WGPURequestDeviceCallback mCallback;
raw_ptr<void> mUserdata1;
raw_ptr<void> mUserdata2;
@@ -412,7 +392,7 @@
Ref<DeviceBase> mDevice = nullptr;
std::string mMessage;
- RequestDeviceEvent(const WGPURequestDeviceCallbackInfo2& callbackInfo,
+ RequestDeviceEvent(const WGPURequestDeviceCallbackInfo& callbackInfo,
Ref<DeviceBase> device)
: TrackedEvent(static_cast<wgpu::CallbackMode>(callbackInfo.mode),
TrackedEvent::Completed{}),
@@ -422,7 +402,7 @@
mStatus(WGPURequestDeviceStatus_Success),
mDevice(std::move(device)) {}
- RequestDeviceEvent(const WGPURequestDeviceCallbackInfo2& callbackInfo,
+ RequestDeviceEvent(const WGPURequestDeviceCallbackInfo& callbackInfo,
const std::string& message)
: TrackedEvent(static_cast<wgpu::CallbackMode>(callbackInfo.mode),
TrackedEvent::Completed{}),
diff --git a/src/dawn/native/Adapter.h b/src/dawn/native/Adapter.h
index 8a6796f..eb0b3d7 100644
--- a/src/dawn/native/Adapter.h
+++ b/src/dawn/native/Adapter.h
@@ -65,13 +65,8 @@
bool APIHasFeature(wgpu::FeatureName feature) const;
void APIGetFeatures(SupportedFeatures* features) const;
void APIGetFeatures(wgpu::SupportedFeatures* features) const;
- void APIRequestDevice(const DeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata);
- Future APIRequestDeviceF(const DeviceDescriptor* descriptor,
- const RequestDeviceCallbackInfo& callbackInfo);
- Future APIRequestDevice2(const DeviceDescriptor* descriptor,
- const WGPURequestDeviceCallbackInfo2& callbackInfo);
+ Future APIRequestDevice(const DeviceDescriptor* descriptor,
+ const WGPURequestDeviceCallbackInfo& callbackInfo);
DeviceBase* APICreateDevice(const DeviceDescriptor* descriptor = nullptr);
wgpu::Status APIGetFormatCapabilities(wgpu::TextureFormat format,
FormatCapabilities* capabilities);
diff --git a/src/dawn/native/DawnNative.cpp b/src/dawn/native/DawnNative.cpp
index 17fe33d..145e86d 100644
--- a/src/dawn/native/DawnNative.cpp
+++ b/src/dawn/native/DawnNative.cpp
@@ -113,20 +113,6 @@
return ToAPI(mImpl->APICreateDevice(FromAPI(deviceDescriptor)));
}
-void Adapter::RequestDevice(const wgpu::DeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata) {
- mImpl->APIRequestDevice(reinterpret_cast<const DeviceDescriptor*>(descriptor), callback,
- userdata);
-}
-
-void Adapter::RequestDevice(const WGPUDeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata) {
- mImpl->APIRequestDevice(reinterpret_cast<const DeviceDescriptor*>(descriptor), callback,
- userdata);
-}
-
void Adapter::ResetInternalDeviceForTesting() {
[[maybe_unused]] bool hadError = mImpl->GetInstance()->ConsumedError(
mImpl->GetPhysicalDevice()->ResetInternalDeviceForTesting());
diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp
index b332677..e9ad666 100644
--- a/src/dawn/native/Device.cpp
+++ b/src/dawn/native/Device.cpp
@@ -169,12 +169,12 @@
raw_ptr<void> mUserdata;
};
-static constexpr WGPUUncapturedErrorCallbackInfo2 kEmptyUncapturedErrorCallbackInfo = {
+static constexpr WGPUUncapturedErrorCallbackInfo kEmptyUncapturedErrorCallbackInfo = {
nullptr, nullptr, nullptr, nullptr};
} // anonymous namespace
-DeviceBase::DeviceLostEvent::DeviceLostEvent(const WGPUDeviceLostCallbackInfo2& callbackInfo)
+DeviceBase::DeviceLostEvent::DeviceLostEvent(const WGPUDeviceLostCallbackInfo& callbackInfo)
: TrackedEvent(static_cast<wgpu::CallbackMode>(callbackInfo.mode),
SystemEvent::CreateNonProgressingEvent()),
mCallback(callbackInfo.callback),
@@ -191,7 +191,7 @@
DAWN_ASSERT(descriptor != nullptr);
#if defined(DAWN_ENABLE_ASSERTS)
- static constexpr WGPUDeviceLostCallbackInfo2 kDefaultDeviceLostCallbackInfo = {
+ static constexpr WGPUDeviceLostCallbackInfo kDefaultDeviceLostCallbackInfo = {
nullptr, WGPUCallbackMode_AllowSpontaneous,
[](WGPUDevice const*, WGPUDeviceLostReason, WGPUStringView, void*, void*) {
static bool calledOnce = false;
@@ -204,13 +204,13 @@
},
nullptr, nullptr};
#else
- static constexpr WGPUDeviceLostCallbackInfo2 kDefaultDeviceLostCallbackInfo = {
+ static constexpr WGPUDeviceLostCallbackInfo kDefaultDeviceLostCallbackInfo = {
nullptr, WGPUCallbackMode_AllowProcessEvents, nullptr, nullptr, nullptr};
#endif // DAWN_ENABLE_ASSERTS
- WGPUDeviceLostCallbackInfo2 deviceLostCallbackInfo = kDefaultDeviceLostCallbackInfo;
- if (descriptor->deviceLostCallbackInfo2.callback != nullptr) {
- deviceLostCallbackInfo = descriptor->deviceLostCallbackInfo2;
+ WGPUDeviceLostCallbackInfo deviceLostCallbackInfo = kDefaultDeviceLostCallbackInfo;
+ if (descriptor->deviceLostCallbackInfo.callback != nullptr) {
+ deviceLostCallbackInfo = descriptor->deviceLostCallbackInfo;
}
return AcquireRef(new DeviceBase::DeviceLostEvent(deviceLostCallbackInfo));
}
@@ -304,7 +304,7 @@
mLostEvent->mDevice = this;
#if defined(DAWN_ENABLE_ASSERTS)
- static constexpr WGPUUncapturedErrorCallbackInfo2 kDefaultUncapturedErrorCallbackInfo = {
+ static constexpr WGPUUncapturedErrorCallbackInfo kDefaultUncapturedErrorCallbackInfo = {
nullptr,
[](WGPUDevice const*, WGPUErrorType, WGPUStringView, void*, void*) {
static bool calledOnce = false;
@@ -317,12 +317,12 @@
},
nullptr, nullptr};
#else
- static constexpr WGPUUncapturedErrorCallbackInfo2 kDefaultUncapturedErrorCallbackInfo =
+ static constexpr WGPUUncapturedErrorCallbackInfo kDefaultUncapturedErrorCallbackInfo =
kEmptyUncapturedErrorCallbackInfo;
#endif // DAWN_ENABLE_ASSERTS
mUncapturedErrorCallbackInfo = kDefaultUncapturedErrorCallbackInfo;
- if (descriptor->uncapturedErrorCallbackInfo2.callback != nullptr) {
- mUncapturedErrorCallbackInfo = descriptor->uncapturedErrorCallbackInfo2;
+ if (descriptor->uncapturedErrorCallbackInfo.callback != nullptr) {
+ mUncapturedErrorCallbackInfo = descriptor->uncapturedErrorCallbackInfo;
}
AdapterInfo adapterInfo;
@@ -414,8 +414,8 @@
mFormatTable = BuildFormatTable(this);
DeviceDescriptor desc = {};
- desc.deviceLostCallbackInfo2 = {nullptr, WGPUCallbackMode_AllowSpontaneous, nullptr, nullptr,
- nullptr};
+ desc.deviceLostCallbackInfo = {nullptr, WGPUCallbackMode_AllowSpontaneous, nullptr, nullptr,
+ nullptr};
mLostEvent = DeviceLostEvent::Create(&desc);
mLostEvent->mDevice = this;
}
diff --git a/src/dawn/native/Device.h b/src/dawn/native/Device.h
index b6b6d8d..f6883c5 100644
--- a/src/dawn/native/Device.h
+++ b/src/dawn/native/Device.h
@@ -83,12 +83,6 @@
class DeviceBase : public ErrorSink, public RefCountedWithExternalCount<RefCounted> {
public:
struct DeviceLostEvent final : public EventManager::TrackedEvent {
- // TODO(https://crbug.com/dawn/2465): Pass just the DeviceLostCallbackInfo when setters are
- // deprecated. Creates and sets the device lost event for the given device if applicable. If
- // the device is nullptr, an event is still created, but the caller owns the last ref of the
- // event. When passing a device, note that device construction can be successful but fail
- // later at initialization, and this should only be called with the device if initialization
- // was successful.
static Ref<DeviceLostEvent> Create(const DeviceDescriptor* descriptor);
// Event result fields need to be public so that they can easily be updated prior to
@@ -96,14 +90,14 @@
wgpu::DeviceLostReason mReason;
std::string mMessage;
- WGPUDeviceLostCallback2 mCallback = nullptr;
+ WGPUDeviceLostCallback mCallback = nullptr;
raw_ptr<void> mUserdata1;
raw_ptr<void> mUserdata2;
// Note that the device is set when the event is passed to construct a device.
Ref<DeviceBase> mDevice = nullptr;
private:
- explicit DeviceLostEvent(const WGPUDeviceLostCallbackInfo2& callbackInfo);
+ explicit DeviceLostEvent(const WGPUDeviceLostCallbackInfo& callbackInfo);
~DeviceLostEvent() override;
void Complete(EventCompletionType completionType) override;
@@ -285,8 +279,6 @@
bool APITick();
void APIValidateTextureDescriptor(const TextureDescriptor* desc);
- void APISetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata);
- void APISetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata);
void APISetLoggingCallback(wgpu::LoggingCallback callback, void* userdata);
void APIPushErrorScope(wgpu::ErrorFilter filter);
Future APIPopErrorScope(const WGPUPopErrorScopeCallbackInfo& callbackInfo);
@@ -538,7 +530,7 @@
const TextureCopy& dst,
const Extent3D& copySizePixels) = 0;
- WGPUUncapturedErrorCallbackInfo2 mUncapturedErrorCallbackInfo;
+ WGPUUncapturedErrorCallbackInfo mUncapturedErrorCallbackInfo;
std::shared_mutex mLoggingMutex;
wgpu::LoggingCallback mLoggingCallback = nullptr;
diff --git a/src/dawn/native/Instance.cpp b/src/dawn/native/Instance.cpp
index eb108ef..065b9f9 100644
--- a/src/dawn/native/Instance.cpp
+++ b/src/dawn/native/Instance.cpp
@@ -264,35 +264,15 @@
return {};
}
-void InstanceBase::APIRequestAdapter(const RequestAdapterOptions* options,
- WGPURequestAdapterCallback callback,
- void* userdata) {
- APIRequestAdapterF(
- options, RequestAdapterCallbackInfo{nullptr, wgpu::CallbackMode::AllowSpontaneous, callback,
- userdata});
-}
-
-Future InstanceBase::APIRequestAdapterF(const RequestAdapterOptions* options,
- const RequestAdapterCallbackInfo& callbackInfo) {
- return APIRequestAdapter2(
- options, {ToAPI(callbackInfo.nextInChain), ToAPI(callbackInfo.mode),
- [](WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message,
- void* callback, void* userdata) {
- auto cb = reinterpret_cast<WGPURequestAdapterCallback>(callback);
- cb(status, adapter, message, userdata);
- },
- reinterpret_cast<void*>(callbackInfo.callback), callbackInfo.userdata});
-}
-
-Future InstanceBase::APIRequestAdapter2(const RequestAdapterOptions* options,
- const WGPURequestAdapterCallbackInfo2& callbackInfo) {
+Future InstanceBase::APIRequestAdapter(const RequestAdapterOptions* options,
+ const WGPURequestAdapterCallbackInfo& callbackInfo) {
struct RequestAdapterEvent final : public EventManager::TrackedEvent {
- WGPURequestAdapterCallback2 mCallback;
+ WGPURequestAdapterCallback mCallback;
raw_ptr<void> mUserdata1;
raw_ptr<void> mUserdata2;
Ref<AdapterBase> mAdapter;
- RequestAdapterEvent(const WGPURequestAdapterCallbackInfo2& callbackInfo,
+ RequestAdapterEvent(const WGPURequestAdapterCallbackInfo& callbackInfo,
Ref<AdapterBase> adapter)
: TrackedEvent(static_cast<wgpu::CallbackMode>(callbackInfo.mode),
TrackedEvent::Completed{}),
@@ -304,20 +284,22 @@
~RequestAdapterEvent() override { EnsureComplete(EventCompletionType::Shutdown); }
void Complete(EventCompletionType completionType) override {
+ void* userdata1 = mUserdata1.ExtractAsDangling();
+ void* userdata2 = mUserdata2.ExtractAsDangling();
+
if (completionType == EventCompletionType::Shutdown) {
mCallback(WGPURequestAdapterStatus_InstanceDropped, nullptr, kEmptyOutputStringView,
- mUserdata1.ExtractAsDangling(), mUserdata2.ExtractAsDangling());
+ userdata1, userdata2);
return;
}
WGPUAdapter adapter = ToAPI(ReturnToAPI(std::move(mAdapter)));
if (adapter == nullptr) {
mCallback(WGPURequestAdapterStatus_Unavailable, nullptr,
- ToOutputStringView("No supported adapters"),
- mUserdata1.ExtractAsDangling(), mUserdata2.ExtractAsDangling());
+ ToOutputStringView("No supported adapters"), userdata1, userdata2);
} else {
mCallback(WGPURequestAdapterStatus_Success, adapter, kEmptyOutputStringView,
- mUserdata1.ExtractAsDangling(), mUserdata2.ExtractAsDangling());
+ userdata1, userdata2);
}
}
};
diff --git a/src/dawn/native/Instance.h b/src/dawn/native/Instance.h
index 01e4099..1438565 100644
--- a/src/dawn/native/Instance.h
+++ b/src/dawn/native/Instance.h
@@ -75,13 +75,8 @@
public:
static ResultOrError<Ref<InstanceBase>> Create(const InstanceDescriptor* descriptor = nullptr);
- void APIRequestAdapter(const RequestAdapterOptions* options,
- WGPURequestAdapterCallback callback,
- void* userdata);
- Future APIRequestAdapterF(const RequestAdapterOptions* options,
- const RequestAdapterCallbackInfo& callbackInfo);
- Future APIRequestAdapter2(const RequestAdapterOptions* options,
- const WGPURequestAdapterCallbackInfo2& callbackInfo);
+ Future APIRequestAdapter(const RequestAdapterOptions* options,
+ const WGPURequestAdapterCallbackInfo& callbackInfo);
// Discovers and returns a vector of adapters.
// All systems adapters that can be found are returned if no options are passed.
diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp
index 2a127ad..3f05287 100644
--- a/src/dawn/tests/DawnTest.cpp
+++ b/src/dawn/tests/DawnTest.cpp
@@ -727,8 +727,8 @@
// Override procs to provide harness-specific behavior to always select the adapter required in
// testing parameter, and to allow fixture-specific overriding of the test device with
// CreateDeviceImpl.
- procs.instanceRequestAdapter2 = [](WGPUInstance cInstance, const WGPURequestAdapterOptions*,
- WGPURequestAdapterCallbackInfo2 callbackInfo) -> WGPUFuture {
+ procs.instanceRequestAdapter = [](WGPUInstance cInstance, const WGPURequestAdapterOptions*,
+ WGPURequestAdapterCallbackInfo callbackInfo) -> WGPUFuture {
DAWN_ASSERT(gCurrentTest);
DAWN_ASSERT(callbackInfo.mode == WGPUCallbackMode_AllowSpontaneous);
@@ -774,8 +774,8 @@
return {0};
};
- procs.adapterRequestDevice2 = [](WGPUAdapter cAdapter, const WGPUDeviceDescriptor* descriptor,
- WGPURequestDeviceCallbackInfo2 callbackInfo) -> WGPUFuture {
+ procs.adapterRequestDevice = [](WGPUAdapter cAdapter, const WGPUDeviceDescriptor* descriptor,
+ WGPURequestDeviceCallbackInfo callbackInfo) -> WGPUFuture {
DAWN_ASSERT(gCurrentTest);
DAWN_ASSERT(callbackInfo.mode == WGPUCallbackMode_AllowSpontaneous);
diff --git a/src/dawn/tests/DawnTest.h b/src/dawn/tests/DawnTest.h
index 1757aa7..d964f82 100644
--- a/src/dawn/tests/DawnTest.h
+++ b/src/dawn/tests/DawnTest.h
@@ -346,7 +346,7 @@
// printed to stdout.
testing::StrictMock<testing::MockCppCallback<wgpu::UncapturedErrorCallback<void>*>>
mDeviceErrorCallback;
- testing::StrictMock<testing::MockCppCallback<wgpu::DeviceLostCallback2<void>*>>
+ testing::StrictMock<testing::MockCppCallback<wgpu::DeviceLostCallback<void>*>>
mDeviceLostCallback;
// Helper methods to implement the EXPECT_ macros
diff --git a/src/dawn/tests/end2end/AdapterCreationTests.cpp b/src/dawn/tests/end2end/AdapterCreationTests.cpp
index 432593f..3fd5908 100644
--- a/src/dawn/tests/end2end/AdapterCreationTests.cpp
+++ b/src/dawn/tests/end2end/AdapterCreationTests.cpp
@@ -51,7 +51,7 @@
using testing::StrictMock;
using testing::WithArg;
-using MockRequestAdapterCallback = MockCppCallback<wgpu::RequestAdapterCallback2<void>*>;
+using MockRequestAdapterCallback = MockCppCallback<wgpu::RequestAdapterCallback<void>*>;
class AdapterCreationTest : public ::testing::TestWithParam<wgpu::CallbackMode> {
protected:
diff --git a/src/dawn/tests/end2end/EventTests.cpp b/src/dawn/tests/end2end/EventTests.cpp
index 2ed3d40..5fd0d92 100644
--- a/src/dawn/tests/end2end/EventTests.cpp
+++ b/src/dawn/tests/end2end/EventTests.cpp
@@ -46,10 +46,10 @@
wgpu::Device CreateExtraDevice(wgpu::Instance instance) {
// IMPORTANT: DawnTest overrides RequestAdapter and RequestDevice and mixes
// up the two instances. We use these to bypass the override.
- auto* requestAdapter = reinterpret_cast<WGPUProcInstanceRequestAdapter2>(
- wgpu::GetProcAddress("wgpuInstanceRequestAdapter2"));
- auto* requestDevice = reinterpret_cast<WGPUProcAdapterRequestDevice2>(
- wgpu::GetProcAddress("wgpuAdapterRequestDevice2"));
+ auto* requestAdapter = reinterpret_cast<WGPUProcInstanceRequestAdapter>(
+ wgpu::GetProcAddress("wgpuInstanceRequestAdapter"));
+ auto* requestDevice = reinterpret_cast<WGPUProcAdapterRequestDevice>(
+ wgpu::GetProcAddress("wgpuAdapterRequestDevice"));
wgpu::Adapter adapter2;
requestAdapter(instance.Get(), nullptr,
diff --git a/src/dawn/tests/unittests/native/DeviceCreationTests.cpp b/src/dawn/tests/unittests/native/DeviceCreationTests.cpp
index 91f842e..8106a47 100644
--- a/src/dawn/tests/unittests/native/DeviceCreationTests.cpp
+++ b/src/dawn/tests/unittests/native/DeviceCreationTests.cpp
@@ -299,7 +299,7 @@
}
}
- MockCppCallback<wgpu::RequestDeviceCallback2<void>*> mMockCb;
+ MockCppCallback<wgpu::RequestDeviceCallback<void>*> mMockCb;
};
INSTANTIATE_TEST_SUITE_P(,
diff --git a/src/dawn/tests/unittests/native/mocks/DawnMockTest.h b/src/dawn/tests/unittests/native/mocks/DawnMockTest.h
index a6a2014..3e45dd5 100644
--- a/src/dawn/tests/unittests/native/mocks/DawnMockTest.h
+++ b/src/dawn/tests/unittests/native/mocks/DawnMockTest.h
@@ -53,7 +53,7 @@
// Device mock callbacks used throughout the tests.
testing::StrictMock<testing::MockCppCallback<wgpu::UncapturedErrorCallback<void>*>>
mDeviceErrorCallback;
- testing::StrictMock<testing::MockCppCallback<wgpu::DeviceLostCallback2<void>*>>
+ testing::StrictMock<testing::MockCppCallback<wgpu::DeviceLostCallback<void>*>>
mDeviceLostCallback;
TogglesState mDeviceToggles;
diff --git a/src/dawn/tests/unittests/validation/ValidationTest.cpp b/src/dawn/tests/unittests/validation/ValidationTest.cpp
index 0aa5e09..c6ff2fe 100644
--- a/src/dawn/tests/unittests/validation/ValidationTest.cpp
+++ b/src/dawn/tests/unittests/validation/ValidationTest.cpp
@@ -110,29 +110,29 @@
// Forward to dawn::native instanceRequestAdapter, but save the returned adapter in
// gCurrentTest->mBackendAdapter.
- procs.instanceRequestAdapter2 = [](WGPUInstance self, const WGPURequestAdapterOptions* options,
- WGPURequestAdapterCallbackInfo2 callbackInfo) -> WGPUFuture {
+ procs.instanceRequestAdapter = [](WGPUInstance self, const WGPURequestAdapterOptions* options,
+ WGPURequestAdapterCallbackInfo callbackInfo) -> WGPUFuture {
DAWN_ASSERT(gCurrentTest);
DAWN_ASSERT(callbackInfo.mode == WGPUCallbackMode_AllowSpontaneous);
- return dawn::native::GetProcs().instanceRequestAdapter2(
+ return dawn::native::GetProcs().instanceRequestAdapter(
self, options,
{nullptr, WGPUCallbackMode_AllowSpontaneous,
[](WGPURequestAdapterStatus status, WGPUAdapter cAdapter, WGPUStringView message,
void* userdata, void*) {
gCurrentTest->mBackendAdapter = dawn::native::FromAPI(cAdapter);
- auto* info = static_cast<WGPURequestAdapterCallbackInfo2*>(userdata);
+ auto* info = static_cast<WGPURequestAdapterCallbackInfo*>(userdata);
info->callback(status, cAdapter, message, info->userdata1, info->userdata2);
delete info;
},
- new WGPURequestAdapterCallbackInfo2(callbackInfo), nullptr});
+ new WGPURequestAdapterCallbackInfo(callbackInfo), nullptr});
};
// Forward to dawn::native instanceRequestAdapter, but save the returned backend device in
// gCurrentTest->mLastCreatedBackendDevice.
- procs.adapterRequestDevice2 = [](WGPUAdapter self, const WGPUDeviceDescriptor* descriptor,
- WGPURequestDeviceCallbackInfo2 callbackInfo) -> WGPUFuture {
+ procs.adapterRequestDevice = [](WGPUAdapter self, const WGPUDeviceDescriptor* descriptor,
+ WGPURequestDeviceCallbackInfo callbackInfo) -> WGPUFuture {
DAWN_ASSERT(gCurrentTest);
DAWN_ASSERT(callbackInfo.mode == WGPUCallbackMode_AllowSpontaneous);
@@ -161,18 +161,18 @@
deviceTogglesDesc.disabledToggles = disabledToggles.data();
deviceTogglesDesc.disabledToggleCount = disabledToggles.size();
- return dawn::native::GetProcs().adapterRequestDevice2(
+ return dawn::native::GetProcs().adapterRequestDevice(
self, reinterpret_cast<WGPUDeviceDescriptor*>(&deviceDesc),
{nullptr, WGPUCallbackMode_AllowSpontaneous,
[](WGPURequestDeviceStatus status, WGPUDevice cDevice, WGPUStringView message,
void* userdata, void*) {
gCurrentTest->mLastCreatedBackendDevice = cDevice;
- auto* info = static_cast<WGPURequestDeviceCallbackInfo2*>(userdata);
+ auto* info = static_cast<WGPURequestDeviceCallbackInfo*>(userdata);
info->callback(status, cDevice, message, info->userdata1, info->userdata2);
delete info;
},
- new WGPURequestDeviceCallbackInfo2(callbackInfo), nullptr});
+ new WGPURequestDeviceCallbackInfo(callbackInfo), nullptr});
};
mWireHelper = dawn::utils::CreateWireHelper(procs, gUseWire, gWireTraceDir.c_str());
diff --git a/src/dawn/tests/unittests/wire/WireAdapterTests.cpp b/src/dawn/tests/unittests/wire/WireAdapterTests.cpp
index f328ccb..0fcdd91 100644
--- a/src/dawn/tests/unittests/wire/WireAdapterTests.cpp
+++ b/src/dawn/tests/unittests/wire/WireAdapterTests.cpp
@@ -52,7 +52,7 @@
using testing::SizedString;
using testing::WithArg;
-using WireAdapterTestBase = WireFutureTest<wgpu::RequestDeviceCallback2<void>*>;
+using WireAdapterTestBase = WireFutureTest<wgpu::RequestDeviceCallback<void>*>;
class WireAdapterTests : public WireAdapterTestBase {
protected:
void RequestDevice(const wgpu::DeviceDescriptor* descriptor) {
@@ -69,15 +69,15 @@
wgpu::DeviceDescriptor desc = {};
RequestDevice(&desc);
- EXPECT_CALL(api, OnAdapterRequestDevice2(apiAdapter, NotNull(), _))
+ EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _))
.WillOnce(WithArg<1>(Invoke([&](const WGPUDeviceDescriptor* apiDesc) {
EXPECT_EQ(apiDesc->label.data, nullptr);
EXPECT_EQ(apiDesc->requiredFeatureCount, 0u);
EXPECT_EQ(apiDesc->requiredLimits, nullptr);
// Call the callback so the test doesn't wait indefinitely.
- api.CallAdapterRequestDevice2Callback(apiAdapter, WGPURequestDeviceStatus_Error,
- nullptr, kEmptyOutputStringView);
+ api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Error, nullptr,
+ kEmptyOutputStringView);
})));
FlushClient();
FlushFutures();
@@ -92,15 +92,15 @@
TEST_P(WireAdapterTests, RequestDeviceNullDescriptor) {
RequestDevice(nullptr);
- EXPECT_CALL(api, OnAdapterRequestDevice2(apiAdapter, NotNull(), _))
+ EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _))
.WillOnce(WithArg<1>(Invoke([&](const WGPUDeviceDescriptor* apiDesc) {
EXPECT_EQ(apiDesc->label.data, nullptr);
EXPECT_EQ(apiDesc->requiredFeatureCount, 0u);
EXPECT_EQ(apiDesc->requiredLimits, nullptr);
// Call the callback so the test doesn't wait indefinitely.
- api.CallAdapterRequestDevice2Callback(apiAdapter, WGPURequestDeviceStatus_Error,
- nullptr, kEmptyOutputStringView);
+ api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Error, nullptr,
+ kEmptyOutputStringView);
})));
FlushClient();
FlushFutures();
@@ -121,22 +121,22 @@
desc.SetUncapturedErrorCallback([](const wgpu::Device&, wgpu::ErrorType, wgpu::StringView) {});
RequestDevice(&desc);
- EXPECT_CALL(api, OnAdapterRequestDevice2(apiAdapter, NotNull(), _))
+ EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _))
.WillOnce(WithArg<1>(Invoke([&](const WGPUDeviceDescriptor* apiDesc) {
EXPECT_STREQ(apiDesc->label.data, desc.label.data);
// The callback should not be passed through to the server, and it should be overridden.
WGPUDeviceDescriptor& inputDesc = *reinterpret_cast<WGPUDeviceDescriptor*>(&desc);
- ASSERT_NE(apiDesc->deviceLostCallbackInfo2.callback,
- inputDesc.deviceLostCallbackInfo2.callback);
- ASSERT_NE(apiDesc->deviceLostCallbackInfo2.callback, nullptr);
- ASSERT_NE(apiDesc->uncapturedErrorCallbackInfo2.callback,
- inputDesc.uncapturedErrorCallbackInfo2.callback);
- ASSERT_NE(apiDesc->uncapturedErrorCallbackInfo2.callback, nullptr);
+ ASSERT_NE(apiDesc->deviceLostCallbackInfo.callback,
+ inputDesc.deviceLostCallbackInfo.callback);
+ ASSERT_NE(apiDesc->deviceLostCallbackInfo.callback, nullptr);
+ ASSERT_NE(apiDesc->uncapturedErrorCallbackInfo.callback,
+ inputDesc.uncapturedErrorCallbackInfo.callback);
+ ASSERT_NE(apiDesc->uncapturedErrorCallbackInfo.callback, nullptr);
// Call the callback so the test doesn't wait indefinitely.
- api.CallAdapterRequestDevice2Callback(apiAdapter, WGPURequestDeviceStatus_Error,
- nullptr, kEmptyOutputStringView);
+ api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Error, nullptr,
+ kEmptyOutputStringView);
})));
FlushClient();
FlushFutures();
@@ -167,7 +167,7 @@
// The backend device should not be known by the wire server.
EXPECT_FALSE(GetWireServer()->IsDeviceKnown(apiDevice));
- EXPECT_CALL(api, OnAdapterRequestDevice2(apiAdapter, NotNull(), _))
+ EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _))
.WillOnce(InvokeWithoutArgs([&] {
// Set on device creation to forward callbacks to the client.
EXPECT_CALL(api, OnDeviceSetLoggingCallback(apiDevice, NotNull(), NotNull())).Times(1);
@@ -185,8 +185,8 @@
// The backend device should still not be known by the wire server since the
// callback has not been called yet.
EXPECT_FALSE(GetWireServer()->IsDeviceKnown(apiDevice));
- api.CallAdapterRequestDevice2Callback(apiAdapter, WGPURequestDeviceStatus_Success,
- apiDevice, kEmptyOutputStringView);
+ api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Success,
+ apiDevice, kEmptyOutputStringView);
// After the callback is called, the backend device is now known by the server.
EXPECT_TRUE(GetWireServer()->IsDeviceKnown(apiDevice));
}));
@@ -259,7 +259,7 @@
// The reply contains features that the device implementation supports, but the
// wire does not.
WGPUDevice apiDevice = api.GetNewDevice();
- EXPECT_CALL(api, OnAdapterRequestDevice2(apiAdapter, NotNull(), _))
+ EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _))
.WillOnce(InvokeWithoutArgs([&] {
EXPECT_CALL(api, DeviceGetFeatures(apiDevice, NotNull()))
.WillOnce(WithArg<1>(
@@ -271,8 +271,8 @@
// Fake successful creation. The client still receives a failure due to
// unsupported features.
- api.CallAdapterRequestDevice2Callback(apiAdapter, WGPURequestDeviceStatus_Success,
- apiDevice, kEmptyOutputStringView);
+ api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Success,
+ apiDevice, kEmptyOutputStringView);
}));
FlushClient();
FlushFutures();
@@ -292,11 +292,10 @@
RequestDevice(&desc);
// Expect the server to receive the message. Then, mock an error.
- EXPECT_CALL(api, OnAdapterRequestDevice2(apiAdapter, NotNull(), _))
+ EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _))
.WillOnce(InvokeWithoutArgs([&] {
- api.CallAdapterRequestDevice2Callback(apiAdapter, WGPURequestDeviceStatus_Error,
- nullptr,
- ToOutputStringView("Request device failed"));
+ api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Error, nullptr,
+ ToOutputStringView("Request device failed"));
}));
FlushClient();
FlushFutures();
@@ -319,15 +318,15 @@
// Mock a reply from the server.
WGPUDevice apiDevice = api.GetNewDevice();
- EXPECT_CALL(api, OnAdapterRequestDevice2(apiAdapter, NotNull(), _))
+ EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _))
.WillOnce(InvokeWithoutArgs([&] {
// Set on device creation to forward callbacks to the client.
EXPECT_CALL(api, OnDeviceSetLoggingCallback(apiDevice, NotNull(), NotNull())).Times(1);
EXPECT_CALL(api, DeviceGetLimits(apiDevice, NotNull())).Times(1);
EXPECT_CALL(api, DeviceGetFeatures(apiDevice, NotNull())).Times(1);
- api.CallAdapterRequestDevice2Callback(apiAdapter, WGPURequestDeviceStatus_Success,
- apiDevice, kEmptyOutputStringView);
+ api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Success,
+ apiDevice, kEmptyOutputStringView);
}));
FlushClient();
FlushFutures();
diff --git a/src/dawn/tests/unittests/wire/WireDeviceLifetimeTests.cpp b/src/dawn/tests/unittests/wire/WireDeviceLifetimeTests.cpp
index 6b174eb..b2d31cf 100644
--- a/src/dawn/tests/unittests/wire/WireDeviceLifetimeTests.cpp
+++ b/src/dawn/tests/unittests/wire/WireDeviceLifetimeTests.cpp
@@ -75,19 +75,19 @@
// backend device separately.
DawnProcTable BuildProcs() {
DawnProcTable procs = native::GetProcs();
- procs.adapterRequestDevice2 = [](WGPUAdapter self, const WGPUDeviceDescriptor* desc,
- WGPURequestDeviceCallbackInfo2 callbackInfo) {
- return native::GetProcs().adapterRequestDevice2(
+ procs.adapterRequestDevice = [](WGPUAdapter self, const WGPUDeviceDescriptor* desc,
+ WGPURequestDeviceCallbackInfo callbackInfo) {
+ return native::GetProcs().adapterRequestDevice(
self, desc,
{nullptr, callbackInfo.mode,
[](WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message,
void* userdata, void*) {
lastBackendDevice = device;
- std::unique_ptr<WGPURequestDeviceCallbackInfo2> info(
- static_cast<WGPURequestDeviceCallbackInfo2*>(userdata));
+ std::unique_ptr<WGPURequestDeviceCallbackInfo> info(
+ static_cast<WGPURequestDeviceCallbackInfo*>(userdata));
info->callback(status, device, message, info->userdata1, info->userdata2);
},
- new WGPURequestDeviceCallbackInfo2(callbackInfo), nullptr});
+ new WGPURequestDeviceCallbackInfo(callbackInfo), nullptr});
};
return procs;
diff --git a/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp b/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp
index a0a1fb6..f35f4b7 100644
--- a/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp
+++ b/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp
@@ -93,8 +93,8 @@
// Check that disconnecting the wire client after a device loss does not trigger the callback
// again.
TEST_F(WireDisconnectTests, ServerLostThenDisconnect) {
- api.CallDeviceSetDeviceLostCallbackCallback(apiDevice, WGPUDeviceLostReason_Unknown,
- ToOutputStringView("some reason"));
+ api.CallDeviceLostCallback(apiDevice, WGPUDeviceLostReason_Unknown,
+ ToOutputStringView("some reason"));
// Flush the device lost return command.
EXPECT_CALL(deviceLostCallback, Call(CHandleIs(device.Get()), wgpu::DeviceLostReason::Unknown,
@@ -109,8 +109,8 @@
// Check that disconnecting the wire client inside the device loss callback does not trigger the
// callback again.
TEST_F(WireDisconnectTests, ServerLostThenDisconnectInCallback) {
- api.CallDeviceSetDeviceLostCallbackCallback(apiDevice, WGPUDeviceLostReason_Unknown,
- ToOutputStringView("lost reason"));
+ api.CallDeviceLostCallback(apiDevice, WGPUDeviceLostReason_Unknown,
+ ToOutputStringView("lost reason"));
// Disconnect the client inside the lost callback. We should see the callback
// only once.
@@ -130,8 +130,8 @@
// Lose the device on the server. The client callback shouldn't be
// called again.
- api.CallDeviceSetDeviceLostCallbackCallback(apiDevice, WGPUDeviceLostReason_Unknown,
- ToOutputStringView("lost reason"));
+ api.CallDeviceLostCallback(apiDevice, WGPUDeviceLostReason_Unknown,
+ ToOutputStringView("lost reason"));
FlushServer();
}
diff --git a/src/dawn/tests/unittests/wire/WireErrorCallbackTests.cpp b/src/dawn/tests/unittests/wire/WireErrorCallbackTests.cpp
index eb6a692..f0e1cc2 100644
--- a/src/dawn/tests/unittests/wire/WireErrorCallbackTests.cpp
+++ b/src/dawn/tests/unittests/wire/WireErrorCallbackTests.cpp
@@ -102,8 +102,8 @@
for (auto type : kErrorTypes) {
// Calling the callback on the server side will result in the callback being called on the
// client side when the server is flushed.
- api.CallDeviceSetUncapturedErrorCallbackCallback(
- apiDevice, static_cast<WGPUErrorType>(type), ToOutputStringView("Some error message"));
+ api.CallDeviceUncapturedErrorCallback(apiDevice, static_cast<WGPUErrorType>(type),
+ ToOutputStringView("Some error message"));
EXPECT_CALL(uncapturedErrorCallback,
Call(CHandleIs(device.Get()), type, SizedString("Some error message")))
.Times(1);
@@ -116,8 +116,8 @@
TEST_F(WireErrorCallbackTests, DeviceLostCallback) {
// Calling the callback on the server side will result in the callback being called on the
// client side when the server is flushed.
- api.CallDeviceSetDeviceLostCallbackCallback(apiDevice, WGPUDeviceLostReason_Unknown,
- ToOutputStringView("Some error message"));
+ api.CallDeviceLostCallback(apiDevice, WGPUDeviceLostReason_Unknown,
+ ToOutputStringView("Some error message"));
EXPECT_CALL(deviceLostCallback, Call(CHandleIs(device.Get()), wgpu::DeviceLostReason::Unknown,
SizedString("Some error message")))
diff --git a/src/dawn/tests/unittests/wire/WireInjectInstanceTests.cpp b/src/dawn/tests/unittests/wire/WireInjectInstanceTests.cpp
index 193f426..3fcf8c2 100644
--- a/src/dawn/tests/unittests/wire/WireInjectInstanceTests.cpp
+++ b/src/dawn/tests/unittests/wire/WireInjectInstanceTests.cpp
@@ -62,9 +62,9 @@
instance.RequestAdapter(nullptr, wgpu::CallbackMode::AllowSpontaneous, adapterCb.Callback(),
adapterCb.MakeUserdata(this));
- EXPECT_CALL(api, OnInstanceRequestAdapter2(apiInstance, _, _)).WillOnce([&]() {
- api.CallInstanceRequestAdapter2Callback(apiInstance, WGPURequestAdapterStatus_Error,
- nullptr, ToOutputStringView("Some error message."));
+ EXPECT_CALL(api, OnInstanceRequestAdapter(apiInstance, _, _)).WillOnce([&]() {
+ api.CallInstanceRequestAdapterCallback(apiInstance, WGPURequestAdapterStatus_Error, nullptr,
+ ToOutputStringView("Some error message."));
});
FlushClient();
diff --git a/src/dawn/tests/unittests/wire/WireInstanceTests.cpp b/src/dawn/tests/unittests/wire/WireInstanceTests.cpp
index 9b4d055..ba9efc3 100644
--- a/src/dawn/tests/unittests/wire/WireInstanceTests.cpp
+++ b/src/dawn/tests/unittests/wire/WireInstanceTests.cpp
@@ -72,7 +72,7 @@
FlushClient();
}
-using WireInstanceTestBase = WireFutureTest<wgpu::RequestAdapterCallback2<void>*>;
+using WireInstanceTestBase = WireFutureTest<wgpu::RequestAdapterCallback<void>*>;
class WireInstanceTests : public WireInstanceTestBase {
protected:
void RequestAdapter(wgpu::RequestAdapterOptions const* options) {
@@ -94,13 +94,13 @@
RequestAdapter(&options);
- EXPECT_CALL(api, OnInstanceRequestAdapter2(apiInstance, NotNull(), _))
+ EXPECT_CALL(api, OnInstanceRequestAdapter(apiInstance, NotNull(), _))
.WillOnce(WithArg<1>(Invoke([&](const WGPURequestAdapterOptions* apiOptions) {
EXPECT_EQ(apiOptions->powerPreference,
static_cast<WGPUPowerPreference>(options.powerPreference));
EXPECT_EQ(apiOptions->forceFallbackAdapter, options.forceFallbackAdapter);
- api.CallInstanceRequestAdapter2Callback(apiInstance, WGPURequestAdapterStatus_Error,
- nullptr, kEmptyOutputStringView);
+ api.CallInstanceRequestAdapterCallback(apiInstance, WGPURequestAdapterStatus_Error,
+ nullptr, kEmptyOutputStringView);
})));
FlushClient();
@@ -140,7 +140,7 @@
// Expect the server to receive the message. Then, mock a fake reply.
WGPUAdapter apiAdapter = api.GetNewAdapter();
- EXPECT_CALL(api, OnInstanceRequestAdapter2(apiInstance, NotNull(), _))
+ EXPECT_CALL(api, OnInstanceRequestAdapter(apiInstance, NotNull(), _))
.WillOnce(InvokeWithoutArgs([&] {
EXPECT_CALL(api, AdapterHasFeature(apiAdapter, _)).WillRepeatedly(Return(false));
@@ -160,8 +160,8 @@
.WillOnce(WithArg<1>(
Invoke([&](WGPUSupportedFeatures* features) { *features = fakeFeatures; })));
- api.CallInstanceRequestAdapter2Callback(apiInstance, WGPURequestAdapterStatus_Success,
- apiAdapter, kEmptyOutputStringView);
+ api.CallInstanceRequestAdapterCallback(apiInstance, WGPURequestAdapterStatus_Success,
+ apiAdapter, kEmptyOutputStringView);
}));
FlushClient();
@@ -247,7 +247,7 @@
// Expect the server to receive the message. Then, mock a fake reply.
WGPUAdapter apiAdapter = api.GetNewAdapter();
- EXPECT_CALL(api, OnInstanceRequestAdapter2(apiInstance, NotNull(), _))
+ EXPECT_CALL(api, OnInstanceRequestAdapter(apiInstance, NotNull(), _))
.WillOnce(InvokeWithoutArgs([&] {
EXPECT_CALL(api, AdapterGetLimits(apiAdapter, NotNull())).Times(1);
EXPECT_CALL(api, AdapterGetFeatures(apiAdapter, NotNull())).Times(1);
@@ -289,8 +289,8 @@
return WGPUStatus_Success;
})));
- api.CallInstanceRequestAdapter2Callback(apiInstance, WGPURequestAdapterStatus_Success,
- apiAdapter, kEmptyOutputStringView);
+ api.CallInstanceRequestAdapterCallback(apiInstance, WGPURequestAdapterStatus_Success,
+ apiAdapter, kEmptyOutputStringView);
}));
FlushClient();
@@ -369,7 +369,7 @@
// Expect the server to receive the message. Then, mock a fake reply.
WGPUAdapter apiAdapter = api.GetNewAdapter();
- EXPECT_CALL(api, OnInstanceRequestAdapter2(apiInstance, NotNull(), _))
+ EXPECT_CALL(api, OnInstanceRequestAdapter(apiInstance, NotNull(), _))
.WillOnce(InvokeWithoutArgs([&] {
EXPECT_CALL(api, AdapterHasFeature(apiAdapter, _)).WillRepeatedly(Return(false));
EXPECT_CALL(api, AdapterGetInfo(apiAdapter, NotNull())).Times(1);
@@ -379,8 +379,8 @@
.WillOnce(WithArg<1>(
Invoke([&](WGPUSupportedFeatures* features) { *features = fakeFeatures; })));
- api.CallInstanceRequestAdapter2Callback(apiInstance, WGPURequestAdapterStatus_Success,
- apiAdapter, kEmptyOutputStringView);
+ api.CallInstanceRequestAdapterCallback(apiInstance, WGPURequestAdapterStatus_Success,
+ apiAdapter, kEmptyOutputStringView);
}));
FlushClient();
@@ -407,10 +407,10 @@
RequestAdapter(&options);
// Expect the server to receive the message. Then, mock an error.
- EXPECT_CALL(api, OnInstanceRequestAdapter2(apiInstance, NotNull(), _))
+ EXPECT_CALL(api, OnInstanceRequestAdapter(apiInstance, NotNull(), _))
.WillOnce(InvokeWithoutArgs([&] {
- api.CallInstanceRequestAdapter2Callback(apiInstance, WGPURequestAdapterStatus_Error,
- nullptr, ToOutputStringView("Some error"));
+ api.CallInstanceRequestAdapterCallback(apiInstance, WGPURequestAdapterStatus_Error,
+ nullptr, ToOutputStringView("Some error"));
}));
FlushClient();
diff --git a/src/dawn/tests/unittests/wire/WireTest.cpp b/src/dawn/tests/unittests/wire/WireTest.cpp
index 95fc06e..3850ff3 100644
--- a/src/dawn/tests/unittests/wire/WireTest.cpp
+++ b/src/dawn/tests/unittests/wire/WireTest.cpp
@@ -99,7 +99,7 @@
instance.RequestAdapter(nullptr, wgpu::CallbackMode::AllowSpontaneous, adapterCb.Callback(),
adapterCb.MakeUserdata(this));
- EXPECT_CALL(api, OnInstanceRequestAdapter2(apiInstance, _, _)).WillOnce([&]() {
+ EXPECT_CALL(api, OnInstanceRequestAdapter(apiInstance, _, _)).WillOnce([&]() {
EXPECT_CALL(api, AdapterHasFeature(apiAdapter, _)).WillRepeatedly(Return(false));
EXPECT_CALL(api, AdapterGetInfo(apiAdapter, NotNull()))
@@ -121,8 +121,8 @@
EXPECT_CALL(api, AdapterGetFeatures(apiAdapter, NotNull()))
.WillOnce(WithArg<1>(Invoke([&](WGPUSupportedFeatures* features) { *features = {}; })));
- api.CallInstanceRequestAdapter2Callback(apiInstance, WGPURequestAdapterStatus_Success,
- apiAdapter, kEmptyOutputStringView);
+ api.CallInstanceRequestAdapterCallback(apiInstance, WGPURequestAdapterStatus_Success,
+ apiAdapter, kEmptyOutputStringView);
});
FlushClient();
EXPECT_CALL(adapterCb, Call(wgpu::RequestAdapterStatus::Success, NotNull(), StrEq(""), this))
@@ -143,7 +143,7 @@
deviceCb;
adapter.RequestDevice(&deviceDesc, wgpu::CallbackMode::AllowSpontaneous, deviceCb.Callback(),
deviceCb.MakeUserdata(this));
- EXPECT_CALL(api, OnAdapterRequestDevice2(apiAdapter, NotNull(), _))
+ EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _))
.WillOnce(WithArg<1>([&](const WGPUDeviceDescriptor* desc) {
// Set on device creation to forward callbacks to the client.
EXPECT_CALL(api, OnDeviceSetLoggingCallback(apiDevice, NotNull(), NotNull())).Times(1);
@@ -152,12 +152,12 @@
// are no longer explicitly calling the setters anymore.
ProcTableAsClass::Object* object =
reinterpret_cast<ProcTableAsClass::Object*>(apiDevice);
- object->mDeviceLostCallback = desc->deviceLostCallbackInfo2.callback;
- object->mDeviceLostUserdata1 = desc->deviceLostCallbackInfo2.userdata1;
- object->mDeviceLostUserdata2 = desc->deviceLostCallbackInfo2.userdata2;
- object->mUncapturedErrorCallback = desc->uncapturedErrorCallbackInfo2.callback;
- object->mUncapturedErrorUserdata1 = desc->uncapturedErrorCallbackInfo2.userdata1;
- object->mUncapturedErrorUserdata2 = desc->uncapturedErrorCallbackInfo2.userdata2;
+ object->mDeviceLostCallback = desc->deviceLostCallbackInfo.callback;
+ object->mDeviceLostUserdata1 = desc->deviceLostCallbackInfo.userdata1;
+ object->mDeviceLostUserdata2 = desc->deviceLostCallbackInfo.userdata2;
+ object->mUncapturedErrorCallback = desc->uncapturedErrorCallbackInfo.callback;
+ object->mUncapturedErrorUserdata1 = desc->uncapturedErrorCallbackInfo.userdata1;
+ object->mUncapturedErrorUserdata2 = desc->uncapturedErrorCallbackInfo.userdata2;
EXPECT_CALL(api, DeviceGetLimits(apiDevice, NotNull()))
.WillOnce(WithArg<1>(Invoke([&](WGPUSupportedLimits* limits) {
@@ -169,8 +169,8 @@
.WillOnce(
WithArg<1>(Invoke([&](WGPUSupportedFeatures* features) { *features = {}; })));
- api.CallAdapterRequestDevice2Callback(apiAdapter, WGPURequestDeviceStatus_Success,
- apiDevice, kEmptyOutputStringView);
+ api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Success,
+ apiDevice, kEmptyOutputStringView);
}));
FlushClient();
EXPECT_CALL(deviceCb, Call(wgpu::RequestDeviceStatus::Success, NotNull(), StrEq(""), this))
diff --git a/src/dawn/tests/unittests/wire/WireTest.h b/src/dawn/tests/unittests/wire/WireTest.h
index f809a6c..e483bb0 100644
--- a/src/dawn/tests/unittests/wire/WireTest.h
+++ b/src/dawn/tests/unittests/wire/WireTest.h
@@ -160,7 +160,7 @@
// Mock callbacks tracking errors and destruction. These are strict mocks because any errors or
// device loss that aren't expected should result in test failures and not just some warnings
// printed to stdout.
- testing::StrictMock<testing::MockCppCallback<wgpu::DeviceLostCallback2<void>*>>
+ testing::StrictMock<testing::MockCppCallback<wgpu::DeviceLostCallback<void>*>>
deviceLostCallback;
testing::StrictMock<testing::MockCppCallback<wgpu::UncapturedErrorCallback<void>*>>
uncapturedErrorCallback;
diff --git a/src/dawn/wire/client/Adapter.cpp b/src/dawn/wire/client/Adapter.cpp
index 3ed95ee..598393d 100644
--- a/src/dawn/wire/client/Adapter.cpp
+++ b/src/dawn/wire/client/Adapter.cpp
@@ -48,12 +48,6 @@
RequestDeviceEvent(const WGPURequestDeviceCallbackInfo& callbackInfo, Ref<Device> device)
: TrackedEvent(callbackInfo.mode),
mCallback(callbackInfo.callback),
- mUserdata1(callbackInfo.userdata),
- mDevice(std::move(device)) {}
-
- RequestDeviceEvent(const WGPURequestDeviceCallbackInfo2& callbackInfo, Ref<Device> device)
- : TrackedEvent(callbackInfo.mode),
- mCallback2(callbackInfo.callback),
mUserdata1(callbackInfo.userdata1),
mUserdata2(callbackInfo.userdata2),
mDevice(std::move(device)) {}
@@ -84,19 +78,14 @@
}
// Callback needs to happen before device lost handling to ensure resolution order.
+ void* userdata1 = mUserdata1.ExtractAsDangling();
+ void* userdata2 = mUserdata2.ExtractAsDangling();
if (mCallback) {
Ref<Device> device = mDevice;
mCallback(mStatus,
mStatus == WGPURequestDeviceStatus_Success ? ReturnToAPI(std::move(device))
: nullptr,
- ToOutputStringView(mMessage), mUserdata1.ExtractAsDangling());
- } else if (mCallback2) {
- Ref<Device> device = mDevice;
- mCallback2(mStatus,
- mStatus == WGPURequestDeviceStatus_Success ? ReturnToAPI(std::move(device))
- : nullptr,
- ToOutputStringView(mMessage), mUserdata1.ExtractAsDangling(),
- mUserdata2.ExtractAsDangling());
+ ToOutputStringView(mMessage), userdata1, userdata2);
}
if (mStatus != WGPURequestDeviceStatus_Success) {
@@ -111,16 +100,9 @@
ToOutputStringView("Device failed at creation."));
}
}
-
- if (mCallback == nullptr && mCallback2 == nullptr) {
- // If there's no callback, clean up the resources.
- mUserdata1.ExtractAsDangling();
- mUserdata2.ExtractAsDangling();
- }
}
WGPURequestDeviceCallback mCallback = nullptr;
- WGPURequestDeviceCallback2 mCallback2 = nullptr;
raw_ptr<void> mUserdata1;
raw_ptr<void> mUserdata2;
@@ -129,7 +111,7 @@
WGPURequestDeviceStatus mStatus;
std::string mMessage;
- // The device is created when we call RequestDevice(F). It is guaranteed to be alive
+ // The device is created when we call RequestDevice. It is guaranteed to be alive
// throughout the duration of a RequestDeviceEvent because the Event essentially takes
// ownership of it until either an error occurs at which point the Event cleans it up, or it
// returns the device to the user who then takes ownership as the Event goes away.
@@ -278,18 +260,8 @@
return WGPUStatus_Success;
}
-void Adapter::RequestDevice(const WGPUDeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata) {
- WGPURequestDeviceCallbackInfo callbackInfo = {};
- callbackInfo.mode = WGPUCallbackMode_AllowSpontaneous;
- callbackInfo.callback = callback;
- callbackInfo.userdata = userdata;
- RequestDeviceF(descriptor, callbackInfo);
-}
-
-WGPUFuture Adapter::RequestDeviceF(const WGPUDeviceDescriptor* descriptor,
- const WGPURequestDeviceCallbackInfo& callbackInfo) {
+WGPUFuture Adapter::RequestDevice(const WGPUDeviceDescriptor* descriptor,
+ const WGPURequestDeviceCallbackInfo& callbackInfo) {
Client* client = GetClient();
Ref<Device> device = client->Make<Device>(GetEventManagerHandle(), this, descriptor);
auto [futureIDInternal, tracked] =
@@ -303,8 +275,8 @@
WGPUDeviceDescriptor wireDescriptor = {};
if (descriptor) {
wireDescriptor = *descriptor;
- wireDescriptor.deviceLostCallbackInfo2 = {};
- wireDescriptor.uncapturedErrorCallbackInfo2 = {};
+ wireDescriptor.deviceLostCallbackInfo = {};
+ wireDescriptor.uncapturedErrorCallbackInfo = {};
}
AdapterRequestDeviceCmd cmd;
@@ -314,39 +286,6 @@
cmd.deviceObjectHandle = device->GetWireHandle();
cmd.deviceLostFuture = device->GetLostFuture();
cmd.descriptor = &wireDescriptor;
- cmd.userdataCount = 1;
-
- client->SerializeCommand(cmd);
- return {futureIDInternal};
-}
-
-WGPUFuture Adapter::RequestDevice2(const WGPUDeviceDescriptor* descriptor,
- const WGPURequestDeviceCallbackInfo2& callbackInfo) {
- Client* client = GetClient();
- Ref<Device> device = client->Make<Device>(GetEventManagerHandle(), this, descriptor);
- auto [futureIDInternal, tracked] =
- GetEventManager().TrackEvent(std::make_unique<RequestDeviceEvent>(callbackInfo, device));
- if (!tracked) {
- return {futureIDInternal};
- }
-
- // Ensure callbacks are not serialized as part of the command, as they cannot be passed between
- // processes.
- WGPUDeviceDescriptor wireDescriptor = {};
- if (descriptor) {
- wireDescriptor = *descriptor;
- wireDescriptor.deviceLostCallbackInfo2 = {};
- wireDescriptor.uncapturedErrorCallbackInfo2 = {};
- }
-
- AdapterRequestDeviceCmd cmd;
- cmd.adapterId = GetWireId();
- cmd.eventManagerHandle = GetEventManagerHandle();
- cmd.future = {futureIDInternal};
- cmd.deviceObjectHandle = device->GetWireHandle();
- cmd.deviceLostFuture = device->GetLostFuture();
- cmd.descriptor = &wireDescriptor;
- cmd.userdataCount = 2;
client->SerializeCommand(cmd);
return {futureIDInternal};
diff --git a/src/dawn/wire/client/Adapter.h b/src/dawn/wire/client/Adapter.h
index 756b411..a6dbc88 100644
--- a/src/dawn/wire/client/Adapter.h
+++ b/src/dawn/wire/client/Adapter.h
@@ -52,13 +52,8 @@
void SetInfo(const WGPUAdapterInfo* info);
WGPUStatus GetInfo(WGPUAdapterInfo* info) const;
void GetFeatures(WGPUSupportedFeatures* features) const;
- void RequestDevice(const WGPUDeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata);
- WGPUFuture RequestDeviceF(const WGPUDeviceDescriptor* descriptor,
- const WGPURequestDeviceCallbackInfo& callbackInfo);
- WGPUFuture RequestDevice2(const WGPUDeviceDescriptor* descriptor,
- const WGPURequestDeviceCallbackInfo2& callbackInfo);
+ WGPUFuture RequestDevice(const WGPUDeviceDescriptor* descriptor,
+ const WGPURequestDeviceCallbackInfo& callbackInfo);
// Unimplementable. Only availale in dawn_native.
WGPUInstance GetInstance() const;
diff --git a/src/dawn/wire/client/Device.cpp b/src/dawn/wire/client/Device.cpp
index 1b4960e..e86b14b 100644
--- a/src/dawn/wire/client/Device.cpp
+++ b/src/dawn/wire/client/Device.cpp
@@ -151,7 +151,7 @@
EventType::CreateRenderPipeline,
WGPUCreateRenderPipelineAsyncCallbackInfo>;
-static constexpr WGPUUncapturedErrorCallbackInfo2 kEmptyUncapturedErrorCallbackInfo = {
+static constexpr WGPUUncapturedErrorCallbackInfo kEmptyUncapturedErrorCallbackInfo = {
nullptr, nullptr, nullptr, nullptr};
} // namespace
@@ -160,7 +160,7 @@
public:
static constexpr EventType kType = EventType::DeviceLost;
- DeviceLostEvent(const WGPUDeviceLostCallbackInfo2& callbackInfo, Ref<Device> device)
+ DeviceLostEvent(const WGPUDeviceLostCallbackInfo& callbackInfo, Ref<Device> device)
: TrackedEvent(callbackInfo.mode),
mCallback(callbackInfo.callback),
mUserdata1(callbackInfo.userdata1),
@@ -201,7 +201,7 @@
}
}
- WGPUDeviceLostCallback2 mCallback = nullptr;
+ WGPUDeviceLostCallback mCallback = nullptr;
raw_ptr<void> mUserdata1 = nullptr;
raw_ptr<void> mUserdata2 = nullptr;
@@ -219,7 +219,7 @@
: RefCountedWithExternalCount<ObjectWithEventsBase>(params, eventManagerHandle),
mAdapter(adapter) {
#if defined(DAWN_ENABLE_ASSERTS)
- static constexpr WGPUDeviceLostCallbackInfo2 kDefaultDeviceLostCallbackInfo = {
+ static constexpr WGPUDeviceLostCallbackInfo kDefaultDeviceLostCallbackInfo = {
nullptr, WGPUCallbackMode_AllowSpontaneous,
[](WGPUDevice const*, WGPUDeviceLostReason, WGPUStringView, void*, void*) {
static bool calledOnce = false;
@@ -231,7 +231,7 @@
}
},
nullptr, nullptr};
- static constexpr WGPUUncapturedErrorCallbackInfo2 kDefaultUncapturedErrorCallbackInfo = {
+ static constexpr WGPUUncapturedErrorCallbackInfo kDefaultUncapturedErrorCallbackInfo = {
nullptr,
[](WGPUDevice const*, WGPUErrorType, WGPUStringView, void*, void*) {
static bool calledOnce = false;
@@ -244,21 +244,21 @@
},
nullptr, nullptr};
#else
- static constexpr WGPUDeviceLostCallbackInfo2 kDefaultDeviceLostCallbackInfo = {
+ static constexpr WGPUDeviceLostCallbackInfo kDefaultDeviceLostCallbackInfo = {
nullptr, WGPUCallbackMode_AllowSpontaneous, nullptr, nullptr, nullptr};
- static constexpr WGPUUncapturedErrorCallbackInfo2 kDefaultUncapturedErrorCallbackInfo =
+ static constexpr WGPUUncapturedErrorCallbackInfo kDefaultUncapturedErrorCallbackInfo =
kEmptyUncapturedErrorCallbackInfo;
#endif // DAWN_ENABLE_ASSERTS
- WGPUDeviceLostCallbackInfo2 deviceLostCallbackInfo = kDefaultDeviceLostCallbackInfo;
- if (descriptor != nullptr && descriptor->deviceLostCallbackInfo2.callback != nullptr) {
- deviceLostCallbackInfo = descriptor->deviceLostCallbackInfo2;
+ WGPUDeviceLostCallbackInfo deviceLostCallbackInfo = kDefaultDeviceLostCallbackInfo;
+ if (descriptor != nullptr && descriptor->deviceLostCallbackInfo.callback != nullptr) {
+ deviceLostCallbackInfo = descriptor->deviceLostCallbackInfo;
}
mDeviceLostInfo.event = std::make_unique<DeviceLostEvent>(deviceLostCallbackInfo, this);
mUncapturedErrorCallbackInfo = kDefaultUncapturedErrorCallbackInfo;
- if (descriptor != nullptr && descriptor->uncapturedErrorCallbackInfo2.callback != nullptr) {
- mUncapturedErrorCallbackInfo = descriptor->uncapturedErrorCallbackInfo2;
+ if (descriptor != nullptr && descriptor->uncapturedErrorCallbackInfo.callback != nullptr) {
+ mUncapturedErrorCallbackInfo = descriptor->uncapturedErrorCallbackInfo;
}
}
diff --git a/src/dawn/wire/client/Device.h b/src/dawn/wire/client/Device.h
index 5efef24..29be5fa 100644
--- a/src/dawn/wire/client/Device.h
+++ b/src/dawn/wire/client/Device.h
@@ -104,7 +104,7 @@
};
DeviceLostInfo mDeviceLostInfo;
- WGPUUncapturedErrorCallbackInfo2 mUncapturedErrorCallbackInfo;
+ WGPUUncapturedErrorCallbackInfo mUncapturedErrorCallbackInfo;
WGPULoggingCallback mLoggingCallback = nullptr;
raw_ptr<void> mLoggingUserdata = nullptr;
diff --git a/src/dawn/wire/client/Instance.cpp b/src/dawn/wire/client/Instance.cpp
index 19e940b..7555bd4 100644
--- a/src/dawn/wire/client/Instance.cpp
+++ b/src/dawn/wire/client/Instance.cpp
@@ -52,12 +52,6 @@
RequestAdapterEvent(const WGPURequestAdapterCallbackInfo& callbackInfo, Ref<Adapter> adapter)
: TrackedEvent(callbackInfo.mode),
mCallback(callbackInfo.callback),
- mUserdata1(callbackInfo.userdata),
- mAdapter(std::move(adapter)) {}
-
- RequestAdapterEvent(const WGPURequestAdapterCallbackInfo2& callbackInfo, Ref<Adapter> adapter)
- : TrackedEvent(callbackInfo.mode),
- mCallback2(callbackInfo.callback),
mUserdata1(callbackInfo.userdata1),
mUserdata2(callbackInfo.userdata2),
mAdapter(std::move(adapter)) {}
@@ -84,35 +78,22 @@
private:
void CompleteImpl(FutureID futureID, EventCompletionType completionType) override {
- if (mCallback == nullptr && mCallback2 == nullptr) {
- // If there's no callback, just clean up the resources.
- mUserdata1.ExtractAsDangling();
- mUserdata2.ExtractAsDangling();
- return;
- }
-
if (completionType == EventCompletionType::Shutdown) {
mStatus = WGPURequestAdapterStatus_InstanceDropped;
mMessage = "A valid external Instance reference no longer exists.";
}
+ void* userdata1 = mUserdata1.ExtractAsDangling();
+ void* userdata2 = mUserdata2.ExtractAsDangling();
if (mCallback) {
mCallback(mStatus,
mStatus == WGPURequestAdapterStatus_Success ? ReturnToAPI(std::move(mAdapter))
: nullptr,
- ToOutputStringView(mMessage), mUserdata1.ExtractAsDangling());
- } else {
- mCallback2(mStatus,
- mStatus == WGPURequestAdapterStatus_Success
- ? ReturnToAPI(std::move(mAdapter))
- : nullptr,
- ToOutputStringView(mMessage), mUserdata1.ExtractAsDangling(),
- mUserdata2.ExtractAsDangling());
+ ToOutputStringView(mMessage), userdata1, userdata2);
}
}
WGPURequestAdapterCallback mCallback = nullptr;
- WGPURequestAdapterCallback2 mCallback2 = nullptr;
raw_ptr<void> mUserdata1;
raw_ptr<void> mUserdata2;
@@ -196,18 +177,8 @@
return WireResult::Success;
}
-void Instance::RequestAdapter(const WGPURequestAdapterOptions* options,
- WGPURequestAdapterCallback callback,
- void* userdata) {
- WGPURequestAdapterCallbackInfo callbackInfo = {};
- callbackInfo.mode = WGPUCallbackMode_AllowSpontaneous;
- callbackInfo.callback = callback;
- callbackInfo.userdata = userdata;
- RequestAdapterF(options, callbackInfo);
-}
-
-WGPUFuture Instance::RequestAdapterF(const WGPURequestAdapterOptions* options,
- const WGPURequestAdapterCallbackInfo& callbackInfo) {
+WGPUFuture Instance::RequestAdapter(const WGPURequestAdapterOptions* options,
+ const WGPURequestAdapterCallbackInfo& callbackInfo) {
Client* client = GetClient();
Ref<Adapter> adapter = client->Make<Adapter>(GetEventManagerHandle());
auto [futureIDInternal, tracked] =
@@ -222,29 +193,6 @@
cmd.future = {futureIDInternal};
cmd.adapterObjectHandle = adapter->GetWireHandle();
cmd.options = options;
- cmd.userdataCount = 1;
-
- client->SerializeCommand(cmd);
- return {futureIDInternal};
-}
-
-WGPUFuture Instance::RequestAdapter2(const WGPURequestAdapterOptions* options,
- const WGPURequestAdapterCallbackInfo2& callbackInfo) {
- Client* client = GetClient();
- Ref<Adapter> adapter = client->Make<Adapter>(GetEventManagerHandle());
- auto [futureIDInternal, tracked] =
- GetEventManager().TrackEvent(std::make_unique<RequestAdapterEvent>(callbackInfo, adapter));
- if (!tracked) {
- return {futureIDInternal};
- }
-
- InstanceRequestAdapterCmd cmd;
- cmd.instanceId = GetWireId();
- cmd.eventManagerHandle = GetEventManagerHandle();
- cmd.future = {futureIDInternal};
- cmd.adapterObjectHandle = adapter->GetWireHandle();
- cmd.options = options;
- cmd.userdataCount = 2;
client->SerializeCommand(cmd);
return {futureIDInternal};
diff --git a/src/dawn/wire/client/Instance.h b/src/dawn/wire/client/Instance.h
index eb3e418..c88f520 100644
--- a/src/dawn/wire/client/Instance.h
+++ b/src/dawn/wire/client/Instance.h
@@ -44,13 +44,8 @@
WireResult Initialize(const WGPUInstanceDescriptor* descriptor);
- void RequestAdapter(const WGPURequestAdapterOptions* options,
- WGPURequestAdapterCallback callback,
- void* userdata);
- WGPUFuture RequestAdapterF(const WGPURequestAdapterOptions* options,
- const WGPURequestAdapterCallbackInfo& callbackInfo);
- WGPUFuture RequestAdapter2(const WGPURequestAdapterOptions* options,
- const WGPURequestAdapterCallbackInfo2& callbackInfo);
+ WGPUFuture RequestAdapter(const WGPURequestAdapterOptions* options,
+ const WGPURequestAdapterCallbackInfo& callbackInfo);
void ProcessEvents();
WGPUWaitStatus WaitAny(size_t count, WGPUFutureWaitInfo* infos, uint64_t timeoutNS);
diff --git a/src/dawn/wire/server/ServerAdapter.cpp b/src/dawn/wire/server/ServerAdapter.cpp
index 60b4afd..40c7e62 100644
--- a/src/dawn/wire/server/ServerAdapter.cpp
+++ b/src/dawn/wire/server/ServerAdapter.cpp
@@ -41,8 +41,7 @@
WGPUFuture future,
ObjectHandle deviceHandle,
WGPUFuture deviceLostFuture,
- const WGPUDeviceDescriptor* descriptor,
- uint8_t userdataCount) {
+ const WGPUDeviceDescriptor* descriptor) {
Reserved<WGPUDevice> device;
WIRE_TRY(Objects<WGPUDevice>().Allocate(&device, deviceHandle, AllocationState::Reserved));
@@ -58,10 +57,10 @@
deviceLostUserdata->future = deviceLostFuture;
WGPUDeviceDescriptor desc = *descriptor;
- desc.deviceLostCallbackInfo2 = {nullptr, WGPUCallbackMode_AllowSpontaneous,
- ForwardToServer2<&Server::OnDeviceLost>,
- deviceLostUserdata.release(), nullptr};
- desc.uncapturedErrorCallbackInfo2 = {
+ desc.deviceLostCallbackInfo = {nullptr, WGPUCallbackMode_AllowSpontaneous,
+ ForwardToServer2<&Server::OnDeviceLost>,
+ deviceLostUserdata.release(), nullptr};
+ desc.uncapturedErrorCallbackInfo = {
nullptr,
[](WGPUDevice const*, WGPUErrorType type, WGPUStringView message, void*, void* userdata) {
DeviceInfo* info = static_cast<DeviceInfo*>(userdata);
@@ -69,16 +68,10 @@
},
nullptr, device->info.get()};
- if (userdataCount == 1) {
- mProcs.adapterRequestDevice(adapter->handle, &desc,
- ForwardToServer<&Server::OnRequestDeviceCallback>,
- userdata.release());
- } else {
- mProcs.adapterRequestDevice2(
- adapter->handle, &desc,
- {nullptr, WGPUCallbackMode_AllowSpontaneous,
- ForwardToServer2<&Server::OnRequestDeviceCallback>, userdata.release(), nullptr});
- }
+ mProcs.adapterRequestDevice(
+ adapter->handle, &desc,
+ {nullptr, WGPUCallbackMode_AllowSpontaneous,
+ ForwardToServer2<&Server::OnRequestDeviceCallback>, userdata.release(), nullptr});
return WireResult::Success;
}
diff --git a/src/dawn/wire/server/ServerInstance.cpp b/src/dawn/wire/server/ServerInstance.cpp
index e504950..b69e393 100644
--- a/src/dawn/wire/server/ServerInstance.cpp
+++ b/src/dawn/wire/server/ServerInstance.cpp
@@ -39,8 +39,7 @@
ObjectHandle eventManager,
WGPUFuture future,
ObjectHandle adapterHandle,
- const WGPURequestAdapterOptions* options,
- uint8_t userdataCount) {
+ const WGPURequestAdapterOptions* options) {
Reserved<WGPUAdapter> adapter;
WIRE_TRY(Objects<WGPUAdapter>().Allocate(&adapter, adapterHandle, AllocationState::Reserved));
@@ -49,16 +48,10 @@
userdata->future = future;
userdata->adapterObjectId = adapter.id;
- if (userdataCount == 1) {
- mProcs.instanceRequestAdapter(instance->handle, options,
- ForwardToServer<&Server::OnRequestAdapterCallback>,
- userdata.release());
- } else {
- mProcs.instanceRequestAdapter2(
- instance->handle, options,
- {nullptr, WGPUCallbackMode_AllowSpontaneous,
- ForwardToServer2<&Server::OnRequestAdapterCallback>, userdata.release(), nullptr});
- }
+ mProcs.instanceRequestAdapter(
+ instance->handle, options,
+ {nullptr, WGPUCallbackMode_AllowSpontaneous,
+ ForwardToServer2<&Server::OnRequestAdapterCallback>, userdata.release(), nullptr});
return WireResult::Success;
}
diff --git a/third_party/emdawnwebgpu/webgpu.cpp b/third_party/emdawnwebgpu/webgpu.cpp
index e8294d7..f0fa704 100644
--- a/third_party/emdawnwebgpu/webgpu.cpp
+++ b/third_party/emdawnwebgpu/webgpu.cpp
@@ -699,8 +699,8 @@
void WillDropLastExternalRef() override;
Ref<WGPUQueue> mQueue;
- WGPUUncapturedErrorCallbackInfo2 mUncapturedErrorCallbackInfo =
- WGPU_UNCAPTURED_ERROR_CALLBACK_INFO_2_INIT;
+ WGPUUncapturedErrorCallbackInfo mUncapturedErrorCallbackInfo =
+ WGPU_UNCAPTURED_ERROR_CALLBACK_INFO_INIT;
FutureID mDeviceLostFutureId = kNullFutureId;
};
@@ -869,7 +869,7 @@
DeviceLostEvent(InstanceID instance,
WGPUDevice device,
- const WGPUDeviceLostCallbackInfo2& callbackInfo)
+ const WGPUDeviceLostCallbackInfo& callbackInfo)
: TrackedEvent(instance, callbackInfo.mode),
mCallback(callbackInfo.callback),
mUserdata1(callbackInfo.userdata1),
@@ -902,7 +902,7 @@
}
private:
- WGPUDeviceLostCallback2 mCallback = nullptr;
+ WGPUDeviceLostCallback mCallback = nullptr;
void* mUserdata1 = nullptr;
void* mUserdata2 = nullptr;
@@ -1024,7 +1024,7 @@
static constexpr EventType kType = EventType::RequestAdapter;
RequestAdapterEvent(InstanceID instance,
- const WGPURequestAdapterCallbackInfo2& callbackInfo)
+ const WGPURequestAdapterCallbackInfo& callbackInfo)
: TrackedEvent(instance, callbackInfo.mode),
mCallback(callbackInfo.callback),
mUserdata1(callbackInfo.userdata1),
@@ -1057,7 +1057,7 @@
}
private:
- WGPURequestAdapterCallback2 mCallback = nullptr;
+ WGPURequestAdapterCallback mCallback = nullptr;
void* mUserdata1 = nullptr;
void* mUserdata2 = nullptr;
@@ -1071,7 +1071,7 @@
static constexpr EventType kType = EventType::RequestDevice;
RequestDeviceEvent(InstanceID instance,
- const WGPURequestDeviceCallbackInfo2& callbackInfo)
+ const WGPURequestDeviceCallbackInfo& callbackInfo)
: TrackedEvent(instance, callbackInfo.mode),
mCallback(callbackInfo.callback),
mUserdata1(callbackInfo.userdata1),
@@ -1104,7 +1104,7 @@
}
private:
- WGPURequestDeviceCallback2 mCallback = nullptr;
+ WGPURequestDeviceCallback mCallback = nullptr;
void* mUserdata1 = nullptr;
void* mUserdata2 = nullptr;
@@ -1377,11 +1377,11 @@
const WGPUDeviceDescriptor* descriptor,
WGPUQueue queue)
: EventSource(source),
- mUncapturedErrorCallbackInfo(descriptor->uncapturedErrorCallbackInfo2) {
+ mUncapturedErrorCallbackInfo(descriptor->uncapturedErrorCallbackInfo) {
// Create the DeviceLostEvent now.
std::tie(mDeviceLostFutureId, std::ignore) =
GetEventManager().TrackEvent(std::make_unique<DeviceLostEvent>(
- source->GetInstanceId(), this, descriptor->deviceLostCallbackInfo2));
+ source->GetInstanceId(), this, descriptor->deviceLostCallbackInfo));
mQueue.Acquire(queue);
}
@@ -1546,27 +1546,10 @@
// Methods of Adapter
// ----------------------------------------------------------------------------
-void wgpuAdapterRequestDevice(WGPUAdapter adapter,
- const WGPUDeviceDescriptor* descriptor,
- WGPURequestDeviceCallback callback,
- void* userdata) {
- WGPURequestDeviceCallbackInfo2 callbackInfo = {};
- callbackInfo.mode = WGPUCallbackMode_AllowSpontaneous;
- callbackInfo.callback = [](WGPURequestDeviceStatus status, WGPUDevice device,
- WGPUStringView message, void* callback,
- void* userdata) {
- auto cb = reinterpret_cast<WGPURequestDeviceCallback>(callback);
- cb(status, device, message, userdata);
- };
- callbackInfo.userdata1 = reinterpret_cast<void*>(callback);
- callbackInfo.userdata2 = userdata;
- wgpuAdapterRequestDevice2(adapter, descriptor, callbackInfo);
-}
-
-WGPUFuture wgpuAdapterRequestDevice2(
+WGPUFuture wgpuAdapterRequestDevice(
WGPUAdapter adapter,
const WGPUDeviceDescriptor* descriptor,
- WGPURequestDeviceCallbackInfo2 callbackInfo) {
+ WGPURequestDeviceCallbackInfo callbackInfo) {
auto [futureId, tracked] =
GetEventManager().TrackEvent(std::make_unique<RequestDeviceEvent>(
adapter->GetInstanceId(), callbackInfo));
@@ -1731,27 +1714,10 @@
instance->ProcessEvents();
}
-void wgpuInstanceRequestAdapter(WGPUInstance instance,
- WGPURequestAdapterOptions const* options,
- WGPURequestAdapterCallback callback,
- void* userdata) {
- WGPURequestAdapterCallbackInfo2 callbackInfo = {};
- callbackInfo.mode = WGPUCallbackMode_AllowSpontaneous;
- callbackInfo.callback = [](WGPURequestAdapterStatus status,
- WGPUAdapter adapter, WGPUStringView message,
- void* callback, void* userdata) {
- auto cb = reinterpret_cast<WGPURequestAdapterCallback>(callback);
- cb(status, adapter, message, userdata);
- };
- callbackInfo.userdata1 = reinterpret_cast<void*>(callback);
- callbackInfo.userdata2 = userdata;
- wgpuInstanceRequestAdapter2(instance, options, callbackInfo);
-}
-
-WGPUFuture wgpuInstanceRequestAdapter2(
+WGPUFuture wgpuInstanceRequestAdapter(
WGPUInstance instance,
WGPURequestAdapterOptions const* options,
- WGPURequestAdapterCallbackInfo2 callbackInfo) {
+ WGPURequestAdapterCallbackInfo callbackInfo) {
auto [futureId, tracked] =
GetEventManager().TrackEvent(std::make_unique<RequestAdapterEvent>(
instance->GetInstanceId(), callbackInfo));
diff --git a/tools/android/BUILD.gn b/tools/android/BUILD.gn
index de900b1..94a7077 100644
--- a/tools/android/BUILD.gn
+++ b/tools/android/BUILD.gn
@@ -100,12 +100,8 @@
"java/android/dawn/Device.kt",
"java/android/dawn/DeviceDescriptor.kt",
"java/android/dawn/DeviceLostCallback.kt",
- "java/android/dawn/DeviceLostCallback2.kt",
"java/android/dawn/DeviceLostCallbackInfo.kt",
- "java/android/dawn/DeviceLostCallbackInfo2.kt",
- "java/android/dawn/DeviceLostCallbackNew.kt",
"java/android/dawn/DeviceLostReason.kt",
- "java/android/dawn/ErrorCallback.kt",
"java/android/dawn/ErrorFilter.kt",
"java/android/dawn/ErrorType.kt",
"java/android/dawn/Extent3D.kt",
@@ -162,15 +158,11 @@
"java/android/dawn/RenderPipeline.kt",
"java/android/dawn/RenderPipelineDescriptor.kt",
"java/android/dawn/RequestAdapterCallback.kt",
- "java/android/dawn/RequestAdapterCallback2.kt",
"java/android/dawn/RequestAdapterCallbackInfo.kt",
- "java/android/dawn/RequestAdapterCallbackInfo2.kt",
"java/android/dawn/RequestAdapterOptions.kt",
"java/android/dawn/RequestAdapterStatus.kt",
"java/android/dawn/RequestDeviceCallback.kt",
- "java/android/dawn/RequestDeviceCallback2.kt",
"java/android/dawn/RequestDeviceCallbackInfo.kt",
- "java/android/dawn/RequestDeviceCallbackInfo2.kt",
"java/android/dawn/RequestDeviceStatus.kt",
"java/android/dawn/RequiredLimits.kt",
"java/android/dawn/SType.kt",
@@ -213,7 +205,6 @@
"java/android/dawn/TextureViewDimension.kt",
"java/android/dawn/UncapturedErrorCallback.kt",
"java/android/dawn/UncapturedErrorCallbackInfo.kt",
- "java/android/dawn/UncapturedErrorCallbackInfo2.kt",
"java/android/dawn/VertexAttribute.kt",
"java/android/dawn/VertexBufferLayout.kt",
"java/android/dawn/VertexFormat.kt",