Reland "[chromium-style] Adding constructors and destructors."

This reverts commit 63cea3f8c0.

...except it skips adding the the constructor/destructor/copy
definitions for dawn::native::Format. Adding them triggers "constexpr
variable cannot have non-literal type" (or "declaration requires a
global constructor" if it's not marked constexpr), unless they're
explicitly marked as =default in the header - which just triggers a
different chromium-style warning, so there's no point.

A better solution to the chromium-style warning on Format may be to just
make the class physically smaller:
https://www.chromium.org/developers/coding-style/chromium-style-checker-errors/#constructordestructor-errors

Bug: dawn:1405
Change-Id: Ied6e9d0abff6bf1330131a40c6583bab18888b67
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90303
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Kai Ninomiya 2022-05-17 06:11:42 +00:00 committed by Dawn LUCI CQ
parent a17df3968e
commit 455f573d09
4 changed files with 152 additions and 0 deletions

View File

@ -39,6 +39,9 @@ class AdapterBase;
// An optional parameter of Adapter::CreateDevice() to send additional information when creating // An optional parameter of Adapter::CreateDevice() to send additional information when creating
// a Device. For example, we can use it to enable a workaround, optimization or feature. // a Device. For example, we can use it to enable a workaround, optimization or feature.
struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor { struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
DawnDeviceDescriptor();
~DawnDeviceDescriptor();
std::vector<const char*> requiredFeatures; std::vector<const char*> requiredFeatures;
std::vector<const char*> forceEnabledToggles; std::vector<const char*> forceEnabledToggles;
std::vector<const char*> forceDisabledToggles; std::vector<const char*> forceDisabledToggles;

View File

@ -361,4 +361,76 @@ void SkipCommand(CommandIterator* commands, Command type) {
} }
} }
TimestampWrite::TimestampWrite(const Ref<QuerySetBase>& set, uint32_t idx)
: querySet(set), queryIndex(idx) {}
TimestampWrite::TimestampWrite(TimestampWrite&&) = default;
TimestampWrite::~TimestampWrite() = default;
BeginComputePassCmd::BeginComputePassCmd() = default;
BeginComputePassCmd::~BeginComputePassCmd() = default;
BeginOcclusionQueryCmd::BeginOcclusionQueryCmd() = default;
BeginOcclusionQueryCmd::~BeginOcclusionQueryCmd() = default;
RenderPassColorAttachmentInfo::RenderPassColorAttachmentInfo() = default;
RenderPassColorAttachmentInfo::~RenderPassColorAttachmentInfo() = default;
RenderPassDepthStencilAttachmentInfo::RenderPassDepthStencilAttachmentInfo() = default;
RenderPassDepthStencilAttachmentInfo::~RenderPassDepthStencilAttachmentInfo() = default;
BeginRenderPassCmd::BeginRenderPassCmd() = default;
BeginRenderPassCmd::~BeginRenderPassCmd() = default;
BufferCopy::BufferCopy() = default;
BufferCopy::~BufferCopy() = default;
TextureCopy::TextureCopy() = default;
TextureCopy::TextureCopy(const TextureCopy&) = default;
TextureCopy::~TextureCopy() = default;
CopyBufferToBufferCmd::CopyBufferToBufferCmd() = default;
CopyBufferToBufferCmd::~CopyBufferToBufferCmd() = default;
DispatchIndirectCmd::DispatchIndirectCmd() = default;
DispatchIndirectCmd::~DispatchIndirectCmd() = default;
DrawIndirectCmd::DrawIndirectCmd() = default;
DrawIndirectCmd::~DrawIndirectCmd() = default;
EndComputePassCmd::EndComputePassCmd() = default;
EndComputePassCmd::~EndComputePassCmd() = default;
EndOcclusionQueryCmd::EndOcclusionQueryCmd() = default;
EndOcclusionQueryCmd::~EndOcclusionQueryCmd() = default;
EndRenderPassCmd::EndRenderPassCmd() = default;
EndRenderPassCmd::~EndRenderPassCmd() = default;
ClearBufferCmd::ClearBufferCmd() = default;
ClearBufferCmd::~ClearBufferCmd() = default;
ResolveQuerySetCmd::ResolveQuerySetCmd() = default;
ResolveQuerySetCmd::~ResolveQuerySetCmd() = default;
SetComputePipelineCmd::SetComputePipelineCmd() = default;
SetComputePipelineCmd::~SetComputePipelineCmd() = default;
SetRenderPipelineCmd::SetRenderPipelineCmd() = default;
SetRenderPipelineCmd::~SetRenderPipelineCmd() = default;
SetBindGroupCmd::SetBindGroupCmd() = default;
SetBindGroupCmd::~SetBindGroupCmd() = default;
SetIndexBufferCmd::SetIndexBufferCmd() = default;
SetIndexBufferCmd::~SetIndexBufferCmd() = default;
SetVertexBufferCmd::SetVertexBufferCmd() = default;
SetVertexBufferCmd::~SetVertexBufferCmd() = default;
WriteBufferCmd::WriteBufferCmd() = default;
WriteBufferCmd::~WriteBufferCmd() = default;
WriteTimestampCmd::WriteTimestampCmd() = default;
WriteTimestampCmd::~WriteTimestampCmd() = default;
} // namespace dawn::native } // namespace dawn::native

