 }
 
 class EffectRenderer {
+	typealias EffectPrimitive = RegionEffect.EffectPrimitive
+	typealias RenderList = ContiguousArray<EffectPrimitive>
 	static let kMaxSimultaneousEffects = 8
 	let device: MTLDevice
 	let pipeline: MTLRenderPipelineState
 	let instanceUniforms: [MTLBuffer]
 	
 	var runningEffects : [RegionEffect]
+	var renderLists : [RenderList]
+	
 	var animating: Bool { get {
 		return !runningEffects.isEmpty
 	}}

		encoder.setVertexBuffer(instanceUniforms[bufferIndex], offset: 0, index: 2)
		
		var instanceCursor = 0
		for effect in runningEffects {
			encoder.setVertexBufferOffset(instanceCursor, index: 2)
			render(primitive: effect.primitive, into: encoder)
			
			instanceCursor += MemoryLayout<InstanceUniforms>.stride
		}

			self.instanceUniforms = (0..<bufferCount).map { _ in
				return device.makeBuffer(length: EffectRenderer.kMaxSimultaneousEffects * MemoryLayout<InstanceUniforms>.stride, options: .storageModeShared)!
			}
			self.renderLists = Array(repeating: ContiguousArray(), count: bufferCount)
		} catch let error {
			fatalError(error.localizedDescription)
		}
