[wire] Remove deprecated wire APIs in favor of volatile versions. - This change needs to wait for this chromium side change to land: https://chromium-review.git.corp.google.com/c/chromium/src/+/8128124 Bug: 528027992 Change-Id: I1f97c174f44722f721a4411e777c010e4f2b7e57 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/326376 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Loko Kung <lokokung@google.com>
diff --git a/include/dawn/wire/Wire.h b/include/dawn/wire/Wire.h index 61b429b..5b887ae 100644 --- a/include/dawn/wire/Wire.h +++ b/include/dawn/wire/Wire.h
@@ -47,18 +47,10 @@ CommandSerializer& operator=(const CommandSerializer& rhs) = delete; // Get space for serializing commands. - // GetCmdSpace will never be called with a value larger than - // what GetMaximumAllocationSize returns. Return nullptr to indicate - // a fatal error. - virtual void* GetCmdSpace(size_t size) { - // TODO(https://crbug.com/528027992): Remove in favor of GetCommandSpace once Chromium - // implements it. - return nullptr; - } - virtual std::optional<std::span<volatile std::byte>> GetCommandSpace(size_t size) { - // TODO(https://crbug.com/528027992): Make pure virtual once Chromium implements it. - return std::nullopt; - } + // GetCommandSpace will never be called with a value larger than what GetMaximumAllocationSize + // returns. Returns std::nullopt to indicate a fatal error, otherwise the returned std::span is + // expected to be a contiguous slice of aligned memory. + virtual std::optional<std::span<volatile std::byte>> GetCommandSpace(size_t size) = 0; virtual bool Flush() = 0; virtual size_t GetMaximumAllocationSize() const = 0; virtual void OnSerializeError(); @@ -71,15 +63,7 @@ CommandHandler(const CommandHandler& rhs) = delete; CommandHandler& operator=(const CommandHandler& rhs) = delete; - virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) { - // TODO(https://crbug.com/528027992): Remove in favor of the version below once Chromium - // implements it. - return nullptr; - } - virtual bool HandleCommands(std::span<const volatile std::byte> commands) { - // TODO(https://crbug.com/528027992): Make pure virtual once Chromium implements it. - return {}; - } + virtual bool HandleCommands(std::span<const volatile std::byte> commands) = 0; }; // Handle struct that are used to uniquely represent an object of a particular type in the wire.
diff --git a/include/dawn/wire/WireClient.h b/include/dawn/wire/WireClient.h index 2fb4b63..13f05b1 100644 --- a/include/dawn/wire/WireClient.h +++ b/include/dawn/wire/WireClient.h
@@ -123,8 +123,7 @@ virtual size_t GetSerializeCreateSize() const = 0; // Serialize the handle into |serializeSpace| so it can be received by the server. - virtual void SerializeCreate(std::span<std::byte> serializeSpace) const {} - virtual void SerializeCreate(std::span<volatile std::byte> serializeSpace) const {} + virtual void SerializeCreate(std::span<volatile std::byte> serializeSpace) const = 0; // Returns a const view of the memory. // dawn::wire::client ensures that the memory is initialized by a data update before it is @@ -142,13 +141,9 @@ // Serializes into |serializeData| the modification of the contents in the range [offset, // offset + size). - // TODO(https://crbug.com/528027992): Remove non-volatile overload once implemented. - virtual void SerializeDataUpdate(std::span<std::byte> serializeData, - size_t offset, - size_t size) const {} virtual void SerializeDataUpdate(std::span<volatile std::byte> serializeData, size_t offset, - size_t size) const {} + size_t size) const = 0; // Applies a data update for the range [offset, offset + size) that was produced by // `server::MemoryTransferService::MemoryHandle::SerializeDataUpdate`.
diff --git a/include/dawn/wire/WireServer.h b/include/dawn/wire/WireServer.h index 07e8012..4c94490 100644 --- a/include/dawn/wire/WireServer.h +++ b/include/dawn/wire/WireServer.h
@@ -115,15 +115,10 @@ // - `offset`: The byte offset of data.data() within the whole allocation.. // - `size`: The size of the range to update (must be <= data.size()). // - `data`: The new contents for the range [offset, offset + data.size()). - // TODO(https://crbug.com/528027992): Remove non-volatile overload once implemented. - virtual void SerializeDataUpdate(std::span<std::byte> serializeData, - size_t offset, - size_t size, - std::span<const std::byte> data) const {} virtual void SerializeDataUpdate(std::span<volatile std::byte> serializeData, size_t offset, size_t size, - std::span<const std::byte> data) const {} + std::span<const std::byte> data) const = 0; // Applies a data update for the range [offset, offset + size) that was produced by // `client::MemoryTransferService::MemoryHandle::SerializeDataUpdate`.
diff --git a/src/dawn/wire/client/Client.cpp b/src/dawn/wire/client/Client.cpp index 277c65b..ff0c9a7 100644 --- a/src/dawn/wire/client/Client.cpp +++ b/src/dawn/wire/client/Client.cpp
@@ -50,7 +50,6 @@ // Return SIZE_MAX so ChunkedCommandSerializer won't unnecessarily try to chunk commands. return SIZE_MAX; } - void* GetCmdSpace(size_t size) final { return nullptr; } std::optional<std::span<volatile std::byte>> GetCommandSpace(size_t size) final { return std::nullopt; }
diff --git a/src/dawn/wire/client/ClientInlineMemoryTransferService.cpp b/src/dawn/wire/client/ClientInlineMemoryTransferService.cpp index c14f3d9..0d492a6 100644 --- a/src/dawn/wire/client/ClientInlineMemoryTransferService.cpp +++ b/src/dawn/wire/client/ClientInlineMemoryTransferService.cpp
@@ -50,10 +50,6 @@ ~MemoryHandleImpl() override = default; size_t GetSerializeCreateSize() const override { return 0; } - // TODO(https://crbug.com/528027992): Remove non-volatile overload once implemented. - void SerializeCreate(std::span<std::byte> serializeSpace) const override { - DAWN_ASSERT(serializeSpace.size() == GetSerializeCreateSize()); - } void SerializeCreate(std::span<volatile std::byte> serializeSpace) const override { DAWN_ASSERT(serializeSpace.size() == GetSerializeCreateSize()); } @@ -66,17 +62,6 @@ return size; } - // TODO(https://crbug.com/528027992): Remove non-volatile overload once implemented. - void SerializeDataUpdate(std::span<std::byte> serializeData, - size_t offset, - size_t size) const override { - DAWN_ASSERT(serializeData.size() == GetSerializeDataUpdateSize(offset, size)); - DAWN_ASSERT(offset <= mStagingData.size()); - DAWN_ASSERT(size <= mStagingData.size() - offset); - - auto src = GetData().subspan(offset, serializeData.size()); - std::ranges::copy(src, serializeData.begin()); - } void SerializeDataUpdate(std::span<volatile std::byte> serializeData, size_t offset, size_t size) const override {
diff --git a/src/dawn/wire/client/ClientMemoryTransferService_mock.h b/src/dawn/wire/client/ClientMemoryTransferService_mock.h index 01288fa..dcd2b6a 100644 --- a/src/dawn/wire/client/ClientMemoryTransferService_mock.h +++ b/src/dawn/wire/client/ClientMemoryTransferService_mock.h
@@ -47,7 +47,7 @@ MOCK_METHOD(void, Destroy, ()); MOCK_METHOD(size_t, GetSerializeCreateSize, (), (const, override)); - MOCK_METHOD(void, SerializeCreate, (std::span<std::byte>), (const, override)); + MOCK_METHOD(void, SerializeCreate, (std::span<std::byte>), (const)); // GMock does not natively support printing/handling volatile types in mock argument tuples // without custom printers, so we implement the volatile overload directly to cast away // volatile and forward to the non-volatile MOCK_METHOD. @@ -57,10 +57,7 @@ } MOCK_METHOD(std::span<std::byte>, GetData, (), (const, override)); MOCK_METHOD(size_t, GetSerializeDataUpdateSize, (size_t, size_t), (const, override)); - MOCK_METHOD(void, - SerializeDataUpdate, - (std::span<std::byte>, size_t, size_t), - (const, override)); + MOCK_METHOD(void, SerializeDataUpdate, (std::span<std::byte>, size_t, size_t), (const)); // GMock does not natively support printing/handling volatile types in mock argument tuples // without custom printers, so we implement the volatile overload directly to cast away // volatile and forward to the non-volatile MOCK_METHOD.
diff --git a/src/dawn/wire/server/ServerInlineMemoryTransferService.cpp b/src/dawn/wire/server/ServerInlineMemoryTransferService.cpp index a60c435..eb24c8b 100644 --- a/src/dawn/wire/server/ServerInlineMemoryTransferService.cpp +++ b/src/dawn/wire/server/ServerInlineMemoryTransferService.cpp
@@ -46,16 +46,6 @@ return size; } - // TODO(https://crbug.com/528027992): Remove non-volatile overload once implemented. - void SerializeDataUpdate(std::span<std::byte> serializeData, - size_t offset, - size_t size, - std::span<const std::byte> data) const override { - DAWN_ASSERT(serializeData.size() == GetSerializeDataUpdateSize(offset, size)); - DAWN_ASSERT(data.size() == size); - DAWN_ASSERT(serializeData.size() >= data.size()); - std::ranges::copy(data, serializeData.begin()); - } void SerializeDataUpdate(std::span<volatile std::byte> serializeData, size_t offset, size_t size,
diff --git a/src/dawn/wire/server/ServerMemoryTransferService_mock.h b/src/dawn/wire/server/ServerMemoryTransferService_mock.h index 447c9cc..2645f8b 100644 --- a/src/dawn/wire/server/ServerMemoryTransferService_mock.h +++ b/src/dawn/wire/server/ServerMemoryTransferService_mock.h
@@ -51,7 +51,7 @@ MOCK_METHOD(void, SerializeDataUpdate, (std::span<std::byte>, size_t, size_t, std::span<const std::byte>), - (const, override)); + (const)); // GMock does not natively support printing/handling volatile types in mock argument tuples // without custom printers, so we implement the volatile overload directly to cast away // volatile and forward to the non-volatile MOCK_METHOD.