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 <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
033cc153b3
commit
6a224fbd52
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 <vector>
|
||||
|
||||
#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<char> 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<char> buffer;
|
||||
buffer.resize(sentWGPUDevicePropertiesSize);
|
||||
dawn::wire::SerializeWGPUDeviceProperties(&sentWGPUDeviceProperties, buffer.data());
|
||||
|
||||
WGPUDeviceProperties receivedWGPUDeviceProperties;
|
||||
ASSERT_FALSE(dawn::wire::DeserializeWGPUDeviceProperties(&receivedWGPUDeviceProperties,
|
||||
buffer.data(), buffer.size() - 1));
|
||||
}
|
Loading…
Reference in New Issue