 
     
     func drawInView(view: MBEMetalView) {
+        dispatch_semaphore_wait(inflightSemaphore, DISPATCH_TIME_FOREVER)
+        
         updateUniforms(view, duration: view.frameDuration)
         
         // MTLTextures are containers for images, where each image is called a slice.


class MBERenderer: MBEMetalViewDelegate {
    
    var device: MTLDevice
    var commandQueue:MTLCommandQueue?
    var pipeline:MTLRenderPipelineState?

    
    init(device: MTLDevice) {
        self.device = device
        inflightSemaphore = dispatch_semaphore_create(kInFlightCommandBufferes)
        makePipeline()
        makeBuffers()
    }
