 
 import Metal
 
-let inflightBuffersCountDefault = 3 // three is magic number
-
 // N.B. planning on always accessing Buffer via BufferProvider (and MTLBuffer via Buffer)
 // - so that interface is consistent and so that stuff can easily be built on top of one thing
 

    func createBuffer(device: MTLDevice, bytecount: Int, options: MTLResourceOptions, createWith: (Self) -> EncodableBuffer) -> EncodableBuffer {
        return createWith(self)
    }
}

class BaseBufferPool: BufferPool {

    func prepareBufferPool(device: MTLDevice, bytecount: Int, options: MTLResourceOptions, createWith: (Self) -> EncodableBuffer)
    func createBuffer(device: MTLDevice, bytecount: Int, options: MTLResourceOptions) -> EncodableBuffer
    func createBuffer(device: MTLDevice, bytecount: Int, options: MTLResourceOptions, createWith: (Self) -> EncodableBuffer) -> EncodableBuffer
    
    func getBuffer() -> EncodableBuffer
    func getBuffer(bufferIndex: Int) -> EncodableBuffer
}

//TODO: must dispatch_semaphore_signal from view render() !!!

extension BufferPool {
    func prepareBufferPool(device: MTLDevice, bytecount: Int, options: MTLResourceOptions = .CPUCacheModeDefaultCache) {
        for _ in 0...buffersCount-1 {
            let buffer = createBuffer(device, bytecount: self.bytecount, options: options)
            buffers.append(buffer)
