2016-08-26 28 views

답변

4

MTLBufferMTLTexture은 Objective-C 개체이므로 참조 카운트됩니다. Objective-C 프로젝트에서 자동 참조 계산을 사용하거나 Swift를 통해 Metal을 사용하는 경우 버퍼 또는 텍스처에 대한 참조를 더 이상 보유하지 않도록하면 관련된 하드웨어 리소스가 해제됩니다.

let texture: MTLTexture? = device.newTexture(with: descriptor) 
texture = nil // <- resources will be released 

하나는 첫번째 [MTLDebugTexture dealloc]

MetalTools`-[MTLDebugTexture dealloc]: 
    ... 
-> 0x100af569e <+34>: call 0x100af87ee    ; symbol stub for: objc_msgSendSuper2 
    0x100af56a3 <+39>: add rsp, 0x10 
    0x100af56a7 <+43>: pop rbp 
    0x100af56a8 <+44>: ret  

로 우리를 인도하는 texturenil를 할당 할 때 관련 어셈블리를 단계별로하여이를 확인 ... 그리고 [MTLToolsObject dealloc]

MetalTools`-[MTLToolsObject dealloc]: 
    0x100ac6c7a <+0>: push rbp 
    0x100ac6c7b <+1>: mov rbp, rsp 
    0x100ac6c7e <+4>: push r14 
    ... 

을 통해 할 수 있습니다. .. 그리고 GeForceMTLDriver를 통해

GeForceMTLDriver`___lldb_unnamed_symbol1095$$GeForceMTLDriver: 
-> 0x7fffd2e57b14 <+0>: push rbp 
    0x7fffd2e57b15 <+1>: mov rbp, rsp 

모든 방법으로 다양한 dealloc 방법을 통해 리소스를 해제합니다.