Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when VkDescriptorSetLayout is destroyed while descriptor set is in use. #2358

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class MVKDescriptorSet : public MVKVulkanAPIDeviceObject {

MVKDescriptorSet(MVKDescriptorPool* pool);

~MVKDescriptorSet() override;

protected:
friend class MVKDescriptorSetLayoutBinding;
friend class MVKDescriptorPool;
Expand Down
6 changes: 6 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
NSUInteger mtlArgBufferOffset,
id<MTLArgumentEncoder> mtlArgEnc) {
_layout = layout;
_layout->retain();
_variableDescriptorCount = variableDescriptorCount;
_argumentBuffer.setArgumentBuffer(_pool->_metalArgumentBuffer, mtlArgBufferOffset, mtlArgEnc);

Expand Down Expand Up @@ -574,6 +575,7 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
}

void MVKDescriptorSet::free(bool isPoolReset) {
if(_layout) { _layout->release(); }
_layout = nullptr;
_dynamicOffsetDescriptorCount = 0;
_variableDescriptorCount = 0;
Expand Down Expand Up @@ -613,6 +615,10 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
free(true);
}

MVKDescriptorSet::~MVKDescriptorSet() {
if(_layout) { _layout->release(); }
}


#pragma mark -
#pragma mark MVKDescriptorTypePool
Expand Down
Loading