From 6a224fbd52cf0acf225755c42a1eba9db86792dd Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Tue, 31 May 2022 20:07:39 +0000 Subject: [PATCH] Remove custom serialization of device properties Fixed: chromium:1315260 Change-Id: I1b4847289f34034a2a0bb5f5c8405ccf9d8e9c3b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92120 Commit-Queue: Austin Eng Kokoro: Kokoro Commit-Queue: Corentin Wallez Reviewed-by: Corentin Wallez Auto-Submit: Austin Eng --- generator/templates/dawn/wire/WireCmd.cpp | 68 ------------------- include/dawn/wire/Wire.h | 20 ------ src/dawn/tests/BUILD.gn | 1 - .../wire/WireWGPUDevicePropertiesTests.cpp | 57 ---------------- 4 files changed, 146 deletions(-) delete mode 100644 src/dawn/tests/unittests/wire/WireWGPUDevicePropertiesTests.cpp diff --git a/generator/templates/dawn/wire/WireCmd.cpp b/generator/templates/dawn/wire/WireCmd.cpp index c945bee871..d0a220d729 100644 --- a/generator/templates/dawn/wire/WireCmd.cpp +++ b/generator/templates/dawn/wire/WireCmd.cpp @@ -784,72 +784,4 @@ namespace dawn::wire { {{ write_command_serialization_methods(command, True) }} {% endfor %} - // Implementations of serialization/deserialization of WPGUDeviceProperties. - size_t SerializedWGPUDevicePropertiesSize(const WGPUDeviceProperties* deviceProperties) { - return sizeof(WGPUDeviceProperties) + - WGPUDevicePropertiesGetExtraRequiredSize(*deviceProperties); - } - - void SerializeWGPUDeviceProperties(const WGPUDeviceProperties* deviceProperties, - char* buffer) { - SerializeBuffer serializeBuffer(buffer, SerializedWGPUDevicePropertiesSize(deviceProperties)); - - WGPUDevicePropertiesTransfer* transfer; - - WireResult result = serializeBuffer.Next(&transfer); - ASSERT(result == WireResult::Success); - - ErrorObjectIdProvider provider; - result = WGPUDevicePropertiesSerialize(*deviceProperties, transfer, &serializeBuffer, provider); - ASSERT(result == WireResult::Success); - } - - bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties, - const volatile char* buffer, - size_t size) { - const volatile WGPUDevicePropertiesTransfer* transfer; - DeserializeBuffer deserializeBuffer(buffer, size); - if (deserializeBuffer.Read(&transfer) != WireResult::Success) { - return false; - } - - ErrorObjectIdResolver resolver; - return WGPUDevicePropertiesDeserialize(deviceProperties, transfer, &deserializeBuffer, - nullptr, resolver) == WireResult::Success; - } - - size_t SerializedWGPUSupportedLimitsSize(const WGPUSupportedLimits* supportedLimits) { - return sizeof(WGPUSupportedLimits) + - WGPUSupportedLimitsGetExtraRequiredSize(*supportedLimits); - } - - void SerializeWGPUSupportedLimits( - const WGPUSupportedLimits* supportedLimits, - char* buffer) { - SerializeBuffer serializeBuffer(buffer, SerializedWGPUSupportedLimitsSize(supportedLimits)); - - WGPUSupportedLimitsTransfer* transfer; - - WireResult result = serializeBuffer.Next(&transfer); - ASSERT(result == WireResult::Success); - - ErrorObjectIdProvider provider; - result = WGPUSupportedLimitsSerialize(*supportedLimits, transfer, &serializeBuffer, provider); - ASSERT(result == WireResult::Success); - } - - bool DeserializeWGPUSupportedLimits(WGPUSupportedLimits* supportedLimits, - const volatile char* buffer, - size_t size) { - const volatile WGPUSupportedLimitsTransfer* transfer; - DeserializeBuffer deserializeBuffer(buffer, size); - if (deserializeBuffer.Read(&transfer) != WireResult::Success) { - return false; - } - - ErrorObjectIdResolver resolver; - return WGPUSupportedLimitsDeserialize(supportedLimits, transfer, &deserializeBuffer, - nullptr, resolver) == WireResult::Success; - } - } // namespace dawn::wire diff --git a/include/dawn/wire/Wire.h b/include/dawn/wire/Wire.h index 1f8e96b42f..e866db3dd8 100644 --- a/include/dawn/wire/Wire.h +++ b/include/dawn/wire/Wire.h @@ -50,26 +50,6 @@ class DAWN_WIRE_EXPORT CommandHandler { virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) = 0; }; -DAWN_WIRE_EXPORT size_t -SerializedWGPUDevicePropertiesSize(const WGPUDeviceProperties* deviceProperties); - -DAWN_WIRE_EXPORT void SerializeWGPUDeviceProperties(const WGPUDeviceProperties* deviceProperties, - char* serializeBuffer); - -DAWN_WIRE_EXPORT bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties, - const volatile char* deserializeBuffer, - size_t deserializeBufferSize); - -DAWN_WIRE_EXPORT size_t -SerializedWGPUSupportedLimitsSize(const WGPUSupportedLimits* supportedLimits); - -DAWN_WIRE_EXPORT void SerializeWGPUSupportedLimits(const WGPUSupportedLimits* supportedLimits, - char* serializeBuffer); - -DAWN_WIRE_EXPORT bool DeserializeWGPUSupportedLimits(WGPUSupportedLimits* supportedLimits, - const volatile char* deserializeBuffer, - size_t deserializeBufferSize); - } // namespace dawn::wire // TODO(dawn:824): Remove once the deprecation period is passed. diff --git a/src/dawn/tests/BUILD.gn b/src/dawn/tests/BUILD.gn index fea0b8c356..9323299e24 100644 --- a/src/dawn/tests/BUILD.gn +++ b/src/dawn/tests/BUILD.gn @@ -321,7 +321,6 @@ dawn_test("dawn_unittests") { "unittests/wire/WireShaderModuleTests.cpp", "unittests/wire/WireTest.cpp", "unittests/wire/WireTest.h", - "unittests/wire/WireWGPUDevicePropertiesTests.cpp", ] if (is_win) { diff --git a/src/dawn/tests/unittests/wire/WireWGPUDevicePropertiesTests.cpp b/src/dawn/tests/unittests/wire/WireWGPUDevicePropertiesTests.cpp deleted file mode 100644 index eba7569ce1..0000000000 --- a/src/dawn/tests/unittests/wire/WireWGPUDevicePropertiesTests.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2019 The Dawn Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include "dawn/wire/Wire.h" -#include "gtest/gtest.h" - -class WireWGPUDevicePropertiesTests : public testing::Test {}; - -// Test that the serialization and deserialization of WGPUDeviceProperties can work correctly. -TEST_F(WireWGPUDevicePropertiesTests, SerializeWGPUDeviceProperties) { - WGPUDeviceProperties sentWGPUDeviceProperties = {}; - sentWGPUDeviceProperties.textureCompressionBC = true; - // Set false to test that the serialization can handle both true and false correctly. - sentWGPUDeviceProperties.pipelineStatisticsQuery = false; - sentWGPUDeviceProperties.timestampQuery = true; - - size_t sentWGPUDevicePropertiesSize = - dawn::wire::SerializedWGPUDevicePropertiesSize(&sentWGPUDeviceProperties); - std::vector buffer; - buffer.resize(sentWGPUDevicePropertiesSize); - dawn::wire::SerializeWGPUDeviceProperties(&sentWGPUDeviceProperties, buffer.data()); - - WGPUDeviceProperties receivedWGPUDeviceProperties; - ASSERT_TRUE(dawn::wire::DeserializeWGPUDeviceProperties(&receivedWGPUDeviceProperties, - buffer.data(), buffer.size())); - ASSERT_TRUE(receivedWGPUDeviceProperties.textureCompressionBC); - ASSERT_FALSE(receivedWGPUDeviceProperties.pipelineStatisticsQuery); - ASSERT_TRUE(receivedWGPUDeviceProperties.timestampQuery); -} - -// Test that deserialization if the buffer is just one byte too small fails. -TEST_F(WireWGPUDevicePropertiesTests, DeserializeBufferTooSmall) { - WGPUDeviceProperties sentWGPUDeviceProperties = {}; - - size_t sentWGPUDevicePropertiesSize = - dawn::wire::SerializedWGPUDevicePropertiesSize(&sentWGPUDeviceProperties); - std::vector buffer; - buffer.resize(sentWGPUDevicePropertiesSize); - dawn::wire::SerializeWGPUDeviceProperties(&sentWGPUDeviceProperties, buffer.data()); - - WGPUDeviceProperties receivedWGPUDeviceProperties; - ASSERT_FALSE(dawn::wire::DeserializeWGPUDeviceProperties(&receivedWGPUDeviceProperties, - buffer.data(), buffer.size() - 1)); -}