mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 06:03:34 +00:00
Adds destruction handling for "simple objects" in device.destroy
Simple objects are defined as per https://dawn-review.googlesource.com/c/dawn/+/65864 and include: - BindGroups - ComputePipelines - PipelineLayouts - RenderPipelines - Samplers - ShaderModules - SwapChains Bug: dawn:628 Change-Id: I4ad74a2c4a223cf45acdbe6bdd0ec74332c9a14a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/67740 Commit-Queue: Loko Kung <lokokung@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
6b6262dde0
commit
2c67af9853
@ -205,7 +205,9 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
}
|
||||
|
||||
BindGroup::~BindGroup() {
|
||||
BindGroup::~BindGroup() = default;
|
||||
|
||||
void BindGroup::DestroyApiObjectImpl() {
|
||||
ToBackend(GetLayout())->DeallocateBindGroup(this, &mCPUViewAllocation);
|
||||
ASSERT(!mCPUViewAllocation.IsValid());
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
private:
|
||||
~BindGroup() override;
|
||||
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
Ref<SamplerHeapCacheEntry> mSamplerAllocationEntry;
|
||||
|
||||
GPUDescriptorHeapAllocation mGPUViewAllocation;
|
||||
|
@ -62,7 +62,9 @@ namespace dawn_native { namespace d3d12 {
|
||||
return {};
|
||||
}
|
||||
|
||||
ComputePipeline::~ComputePipeline() {
|
||||
ComputePipeline::~ComputePipeline() = default;
|
||||
|
||||
void ComputePipeline::DestroyApiObjectImpl() {
|
||||
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,9 @@ namespace dawn_native { namespace d3d12 {
|
||||
|
||||
private:
|
||||
~ComputePipeline() override;
|
||||
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
using ComputePipelineBase::ComputePipelineBase;
|
||||
ComPtr<ID3D12PipelineState> mPipelineState;
|
||||
};
|
||||
|
@ -417,7 +417,9 @@ namespace dawn_native { namespace d3d12 {
|
||||
return {};
|
||||
}
|
||||
|
||||
RenderPipeline::~RenderPipeline() {
|
||||
RenderPipeline::~RenderPipeline() = default;
|
||||
|
||||
void RenderPipeline::DestroyApiObjectImpl() {
|
||||
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,9 @@ namespace dawn_native { namespace d3d12 {
|
||||
|
||||
private:
|
||||
~RenderPipeline() override;
|
||||
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
using RenderPipelineBase::RenderPipelineBase;
|
||||
D3D12_INPUT_LAYOUT_DESC ComputeInputLayout(
|
||||
std::array<D3D12_INPUT_ELEMENT_DESC, kMaxVertexAttributes>* inputElementDescriptors);
|
||||
|
@ -141,7 +141,9 @@ namespace dawn_native { namespace d3d12 {
|
||||
return swapchain;
|
||||
}
|
||||
|
||||
SwapChain::~SwapChain() {
|
||||
SwapChain::~SwapChain() = default;
|
||||
|
||||
void SwapChain::DestroyApiObjectImpl() {
|
||||
DetachFromSurface();
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
private:
|
||||
~SwapChain() override;
|
||||
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
using NewSwapChainBase::NewSwapChainBase;
|
||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
||||
|
||||
|
@ -30,6 +30,8 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
private:
|
||||
~BindGroup() override;
|
||||
|
||||
void DestroyApiObjectImpl() override;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::metal
|
||||
|
@ -22,7 +22,9 @@ namespace dawn_native { namespace metal {
|
||||
: BindGroupBase(this, device, descriptor) {
|
||||
}
|
||||
|
||||
BindGroup::~BindGroup() {
|
||||
BindGroup::~BindGroup() = default;
|
||||
|
||||
void BindGroup::DestroyApiObjectImpl() {
|
||||
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,8 @@ namespace dawn_native { namespace metal {
|
||||
~SwapChain() override;
|
||||
|
||||
private:
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
using NewSwapChainBase::NewSwapChainBase;
|
||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
||||
|
||||
|
@ -73,7 +73,9 @@ namespace dawn_native { namespace metal {
|
||||
return swapchain;
|
||||
}
|
||||
|
||||
SwapChain::~SwapChain() {
|
||||
SwapChain::~SwapChain() = default;
|
||||
|
||||
void SwapChain::DestroyApiObjectImpl() {
|
||||
DetachFromSurface();
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,9 @@ namespace dawn_native { namespace opengl {
|
||||
: BindGroupBase(this, device, descriptor) {
|
||||
}
|
||||
|
||||
BindGroup::~BindGroup() {
|
||||
BindGroup::~BindGroup() = default;
|
||||
|
||||
void BindGroup::DestroyApiObjectImpl() {
|
||||
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
private:
|
||||
~BindGroup() override;
|
||||
|
||||
void DestroyApiObjectImpl() override;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::opengl
|
||||
|
@ -25,7 +25,9 @@ namespace dawn_native { namespace opengl {
|
||||
return AcquireRef(new ComputePipeline(device, descriptor));
|
||||
}
|
||||
|
||||
ComputePipeline::~ComputePipeline() {
|
||||
ComputePipeline::~ComputePipeline() = default;
|
||||
|
||||
void ComputePipeline::DestroyApiObjectImpl() {
|
||||
DeleteProgram(ToBackend(GetDevice())->gl);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ namespace dawn_native { namespace opengl {
|
||||
private:
|
||||
using ComputePipelineBase::ComputePipelineBase;
|
||||
~ComputePipeline() override;
|
||||
void DestroyApiObjectImpl() override;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::opengl
|
||||
|
@ -234,7 +234,9 @@ namespace dawn_native { namespace opengl {
|
||||
return {};
|
||||
}
|
||||
|
||||
RenderPipeline::~RenderPipeline() {
|
||||
RenderPipeline::~RenderPipeline() = default;
|
||||
|
||||
void RenderPipeline::DestroyApiObjectImpl() {
|
||||
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||
gl.DeleteVertexArrays(1, &mVertexArrayObject);
|
||||
gl.BindVertexArray(0);
|
||||
|
@ -43,6 +43,7 @@ namespace dawn_native { namespace opengl {
|
||||
private:
|
||||
RenderPipeline(Device* device, const RenderPipelineDescriptor* descriptor);
|
||||
~RenderPipeline() override;
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
void CreateVAOForVertexState();
|
||||
|
||||
|
@ -76,7 +76,9 @@ namespace dawn_native { namespace opengl {
|
||||
SetupGLSampler(mNonFilteringHandle, descriptor, true);
|
||||
}
|
||||
|
||||
Sampler::~Sampler() {
|
||||
Sampler::~Sampler() = default;
|
||||
|
||||
void Sampler::DestroyApiObjectImpl() {
|
||||
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||
gl.DeleteSamplers(1, &mFilteringHandle);
|
||||
gl.DeleteSamplers(1, &mNonFilteringHandle);
|
||||
|
@ -32,6 +32,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
private:
|
||||
~Sampler() override;
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
void SetupGLSampler(GLuint sampler, const SamplerDescriptor* descriptor, bool forceNearest);
|
||||
|
||||
|
@ -158,7 +158,9 @@ namespace dawn_native { namespace vulkan {
|
||||
nullptr);
|
||||
}
|
||||
|
||||
BindGroup::~BindGroup() {
|
||||
BindGroup::~BindGroup() = default;
|
||||
|
||||
void BindGroup::DestroyApiObjectImpl() {
|
||||
ToBackend(GetLayout())->DeallocateBindGroup(this, &mDescriptorSetAllocation);
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,8 @@ namespace dawn_native { namespace vulkan {
|
||||
private:
|
||||
~BindGroup() override;
|
||||
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
// The descriptor set in this allocation outlives the BindGroup because it is owned by
|
||||
// the BindGroupLayout which is referenced by the BindGroup.
|
||||
DescriptorSetAllocation mDescriptorSetAllocation;
|
||||
|
@ -89,7 +89,9 @@ namespace dawn_native { namespace vulkan {
|
||||
reinterpret_cast<uint64_t&>(mHandle), "Dawn_ComputePipeline", GetLabel());
|
||||
}
|
||||
|
||||
ComputePipeline::~ComputePipeline() {
|
||||
ComputePipeline::~ComputePipeline() = default;
|
||||
|
||||
void ComputePipeline::DestroyApiObjectImpl() {
|
||||
if (mHandle != VK_NULL_HANDLE) {
|
||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||
mHandle = VK_NULL_HANDLE;
|
||||
|
@ -42,6 +42,7 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
private:
|
||||
~ComputePipeline() override;
|
||||
void DestroyApiObjectImpl() override;
|
||||
using ComputePipelineBase::ComputePipelineBase;
|
||||
|
||||
VkPipeline mHandle = VK_NULL_HANDLE;
|
||||
|
@ -57,7 +57,9 @@ namespace dawn_native { namespace vulkan {
|
||||
"CreatePipelineLayout");
|
||||
}
|
||||
|
||||
PipelineLayout::~PipelineLayout() {
|
||||
PipelineLayout::~PipelineLayout() = default;
|
||||
|
||||
void PipelineLayout::DestroyApiObjectImpl() {
|
||||
if (mHandle != VK_NULL_HANDLE) {
|
||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||
mHandle = VK_NULL_HANDLE;
|
||||
|
@ -34,6 +34,8 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
private:
|
||||
~PipelineLayout() override;
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
using PipelineLayoutBase::PipelineLayoutBase;
|
||||
MaybeError Initialize();
|
||||
|
||||
|
@ -599,7 +599,9 @@ namespace dawn_native { namespace vulkan {
|
||||
return createInfo;
|
||||
}
|
||||
|
||||
RenderPipeline::~RenderPipeline() {
|
||||
RenderPipeline::~RenderPipeline() = default;
|
||||
|
||||
void RenderPipeline::DestroyApiObjectImpl() {
|
||||
if (mHandle != VK_NULL_HANDLE) {
|
||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||
mHandle = VK_NULL_HANDLE;
|
||||
|
@ -41,6 +41,7 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
private:
|
||||
~RenderPipeline() override;
|
||||
void DestroyApiObjectImpl() override;
|
||||
using RenderPipelineBase::RenderPipelineBase;
|
||||
|
||||
struct PipelineVertexInputStateCreateInfoTemporaryAllocations {
|
||||
|
@ -105,7 +105,9 @@ namespace dawn_native { namespace vulkan {
|
||||
"CreateSampler");
|
||||
}
|
||||
|
||||
Sampler::~Sampler() {
|
||||
Sampler::~Sampler() = default;
|
||||
|
||||
void Sampler::DestroyApiObjectImpl() {
|
||||
if (mHandle != VK_NULL_HANDLE) {
|
||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||
mHandle = VK_NULL_HANDLE;
|
||||
|
@ -33,6 +33,7 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
private:
|
||||
~Sampler() override;
|
||||
void DestroyApiObjectImpl() override;
|
||||
using SamplerBase::SamplerBase;
|
||||
MaybeError Initialize(const SamplerDescriptor* descriptor);
|
||||
|
||||
|
@ -223,7 +223,9 @@ namespace dawn_native { namespace vulkan {
|
||||
return swapchain;
|
||||
}
|
||||
|
||||
SwapChain::~SwapChain() {
|
||||
SwapChain::~SwapChain() = default;
|
||||
|
||||
void SwapChain::DestroyApiObjectImpl() {
|
||||
DetachFromSurface();
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ namespace dawn_native { namespace vulkan {
|
||||
private:
|
||||
using NewSwapChainBase::NewSwapChainBase;
|
||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
||||
void DestroyApiObjectImpl() override;
|
||||
|
||||
struct Config {
|
||||
// Information that's passed to vulkan swapchain creation.
|
||||
|
Loading…
x
Reference in New Issue
Block a user