Remove deprecated Wire APIs

Bug: dawn:565
Change-Id: I577532347c79e64b418a93551027e89910c3ce68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/40480
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Austin Eng 2021-02-05 23:36:30 +00:00 committed by Commit Bot service account
parent 20d5e380b3
commit 7fe5aa2eac
14 changed files with 18 additions and 49 deletions

View File

@ -142,7 +142,6 @@ wgpu::Device CreateCppDawnDevice() {
s2cBuf = new utils::TerribleCommandBuffer(); s2cBuf = new utils::TerribleCommandBuffer();
dawn_wire::WireServerDescriptor serverDesc = {}; dawn_wire::WireServerDescriptor serverDesc = {};
serverDesc.device = backendDevice;
serverDesc.procs = &backendProcs; serverDesc.procs = &backendProcs;
serverDesc.serializer = s2cBuf; serverDesc.serializer = s2cBuf;
@ -153,9 +152,14 @@ wgpu::Device CreateCppDawnDevice() {
clientDesc.serializer = c2sBuf; clientDesc.serializer = c2sBuf;
wireClient = new dawn_wire::WireClient(clientDesc); wireClient = new dawn_wire::WireClient(clientDesc);
cDevice = wireClient->GetDevice();
procs = dawn_wire::client::GetProcs(); procs = dawn_wire::client::GetProcs();
s2cBuf->SetHandler(wireClient); s2cBuf->SetHandler(wireClient);
auto deviceReservation = wireClient->ReserveDevice();
wireServer->InjectDevice(backendDevice, deviceReservation.id,
deviceReservation.generation);
cDevice = deviceReservation.device;
} break; } break;
} }

View File

