mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-19 01:46:35 +00:00
dawn_wire: Add Reserve/InjectDevice
Now that the wire does enough tracking to prevent a malicious client from freeing a device before its child objects, and the device is no longer a "special" object with regard to reference/release, it is safe to support multiple devices on the wire. The simplest way to use this in WebGPU (to fix createReadyRenderPipeline validation) is to add a reserve/inject device API similar to the one we use for swapchain textures. Bug: dawn:565 Change-Id: Ie956aff528c5610c9ecc5c189dab2d22185cb572 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37800 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
b830da7d6e
commit
8bcde8e394
@@ -85,8 +85,13 @@ namespace dawn_wire { namespace client {
|
||||
}
|
||||
|
||||
WGPUDevice Client::GetDevice() {
|
||||
// This function is deprecated. The concept of a "default" device on the wire
|
||||
// will be removed in favor of ReserveDevice/InjectDevice.
|
||||
if (mDevice == nullptr) {
|
||||
mDevice = DeviceAllocator().New(this)->object.get();
|
||||
ReservedDevice reservation = ReserveDevice();
|
||||
mDevice = FromAPI(reservation.device);
|
||||
ASSERT(reservation.id == 1);
|
||||
ASSERT(reservation.generation == 0);
|
||||
}
|
||||
return reinterpret_cast<WGPUDeviceImpl*>(mDevice);
|
||||
}
|
||||
@@ -103,6 +108,16 @@ namespace dawn_wire { namespace client {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReservedDevice Client::ReserveDevice() {
|
||||
auto* allocation = DeviceAllocator().New(this);
|
||||
|
||||
ReservedDevice result;
|
||||
result.device = ToAPI(allocation->object.get());
|
||||
result.id = allocation->object->id;
|
||||
result.generation = allocation->generation;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Client::Disconnect() {
|
||||
mDisconnected = true;
|
||||
mSerializer = ChunkedCommandSerializer(NoopCommandSerializer::GetInstance());
|
||||
|
||||
Reference in New Issue
Block a user