Consistent formatting for Dawn/Tint.

This CL updates the clang format files to have a single shared format
between Dawn and Tint. The major changes are tabs are 4 spaces, lines
are 100 columns and namespaces are not indented.

Bug: dawn:1339
Change-Id: I4208742c95643998d9fd14e77a9cc558071ded39
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87603
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
dan sinclair
2022-05-01 14:40:55 +00:00
committed by Dawn LUCI CQ
parent 73b1d1dafa
commit 41e4d9a34c
1827 changed files with 218382 additions and 227741 deletions

View File

@@ -23,53 +23,52 @@
namespace dawn::wire {
class DAWN_WIRE_EXPORT CommandSerializer {
public:
CommandSerializer();
virtual ~CommandSerializer();
CommandSerializer(const CommandSerializer& rhs) = delete;
CommandSerializer& operator=(const CommandSerializer& rhs) = delete;
class DAWN_WIRE_EXPORT CommandSerializer {
public:
CommandSerializer();
virtual ~CommandSerializer();
CommandSerializer(const CommandSerializer& rhs) = delete;
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) = 0;
virtual bool Flush() = 0;
virtual size_t GetMaximumAllocationSize() const = 0;
virtual void OnSerializeError();
};
// 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) = 0;
virtual bool Flush() = 0;
virtual size_t GetMaximumAllocationSize() const = 0;
virtual void OnSerializeError();
};
class DAWN_WIRE_EXPORT CommandHandler {
public:
CommandHandler();
virtual ~CommandHandler();
CommandHandler(const CommandHandler& rhs) = delete;
CommandHandler& operator=(const CommandHandler& rhs) = delete;
class DAWN_WIRE_EXPORT CommandHandler {
public:
CommandHandler();
virtual ~CommandHandler();
CommandHandler(const CommandHandler& rhs) = delete;
CommandHandler& operator=(const CommandHandler& rhs) = delete;
virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) = 0;
};
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 size_t
SerializedWGPUDevicePropertiesSize(const WGPUDeviceProperties* deviceProperties);
DAWN_WIRE_EXPORT void SerializeWGPUDeviceProperties(
const WGPUDeviceProperties* deviceProperties,
char* serializeBuffer);
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 bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties,
const volatile char* deserializeBuffer,
size_t deserializeBufferSize);
DAWN_WIRE_EXPORT size_t
SerializedWGPUSupportedLimitsSize(const WGPUSupportedLimits* supportedLimits);
DAWN_WIRE_EXPORT size_t
SerializedWGPUSupportedLimitsSize(const WGPUSupportedLimits* supportedLimits);
DAWN_WIRE_EXPORT void SerializeWGPUSupportedLimits(const WGPUSupportedLimits* supportedLimits,
char* serializeBuffer);
DAWN_WIRE_EXPORT void SerializeWGPUSupportedLimits(const WGPUSupportedLimits* supportedLimits,
char* serializeBuffer);
DAWN_WIRE_EXPORT bool DeserializeWGPUSupportedLimits(WGPUSupportedLimits* supportedLimits,
const volatile char* deserializeBuffer,
size_t deserializeBufferSize);
DAWN_WIRE_EXPORT bool DeserializeWGPUSupportedLimits(WGPUSupportedLimits* supportedLimits,
const volatile char* deserializeBuffer,
size_t deserializeBufferSize);
} // namespace dawn::wire

View File

