mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Add scoped autoreleasepool to tests and examples
This ensures ObjC objects do not leak. On non-Apple platforms, the scope does nothing. Fixed: dawn:546 Change-Id: Id43702e6536bf9cb37825a5449511e10cf0734f5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55841 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
@@ -61,7 +61,7 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
// The encoder is created autoreleased. Retain it to avoid the autoreleasepool from
|
||||
// draining from under us.
|
||||
mBlit = [*mCommands blitCommandEncoder];
|
||||
mBlit.Acquire([[*mCommands blitCommandEncoder] retain]);
|
||||
}
|
||||
return mBlit.Get();
|
||||
}
|
||||
@@ -82,9 +82,9 @@ namespace dawn_native { namespace metal {
|
||||
ASSERT(!mInEncoder);
|
||||
|
||||
mInEncoder = true;
|
||||
// The encoder is created autoreleased. Retain it to avoid the autoreleasepool from draining
|
||||
// from under us.
|
||||
mCompute = [*mCommands computeCommandEncoder];
|
||||
// The encoder is created autoreleased. Retain it to avoid the autoreleasepool from
|
||||
// draining from under us.
|
||||
mCompute.Acquire([[*mCommands computeCommandEncoder] retain]);
|
||||
return mCompute.Get();
|
||||
}
|
||||
|
||||
@@ -104,9 +104,9 @@ namespace dawn_native { namespace metal {
|
||||
ASSERT(!mInEncoder);
|
||||
|
||||
mInEncoder = true;
|
||||
// The encoder is created autoreleased. Retain it to avoid the autoreleasepool from draining
|
||||
// from under us.
|
||||
mRender = [*mCommands renderCommandEncoderWithDescriptor:descriptor];
|
||||
// The encoder is created autoreleased. Retain it to avoid the autoreleasepool from
|
||||
// draining from under us.
|
||||
mRender.Acquire([[*mCommands renderCommandEncoderWithDescriptor:descriptor] retain]);
|
||||
return mRender.Get();
|
||||
}
|
||||
|
||||
|
||||
@@ -308,7 +308,8 @@ namespace dawn_native { namespace metal {
|
||||
// The MTLCommandBuffer will be autoreleased by default.
|
||||
// The autorelease pool may drain before the command buffer is submitted. Retain so it
|
||||
// stays alive.
|
||||
mCommandContext = CommandRecordingContext([*mCommandQueue commandBuffer]);
|
||||
mCommandContext =
|
||||
CommandRecordingContext(AcquireNSPRef([[*mCommandQueue commandBuffer] retain]));
|
||||
}
|
||||
return &mCommandContext;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user