View File

@ -70,20 +70,33 @@ enum class Command {
}; };
struct TimestampWrite { struct TimestampWrite {
TimestampWrite(const Ref<QuerySetBase>& set, uint32_t idx);
TimestampWrite(TimestampWrite&&);
~TimestampWrite();
Ref<QuerySetBase> querySet; Ref<QuerySetBase> querySet;
uint32_t queryIndex; uint32_t queryIndex;
}; };
struct BeginComputePassCmd { struct BeginComputePassCmd {
BeginComputePassCmd();
~BeginComputePassCmd();
std::vector<TimestampWrite> timestampWrites; std::vector<TimestampWrite> timestampWrites;
}; };
struct BeginOcclusionQueryCmd { struct BeginOcclusionQueryCmd {
BeginOcclusionQueryCmd();
~BeginOcclusionQueryCmd();
Ref<QuerySetBase> querySet; Ref<QuerySetBase> querySet;
uint32_t queryIndex; uint32_t queryIndex;
}; };
struct RenderPassColorAttachmentInfo { struct RenderPassColorAttachmentInfo {
RenderPassColorAttachmentInfo();
~RenderPassColorAttachmentInfo();
Ref<TextureViewBase> view; Ref<TextureViewBase> view;
Ref<TextureViewBase> resolveTarget; Ref<TextureViewBase> resolveTarget;
wgpu::LoadOp loadOp; wgpu::LoadOp loadOp;
@ -92,6 +105,9 @@ struct RenderPassColorAttachmentInfo {
}; };
struct RenderPassDepthStencilAttachmentInfo { struct RenderPassDepthStencilAttachmentInfo {
RenderPassDepthStencilAttachmentInfo();
~RenderPassDepthStencilAttachmentInfo();
Ref<TextureViewBase> view; Ref<TextureViewBase> view;
wgpu::LoadOp depthLoadOp; wgpu::LoadOp depthLoadOp;
wgpu::StoreOp depthStoreOp; wgpu::StoreOp depthStoreOp;
@ -104,6 +120,9 @@ struct RenderPassDepthStencilAttachmentInfo {
}; };
struct BeginRenderPassCmd { struct BeginRenderPassCmd {
BeginRenderPassCmd();
~BeginRenderPassCmd();
Ref<AttachmentState> attachmentState; Ref<AttachmentState> attachmentState;
ityp::array<ColorAttachmentIndex, RenderPassColorAttachmentInfo, kMaxColorAttachments> ityp::array<ColorAttachmentIndex, RenderPassColorAttachmentInfo, kMaxColorAttachments>
colorAttachments; colorAttachments;
@ -118,6 +137,9 @@ struct BeginRenderPassCmd {
}; };
struct BufferCopy { struct BufferCopy {
BufferCopy();
~BufferCopy();
Ref<BufferBase> buffer; Ref<BufferBase> buffer;
uint64_t offset; uint64_t offset;
uint32_t bytesPerRow; uint32_t bytesPerRow;
@ -125,6 +147,10 @@ struct BufferCopy {
}; };
struct TextureCopy { struct TextureCopy {
TextureCopy();
TextureCopy(const TextureCopy&);
~TextureCopy();
Ref<TextureBase> texture; Ref<TextureBase> texture;
uint32_t mipLevel; uint32_t mipLevel;
Origin3D origin; // Texels / array layer Origin3D origin; // Texels / array layer
@ -132,6 +158,9 @@ struct TextureCopy {
}; };
struct CopyBufferToBufferCmd { struct CopyBufferToBufferCmd {
CopyBufferToBufferCmd();
~CopyBufferToBufferCmd();
Ref<BufferBase> source; Ref<BufferBase> source;
uint64_t sourceOffset; uint64_t sourceOffset;
Ref<BufferBase> destination; Ref<BufferBase> destination;
@ -164,6 +193,9 @@ struct DispatchCmd {
}; };
struct DispatchIndirectCmd { struct DispatchIndirectCmd {
DispatchIndirectCmd();
~DispatchIndirectCmd();
Ref<BufferBase> indirectBuffer; Ref<BufferBase> indirectBuffer;
uint64_t indirectOffset; uint64_t indirectOffset;
}; };
@ -184,6 +216,9 @@ struct DrawIndexedCmd {
}; };
struct DrawIndirectCmd { struct DrawIndirectCmd {
DrawIndirectCmd();
~DrawIndirectCmd();
Ref<BufferBase> indirectBuffer; Ref<BufferBase> indirectBuffer;
uint64_t indirectOffset; uint64_t indirectOffset;
}; };
@ -191,15 +226,24 @@ struct DrawIndirectCmd {
struct DrawIndexedIndirectCmd : DrawIndirectCmd {}; struct DrawIndexedIndirectCmd : DrawIndirectCmd {};
struct EndComputePassCmd { struct EndComputePassCmd {
EndComputePassCmd();
~EndComputePassCmd();
std::vector<TimestampWrite> timestampWrites; std::vector<TimestampWrite> timestampWrites;
}; };
struct EndOcclusionQueryCmd { struct EndOcclusionQueryCmd {
EndOcclusionQueryCmd();
~EndOcclusionQueryCmd();
Ref<QuerySetBase> querySet; Ref<QuerySetBase> querySet;
uint32_t queryIndex; uint32_t queryIndex;
}; };
struct EndRenderPassCmd { struct EndRenderPassCmd {
EndRenderPassCmd();
~EndRenderPassCmd();
std::vector<TimestampWrite> timestampWrites; std::vector<TimestampWrite> timestampWrites;
}; };
@ -208,6 +252,9 @@ struct ExecuteBundlesCmd {
}; };
struct ClearBufferCmd { struct ClearBufferCmd {
ClearBufferCmd();
~ClearBufferCmd();
Ref<BufferBase> buffer; Ref<BufferBase> buffer;
uint64_t offset; uint64_t offset;
uint64_t size; uint64_t size;
@ -224,6 +271,9 @@ struct PushDebugGroupCmd {
}; };
struct ResolveQuerySetCmd { struct ResolveQuerySetCmd {
ResolveQuerySetCmd();
~ResolveQuerySetCmd();
Ref<QuerySetBase> querySet; Ref<QuerySetBase> querySet;
uint32_t firstQuery; uint32_t firstQuery;
uint32_t queryCount; uint32_t queryCount;
@ -232,10 +282,16 @@ struct ResolveQuerySetCmd {
}; };
struct SetComputePipelineCmd { struct SetComputePipelineCmd {
SetComputePipelineCmd();
~SetComputePipelineCmd();
Ref<ComputePipelineBase> pipeline; Ref<ComputePipelineBase> pipeline;
}; };
struct SetRenderPipelineCmd { struct SetRenderPipelineCmd {
SetRenderPipelineCmd();
~SetRenderPipelineCmd();
Ref<RenderPipelineBase> pipeline; Ref<RenderPipelineBase> pipeline;
}; };
@ -256,12 +312,18 @@ struct SetBlendConstantCmd {
}; };
struct SetBindGroupCmd { struct SetBindGroupCmd {
SetBindGroupCmd();
~SetBindGroupCmd();
BindGroupIndex index; BindGroupIndex index;
Ref<BindGroupBase> group; Ref<BindGroupBase> group;
uint32_t dynamicOffsetCount; uint32_t dynamicOffsetCount;
}; };
struct SetIndexBufferCmd { struct SetIndexBufferCmd {
SetIndexBufferCmd();
~SetIndexBufferCmd();
Ref<BufferBase> buffer; Ref<BufferBase> buffer;
wgpu::IndexFormat format; wgpu::IndexFormat format;
uint64_t offset; uint64_t offset;
@ -269,6 +331,9 @@ struct SetIndexBufferCmd {
}; };
struct SetVertexBufferCmd { struct SetVertexBufferCmd {
SetVertexBufferCmd();
~SetVertexBufferCmd();
VertexBufferSlot slot; VertexBufferSlot slot;
Ref<BufferBase> buffer; Ref<BufferBase> buffer;
uint64_t offset; uint64_t offset;
@ -276,12 +341,18 @@ struct SetVertexBufferCmd {
}; };
struct WriteBufferCmd { struct WriteBufferCmd {
WriteBufferCmd();
~WriteBufferCmd();
Ref<BufferBase> buffer; Ref<BufferBase> buffer;
uint64_t offset; uint64_t offset;
uint64_t size; uint64_t size;
}; };
struct WriteTimestampCmd { struct WriteTimestampCmd {
WriteTimestampCmd();
~WriteTimestampCmd();
Ref<QuerySetBase> querySet; Ref<QuerySetBase> querySet;
uint32_t queryIndex; uint32_t queryIndex;
}; };

View File

@ -70,6 +70,12 @@ std::vector<const char*> GetTogglesUsed(WGPUDevice device) {
return FromAPI(device)->GetTogglesUsed(); return FromAPI(device)->GetTogglesUsed();
} }
// DawnDeviceDescriptor
DawnDeviceDescriptor::DawnDeviceDescriptor() = default;
DawnDeviceDescriptor::~DawnDeviceDescriptor() = default;
// Adapter // Adapter
Adapter::Adapter() = default; Adapter::Adapter() = default;