@@ -23,160 +23,158 @@
namespace dawn::wire {
namespace client {
class Client;
class MemoryTransferService;
namespace client {
class Client;
class MemoryTransferService;
DAWN_WIRE_EXPORT const DawnProcTable& GetProcs();
} // namespace client
DAWN_WIRE_EXPORT const DawnProcTable& GetProcs();
} // namespace client
struct ReservedTexture {
WGPUTexture texture;
uint32_t id;
uint32_t generation;
uint32_t deviceId;
uint32_t deviceGeneration;
};
struct ReservedTexture {
WGPUTexture texture;
uint32_t id;
uint32_t generation;
uint32_t deviceId;
uint32_t deviceGeneration;
};
struct ReservedSwapChain {
WGPUSwapChain swapchain;
uint32_t id;
uint32_t generation;
uint32_t deviceId;
uint32_t deviceGeneration;
};
struct ReservedSwapChain {
WGPUSwapChain swapchain;
uint32_t id;
uint32_t generation;
uint32_t deviceId;
uint32_t deviceGeneration;
};
struct ReservedDevice {
WGPUDevice device;
uint32_t id;
uint32_t generation;
};
struct ReservedDevice {
WGPUDevice device;
uint32_t id;
uint32_t generation;
};
struct ReservedInstance {
WGPUInstance instance;
uint32_t id;
uint32_t generation;
};
struct ReservedInstance {
WGPUInstance instance;
uint32_t id;
uint32_t generation;
};
struct DAWN_WIRE_EXPORT WireClientDescriptor {
CommandSerializer* serializer;
client::MemoryTransferService* memoryTransferService = nullptr;
};
struct DAWN_WIRE_EXPORT WireClientDescriptor {
CommandSerializer* serializer;
client::MemoryTransferService* memoryTransferService = nullptr;
};
class DAWN_WIRE_EXPORT WireClient : public CommandHandler {
class DAWN_WIRE_EXPORT WireClient : public CommandHandler {
public:
explicit WireClient(const WireClientDescriptor& descriptor);
~WireClient() override;
const volatile char* HandleCommands(const volatile char* commands, size_t size) final;
ReservedTexture ReserveTexture(WGPUDevice device);
ReservedSwapChain ReserveSwapChain(WGPUDevice device);
ReservedDevice ReserveDevice();
ReservedInstance ReserveInstance();
void ReclaimTextureReservation(const ReservedTexture& reservation);
void ReclaimSwapChainReservation(const ReservedSwapChain& reservation);
void ReclaimDeviceReservation(const ReservedDevice& reservation);
void ReclaimInstanceReservation(const ReservedInstance& reservation);
// Disconnects the client.
// Commands allocated after this point will not be sent.
void Disconnect();
private:
std::unique_ptr<client::Client> mImpl;
};
namespace client {
class DAWN_WIRE_EXPORT MemoryTransferService {
public:
MemoryTransferService();
virtual ~MemoryTransferService();
class ReadHandle;
class WriteHandle;
// Create a handle for reading server data.
// This may fail and return nullptr.
virtual ReadHandle* CreateReadHandle(size_t) = 0;
// Create a handle for writing server data.
// This may fail and return nullptr.
virtual WriteHandle* CreateWriteHandle(size_t) = 0;
class DAWN_WIRE_EXPORT ReadHandle {
public:
explicit WireClient(const WireClientDescriptor& descriptor);
~WireClient() override;
ReadHandle();
virtual ~ReadHandle();
const volatile char* HandleCommands(const volatile char* commands, size_t size) final;
// Get the required serialization size for SerializeCreate
virtual size_t SerializeCreateSize() = 0;
ReservedTexture ReserveTexture(WGPUDevice device);
ReservedSwapChain ReserveSwapChain(WGPUDevice device);
ReservedDevice ReserveDevice();
ReservedInstance ReserveInstance();
// Serialize the handle into |serializePointer| so it can be received by the server.
virtual void SerializeCreate(void* serializePointer) = 0;
void ReclaimTextureReservation(const ReservedTexture& reservation);
void ReclaimSwapChainReservation(const ReservedSwapChain& reservation);
void ReclaimDeviceReservation(const ReservedDevice& reservation);
void ReclaimInstanceReservation(const ReservedInstance& reservation);
// Simply return the base address of the allocation (without applying any offset)
// Returns nullptr if the allocation failed.
// The data must live at least until the ReadHandle is destructued
virtual const void* GetData() = 0;
// Disconnects the client.
// Commands allocated after this point will not be sent.
void Disconnect();
// Gets called when a MapReadCallback resolves.
// deserialize the data update and apply
// it to the range (offset, offset + size) of allocation
// There could be nothing to be deserialized (if using shared memory)
// Needs to check potential offset/size OOB and overflow
virtual bool DeserializeDataUpdate(const void* deserializePointer,
size_t deserializeSize,
size_t offset,
size_t size) = 0;
private:
std::unique_ptr<client::Client> mImpl;
ReadHandle(const ReadHandle&) = delete;
ReadHandle& operator=(const ReadHandle&) = delete;
};
namespace client {
class DAWN_WIRE_EXPORT MemoryTransferService {
public:
MemoryTransferService();
virtual ~MemoryTransferService();
class DAWN_WIRE_EXPORT WriteHandle {
public:
WriteHandle();
virtual ~WriteHandle();
class ReadHandle;
class WriteHandle;
// Get the required serialization size for SerializeCreate
virtual size_t SerializeCreateSize() = 0;
// Create a handle for reading server data.
// This may fail and return nullptr.
virtual ReadHandle* CreateReadHandle(size_t) = 0;
// Serialize the handle into |serializePointer| so it can be received by the server.
virtual void SerializeCreate(void* serializePointer) = 0;
// Create a handle for writing server data.
// This may fail and return nullptr.
virtual WriteHandle* CreateWriteHandle(size_t) = 0;
// Simply return the base address of the allocation (without applying any offset)
// The data returned should be zero-initialized.
// The data returned must live at least until the WriteHandle is destructed.
// On failure, the pointer returned should be null.
virtual void* GetData() = 0;
class DAWN_WIRE_EXPORT ReadHandle {
public:
ReadHandle();
virtual ~ReadHandle();
// Get the required serialization size for SerializeDataUpdate
virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
// Get the required serialization size for SerializeCreate
virtual size_t SerializeCreateSize() = 0;
// Serialize a command to send the modified contents of
// the subrange (offset, offset + size) of the allocation at buffer unmap
// This subrange is always the whole mapped region for now
// There could be nothing to be serialized (if using shared memory)
virtual void SerializeDataUpdate(void* serializePointer, size_t offset, size_t size) = 0;
// Serialize the handle into |serializePointer| so it can be received by the server.
virtual void SerializeCreate(void* serializePointer) = 0;
private:
WriteHandle(const WriteHandle&) = delete;
WriteHandle& operator=(const WriteHandle&) = delete;
};
// Simply return the base address of the allocation (without applying any offset)
// Returns nullptr if the allocation failed.
// The data must live at least until the ReadHandle is destructued
virtual const void* GetData() = 0;
private:
MemoryTransferService(const MemoryTransferService&) = delete;
MemoryTransferService& operator=(const MemoryTransferService&) = delete;
};
// Gets called when a MapReadCallback resolves.
// deserialize the data update and apply
// it to the range (offset, offset + size) of allocation
// There could be nothing to be deserialized (if using shared memory)
// Needs to check potential offset/size OOB and overflow
virtual bool DeserializeDataUpdate(const void* deserializePointer,
size_t deserializeSize,
size_t offset,
size_t size) = 0;
private:
ReadHandle(const ReadHandle&) = delete;
ReadHandle& operator=(const ReadHandle&) = delete;
};
class DAWN_WIRE_EXPORT WriteHandle {
public:
WriteHandle();
virtual ~WriteHandle();
// Get the required serialization size for SerializeCreate
virtual size_t SerializeCreateSize() = 0;
// Serialize the handle into |serializePointer| so it can be received by the server.
virtual void SerializeCreate(void* serializePointer) = 0;
// Simply return the base address of the allocation (without applying any offset)
// The data returned should be zero-initialized.
// The data returned must live at least until the WriteHandle is destructed.
// On failure, the pointer returned should be null.
virtual void* GetData() = 0;
// Get the required serialization size for SerializeDataUpdate
virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
// Serialize a command to send the modified contents of
// the subrange (offset, offset + size) of the allocation at buffer unmap
// This subrange is always the whole mapped region for now
// There could be nothing to be serialized (if using shared memory)
virtual void SerializeDataUpdate(void* serializePointer,
size_t offset,
size_t size) = 0;
private:
WriteHandle(const WriteHandle&) = delete;
WriteHandle& operator=(const WriteHandle&) = delete;
};
private:
MemoryTransferService(const MemoryTransferService&) = delete;
MemoryTransferService& operator=(const MemoryTransferService&) = delete;
};
// Backdoor to get the order of the ProcMap for testing
DAWN_WIRE_EXPORT std::vector<const char*> GetProcMapNamesForTesting();
} // namespace client
// Backdoor to get the order of the ProcMap for testing
DAWN_WIRE_EXPORT std::vector<const char*> GetProcMapNamesForTesting();
} // namespace client
} // namespace dawn::wire
#endif // INCLUDE_DAWN_WIRE_WIRECLIENT_H_

View File

@@ -23,126 +23,126 @@ struct DawnProcTable;
namespace dawn::wire {
namespace server {
class Server;
class MemoryTransferService;
} // namespace server
namespace server {
class Server;
class MemoryTransferService;
} // namespace server
struct DAWN_WIRE_EXPORT WireServerDescriptor {
const DawnProcTable* procs;
CommandSerializer* serializer;
server::MemoryTransferService* memoryTransferService = nullptr;
};
struct DAWN_WIRE_EXPORT WireServerDescriptor {
const DawnProcTable* procs;
CommandSerializer* serializer;
server::MemoryTransferService* memoryTransferService = nullptr;
};
class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
public:
explicit WireServer(const WireServerDescriptor& descriptor);
~WireServer() override;
const volatile char* HandleCommands(const volatile char* commands, size_t size) final;
bool InjectTexture(WGPUTexture texture,
uint32_t id,
uint32_t generation,
uint32_t deviceId,
uint32_t deviceGeneration);
bool InjectSwapChain(WGPUSwapChain swapchain,
uint32_t id,
uint32_t generation,
uint32_t deviceId,
uint32_t deviceGeneration);
bool InjectDevice(WGPUDevice device, uint32_t id, uint32_t generation);
bool InjectInstance(WGPUInstance instance, uint32_t id, uint32_t generation);
// Look up a device by (id, generation) pair. Returns nullptr if the generation
// has expired or the id is not found.
// The Wire does not have destroy hooks to allow an embedder to observe when an object
// has been destroyed, but in Chrome, we need to know the list of live devices so we
// can call device.Tick() on all of them periodically to ensure progress on asynchronous
// work is made. Getting this list can be done by tracking the (id, generation) of
// previously injected devices, and observing if GetDevice(id, generation) returns non-null.
WGPUDevice GetDevice(uint32_t id, uint32_t generation);
private:
std::unique_ptr<server::Server> mImpl;
};
namespace server {
class DAWN_WIRE_EXPORT MemoryTransferService {
public:
MemoryTransferService();
virtual ~MemoryTransferService();
class ReadHandle;
class WriteHandle;
// Deserialize data to create Read/Write handles. These handles are for the client
// to Read/Write data.
virtual bool DeserializeReadHandle(const void* deserializePointer,
size_t deserializeSize,
ReadHandle** readHandle) = 0;
virtual bool DeserializeWriteHandle(const void* deserializePointer,
size_t deserializeSize,
WriteHandle** writeHandle) = 0;
class DAWN_WIRE_EXPORT ReadHandle {
public:
explicit WireServer(const WireServerDescriptor& descriptor);
~WireServer() override;
ReadHandle();
virtual ~ReadHandle();
const volatile char* HandleCommands(const volatile char* commands, size_t size) final;
// Return the size of the command serialized if
// SerializeDataUpdate is called with the same offset/size args
virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
bool InjectTexture(WGPUTexture texture,
uint32_t id,
uint32_t generation,
uint32_t deviceId,
uint32_t deviceGeneration);
bool InjectSwapChain(WGPUSwapChain swapchain,
uint32_t id,
uint32_t generation,
uint32_t deviceId,
uint32_t deviceGeneration);
bool InjectDevice(WGPUDevice device, uint32_t id, uint32_t generation);
bool InjectInstance(WGPUInstance instance, uint32_t id, uint32_t generation);
// Look up a device by (id, generation) pair. Returns nullptr if the generation
// has expired or the id is not found.
// The Wire does not have destroy hooks to allow an embedder to observe when an object
// has been destroyed, but in Chrome, we need to know the list of live devices so we
// can call device.Tick() on all of them periodically to ensure progress on asynchronous
// work is made. Getting this list can be done by tracking the (id, generation) of
// previously injected devices, and observing if GetDevice(id, generation) returns non-null.
WGPUDevice GetDevice(uint32_t id, uint32_t generation);
// Gets called when a MapReadCallback resolves.
// Serialize the data update for the range (offset, offset + size) into
// |serializePointer| to the client There could be nothing to be serialized (if
// using shared memory)
virtual void SerializeDataUpdate(const void* data,
size_t offset,
size_t size,
void* serializePointer) = 0;
private:
std::unique_ptr<server::Server> mImpl;
ReadHandle(const ReadHandle&) = delete;
ReadHandle& operator=(const ReadHandle&) = delete;
};
namespace server {
class DAWN_WIRE_EXPORT MemoryTransferService {
public:
MemoryTransferService();
virtual ~MemoryTransferService();
class DAWN_WIRE_EXPORT WriteHandle {
public:
WriteHandle();
virtual ~WriteHandle();
class ReadHandle;
class WriteHandle;
// Set the target for writes from the client. DeserializeFlush should copy data
// into the target.
void SetTarget(void* data);
// Set Staging data length for OOB check
void SetDataLength(size_t dataLength);
// Deserialize data to create Read/Write handles. These handles are for the client
// to Read/Write data.
virtual bool DeserializeReadHandle(const void* deserializePointer,
size_t deserializeSize,
ReadHandle** readHandle) = 0;
virtual bool DeserializeWriteHandle(const void* deserializePointer,
size_t deserializeSize,
WriteHandle** writeHandle) = 0;
// This function takes in the serialized result of
// client::MemoryTransferService::WriteHandle::SerializeDataUpdate.
// Needs to check potential offset/size OOB and overflow
virtual bool DeserializeDataUpdate(const void* deserializePointer,
size_t deserializeSize,
size_t offset,
size_t size) = 0;
class DAWN_WIRE_EXPORT ReadHandle {
public:
ReadHandle();
virtual ~ReadHandle();
protected:
void* mTargetData = nullptr;
size_t mDataLength = 0;
// Return the size of the command serialized if
// SerializeDataUpdate is called with the same offset/size args
virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
private:
WriteHandle(const WriteHandle&) = delete;
WriteHandle& operator=(const WriteHandle&) = delete;
};
// Gets called when a MapReadCallback resolves.
// Serialize the data update for the range (offset, offset + size) into
// |serializePointer| to the client There could be nothing to be serialized (if
// using shared memory)
virtual void SerializeDataUpdate(const void* data,
size_t offset,
size_t size,
void* serializePointer) = 0;
private:
ReadHandle(const ReadHandle&) = delete;
ReadHandle& operator=(const ReadHandle&) = delete;
};
class DAWN_WIRE_EXPORT WriteHandle {
public:
WriteHandle();
virtual ~WriteHandle();
// Set the target for writes from the client. DeserializeFlush should copy data
// into the target.
void SetTarget(void* data);
// Set Staging data length for OOB check
void SetDataLength(size_t dataLength);
// This function takes in the serialized result of
// client::MemoryTransferService::WriteHandle::SerializeDataUpdate.
// Needs to check potential offset/size OOB and overflow
virtual bool DeserializeDataUpdate(const void* deserializePointer,
size_t deserializeSize,
size_t offset,
size_t size) = 0;
protected:
void* mTargetData = nullptr;
size_t mDataLength = 0;
private:
WriteHandle(const WriteHandle&) = delete;
WriteHandle& operator=(const WriteHandle&) = delete;
};
private:
MemoryTransferService(const MemoryTransferService&) = delete;
MemoryTransferService& operator=(const MemoryTransferService&) = delete;
};
} // namespace server
private:
MemoryTransferService(const MemoryTransferService&) = delete;
MemoryTransferService& operator=(const MemoryTransferService&) = delete;
};
} // namespace server
} // namespace dawn::wire

