dawn_wire: Make all objects owned by the client

This removes the logic where the Client owns the Device and the
Device owns all other objects. Ownership should be tracked in
dawn_native either with refcounting or validation to disallow
operations after an object's parent has been destroyed.

This simplifies the wire client code in that the client only
tracks allocated handles and does not manage parent/child lifetimes.
This is an important simplification so we can support multiple WebGPU
instances, adapters, and devices on a single wire.

Bug: dawn:384
Change-Id: I8ecc7c368130b8917202150c467b5f0e7d4b753e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37000
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Austin Eng
2021-01-13 18:31:47 +00:00
committed by Commit Bot service account
parent f6ef7530ab
commit f0d7cc4f5a
11 changed files with 126 additions and 152 deletions

View File

@@ -22,16 +22,16 @@
namespace dawn_wire { namespace client {
class Device;
class Client;
// All non-Device objects of the client side have:
// - A pointer to the device to get where to serialize commands
// All objects on the client side have:
// - A pointer to the Client to get where to serialize commands
// - The external reference count
// - An ID that is used to refer to this object when talking with the server side
// - A next/prev pointer. They are part of a linked list of objects of the same type.
struct ObjectBase : public LinkNode<ObjectBase> {
ObjectBase(Device* device, uint32_t refcount, uint32_t id)
: device(device), refcount(refcount), id(id) {
ObjectBase(Client* client, uint32_t refcount, uint32_t id)
: client(client), refcount(refcount), id(id) {
}
~ObjectBase() {
@@ -41,7 +41,7 @@ namespace dawn_wire { namespace client {
virtual void CancelCallbacksForDisconnect() {
}
Device* const device;
Client* const client;
uint32_t refcount;
const uint32_t id;
};