dawn_wire: Add support for injecting/reserving swapchains

This will help experiment using dawn_wire for remoting WebGPU to render
on the screen.

Bug: None
Change-Id: I9a60ff8c3889ec917f6fd56e4cbb1ffef639748d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47621
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez
2021-04-13 01:26:04 +00:00
committed by Commit Bot service account
parent b676602188
commit e190045664
10 changed files with 206 additions and 3 deletions

View File

@@ -96,6 +96,18 @@ namespace dawn_wire { namespace client {
return result;
}
ReservedSwapChain Client::ReserveSwapChain(WGPUDevice device) {
auto* allocation = SwapChainAllocator().New(this);
ReservedSwapChain result;
result.swapchain = ToAPI(allocation->object.get());
result.id = allocation->object->id;
result.generation = allocation->generation;
result.deviceId = FromAPI(device)->id;
result.deviceGeneration = DeviceAllocator().GetGeneration(FromAPI(device)->id);
return result;
}
ReservedDevice Client::ReserveDevice() {
auto* allocation = DeviceAllocator().New(this);
@@ -110,6 +122,10 @@ namespace dawn_wire { namespace client {
TextureAllocator().Free(FromAPI(reservation.texture));
}
void Client::ReclaimSwapChainReservation(const ReservedSwapChain& reservation) {
SwapChainAllocator().Free(FromAPI(reservation.swapchain));
}
void Client::ReclaimDeviceReservation(const ReservedDevice& reservation) {
DeviceAllocator().Free(FromAPI(reservation.device));
}