src/render/metal/SDL_render_metal.m
changeset 11741 e7d5d4ae2e73
parent 11740 24c1d2de7a09
child 11742 971cd689bd96
equal deleted inserted replaced
11740:24c1d2de7a09 11741:e7d5d4ae2e73
   724 static void
   724 static void
   725 METAL_RenderPresent(SDL_Renderer * renderer)
   725 METAL_RenderPresent(SDL_Renderer * renderer)
   726 {
   726 {
   727     METAL_ActivateRenderer(renderer);
   727     METAL_ActivateRenderer(renderer);
   728     METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
   728     METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
   729     id<CAMetalDrawable> mtlbackbuffer = data.mtlbackbuffer;
       
   730 
   729 
   731     [data.mtlcmdencoder endEncoding];
   730     [data.mtlcmdencoder endEncoding];
   732     [data.mtlcmdbuffer presentDrawable:mtlbackbuffer];
   731     [data.mtlcmdbuffer presentDrawable:data.mtlbackbuffer];
   733 #if !__has_feature(objc_arc)
       
   734     [data.mtlcmdbuffer addCompletedHandler:^(id <MTLCommandBuffer> mtlcmdbuffer) {
       
   735         [mtlbackbuffer release];
       
   736     }];
       
   737 #endif
       
   738     [data.mtlcmdbuffer commit];
   732     [data.mtlcmdbuffer commit];
   739 #if !__has_feature(objc_arc)
   733 #if !__has_feature(objc_arc)
   740     [data.mtlcmdencoder release];
   734     [data.mtlcmdencoder release];
   741     [data.mtlcmdbuffer release];
   735     [data.mtlcmdbuffer release];
   742 #endif
   736     [data.mtlbackbuffer release];
       
   737 #endif
       
   738     data.mtlcmdencoder = nil;
       
   739     data.mtlcmdbuffer = nil;
       
   740     data.mtlbackbuffer = nil;
   743     data.beginScene = YES;
   741     data.beginScene = YES;
   744 }
   742 }
   745 
   743 
   746 static void
   744 static void
   747 METAL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   745 METAL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   758 {
   756 {
   759     if (renderer->driverdata) {
   757     if (renderer->driverdata) {
   760         METAL_RenderData *data = CFBridgingRelease(renderer->driverdata);
   758         METAL_RenderData *data = CFBridgingRelease(renderer->driverdata);
   761 
   759 
   762 #if !__has_feature(objc_arc)
   760 #if !__has_feature(objc_arc)
   763         int i;
   761         if (data.mtlbackbuffer != nil) {
   764         [data.mtlcmdencoder endEncoding];
   762             [data.mtlbackbuffer release];
   765         [data.mtlcmdencoder release];
   763         }
   766         [data.mtlcmdbuffer release];
   764         if (data.mtlcmdencoder != nil) {
       
   765             [data.mtlcmdencoder endEncoding];
       
   766             [data.mtlcmdencoder release];
       
   767         }
       
   768         if (data.mtlcmdbuffer != nil) {
       
   769             [data.mtlcmdbuffer release];
       
   770         }
   767         [data.mtlcmdqueue release];
   771         [data.mtlcmdqueue release];
   768         for (i = 0; i < 4; i++) {
   772         for (int i = 0; i < 4; i++) {
   769             [data.mtlpipelineprims[i] release];
   773             [data.mtlpipelineprims[i] release];
   770             [data.mtlpipelinecopy[i] release];
   774             [data.mtlpipelinecopy[i] release];
   771         }
   775         }
       
   776         [data.mtlpipelineprims release];
       
   777         [data.mtlpipelinecopy release];
   772         [data.mtlbufclearverts release];
   778         [data.mtlbufclearverts release];
   773         [data.mtllibrary release];
   779         [data.mtllibrary release];
   774         [data.mtldevice release];
   780         [data.mtldevice release];
   775         [data.mtlpassdesc release];
   781         [data.mtlpassdesc release];
   776         [data.mtllayer release];
   782         [data.mtllayer release];