Fix Metal object retain-release errors in assignment operators.

This commit is contained in:
Bill Hollings 2021-12-25 12:58:55 -05:00
parent bc4ce5799c
commit 355bfed457
3 changed files with 13 additions and 6 deletions

View File

@ -22,6 +22,7 @@ Released TBD
- Do not use `MTLEvent` for `VkSemaphore` under *Rosetta2*.
- Support compiling *MSL 2.4* in runtime pipelines and `MoltenVKShaderConverterTool`.
- Fix issue where *MSL 2.3* only available on *Apple Silicon*, even on *macOS*.
- Fix Metal object retain-release errors in assignment operators.
- Update to latest SPIRV-Cross:
- MSL: Add 64 bit support for `OpSwitch`.
- MSL: Don't output depth and stencil values with explicit early fragment tests.

View File

@ -37,8 +37,10 @@ MVKMTLFunction::MVKMTLFunction(const MVKMTLFunction& other) {
}
MVKMTLFunction& MVKMTLFunction::operator=(const MVKMTLFunction& other) {
[_mtlFunction release];
_mtlFunction = [other._mtlFunction retain]; // retained
if (_mtlFunction != other._mtlFunction) {
[_mtlFunction release];
_mtlFunction = [other._mtlFunction retain]; // retained
}
shaderConversionResults = other.shaderConversionResults;
threadGroupSize = other.threadGroupSize;
return *this;
@ -179,9 +181,11 @@ MVKShaderLibrary::MVKShaderLibrary(const MVKShaderLibrary& other) {
}
MVKShaderLibrary& MVKShaderLibrary::operator=(const MVKShaderLibrary& other) {
[_mtlLibrary release];
if (_mtlLibrary != other._mtlLibrary) {
[_mtlLibrary release];
_mtlLibrary = [other._mtlLibrary retain];
}
_owner = other._owner;
_mtlLibrary = [other._mtlLibrary retain];
_shaderConversionResults = other._shaderConversionResults;
_msl = other._msl;
return *this;

View File

@ -66,8 +66,10 @@ MVKVulkanAPIObject::MVKVulkanAPIObject(const MVKVulkanAPIObject& other) {
}
MVKVulkanAPIObject& MVKVulkanAPIObject::operator=(const MVKVulkanAPIObject& other) {
[_debugName release];
_debugName = [other._debugName retain];
if (_debugName != other._debugName) {
[_debugName release];
_debugName = [other._debugName retain];
}
return *this;
}