 private var MTLCommandQueueCache: [NSObject: MTLCommandQueue] = [:]
 
 @available(OSX 10.13, iOS 11.0, *)
-private let command_encoder_limit = 4
-
-@available(OSX 10.13, iOS 11.0, *)
-private let stencil_buffer_limit = 4
+private let command_encoder_limit = 32
+
+@available(OSX 10.13, iOS 11.0, *)
+private let stencil_buffer_limit = 16
 
 @available(OSX 10.13, iOS 11.0, *)
 class MetalRenderer<Model : ColorModelProtocol> : DGRenderer {

        let encoder = try self.makeComputeCommandEncoder()
        guard let _buffer = device.makeBuffer(buffer) else { throw MetalRenderer.Error(description: "MTLDevice.makeBuffer failed.") }
        
        let pipeline = try renderer.request_pipeline("stencil_triangle")
        encoder.setComputePipelineState(pipeline)
        
        encoder.setValues(UInt32(offset_x), UInt32(offset_y), UInt32(width), index: 0)

@available(OSX 10.13, iOS 11.0, *)
extension MetalRenderer.Encoder {
    
    private func render_stencil<T>(width: Int, height: Int, pipeline: String, bound: Rect?, buffer: MappedBuffer<T>, output: MTLBuffer) throws {
        
        guard let bound = bound, buffer.count != 0 else { return }
        
        let offset_x = max(0, min(width - 1, Int(floor(bound.x))))
        let offset_y = max(0, min(height - 1, Int(floor(bound.y))))
