       //print("capture", captureOutput)
     }
   }
-  
-  /*
-  func render(metalTexture:CVMetalTexture) {
-    guard let drawable = metalLayer.nextDrawable(),
-      let pipelineState = self.pipelineState,
-      let commandBuffer = commandQueue?.makeCommandBuffer(),
-      let texture = CVMetalTextureGetTexture(metalTexture) else {
-        print("something is wrong")
-        return
-    }
-    
-    let renderPassDescriptor = MTLRenderPassDescriptor()
-    renderPassDescriptor.colorAttachments[0].texture = drawable.texture
-    renderPassDescriptor.colorAttachments[0].loadAction = .clear
-    renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor(red: 0.0, green: 104.0/255.0, blue: 5.0/255.0, alpha: 1.0)
-    
-    let renderEncoder = commandBuffer.makeRenderCommandEncoder(descriptor: renderPassDescriptor)
-    renderEncoder.setRenderPipelineState(pipelineState)
-    renderEncoder.setVertexBuffer(vertexBuffer, offset: 0, at: 0)
-    renderEncoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: 3, instanceCount: 1)
-    renderEncoder.setFragmentTexture(texture, at: 0)
-    renderEncoder.endEncoding()
-    
-    commandBuffer.present(drawable)
-    commandBuffer.commit()
-    print("render", texture)
-  }
-  */
 }
 
 

    super.viewDidLoad()
    
    if let mtkView = self.view as? MTKView {
        mtkView.device = MTLCreateSystemDefaultDevice()
        renderer = VSRenderer(view: mtkView)
        renderer?.mtkView(mtkView, drawableSizeWillChange: mtkView.drawableSize)
        mtkView.delegate = renderer

    CVMetalTextureCacheCreate(nil, nil, VideoSessionController.device, nil, &cache)
    return cache!
  }()
  
  // Debug only for Metal
  let vertexData:[Float] = [ -1.0, -1.0,  0.0, 1.0,
