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:
parent
27e67b5f97
commit
4b90c47ce0
36
dawn.json
36
dawn.json
|
@ -244,23 +244,34 @@
|
|||
"command buffer": {
|
||||
"category": "object"
|
||||
},
|
||||
"command buffer descriptor": {
|
||||
"category": "structure",
|
||||
"extensible": true,
|
||||
"members": []
|
||||
},
|
||||
"command encoder": {
|
||||
"category": "object",
|
||||
"methods": [
|
||||
{
|
||||
"name": "finish",
|
||||
"returns": "command buffer"
|
||||
"returns": "command buffer",
|
||||
"args": [
|
||||
{"name": "descriptor", "type": "command buffer descriptor", "annotation": "const*", "optional": true}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"returns": "render pass encoder",
|
||||
"args": [
|
||||
{"name": "info", "type": "render pass descriptor", "annotation": "const*"}
|
||||
],
|
||||
"returns": "render pass encoder"
|
||||
{"name": "descriptor", "type": "render pass descriptor", "annotation": "const*"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "copy buffer to buffer",
|
||||
|
@ -301,6 +312,11 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"command encoder descriptor": {
|
||||
"category": "structure",
|
||||
"extensible": true,
|
||||
"members": []
|
||||
},
|
||||
"compare function": {
|
||||
"category": "enum",
|
||||
"values": [
|
||||
|
@ -314,6 +330,11 @@
|
|||
{"value": 7, "name": "always"}
|
||||
]
|
||||
},
|
||||
"compute pass descriptor": {
|
||||
"category": "structure",
|
||||
"extensible": true,
|
||||
"members": []
|
||||
},
|
||||
"compute pass encoder": {
|
||||
"category": "object",
|
||||
"methods": [
|
||||
|
@ -429,7 +450,10 @@
|
|||
},
|
||||
{
|
||||
"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",
|
||||
|
|
|
@ -141,7 +141,7 @@ void frame() {
|
|||
}
|
||||
DawnCommandBuffer commands;
|
||||
{
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
|
||||
|
||||
DawnRenderPassEncoder pass = dawnCommandEncoderBeginRenderPass(encoder, &renderpassInfo);
|
||||
dawnRenderPassEncoderSetPipeline(pass, pipeline);
|
||||
|
@ -149,7 +149,7 @@ void frame() {
|
|||
dawnRenderPassEncoderEndPass(pass);
|
||||
dawnRenderPassEncoderRelease(pass);
|
||||
|
||||
commands = dawnCommandEncoderFinish(encoder);
|
||||
commands = dawnCommandEncoderFinish(encoder, nullptr);
|
||||
dawnCommandEncoderRelease(encoder);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
|
||||
namespace dawn_native {
|
||||
|
||||
CommandBufferBase::CommandBufferBase(DeviceBase* device, CommandEncoderBase* encoder)
|
||||
: ObjectBase(device), mResourceUsages(encoder->AcquireResourceUsages()) {
|
||||
CommandBufferBase::CommandBufferBase(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor*)
|
||||
: ObjectBase(encoder->GetDevice()), mResourceUsages(encoder->AcquireResourceUsages()) {
|
||||
}
|
||||
|
||||
CommandBufferBase::CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace dawn_native {
|
|||
|
||||
class CommandBufferBase : public ObjectBase {
|
||||
public:
|
||||
CommandBufferBase(DeviceBase* device, CommandEncoderBase* encoder);
|
||||
CommandBufferBase(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
|
||||
static CommandBufferBase* MakeError(DeviceBase* device);
|
||||
|
||||
const CommandBufferResourceUsage& GetResourceUsages() const;
|
||||
|
|
|
@ -444,32 +444,37 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
MaybeError ValidateRenderPassDescriptor(const DeviceBase* device,
|
||||
const RenderPassDescriptor* renderPass,
|
||||
const RenderPassDescriptor* descriptor,
|
||||
uint32_t* width,
|
||||
uint32_t* height,
|
||||
uint32_t* sampleCount) {
|
||||
if (renderPass->colorAttachmentCount > kMaxColorAttachments) {
|
||||
if (descriptor->colorAttachmentCount > kMaxColorAttachments) {
|
||||
return DAWN_VALIDATION_ERROR("Setting color attachments out of bounds");
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < renderPass->colorAttachmentCount; ++i) {
|
||||
DAWN_TRY(ValidateRenderPassColorAttachment(device, renderPass->colorAttachments[i],
|
||||
for (uint32_t i = 0; i < descriptor->colorAttachmentCount; ++i) {
|
||||
DAWN_TRY(ValidateRenderPassColorAttachment(device, descriptor->colorAttachments[i],
|
||||
width, height, sampleCount));
|
||||
}
|
||||
|
||||
if (renderPass->depthStencilAttachment != nullptr) {
|
||||
if (descriptor->depthStencilAttachment != nullptr) {
|
||||
DAWN_TRY(ValidateRenderPassDepthStencilAttachment(
|
||||
device, renderPass->depthStencilAttachment, width, height, sampleCount));
|
||||
device, descriptor->depthStencilAttachment, width, height, sampleCount));
|
||||
}
|
||||
|
||||
if (renderPass->colorAttachmentCount == 0 &&
|
||||
renderPass->depthStencilAttachment == nullptr) {
|
||||
if (descriptor->colorAttachmentCount == 0 &&
|
||||
descriptor->depthStencilAttachment == nullptr) {
|
||||
return DAWN_VALIDATION_ERROR("Cannot use render pass with no attachments.");
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
MaybeError ValidateComputePassDescriptor(const DeviceBase* device,
|
||||
const ComputePassDescriptor* descriptor) {
|
||||
return {};
|
||||
}
|
||||
|
||||
enum class PassType {
|
||||
Render,
|
||||
Compute,
|
||||
|
@ -618,7 +623,7 @@ namespace dawn_native {
|
|||
Finished
|
||||
};
|
||||
|
||||
CommandEncoderBase::CommandEncoderBase(DeviceBase* device)
|
||||
CommandEncoderBase::CommandEncoderBase(DeviceBase* device, const CommandEncoderDescriptor*)
|
||||
: ObjectBase(device), mEncodingState(EncodingState::TopLevel) {
|
||||
}
|
||||
|
||||
|
@ -650,19 +655,25 @@ namespace dawn_native {
|
|||
|
||||
// Implementation of the API's command recording methods
|
||||
|
||||
ComputePassEncoderBase* CommandEncoderBase::BeginComputePass() {
|
||||
ComputePassEncoderBase* CommandEncoderBase::BeginComputePass(
|
||||
const ComputePassDescriptor* descriptor) {
|
||||
DeviceBase* device = GetDevice();
|
||||
if (ConsumedError(ValidateCanRecordTopLevelCommands())) {
|
||||
return ComputePassEncoderBase::MakeError(device, this);
|
||||
}
|
||||
|
||||
if (ConsumedError(ValidateComputePassDescriptor(device, descriptor))) {
|
||||
return ComputePassEncoderBase::MakeError(device, this);
|
||||
}
|
||||
|
||||
mAllocator.Allocate<BeginComputePassCmd>(Command::BeginComputePass);
|
||||
|
||||
mEncodingState = EncodingState::ComputePass;
|
||||
return new ComputePassEncoderBase(device, this, &mAllocator);
|
||||
}
|
||||
|
||||
RenderPassEncoderBase* CommandEncoderBase::BeginRenderPass(const RenderPassDescriptor* info) {
|
||||
RenderPassEncoderBase* CommandEncoderBase::BeginRenderPass(
|
||||
const RenderPassDescriptor* descriptor) {
|
||||
DeviceBase* device = GetDevice();
|
||||
|
||||
if (ConsumedError(ValidateCanRecordTopLevelCommands())) {
|
||||
|
@ -673,7 +684,7 @@ namespace dawn_native {
|
|||
uint32_t height = 0;
|
||||
uint32_t sampleCount = 0;
|
||||
if (ConsumedError(
|
||||
ValidateRenderPassDescriptor(device, info, &width, &height, &sampleCount))) {
|
||||
ValidateRenderPassDescriptor(device, descriptor, &width, &height, &sampleCount))) {
|
||||
return RenderPassEncoderBase::MakeError(device, this);
|
||||
}
|
||||
|
||||
|
@ -683,28 +694,33 @@ namespace dawn_native {
|
|||
|
||||
BeginRenderPassCmd* cmd = mAllocator.Allocate<BeginRenderPassCmd>(Command::BeginRenderPass);
|
||||
|
||||
for (uint32_t i = 0; i < info->colorAttachmentCount; ++i) {
|
||||
if (info->colorAttachments[i] != nullptr) {
|
||||
for (uint32_t i = 0; i < descriptor->colorAttachmentCount; ++i) {
|
||||
if (descriptor->colorAttachments[i] != nullptr) {
|
||||
cmd->colorAttachmentsSet.set(i);
|
||||
cmd->colorAttachments[i].view = info->colorAttachments[i]->attachment;
|
||||
cmd->colorAttachments[i].resolveTarget = info->colorAttachments[i]->resolveTarget;
|
||||
cmd->colorAttachments[i].loadOp = info->colorAttachments[i]->loadOp;
|
||||
cmd->colorAttachments[i].storeOp = info->colorAttachments[i]->storeOp;
|
||||
cmd->colorAttachments[i].clearColor = info->colorAttachments[i]->clearColor;
|
||||
cmd->colorAttachments[i].view = descriptor->colorAttachments[i]->attachment;
|
||||
cmd->colorAttachments[i].resolveTarget =
|
||||
descriptor->colorAttachments[i]->resolveTarget;
|
||||
cmd->colorAttachments[i].loadOp = descriptor->colorAttachments[i]->loadOp;
|
||||
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) {
|
||||
cmd->hasDepthStencilAttachment = true;
|
||||
cmd->depthStencilAttachment.view = info->depthStencilAttachment->attachment;
|
||||
cmd->depthStencilAttachment.clearDepth = info->depthStencilAttachment->clearDepth;
|
||||
cmd->depthStencilAttachment.clearStencil = info->depthStencilAttachment->clearStencil;
|
||||
cmd->depthStencilAttachment.depthLoadOp = info->depthStencilAttachment->depthLoadOp;
|
||||
cmd->depthStencilAttachment.depthStoreOp = info->depthStencilAttachment->depthStoreOp;
|
||||
cmd->depthStencilAttachment.stencilLoadOp = info->depthStencilAttachment->stencilLoadOp;
|
||||
cmd->depthStencilAttachment.view = descriptor->depthStencilAttachment->attachment;
|
||||
cmd->depthStencilAttachment.clearDepth = descriptor->depthStencilAttachment->clearDepth;
|
||||
cmd->depthStencilAttachment.clearStencil =
|
||||
descriptor->depthStencilAttachment->clearStencil;
|
||||
cmd->depthStencilAttachment.depthLoadOp =
|
||||
descriptor->depthStencilAttachment->depthLoadOp;
|
||||
cmd->depthStencilAttachment.depthStoreOp =
|
||||
descriptor->depthStencilAttachment->depthStoreOp;
|
||||
cmd->depthStencilAttachment.stencilLoadOp =
|
||||
descriptor->depthStencilAttachment->stencilLoadOp;
|
||||
cmd->depthStencilAttachment.stencilStoreOp =
|
||||
info->depthStencilAttachment->stencilStoreOp;
|
||||
descriptor->depthStencilAttachment->stencilStoreOp;
|
||||
}
|
||||
|
||||
cmd->width = width;
|
||||
|
@ -842,8 +858,8 @@ namespace dawn_native {
|
|||
copy->copySize = *copySize;
|
||||
}
|
||||
|
||||
CommandBufferBase* CommandEncoderBase::Finish() {
|
||||
if (GetDevice()->ConsumedError(ValidateFinish())) {
|
||||
CommandBufferBase* CommandEncoderBase::Finish(const CommandBufferDescriptor* descriptor) {
|
||||
if (GetDevice()->ConsumedError(ValidateFinish(descriptor))) {
|
||||
// Even if finish validation fails, it is now invalid to call any encoding commands on
|
||||
// this object, so we set its state to finished.
|
||||
mEncodingState = EncodingState::Finished;
|
||||
|
@ -854,7 +870,7 @@ namespace dawn_native {
|
|||
mEncodingState = EncodingState::Finished;
|
||||
|
||||
MoveToIterator();
|
||||
return GetDevice()->CreateCommandBuffer(this);
|
||||
return GetDevice()->CreateCommandBuffer(this, descriptor);
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
MaybeError CommandEncoderBase::ValidateFinish() {
|
||||
MaybeError CommandEncoderBase::ValidateFinish(const CommandBufferDescriptor*) {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
|
||||
if (mGotError) {
|
||||
|
|
|
@ -30,15 +30,15 @@ namespace dawn_native {
|
|||
|
||||
class CommandEncoderBase : public ObjectBase {
|
||||
public:
|
||||
CommandEncoderBase(DeviceBase* device);
|
||||
CommandEncoderBase(DeviceBase* device, const CommandEncoderDescriptor* descriptor);
|
||||
~CommandEncoderBase();
|
||||
|
||||
CommandIterator AcquireCommands();
|
||||
CommandBufferResourceUsage AcquireResourceUsages();
|
||||
|
||||
// Dawn API
|
||||
ComputePassEncoderBase* BeginComputePass();
|
||||
RenderPassEncoderBase* BeginRenderPass(const RenderPassDescriptor* info);
|
||||
ComputePassEncoderBase* BeginComputePass(const ComputePassDescriptor* descriptor);
|
||||
RenderPassEncoderBase* BeginRenderPass(const RenderPassDescriptor* descriptor);
|
||||
void CopyBufferToBuffer(BufferBase* source,
|
||||
uint64_t sourceOffset,
|
||||
BufferBase* destination,
|
||||
|
@ -53,7 +53,7 @@ namespace dawn_native {
|
|||
void CopyTextureToTexture(const TextureCopyView* source,
|
||||
const TextureCopyView* destination,
|
||||
const Extent3D* copySize);
|
||||
CommandBufferBase* Finish();
|
||||
CommandBufferBase* Finish(const CommandBufferDescriptor* descriptor);
|
||||
|
||||
// Functions to interact with the encoders
|
||||
void HandleError(const char* message);
|
||||
|
@ -69,7 +69,7 @@ namespace dawn_native {
|
|||
void PassEnded();
|
||||
|
||||
private:
|
||||
MaybeError ValidateFinish();
|
||||
MaybeError ValidateFinish(const CommandBufferDescriptor* descriptor);
|
||||
MaybeError ValidateComputePass();
|
||||
MaybeError ValidateRenderPass(BeginRenderPassCmd* renderPass);
|
||||
MaybeError ValidateCanRecordTopLevelCommands() const;
|
||||
|
|
|
@ -307,8 +307,9 @@ namespace dawn_native {
|
|||
// The callback is deferred so it matches the async behavior of WebGPU.
|
||||
mDeferredCreateBufferMappedAsyncResults.push_back(deferred_info);
|
||||
}
|
||||
CommandEncoderBase* DeviceBase::CreateCommandEncoder() {
|
||||
return new CommandEncoderBase(this);
|
||||
CommandEncoderBase* DeviceBase::CreateCommandEncoder(
|
||||
const CommandEncoderDescriptor* descriptor) {
|
||||
return new CommandEncoderBase(this, descriptor);
|
||||
}
|
||||
ComputePipelineBase* DeviceBase::CreateComputePipeline(
|
||||
const ComputePipelineDescriptor* descriptor) {
|
||||
|
|
|
@ -56,7 +56,9 @@ namespace dawn_native {
|
|||
|
||||
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 GetLastSubmittedCommandSerial() const = 0;
|
||||
|
@ -108,7 +110,7 @@ namespace dawn_native {
|
|||
void CreateBufferMappedAsync(const BufferDescriptor* descriptor,
|
||||
dawn::BufferCreateMappedCallback callback,
|
||||
void* userdata);
|
||||
CommandEncoderBase* CreateCommandEncoder();
|
||||
CommandEncoderBase* CreateCommandEncoder(const CommandEncoderDescriptor* descriptor);
|
||||
ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
|
||||
PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor);
|
||||
QueueBase* CreateQueue();
|
||||
|
|
|
@ -401,8 +401,9 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder)
|
||||
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) {
|
||||
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor)
|
||||
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
|
||||
}
|
||||
|
||||
CommandBuffer::~CommandBuffer() {
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
class CommandBuffer : public CommandBufferBase {
|
||||
public:
|
||||
CommandBuffer(Device* device, CommandEncoderBase* encoder);
|
||||
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
|
||||
~CommandBuffer();
|
||||
|
||||
void RecordCommands(ComPtr<ID3D12GraphicsCommandList> commandList, uint32_t indexInSubmit);
|
||||
|
|
|
@ -262,8 +262,9 @@ namespace dawn_native { namespace d3d12 {
|
|||
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
||||
return new Buffer(this, descriptor);
|
||||
}
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder) {
|
||||
return new CommandBuffer(this, encoder);
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) {
|
||||
return new CommandBuffer(encoder, descriptor);
|
||||
}
|
||||
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
|
||||
const ComputePipelineDescriptor* descriptor) {
|
||||
|
|
|
@ -42,7 +42,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
MaybeError Initialize();
|
||||
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder) override;
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) override;
|
||||
|
||||
Serial GetCompletedCommandSerial() const final override;
|
||||
Serial GetLastSubmittedCommandSerial() const final override;
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
class CommandBuffer : public CommandBufferBase {
|
||||
public:
|
||||
CommandBuffer(Device* device, CommandEncoderBase* encoder);
|
||||
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
|
||||
~CommandBuffer();
|
||||
|
||||
void FillCommands(id<MTLCommandBuffer> commandBuffer);
|
||||
|
|
|
@ -399,8 +399,9 @@ namespace dawn_native { namespace metal {
|
|||
}
|
||||
} // anonymous namespace
|
||||
|
||||
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder)
|
||||
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) {
|
||||
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor)
|
||||
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
|
||||
}
|
||||
|
||||
CommandBuffer::~CommandBuffer() {
|
||||
|
|
|
@ -37,7 +37,8 @@ namespace dawn_native { namespace metal {
|
|||
Device(AdapterBase* adapter, id<MTLDevice> mtlDevice, const DeviceDescriptor* descriptor);
|
||||
~Device();
|
||||
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder) override;
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) override;
|
||||
|
||||
Serial GetCompletedCommandSerial() const final override;
|
||||
Serial GetLastSubmittedCommandSerial() const final override;
|
||||
|
|
|
@ -95,8 +95,9 @@ namespace dawn_native { namespace metal {
|
|||
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
||||
return new Buffer(this, descriptor);
|
||||
}
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder) {
|
||||
return new CommandBuffer(this, encoder);
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) {
|
||||
return new CommandBuffer(encoder, descriptor);
|
||||
}
|
||||
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
|
||||
const ComputePipelineDescriptor* descriptor) {
|
||||
|
|
|
@ -97,8 +97,9 @@ namespace dawn_native { namespace null {
|
|||
DAWN_TRY(IncrementMemoryUsage(descriptor->size));
|
||||
return new Buffer(this, descriptor);
|
||||
}
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder) {
|
||||
return new CommandBuffer(this, encoder);
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) {
|
||||
return new CommandBuffer(encoder, descriptor);
|
||||
}
|
||||
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
|
||||
const ComputePipelineDescriptor* descriptor) {
|
||||
|
@ -291,8 +292,9 @@ namespace dawn_native { namespace null {
|
|||
|
||||
// CommandBuffer
|
||||
|
||||
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder)
|
||||
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) {
|
||||
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor)
|
||||
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
|
||||
}
|
||||
|
||||
CommandBuffer::~CommandBuffer() {
|
||||
|
|
|
@ -85,7 +85,8 @@ namespace dawn_native { namespace null {
|
|||
Device(Adapter* adapter, const DeviceDescriptor* descriptor);
|
||||
~Device();
|
||||
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder) override;
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) override;
|
||||
|
||||
Serial GetCompletedCommandSerial() const final override;
|
||||
Serial GetLastSubmittedCommandSerial() const final override;
|
||||
|
@ -164,7 +165,7 @@ namespace dawn_native { namespace null {
|
|||
|
||||
class CommandBuffer : public CommandBufferBase {
|
||||
public:
|
||||
CommandBuffer(Device* device, CommandEncoderBase* encoder);
|
||||
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
|
||||
~CommandBuffer();
|
||||
|
||||
private:
|
||||
|
|
|
@ -326,8 +326,9 @@ namespace dawn_native { namespace opengl {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder)
|
||||
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) {
|
||||
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor)
|
||||
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
|
||||
}
|
||||
|
||||
CommandBuffer::~CommandBuffer() {
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native { namespace opengl {
|
|||
|
||||
class CommandBuffer : public CommandBufferBase {
|
||||
public:
|
||||
CommandBuffer(Device* device, CommandEncoderBase* encoder);
|
||||
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
|
||||
~CommandBuffer();
|
||||
|
||||
void Execute();
|
||||
|
|
|
@ -65,8 +65,9 @@ namespace dawn_native { namespace opengl {
|
|||
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
||||
return new Buffer(this, descriptor);
|
||||
}
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder) {
|
||||
return new CommandBuffer(this, encoder);
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) {
|
||||
return new CommandBuffer(encoder, descriptor);
|
||||
}
|
||||
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
|
||||
const ComputePipelineDescriptor* descriptor) {
|
||||
|
|
|
@ -44,7 +44,8 @@ namespace dawn_native { namespace opengl {
|
|||
void SubmitFenceSync();
|
||||
|
||||
// Dawn API
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder) override;
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) override;
|
||||
|
||||
Serial GetCompletedCommandSerial() const final override;
|
||||
Serial GetLastSubmittedCommandSerial() const final override;
|
||||
|
|
|
@ -327,8 +327,9 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
} // anonymous namespace
|
||||
|
||||
CommandBuffer::CommandBuffer(Device* device, CommandEncoderBase* encoder)
|
||||
: CommandBufferBase(device, encoder), mCommands(encoder->AcquireCommands()) {
|
||||
CommandBuffer::CommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor)
|
||||
: CommandBufferBase(encoder, descriptor), mCommands(encoder->AcquireCommands()) {
|
||||
}
|
||||
|
||||
CommandBuffer::~CommandBuffer() {
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
class CommandBuffer : public CommandBufferBase {
|
||||
public:
|
||||
CommandBuffer(Device* device, CommandEncoderBase* encoder);
|
||||
CommandBuffer(CommandEncoderBase* encoder, const CommandBufferDescriptor* descriptor);
|
||||
~CommandBuffer();
|
||||
|
||||
void RecordCommands(VkCommandBuffer commands);
|
||||
|
|
|
@ -148,8 +148,9 @@ namespace dawn_native { namespace vulkan {
|
|||
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
||||
return new Buffer(this, descriptor);
|
||||
}
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder) {
|
||||
return new CommandBuffer(this, encoder);
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) {
|
||||
return new CommandBuffer(encoder, descriptor);
|
||||
}
|
||||
ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
|
||||
const ComputePipelineDescriptor* descriptor) {
|
||||
|
|
|
@ -64,7 +64,8 @@ namespace dawn_native { namespace vulkan {
|
|||
void AddWaitSemaphore(VkSemaphore semaphore);
|
||||
|
||||
// Dawn API
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder) override;
|
||||
CommandBufferBase* CreateCommandBuffer(CommandEncoderBase* encoder,
|
||||
const CommandBufferDescriptor* descriptor) override;
|
||||
|
||||
Serial GetCompletedCommandSerial() const final override;
|
||||
Serial GetLastSubmittedCommandSerial() const final override;
|
||||
|
|
|
@ -30,15 +30,15 @@ class WireArgumentTests : public WireTest {
|
|||
|
||||
// Test that the wire is able to send numerical values
|
||||
TEST_F(WireArgumentTests, ValueArgument) {
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
|
||||
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder, nullptr);
|
||||
dawnComputePassEncoderDispatch(pass, 1, 2, 3);
|
||||
|
||||
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();
|
||||
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);
|
||||
|
||||
|
@ -68,17 +68,17 @@ TEST_F(WireArgumentTests, ValueArrayArgument) {
|
|||
EXPECT_CALL(api, DeviceCreateBindGroup(apiDevice, _)).WillOnce(Return(apiBindGroup));
|
||||
|
||||
// Use the bindgroup in SetBindGroup that takes an array of value offsets.
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
|
||||
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder, nullptr);
|
||||
|
||||
std::array<uint64_t, 4> testOffsets = {0, 42, 0xDEAD'BEEF'DEAD'BEEFu, 0xFFFF'FFFF'FFFF'FFFFu};
|
||||
dawnComputePassEncoderSetBindGroup(pass, 0, bindGroup, testOffsets.size(), testOffsets.data());
|
||||
|
||||
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();
|
||||
EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder)).WillOnce(Return(apiPass));
|
||||
EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder, nullptr)).WillOnce(Return(apiPass));
|
||||
|
||||
EXPECT_CALL(api, ComputePassEncoderSetBindGroup(
|
||||
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_F(WireArgumentTests, ObjectAsValueArgument) {
|
||||
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device, nullptr);
|
||||
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder));
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder));
|
||||
|
||||
DawnBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
|
@ -232,16 +232,16 @@ TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
|
|||
// CreateCommandEncoder might be swapped since they are equivalent in term of matchers
|
||||
Sequence s;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device);
|
||||
cmdBufs[i] = dawnCommandEncoderFinish(cmdBufEncoder);
|
||||
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device, nullptr);
|
||||
cmdBufs[i] = dawnCommandEncoderFinish(cmdBufEncoder, nullptr);
|
||||
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
|
||||
.InSequence(s)
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
|
||||
apiCmdBufs[i] = api.GetNewCommandBuffer();
|
||||
EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder))
|
||||
EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder, nullptr))
|
||||
.WillOnce(Return(apiCmdBufs[i]));
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@ class WireBasicTests : public WireTest {
|
|||
|
||||
// One call gets forwarded correctly.
|
||||
TEST_F(WireBasicTests, CallForwarded) {
|
||||
dawnDeviceCreateCommandEncoder(device);
|
||||
dawnDeviceCreateCommandEncoder(device, nullptr);
|
||||
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
|
||||
FlushClient();
|
||||
|
@ -37,28 +37,28 @@ TEST_F(WireBasicTests, CallForwarded) {
|
|||
|
||||
// Test that calling methods on a new object works as expected.
|
||||
TEST_F(WireBasicTests, CreateThenCall) {
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
dawnCommandEncoderFinish(encoder);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
|
||||
dawnCommandEncoderFinish(encoder, nullptr);
|
||||
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
|
||||
DawnCommandBuffer apiCmdBuf = api.GetNewCommandBuffer();
|
||||
EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder)).WillOnce(Return(apiCmdBuf));
|
||||
EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder, nullptr)).WillOnce(Return(apiCmdBuf));
|
||||
|
||||
FlushClient();
|
||||
}
|
||||
|
||||
// Test that client reference/release do not call the backend API.
|
||||
TEST_F(WireBasicTests, RefCountKeptInClient) {
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
|
||||
|
||||
dawnCommandEncoderReference(encoder);
|
||||
dawnCommandEncoderRelease(encoder);
|
||||
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
|
||||
FlushClient();
|
||||
|
@ -66,12 +66,12 @@ TEST_F(WireBasicTests, RefCountKeptInClient) {
|
|||
|
||||
// Test that client reference/release do not call the backend API.
|
||||
TEST_F(WireBasicTests, ReleaseCalledOnRefCount0) {
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
|
||||
|
||||
dawnCommandEncoderRelease(encoder);
|
||||
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
|
||||
EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
|
||||
|
|
Loading…
Reference in New Issue