mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-01 10:53:33 +00:00
dawn_native: Add RequestDevice to the Adapter
Adds a basic RequestDevice method to the adapter, only in dawn_native. We will revisit this when we implement adapters in dawn_wire. RequestDevice allows us to have tests of the limit bounds because it receives a callback which can return status codes and error messages. Bug: dawn:685 Change-Id: I7a68922b078c6a436f49a16346cb41fb9df9cfee Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63982 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
dc7971ce58
commit
2092a66ab5
19
dawn.json
19
dawn.json
@ -1539,6 +1539,25 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"request device callback": {
|
||||||
|
"category": "callback",
|
||||||
|
"args": [
|
||||||
|
{"name": "status", "type": "request device status"},
|
||||||
|
{"name": "device", "type": "device"},
|
||||||
|
{"name": "message", "type": "char", "annotation": "const*"},
|
||||||
|
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"request device status": {
|
||||||
|
"category": "enum",
|
||||||
|
"values": [
|
||||||
|
{"value": 0, "name": "success"},
|
||||||
|
{"value": 1, "name": "error"},
|
||||||
|
{"value": 2, "name": "unknown"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
"vertex state": {
|
"vertex state": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"extensible": true,
|
"extensible": true,
|
||||||
|
@ -78,6 +78,24 @@ namespace dawn_native {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdapterBase::RequestDevice(const DeviceDescriptor* descriptor,
|
||||||
|
WGPURequestDeviceCallback callback,
|
||||||
|
void* userdata) {
|
||||||
|
DeviceBase* result = nullptr;
|
||||||
|
MaybeError err = CreateDeviceInternal(&result, descriptor);
|
||||||
|
WGPUDevice device = reinterpret_cast<WGPUDevice>(result);
|
||||||
|
|
||||||
|
if (err.IsError()) {
|
||||||
|
std::unique_ptr<ErrorData> errorData = err.AcquireError();
|
||||||
|
callback(WGPURequestDeviceStatus_Error, device, errorData->GetMessage().c_str(),
|
||||||
|
userdata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WGPURequestDeviceStatus status =
|
||||||
|
device == nullptr ? WGPURequestDeviceStatus_Unknown : WGPURequestDeviceStatus_Success;
|
||||||
|
callback(status, device, nullptr, userdata);
|
||||||
|
}
|
||||||
|
|
||||||
MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result,
|
MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result,
|
||||||
const DeviceDescriptor* descriptor) {
|
const DeviceDescriptor* descriptor) {
|
||||||
if (descriptor != nullptr) {
|
if (descriptor != nullptr) {
|
||||||
|
@ -40,6 +40,10 @@ namespace dawn_native {
|
|||||||
|
|
||||||
DeviceBase* CreateDevice(const DeviceDescriptor* descriptor = nullptr);
|
DeviceBase* CreateDevice(const DeviceDescriptor* descriptor = nullptr);
|
||||||
|
|
||||||
|
void RequestDevice(const DeviceDescriptor* descriptor,
|
||||||
|
WGPURequestDeviceCallback callback,
|
||||||
|
void* userdata);
|
||||||
|
|
||||||
void ResetInternalDeviceForTesting();
|
void ResetInternalDeviceForTesting();
|
||||||
|
|
||||||
ExtensionsSet GetSupportedExtensions() const;
|
ExtensionsSet GetSupportedExtensions() const;
|
||||||
|
@ -118,6 +118,12 @@ namespace dawn_native {
|
|||||||
return reinterpret_cast<WGPUDevice>(mImpl->CreateDevice(deviceDescriptor));
|
return reinterpret_cast<WGPUDevice>(mImpl->CreateDevice(deviceDescriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Adapter::RequestDevice(const DeviceDescriptor* descriptor,
|
||||||
|
WGPURequestDeviceCallback callback,
|
||||||
|
void* userdata) {
|
||||||
|
mImpl->RequestDevice(descriptor, callback, userdata);
|
||||||
|
}
|
||||||
|
|
||||||
void Adapter::ResetInternalDeviceForTesting() {
|
void Adapter::ResetInternalDeviceForTesting() {
|
||||||
mImpl->ResetInternalDeviceForTesting();
|
mImpl->ResetInternalDeviceForTesting();
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,10 @@ namespace dawn_native {
|
|||||||
// On an error, nullptr is returned.
|
// On an error, nullptr is returned.
|
||||||
WGPUDevice CreateDevice(const DeviceDescriptor* deviceDescriptor = nullptr);
|
WGPUDevice CreateDevice(const DeviceDescriptor* deviceDescriptor = nullptr);
|
||||||
|
|
||||||
|
void RequestDevice(const DeviceDescriptor* descriptor,
|
||||||
|
WGPURequestDeviceCallback callback,
|
||||||
|
void* userdata);
|
||||||
|
|
||||||
// Reset the backend device object for testing purposes.
|
// Reset the backend device object for testing purposes.
|
||||||
void ResetInternalDeviceForTesting();
|
void ResetInternalDeviceForTesting();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user