diff --git a/ios/graphics/Model/MultiBuffer.swift b/ios/graphics/Model/MultiBuffer.swift index 007599241..e05239ce5 100644 --- a/ios/graphics/Model/MultiBuffer.swift +++ b/ios/graphics/Model/MultiBuffer.swift @@ -8,14 +8,10 @@ import Metal import simd -private let bufferCount = 3 // Triple buffering - public struct MultiBuffer { // Warning: Seems like suited to be generic // But makeBuffer &reference does not like generic data var buffers: [MTLBuffer] - var currentBufferIndex = 0 - var currentFrameId = -1 fileprivate init(buffers: [MTLBuffer]) { self.buffers = buffers @@ -24,21 +20,15 @@ public struct MultiBuffer { public mutating func getNextBuffer(_ context: RenderingContext) -> MTLBuffer? { - if context.frameId != currentFrameId { - currentBufferIndex = (currentBufferIndex + 1) % bufferCount - currentFrameId = context.frameId - } - guard currentBufferIndex < buffers.count else { - return nil - } - return buffers[currentBufferIndex] + return buffers[context.currentBufferIndex] } } extension MultiBuffer { public init(device: MTLDevice) { var initialMutable = simd_float1(1.0) - let buffers: [MTLBuffer] = (0.. { extension MultiBuffer { public init(device: MTLDevice) { var initialMutable = simd_float4(0.0, 0.0, 0.0, 0.0) - let buffers: [MTLBuffer] = (0.. { extension MultiBuffer { public init(device: MTLDevice) { var initialMutable = simd_float4x4(1.0) - let buffers: [MTLBuffer] = (0..