Minor cleanup
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m
index 9fb3de4..2395342 100644
--- a/src/render/metal/SDL_render_metal.m
+++ b/src/render/metal/SDL_render_metal.m
@@ -726,20 +726,18 @@ METAL_RenderPresent(SDL_Renderer * renderer)
{
METAL_ActivateRenderer(renderer);
METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
- id<CAMetalDrawable> mtlbackbuffer = data.mtlbackbuffer;
[data.mtlcmdencoder endEncoding];
- [data.mtlcmdbuffer presentDrawable:mtlbackbuffer];
-#if !__has_feature(objc_arc)
- [data.mtlcmdbuffer addCompletedHandler:^(id <MTLCommandBuffer> mtlcmdbuffer) {
- [mtlbackbuffer release];
- }];
-#endif
+ [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;
data.beginScene = YES;
}
@@ -760,15 +758,23 @@ METAL_DestroyRenderer(SDL_Renderer * renderer)
METAL_RenderData *data = CFBridgingRelease(renderer->driverdata);
#if !__has_feature(objc_arc)
- int i;
- [data.mtlcmdencoder endEncoding];
- [data.mtlcmdencoder release];
- [data.mtlcmdbuffer release];
+ if (data.mtlbackbuffer != nil) {
+ [data.mtlbackbuffer release];
+ }
+ if (data.mtlcmdencoder != nil) {
+ [data.mtlcmdencoder endEncoding];
+ [data.mtlcmdencoder release];
+ }
+ if (data.mtlcmdbuffer != nil) {
+ [data.mtlcmdbuffer release];
+ }
[data.mtlcmdqueue release];
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
[data.mtlpipelineprims[i] release];
[data.mtlpipelinecopy[i] release];
}
+ [data.mtlpipelineprims release];
+ [data.mtlpipelinecopy release];
[data.mtlbufclearverts release];
[data.mtllibrary release];
[data.mtldevice release];