diff --git a/plume_metal.cpp b/plume_metal.cpp index fd27894..302cce2 100644 --- a/plume_metal.cpp +++ b/plume_metal.cpp @@ -1196,8 +1196,6 @@ namespace plume { // Create texture with configured descriptor and alignment MTL::TextureDescriptor *descriptor = MTL::TextureDescriptor::textureBufferDescriptor(pixelFormat, width, options, usage); this->texture = buffer->mtl->newTexture(descriptor, 0, bytesPerRow); - - descriptor->release(); } MetalBufferFormattedView::~MetalBufferFormattedView() { @@ -2238,7 +2236,9 @@ namespace plume { } MetalCommandList::~MetalCommandList() { - mtl->release(); + if (mtl != nullptr) { + mtl->release(); + } for (auto& fenceSet : fences) { for (auto* fence : fenceSet) { @@ -2253,6 +2253,7 @@ namespace plume { assert(mtl == nullptr); startedEncoding = false; mtl = queue->mtl->commandBufferWithUnretainedReferences(); + mtl->retain(); mtl->setLabel(MTLSTR("RT64 Command List")); // Reset fence waits and updates for new command list. @@ -3551,6 +3552,7 @@ namespace plume { if (activeBlitEncoder == nullptr) { activeBlitEncoder = mtl->blitCommandEncoder(device->sharedBlitDescriptor); activeBlitEncoder->setLabel(MTLSTR("Copy Blit Encoder")); + activeBlitEncoder->retain(); startedEncoding = true;