src/render/metal/SDL_render_metal.m
changeset 11741 e7d5d4ae2e73
parent 11740 24c1d2de7a09
child 11742 971cd689bd96
     1.1 --- a/src/render/metal/SDL_render_metal.m	Fri Dec 08 11:35:19 2017 -0800
     1.2 +++ b/src/render/metal/SDL_render_metal.m	Fri Dec 08 12:02:23 2017 -0800
     1.3 @@ -726,20 +726,18 @@
     1.4  {
     1.5      METAL_ActivateRenderer(renderer);
     1.6      METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
     1.7 -    id<CAMetalDrawable> mtlbackbuffer = data.mtlbackbuffer;
     1.8  
     1.9      [data.mtlcmdencoder endEncoding];
    1.10 -    [data.mtlcmdbuffer presentDrawable:mtlbackbuffer];
    1.11 -#if !__has_feature(objc_arc)
    1.12 -    [data.mtlcmdbuffer addCompletedHandler:^(id <MTLCommandBuffer> mtlcmdbuffer) {
    1.13 -        [mtlbackbuffer release];
    1.14 -    }];
    1.15 -#endif
    1.16 +    [data.mtlcmdbuffer presentDrawable:data.mtlbackbuffer];
    1.17      [data.mtlcmdbuffer commit];
    1.18  #if !__has_feature(objc_arc)
    1.19      [data.mtlcmdencoder release];
    1.20      [data.mtlcmdbuffer release];
    1.21 +    [data.mtlbackbuffer release];
    1.22  #endif
    1.23 +    data.mtlcmdencoder = nil;
    1.24 +    data.mtlcmdbuffer = nil;
    1.25 +    data.mtlbackbuffer = nil;
    1.26      data.beginScene = YES;
    1.27  }
    1.28  
    1.29 @@ -760,15 +758,23 @@
    1.30          METAL_RenderData *data = CFBridgingRelease(renderer->driverdata);
    1.31  
    1.32  #if !__has_feature(objc_arc)
    1.33 -        int i;
    1.34 -        [data.mtlcmdencoder endEncoding];
    1.35 -        [data.mtlcmdencoder release];
    1.36 -        [data.mtlcmdbuffer release];
    1.37 +        if (data.mtlbackbuffer != nil) {
    1.38 +            [data.mtlbackbuffer release];
    1.39 +        }
    1.40 +        if (data.mtlcmdencoder != nil) {
    1.41 +            [data.mtlcmdencoder endEncoding];
    1.42 +            [data.mtlcmdencoder release];
    1.43 +        }
    1.44 +        if (data.mtlcmdbuffer != nil) {
    1.45 +            [data.mtlcmdbuffer release];
    1.46 +        }
    1.47          [data.mtlcmdqueue release];
    1.48 -        for (i = 0; i < 4; i++) {
    1.49 +        for (int i = 0; i < 4; i++) {
    1.50              [data.mtlpipelineprims[i] release];
    1.51              [data.mtlpipelinecopy[i] release];
    1.52          }
    1.53 +        [data.mtlpipelineprims release];
    1.54 +        [data.mtlpipelinecopy release];
    1.55          [data.mtlbufclearverts release];
    1.56          [data.mtllibrary release];
    1.57          [data.mtldevice release];