     }
     
     func setVideoFilter(filterPasses:[String], usesBlur:Bool = true) {
-        _currentVideoFilter.removeAll(keepCapacity: true)
         println("Setting filter...")
-        _currentVideoFilter.extend(filterPasses.map({self.cachedPipelineStateFor($0)!}))
+        _currentVideoFilter = filterPasses.map({self.cachedPipelineStateFor($0)!})
         _currentVideoFilterUsesBlur = usesBlur
     }
     

        print("Setting offscreen texure resolution to \(textureWidth)x\(textureHeight)\n")
        
        let descriptor = MTLTextureDescriptor.texture2DDescriptorWithPixelFormat(.BGRA8Unorm, width: textureWidth, height: textureHeight, mipmapped: false)
        _intermediateTextures.removeAll(keepCapacity: true)
        _intermediateRenderPassDescriptor.removeAll(keepCapacity: true)
        for i in (0...1) {
            let texture = _device.newTextureWithDescriptor(descriptor)
            let renderDescriptor = MTLRenderPassDescriptor()
            renderDescriptor.colorAttachments[0].texture = texture
            renderDescriptor.colorAttachments[0].loadAction = .DontCare
            renderDescriptor.colorAttachments[0].storeAction = .DontCare
            
            _intermediateTextures.append(texture)
            _intermediateRenderPassDescriptor.append(renderDescriptor)
        }

        _rgbTexture = _device.newTextureWithDescriptor(descriptor)
        _rgbDescriptor = MTLRenderPassDescriptor()
        _rgbDescriptor.colorAttachments[0].texture = _rgbTexture

                    renderEncoder.setViewport(view)
                }
                renderEncoder.setRenderPipelineState(pipeline)
                
                for (index,(buffer, offset)) in enumerate(vertexBuffers) {
                    renderEncoder.setVertexBuffer(buffer, offset: offset, atIndex: index)
                }
                for (index,(buffer, offset)) in enumerate(fragmentBuffers) {
                    renderEncoder.setFragmentBuffer(buffer, offset: offset, atIndex: index)
                }
                for (index,texture) in enumerate(sourceTextures) {
                    renderEncoder.setFragmentTexture(texture, atIndex: index)
                }
                for (index,samplerState) in enumerate(_samplerStates) {
                    renderEncoder.setFragmentSamplerState(samplerState, atIndex: index)
                }
                
                renderEncoder.drawPrimitives(.Triangle, vertexStart: 0, vertexCount: 6, instanceCount: 1)
                renderEncoder.popDebugGroup()
                renderEncoder.endEncoding()