@ -689,10 +689,6 @@ namespace dawn_wire {
bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties, bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties,
const volatile char* deserializeBuffer, const volatile char* deserializeBuffer,
size_t deserializeBufferSize) { size_t deserializeBufferSize) {
if (deserializeBufferSize == 0) {
// TODO(enga): Remove this after updating Chromium.
deserializeBufferSize = SerializedWGPUDevicePropertiesSize(deviceProperties);
}
const volatile WGPUDevicePropertiesTransfer* transfer = nullptr; const volatile WGPUDevicePropertiesTransfer* transfer = nullptr;
if (GetPtrFromBuffer(&deserializeBuffer, &deserializeBufferSize, 1, &transfer) != if (GetPtrFromBuffer(&deserializeBuffer, &deserializeBufferSize, 1, &transfer) !=
DeserializeResult::Success) { DeserializeResult::Success) {

View File

@ -25,10 +25,6 @@ namespace dawn_wire {
mImpl.reset(); mImpl.reset();
} }
WGPUDevice WireClient::GetDevice() const {
return mImpl->GetDevice();
}
const volatile char* WireClient::HandleCommands(const volatile char* commands, size_t size) { const volatile char* WireClient::HandleCommands(const volatile char* commands, size_t size) {
return mImpl->HandleCommands(commands, size); return mImpl->HandleCommands(commands, size);
} }

View File

@ -18,8 +18,7 @@
namespace dawn_wire { namespace dawn_wire {
WireServer::WireServer(const WireServerDescriptor& descriptor) WireServer::WireServer(const WireServerDescriptor& descriptor)
: mImpl(new server::Server(descriptor.device, : mImpl(new server::Server(*descriptor.procs,
*descriptor.procs,
descriptor.serializer, descriptor.serializer,
descriptor.memoryTransferService)) { descriptor.memoryTransferService)) {
} }

View File

@ -84,18 +84,6 @@ namespace dawn_wire { namespace client {
} }
} }
WGPUDevice Client::GetDevice() {
// This function is deprecated. The concept of a "default" device on the wire
// will be removed in favor of ReserveDevice/InjectDevice.
if (mDevice == nullptr) {
ReservedDevice reservation = ReserveDevice();
mDevice = FromAPI(reservation.device);
ASSERT(reservation.id == 1);
ASSERT(reservation.generation == 0);
}
return reinterpret_cast<WGPUDeviceImpl*>(mDevice);
}
ReservedTexture Client::ReserveTexture(WGPUDevice device) { ReservedTexture Client::ReserveTexture(WGPUDevice device) {
auto* allocation = TextureAllocator().New(this); auto* allocation = TextureAllocator().New(this);

View File

@ -39,8 +39,6 @@ namespace dawn_wire { namespace client {
const volatile char* HandleCommandsImpl(const volatile char* commands, const volatile char* HandleCommandsImpl(const volatile char* commands,
size_t size) override; size_t size) override;
WGPUDevice GetDevice();
MemoryTransferService* GetMemoryTransferService() const { MemoryTransferService* GetMemoryTransferService() const {
return mMemoryTransferService; return mMemoryTransferService;
} }
@ -76,7 +74,6 @@ namespace dawn_wire { namespace client {
#include "dawn_wire/client/ClientPrototypes_autogen.inc" #include "dawn_wire/client/ClientPrototypes_autogen.inc"
Device* mDevice = nullptr;
ChunkedCommandSerializer mSerializer; ChunkedCommandSerializer mSerializer;
WireDeserializeAllocator mAllocator; WireDeserializeAllocator mAllocator;
MemoryTransferService* mMemoryTransferService = nullptr; MemoryTransferService* mMemoryTransferService = nullptr;

View File

@ -17,8 +17,7 @@
namespace dawn_wire { namespace server { namespace dawn_wire { namespace server {
Server::Server(WGPUDevice device, Server::Server(const DawnProcTable& procs,
const DawnProcTable& procs,
CommandSerializer* serializer, CommandSerializer* serializer,
MemoryTransferService* memoryTransferService) MemoryTransferService* memoryTransferService)
: mSerializer(serializer), : mSerializer(serializer),
@ -30,13 +29,6 @@ namespace dawn_wire { namespace server {
mOwnedMemoryTransferService = CreateInlineMemoryTransferService(); mOwnedMemoryTransferService = CreateInlineMemoryTransferService();
mMemoryTransferService = mOwnedMemoryTransferService.get(); mMemoryTransferService = mOwnedMemoryTransferService.get();
} }
// For the deprecated initialization path:
// The client-server knowledge is bootstrapped with device 1, generation 0.
if (device != nullptr) {
bool success = InjectDevice(device, 1, 0);
ASSERT(success);
}
} }
Server::~Server() { Server::~Server() {

View File

@ -151,8 +151,7 @@ namespace dawn_wire { namespace server {
class Server : public ServerBase { class Server : public ServerBase {
public: public:
Server(WGPUDevice device, Server(const DawnProcTable& procs,
const DawnProcTable& procs,
CommandSerializer* serializer, CommandSerializer* serializer,
MemoryTransferService* memoryTransferService); MemoryTransferService* memoryTransferService);
~Server() override; ~Server() override;

View File

@ -152,11 +152,12 @@ int DawnWireServerFuzzer::Run(const uint8_t* data,
DevNull devNull; DevNull devNull;
dawn_wire::WireServerDescriptor serverDesc = {}; dawn_wire::WireServerDescriptor serverDesc = {};
serverDesc.device = device.Get();
serverDesc.procs = &procs; serverDesc.procs = &procs;
serverDesc.serializer = &devNull; serverDesc.serializer = &devNull;
std::unique_ptr<dawn_wire::WireServer> wireServer(new dawn_wire::WireServer(serverDesc)); std::unique_ptr<dawn_wire::WireServer> wireServer(new dawn_wire::WireServer(serverDesc));
wireServer->InjectDevice(device.Get(), 1, 0);
device = nullptr; // Server owns the device now.
wireServer->HandleCommands(reinterpret_cast<const char*>(data), size); wireServer->HandleCommands(reinterpret_cast<const char*>(data), size);
@ -173,9 +174,7 @@ int DawnWireServerFuzzer::Run(const uint8_t* data,
} }
} }
// Destroy the server before the device because it needs to free all objects.
wireServer = nullptr; wireServer = nullptr;
device = nullptr;
// If we support error injection, and an output directory was provided, output copies of the // If we support error injection, and an output directory was provided, output copies of the
// original testcase data, prepended with the injected error index. // original testcase data, prepended with the injected error index.

View File

@ -49,10 +49,9 @@ namespace dawn_wire {
const WGPUDeviceProperties* deviceProperties, const WGPUDeviceProperties* deviceProperties,
char* serializeBuffer); char* serializeBuffer);
// TODO(enga): Remove the default value after updating Chromium.
DAWN_WIRE_EXPORT bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties, DAWN_WIRE_EXPORT bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties,
const volatile char* deserializeBuffer, const volatile char* deserializeBuffer,
size_t deserializeBufferSize = 0); size_t deserializeBufferSize);
} // namespace dawn_wire } // namespace dawn_wire

View File

@ -54,7 +54,6 @@ namespace dawn_wire {
WireClient(const WireClientDescriptor& descriptor); WireClient(const WireClientDescriptor& descriptor);
~WireClient() override; ~WireClient() override;
WGPUDevice GetDevice() const;
const volatile char* HandleCommands(const volatile char* commands, const volatile char* HandleCommands(const volatile char* commands,
size_t size) override final; size_t size) override final;

View File

@ -29,7 +29,6 @@ namespace dawn_wire {
} // namespace server } // namespace server
struct DAWN_WIRE_EXPORT WireServerDescriptor { struct DAWN_WIRE_EXPORT WireServerDescriptor {
WGPUDevice device;
const DawnProcTable* procs; const DawnProcTable* procs;
CommandSerializer* serializer; CommandSerializer* serializer;
server::MemoryTransferService* memoryTransferService = nullptr; server::MemoryTransferService* memoryTransferService = nullptr;

View File

@ -71,7 +71,7 @@ namespace {
clientDesc.serializer = mC2sBuf.get(); clientDesc.serializer = mC2sBuf.get();
mWireClient = std::make_unique<dawn_wire::WireClient>(clientDesc); mWireClient = std::make_unique<dawn_wire::WireClient>(clientDesc);
mDevice = wgpu::Device::Acquire(mWireClient->GetDevice()); mDevice = wgpu::Device::Acquire(mWireClient->ReserveDevice().device);
mProcs = dawn_wire::client::GetProcs(); mProcs = dawn_wire::client::GetProcs();
break; break;
} }

View File

@ -50,12 +50,10 @@ void WireTest::SetUp() {
mC2sBuf = std::make_unique<utils::TerribleCommandBuffer>(mWireServer.get()); mC2sBuf = std::make_unique<utils::TerribleCommandBuffer>(mWireServer.get());
WireServerDescriptor serverDesc = {}; WireServerDescriptor serverDesc = {};
serverDesc.device = mockDevice;
serverDesc.procs = &mockProcs; serverDesc.procs = &mockProcs;
serverDesc.serializer = mS2cBuf.get(); serverDesc.serializer = mS2cBuf.get();
serverDesc.memoryTransferService = GetServerMemoryTransferService(); serverDesc.memoryTransferService = GetServerMemoryTransferService();
EXPECT_CALL(api, DeviceReference(mockDevice));
mWireServer.reset(new WireServer(serverDesc)); mWireServer.reset(new WireServer(serverDesc));
mC2sBuf->SetHandler(mWireServer.get()); mC2sBuf->SetHandler(mWireServer.get());
@ -66,9 +64,13 @@ void WireTest::SetUp() {
mWireClient.reset(new WireClient(clientDesc)); mWireClient.reset(new WireClient(clientDesc));
mS2cBuf->SetHandler(mWireClient.get()); mS2cBuf->SetHandler(mWireClient.get());
device = mWireClient->GetDevice();
dawnProcSetProcs(&dawn_wire::client::GetProcs()); dawnProcSetProcs(&dawn_wire::client::GetProcs());
auto deviceReservation = mWireClient->ReserveDevice();
EXPECT_CALL(api, DeviceReference(mockDevice));
mWireServer->InjectDevice(mockDevice, deviceReservation.id, deviceReservation.generation);
device = deviceReservation.device;
apiDevice = mockDevice; apiDevice = mockDevice;
// The GetQueue is done on WireClient startup so we expect it now. // The GetQueue is done on WireClient startup so we expect it now.