[Commits] SDL: metal: Cleaned up some reference count politics.

libsdl.org revision control commits-owner at libsdl.org
Fri Dec 8 15:26:35 PST 2017


details:   https://hg.libsdl.org/SDL/rev/17cc18a8dd5b
changeset: 11746:17cc18a8dd5b
user:      Ryan C. Gordon <icculus at icculus.org>
date:      Fri Dec 08 18:26:26 2017 -0500
description:
metal: Cleaned up some reference count politics.

diffstat:

 src/render/metal/SDL_render_metal.m |  24 ++++++------------------
 1 files changed, 6 insertions(+), 18 deletions(-)

diffs (64 lines):

diff -r bb8a8a1996d1 -r 17cc18a8dd5b src/render/metal/SDL_render_metal.m
--- a/src/render/metal/SDL_render_metal.m	Fri Dec 08 17:43:57 2017 -0500
+++ b/src/render/metal/SDL_render_metal.m	Fri Dec 08 18:26:26 2017 -0500
@@ -394,14 +394,10 @@
         default: return SDL_SetError("Texture format %s not supported by Metal", SDL_GetPixelFormatName(texture->format));
     }
 
-    // !!! FIXME: autorelease or nah?
     MTLTextureDescriptor *mtltexdesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:mtlpixfmt
                                             width:(NSUInteger)texture->w height:(NSUInteger)texture->h mipmapped:NO];
 
     id<MTLTexture> mtltexture = [data.mtldevice newTextureWithDescriptor:mtltexdesc];
-#if !__has_feature(objc_arc)
-    [mtltexdesc release];
-#endif
     if (mtltexture == nil) {
         return SDL_SetError("Texture allocation failed");
     }
@@ -734,11 +730,6 @@
     [data.mtlcmdencoder endEncoding];
     [data.mtlcmdbuffer presentDrawable:data.mtlbackbuffer];
     [data.mtlcmdbuffer commit];
-#if !__has_feature(objc_arc)
-    [data.mtlcmdencoder release];
-    [data.mtlcmdbuffer release];
-    [data.mtlbackbuffer release];
-#endif
     data.mtlcmdencoder = nil;
     data.mtlcmdbuffer = nil;
     data.mtlbackbuffer = nil;
@@ -761,17 +752,14 @@
     if (renderer->driverdata) {
         METAL_RenderData *data = CFBridgingRelease(renderer->driverdata);
 
-#if !__has_feature(objc_arc)
-        if (data.mtlbackbuffer != nil) {
-            [data.mtlbackbuffer release];
-        }
         if (data.mtlcmdencoder != nil) {
             [data.mtlcmdencoder endEncoding];
-            [data.mtlcmdencoder release];
         }
-        if (data.mtlcmdbuffer != nil) {
-            [data.mtlcmdbuffer release];
-        }
+
+#if !__has_feature(objc_arc)
+        [data.mtlbackbuffer release];
+        [data.mtlcmdencoder release];
+        [data.mtlcmdbuffer release];
         [data.mtlcmdqueue release];
         for (int i = 0; i < 4; i++) {
             [data.mtlpipelineprims[i] release];
@@ -784,9 +772,9 @@
         [data.mtldevice release];
         [data.mtlpassdesc release];
         [data.mtllayer release];
-        [data release];
 #endif
     }
+
     SDL_free(renderer);
 }}
 


More information about the commits mailing list