mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 19:01:24 +00:00
Replace the wire serializer with a no-op impl on disconnect
Now that the command serialization knows to no-op if GetCmdSpace returns nullptr, when the wire is disconnected, we can replace it with a no-op serializer that always returns nullptr. Bug: chromium:951558 Change-Id: I7363fd10f529119e515eda0e743e1a7839049b9b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30000 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
a7278454b2
commit
e757c012be
@ -19,6 +19,27 @@
|
|||||||
|
|
||||||
namespace dawn_wire { namespace client {
|
namespace dawn_wire { namespace client {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class NoopCommandSerializer final : public CommandSerializer {
|
||||||
|
public:
|
||||||
|
~NoopCommandSerializer() = default;
|
||||||
|
|
||||||
|
size_t GetMaximumAllocationSize() const final {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void* GetCmdSpace(size_t size) final {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
bool Flush() final {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NoopCommandSerializer gNoopCommandSerializer;
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
Client::Client(CommandSerializer* serializer, MemoryTransferService* memoryTransferService)
|
Client::Client(CommandSerializer* serializer, MemoryTransferService* memoryTransferService)
|
||||||
: ClientBase(), mSerializer(serializer), mMemoryTransferService(memoryTransferService) {
|
: ClientBase(), mSerializer(serializer), mMemoryTransferService(memoryTransferService) {
|
||||||
if (mMemoryTransferService == nullptr) {
|
if (mMemoryTransferService == nullptr) {
|
||||||
@ -53,11 +74,7 @@ namespace dawn_wire { namespace client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::Disconnect() {
|
void Client::Disconnect() {
|
||||||
if (mDisconnected) {
|
mSerializer = ChunkedCommandSerializer(&gNoopCommandSerializer);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mDisconnected = true;
|
|
||||||
if (mDevice != nullptr) {
|
if (mDevice != nullptr) {
|
||||||
mDevice->HandleDeviceLost("GPU connection lost");
|
mDevice->HandleDeviceLost("GPU connection lost");
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,6 @@ namespace dawn_wire { namespace client {
|
|||||||
|
|
||||||
template <typename Cmd>
|
template <typename Cmd>
|
||||||
void SerializeCommand(const Cmd& cmd) {
|
void SerializeCommand(const Cmd& cmd) {
|
||||||
// TODO(enga): Swap out the serializer with a no-op one on disconnect.
|
|
||||||
if (mDisconnected) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mSerializer.SerializeCommand(cmd, *this);
|
mSerializer.SerializeCommand(cmd, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,10 +55,6 @@ namespace dawn_wire { namespace client {
|
|||||||
void SerializeCommand(const Cmd& cmd,
|
void SerializeCommand(const Cmd& cmd,
|
||||||
size_t extraSize,
|
size_t extraSize,
|
||||||
ExtraSizeSerializeFn&& SerializeExtraSize) {
|
ExtraSizeSerializeFn&& SerializeExtraSize) {
|
||||||
// TODO(enga): Swap out the serializer with a no-op one on disconnect.
|
|
||||||
if (mDisconnected) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mSerializer.SerializeCommand(cmd, *this, extraSize, SerializeExtraSize);
|
mSerializer.SerializeCommand(cmd, *this, extraSize, SerializeExtraSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +68,6 @@ namespace dawn_wire { namespace client {
|
|||||||
WireDeserializeAllocator mAllocator;
|
WireDeserializeAllocator mAllocator;
|
||||||
MemoryTransferService* mMemoryTransferService = nullptr;
|
MemoryTransferService* mMemoryTransferService = nullptr;
|
||||||
std::unique_ptr<MemoryTransferService> mOwnedMemoryTransferService = nullptr;
|
std::unique_ptr<MemoryTransferService> mOwnedMemoryTransferService = nullptr;
|
||||||
bool mDisconnected = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<MemoryTransferService> CreateInlineMemoryTransferService();
|
std::unique_ptr<MemoryTransferService> CreateInlineMemoryTransferService();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user