Add missing descriptors that are present in WebGPU.

These are the CommandEncoder, ComputePass and CommandBuffer descriptors
that contains nothing but a debug name for now but are important for
later extensibility. Defaults are added so the C++ API doesn't require
the descriptors to be passed as arguments.

Also renames variables named "info" for RenderPassDescriptor to
"descriptor" as is now the standard in the codebase.

BUG=dawn:22

Change-Id: I9de4cfbbce952d01fb79ed1d9f34825a6fa174f9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8686
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2019-07-10 20:43:13 +00:00 committed by Commit Bot service account
parent 27e67b5f97
commit 4b90c47ce0
28 changed files with 164 additions and 105 deletions

View File

@ -244,23 +244,34 @@
"command buffer": { "command buffer": {
"category": "object" "category": "object"
}, },
"command buffer descriptor": {
"category": "structure",
"extensible": true,
"members": []
},
"command encoder": { "command encoder": {
"category": "object", "category": "object",
"methods": [ "methods": [
{ {
"name": "finish", "name": "finish",
"returns": "command buffer" "returns": "command buffer",
"args": [
{"name": "descriptor", "type": "command buffer descriptor", "annotation": "const*", "optional": true}
]
}, },
{ {
"name": "begin compute pass", "name": "begin compute pass",
"returns": "compute pass encoder" "returns": "compute pass encoder",
"args": [
{"name": "descriptor", "type": "compute pass descriptor", "annotation": "const*", "optional": true}
]
}, },
{ {
"name": "begin render pass", "name": "begin render pass",
"returns": "render pass encoder",
"args": [ "args": [
{"name": "info", "type": "render pass descriptor", "annotation": "const*"} {"name": "descriptor", "type": "render pass descriptor", "annotation": "const*"}
], ]
"returns": "render pass encoder"
}, },
{ {
"name": "copy buffer to buffer", "name": "copy buffer to buffer",
@ -301,6 +312,11 @@
} }
] ]
}, },
"command encoder descriptor": {
"category": "structure",
"extensible": true,
"members": []
},
"compare function": { "compare function": {
"category": "enum", "category": "enum",
"values": [ "values": [
@ -314,6 +330,11 @@
{"value": 7, "name": "always"} {"value": 7, "name": "always"}
] ]
}, },
"compute pass descriptor": {
"category": "structure",
"extensible": true,
"members": []
},
"compute pass encoder": { "compute pass encoder": {
"category": "object", "category": "object",
"methods": [ "methods": [
@ -429,7 +450,10 @@
}, },
{ {
"name": "create command encoder", "name": "create command encoder",
"returns": "command encoder" "returns": "command encoder",
"args": [
{"name": "descriptor", "type": "command encoder descriptor", "annotation": "const*", "optional": true}
]
}, },
{ {
"name": "create compute pipeline", "name": "create compute pipeline",

View File

@ -141,7 +141,7 @@ void frame() {
} }
DawnCommandBuffer commands; DawnCommandBuffer commands;
{ {
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device); DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
DawnRenderPassEncoder pass = dawnCommandEncoderBeginRenderPass(encoder, &renderpassInfo); DawnRenderPassEncoder pass = dawnCommandEncoderBeginRenderPass(encoder, &renderpassInfo);
dawnRenderPassEncoderSetPipeline(pass, pipeline); dawnRenderPassEncoderSetPipeline(pass, pipeline);
@ -149,7 +149,7 @@ void frame() {
dawnRenderPassEncoderEndPass(pass); dawnRenderPassEncoderEndPass(pass);
dawnRenderPassEncoderRelease(pass); dawnRenderPassEncoderRelease(pass);
commands = dawnCommandEncoderFinish(encoder); commands = dawnCommandEncoderFinish(encoder, nullptr);
dawnCommandEncoderRelease(encoder); dawnCommandEncoderRelease(encoder);
} }

View File

@ -19,8 +19,9 @@
namespace dawn_native { namespace dawn_native {
CommandBufferBase::CommandBufferBase(DeviceBase* device, CommandEncoderBase* encoder) CommandBufferBase::CommandBufferBase(CommandEncoderBase* encoder,
: ObjectBase(device), mResourceUsages(encoder->AcquireResourceUsages()) { const CommandBufferDescriptor*)
: ObjectBase(encoder->GetDevice()), mResourceUsages(encoder->AcquireResourceUsages()) {
} }
CommandBufferBase::CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag) CommandBufferBase::CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag)

View File

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

View File

@ -444,32 +444,37 @@ namespace dawn_native {
} }
MaybeError ValidateRenderPassDescriptor(const DeviceBase* device, MaybeError ValidateRenderPassDescriptor(const DeviceBase* device,
const RenderPassDescriptor* renderPass, const RenderPassDescriptor* descriptor,
uint32_t* width, uint32_t* width,
uint32_t* height, uint32_t* height,
uint32_t* sampleCount) { uint32_t* sampleCount) {
if (renderPass->colorAttachmentCount > kMaxColorAttachments) { if (descriptor->colorAttachmentCount > kMaxColorAttachments) {
return DAWN_VALIDATION_ERROR("Setting color attachments out of bounds"); return DAWN_VALIDATION_ERROR("Setting color attachments out of bounds");
} }
for (uint32_t i = 0; i < renderPass->colorAttachmentCount; ++i) { for (uint32_t i = 0; i < descriptor->colorAttachmentCount; ++i) {
DAWN_TRY(ValidateRenderPassColorAttachment(device, renderPass->colorAttachments[i], DAWN_TRY(ValidateRenderPassColorAttachment(device, descriptor->colorAttachments[i],
width, height, sampleCount)); width, height, sampleCount));
} }
if (renderPass->depthStencilAttachment != nullptr) { if (descriptor->depthStencilAttachment != nullptr) {
DAWN_TRY(ValidateRenderPassDepthStencilAttachment( DAWN_TRY(ValidateRenderPassDepthStencilAttachment(
device, renderPass->depthStencilAttachment, width, height, sampleCount)); device, descriptor->depthStencilAttachment, width, height, sampleCount));
} }
if (renderPass->colorAttachmentCount == 0 && if (descriptor->colorAttachmentCount == 0 &&
renderPass->depthStencilAttachment == nullptr) { descriptor->depthStencilAttachment == nullptr) {
return DAWN_VALIDATION_ERROR("Cannot use render pass with no attachments."); return DAWN_VALIDATION_ERROR("Cannot use render pass with no attachments.");
} }
return {}; return {};
} }
MaybeError ValidateComputePassDescriptor(const DeviceBase* device,
const ComputePassDescriptor* descriptor) {
return {};
}
enum class PassType { enum class PassType {
Render, Render,
Compute, Compute,
@ -618,7 +623,7 @@ namespace dawn_native {
Finished Finished
}; };
CommandEncoderBase::CommandEncoderBase(DeviceBase* device) CommandEncoderBase::CommandEncoderBase(DeviceBase* device, const CommandEncoderDescriptor*)
: ObjectBase(device), mEncodingState(EncodingState::TopLevel) { : ObjectBase(device), mEncodingState(EncodingState::TopLevel) {
} }
@ -650,19 +655,25 @@ namespace dawn_native {
// Implementation of the API's command recording methods // Implementation of the API's command recording methods
ComputePassEncoderBase* CommandEncoderBase::BeginComputePass() { ComputePassEncoderBase* CommandEncoderBase::BeginComputePass(
const ComputePassDescriptor* descriptor) {
DeviceBase* device = GetDevice(); DeviceBase* device = GetDevice();
if (ConsumedError(ValidateCanRecordTopLevelCommands())) { if (ConsumedError(ValidateCanRecordTopLevelCommands())) {
return ComputePassEncoderBase::MakeError(device, this); return ComputePassEncoderBase::MakeError(device, this);
} }
if (ConsumedError(ValidateComputePassDescriptor(device, descriptor))) {
return ComputePassEncoderBase::MakeError(device, this);
}
mAllocator.Allocate<BeginComputePassCmd>(Command::BeginComputePass); mAllocator.Allocate<BeginComputePassCmd>(Command::BeginComputePass);
mEncodingState = EncodingState::ComputePass; mEncodingState = EncodingState::ComputePass;
return new ComputePassEncoderBase(device, this, &mAllocator); return new ComputePassEncoderBase(device, this, &mAllocator);
} }
RenderPassEncoderBase* CommandEncoderBase::BeginRenderPass(const RenderPassDescriptor* info) { RenderPassEncoderBase* CommandEncoderBase::BeginRenderPass(
const RenderPassDescriptor* descriptor) {
DeviceBase* device = GetDevice(); DeviceBase* device = GetDevice();
if (ConsumedError(ValidateCanRecordTopLevelCommands())) { if (ConsumedError(ValidateCanRecordTopLevelCommands())) {
@ -673,7 +684,7 @@ namespace dawn_native {
uint32_t height = 0; uint32_t height = 0;
uint32_t sampleCount = 0; uint32_t sampleCount = 0;
if (ConsumedError( if (ConsumedError(
ValidateRenderPassDescriptor(device, info, &width, &height, &sampleCount))) { ValidateRenderPassDescriptor(device, descriptor, &width, &height, &sampleCount))) {
return RenderPassEncoderBase::MakeError(device, this); return RenderPassEncoderBase::MakeError(device, this);
} }
@ -683,28 +694,33 @@ namespace dawn_native {
BeginRenderPassCmd* cmd = mAllocator.Allocate<BeginRenderPassCmd>(Command::BeginRenderPass); BeginRenderPassCmd* cmd = mAllocator.Allocate<BeginRenderPassCmd>(Command::BeginRenderPass);
for (uint32_t i = 0; i < info->colorAttachmentCount; ++i) { for (uint32_t i = 0; i < descriptor->colorAttachmentCount; ++i) {
if (info->colorAttachments[i] != nullptr) { if (descriptor->colorAttachments[i] != nullptr) {
cmd->colorAttachmentsSet.set(i); cmd->colorAttachmentsSet.set(i);
cmd->colorAttachments[i].view = info->colorAttachments[i]->attachment; cmd->colorAttachments[i].view = descriptor->colorAttachments[i]->attachment;
cmd->colorAttachments[i].resolveTarget = info->colorAttachments[i]->resolveTarget; cmd->colorAttachments[i].resolveTarget =
cmd->colorAttachments[i].loadOp = info->colorAttachments[i]->loadOp; descriptor->colorAttachments[i]->resolveTarget;
cmd->colorAttachments[i].storeOp = info->colorAttachments[i]->storeOp; cmd->colorAttachments[i].loadOp = descriptor->colorAttachments[i]->loadOp;
cmd->colorAttachments[i].clearColor = info->colorAttachments[i]->clearColor; cmd->colorAttachments[i].storeOp = descriptor->colorAttachments[i]->storeOp;
cmd->colorAttachments[i].clearColor = descriptor->colorAttachments[i]->clearColor;
} }
} }
cmd->hasDepthStencilAttachment = info->depthStencilAttachment != nullptr; cmd->hasDepthStencilAttachment = descriptor->depthStencilAttachment != nullptr;
if (cmd->hasDepthStencilAttachment) { if (cmd->hasDepthStencilAttachment) {
cmd->hasDepthStencilAttachment = true; cmd->hasDepthStencilAttachment = true;
cmd->depthStencilAttachment.view = info->depthStencilAttachment->attachment; cmd->depthStencilAttachment.view = descriptor->depthStencilAttachment->attachment;
cmd->depthStencilAttachment.clearDepth = info->depthStencilAttachment->clearDepth; cmd->depthStencilAttachment.clearDepth = descriptor->depthStencilAttachment->clearDepth;
cmd->depthStencilAttachment.clearStencil = info->depthStencilAttachment->clearStencil; cmd->depthStencilAttachment.clearStencil =
cmd->depthStencilAttachment.depthLoadOp = info->depthStencilAttachment->depthLoadOp; descriptor->depthStencilAttachment->clearStencil;
cmd->depthStencilAttachment.depthStoreOp = info->depthStencilAttachment->depthStoreOp; cmd->depthStencilAttachment.depthLoadOp =
cmd->depthStencilAttachment.stencilLoadOp = info->depthStencilAttachment->stencilLoadOp; descriptor->depthStencilAttachment->depthLoadOp;
cmd->depthStencilAttachment.depthStoreOp =
descriptor->depthStencilAttachment->depthStoreOp;
cmd->depthStencilAttachment.stencilLoadOp =
descriptor->depthStencilAttachment->stencilLoadOp;
cmd->depthStencilAttachment.stencilStoreOp = cmd->depthStencilAttachment.stencilStoreOp =
info->depthStencilAttachment->stencilStoreOp; descriptor->depthStencilAttachment->stencilStoreOp;
} }
cmd->width = width; cmd->width = width;
@ -842,8 +858,8 @@ namespace dawn_native {
copy->copySize = *copySize; copy->copySize = *copySize;
} }
CommandBufferBase* CommandEncoderBase::Finish() { CommandBufferBase* CommandEncoderBase::Finish(const CommandBufferDescriptor* descriptor) {
if (GetDevice()->ConsumedError(ValidateFinish())) { 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.
mEncodingState = EncodingState::Finished; mEncodingState = EncodingState::Finished;
@ -854,7 +870,7 @@ namespace dawn_native {
mEncodingState = EncodingState::Finished; mEncodingState = EncodingState::Finished;
MoveToIterator(); MoveToIterator();
return GetDevice()->CreateCommandBuffer(this); return GetDevice()->CreateCommandBuffer(this, descriptor);
} }
// Implementation of functions to interact with sub-encoders // Implementation of functions to interact with sub-encoders
@ -892,7 +908,7 @@ 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() { MaybeError CommandEncoderBase::ValidateFinish(const CommandBufferDescriptor*) {
DAWN_TRY(GetDevice()->ValidateObject(this)); DAWN_TRY(GetDevice()->ValidateObject(this));
if (mGotError) { if (mGotError) {

View File

@ -30,15 +30,15 @@ namespace dawn_native {
class CommandEncoderBase : public ObjectBase { class CommandEncoderBase : public ObjectBase {
public: public:
CommandEncoderBase(DeviceBase* device); CommandEncoderBase(DeviceBase* device, const CommandEncoderDescriptor* descriptor);
~CommandEncoderBase(); ~CommandEncoderBase();
CommandIterator AcquireCommands(); CommandIterator AcquireCommands();
CommandBufferResourceUsage AcquireResourceUsages(); CommandBufferResourceUsage AcquireResourceUsages();
// Dawn API // Dawn API
ComputePassEncoderBase* BeginComputePass(); ComputePassEncoderBase* BeginComputePass(const ComputePassDescriptor* descriptor);
RenderPassEncoderBase* BeginRenderPass(const RenderPassDescriptor* info); RenderPassEncoderBase* BeginRenderPass(const RenderPassDescriptor* descriptor);
void CopyBufferToBuffer(BufferBase* source, void CopyBufferToBuffer(BufferBase* source,
uint64_t sourceOffset, uint64_t sourceOffset,
BufferBase* destination, BufferBase* destination,
@ -53,7 +53,7 @@ namespace dawn_native {
void CopyTextureToTexture(const TextureCopyView* source, void CopyTextureToTexture(const TextureCopyView* source,
const TextureCopyView* destination, const TextureCopyView* destination,
const Extent3D* copySize); const Extent3D* copySize);
CommandBufferBase* Finish(); CommandBufferBase* Finish(const CommandBufferDescriptor* descriptor);
// Functions to interact with the encoders // Functions to interact with the encoders
void HandleError(const char* message); void HandleError(const char* message);
@ -69,7 +69,7 @@ namespace dawn_native {
void PassEnded(); void PassEnded();
private: private:
MaybeError ValidateFinish(); MaybeError ValidateFinish(const CommandBufferDescriptor* descriptor);
MaybeError ValidateComputePass(); MaybeError ValidateComputePass();
MaybeError ValidateRenderPass(BeginRenderPassCmd* renderPass); MaybeError ValidateRenderPass(BeginRenderPassCmd* renderPass);
MaybeError ValidateCanRecordTopLevelCommands() const; MaybeError ValidateCanRecordTopLevelCommands() const;

View File

@ -307,8 +307,9 @@ 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() { CommandEncoderBase* DeviceBase::CreateCommandEncoder(
return new CommandEncoderBase(this); const CommandEncoderDescriptor* descriptor) {
return new CommandEncoderBase(this, descriptor);
} }
ComputePipelineBase* DeviceBase::CreateComputePipeline( ComputePipelineBase* DeviceBase::CreateComputePipeline(
const ComputePipelineDescriptor* descriptor) { const ComputePipelineDescriptor* descriptor) {

View File

@ -56,7 +56,9 @@ namespace dawn_native {
FenceSignalTracker* GetFenceSignalTracker() const; FenceSignalTracker* GetFenceSignalTracker() const;
virtual CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder) = 0; virtual CommandBufferBase* CreateCommandBuffer(
CommandEncoderBase* encoder,
const CommandBufferDescriptor* descriptor) = 0;
virtual Serial GetCompletedCommandSerial() const = 0; virtual Serial GetCompletedCommandSerial() const = 0;
virtual Serial GetLastSubmittedCommandSerial() const = 0; virtual Serial GetLastSubmittedCommandSerial() const = 0;
@ -108,7 +110,7 @@ namespace dawn_native {
void CreateBufferMappedAsync(const BufferDescriptor* descriptor, void CreateBufferMappedAsync(const BufferDescriptor* descriptor,
dawn::BufferCreateMappedCallback callback, dawn::BufferCreateMappedCallback callback,
void* userdata); void* userdata);
CommandEncoderBase* CreateCommandEncoder(); CommandEncoderBase* 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();

View File

@ -401,8 +401,9 @@ namespace dawn_native { namespace d3d12 {
} // anonymous namespace } // anonymous namespace
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder) CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) { const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }
CommandBuffer::~CommandBuffer() { CommandBuffer::~CommandBuffer() {

View File

@ -48,7 +48,7 @@ namespace dawn_native { namespace d3d12 {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(Device* device, CommandEncoderBase* encoder); CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
~CommandBuffer(); ~CommandBuffer();
void RecordCommands(ComPtr<ID3D12GraphicsCommandList> commandList, uint32_t indexInSubmit); void RecordCommands(ComPtr<ID3D12GraphicsCommandList> commandList, uint32_t indexInSubmit);

View File

@ -262,8 +262,9 @@ namespace dawn_native { namespace d3d12 {
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(CommandEncoderBase* encoder,
return new CommandBuffer(this, encoder); const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor);
} }
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl( ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
const ComputePipelineDescriptor* descriptor) { const ComputePipelineDescriptor* descriptor) {

View File

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

View File

@ -31,7 +31,7 @@ namespace dawn_native { namespace metal {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(Device* device, CommandEncoderBase* encoder); CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
~CommandBuffer(); ~CommandBuffer();
void FillCommands(id<MTLCommandBuffer> commandBuffer); void FillCommands(id<MTLCommandBuffer> commandBuffer);

View File

@ -399,8 +399,9 @@ namespace dawn_native { namespace metal {
} }
} // anonymous namespace } // anonymous namespace
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder) CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) { const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }
CommandBuffer::~CommandBuffer() { CommandBuffer::~CommandBuffer() {

View File

@ -37,7 +37,8 @@ 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) override; CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder,
const CommandBufferDescriptor* descriptor) override;
Serial GetCompletedCommandSerial() const final override; Serial GetCompletedCommandSerial() const final override;
Serial GetLastSubmittedCommandSerial() const final override; Serial GetLastSubmittedCommandSerial() const final override;

View File

@ -95,8 +95,9 @@ 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(CommandEncoderBase* encoder,
return new CommandBuffer(this, encoder); const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor);
} }
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl( ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
const ComputePipelineDescriptor* descriptor) { const ComputePipelineDescriptor* descriptor) {

View File

@ -97,8 +97,9 @@ 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(CommandEncoderBase* encoder,
return new CommandBuffer(this, encoder); const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor);
} }
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl( ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
const ComputePipelineDescriptor* descriptor) { const ComputePipelineDescriptor* descriptor) {
@ -291,8 +292,9 @@ namespace dawn_native { namespace null {
// CommandBuffer // CommandBuffer
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder) CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) { const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }
CommandBuffer::~CommandBuffer() { CommandBuffer::~CommandBuffer() {

View File

@ -85,7 +85,8 @@ namespace dawn_native { namespace null {
Device(Adapter* adapter, const DeviceDescriptor* descriptor); Device(Adapter* adapter, const DeviceDescriptor* descriptor);
~Device(); ~Device();
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder) override; CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder,
const CommandBufferDescriptor* descriptor) override;
Serial GetCompletedCommandSerial() const final override; Serial GetCompletedCommandSerial() const final override;
Serial GetLastSubmittedCommandSerial() const final override; Serial GetLastSubmittedCommandSerial() const final override;
@ -164,7 +165,7 @@ namespace dawn_native { namespace null {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(Device* device, CommandEncoderBase* encoder); CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
~CommandBuffer(); ~CommandBuffer();
private: private:

View File

@ -326,8 +326,9 @@ namespace dawn_native { namespace opengl {
} }
} // namespace } // namespace
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder) CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) { const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }
CommandBuffer::~CommandBuffer() { CommandBuffer::~CommandBuffer() {

View File

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

View File

@ -65,8 +65,9 @@ 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(CommandEncoderBase* encoder,
return new CommandBuffer(this, encoder); const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor);
} }
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl( ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
const ComputePipelineDescriptor* descriptor) { const ComputePipelineDescriptor* descriptor) {

View File

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

View File

@ -327,8 +327,9 @@ namespace dawn_native { namespace vulkan {
} }
} // anonymous namespace } // anonymous namespace
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder) CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) { const CommandBufferDescriptor* descriptor)
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
} }
CommandBuffer::~CommandBuffer() { CommandBuffer::~CommandBuffer() {

View File

@ -30,7 +30,7 @@ namespace dawn_native { namespace vulkan {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(Device* device, CommandEncoderBase* encoder); CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
~CommandBuffer(); ~CommandBuffer();
void RecordCommands(VkCommandBuffer commands); void RecordCommands(VkCommandBuffer commands);

View File

@ -148,8 +148,9 @@ namespace dawn_native { namespace vulkan {
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(CommandEncoderBase* encoder,
return new CommandBuffer(this, encoder); const CommandBufferDescriptor* descriptor) {
return new CommandBuffer(encoder, descriptor);
} }
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl( ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
const ComputePipelineDescriptor* descriptor) { const ComputePipelineDescriptor* descriptor) {

View File

@ -64,7 +64,8 @@ namespace dawn_native { namespace vulkan {
void AddWaitSemaphore(VkSemaphore semaphore); void AddWaitSemaphore(VkSemaphore semaphore);
// Dawn API // Dawn API
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder) override; CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder,
const CommandBufferDescriptor* descriptor) override;
Serial GetCompletedCommandSerial() const final override; Serial GetCompletedCommandSerial() const final override;
Serial GetLastSubmittedCommandSerial() const final override; Serial GetLastSubmittedCommandSerial() const final override;

View File

@ -30,15 +30,15 @@ class WireArgumentTests : public WireTest {
// Test that the wire is able to send numerical values // Test that the wire is able to send numerical values
TEST_F(WireArgumentTests, ValueArgument) { TEST_F(WireArgumentTests, ValueArgument) {
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device); DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder); DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder, nullptr);
dawnComputePassEncoderDispatch(pass, 1, 2, 3); dawnComputePassEncoderDispatch(pass, 1, 2, 3);
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder(); DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder)); EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder));
DawnComputePassEncoder apiPass = api.GetNewComputePassEncoder(); DawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder)).WillOnce(Return(apiPass)); EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder, nullptr)).WillOnce(Return(apiPass));
EXPECT_CALL(api, ComputePassEncoderDispatch(apiPass, 1, 2, 3)).Times(1); EXPECT_CALL(api, ComputePassEncoderDispatch(apiPass, 1, 2, 3)).Times(1);
@ -68,17 +68,17 @@ TEST_F(WireArgumentTests, ValueArrayArgument) {
EXPECT_CALL(api, DeviceCreateBindGroup(apiDevice, _)).WillOnce(Return(apiBindGroup)); EXPECT_CALL(api, DeviceCreateBindGroup(apiDevice, _)).WillOnce(Return(apiBindGroup));
// Use the bindgroup in SetBindGroup that takes an array of value offsets. // Use the bindgroup in SetBindGroup that takes an array of value offsets.
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device); DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder); DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder, nullptr);
std::array<uint64_t, 4> testOffsets = {0, 42, 0xDEAD'BEEF'DEAD'BEEFu, 0xFFFF'FFFF'FFFF'FFFFu}; std::array<uint64_t, 4> testOffsets = {0, 42, 0xDEAD'BEEF'DEAD'BEEFu, 0xFFFF'FFFF'FFFF'FFFFu};
dawnComputePassEncoderSetBindGroup(pass, 0, bindGroup, testOffsets.size(), testOffsets.data()); dawnComputePassEncoderSetBindGroup(pass, 0, bindGroup, testOffsets.size(), testOffsets.data());
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder(); DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder)); EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder));
DawnComputePassEncoder apiPass = api.GetNewComputePassEncoder(); DawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder)).WillOnce(Return(apiPass)); EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder, nullptr)).WillOnce(Return(apiPass));
EXPECT_CALL(api, ComputePassEncoderSetBindGroup( EXPECT_CALL(api, ComputePassEncoderSetBindGroup(
apiPass, 0, apiBindGroup, testOffsets.size(), apiPass, 0, apiBindGroup, testOffsets.size(),
@ -201,9 +201,9 @@ TEST_F(WireArgumentTests, CStringArgument) {
// Test that the wire is able to send objects as value arguments // Test that the wire is able to send objects as value arguments
TEST_F(WireArgumentTests, ObjectAsValueArgument) { TEST_F(WireArgumentTests, ObjectAsValueArgument) {
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device); DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device, nullptr);
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder(); DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder)); EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder));
DawnBufferDescriptor descriptor; DawnBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
@ -232,16 +232,16 @@ TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
// CreateCommandEncoder might be swapped since they are equivalent in term of matchers // CreateCommandEncoder might be swapped since they are equivalent in term of matchers
Sequence s; Sequence s;
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device); DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device, nullptr);
cmdBufs[i] = dawnCommandEncoderFinish(cmdBufEncoder); cmdBufs[i] = dawnCommandEncoderFinish(cmdBufEncoder, nullptr);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.InSequence(s) .InSequence(s)
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));
apiCmdBufs[i] = api.GetNewCommandBuffer(); apiCmdBufs[i] = api.GetNewCommandBuffer();
EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder)) EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder, nullptr))
.WillOnce(Return(apiCmdBufs[i])); .WillOnce(Return(apiCmdBufs[i]));
} }

View File

@ -26,10 +26,10 @@ class WireBasicTests : public WireTest {
// One call gets forwarded correctly. // One call gets forwarded correctly.
TEST_F(WireBasicTests, CallForwarded) { TEST_F(WireBasicTests, CallForwarded) {
dawnDeviceCreateCommandEncoder(device); dawnDeviceCreateCommandEncoder(device, nullptr);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));
FlushClient(); FlushClient();
@ -37,28 +37,28 @@ TEST_F(WireBasicTests, CallForwarded) {
// Test that calling methods on a new object works as expected. // Test that calling methods on a new object works as expected.
TEST_F(WireBasicTests, CreateThenCall) { TEST_F(WireBasicTests, CreateThenCall) {
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device); DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
dawnCommandEncoderFinish(encoder); dawnCommandEncoderFinish(encoder, nullptr);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));
DawnCommandBuffer apiCmdBuf = api.GetNewCommandBuffer(); DawnCommandBuffer apiCmdBuf = api.GetNewCommandBuffer();
EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder)).WillOnce(Return(apiCmdBuf)); EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder, nullptr)).WillOnce(Return(apiCmdBuf));
FlushClient(); FlushClient();
} }
// Test that client reference/release do not call the backend API. // Test that client reference/release do not call the backend API.
TEST_F(WireBasicTests, RefCountKeptInClient) { TEST_F(WireBasicTests, RefCountKeptInClient) {
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device); DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
dawnCommandEncoderReference(encoder); dawnCommandEncoderReference(encoder);
dawnCommandEncoderRelease(encoder); dawnCommandEncoderRelease(encoder);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));
FlushClient(); FlushClient();
@ -66,12 +66,12 @@ TEST_F(WireBasicTests, RefCountKeptInClient) {
// Test that client reference/release do not call the backend API. // Test that client reference/release do not call the backend API.
TEST_F(WireBasicTests, ReleaseCalledOnRefCount0) { TEST_F(WireBasicTests, ReleaseCalledOnRefCount0) {
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device); DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
dawnCommandEncoderRelease(encoder); dawnCommandEncoderRelease(encoder);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));
EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder)); EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));