Remove the "Base" from pure-frontend dawn_native types

This was unnecessary verbosity. Fix this by having the ProcTable
generator using type aliases so all types appear like they have
"Base".

BUG=

Change-Id: I8c472fb924f6ce739e4e41038452381b4f727a2b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13442
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2019-11-13 17:00:37 +00:00 committed by Commit Bot service account
parent 9e7107eb96
commit 321c12255e
41 changed files with 198 additions and 214 deletions

View File

@ -26,6 +26,14 @@
namespace dawn_native { namespace dawn_native {
// Type aliases to make all frontend types appear as if they have "Base" at the end when some
// of them are actually pure-frontend and don't have the Base.
using CommandEncoderBase = CommandEncoder;
using ComputePassEncoderBase = ComputePassEncoder;
using FenceBase = Fence;
using RenderPassEncoderBase = RenderPassEncoder;
using RenderBundleEncoderBase = RenderBundleEncoder;
namespace { namespace {
{% for type in by_category["object"] %} {% for type in by_category["object"] %}

View File

@ -19,8 +19,7 @@
namespace dawn_native { namespace dawn_native {
CommandBufferBase::CommandBufferBase(CommandEncoderBase* encoder, CommandBufferBase::CommandBufferBase(CommandEncoder* encoder, const CommandBufferDescriptor*)
const CommandBufferDescriptor*)
: ObjectBase(encoder->GetDevice()), mResourceUsages(encoder->AcquireResourceUsages()) { : ObjectBase(encoder->GetDevice()), mResourceUsages(encoder->AcquireResourceUsages()) {
} }

View File

@ -25,7 +25,7 @@ namespace dawn_native {
class CommandBufferBase : public ObjectBase { class CommandBufferBase : public ObjectBase {
public: public:
CommandBufferBase(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor); CommandBufferBase(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
static CommandBufferBase* MakeError(DeviceBase* device); static CommandBufferBase* MakeError(DeviceBase* device);
const CommandBufferResourceUsage& GetResourceUsages() const; const CommandBufferResourceUsage& GetResourceUsages() const;

View File

@ -462,24 +462,23 @@ namespace dawn_native {
} // namespace } // namespace
CommandEncoderBase::CommandEncoderBase(DeviceBase* device, const CommandEncoderDescriptor*) CommandEncoder::CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor*)
: ObjectBase(device), mEncodingContext(device, this) { : ObjectBase(device), mEncodingContext(device, this) {
} }
CommandBufferResourceUsage CommandEncoderBase::AcquireResourceUsages() { CommandBufferResourceUsage CommandEncoder::AcquireResourceUsages() {
ASSERT(!mWereResourceUsagesAcquired); ASSERT(!mWereResourceUsagesAcquired);
mWereResourceUsagesAcquired = true; mWereResourceUsagesAcquired = true;
return std::move(mResourceUsages); return std::move(mResourceUsages);
} }
CommandIterator CommandEncoderBase::AcquireCommands() { CommandIterator CommandEncoder::AcquireCommands() {
return mEncodingContext.AcquireCommands(); return mEncodingContext.AcquireCommands();
} }
// Implementation of the API's command recording methods // Implementation of the API's command recording methods
ComputePassEncoderBase* CommandEncoderBase::BeginComputePass( ComputePassEncoder* CommandEncoder::BeginComputePass(const ComputePassDescriptor* descriptor) {
const ComputePassDescriptor* descriptor) {
DeviceBase* device = GetDevice(); DeviceBase* device = GetDevice();
bool success = bool success =
@ -492,17 +491,16 @@ namespace dawn_native {
}); });
if (success) { if (success) {
ComputePassEncoderBase* passEncoder = ComputePassEncoder* passEncoder =
new ComputePassEncoderBase(device, this, &mEncodingContext); new ComputePassEncoder(device, this, &mEncodingContext);
mEncodingContext.EnterPass(passEncoder); mEncodingContext.EnterPass(passEncoder);
return passEncoder; return passEncoder;
} }
return ComputePassEncoderBase::MakeError(device, this, &mEncodingContext); return ComputePassEncoder::MakeError(device, this, &mEncodingContext);
} }
RenderPassEncoderBase* CommandEncoderBase::BeginRenderPass( RenderPassEncoder* CommandEncoder::BeginRenderPass(const RenderPassDescriptor* descriptor) {
const RenderPassDescriptor* descriptor) {
DeviceBase* device = GetDevice(); DeviceBase* device = GetDevice();
bool success = bool success =
@ -555,16 +553,15 @@ namespace dawn_native {
}); });
if (success) { if (success) {
RenderPassEncoderBase* passEncoder = RenderPassEncoder* passEncoder = new RenderPassEncoder(device, this, &mEncodingContext);
new RenderPassEncoderBase(device, this, &mEncodingContext);
mEncodingContext.EnterPass(passEncoder); mEncodingContext.EnterPass(passEncoder);
return passEncoder; return passEncoder;
} }
return RenderPassEncoderBase::MakeError(device, this, &mEncodingContext); return RenderPassEncoder::MakeError(device, this, &mEncodingContext);
} }
void CommandEncoderBase::CopyBufferToBuffer(BufferBase* source, void CommandEncoder::CopyBufferToBuffer(BufferBase* source,
uint64_t sourceOffset, uint64_t sourceOffset,
BufferBase* destination, BufferBase* destination,
uint64_t destinationOffset, uint64_t destinationOffset,
@ -585,7 +582,7 @@ namespace dawn_native {
}); });
} }
void CommandEncoderBase::CopyBufferToTexture(const BufferCopyView* source, void CommandEncoder::CopyBufferToTexture(const BufferCopyView* source,
const TextureCopyView* destination, const TextureCopyView* destination,
const Extent3D* copySize) { const Extent3D* copySize) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
@ -617,7 +614,7 @@ namespace dawn_native {
}); });
} }
void CommandEncoderBase::CopyTextureToBuffer(const TextureCopyView* source, void CommandEncoder::CopyTextureToBuffer(const TextureCopyView* source,
const BufferCopyView* destination, const BufferCopyView* destination,
const Extent3D* copySize) { const Extent3D* copySize) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
@ -649,7 +646,7 @@ namespace dawn_native {
}); });
} }
void CommandEncoderBase::CopyTextureToTexture(const TextureCopyView* source, void CommandEncoder::CopyTextureToTexture(const TextureCopyView* source,
const TextureCopyView* destination, const TextureCopyView* destination,
const Extent3D* copySize) { const Extent3D* copySize) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
@ -672,7 +669,7 @@ namespace dawn_native {
}); });
} }
void CommandEncoderBase::InsertDebugMarker(const char* groupLabel) { void CommandEncoder::InsertDebugMarker(const char* groupLabel) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
InsertDebugMarkerCmd* cmd = InsertDebugMarkerCmd* cmd =
allocator->Allocate<InsertDebugMarkerCmd>(Command::InsertDebugMarker); allocator->Allocate<InsertDebugMarkerCmd>(Command::InsertDebugMarker);
@ -685,7 +682,7 @@ namespace dawn_native {
}); });
} }
void CommandEncoderBase::PopDebugGroup() { void CommandEncoder::PopDebugGroup() {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
allocator->Allocate<PopDebugGroupCmd>(Command::PopDebugGroup); allocator->Allocate<PopDebugGroupCmd>(Command::PopDebugGroup);
@ -693,7 +690,7 @@ namespace dawn_native {
}); });
} }
void CommandEncoderBase::PushDebugGroup(const char* groupLabel) { void CommandEncoder::PushDebugGroup(const char* groupLabel) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
PushDebugGroupCmd* cmd = PushDebugGroupCmd* cmd =
allocator->Allocate<PushDebugGroupCmd>(Command::PushDebugGroup); allocator->Allocate<PushDebugGroupCmd>(Command::PushDebugGroup);
@ -706,7 +703,7 @@ namespace dawn_native {
}); });
} }
CommandBufferBase* CommandEncoderBase::Finish(const CommandBufferDescriptor* descriptor) { CommandBufferBase* CommandEncoder::Finish(const CommandBufferDescriptor* descriptor) {
if (GetDevice()->ConsumedError(ValidateFinish(descriptor))) { if (GetDevice()->ConsumedError(ValidateFinish(descriptor))) {
// Even if finish validation fails, it is now invalid to call any encoding commands on // Even if finish validation fails, it is now invalid to call any encoding commands on
// this object, so we set its state to finished. // this object, so we set its state to finished.
@ -719,8 +716,8 @@ namespace dawn_native {
// Implementation of the command buffer validation that can be precomputed before submit // Implementation of the command buffer validation that can be precomputed before submit
MaybeError CommandEncoderBase::ValidateFinish(const CommandBufferDescriptor*) { MaybeError CommandEncoder::ValidateFinish(const CommandBufferDescriptor*) {
TRACE_EVENT0(GetDevice()->GetPlatform(), Validation, "CommandEncoderBase::ValidateFinish"); TRACE_EVENT0(GetDevice()->GetPlatform(), Validation, "CommandEncoder::ValidateFinish");
DAWN_TRY(GetDevice()->ValidateObject(this)); DAWN_TRY(GetDevice()->ValidateObject(this));
// Even if Finish() validation fails, calling it will mutate the internal state of the // Even if Finish() validation fails, calling it will mutate the internal state of the

View File

@ -28,16 +28,16 @@ namespace dawn_native {
struct BeginRenderPassCmd; struct BeginRenderPassCmd;
class CommandEncoderBase : public ObjectBase { class CommandEncoder final : public ObjectBase {
public: public:
CommandEncoderBase(DeviceBase* device, const CommandEncoderDescriptor* descriptor); CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor* descriptor);
CommandIterator AcquireCommands(); CommandIterator AcquireCommands();
CommandBufferResourceUsage AcquireResourceUsages(); CommandBufferResourceUsage AcquireResourceUsages();
// Dawn API // Dawn API
ComputePassEncoderBase* BeginComputePass(const ComputePassDescriptor* descriptor); ComputePassEncoder* BeginComputePass(const ComputePassDescriptor* descriptor);
RenderPassEncoderBase* BeginRenderPass(const RenderPassDescriptor* descriptor); RenderPassEncoder* BeginRenderPass(const RenderPassDescriptor* descriptor);
void CopyBufferToBuffer(BufferBase* source, void CopyBufferToBuffer(BufferBase* source,
uint64_t sourceOffset, uint64_t sourceOffset,

View File

@ -22,28 +22,27 @@
namespace dawn_native { namespace dawn_native {
ComputePassEncoderBase::ComputePassEncoderBase(DeviceBase* device, ComputePassEncoder::ComputePassEncoder(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext) EncodingContext* encodingContext)
: ProgrammablePassEncoder(device, encodingContext), mCommandEncoder(commandEncoder) { : ProgrammablePassEncoder(device, encodingContext), mCommandEncoder(commandEncoder) {
} }
ComputePassEncoderBase::ComputePassEncoderBase(DeviceBase* device, ComputePassEncoder::ComputePassEncoder(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext, EncodingContext* encodingContext,
ErrorTag errorTag) ErrorTag errorTag)
: ProgrammablePassEncoder(device, encodingContext, errorTag), : ProgrammablePassEncoder(device, encodingContext, errorTag),
mCommandEncoder(commandEncoder) { mCommandEncoder(commandEncoder) {
} }
ComputePassEncoderBase* ComputePassEncoderBase::MakeError(DeviceBase* device, ComputePassEncoder* ComputePassEncoder::MakeError(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext) { EncodingContext* encodingContext) {
return new ComputePassEncoderBase(device, commandEncoder, encodingContext, return new ComputePassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError);
ObjectBase::kError);
} }
void ComputePassEncoderBase::EndPass() { void ComputePassEncoder::EndPass() {
if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
allocator->Allocate<EndComputePassCmd>(Command::EndComputePass); allocator->Allocate<EndComputePassCmd>(Command::EndComputePass);
@ -53,7 +52,7 @@ namespace dawn_native {
} }
} }
void ComputePassEncoderBase::Dispatch(uint32_t x, uint32_t y, uint32_t z) { void ComputePassEncoder::Dispatch(uint32_t x, uint32_t y, uint32_t z) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
DispatchCmd* dispatch = allocator->Allocate<DispatchCmd>(Command::Dispatch); DispatchCmd* dispatch = allocator->Allocate<DispatchCmd>(Command::Dispatch);
dispatch->x = x; dispatch->x = x;
@ -64,8 +63,7 @@ namespace dawn_native {
}); });
} }
void ComputePassEncoderBase::DispatchIndirect(BufferBase* indirectBuffer, void ComputePassEncoder::DispatchIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) {
uint64_t indirectOffset) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer)); DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
@ -83,7 +81,7 @@ namespace dawn_native {
}); });
} }
void ComputePassEncoderBase::SetPipeline(ComputePipelineBase* pipeline) { void ComputePassEncoder::SetPipeline(ComputePipelineBase* pipeline) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
DAWN_TRY(GetDevice()->ValidateObject(pipeline)); DAWN_TRY(GetDevice()->ValidateObject(pipeline));

View File

@ -20,18 +20,14 @@
namespace dawn_native { namespace dawn_native {
// This is called ComputePassEncoderBase to match the code generator expectations. Note that it class ComputePassEncoder final : public ProgrammablePassEncoder {
// is a pure frontend type to record in its parent CommandEncoder and never has a backend
// implementation.
// TODO(cwallez@chromium.org): Remove that generator limitation and rename to ComputePassEncoder
class ComputePassEncoderBase : public ProgrammablePassEncoder {
public: public:
ComputePassEncoderBase(DeviceBase* device, ComputePassEncoder(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext); EncodingContext* encodingContext);
static ComputePassEncoderBase* MakeError(DeviceBase* device, static ComputePassEncoder* MakeError(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext); EncodingContext* encodingContext);
void EndPass(); void EndPass();
@ -41,15 +37,15 @@ namespace dawn_native {
void SetPipeline(ComputePipelineBase* pipeline); void SetPipeline(ComputePipelineBase* pipeline);
protected: protected:
ComputePassEncoderBase(DeviceBase* device, ComputePassEncoder(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext, EncodingContext* encodingContext,
ErrorTag errorTag); ErrorTag errorTag);
private: private:
// For render and compute passes, the encoding context is borrowed from the command encoder. // For render and compute passes, the encoding context is borrowed from the command encoder.
// Keep a reference to the encoder to make sure the context isn't freed. // Keep a reference to the encoder to make sure the context isn't freed.
Ref<CommandEncoderBase> mCommandEncoder; Ref<CommandEncoder> mCommandEncoder;
}; };
} // namespace dawn_native } // namespace dawn_native

View File

@ -445,9 +445,8 @@ namespace dawn_native {
// The callback is deferred so it matches the async behavior of WebGPU. // The callback is deferred so it matches the async behavior of WebGPU.
mDeferredCreateBufferMappedAsyncResults.push_back(deferred_info); mDeferredCreateBufferMappedAsyncResults.push_back(deferred_info);
} }
CommandEncoderBase* DeviceBase::CreateCommandEncoder( CommandEncoder* DeviceBase::CreateCommandEncoder(const CommandEncoderDescriptor* descriptor) {
const CommandEncoderDescriptor* descriptor) { return new CommandEncoder(this, descriptor);
return new CommandEncoderBase(this, descriptor);
} }
ComputePipelineBase* DeviceBase::CreateComputePipeline( ComputePipelineBase* DeviceBase::CreateComputePipeline(
const ComputePipelineDescriptor* descriptor) { const ComputePipelineDescriptor* descriptor) {
@ -490,12 +489,12 @@ namespace dawn_native {
return result; return result;
} }
RenderBundleEncoderBase* DeviceBase::CreateRenderBundleEncoder( RenderBundleEncoder* DeviceBase::CreateRenderBundleEncoder(
const RenderBundleEncoderDescriptor* descriptor) { const RenderBundleEncoderDescriptor* descriptor) {
RenderBundleEncoderBase* result = nullptr; RenderBundleEncoder* result = nullptr;
if (ConsumedError(CreateRenderBundleEncoderInternal(&result, descriptor))) { if (ConsumedError(CreateRenderBundleEncoderInternal(&result, descriptor))) {
return RenderBundleEncoderBase::MakeError(this); return RenderBundleEncoder::MakeError(this);
} }
return result; return result;
@ -677,10 +676,10 @@ namespace dawn_native {
} }
MaybeError DeviceBase::CreateRenderBundleEncoderInternal( MaybeError DeviceBase::CreateRenderBundleEncoderInternal(
RenderBundleEncoderBase** result, RenderBundleEncoder** result,
const RenderBundleEncoderDescriptor* descriptor) { const RenderBundleEncoderDescriptor* descriptor) {
DAWN_TRY(ValidateRenderBundleEncoderDescriptor(this, descriptor)); DAWN_TRY(ValidateRenderBundleEncoderDescriptor(this, descriptor));
*result = new RenderBundleEncoderBase(this, descriptor); *result = new RenderBundleEncoder(this, descriptor);
return {}; return {};
} }

View File

@ -85,7 +85,7 @@ namespace dawn_native {
const Format& GetValidInternalFormat(wgpu::TextureFormat format) const; const Format& GetValidInternalFormat(wgpu::TextureFormat format) const;
virtual CommandBufferBase* CreateCommandBuffer( virtual CommandBufferBase* CreateCommandBuffer(
CommandEncoderBase* encoder, CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) = 0; const CommandBufferDescriptor* descriptor) = 0;
virtual Serial GetCompletedCommandSerial() const = 0; virtual Serial GetCompletedCommandSerial() const = 0;
@ -145,11 +145,11 @@ namespace dawn_native {
void CreateBufferMappedAsync(const BufferDescriptor* descriptor, void CreateBufferMappedAsync(const BufferDescriptor* descriptor,
wgpu::BufferCreateMappedCallback callback, wgpu::BufferCreateMappedCallback callback,
void* userdata); void* userdata);
CommandEncoderBase* CreateCommandEncoder(const CommandEncoderDescriptor* descriptor); CommandEncoder* CreateCommandEncoder(const CommandEncoderDescriptor* descriptor);
ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor); ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor); PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor);
QueueBase* CreateQueue(); QueueBase* CreateQueue();
RenderBundleEncoderBase* CreateRenderBundleEncoder( RenderBundleEncoder* CreateRenderBundleEncoder(
const RenderBundleEncoderDescriptor* descriptor); const RenderBundleEncoderDescriptor* descriptor);
RenderPipelineBase* CreateRenderPipeline(const RenderPipelineDescriptor* descriptor); RenderPipelineBase* CreateRenderPipeline(const RenderPipelineDescriptor* descriptor);
SamplerBase* CreateSampler(const SamplerDescriptor* descriptor); SamplerBase* CreateSampler(const SamplerDescriptor* descriptor);
@ -230,7 +230,7 @@ namespace dawn_native {
const PipelineLayoutDescriptor* descriptor); const PipelineLayoutDescriptor* descriptor);
MaybeError CreateQueueInternal(QueueBase** result); MaybeError CreateQueueInternal(QueueBase** result);
MaybeError CreateRenderBundleEncoderInternal( MaybeError CreateRenderBundleEncoderInternal(
RenderBundleEncoderBase** result, RenderBundleEncoder** result,
const RenderBundleEncoderDescriptor* descriptor); const RenderBundleEncoderDescriptor* descriptor);
MaybeError CreateRenderPipelineInternal(RenderPipelineBase** result, MaybeError CreateRenderPipelineInternal(RenderPipelineBase** result,
const RenderPipelineDescriptor* descriptor); const RenderPipelineDescriptor* descriptor);

View File

@ -33,17 +33,17 @@ namespace dawn_native {
// Fence // Fence
FenceBase::FenceBase(QueueBase* queue, const FenceDescriptor* descriptor) Fence::Fence(QueueBase* queue, const FenceDescriptor* descriptor)
: ObjectBase(queue->GetDevice()), : ObjectBase(queue->GetDevice()),
mSignalValue(descriptor->initialValue), mSignalValue(descriptor->initialValue),
mCompletedValue(descriptor->initialValue), mCompletedValue(descriptor->initialValue),
mQueue(queue) { mQueue(queue) {
} }
FenceBase::FenceBase(DeviceBase* device, ObjectBase::ErrorTag tag) : ObjectBase(device, tag) { Fence::Fence(DeviceBase* device, ObjectBase::ErrorTag tag) : ObjectBase(device, tag) {
} }
FenceBase::~FenceBase() { Fence::~Fence() {
for (auto& request : mRequests.IterateAll()) { for (auto& request : mRequests.IterateAll()) {
ASSERT(!IsError()); ASSERT(!IsError());
request.completionCallback(WGPUFenceCompletionStatus_Unknown, request.userdata); request.completionCallback(WGPUFenceCompletionStatus_Unknown, request.userdata);
@ -52,18 +52,18 @@ namespace dawn_native {
} }
// static // static
FenceBase* FenceBase::MakeError(DeviceBase* device) { Fence* Fence::MakeError(DeviceBase* device) {
return new FenceBase(device, ObjectBase::kError); return new Fence(device, ObjectBase::kError);
} }
uint64_t FenceBase::GetCompletedValue() const { uint64_t Fence::GetCompletedValue() const {
if (IsError()) { if (IsError()) {
return 0; return 0;
} }
return mCompletedValue; return mCompletedValue;
} }
void FenceBase::OnCompletion(uint64_t value, void Fence::OnCompletion(uint64_t value,
wgpu::FenceOnCompletionCallback callback, wgpu::FenceOnCompletionCallback callback,
void* userdata) { void* userdata) {
if (GetDevice()->ConsumedError(ValidateOnCompletion(value))) { if (GetDevice()->ConsumedError(ValidateOnCompletion(value))) {
@ -83,23 +83,23 @@ namespace dawn_native {
mRequests.Enqueue(std::move(request), value); mRequests.Enqueue(std::move(request), value);
} }
uint64_t FenceBase::GetSignaledValue() const { uint64_t Fence::GetSignaledValue() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mSignalValue; return mSignalValue;
} }
const QueueBase* FenceBase::GetQueue() const { const QueueBase* Fence::GetQueue() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mQueue.Get(); return mQueue.Get();
} }
void FenceBase::SetSignaledValue(uint64_t signalValue) { void Fence::SetSignaledValue(uint64_t signalValue) {
ASSERT(!IsError()); ASSERT(!IsError());
ASSERT(signalValue > mSignalValue); ASSERT(signalValue > mSignalValue);
mSignalValue = signalValue; mSignalValue = signalValue;
} }
void FenceBase::SetCompletedValue(uint64_t completedValue) { void Fence::SetCompletedValue(uint64_t completedValue) {
ASSERT(!IsError()); ASSERT(!IsError());
ASSERT(completedValue <= mSignalValue); ASSERT(completedValue <= mSignalValue);
ASSERT(completedValue > mCompletedValue); ASSERT(completedValue > mCompletedValue);
@ -111,7 +111,7 @@ namespace dawn_native {
mRequests.ClearUpTo(mCompletedValue); mRequests.ClearUpTo(mCompletedValue);
} }
MaybeError FenceBase::ValidateOnCompletion(uint64_t value) const { MaybeError Fence::ValidateOnCompletion(uint64_t value) const {
DAWN_TRY(GetDevice()->ValidateObject(this)); DAWN_TRY(GetDevice()->ValidateObject(this));
if (value > mSignalValue) { if (value > mSignalValue) {
return DAWN_VALIDATION_ERROR("Value greater than fence signaled value"); return DAWN_VALIDATION_ERROR("Value greater than fence signaled value");

View File

@ -28,12 +28,12 @@ namespace dawn_native {
MaybeError ValidateFenceDescriptor(const FenceDescriptor* descriptor); MaybeError ValidateFenceDescriptor(const FenceDescriptor* descriptor);
class FenceBase : public ObjectBase { class Fence final : public ObjectBase {
public: public:
FenceBase(QueueBase* queue, const FenceDescriptor* descriptor); Fence(QueueBase* queue, const FenceDescriptor* descriptor);
~FenceBase(); ~Fence();
static FenceBase* MakeError(DeviceBase* device); static Fence* MakeError(DeviceBase* device);
uint64_t GetSignaledValue() const; uint64_t GetSignaledValue() const;
const QueueBase* GetQueue() const; const QueueBase* GetQueue() const;
@ -49,7 +49,7 @@ namespace dawn_native {
void SetCompletedValue(uint64_t completedValue); void SetCompletedValue(uint64_t completedValue);
private: private:
FenceBase(DeviceBase* device, ObjectBase::ErrorTag tag); Fence(DeviceBase* device, ObjectBase::ErrorTag tag);
MaybeError ValidateOnCompletion(uint64_t value) const; MaybeError ValidateOnCompletion(uint64_t value) const;

View File

@ -26,7 +26,7 @@ namespace dawn_native {
ASSERT(mFencesInFlight.Empty()); ASSERT(mFencesInFlight.Empty());
} }
void FenceSignalTracker::UpdateFenceOnComplete(FenceBase* fence, uint64_t value) { void FenceSignalTracker::UpdateFenceOnComplete(Fence* fence, uint64_t value) {
// Because we currently only have a single queue, we can simply update // Because we currently only have a single queue, we can simply update
// the fence completed value once the last submitted serial has passed. // the fence completed value once the last submitted serial has passed.
mFencesInFlight.Enqueue(FenceInFlight{fence, value}, mFencesInFlight.Enqueue(FenceInFlight{fence, value},

View File

@ -21,11 +21,11 @@
namespace dawn_native { namespace dawn_native {
class DeviceBase; class DeviceBase;
class FenceBase; class Fence;
class FenceSignalTracker { class FenceSignalTracker {
struct FenceInFlight { struct FenceInFlight {
Ref<FenceBase> fence; Ref<Fence> fence;
uint64_t value; uint64_t value;
}; };
@ -33,7 +33,7 @@ namespace dawn_native {
FenceSignalTracker(DeviceBase* device); FenceSignalTracker(DeviceBase* device);
~FenceSignalTracker(); ~FenceSignalTracker();
void UpdateFenceOnComplete(FenceBase* fence, uint64_t value); void UpdateFenceOnComplete(Fence* fence, uint64_t value);
void Tick(Serial finishedSerial); void Tick(Serial finishedSerial);

View File

@ -25,16 +25,16 @@ namespace dawn_native {
class BufferBase; class BufferBase;
class ComputePipelineBase; class ComputePipelineBase;
class CommandBufferBase; class CommandBufferBase;
class CommandEncoderBase; class CommandEncoder;
class ComputePassEncoderBase; class ComputePassEncoder;
class FenceBase; class Fence;
class InstanceBase; class InstanceBase;
class PipelineBase; class PipelineBase;
class PipelineLayoutBase; class PipelineLayoutBase;
class QueueBase; class QueueBase;
class RenderBundleBase; class RenderBundleBase;
class RenderBundleEncoderBase; class RenderBundleEncoder;
class RenderPassEncoderBase; class RenderPassEncoder;
class RenderPipelineBase; class RenderPipelineBase;
class ResourceHeapBase; class ResourceHeapBase;
class SamplerBase; class SamplerBase;

View File

@ -47,7 +47,7 @@ namespace dawn_native {
device->GetCurrentErrorScope()); device->GetCurrentErrorScope());
} }
void QueueBase::Signal(FenceBase* fence, uint64_t signalValue) { void QueueBase::Signal(Fence* fence, uint64_t signalValue) {
DeviceBase* device = GetDevice(); DeviceBase* device = GetDevice();
if (device->ConsumedError(ValidateSignal(fence, signalValue))) { if (device->ConsumedError(ValidateSignal(fence, signalValue))) {
return; return;
@ -60,12 +60,12 @@ namespace dawn_native {
device->GetCurrentErrorScope()); device->GetCurrentErrorScope());
} }
FenceBase* QueueBase::CreateFence(const FenceDescriptor* descriptor) { Fence* QueueBase::CreateFence(const FenceDescriptor* descriptor) {
if (GetDevice()->ConsumedError(ValidateCreateFence(descriptor))) { if (GetDevice()->ConsumedError(ValidateCreateFence(descriptor))) {
return FenceBase::MakeError(GetDevice()); return Fence::MakeError(GetDevice());
} }
return new FenceBase(this, descriptor); return new Fence(this, descriptor);
} }
MaybeError QueueBase::ValidateSubmit(uint32_t commandCount, MaybeError QueueBase::ValidateSubmit(uint32_t commandCount,
@ -98,7 +98,7 @@ namespace dawn_native {
return {}; return {};
} }
MaybeError QueueBase::ValidateSignal(const FenceBase* fence, uint64_t signalValue) { MaybeError QueueBase::ValidateSignal(const Fence* fence, uint64_t signalValue) {
DAWN_TRY(GetDevice()->ValidateObject(this)); DAWN_TRY(GetDevice()->ValidateObject(this));
DAWN_TRY(GetDevice()->ValidateObject(fence)); DAWN_TRY(GetDevice()->ValidateObject(fence));

View File

@ -29,15 +29,15 @@ namespace dawn_native {
// Dawn API // Dawn API
void Submit(uint32_t commandCount, CommandBufferBase* const* commands); void Submit(uint32_t commandCount, CommandBufferBase* const* commands);
void Signal(FenceBase* fence, uint64_t signalValue); void Signal(Fence* fence, uint64_t signalValue);
FenceBase* CreateFence(const FenceDescriptor* descriptor); Fence* CreateFence(const FenceDescriptor* descriptor);
private: private:
virtual MaybeError SubmitImpl(uint32_t commandCount, virtual MaybeError SubmitImpl(uint32_t commandCount,
CommandBufferBase* const* commands) = 0; CommandBufferBase* const* commands) = 0;
MaybeError ValidateSubmit(uint32_t commandCount, CommandBufferBase* const* commands); MaybeError ValidateSubmit(uint32_t commandCount, CommandBufferBase* const* commands);
MaybeError ValidateSignal(const FenceBase* fence, uint64_t signalValue); MaybeError ValidateSignal(const Fence* fence, uint64_t signalValue);
MaybeError ValidateCreateFence(const FenceDescriptor* descriptor); MaybeError ValidateCreateFence(const FenceDescriptor* descriptor);
}; };

View File

@ -21,7 +21,7 @@
namespace dawn_native { namespace dawn_native {
RenderBundleBase::RenderBundleBase(RenderBundleEncoderBase* encoder, RenderBundleBase::RenderBundleBase(RenderBundleEncoder* encoder,
const RenderBundleDescriptor* descriptor, const RenderBundleDescriptor* descriptor,
AttachmentState* attachmentState, AttachmentState* attachmentState,
PassResourceUsage resourceUsage) PassResourceUsage resourceUsage)

View File

@ -30,11 +30,11 @@ namespace dawn_native {
struct BeginRenderPassCmd; struct BeginRenderPassCmd;
struct RenderBundleDescriptor; struct RenderBundleDescriptor;
class RenderBundleEncoderBase; class RenderBundleEncoder;
class RenderBundleBase : public ObjectBase { class RenderBundleBase : public ObjectBase {
public: public:
RenderBundleBase(RenderBundleEncoderBase* encoder, RenderBundleBase(RenderBundleEncoder* encoder,
const RenderBundleDescriptor* descriptor, const RenderBundleDescriptor* descriptor,
AttachmentState* attachmentState, AttachmentState* attachmentState,
PassResourceUsage resourceUsage); PassResourceUsage resourceUsage);

View File

@ -77,32 +77,31 @@ namespace dawn_native {
return {}; return {};
} }
RenderBundleEncoderBase::RenderBundleEncoderBase( RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device,
DeviceBase* device,
const RenderBundleEncoderDescriptor* descriptor) const RenderBundleEncoderDescriptor* descriptor)
: RenderEncoderBase(device, &mEncodingContext), : RenderEncoderBase(device, &mEncodingContext),
mEncodingContext(device, this), mEncodingContext(device, this),
mAttachmentState(device->GetOrCreateAttachmentState(descriptor)) { mAttachmentState(device->GetOrCreateAttachmentState(descriptor)) {
} }
RenderBundleEncoderBase::RenderBundleEncoderBase(DeviceBase* device, ErrorTag errorTag) RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device, ErrorTag errorTag)
: RenderEncoderBase(device, &mEncodingContext, errorTag), mEncodingContext(device, this) { : RenderEncoderBase(device, &mEncodingContext, errorTag), mEncodingContext(device, this) {
} }
// static // static
RenderBundleEncoderBase* RenderBundleEncoderBase::MakeError(DeviceBase* device) { RenderBundleEncoder* RenderBundleEncoder::MakeError(DeviceBase* device) {
return new RenderBundleEncoderBase(device, ObjectBase::kError); return new RenderBundleEncoder(device, ObjectBase::kError);
} }
const AttachmentState* RenderBundleEncoderBase::GetAttachmentState() const { const AttachmentState* RenderBundleEncoder::GetAttachmentState() const {
return mAttachmentState.Get(); return mAttachmentState.Get();
} }
CommandIterator RenderBundleEncoderBase::AcquireCommands() { CommandIterator RenderBundleEncoder::AcquireCommands() {
return mEncodingContext.AcquireCommands(); return mEncodingContext.AcquireCommands();
} }
RenderBundleBase* RenderBundleEncoderBase::Finish(const RenderBundleDescriptor* descriptor) { RenderBundleBase* RenderBundleEncoder::Finish(const RenderBundleDescriptor* descriptor) {
if (GetDevice()->ConsumedError(ValidateFinish(descriptor))) { if (GetDevice()->ConsumedError(ValidateFinish(descriptor))) {
return RenderBundleBase::MakeError(GetDevice()); return RenderBundleBase::MakeError(GetDevice());
} }
@ -112,9 +111,8 @@ namespace dawn_native {
std::move(mResourceUsage)); std::move(mResourceUsage));
} }
MaybeError RenderBundleEncoderBase::ValidateFinish(const RenderBundleDescriptor* descriptor) { MaybeError RenderBundleEncoder::ValidateFinish(const RenderBundleDescriptor* descriptor) {
TRACE_EVENT0(GetDevice()->GetPlatform(), Validation, TRACE_EVENT0(GetDevice()->GetPlatform(), Validation, "RenderBundleEncoder::ValidateFinish");
"RenderBundleEncoderBase::ValidateFinish");
DAWN_TRY(GetDevice()->ValidateObject(this)); DAWN_TRY(GetDevice()->ValidateObject(this));
// Even if Finish() validation fails, calling it will mutate the internal state of the // Even if Finish() validation fails, calling it will mutate the internal state of the

View File

@ -26,12 +26,12 @@ namespace dawn_native {
MaybeError ValidateRenderBundleEncoderDescriptor( MaybeError ValidateRenderBundleEncoderDescriptor(
const DeviceBase* device, const DeviceBase* device,
const RenderBundleEncoderDescriptor* descriptor); const RenderBundleEncoderDescriptor* descriptor);
class RenderBundleEncoderBase : public RenderEncoderBase {
public:
RenderBundleEncoderBase(DeviceBase* device,
const RenderBundleEncoderDescriptor* descriptor);
static RenderBundleEncoderBase* MakeError(DeviceBase* device); class RenderBundleEncoder final : public RenderEncoderBase {
public:
RenderBundleEncoder(DeviceBase* device, const RenderBundleEncoderDescriptor* descriptor);
static RenderBundleEncoder* MakeError(DeviceBase* device);
const AttachmentState* GetAttachmentState() const; const AttachmentState* GetAttachmentState() const;
@ -40,7 +40,7 @@ namespace dawn_native {
CommandIterator AcquireCommands(); CommandIterator AcquireCommands();
private: private:
RenderBundleEncoderBase(DeviceBase* device, ErrorTag errorTag); RenderBundleEncoder(DeviceBase* device, ErrorTag errorTag);
MaybeError ValidateFinish(const RenderBundleDescriptor* descriptor); MaybeError ValidateFinish(const RenderBundleDescriptor* descriptor);

View File

@ -27,27 +27,26 @@
namespace dawn_native { namespace dawn_native {
RenderPassEncoderBase::RenderPassEncoderBase(DeviceBase* device, RenderPassEncoder::RenderPassEncoder(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext) EncodingContext* encodingContext)
: RenderEncoderBase(device, encodingContext), mCommandEncoder(commandEncoder) { : RenderEncoderBase(device, encodingContext), mCommandEncoder(commandEncoder) {
} }
RenderPassEncoderBase::RenderPassEncoderBase(DeviceBase* device, RenderPassEncoder::RenderPassEncoder(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext, EncodingContext* encodingContext,
ErrorTag errorTag) ErrorTag errorTag)
: RenderEncoderBase(device, encodingContext, errorTag), mCommandEncoder(commandEncoder) { : RenderEncoderBase(device, encodingContext, errorTag), mCommandEncoder(commandEncoder) {
} }
RenderPassEncoderBase* RenderPassEncoderBase::MakeError(DeviceBase* device, RenderPassEncoder* RenderPassEncoder::MakeError(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext) { EncodingContext* encodingContext) {
return new RenderPassEncoderBase(device, commandEncoder, encodingContext, return new RenderPassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError);
ObjectBase::kError);
} }
void RenderPassEncoderBase::EndPass() { void RenderPassEncoder::EndPass() {
if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
allocator->Allocate<EndRenderPassCmd>(Command::EndRenderPass); allocator->Allocate<EndRenderPassCmd>(Command::EndRenderPass);
@ -57,7 +56,7 @@ namespace dawn_native {
} }
} }
void RenderPassEncoderBase::SetStencilReference(uint32_t reference) { void RenderPassEncoder::SetStencilReference(uint32_t reference) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
SetStencilReferenceCmd* cmd = SetStencilReferenceCmd* cmd =
allocator->Allocate<SetStencilReferenceCmd>(Command::SetStencilReference); allocator->Allocate<SetStencilReferenceCmd>(Command::SetStencilReference);
@ -67,7 +66,7 @@ namespace dawn_native {
}); });
} }
void RenderPassEncoderBase::SetBlendColor(const Color* color) { void RenderPassEncoder::SetBlendColor(const Color* color) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
SetBlendColorCmd* cmd = allocator->Allocate<SetBlendColorCmd>(Command::SetBlendColor); SetBlendColorCmd* cmd = allocator->Allocate<SetBlendColorCmd>(Command::SetBlendColor);
cmd->color = *color; cmd->color = *color;
@ -76,7 +75,7 @@ namespace dawn_native {
}); });
} }
void RenderPassEncoderBase::SetViewport(float x, void RenderPassEncoder::SetViewport(float x,
float y, float y,
float width, float width,
float height, float height,
@ -111,7 +110,7 @@ namespace dawn_native {
}); });
} }
void RenderPassEncoderBase::SetScissorRect(uint32_t x, void RenderPassEncoder::SetScissorRect(uint32_t x,
uint32_t y, uint32_t y,
uint32_t width, uint32_t width,
uint32_t height) { uint32_t height) {
@ -131,8 +130,7 @@ namespace dawn_native {
}); });
} }
void RenderPassEncoderBase::ExecuteBundles(uint32_t count, void RenderPassEncoder::ExecuteBundles(uint32_t count, RenderBundleBase* const* renderBundles) {
RenderBundleBase* const* renderBundles) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
for (uint32_t i = 0; i < count; ++i) { for (uint32_t i = 0; i < count; ++i) {
DAWN_TRY(GetDevice()->ValidateObject(renderBundles[i])); DAWN_TRY(GetDevice()->ValidateObject(renderBundles[i]));

View File

@ -22,18 +22,14 @@ namespace dawn_native {
class RenderBundleBase; class RenderBundleBase;
// This is called RenderPassEncoderBase to match the code generator expectations. Note that it class RenderPassEncoder final : public RenderEncoderBase {
// is a pure frontend type to record in its parent CommandEncoder and never has a backend
// implementation.
// TODO(cwallez@chromium.org): Remove that generator limitation and rename to RenderPassEncoder
class RenderPassEncoderBase : public RenderEncoderBase {
public: public:
RenderPassEncoderBase(DeviceBase* device, RenderPassEncoder(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext); EncodingContext* encodingContext);
static RenderPassEncoderBase* MakeError(DeviceBase* device, static RenderPassEncoder* MakeError(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext); EncodingContext* encodingContext);
void EndPass(); void EndPass();
@ -50,15 +46,15 @@ namespace dawn_native {
void ExecuteBundles(uint32_t count, RenderBundleBase* const* renderBundles); void ExecuteBundles(uint32_t count, RenderBundleBase* const* renderBundles);
protected: protected:
RenderPassEncoderBase(DeviceBase* device, RenderPassEncoder(DeviceBase* device,
CommandEncoderBase* commandEncoder, CommandEncoder* commandEncoder,
EncodingContext* encodingContext, EncodingContext* encodingContext,
ErrorTag errorTag); ErrorTag errorTag);
private: private:
// For render and compute passes, the encoding context is borrowed from the command encoder. // For render and compute passes, the encoding context is borrowed from the command encoder.
// Keep a reference to the encoder to make sure the context isn't freed. // Keep a reference to the encoder to make sure the context isn't freed.
Ref<CommandEncoderBase> mCommandEncoder; Ref<CommandEncoder> mCommandEncoder;
}; };
} // namespace dawn_native } // namespace dawn_native

View File

@ -28,7 +28,7 @@ namespace dawn_native {
struct BeginRenderPassCmd; struct BeginRenderPassCmd;
class DeviceBase; class DeviceBase;
class RenderBundleEncoderBase; class RenderBundleEncoder;
MaybeError ValidateRenderPipelineDescriptor(const DeviceBase* device, MaybeError ValidateRenderPipelineDescriptor(const DeviceBase* device,
const RenderPipelineDescriptor* descriptor); const RenderPipelineDescriptor* descriptor);

View File

@ -566,8 +566,7 @@ namespace dawn_native { namespace d3d12 {
} // anonymous namespace } // anonymous namespace
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder, CommandBuffer::CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor)
const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) { : CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }

View File

@ -46,7 +46,7 @@ namespace dawn_native { namespace d3d12 {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor); CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
~CommandBuffer(); ~CommandBuffer();
MaybeError RecordCommands(CommandRecordingContext* commandContext, uint32_t indexInSubmit); MaybeError RecordCommands(CommandRecordingContext* commandContext, uint32_t indexInSubmit);

View File

@ -250,7 +250,7 @@ namespace dawn_native { namespace d3d12 {
DAWN_TRY(buffer->Initialize()); DAWN_TRY(buffer->Initialize());
return buffer.release(); return buffer.release();
} }
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* Device::CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) { const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor); return new CommandBuffer(encoder, descriptor);
} }

View File

@ -48,7 +48,7 @@ namespace dawn_native { namespace d3d12 {
MaybeError Initialize(); MaybeError Initialize();
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) override; const CommandBufferDescriptor* descriptor) override;
Serial GetCompletedCommandSerial() const final override; Serial GetCompletedCommandSerial() const final override;

View File

@ -21,7 +21,7 @@
#import <Metal/Metal.h> #import <Metal/Metal.h>
namespace dawn_native { namespace dawn_native {
class CommandEncoderBase; class CommandEncoder;
} }
namespace dawn_native { namespace metal { namespace dawn_native { namespace metal {
@ -31,7 +31,7 @@ namespace dawn_native { namespace metal {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor); CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
~CommandBuffer(); ~CommandBuffer();
void FillCommands(id<MTLCommandBuffer> commandBuffer); void FillCommands(id<MTLCommandBuffer> commandBuffer);

View File

@ -591,8 +591,7 @@ namespace dawn_native { namespace metal {
} // anonymous namespace } // anonymous namespace
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder, CommandBuffer::CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor)
const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) { : CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }

View File

@ -38,7 +38,7 @@ namespace dawn_native { namespace metal {
Device(AdapterBase* adapter, id<MTLDevice> mtlDevice, const DeviceDescriptor* descriptor); Device(AdapterBase* adapter, id<MTLDevice> mtlDevice, const DeviceDescriptor* descriptor);
~Device(); ~Device();
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) override; const CommandBufferDescriptor* descriptor) override;
Serial GetCompletedCommandSerial() const final override; Serial GetCompletedCommandSerial() const final override;

View File

@ -105,7 +105,7 @@ namespace dawn_native { namespace metal {
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) { ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
return new Buffer(this, descriptor); return new Buffer(this, descriptor);
} }
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* Device::CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) { const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor); return new CommandBuffer(encoder, descriptor);
} }

View File

@ -103,7 +103,7 @@ namespace dawn_native { namespace null {
DAWN_TRY(IncrementMemoryUsage(descriptor->size)); DAWN_TRY(IncrementMemoryUsage(descriptor->size));
return new Buffer(this, descriptor); return new Buffer(this, descriptor);
} }
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* Device::CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) { const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor); return new CommandBuffer(encoder, descriptor);
} }
@ -302,8 +302,7 @@ namespace dawn_native { namespace null {
// CommandBuffer // CommandBuffer
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder, CommandBuffer::CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor)
const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) { : CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }

View File

@ -86,7 +86,7 @@ namespace dawn_native { namespace null {
Device(Adapter* adapter, const DeviceDescriptor* descriptor); Device(Adapter* adapter, const DeviceDescriptor* descriptor);
~Device(); ~Device();
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) override; const CommandBufferDescriptor* descriptor) override;
Serial GetCompletedCommandSerial() const final override; Serial GetCompletedCommandSerial() const final override;
@ -178,7 +178,7 @@ namespace dawn_native { namespace null {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor); CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
~CommandBuffer(); ~CommandBuffer();
private: private:

View File

@ -394,8 +394,7 @@ namespace dawn_native { namespace opengl {
} // namespace } // namespace
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder, CommandBuffer::CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor)
const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) { : CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }

View File

@ -28,7 +28,7 @@ namespace dawn_native { namespace opengl {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor); CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
~CommandBuffer(); ~CommandBuffer();
void Execute(); void Execute();

View File

@ -75,7 +75,7 @@ namespace dawn_native { namespace opengl {
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) { ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
return new Buffer(this, descriptor); return new Buffer(this, descriptor);
} }
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* Device::CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) { const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor); return new CommandBuffer(encoder, descriptor);
} }

View File

@ -47,7 +47,7 @@ namespace dawn_native { namespace opengl {
void SubmitFenceSync(); void SubmitFenceSync();
// Dawn API // Dawn API
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) override; const CommandBufferDescriptor* descriptor) override;
Serial GetCompletedCommandSerial() const final override; Serial GetCompletedCommandSerial() const final override;

View File

@ -351,13 +351,12 @@ namespace dawn_native { namespace vulkan {
} // anonymous namespace } // anonymous namespace
// static // static
CommandBuffer* CommandBuffer::Create(CommandEncoderBase* encoder, CommandBuffer* CommandBuffer::Create(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) { const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor); return new CommandBuffer(encoder, descriptor);
} }
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder, CommandBuffer::CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor)
const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) { : CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }

View File

@ -33,14 +33,14 @@ namespace dawn_native { namespace vulkan {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
static CommandBuffer* Create(CommandEncoderBase* encoder, static CommandBuffer* Create(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor); const CommandBufferDescriptor* descriptor);
~CommandBuffer(); ~CommandBuffer();
MaybeError RecordCommands(CommandRecordingContext* recordingContext); MaybeError RecordCommands(CommandRecordingContext* recordingContext);
private: private:
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor); CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
void RecordComputePass(CommandRecordingContext* recordingContext); void RecordComputePass(CommandRecordingContext* recordingContext);
MaybeError RecordRenderPass(CommandRecordingContext* recordingContext, MaybeError RecordRenderPass(CommandRecordingContext* recordingContext,

View File

@ -164,7 +164,7 @@ namespace dawn_native { namespace vulkan {
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) { ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
return Buffer::Create(this, descriptor); return Buffer::Create(this, descriptor);
} }
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* Device::CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) { const CommandBufferDescriptor* descriptor) {
return CommandBuffer::Create(encoder, descriptor); return CommandBuffer::Create(encoder, descriptor);
} }

View File

@ -77,7 +77,7 @@ namespace dawn_native { namespace vulkan {
ExternalSemaphoreHandle* outHandle); ExternalSemaphoreHandle* outHandle);
// Dawn API // Dawn API
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder, CommandBufferBase* CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) override; const CommandBufferDescriptor* descriptor) override;
Serial GetCompletedCommandSerial() const final override; Serial GetCompletedCommandSerial() const final override;