mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-07 07:03:42 +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);
|
ToBackend(GetLayout())->DeallocateBindGroup(this, &mCPUViewAllocation);
|
||||||
ASSERT(!mCPUViewAllocation.IsValid());
|
ASSERT(!mCPUViewAllocation.IsValid());
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
private:
|
private:
|
||||||
~BindGroup() override;
|
~BindGroup() override;
|
||||||
|
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
Ref<SamplerHeapCacheEntry> mSamplerAllocationEntry;
|
Ref<SamplerHeapCacheEntry> mSamplerAllocationEntry;
|
||||||
|
|
||||||
GPUDescriptorHeapAllocation mGPUViewAllocation;
|
GPUDescriptorHeapAllocation mGPUViewAllocation;
|
||||||
|
@ -62,7 +62,9 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputePipeline::~ComputePipeline() {
|
ComputePipeline::~ComputePipeline() = default;
|
||||||
|
|
||||||
|
void ComputePipeline::DestroyApiObjectImpl() {
|
||||||
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,9 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~ComputePipeline() override;
|
~ComputePipeline() override;
|
||||||
|
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
using ComputePipelineBase::ComputePipelineBase;
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
ComPtr<ID3D12PipelineState> mPipelineState;
|
ComPtr<ID3D12PipelineState> mPipelineState;
|
||||||
};
|
};
|
||||||
|
@ -417,7 +417,9 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPipeline::~RenderPipeline() {
|
RenderPipeline::~RenderPipeline() = default;
|
||||||
|
|
||||||
|
void RenderPipeline::DestroyApiObjectImpl() {
|
||||||
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,9 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~RenderPipeline() override;
|
~RenderPipeline() override;
|
||||||
|
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
using RenderPipelineBase::RenderPipelineBase;
|
using RenderPipelineBase::RenderPipelineBase;
|
||||||
D3D12_INPUT_LAYOUT_DESC ComputeInputLayout(
|
D3D12_INPUT_LAYOUT_DESC ComputeInputLayout(
|
||||||
std::array<D3D12_INPUT_ELEMENT_DESC, kMaxVertexAttributes>* inputElementDescriptors);
|
std::array<D3D12_INPUT_ELEMENT_DESC, kMaxVertexAttributes>* inputElementDescriptors);
|
||||||
|
@ -141,7 +141,9 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
return swapchain;
|
return swapchain;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwapChain::~SwapChain() {
|
SwapChain::~SwapChain() = default;
|
||||||
|
|
||||||
|
void SwapChain::DestroyApiObjectImpl() {
|
||||||
DetachFromSurface();
|
DetachFromSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,8 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
private:
|
private:
|
||||||
~SwapChain() override;
|
~SwapChain() override;
|
||||||
|
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using NewSwapChainBase::NewSwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~BindGroup() override;
|
~BindGroup() override;
|
||||||
|
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::metal
|
}} // namespace dawn_native::metal
|
||||||
|
@ -22,7 +22,9 @@ namespace dawn_native { namespace metal {
|
|||||||
: BindGroupBase(this, device, descriptor) {
|
: BindGroupBase(this, device, descriptor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BindGroup::~BindGroup() {
|
BindGroup::~BindGroup() = default;
|
||||||
|
|
||||||
|
void BindGroup::DestroyApiObjectImpl() {
|
||||||
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ namespace dawn_native { namespace metal {
|
|||||||
~SwapChain() override;
|
~SwapChain() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using NewSwapChainBase::NewSwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
||||||
|
|
||||||
|
@ -73,7 +73,9 @@ namespace dawn_native { namespace metal {
|
|||||||
return swapchain;
|
return swapchain;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwapChain::~SwapChain() {
|
SwapChain::~SwapChain() = default;
|
||||||
|
|
||||||
|
void SwapChain::DestroyApiObjectImpl() {
|
||||||
DetachFromSurface();
|
DetachFromSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,9 @@ namespace dawn_native { namespace opengl {
|
|||||||
: BindGroupBase(this, device, descriptor) {
|
: BindGroupBase(this, device, descriptor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BindGroup::~BindGroup() {
|
BindGroup::~BindGroup() = default;
|
||||||
|
|
||||||
|
void BindGroup::DestroyApiObjectImpl() {
|
||||||
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ namespace dawn_native { namespace opengl {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~BindGroup() override;
|
~BindGroup() override;
|
||||||
|
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::opengl
|
}} // namespace dawn_native::opengl
|
||||||
|
@ -25,7 +25,9 @@ namespace dawn_native { namespace opengl {
|
|||||||
return AcquireRef(new ComputePipeline(device, descriptor));
|
return AcquireRef(new ComputePipeline(device, descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputePipeline::~ComputePipeline() {
|
ComputePipeline::~ComputePipeline() = default;
|
||||||
|
|
||||||
|
void ComputePipeline::DestroyApiObjectImpl() {
|
||||||
DeleteProgram(ToBackend(GetDevice())->gl);
|
DeleteProgram(ToBackend(GetDevice())->gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ namespace dawn_native { namespace opengl {
|
|||||||
private:
|
private:
|
||||||
using ComputePipelineBase::ComputePipelineBase;
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
~ComputePipeline() override;
|
~ComputePipeline() override;
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::opengl
|
}} // namespace dawn_native::opengl
|
||||||
|
@ -234,7 +234,9 @@ namespace dawn_native { namespace opengl {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPipeline::~RenderPipeline() {
|
RenderPipeline::~RenderPipeline() = default;
|
||||||
|
|
||||||
|
void RenderPipeline::DestroyApiObjectImpl() {
|
||||||
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||||
gl.DeleteVertexArrays(1, &mVertexArrayObject);
|
gl.DeleteVertexArrays(1, &mVertexArrayObject);
|
||||||
gl.BindVertexArray(0);
|
gl.BindVertexArray(0);
|
||||||
|
@ -43,6 +43,7 @@ namespace dawn_native { namespace opengl {
|
|||||||
private:
|
private:
|
||||||
RenderPipeline(Device* device, const RenderPipelineDescriptor* descriptor);
|
RenderPipeline(Device* device, const RenderPipelineDescriptor* descriptor);
|
||||||
~RenderPipeline() override;
|
~RenderPipeline() override;
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
void CreateVAOForVertexState();
|
void CreateVAOForVertexState();
|
||||||
|
|
||||||
|
@ -76,7 +76,9 @@ namespace dawn_native { namespace opengl {
|
|||||||
SetupGLSampler(mNonFilteringHandle, descriptor, true);
|
SetupGLSampler(mNonFilteringHandle, descriptor, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sampler::~Sampler() {
|
Sampler::~Sampler() = default;
|
||||||
|
|
||||||
|
void Sampler::DestroyApiObjectImpl() {
|
||||||
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||||
gl.DeleteSamplers(1, &mFilteringHandle);
|
gl.DeleteSamplers(1, &mFilteringHandle);
|
||||||
gl.DeleteSamplers(1, &mNonFilteringHandle);
|
gl.DeleteSamplers(1, &mNonFilteringHandle);
|
||||||
|
@ -32,6 +32,7 @@ namespace dawn_native { namespace opengl {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~Sampler() override;
|
~Sampler() override;
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
void SetupGLSampler(GLuint sampler, const SamplerDescriptor* descriptor, bool forceNearest);
|
void SetupGLSampler(GLuint sampler, const SamplerDescriptor* descriptor, bool forceNearest);
|
||||||
|
|
||||||
|
@ -158,7 +158,9 @@ namespace dawn_native { namespace vulkan {
|
|||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
BindGroup::~BindGroup() {
|
BindGroup::~BindGroup() = default;
|
||||||
|
|
||||||
|
void BindGroup::DestroyApiObjectImpl() {
|
||||||
ToBackend(GetLayout())->DeallocateBindGroup(this, &mDescriptorSetAllocation);
|
ToBackend(GetLayout())->DeallocateBindGroup(this, &mDescriptorSetAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
private:
|
private:
|
||||||
~BindGroup() override;
|
~BindGroup() override;
|
||||||
|
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
// The descriptor set in this allocation outlives the BindGroup because it is owned by
|
// The descriptor set in this allocation outlives the BindGroup because it is owned by
|
||||||
// the BindGroupLayout which is referenced by the BindGroup.
|
// the BindGroupLayout which is referenced by the BindGroup.
|
||||||
DescriptorSetAllocation mDescriptorSetAllocation;
|
DescriptorSetAllocation mDescriptorSetAllocation;
|
||||||
|
@ -89,7 +89,9 @@ namespace dawn_native { namespace vulkan {
|
|||||||
reinterpret_cast<uint64_t&>(mHandle), "Dawn_ComputePipeline", GetLabel());
|
reinterpret_cast<uint64_t&>(mHandle), "Dawn_ComputePipeline", GetLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputePipeline::~ComputePipeline() {
|
ComputePipeline::~ComputePipeline() = default;
|
||||||
|
|
||||||
|
void ComputePipeline::DestroyApiObjectImpl() {
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||||
mHandle = VK_NULL_HANDLE;
|
mHandle = VK_NULL_HANDLE;
|
||||||
|
@ -42,6 +42,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~ComputePipeline() override;
|
~ComputePipeline() override;
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
using ComputePipelineBase::ComputePipelineBase;
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
|
|
||||||
VkPipeline mHandle = VK_NULL_HANDLE;
|
VkPipeline mHandle = VK_NULL_HANDLE;
|
||||||
|
@ -57,7 +57,9 @@ namespace dawn_native { namespace vulkan {
|
|||||||
"CreatePipelineLayout");
|
"CreatePipelineLayout");
|
||||||
}
|
}
|
||||||
|
|
||||||
PipelineLayout::~PipelineLayout() {
|
PipelineLayout::~PipelineLayout() = default;
|
||||||
|
|
||||||
|
void PipelineLayout::DestroyApiObjectImpl() {
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||||
mHandle = VK_NULL_HANDLE;
|
mHandle = VK_NULL_HANDLE;
|
||||||
|
@ -34,6 +34,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~PipelineLayout() override;
|
~PipelineLayout() override;
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
using PipelineLayoutBase::PipelineLayoutBase;
|
using PipelineLayoutBase::PipelineLayoutBase;
|
||||||
MaybeError Initialize();
|
MaybeError Initialize();
|
||||||
|
|
||||||
|
@ -599,7 +599,9 @@ namespace dawn_native { namespace vulkan {
|
|||||||
return createInfo;
|
return createInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPipeline::~RenderPipeline() {
|
RenderPipeline::~RenderPipeline() = default;
|
||||||
|
|
||||||
|
void RenderPipeline::DestroyApiObjectImpl() {
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||||
mHandle = VK_NULL_HANDLE;
|
mHandle = VK_NULL_HANDLE;
|
||||||
|
@ -41,6 +41,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~RenderPipeline() override;
|
~RenderPipeline() override;
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
using RenderPipelineBase::RenderPipelineBase;
|
using RenderPipelineBase::RenderPipelineBase;
|
||||||
|
|
||||||
struct PipelineVertexInputStateCreateInfoTemporaryAllocations {
|
struct PipelineVertexInputStateCreateInfoTemporaryAllocations {
|
||||||
|
@ -105,7 +105,9 @@ namespace dawn_native { namespace vulkan {
|
|||||||
"CreateSampler");
|
"CreateSampler");
|
||||||
}
|
}
|
||||||
|
|
||||||
Sampler::~Sampler() {
|
Sampler::~Sampler() = default;
|
||||||
|
|
||||||
|
void Sampler::DestroyApiObjectImpl() {
|
||||||
if (mHandle != VK_NULL_HANDLE) {
|
if (mHandle != VK_NULL_HANDLE) {
|
||||||
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
|
||||||
mHandle = VK_NULL_HANDLE;
|
mHandle = VK_NULL_HANDLE;
|
||||||
|
@ -33,6 +33,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~Sampler() override;
|
~Sampler() override;
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
using SamplerBase::SamplerBase;
|
using SamplerBase::SamplerBase;
|
||||||
MaybeError Initialize(const SamplerDescriptor* descriptor);
|
MaybeError Initialize(const SamplerDescriptor* descriptor);
|
||||||
|
|
||||||
|
@ -223,7 +223,9 @@ namespace dawn_native { namespace vulkan {
|
|||||||
return swapchain;
|
return swapchain;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwapChain::~SwapChain() {
|
SwapChain::~SwapChain() = default;
|
||||||
|
|
||||||
|
void SwapChain::DestroyApiObjectImpl() {
|
||||||
DetachFromSurface();
|
DetachFromSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
private:
|
private:
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using NewSwapChainBase::NewSwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
||||||
|
void DestroyApiObjectImpl() override;
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
// Information that's passed to vulkan swapchain creation.
|
// Information that's passed to vulkan swapchain creation.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user