     
     func setUniforms (command: DrawCommand, uniformState: UniformState) -> (buffer: Buffer, fragmentOffset: Int, texturesValid: Bool, textures: [Texture]) {
         
-        assert(nativeMetalUniforms == false, "cannot set uniforms for non-GLSL shaders")
-        
         let buffer = command.uniformBufferProvider.nextBuffer()
+
+        if  nativeMetalUniforms {
+            let textures = command.metalUniformUpdateBlock?(buffer: buffer) ?? [Texture]()
+            return (buffer: buffer, fragmentOffset: 0, texturesValid: true, textures: textures)
+        }
+        
         let map = command.uniformMap ?? nullUniformMap
         for uniform in _vertexUniforms {
             setUniform(uniform, buffer: buffer, uniformMap: map, uniformState: uniformState)

        initialize(device, optimizer: optimizer)
    }

    init? (device: MTLDevice,compiledMetalVertexName vertex: String, compiledMetalFragmentName fragment: String, keyword: String) {

        guard let defaultLibrary = device.newDefaultLibrary() else {
            assertionFailure("Could not get default library")
            return nil
        }
        guard let metalVertexFunction = defaultLibrary.newFunctionWithName(vertex) else {
            assertionFailure("No vertex function found for \(vertex)")
            return nil
        }
        self.metalVertexFunction = metalVertexFunction
        guard let metalFragmentFunction = defaultLibrary.newFunctionWithName(fragment) else {
            assertionFailure("No fragment function found for \(fragment)")
            return nil
        }
        self.metalFragmentFunction = metalFragmentFunction
        
        vertexShaderSource = nil
        _vertexShaderText = nil

import Metal
import GLSLOptimizer
import simd

private var _shaderLibrary: MTLLibrary! = nil

class ShaderProgram {
    