View File

@@ -16,21 +16,21 @@
#define INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_
#if defined(DAWN_WIRE_SHARED_LIBRARY)
# if defined(_WIN32)
# if defined(DAWN_WIRE_IMPLEMENTATION)
# define DAWN_WIRE_EXPORT __declspec(dllexport)
# else
# define DAWN_WIRE_EXPORT __declspec(dllimport)
# endif
# else // defined(_WIN32)
# if defined(DAWN_WIRE_IMPLEMENTATION)
# define DAWN_WIRE_EXPORT __attribute__((visibility("default")))
# else
# define DAWN_WIRE_EXPORT
# endif
# endif // defined(_WIN32)
#else // defined(DAWN_WIRE_SHARED_LIBRARY)
# define DAWN_WIRE_EXPORT
#if defined(_WIN32)
#if defined(DAWN_WIRE_IMPLEMENTATION)
#define DAWN_WIRE_EXPORT __declspec(dllexport)
#else
#define DAWN_WIRE_EXPORT __declspec(dllimport)
#endif
#else // defined(_WIN32)
#if defined(DAWN_WIRE_IMPLEMENTATION)
#define DAWN_WIRE_EXPORT __attribute__((visibility("default")))
#else
#define DAWN_WIRE_EXPORT
#endif
#endif // defined(_WIN32)
#else // defined(DAWN_WIRE_SHARED_LIBRARY)
#define DAWN_WIRE_EXPORT
#endif // defined(DAWN_WIRE_SHARED_LIBRARY)
#endif // INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_