From 2ce4b905b259caf10dd13f77710484a3dfe392b0 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 29 Mar 2021 14:02:05 +0000 Subject: [PATCH] dawn_native: Prefix all API methods with API This means that calling wgpu::Object::DoStuff will translate to a call to dawn_native::ObjectBase::APIDoStuff. This will clarify the difference between reentrant calls and internal calls in dawn_native. Avoiding issues in the future. This CL only changes the code generator to prefix with "API", performs renames needed to make the code compile, and adds TODOs for things that should be fixed in follow-up CLs. Bug: dawn:723 Change-Id: Ie24471fa093adc4179d33d13323429847d076ecb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/45921 Commit-Queue: Corentin Wallez Auto-Submit: Corentin Wallez Reviewed-by: Austin Eng Reviewed-by: Stephen White --- generator/templates/dawn_native/ProcTable.cpp | 2 +- src/common/RefCounted.cpp | 8 +++ src/common/RefCounted.h | 4 +- src/dawn_native/Buffer.cpp | 29 ++++---- src/dawn_native/Buffer.h | 18 ++--- src/dawn_native/CommandEncoder.cpp | 71 ++++++++++--------- src/dawn_native/CommandEncoder.h | 56 +++++++-------- src/dawn_native/ComputePassEncoder.cpp | 11 +-- src/dawn_native/ComputePassEncoder.h | 10 +-- .../CopyTextureForBrowserHelper.cpp | 55 +++++++++----- src/dawn_native/DawnNative.cpp | 2 +- src/dawn_native/Device.cpp | 71 ++++++++++--------- src/dawn_native/Device.h | 60 ++++++++-------- src/dawn_native/Fence.cpp | 13 ++-- src/dawn_native/Fence.h | 6 +- src/dawn_native/Instance.cpp | 2 +- src/dawn_native/Instance.h | 2 +- src/dawn_native/Pipeline.cpp | 2 +- src/dawn_native/Pipeline.h | 2 +- src/dawn_native/ProgrammablePassEncoder.cpp | 14 ++-- src/dawn_native/ProgrammablePassEncoder.h | 14 ++-- src/dawn_native/QueryHelper.cpp | 24 ++++--- src/dawn_native/QuerySet.cpp | 2 +- src/dawn_native/QuerySet.h | 2 +- src/dawn_native/Queue.cpp | 38 +++++----- src/dawn_native/Queue.h | 35 ++++----- src/dawn_native/RenderBundleEncoder.cpp | 2 +- src/dawn_native/RenderBundleEncoder.h | 2 +- src/dawn_native/RenderEncoderBase.cpp | 50 ++++++------- src/dawn_native/RenderEncoderBase.h | 40 ++++++----- src/dawn_native/RenderPassEncoder.cpp | 35 ++++----- src/dawn_native/RenderPassEncoder.h | 28 ++++---- src/dawn_native/SwapChain.cpp | 38 +++++----- src/dawn_native/SwapChain.h | 36 +++++----- src/dawn_native/Texture.cpp | 4 +- src/dawn_native/Texture.h | 4 +- src/dawn_native/d3d12/CommandBufferD3D12.cpp | 3 +- src/dawn_native/d3d12/QueueD3D12.cpp | 3 +- src/dawn_native/metal/QueueMTL.mm | 5 +- src/dawn_native/metal/SwapChainMTL.mm | 8 ++- src/dawn_native/null/DeviceNull.cpp | 10 +-- src/dawn_native/opengl/TextureGL.cpp | 6 +- src/dawn_native/vulkan/CommandBufferVk.cpp | 4 +- src/dawn_native/vulkan/QueueVk.cpp | 3 +- src/dawn_native/vulkan/SwapChainVk.cpp | 14 ++-- .../white_box/D3D12DescriptorHeapTests.cpp | 6 +- 46 files changed, 464 insertions(+), 390 deletions(-) diff --git a/generator/templates/dawn_native/ProcTable.cpp b/generator/templates/dawn_native/ProcTable.cpp index defae2df3f..3b3bd74f9c 100644 --- a/generator/templates/dawn_native/ProcTable.cpp +++ b/generator/templates/dawn_native/ProcTable.cpp @@ -64,7 +64,7 @@ namespace dawn_native { {% if method.return_type.name.canonical_case() != "void" %} auto result = {%- endif %} - self->{{method.name.CamelCase()}}( + self->API{{method.name.CamelCase()}}( {%- for arg in method.arguments -%} {%- if not loop.first %}, {% endif -%} {{as_varName(arg.name)}}_ diff --git a/src/common/RefCounted.cpp b/src/common/RefCounted.cpp index af38fc668e..f559638649 100644 --- a/src/common/RefCounted.cpp +++ b/src/common/RefCounted.cpp @@ -73,6 +73,14 @@ void RefCounted::Release() { } } +void RefCounted::APIReference() { + Reference(); +} + +void RefCounted::APIRelease() { + Release(); +} + void RefCounted::DeleteThis() { delete this; } diff --git a/src/common/RefCounted.h b/src/common/RefCounted.h index 9328a4c5c4..6b266e3b9e 100644 --- a/src/common/RefCounted.h +++ b/src/common/RefCounted.h @@ -27,10 +27,12 @@ class RefCounted { uint64_t GetRefCountForTesting() const; uint64_t GetRefCountPayload() const; - // Dawn API void Reference(); void Release(); + void APIReference(); + void APIRelease(); + protected: virtual ~RefCounted() = default; // A Derived class may override this if they require a custom deleter. diff --git a/src/dawn_native/Buffer.cpp b/src/dawn_native/Buffer.cpp index 7c8dea9c05..64ee20f654 100644 --- a/src/dawn_native/Buffer.cpp +++ b/src/dawn_native/Buffer.cpp @@ -186,11 +186,13 @@ namespace dawn_native { DeviceBase* device = GetDevice(); if (device->IsToggleEnabled(Toggle::LazyClearResourceOnFirstUse)) { - memset(GetMappedRange(0, mSize), uint8_t(0u), mSize); + // TODO(dawn:723): propagate any errors from GetMappedRange. + memset(APIGetMappedRange(0, mSize), uint8_t(0u), mSize); SetIsDataInitialized(); device->IncrementLazyClearCountForTesting(); } else if (device->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting)) { - memset(GetMappedRange(0, mSize), uint8_t(1u), mSize); + // TODO(dawn:723): propagate any errors from GetMappedRange. + memset(APIGetMappedRange(0, mSize), uint8_t(1u), mSize); } return {}; @@ -252,11 +254,11 @@ namespace dawn_native { } } - void BufferBase::MapAsync(wgpu::MapMode mode, - size_t offset, - size_t size, - WGPUBufferMapCallback callback, - void* userdata) { + void BufferBase::APIMapAsync(wgpu::MapMode mode, + size_t offset, + size_t size, + WGPUBufferMapCallback callback, + void* userdata) { // Handle the defaulting of size required by WebGPU, even if in webgpu_cpp.h it is not // possible to default the function argument (because there is the callback later in the // argument list) @@ -287,15 +289,16 @@ namespace dawn_native { } std::unique_ptr request = std::make_unique(this, mLastMapID); - GetDevice()->GetQueue()->TrackTask(std::move(request), - GetDevice()->GetPendingCommandSerial()); + // TODO(dawn:723): do not get a new reference to the Queue. + GetDevice()->APIGetQueue()->TrackTask(std::move(request), + GetDevice()->GetPendingCommandSerial()); } - void* BufferBase::GetMappedRange(size_t offset, size_t size) { + void* BufferBase::APIGetMappedRange(size_t offset, size_t size) { return GetMappedRangeInternal(true, offset, size); } - const void* BufferBase::GetConstMappedRange(size_t offset, size_t size) { + const void* BufferBase::APIGetConstMappedRange(size_t offset, size_t size) { return GetMappedRangeInternal(false, offset, size); } @@ -314,7 +317,7 @@ namespace dawn_native { return start == nullptr ? nullptr : start + offset; } - void BufferBase::Destroy() { + void BufferBase::APIDestroy() { if (IsError()) { // It is an error to call Destroy() on an ErrorBuffer, but we still need to reclaim the // fake mapped staging data. @@ -354,7 +357,7 @@ namespace dawn_native { return {}; } - void BufferBase::Unmap() { + void BufferBase::APIUnmap() { UnmapInternal(WGPUBufferMapAsyncStatus_UnmappedBeforeCallback); } diff --git a/src/dawn_native/Buffer.h b/src/dawn_native/Buffer.h index 936ae3c297..30d77086cb 100644 --- a/src/dawn_native/Buffer.h +++ b/src/dawn_native/Buffer.h @@ -62,15 +62,15 @@ namespace dawn_native { void SetIsDataInitialized(); // Dawn API - void MapAsync(wgpu::MapMode mode, - size_t offset, - size_t size, - WGPUBufferMapCallback callback, - void* userdata); - void* GetMappedRange(size_t offset, size_t size); - const void* GetConstMappedRange(size_t offset, size_t size); - void Unmap(); - void Destroy(); + void APIMapAsync(wgpu::MapMode mode, + size_t offset, + size_t size, + WGPUBufferMapCallback callback, + void* userdata); + void* APIGetMappedRange(size_t offset, size_t size); + const void* APIGetConstMappedRange(size_t offset, size_t size); + void APIUnmap(); + void APIDestroy(); protected: BufferBase(DeviceBase* device, diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp index 00e62552a3..699d49714f 100644 --- a/src/dawn_native/CommandEncoder.cpp +++ b/src/dawn_native/CommandEncoder.cpp @@ -416,10 +416,13 @@ namespace dawn_native { BufferDescriptor availabilityDesc = {}; availabilityDesc.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst; availabilityDesc.size = querySet->GetQueryCount() * sizeof(uint32_t); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. Ref availabilityBuffer = - AcquireRef(device->CreateBuffer(&availabilityDesc)); - device->GetQueue()->WriteBuffer(availabilityBuffer.Get(), 0, availability.data(), - availability.size() * sizeof(uint32_t)); + AcquireRef(device->APICreateBuffer(&availabilityDesc)); + // TODO(dawn:723): do not get a new reference to the Queue. + // TODO(dawn:723): propagate any errors from WriteBuffer. + device->APIGetQueue()->APIWriteBuffer(availabilityBuffer.Get(), 0, availability.data(), + availability.size() * sizeof(uint32_t)); // Timestamp params uniform buffer TimestampParams params = {queryCount, static_cast(destinationOffset), @@ -427,8 +430,11 @@ namespace dawn_native { BufferDescriptor parmsDesc = {}; parmsDesc.usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst; parmsDesc.size = sizeof(params); - Ref paramsBuffer = AcquireRef(device->CreateBuffer(&parmsDesc)); - device->GetQueue()->WriteBuffer(paramsBuffer.Get(), 0, ¶ms, sizeof(params)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref paramsBuffer = AcquireRef(device->APICreateBuffer(&parmsDesc)); + // TODO(dawn:723): do not get a new reference to the Queue. + // TODO(dawn:723): propagate any errors from WriteBuffer. + device->APIGetQueue()->APIWriteBuffer(paramsBuffer.Get(), 0, ¶ms, sizeof(params)); EncodeConvertTimestampsToNanoseconds(encoder, destination, availabilityBuffer.Get(), paramsBuffer.Get()); @@ -476,7 +482,8 @@ namespace dawn_native { // Implementation of the API's command recording methods - ComputePassEncoder* CommandEncoder::BeginComputePass(const ComputePassDescriptor* descriptor) { + ComputePassEncoder* CommandEncoder::APIBeginComputePass( + const ComputePassDescriptor* descriptor) { DeviceBase* device = GetDevice(); bool success = @@ -498,7 +505,7 @@ namespace dawn_native { return ComputePassEncoder::MakeError(device, this, &mEncodingContext); } - RenderPassEncoder* CommandEncoder::BeginRenderPass(const RenderPassDescriptor* descriptor) { + RenderPassEncoder* CommandEncoder::APIBeginRenderPass(const RenderPassDescriptor* descriptor) { DeviceBase* device = GetDevice(); PassResourceUsageTracker usageTracker(PassType::Render); @@ -581,11 +588,11 @@ namespace dawn_native { return RenderPassEncoder::MakeError(device, this, &mEncodingContext); } - void CommandEncoder::CopyBufferToBuffer(BufferBase* source, - uint64_t sourceOffset, - BufferBase* destination, - uint64_t destinationOffset, - uint64_t size) { + void CommandEncoder::APICopyBufferToBuffer(BufferBase* source, + uint64_t sourceOffset, + BufferBase* destination, + uint64_t destinationOffset, + uint64_t size) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (GetDevice()->IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(source)); @@ -622,9 +629,9 @@ namespace dawn_native { }); } - void CommandEncoder::CopyBufferToTexture(const ImageCopyBuffer* source, - const ImageCopyTexture* destination, - const Extent3D* copySize) { + void CommandEncoder::APICopyBufferToTexture(const ImageCopyBuffer* source, + const ImageCopyTexture* destination, + const Extent3D* copySize) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { Extent3D fixedCopySize = *copySize; DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize)); @@ -681,9 +688,9 @@ namespace dawn_native { }); } - void CommandEncoder::CopyTextureToBuffer(const ImageCopyTexture* source, - const ImageCopyBuffer* destination, - const Extent3D* copySize) { + void CommandEncoder::APICopyTextureToBuffer(const ImageCopyTexture* source, + const ImageCopyBuffer* destination, + const Extent3D* copySize) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { Extent3D fixedCopySize = *copySize; DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize)); @@ -739,9 +746,9 @@ namespace dawn_native { }); } - void CommandEncoder::CopyTextureToTexture(const ImageCopyTexture* source, - const ImageCopyTexture* destination, - const Extent3D* copySize) { + void CommandEncoder::APICopyTextureToTexture(const ImageCopyTexture* source, + const ImageCopyTexture* destination, + const Extent3D* copySize) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { Extent3D fixedCopySize = *copySize; DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize)); @@ -786,13 +793,13 @@ namespace dawn_native { }); } - void CommandEncoder::InjectValidationError(const char* message) { + void CommandEncoder::APIInjectValidationError(const char* message) { if (mEncodingContext.CheckCurrentEncoder(this)) { mEncodingContext.HandleError(InternalErrorType::Validation, message); } } - void CommandEncoder::InsertDebugMarker(const char* groupLabel) { + void CommandEncoder::APIInsertDebugMarker(const char* groupLabel) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { InsertDebugMarkerCmd* cmd = allocator->Allocate(Command::InsertDebugMarker); @@ -805,7 +812,7 @@ namespace dawn_native { }); } - void CommandEncoder::PopDebugGroup() { + void CommandEncoder::APIPopDebugGroup() { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (GetDevice()->IsValidationEnabled()) { if (mDebugGroupStackSize == 0) { @@ -819,7 +826,7 @@ namespace dawn_native { }); } - void CommandEncoder::PushDebugGroup(const char* groupLabel) { + void CommandEncoder::APIPushDebugGroup(const char* groupLabel) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { PushDebugGroupCmd* cmd = allocator->Allocate(Command::PushDebugGroup); @@ -834,11 +841,11 @@ namespace dawn_native { }); } - void CommandEncoder::ResolveQuerySet(QuerySetBase* querySet, - uint32_t firstQuery, - uint32_t queryCount, - BufferBase* destination, - uint64_t destinationOffset) { + void CommandEncoder::APIResolveQuerySet(QuerySetBase* querySet, + uint32_t firstQuery, + uint32_t queryCount, + BufferBase* destination, + uint64_t destinationOffset) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (GetDevice()->IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(querySet)); @@ -872,7 +879,7 @@ namespace dawn_native { }); } - void CommandEncoder::WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) { + void CommandEncoder::APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (GetDevice()->IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(querySet)); @@ -890,7 +897,7 @@ namespace dawn_native { }); } - CommandBufferBase* CommandEncoder::Finish(const CommandBufferDescriptor* descriptor) { + CommandBufferBase* CommandEncoder::APIFinish(const CommandBufferDescriptor* descriptor) { DeviceBase* device = GetDevice(); // Even if mEncodingContext.Finish() validation fails, calling it will mutate the internal // state of the encoding context. The internal state is set to finished, and subsequent diff --git a/src/dawn_native/CommandEncoder.h b/src/dawn_native/CommandEncoder.h index 0abab3aa5d..816651c73b 100644 --- a/src/dawn_native/CommandEncoder.h +++ b/src/dawn_native/CommandEncoder.h @@ -41,37 +41,37 @@ namespace dawn_native { const QueryAvailabilityMap& GetQueryAvailabilityMap() const; // Dawn API - ComputePassEncoder* BeginComputePass(const ComputePassDescriptor* descriptor); - RenderPassEncoder* BeginRenderPass(const RenderPassDescriptor* descriptor); + ComputePassEncoder* APIBeginComputePass(const ComputePassDescriptor* descriptor); + RenderPassEncoder* APIBeginRenderPass(const RenderPassDescriptor* descriptor); - void CopyBufferToBuffer(BufferBase* source, - uint64_t sourceOffset, + void APICopyBufferToBuffer(BufferBase* source, + uint64_t sourceOffset, + BufferBase* destination, + uint64_t destinationOffset, + uint64_t size); + void APICopyBufferToTexture(const ImageCopyBuffer* source, + const ImageCopyTexture* destination, + const Extent3D* copySize); + void APICopyTextureToBuffer(const ImageCopyTexture* source, + const ImageCopyBuffer* destination, + const Extent3D* copySize); + void APICopyTextureToTexture(const ImageCopyTexture* source, + const ImageCopyTexture* destination, + const Extent3D* copySize); + + void APIInjectValidationError(const char* message); + void APIInsertDebugMarker(const char* groupLabel); + void APIPopDebugGroup(); + void APIPushDebugGroup(const char* groupLabel); + + void APIResolveQuerySet(QuerySetBase* querySet, + uint32_t firstQuery, + uint32_t queryCount, BufferBase* destination, - uint64_t destinationOffset, - uint64_t size); - void CopyBufferToTexture(const ImageCopyBuffer* source, - const ImageCopyTexture* destination, - const Extent3D* copySize); - void CopyTextureToBuffer(const ImageCopyTexture* source, - const ImageCopyBuffer* destination, - const Extent3D* copySize); - void CopyTextureToTexture(const ImageCopyTexture* source, - const ImageCopyTexture* destination, - const Extent3D* copySize); + uint64_t destinationOffset); + void APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex); - void InjectValidationError(const char* message); - void InsertDebugMarker(const char* groupLabel); - void PopDebugGroup(); - void PushDebugGroup(const char* groupLabel); - - void ResolveQuerySet(QuerySetBase* querySet, - uint32_t firstQuery, - uint32_t queryCount, - BufferBase* destination, - uint64_t destinationOffset); - void WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex); - - CommandBufferBase* Finish(const CommandBufferDescriptor* descriptor = nullptr); + CommandBufferBase* APIFinish(const CommandBufferDescriptor* descriptor = nullptr); private: MaybeError ValidateFinish(CommandIterator* commands, diff --git a/src/dawn_native/ComputePassEncoder.cpp b/src/dawn_native/ComputePassEncoder.cpp index 057ef3f3d6..04bb8ff56f 100644 --- a/src/dawn_native/ComputePassEncoder.cpp +++ b/src/dawn_native/ComputePassEncoder.cpp @@ -45,7 +45,7 @@ namespace dawn_native { return new ComputePassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError); } - void ComputePassEncoder::EndPass() { + void ComputePassEncoder::APIEndPass() { if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(ValidateProgrammableEncoderEnd()); @@ -59,7 +59,7 @@ namespace dawn_native { } } - void ComputePassEncoder::Dispatch(uint32_t x, uint32_t y, uint32_t z) { + void ComputePassEncoder::APIDispatch(uint32_t x, uint32_t y, uint32_t z) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(mCommandBufferState.ValidateCanDispatch()); @@ -78,7 +78,8 @@ namespace dawn_native { }); } - void ComputePassEncoder::DispatchIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) { + void ComputePassEncoder::APIDispatchIndirect(BufferBase* indirectBuffer, + uint64_t indirectOffset) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer)); @@ -116,7 +117,7 @@ namespace dawn_native { }); } - void ComputePassEncoder::SetPipeline(ComputePipelineBase* pipeline) { + void ComputePassEncoder::APISetPipeline(ComputePipelineBase* pipeline) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(pipeline)); @@ -132,7 +133,7 @@ namespace dawn_native { }); } - void ComputePassEncoder::WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) { + void ComputePassEncoder::APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(querySet)); diff --git a/src/dawn_native/ComputePassEncoder.h b/src/dawn_native/ComputePassEncoder.h index 0f99462f3c..fcff7a9f96 100644 --- a/src/dawn_native/ComputePassEncoder.h +++ b/src/dawn_native/ComputePassEncoder.h @@ -30,13 +30,13 @@ namespace dawn_native { CommandEncoder* commandEncoder, EncodingContext* encodingContext); - void EndPass(); + void APIEndPass(); - void Dispatch(uint32_t x, uint32_t y = 1, uint32_t z = 1); - void DispatchIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset); - void SetPipeline(ComputePipelineBase* pipeline); + void APIDispatch(uint32_t x, uint32_t y = 1, uint32_t z = 1); + void APIDispatchIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset); + void APISetPipeline(ComputePipelineBase* pipeline); - void WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex); + void APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex); protected: ComputePassEncoder(DeviceBase* device, diff --git a/src/dawn_native/CopyTextureForBrowserHelper.cpp b/src/dawn_native/CopyTextureForBrowserHelper.cpp index 78384504da..fea63efbeb 100644 --- a/src/dawn_native/CopyTextureForBrowserHelper.cpp +++ b/src/dawn_native/CopyTextureForBrowserHelper.cpp @@ -137,8 +137,9 @@ namespace dawn_native { wgslDesc.source = sCopyTextureForBrowserVertex; descriptor.nextInChain = reinterpret_cast(&wgslDesc); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. store->copyTextureForBrowserVS = - AcquireRef(device->CreateShaderModule(&descriptor)); + AcquireRef(device->APICreateShaderModule(&descriptor)); } ShaderModuleBase* vertexModule = store->copyTextureForBrowserVS.Get(); @@ -149,8 +150,9 @@ namespace dawn_native { ShaderModuleWGSLDescriptor wgslDesc; wgslDesc.source = sCopyTextureForBrowserFragment; descriptor.nextInChain = reinterpret_cast(&wgslDesc); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. store->copyTextureForBrowserFS = - AcquireRef(device->CreateShaderModule(&descriptor)); + AcquireRef(device->APICreateShaderModule(&descriptor)); } ShaderModuleBase* fragmentModule = store->copyTextureForBrowserFS.Get(); @@ -183,8 +185,9 @@ namespace dawn_native { fragment.targetCount = 1; fragment.targets = ⌖ + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. store->copyTextureForBrowserPipelines.insert( - {dstFormat, AcquireRef(device->CreateRenderPipeline2(&renderPipelineDesc))}); + {dstFormat, AcquireRef(device->APICreateRenderPipeline2(&renderPipelineDesc))}); } return GetCachedPipeline(store, dstFormat); @@ -242,7 +245,8 @@ namespace dawn_native { device, destination->texture->GetFormat().format); // Prepare bind group layout. - Ref layout = AcquireRef(pipeline->GetBindGroupLayout(0)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref layout = AcquireRef(pipeline->APIGetBindGroupLayout(0)); // Prepare bind group descriptor BindGroupEntry bindGroupEntries[3] = {}; @@ -266,21 +270,27 @@ namespace dawn_native { BufferDescriptor uniformDesc = {}; uniformDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform; uniformDesc.size = sizeof(uniformData); - Ref uniformBuffer = AcquireRef(device->CreateBuffer(&uniformDesc)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref uniformBuffer = AcquireRef(device->APICreateBuffer(&uniformDesc)); - device->GetQueue()->WriteBuffer(uniformBuffer.Get(), 0, uniformData, sizeof(uniformData)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + // TODO(dawn:723): propagate any errors from WriteBuffer. + device->APIGetQueue()->APIWriteBuffer(uniformBuffer.Get(), 0, uniformData, + sizeof(uniformData)); // Prepare binding 1 resource: sampler // Use default configuration, filterMode set to Nearest for min and mag. SamplerDescriptor samplerDesc = {}; - Ref sampler = AcquireRef(device->CreateSampler(&samplerDesc)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref sampler = AcquireRef(device->APICreateSampler(&samplerDesc)); // Prepare binding 2 resource: sampled texture TextureViewDescriptor srcTextureViewDesc = {}; srcTextureViewDesc.baseMipLevel = source->mipLevel; srcTextureViewDesc.mipLevelCount = 1; + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. Ref srcTextureView = - AcquireRef(source->texture->CreateView(&srcTextureViewDesc)); + AcquireRef(source->texture->APICreateView(&srcTextureViewDesc)); // Set bind group entries. bindGroupEntries[0].binding = 0; @@ -292,18 +302,21 @@ namespace dawn_native { bindGroupEntries[2].textureView = srcTextureView.Get(); // Create bind group after all binding entries are set. - Ref bindGroup = AcquireRef(device->CreateBindGroup(&bgDesc)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref bindGroup = AcquireRef(device->APICreateBindGroup(&bgDesc)); // Create command encoder. CommandEncoderDescriptor encoderDesc = {}; - Ref encoder = AcquireRef(device->CreateCommandEncoder(&encoderDesc)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref encoder = AcquireRef(device->APICreateCommandEncoder(&encoderDesc)); // Prepare dst texture view as color Attachment. TextureViewDescriptor dstTextureViewDesc; dstTextureViewDesc.baseMipLevel = destination->mipLevel; dstTextureViewDesc.mipLevelCount = 1; + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. Ref dstView = - AcquireRef(destination->texture->CreateView(&dstTextureViewDesc)); + AcquireRef(destination->texture->APICreateView(&dstTextureViewDesc)); // Prepare render pass color attachment descriptor. RenderPassColorAttachmentDescriptor colorAttachmentDesc; @@ -317,22 +330,26 @@ namespace dawn_native { RenderPassDescriptor renderPassDesc; renderPassDesc.colorAttachmentCount = 1; renderPassDesc.colorAttachments = &colorAttachmentDesc; - Ref passEncoder = AcquireRef(encoder->BeginRenderPass(&renderPassDesc)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref passEncoder = + AcquireRef(encoder->APIBeginRenderPass(&renderPassDesc)); // Start pipeline and encode commands to complete // the copy from src texture to dst texture with transformation. - passEncoder->SetPipeline(pipeline); - passEncoder->SetBindGroup(0, bindGroup.Get()); - passEncoder->Draw(3); - passEncoder->EndPass(); + passEncoder->APISetPipeline(pipeline); + passEncoder->APISetBindGroup(0, bindGroup.Get()); + passEncoder->APIDraw(3); + passEncoder->APIEndPass(); // Finsh encoding. - Ref commandBuffer = AcquireRef(encoder->Finish()); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref commandBuffer = AcquireRef(encoder->APIFinish()); CommandBufferBase* submitCommandBuffer = commandBuffer.Get(); // Submit command buffer. - Ref queue = AcquireRef(device->GetQueue()); - queue->Submit(1, &submitCommandBuffer); + // TODO(dawn:723): do not get a new reference to the Queue. + Ref queue = AcquireRef(device->APIGetQueue()); + queue->APISubmit(1, &submitCommandBuffer); return {}; } diff --git a/src/dawn_native/DawnNative.cpp b/src/dawn_native/DawnNative.cpp index c089926a37..849c6c0be6 100644 --- a/src/dawn_native/DawnNative.cpp +++ b/src/dawn_native/DawnNative.cpp @@ -208,7 +208,7 @@ namespace dawn_native { DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device) { dawn_native::DeviceBase* deviceBase = reinterpret_cast(device); - return deviceBase->Tick(); + return deviceBase->APITick(); } // ExternalImageDescriptor diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp index 67020a0dbe..3b8bf166d3 100644 --- a/src/dawn_native/Device.cpp +++ b/src/dawn_native/Device.cpp @@ -176,7 +176,8 @@ namespace dawn_native { // Tick the queue-related tasks since they should be complete. This must be done before // ShutDownImpl() it may relinquish resources that will be freed by backends in the // ShutDownImpl() call. - GetQueue()->Tick(GetCompletedCommandSerial()); + // TODO(dawn:723): do not get a new reference to the Queue. + APIGetQueue()->Tick(GetCompletedCommandSerial()); // Call TickImpl once last time to clean up resources // Ignore errors so that we can continue with destruction IgnoreErrors(TickImpl()); @@ -251,7 +252,7 @@ namespace dawn_native { } } - void DeviceBase::InjectError(wgpu::ErrorType type, const char* message) { + void DeviceBase::APIInjectError(wgpu::ErrorType type, const char* message) { if (ConsumedError(ValidateErrorType(type))) { return; } @@ -278,24 +279,24 @@ namespace dawn_native { HandleError(error->GetType(), ss.str().c_str()); } - void DeviceBase::SetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata) { + void DeviceBase::APISetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata) { mUncapturedErrorCallback = callback; mUncapturedErrorUserdata = userdata; } - void DeviceBase::SetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata) { + void DeviceBase::APISetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata) { mDeviceLostCallback = callback; mDeviceLostUserdata = userdata; } - void DeviceBase::PushErrorScope(wgpu::ErrorFilter filter) { + void DeviceBase::APIPushErrorScope(wgpu::ErrorFilter filter) { if (ConsumedError(ValidateErrorFilter(filter))) { return; } mErrorScopeStack->Push(filter); } - bool DeviceBase::PopErrorScope(wgpu::ErrorCallback callback, void* userdata) { + bool DeviceBase::APIPopErrorScope(wgpu::ErrorCallback callback, void* userdata) { if (mErrorScopeStack->Empty()) { return false; } @@ -331,7 +332,7 @@ namespace dawn_native { return DAWN_VALIDATION_ERROR("Device is lost"); } - void DeviceBase::LoseForTesting() { + void DeviceBase::APILoseForTesting() { if (mState != State::Alive) { return; } @@ -664,7 +665,7 @@ namespace dawn_native { // Object creation API methods - BindGroupBase* DeviceBase::CreateBindGroup(const BindGroupDescriptor* descriptor) { + BindGroupBase* DeviceBase::APICreateBindGroup(const BindGroupDescriptor* descriptor) { BindGroupBase* result = nullptr; if (ConsumedError(CreateBindGroupInternal(&result, descriptor))) { @@ -673,7 +674,7 @@ namespace dawn_native { return result; } - BindGroupLayoutBase* DeviceBase::CreateBindGroupLayout( + BindGroupLayoutBase* DeviceBase::APICreateBindGroupLayout( const BindGroupLayoutDescriptor* descriptor) { BindGroupLayoutBase* result = nullptr; @@ -683,7 +684,7 @@ namespace dawn_native { return result; } - BufferBase* DeviceBase::CreateBuffer(const BufferDescriptor* descriptor) { + BufferBase* DeviceBase::APICreateBuffer(const BufferDescriptor* descriptor) { Ref result = nullptr; if (ConsumedError(CreateBufferInternal(descriptor), &result)) { ASSERT(result == nullptr); @@ -692,10 +693,11 @@ namespace dawn_native { return result.Detach(); } - CommandEncoder* DeviceBase::CreateCommandEncoder(const CommandEncoderDescriptor* descriptor) { + CommandEncoder* DeviceBase::APICreateCommandEncoder( + const CommandEncoderDescriptor* descriptor) { return new CommandEncoder(this, descriptor); } - ComputePipelineBase* DeviceBase::CreateComputePipeline( + ComputePipelineBase* DeviceBase::APICreateComputePipeline( const ComputePipelineDescriptor* descriptor) { ComputePipelineBase* result = nullptr; @@ -705,9 +707,9 @@ namespace dawn_native { return result; } - void DeviceBase::CreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor, - WGPUCreateComputePipelineAsyncCallback callback, - void* userdata) { + void DeviceBase::APICreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor, + WGPUCreateComputePipelineAsyncCallback callback, + void* userdata) { ComputePipelineBase* result = nullptr; if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) { @@ -730,7 +732,7 @@ namespace dawn_native { std::make_unique(result, callback, userdata); mCreatePipelineAsyncTracker->TrackTask(std::move(request), GetPendingCommandSerial()); } - PipelineLayoutBase* DeviceBase::CreatePipelineLayout( + PipelineLayoutBase* DeviceBase::APICreatePipelineLayout( const PipelineLayoutDescriptor* descriptor) { PipelineLayoutBase* result = nullptr; @@ -740,7 +742,7 @@ namespace dawn_native { return result; } - QuerySetBase* DeviceBase::CreateQuerySet(const QuerySetDescriptor* descriptor) { + QuerySetBase* DeviceBase::APICreateQuerySet(const QuerySetDescriptor* descriptor) { QuerySetBase* result = nullptr; if (ConsumedError(CreateQuerySetInternal(&result, descriptor))) { @@ -749,7 +751,7 @@ namespace dawn_native { return result; } - SamplerBase* DeviceBase::CreateSampler(const SamplerDescriptor* descriptor) { + SamplerBase* DeviceBase::APICreateSampler(const SamplerDescriptor* descriptor) { SamplerBase* result = nullptr; if (ConsumedError(CreateSamplerInternal(&result, descriptor))) { @@ -758,9 +760,9 @@ namespace dawn_native { return result; } - void DeviceBase::CreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor, - WGPUCreateRenderPipelineAsyncCallback callback, - void* userdata) { + void DeviceBase::APICreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor, + WGPUCreateRenderPipelineAsyncCallback callback, + void* userdata) { RenderPipelineBase* result = nullptr; if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) { @@ -783,7 +785,7 @@ namespace dawn_native { std::make_unique(result, callback, userdata); mCreatePipelineAsyncTracker->TrackTask(std::move(request), GetPendingCommandSerial()); } - RenderBundleEncoder* DeviceBase::CreateRenderBundleEncoder( + RenderBundleEncoder* DeviceBase::APICreateRenderBundleEncoder( const RenderBundleEncoderDescriptor* descriptor) { RenderBundleEncoder* result = nullptr; @@ -793,7 +795,7 @@ namespace dawn_native { return result; } - RenderPipelineBase* DeviceBase::CreateRenderPipeline( + RenderPipelineBase* DeviceBase::APICreateRenderPipeline( const RenderPipelineDescriptor* descriptor) { RenderPipelineBase* result = nullptr; @@ -809,7 +811,7 @@ namespace dawn_native { return result; } - RenderPipelineBase* DeviceBase::CreateRenderPipeline2( + RenderPipelineBase* DeviceBase::APICreateRenderPipeline2( const RenderPipelineDescriptor2* descriptor) { RenderPipelineBase* result = nullptr; @@ -819,7 +821,7 @@ namespace dawn_native { return result; } - ShaderModuleBase* DeviceBase::CreateShaderModule(const ShaderModuleDescriptor* descriptor) { + ShaderModuleBase* DeviceBase::APICreateShaderModule(const ShaderModuleDescriptor* descriptor) { ShaderModuleBase* result = nullptr; if (ConsumedError(CreateShaderModuleInternal(&result, descriptor))) { @@ -828,8 +830,8 @@ namespace dawn_native { return result; } - SwapChainBase* DeviceBase::CreateSwapChain(Surface* surface, - const SwapChainDescriptor* descriptor) { + SwapChainBase* DeviceBase::APICreateSwapChain(Surface* surface, + const SwapChainDescriptor* descriptor) { SwapChainBase* result = nullptr; if (ConsumedError(CreateSwapChainInternal(&result, surface, descriptor))) { @@ -838,7 +840,7 @@ namespace dawn_native { return result; } - TextureBase* DeviceBase::CreateTexture(const TextureDescriptor* descriptor) { + TextureBase* DeviceBase::APICreateTexture(const TextureDescriptor* descriptor) { Ref result; if (ConsumedError(CreateTextureInternal(descriptor), &result)) { @@ -860,7 +862,7 @@ namespace dawn_native { // For Dawn Wire - BufferBase* DeviceBase::CreateErrorBuffer() { + BufferBase* DeviceBase::APICreateErrorBuffer() { BufferDescriptor desc = {}; return BufferBase::MakeError(this, &desc); } @@ -868,7 +870,7 @@ namespace dawn_native { // Other Device API methods // Returns true if future ticking is needed. - bool DeviceBase::Tick() { + bool DeviceBase::APITick() { if (ConsumedError(ValidateIsAlive())) { return false; } @@ -894,7 +896,8 @@ namespace dawn_native { // tick the dynamic uploader before the backend resource allocators. This would allow // reclaiming resources one tick earlier. mDynamicUploader->Deallocate(mCompletedSerial); - GetQueue()->Tick(mCompletedSerial); + // TODO(dawn:723): do not get a new reference to the Queue. + APIGetQueue()->Tick(mCompletedSerial); mCreatePipelineAsyncTracker->Tick(mCompletedSerial); } @@ -902,7 +905,7 @@ namespace dawn_native { return !IsDeviceIdle(); } - QueueBase* DeviceBase::GetQueue() { + QueueBase* DeviceBase::APIGetQueue() { // Backends gave the primary queue during initialization. ASSERT(mQueue != nullptr); @@ -911,10 +914,10 @@ namespace dawn_native { return mQueue.Get(); } - QueueBase* DeviceBase::GetDefaultQueue() { + QueueBase* DeviceBase::APIGetDefaultQueue() { EmitDeprecationWarning( "Device::GetDefaultQueue is deprecated, use Device::GetQueue() instead"); - return GetQueue(); + return APIGetQueue(); } void DeviceBase::ApplyExtensions(const DeviceDescriptor* deviceDescriptor) { diff --git a/src/dawn_native/Device.h b/src/dawn_native/Device.h index 32d676791c..9064224ba3 100644 --- a/src/dawn_native/Device.h +++ b/src/dawn_native/Device.h @@ -139,45 +139,45 @@ namespace dawn_native { void UncacheAttachmentState(AttachmentState* obj); // Dawn API - BindGroupBase* CreateBindGroup(const BindGroupDescriptor* descriptor); - BindGroupLayoutBase* CreateBindGroupLayout(const BindGroupLayoutDescriptor* descriptor); - BufferBase* CreateBuffer(const BufferDescriptor* descriptor); - CommandEncoder* CreateCommandEncoder(const CommandEncoderDescriptor* descriptor); - ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor); - PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor); - QuerySetBase* CreateQuerySet(const QuerySetDescriptor* descriptor); - void CreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor, - WGPUCreateComputePipelineAsyncCallback callback, - void* userdata); - void CreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor, - WGPUCreateRenderPipelineAsyncCallback callback, - void* userdata); - RenderBundleEncoder* CreateRenderBundleEncoder( + BindGroupBase* APICreateBindGroup(const BindGroupDescriptor* descriptor); + BindGroupLayoutBase* APICreateBindGroupLayout(const BindGroupLayoutDescriptor* descriptor); + BufferBase* APICreateBuffer(const BufferDescriptor* descriptor); + CommandEncoder* APICreateCommandEncoder(const CommandEncoderDescriptor* descriptor); + ComputePipelineBase* APICreateComputePipeline(const ComputePipelineDescriptor* descriptor); + PipelineLayoutBase* APICreatePipelineLayout(const PipelineLayoutDescriptor* descriptor); + QuerySetBase* APICreateQuerySet(const QuerySetDescriptor* descriptor); + void APICreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor, + WGPUCreateComputePipelineAsyncCallback callback, + void* userdata); + void APICreateRenderPipelineAsync(const RenderPipelineDescriptor2* descriptor, + WGPUCreateRenderPipelineAsyncCallback callback, + void* userdata); + RenderBundleEncoder* APICreateRenderBundleEncoder( const RenderBundleEncoderDescriptor* descriptor); - RenderPipelineBase* CreateRenderPipeline(const RenderPipelineDescriptor* descriptor); - RenderPipelineBase* CreateRenderPipeline2(const RenderPipelineDescriptor2* descriptor); - SamplerBase* CreateSampler(const SamplerDescriptor* descriptor); - ShaderModuleBase* CreateShaderModule(const ShaderModuleDescriptor* descriptor); - SwapChainBase* CreateSwapChain(Surface* surface, const SwapChainDescriptor* descriptor); - TextureBase* CreateTexture(const TextureDescriptor* descriptor); + RenderPipelineBase* APICreateRenderPipeline(const RenderPipelineDescriptor* descriptor); + RenderPipelineBase* APICreateRenderPipeline2(const RenderPipelineDescriptor2* descriptor); + SamplerBase* APICreateSampler(const SamplerDescriptor* descriptor); + ShaderModuleBase* APICreateShaderModule(const ShaderModuleDescriptor* descriptor); + SwapChainBase* APICreateSwapChain(Surface* surface, const SwapChainDescriptor* descriptor); + TextureBase* APICreateTexture(const TextureDescriptor* descriptor); TextureViewBase* CreateTextureView(TextureBase* texture, const TextureViewDescriptor* descriptor); InternalPipelineStore* GetInternalPipelineStore(); // For Dawn Wire - BufferBase* CreateErrorBuffer(); + BufferBase* APICreateErrorBuffer(); // TODO(dawn:22): Remove once the deprecation period is finished. - QueueBase* GetDefaultQueue(); - QueueBase* GetQueue(); + QueueBase* APIGetDefaultQueue(); + QueueBase* APIGetQueue(); - void InjectError(wgpu::ErrorType type, const char* message); - bool Tick(); + void APIInjectError(wgpu::ErrorType type, const char* message); + bool APITick(); - void SetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata); - void SetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata); - void PushErrorScope(wgpu::ErrorFilter filter); - bool PopErrorScope(wgpu::ErrorCallback callback, void* userdata); + void APISetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata); + void APISetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata); + void APIPushErrorScope(wgpu::ErrorFilter filter); + bool APIPopErrorScope(wgpu::ErrorCallback callback, void* userdata); MaybeError ValidateIsAlive() const; @@ -228,7 +228,7 @@ namespace dawn_native { void IncrementLazyClearCountForTesting(); size_t GetDeprecationWarningCountForTesting(); void EmitDeprecationWarning(const char* warning); - void LoseForTesting(); + void APILoseForTesting(); // AddFutureSerial is used to update the mFutureSerial with the max serial needed to be // ticked in order to clean up all pending callback work or to execute asynchronous resource diff --git a/src/dawn_native/Fence.cpp b/src/dawn_native/Fence.cpp index 88e03c8e61..175f4cea28 100644 --- a/src/dawn_native/Fence.cpp +++ b/src/dawn_native/Fence.cpp @@ -73,16 +73,16 @@ namespace dawn_native { return new Fence(device, ObjectBase::kError); } - uint64_t Fence::GetCompletedValue() const { + uint64_t Fence::APIGetCompletedValue() const { if (IsError()) { return 0; } return uint64_t(mCompletedValue); } - void Fence::OnCompletion(uint64_t apiValue, - wgpu::FenceOnCompletionCallback callback, - void* userdata) { + void Fence::APIOnCompletion(uint64_t apiValue, + wgpu::FenceOnCompletionCallback callback, + void* userdata) { FenceAPISerial value(apiValue); WGPUFenceCompletionStatus status; @@ -136,8 +136,9 @@ namespace dawn_native { std::make_unique(fence, value); // TODO: use GetLastSubmittedCommandSerial in the future for perforamnce - GetDevice()->GetQueue()->TrackTask(std::move(fenceInFlight), - GetDevice()->GetPendingCommandSerial()); + // TODO(dawn:723): do not get a new reference to the Queue. + GetDevice()->APIGetQueue()->TrackTask(std::move(fenceInFlight), + GetDevice()->GetPendingCommandSerial()); } MaybeError Fence::ValidateOnCompletion(FenceAPISerial value, diff --git a/src/dawn_native/Fence.h b/src/dawn_native/Fence.h index 9bc471e25e..2f834349ed 100644 --- a/src/dawn_native/Fence.h +++ b/src/dawn_native/Fence.h @@ -39,8 +39,10 @@ namespace dawn_native { const QueueBase* GetQueue() const; // Dawn API - uint64_t GetCompletedValue() const; - void OnCompletion(uint64_t value, wgpu::FenceOnCompletionCallback callback, void* userdata); + uint64_t APIGetCompletedValue() const; + void APIOnCompletion(uint64_t value, + wgpu::FenceOnCompletionCallback callback, + void* userdata); protected: friend class QueueBase; diff --git a/src/dawn_native/Instance.cpp b/src/dawn_native/Instance.cpp index f7fe907af8..7d65e4d185 100644 --- a/src/dawn_native/Instance.cpp +++ b/src/dawn_native/Instance.cpp @@ -238,7 +238,7 @@ namespace dawn_native { #endif // defined(DAWN_USE_X11) } - Surface* InstanceBase::CreateSurface(const SurfaceDescriptor* descriptor) { + Surface* InstanceBase::APICreateSurface(const SurfaceDescriptor* descriptor) { if (ConsumedError(ValidateSurfaceDescriptor(this, descriptor))) { return nullptr; } diff --git a/src/dawn_native/Instance.h b/src/dawn_native/Instance.h index 21f320411b..86118d5ed2 100644 --- a/src/dawn_native/Instance.h +++ b/src/dawn_native/Instance.h @@ -72,7 +72,7 @@ namespace dawn_native { const XlibXcbFunctions* GetOrCreateXlibXcbFunctions(); // Dawn API - Surface* CreateSurface(const SurfaceDescriptor* descriptor); + Surface* APICreateSurface(const SurfaceDescriptor* descriptor); private: InstanceBase() = default; diff --git a/src/dawn_native/Pipeline.cpp b/src/dawn_native/Pipeline.cpp index 4d582e1f4d..03bc726793 100644 --- a/src/dawn_native/Pipeline.cpp +++ b/src/dawn_native/Pipeline.cpp @@ -125,7 +125,7 @@ namespace dawn_native { return {}; } - BindGroupLayoutBase* PipelineBase::GetBindGroupLayout(uint32_t groupIndexIn) { + BindGroupLayoutBase* PipelineBase::APIGetBindGroupLayout(uint32_t groupIndexIn) { if (GetDevice()->ConsumedError(ValidateGetBindGroupLayout(groupIndexIn))) { return BindGroupLayoutBase::MakeError(GetDevice()); } diff --git a/src/dawn_native/Pipeline.h b/src/dawn_native/Pipeline.h index cb18032555..f923727258 100644 --- a/src/dawn_native/Pipeline.h +++ b/src/dawn_native/Pipeline.h @@ -49,7 +49,7 @@ namespace dawn_native { const ProgrammableStage& GetStage(SingleShaderStage stage) const; const PerStage& GetAllStages() const; - BindGroupLayoutBase* GetBindGroupLayout(uint32_t groupIndex); + BindGroupLayoutBase* APIGetBindGroupLayout(uint32_t groupIndex); // Helper functions for std::unordered_map-based pipeline caches. size_t ComputeContentHash() override; diff --git a/src/dawn_native/ProgrammablePassEncoder.cpp b/src/dawn_native/ProgrammablePassEncoder.cpp index 362362dc63..c905de1b27 100644 --- a/src/dawn_native/ProgrammablePassEncoder.cpp +++ b/src/dawn_native/ProgrammablePassEncoder.cpp @@ -111,7 +111,7 @@ namespace dawn_native { return {}; } - void ProgrammablePassEncoder::InsertDebugMarker(const char* groupLabel) { + void ProgrammablePassEncoder::APIInsertDebugMarker(const char* groupLabel) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { InsertDebugMarkerCmd* cmd = allocator->Allocate(Command::InsertDebugMarker); @@ -124,7 +124,7 @@ namespace dawn_native { }); } - void ProgrammablePassEncoder::PopDebugGroup() { + void ProgrammablePassEncoder::APIPopDebugGroup() { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { if (mDebugGroupStackSize == 0) { @@ -138,7 +138,7 @@ namespace dawn_native { }); } - void ProgrammablePassEncoder::PushDebugGroup(const char* groupLabel) { + void ProgrammablePassEncoder::APIPushDebugGroup(const char* groupLabel) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { PushDebugGroupCmd* cmd = allocator->Allocate(Command::PushDebugGroup); @@ -153,10 +153,10 @@ namespace dawn_native { }); } - void ProgrammablePassEncoder::SetBindGroup(uint32_t groupIndexIn, - BindGroupBase* group, - uint32_t dynamicOffsetCountIn, - const uint32_t* dynamicOffsetsIn) { + void ProgrammablePassEncoder::APISetBindGroup(uint32_t groupIndexIn, + BindGroupBase* group, + uint32_t dynamicOffsetCountIn, + const uint32_t* dynamicOffsetsIn) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { BindGroupIndex groupIndex(groupIndexIn); diff --git a/src/dawn_native/ProgrammablePassEncoder.h b/src/dawn_native/ProgrammablePassEncoder.h index 05300e7295..8816914cd7 100644 --- a/src/dawn_native/ProgrammablePassEncoder.h +++ b/src/dawn_native/ProgrammablePassEncoder.h @@ -34,14 +34,14 @@ namespace dawn_native { EncodingContext* encodingContext, PassType passType); - void InsertDebugMarker(const char* groupLabel); - void PopDebugGroup(); - void PushDebugGroup(const char* groupLabel); + void APIInsertDebugMarker(const char* groupLabel); + void APIPopDebugGroup(); + void APIPushDebugGroup(const char* groupLabel); - void SetBindGroup(uint32_t groupIndex, - BindGroupBase* group, - uint32_t dynamicOffsetCount = 0, - const uint32_t* dynamicOffsets = nullptr); + void APISetBindGroup(uint32_t groupIndex, + BindGroupBase* group, + uint32_t dynamicOffsetCount = 0, + const uint32_t* dynamicOffsets = nullptr); protected: bool IsValidationEnabled() const; diff --git a/src/dawn_native/QueryHelper.cpp b/src/dawn_native/QueryHelper.cpp index 4d8bc3fadf..585e844c74 100644 --- a/src/dawn_native/QueryHelper.cpp +++ b/src/dawn_native/QueryHelper.cpp @@ -116,7 +116,8 @@ namespace dawn_native { wgslDesc.source = sConvertTimestampsToNanoseconds; descriptor.nextInChain = reinterpret_cast(&wgslDesc); - store->timestampCS = AcquireRef(device->CreateShaderModule(&descriptor)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + store->timestampCS = AcquireRef(device->APICreateShaderModule(&descriptor)); } // Create ComputePipeline. @@ -126,8 +127,9 @@ namespace dawn_native { computePipelineDesc.computeStage.module = store->timestampCS.Get(); computePipelineDesc.computeStage.entryPoint = "main"; + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. store->timestampComputePipeline = - AcquireRef(device->CreateComputePipeline(&computePipelineDesc)); + AcquireRef(device->APICreateComputePipeline(&computePipelineDesc)); } return store->timestampComputePipeline.Get(); @@ -144,7 +146,8 @@ namespace dawn_native { ComputePipelineBase* pipeline = GetOrCreateTimestampComputePipeline(device); // Prepare bind group layout. - Ref layout = AcquireRef(pipeline->GetBindGroupLayout(0)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref layout = AcquireRef(pipeline->APIGetBindGroupLayout(0)); // Prepare bind group descriptor std::array bindGroupEntries = {}; @@ -165,15 +168,18 @@ namespace dawn_native { bindGroupEntries[2].size = params->GetSize(); // Create bind group after all binding entries are set. - Ref bindGroup = AcquireRef(device->CreateBindGroup(&bgDesc)); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref bindGroup = AcquireRef(device->APICreateBindGroup(&bgDesc)); // Create compute encoder and issue dispatch. ComputePassDescriptor passDesc = {}; - Ref pass = AcquireRef(encoder->BeginComputePass(&passDesc)); - pass->SetPipeline(pipeline); - pass->SetBindGroup(0, bindGroup.Get()); - pass->Dispatch(static_cast((timestamps->GetSize() / sizeof(uint64_t) + 7) / 8)); - pass->EndPass(); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref pass = AcquireRef(encoder->APIBeginComputePass(&passDesc)); + pass->APISetPipeline(pipeline); + pass->APISetBindGroup(0, bindGroup.Get()); + pass->APIDispatch( + static_cast((timestamps->GetSize() / sizeof(uint64_t) + 7) / 8)); + pass->APIEndPass(); } } // namespace dawn_native diff --git a/src/dawn_native/QuerySet.cpp b/src/dawn_native/QuerySet.cpp index d181e36423..26e9c6d1c9 100644 --- a/src/dawn_native/QuerySet.cpp +++ b/src/dawn_native/QuerySet.cpp @@ -153,7 +153,7 @@ namespace dawn_native { return {}; } - void QuerySetBase::Destroy() { + void QuerySetBase::APIDestroy() { if (GetDevice()->ConsumedError(ValidateDestroy())) { return; } diff --git a/src/dawn_native/QuerySet.h b/src/dawn_native/QuerySet.h index df36b2ada4..32b75c9edc 100644 --- a/src/dawn_native/QuerySet.h +++ b/src/dawn_native/QuerySet.h @@ -40,7 +40,7 @@ namespace dawn_native { MaybeError ValidateCanUseInSubmitNow() const; - void Destroy(); + void APIDestroy(); protected: QuerySetBase(DeviceBase* device, ObjectBase::ErrorTag tag); diff --git a/src/dawn_native/Queue.cpp b/src/dawn_native/Queue.cpp index d5fa05a2e4..a62db1ba41 100644 --- a/src/dawn_native/Queue.cpp +++ b/src/dawn_native/Queue.cpp @@ -176,7 +176,7 @@ namespace dawn_native { return new ErrorQueue(device); } - void QueueBase::Submit(uint32_t commandCount, CommandBufferBase* const* commands) { + void QueueBase::APISubmit(uint32_t commandCount, CommandBufferBase* const* commands) { SubmitInternal(commandCount, commands); for (uint32_t i = 0; i < commandCount; ++i) { @@ -184,7 +184,7 @@ namespace dawn_native { } } - void QueueBase::Signal(Fence* fence, uint64_t apiSignalValue) { + void QueueBase::APISignal(Fence* fence, uint64_t apiSignalValue) { FenceAPISerial signalValue(apiSignalValue); DeviceBase* device = GetDevice(); @@ -197,9 +197,9 @@ namespace dawn_native { fence->UpdateFenceOnComplete(fence, signalValue); } - void QueueBase::OnSubmittedWorkDone(uint64_t signalValue, - WGPUQueueWorkDoneCallback callback, - void* userdata) { + void QueueBase::APIOnSubmittedWorkDone(uint64_t signalValue, + WGPUQueueWorkDoneCallback callback, + void* userdata) { // The error status depends on the type of error so we let the validation function choose it WGPUQueueWorkDoneStatus status; if (GetDevice()->ConsumedError(ValidateOnSubmittedWorkDone(signalValue, &status))) { @@ -236,7 +236,7 @@ namespace dawn_native { mTasksInFlight.Clear(); } - Fence* QueueBase::CreateFence(const FenceDescriptor* descriptor) { + Fence* QueueBase::APICreateFence(const FenceDescriptor* descriptor) { // TODO(chromium:1177476): Remove once the deprecation period is finished. GetDevice()->EmitDeprecationWarning( "Fences are deprecated, use Queue::OnSubmittedWorkDone instead."); @@ -252,10 +252,10 @@ namespace dawn_native { return new Fence(this, descriptor); } - void QueueBase::WriteBuffer(BufferBase* buffer, - uint64_t bufferOffset, - const void* data, - size_t size) { + void QueueBase::APIWriteBuffer(BufferBase* buffer, + uint64_t bufferOffset, + const void* data, + size_t size) { GetDevice()->ConsumedError(WriteBufferInternal(buffer, bufferOffset, data, size)); } @@ -291,11 +291,11 @@ namespace dawn_native { buffer, bufferOffset, size); } - void QueueBase::WriteTexture(const ImageCopyTexture* destination, - const void* data, - size_t dataSize, - const TextureDataLayout* dataLayout, - const Extent3D* writeSize) { + void QueueBase::APIWriteTexture(const ImageCopyTexture* destination, + const void* data, + size_t dataSize, + const TextureDataLayout* dataLayout, + const Extent3D* writeSize) { GetDevice()->ConsumedError( WriteTextureInternal(destination, data, dataSize, dataLayout, writeSize)); } @@ -366,10 +366,10 @@ namespace dawn_native { &textureCopy, writeSizePixel); } - void QueueBase::CopyTextureForBrowser(const ImageCopyTexture* source, - const ImageCopyTexture* destination, - const Extent3D* copySize, - const CopyTextureForBrowserOptions* options) { + void QueueBase::APICopyTextureForBrowser(const ImageCopyTexture* source, + const ImageCopyTexture* destination, + const Extent3D* copySize, + const CopyTextureForBrowserOptions* options) { GetDevice()->ConsumedError( CopyTextureForBrowserInternal(source, destination, copySize, options)); } diff --git a/src/dawn_native/Queue.h b/src/dawn_native/Queue.h index bb538db303..d9d9ee4372 100644 --- a/src/dawn_native/Queue.h +++ b/src/dawn_native/Queue.h @@ -37,22 +37,25 @@ namespace dawn_native { ~QueueBase() override; // Dawn API - void Submit(uint32_t commandCount, CommandBufferBase* const* commands); - void Signal(Fence* fence, uint64_t signalValue); - Fence* CreateFence(const FenceDescriptor* descriptor); - void OnSubmittedWorkDone(uint64_t signalValue, - WGPUQueueWorkDoneCallback callback, - void* userdata); - void WriteBuffer(BufferBase* buffer, uint64_t bufferOffset, const void* data, size_t size); - void WriteTexture(const ImageCopyTexture* destination, - const void* data, - size_t dataSize, - const TextureDataLayout* dataLayout, - const Extent3D* writeSize); - void CopyTextureForBrowser(const ImageCopyTexture* source, - const ImageCopyTexture* destination, - const Extent3D* copySize, - const CopyTextureForBrowserOptions* options); + void APISubmit(uint32_t commandCount, CommandBufferBase* const* commands); + void APISignal(Fence* fence, uint64_t signalValue); + Fence* APICreateFence(const FenceDescriptor* descriptor); + void APIOnSubmittedWorkDone(uint64_t signalValue, + WGPUQueueWorkDoneCallback callback, + void* userdata); + void APIWriteBuffer(BufferBase* buffer, + uint64_t bufferOffset, + const void* data, + size_t size); + void APIWriteTexture(const ImageCopyTexture* destination, + const void* data, + size_t dataSize, + const TextureDataLayout* dataLayout, + const Extent3D* writeSize); + void APICopyTextureForBrowser(const ImageCopyTexture* source, + const ImageCopyTexture* destination, + const Extent3D* copySize, + const CopyTextureForBrowserOptions* options); void TrackTask(std::unique_ptr task, ExecutionSerial serial); void Tick(ExecutionSerial finishedSerial); diff --git a/src/dawn_native/RenderBundleEncoder.cpp b/src/dawn_native/RenderBundleEncoder.cpp index b8f3c82355..f466530c04 100644 --- a/src/dawn_native/RenderBundleEncoder.cpp +++ b/src/dawn_native/RenderBundleEncoder.cpp @@ -99,7 +99,7 @@ namespace dawn_native { return mBundleEncodingContext.AcquireCommands(); } - RenderBundleBase* RenderBundleEncoder::Finish(const RenderBundleDescriptor* descriptor) { + RenderBundleBase* RenderBundleEncoder::APIFinish(const RenderBundleDescriptor* descriptor) { RenderBundleBase* result = nullptr; if (GetDevice()->ConsumedError(FinishImpl(descriptor), &result)) { diff --git a/src/dawn_native/RenderBundleEncoder.h b/src/dawn_native/RenderBundleEncoder.h index 0bd63fb468..4b0a1f5a74 100644 --- a/src/dawn_native/RenderBundleEncoder.h +++ b/src/dawn_native/RenderBundleEncoder.h @@ -32,7 +32,7 @@ namespace dawn_native { static RenderBundleEncoder* MakeError(DeviceBase* device); - RenderBundleBase* Finish(const RenderBundleDescriptor* descriptor); + RenderBundleBase* APIFinish(const RenderBundleDescriptor* descriptor); CommandIterator AcquireCommands(); diff --git a/src/dawn_native/RenderEncoderBase.cpp b/src/dawn_native/RenderEncoderBase.cpp index a6be71cbc6..f87bb3b54e 100644 --- a/src/dawn_native/RenderEncoderBase.cpp +++ b/src/dawn_native/RenderEncoderBase.cpp @@ -56,10 +56,10 @@ namespace dawn_native { return std::move(mAttachmentState); } - void RenderEncoderBase::Draw(uint32_t vertexCount, - uint32_t instanceCount, - uint32_t firstVertex, - uint32_t firstInstance) { + void RenderEncoderBase::APIDraw(uint32_t vertexCount, + uint32_t instanceCount, + uint32_t firstVertex, + uint32_t firstInstance) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(mCommandBufferState.ValidateCanDraw()); @@ -79,11 +79,11 @@ namespace dawn_native { }); } - void RenderEncoderBase::DrawIndexed(uint32_t indexCount, - uint32_t instanceCount, - uint32_t firstIndex, - int32_t baseVertex, - uint32_t firstInstance) { + void RenderEncoderBase::APIDrawIndexed(uint32_t indexCount, + uint32_t instanceCount, + uint32_t firstIndex, + int32_t baseVertex, + uint32_t firstInstance) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(mCommandBufferState.ValidateCanDrawIndexed()); @@ -115,7 +115,7 @@ namespace dawn_native { }); } - void RenderEncoderBase::DrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) { + void RenderEncoderBase::APIDrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer)); @@ -142,8 +142,8 @@ namespace dawn_native { }); } - void RenderEncoderBase::DrawIndexedIndirect(BufferBase* indirectBuffer, - uint64_t indirectOffset) { + void RenderEncoderBase::APIDrawIndexedIndirect(BufferBase* indirectBuffer, + uint64_t indirectOffset) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer)); @@ -181,7 +181,7 @@ namespace dawn_native { }); } - void RenderEncoderBase::SetPipeline(RenderPipelineBase* pipeline) { + void RenderEncoderBase::APISetPipeline(RenderPipelineBase* pipeline) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(pipeline)); @@ -203,18 +203,20 @@ namespace dawn_native { }); } - void RenderEncoderBase::SetIndexBufferWithFormat(BufferBase* buffer, wgpu::IndexFormat format, - uint64_t offset, uint64_t size) { + void RenderEncoderBase::APISetIndexBufferWithFormat(BufferBase* buffer, + wgpu::IndexFormat format, + uint64_t offset, + uint64_t size) { GetDevice()->EmitDeprecationWarning( "RenderEncoderBase::SetIndexBufferWithFormat is deprecated. Use " "RenderEncoderBase::SetIndexBuffer instead."); - SetIndexBuffer(buffer, format, offset, size); + APISetIndexBuffer(buffer, format, offset, size); } - void RenderEncoderBase::SetIndexBuffer(BufferBase* buffer, - wgpu::IndexFormat format, - uint64_t offset, - uint64_t size) { + void RenderEncoderBase::APISetIndexBuffer(BufferBase* buffer, + wgpu::IndexFormat format, + uint64_t offset, + uint64_t size) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(buffer)); @@ -259,10 +261,10 @@ namespace dawn_native { }); } - void RenderEncoderBase::SetVertexBuffer(uint32_t slot, - BufferBase* buffer, - uint64_t offset, - uint64_t size) { + void RenderEncoderBase::APISetVertexBuffer(uint32_t slot, + BufferBase* buffer, + uint64_t offset, + uint64_t size) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(buffer)); diff --git a/src/dawn_native/RenderEncoderBase.h b/src/dawn_native/RenderEncoderBase.h index 8025f7442f..4f312707ee 100644 --- a/src/dawn_native/RenderEncoderBase.h +++ b/src/dawn_native/RenderEncoderBase.h @@ -27,28 +27,30 @@ namespace dawn_native { EncodingContext* encodingContext, Ref attachmentState); - void Draw(uint32_t vertexCount, - uint32_t instanceCount = 1, - uint32_t firstVertex = 0, - uint32_t firstInstance = 0); - void DrawIndexed(uint32_t vertexCount, - uint32_t instanceCount, - uint32_t firstIndex, - int32_t baseVertex, - uint32_t firstInstance); + void APIDraw(uint32_t vertexCount, + uint32_t instanceCount = 1, + uint32_t firstVertex = 0, + uint32_t firstInstance = 0); + void APIDrawIndexed(uint32_t vertexCount, + uint32_t instanceCount, + uint32_t firstIndex, + int32_t baseVertex, + uint32_t firstInstance); - void DrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset); - void DrawIndexedIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset); + void APIDrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset); + void APIDrawIndexedIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset); - void SetPipeline(RenderPipelineBase* pipeline); + void APISetPipeline(RenderPipelineBase* pipeline); - void SetVertexBuffer(uint32_t slot, BufferBase* buffer, uint64_t offset, uint64_t size); - void SetIndexBuffer(BufferBase* buffer, - wgpu::IndexFormat format, - uint64_t offset, - uint64_t size); - void SetIndexBufferWithFormat(BufferBase* buffer, wgpu::IndexFormat format, uint64_t offset, - uint64_t size); + void APISetVertexBuffer(uint32_t slot, BufferBase* buffer, uint64_t offset, uint64_t size); + void APISetIndexBuffer(BufferBase* buffer, + wgpu::IndexFormat format, + uint64_t offset, + uint64_t size); + void APISetIndexBufferWithFormat(BufferBase* buffer, + wgpu::IndexFormat format, + uint64_t offset, + uint64_t size); const AttachmentState* GetAttachmentState() const; Ref AcquireAttachmentState(); diff --git a/src/dawn_native/RenderPassEncoder.cpp b/src/dawn_native/RenderPassEncoder.cpp index c5c31a301d..3c9e527cf9 100644 --- a/src/dawn_native/RenderPassEncoder.cpp +++ b/src/dawn_native/RenderPassEncoder.cpp @@ -93,7 +93,7 @@ namespace dawn_native { return mQueryAvailabilityMap; } - void RenderPassEncoder::EndPass() { + void RenderPassEncoder::APIEndPass() { if (mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(ValidateProgrammableEncoderEnd()); @@ -110,7 +110,7 @@ namespace dawn_native { } } - void RenderPassEncoder::SetStencilReference(uint32_t reference) { + void RenderPassEncoder::APISetStencilReference(uint32_t reference) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { SetStencilReferenceCmd* cmd = allocator->Allocate(Command::SetStencilReference); @@ -120,7 +120,7 @@ namespace dawn_native { }); } - void RenderPassEncoder::SetBlendColor(const Color* color) { + void RenderPassEncoder::APISetBlendColor(const Color* color) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { SetBlendColorCmd* cmd = allocator->Allocate(Command::SetBlendColor); cmd->color = *color; @@ -129,12 +129,12 @@ namespace dawn_native { }); } - void RenderPassEncoder::SetViewport(float x, - float y, - float width, - float height, - float minDepth, - float maxDepth) { + void RenderPassEncoder::APISetViewport(float x, + float y, + float width, + float height, + float minDepth, + float maxDepth) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { if ((isnan(x) || isnan(y) || isnan(width) || isnan(height) || isnan(minDepth) || @@ -170,10 +170,10 @@ namespace dawn_native { }); } - void RenderPassEncoder::SetScissorRect(uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height) { + void RenderPassEncoder::APISetScissorRect(uint32_t x, + uint32_t y, + uint32_t width, + uint32_t height) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { if (width > mRenderTargetWidth || height > mRenderTargetHeight || @@ -194,7 +194,8 @@ namespace dawn_native { }); } - void RenderPassEncoder::ExecuteBundles(uint32_t count, RenderBundleBase* const* renderBundles) { + void RenderPassEncoder::APIExecuteBundles(uint32_t count, + RenderBundleBase* const* renderBundles) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { for (uint32_t i = 0; i < count; ++i) { @@ -232,7 +233,7 @@ namespace dawn_native { }); } - void RenderPassEncoder::BeginOcclusionQuery(uint32_t queryIndex) { + void RenderPassEncoder::APIBeginOcclusionQuery(uint32_t queryIndex) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { if (mOcclusionQuerySet.Get() == nullptr) { @@ -271,7 +272,7 @@ namespace dawn_native { }); } - void RenderPassEncoder::EndOcclusionQuery() { + void RenderPassEncoder::APIEndOcclusionQuery() { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { if (!mOcclusionQueryActive) { @@ -293,7 +294,7 @@ namespace dawn_native { }); } - void RenderPassEncoder::WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) { + void RenderPassEncoder::APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { if (IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(querySet)); diff --git a/src/dawn_native/RenderPassEncoder.h b/src/dawn_native/RenderPassEncoder.h index abae193329..08a24f4215 100644 --- a/src/dawn_native/RenderPassEncoder.h +++ b/src/dawn_native/RenderPassEncoder.h @@ -40,23 +40,23 @@ namespace dawn_native { void TrackQueryAvailability(QuerySetBase* querySet, uint32_t queryIndex); const QueryAvailabilityMap& GetQueryAvailabilityMap() const; - void EndPass(); + void APIEndPass(); - void SetStencilReference(uint32_t reference); - void SetBlendColor(const Color* color); - void SetViewport(float x, - float y, - float width, - float height, - float minDepth, - float maxDepth); - void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height); - void ExecuteBundles(uint32_t count, RenderBundleBase* const* renderBundles); + void APISetStencilReference(uint32_t reference); + void APISetBlendColor(const Color* color); + void APISetViewport(float x, + float y, + float width, + float height, + float minDepth, + float maxDepth); + void APISetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height); + void APIExecuteBundles(uint32_t count, RenderBundleBase* const* renderBundles); - void BeginOcclusionQuery(uint32_t queryIndex); - void EndOcclusionQuery(); + void APIBeginOcclusionQuery(uint32_t queryIndex); + void APIEndOcclusionQuery(); - void WriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex); + void APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex); protected: RenderPassEncoder(DeviceBase* device, diff --git a/src/dawn_native/SwapChain.cpp b/src/dawn_native/SwapChain.cpp index 96ef193859..aa5f8942a3 100644 --- a/src/dawn_native/SwapChain.cpp +++ b/src/dawn_native/SwapChain.cpp @@ -31,19 +31,19 @@ namespace dawn_native { } private: - void Configure(wgpu::TextureFormat format, - wgpu::TextureUsage allowedUsage, - uint32_t width, - uint32_t height) override { + void APIConfigure(wgpu::TextureFormat format, + wgpu::TextureUsage allowedUsage, + uint32_t width, + uint32_t height) override { GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("error swapchain")); } - TextureViewBase* GetCurrentTextureView() override { + TextureViewBase* APIGetCurrentTextureView() override { GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("error swapchain")); return TextureViewBase::MakeError(GetDevice()); } - void Present() override { + void APIPresent() override { GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("error swapchain")); } }; @@ -142,10 +142,10 @@ namespace dawn_native { } } - void OldSwapChainBase::Configure(wgpu::TextureFormat format, - wgpu::TextureUsage allowedUsage, - uint32_t width, - uint32_t height) { + void OldSwapChainBase::APIConfigure(wgpu::TextureFormat format, + wgpu::TextureUsage allowedUsage, + uint32_t width, + uint32_t height) { if (GetDevice()->ConsumedError(ValidateConfigure(format, allowedUsage, width, height))) { return; } @@ -161,7 +161,7 @@ namespace dawn_native { static_cast(allowedUsage), width, height); } - TextureViewBase* OldSwapChainBase::GetCurrentTextureView() { + TextureViewBase* OldSwapChainBase::APIGetCurrentTextureView() { if (GetDevice()->ConsumedError(ValidateGetCurrentTextureView())) { return TextureViewBase::MakeError(GetDevice()); } @@ -190,11 +190,11 @@ namespace dawn_native { // of dawn_native mCurrentTexture = AcquireRef(GetNextTextureImpl(&descriptor)); - mCurrentTextureView = mCurrentTexture->CreateView(); + mCurrentTextureView = mCurrentTexture->APICreateView(); return mCurrentTextureView.Get(); } - void OldSwapChainBase::Present() { + void OldSwapChainBase::APIPresent() { if (GetDevice()->ConsumedError(ValidatePresent())) { return; } @@ -292,15 +292,15 @@ namespace dawn_native { mAttached = true; } - void NewSwapChainBase::Configure(wgpu::TextureFormat format, - wgpu::TextureUsage allowedUsage, - uint32_t width, - uint32_t height) { + void NewSwapChainBase::APIConfigure(wgpu::TextureFormat format, + wgpu::TextureUsage allowedUsage, + uint32_t width, + uint32_t height) { GetDevice()->ConsumedError( DAWN_VALIDATION_ERROR("Configure is invalid for surface-based swapchains")); } - TextureViewBase* NewSwapChainBase::GetCurrentTextureView() { + TextureViewBase* NewSwapChainBase::APIGetCurrentTextureView() { if (GetDevice()->ConsumedError(ValidateGetCurrentTextureView())) { return TextureViewBase::MakeError(GetDevice()); } @@ -331,7 +331,7 @@ namespace dawn_native { return view; } - void NewSwapChainBase::Present() { + void NewSwapChainBase::APIPresent() { if (GetDevice()->ConsumedError(ValidatePresent())) { return; } diff --git a/src/dawn_native/SwapChain.h b/src/dawn_native/SwapChain.h index efa8a5411f..2c69fe9c77 100644 --- a/src/dawn_native/SwapChain.h +++ b/src/dawn_native/SwapChain.h @@ -37,12 +37,12 @@ namespace dawn_native { static SwapChainBase* MakeError(DeviceBase* device); // Dawn API - virtual void Configure(wgpu::TextureFormat format, - wgpu::TextureUsage allowedUsage, - uint32_t width, - uint32_t height) = 0; - virtual TextureViewBase* GetCurrentTextureView() = 0; - virtual void Present() = 0; + virtual void APIConfigure(wgpu::TextureFormat format, + wgpu::TextureUsage allowedUsage, + uint32_t width, + uint32_t height) = 0; + virtual TextureViewBase* APIGetCurrentTextureView() = 0; + virtual void APIPresent() = 0; protected: SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag); @@ -57,12 +57,12 @@ namespace dawn_native { static SwapChainBase* MakeError(DeviceBase* device); // Dawn API - void Configure(wgpu::TextureFormat format, - wgpu::TextureUsage allowedUsage, - uint32_t width, - uint32_t height) override; - TextureViewBase* GetCurrentTextureView() override; - void Present() override; + void APIConfigure(wgpu::TextureFormat format, + wgpu::TextureUsage allowedUsage, + uint32_t width, + uint32_t height) override; + TextureViewBase* APIGetCurrentTextureView() override; + void APIPresent() override; protected: ~OldSwapChainBase() override; @@ -114,12 +114,12 @@ namespace dawn_native { void SetIsAttached(); // Dawn API - void Configure(wgpu::TextureFormat format, - wgpu::TextureUsage allowedUsage, - uint32_t width, - uint32_t height) override; - TextureViewBase* GetCurrentTextureView() override; - void Present() override; + void APIConfigure(wgpu::TextureFormat format, + wgpu::TextureUsage allowedUsage, + uint32_t width, + uint32_t height) override; + TextureViewBase* APIGetCurrentTextureView() override; + void APIPresent() override; uint32_t GetWidth() const; uint32_t GetHeight() const; diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp index 8679e952ae..a3764c26ab 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -609,11 +609,11 @@ namespace dawn_native { return {clampedCopyExtentWidth, clampedCopyExtentHeight, extent.depthOrArrayLayers}; } - TextureViewBase* TextureBase::CreateView(const TextureViewDescriptor* descriptor) { + TextureViewBase* TextureBase::APICreateView(const TextureViewDescriptor* descriptor) { return GetDevice()->CreateTextureView(this, descriptor); } - void TextureBase::Destroy() { + void TextureBase::APIDestroy() { if (GetDevice()->ConsumedError(ValidateDestroy())) { return; } diff --git a/src/dawn_native/Texture.h b/src/dawn_native/Texture.h index 108e11b9e6..7ae39463f6 100644 --- a/src/dawn_native/Texture.h +++ b/src/dawn_native/Texture.h @@ -88,8 +88,8 @@ namespace dawn_native { const Extent3D& extent) const; // Dawn API - TextureViewBase* CreateView(const TextureViewDescriptor* descriptor = nullptr); - void Destroy(); + TextureViewBase* APICreateView(const TextureViewDescriptor* descriptor = nullptr); + void APIDestroy(); protected: void DestroyInternal(); diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp index 020d0c6a24..b0946bb9cf 100644 --- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp @@ -240,8 +240,9 @@ namespace dawn_native { namespace d3d12 { tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; tempBufferDescriptor.size = tempBufferSize.AcquireSuccess(); Device* device = ToBackend(srcCopy.texture->GetDevice()); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. Ref tempBuffer = - AcquireRef(ToBackend(device->CreateBuffer(&tempBufferDescriptor))); + AcquireRef(ToBackend(device->APICreateBuffer(&tempBufferDescriptor))); // Copy from source texture into tempBuffer Texture* srcTexture = ToBackend(srcCopy.texture).Get(); diff --git a/src/dawn_native/d3d12/QueueD3D12.cpp b/src/dawn_native/d3d12/QueueD3D12.cpp index 49a0e7597a..663bb4275b 100644 --- a/src/dawn_native/d3d12/QueueD3D12.cpp +++ b/src/dawn_native/d3d12/QueueD3D12.cpp @@ -32,7 +32,8 @@ namespace dawn_native { namespace d3d12 { MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { Device* device = ToBackend(GetDevice()); - device->Tick(); + // TODO(dawn:723): propagate any errors from Tick. + device->APITick(); CommandRecordingContext* commandContext; DAWN_TRY_ASSIGN(commandContext, device->GetPendingCommandContext()); diff --git a/src/dawn_native/metal/QueueMTL.mm b/src/dawn_native/metal/QueueMTL.mm index 480ccd89b4..3c90ea2209 100644 --- a/src/dawn_native/metal/QueueMTL.mm +++ b/src/dawn_native/metal/QueueMTL.mm @@ -31,7 +31,10 @@ namespace dawn_native { namespace metal { MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { Device* device = ToBackend(GetDevice()); - device->Tick(); + + // TODO(dawn:723): propagate any errors from Tick. + device->APITick(); + CommandRecordingContext* commandContext = device->GetPendingCommandContext(); TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferMTL::FillCommands"); diff --git a/src/dawn_native/metal/SwapChainMTL.mm b/src/dawn_native/metal/SwapChainMTL.mm index 55eec73aee..7653634e90 100644 --- a/src/dawn_native/metal/SwapChainMTL.mm +++ b/src/dawn_native/metal/SwapChainMTL.mm @@ -113,7 +113,7 @@ namespace dawn_native { namespace metal { ASSERT(mCurrentDrawable != nullptr); [*mCurrentDrawable present]; - mTexture->Destroy(); + mTexture->APIDestroy(); mTexture = nullptr; mCurrentDrawable = nullptr; @@ -127,16 +127,18 @@ namespace dawn_native { namespace metal { TextureDescriptor textureDesc = GetSwapChainBaseTextureDescriptor(this); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. mTexture = AcquireRef( new Texture(ToBackend(GetDevice()), &textureDesc, [*mCurrentDrawable texture])); - return mTexture->CreateView(); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + return mTexture->APICreateView(); } void SwapChain::DetachFromSurfaceImpl() { ASSERT((mTexture == nullptr) == (mCurrentDrawable == nullptr)); if (mTexture != nullptr) { - mTexture->Destroy(); + mTexture->APIDestroy(); mTexture = nullptr; mCurrentDrawable = nullptr; diff --git a/src/dawn_native/null/DeviceNull.cpp b/src/dawn_native/null/DeviceNull.cpp index 5f5a28304c..3ac5ac8c29 100644 --- a/src/dawn_native/null/DeviceNull.cpp +++ b/src/dawn_native/null/DeviceNull.cpp @@ -375,21 +375,23 @@ namespace dawn_native { namespace null { SwapChain::~SwapChain() = default; MaybeError SwapChain::PresentImpl() { - mTexture->Destroy(); + mTexture->APIDestroy(); mTexture = nullptr; return {}; } ResultOrError SwapChain::GetCurrentTextureViewImpl() { TextureDescriptor textureDesc = GetSwapChainBaseTextureDescriptor(this); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. mTexture = AcquireRef( new Texture(GetDevice(), &textureDesc, TextureBase::TextureState::OwnedInternal)); - return mTexture->CreateView(); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + return mTexture->APICreateView(); } void SwapChain::DetachFromSurfaceImpl() { if (mTexture != nullptr) { - mTexture->Destroy(); + mTexture->APIDestroy(); mTexture = nullptr; } } @@ -412,7 +414,7 @@ namespace dawn_native { namespace null { } TextureBase* OldSwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) { - return GetDevice()->CreateTexture(descriptor); + return GetDevice()->APICreateTexture(descriptor); } MaybeError OldSwapChain::OnBeforePresent(TextureViewBase*) { diff --git a/src/dawn_native/opengl/TextureGL.cpp b/src/dawn_native/opengl/TextureGL.cpp index c7fc9ef74b..208a48e8b0 100644 --- a/src/dawn_native/opengl/TextureGL.cpp +++ b/src/dawn_native/opengl/TextureGL.cpp @@ -383,8 +383,10 @@ namespace dawn_native { namespace opengl { DAWN_TRY_ASSIGN(srcBuffer, Buffer::CreateInternalBuffer(device, &descriptor, false)); // Fill the buffer with clear color - memset(srcBuffer->GetMappedRange(0, descriptor.size), clearColor, descriptor.size); - srcBuffer->Unmap(); + // TODO(dawn:723): propagate any errors from GetMappedRange. + memset(srcBuffer->APIGetMappedRange(0, descriptor.size), clearColor, descriptor.size); + // TODO(dawn:723): propagate any errors from Unmap. + srcBuffer->APIUnmap(); // Bind buffer and texture, and make the buffer to texture copy gl.PixelStorei(GL_UNPACK_ROW_LENGTH, diff --git a/src/dawn_native/vulkan/CommandBufferVk.cpp b/src/dawn_native/vulkan/CommandBufferVk.cpp index 62a0caf4b1..ed2ca188e7 100644 --- a/src/dawn_native/vulkan/CommandBufferVk.cpp +++ b/src/dawn_native/vulkan/CommandBufferVk.cpp @@ -465,7 +465,9 @@ namespace dawn_native { namespace vulkan { tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; Device* device = ToBackend(GetDevice()); - Ref tempBuffer = AcquireRef(ToBackend(device->CreateBuffer(&tempBufferDescriptor))); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + Ref tempBuffer = + AcquireRef(ToBackend(device->APICreateBuffer(&tempBufferDescriptor))); BufferCopy tempBufferCopy; tempBufferCopy.buffer = tempBuffer.Get(); diff --git a/src/dawn_native/vulkan/QueueVk.cpp b/src/dawn_native/vulkan/QueueVk.cpp index b7fa159159..d7b89bee07 100644 --- a/src/dawn_native/vulkan/QueueVk.cpp +++ b/src/dawn_native/vulkan/QueueVk.cpp @@ -41,7 +41,8 @@ namespace dawn_native { namespace vulkan { MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { Device* device = ToBackend(GetDevice()); - device->Tick(); + // TODO(dawn:723): propagate any errors from Tick. + device->APITick(); TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferVk::RecordCommands"); diff --git a/src/dawn_native/vulkan/SwapChainVk.cpp b/src/dawn_native/vulkan/SwapChainVk.cpp index d9f75d15da..a8cd00e2c3 100644 --- a/src/dawn_native/vulkan/SwapChainVk.cpp +++ b/src/dawn_native/vulkan/SwapChainVk.cpp @@ -496,7 +496,7 @@ namespace dawn_native { namespace vulkan { // TODO(cwallez@chromium.org): Find a way to reuse the blit texture between frames // instead of creating a new one every time. This will involve "un-destroying" the // texture or making the blit texture "external". - mBlitTexture->Destroy(); + mBlitTexture->APIDestroy(); mBlitTexture = nullptr; } @@ -523,7 +523,7 @@ namespace dawn_native { namespace vulkan { presentInfo.pResults = nullptr; // Free the texture before present so error handling doesn't skip that step. - mTexture->Destroy(); + mTexture->APIDestroy(); mTexture = nullptr; VkResult result = @@ -620,7 +620,8 @@ namespace dawn_native { namespace vulkan { // In the happy path we can use the swapchain image directly. if (!mConfig.needsBlit) { - return mTexture->CreateView(); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + return mTexture->APICreateView(); } // The blit texture always perfectly matches what the user requested for the swapchain. @@ -628,17 +629,18 @@ namespace dawn_native { namespace vulkan { TextureDescriptor desc = GetSwapChainBaseTextureDescriptor(this); DAWN_TRY_ASSIGN(mBlitTexture, Texture::Create(device, &desc, VK_IMAGE_USAGE_TRANSFER_SRC_BIT)); - return mBlitTexture->CreateView(); + // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. + return mBlitTexture->APICreateView(); } void SwapChain::DetachFromSurfaceImpl() { if (mTexture != nullptr) { - mTexture->Destroy(); + mTexture->APIDestroy(); mTexture = nullptr; } if (mBlitTexture != nullptr) { - mBlitTexture->Destroy(); + mBlitTexture->APIDestroy(); mBlitTexture = nullptr; } diff --git a/src/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/tests/white_box/D3D12DescriptorHeapTests.cpp index 20e799a4b6..9b18b7b1bf 100644 --- a/src/tests/white_box/D3D12DescriptorHeapTests.cpp +++ b/src/tests/white_box/D3D12DescriptorHeapTests.cpp @@ -325,7 +325,7 @@ TEST_P(D3D12DescriptorHeapTests, PoolHeapsInPendingAndMultipleSubmits) { // Ensure switched-over heaps can be recycled by advancing the GPU by at-least |kFrameDepth|. for (uint32_t i = 0; i < kFrameDepth; i++) { - mD3DDevice->Tick(); + mD3DDevice->APITick(); } // Switch-over |kNumOfSwitches| again reusing the same heaps. @@ -359,7 +359,7 @@ TEST_P(D3D12DescriptorHeapTests, GrowHeapsInMultipleSubmits) { ComPtr heap = allocator->GetShaderVisibleHeap(); EXPECT_TRUE(std::find(heaps.begin(), heaps.end(), heap) == heaps.end()); heaps.insert(heap); - mD3DDevice->Tick(); + mD3DDevice->APITick(); } // Verify the number of switches equals the size of heaps allocated (minus the initial). @@ -416,7 +416,7 @@ TEST_P(D3D12DescriptorHeapTests, GrowAndPoolHeapsInPendingAndMultipleSubmits) { // Ensure switched-over heaps can be recycled by advancing the GPU by at-least |kFrameDepth|. for (uint32_t i = 0; i < kFrameDepth; i++) { - mD3DDevice->Tick(); + mD3DDevice->APITick(); } // Switch-over the pool-allocated heaps.