         var need_to_render: [Block] = []
         var blocks: [(Block, (MTLTexture, Int, Int))] = []
         
-        let _minX = minX / blockSize * blockSize
-        let _minY = minY / blockSize * blockSize - blockSize
-        
-        for y in stride(from: _minY, to: maxY, by: blockSize) {
-            for x in stride(from: _minX, to: maxX, by: blockSize) {
+        for y in stride(from: minY / blockSize * blockSize - blockSize, to: maxY, by: blockSize) {
+            for x in stride(from: minX / blockSize * blockSize, to: maxX, by: blockSize) {
                 
                 let block = Block(x: x, y: y, width: blockSize, height: blockSize)
                 

        
        if !need_to_render.isEmpty {
            
            let textures: [(Block, MTLTexture)] = autoreleasepool {
                
                need_to_render.compactMap { block in
                    
                    let extent = Rect(x: block.minX, y: block.minY, width: block.width, height: block.height)
                    
                    let buffer = MappedBuffer<UInt8>(repeating: 0, count: block.width * block.height * 4, fileBacked: true)
                    
                    let descriptor = MTLTextureDescriptor.texture2DDescriptor(
                        pixelFormat: .bgra8Unorm,
                        width: block.width,
                        height: block.height,
                        mipmapped: false)
                    descriptor.usage = .shaderWrite
                    
                    guard let texture = commandBuffer.device.makeTexture(buffer, descriptor: descriptor, bytesPerRow: block.width * 4) else { return nil }
                    
                    renderer.render(image, to: texture, commandBuffer: commandBuffer, bounds: CGRect(extent), colorSpace: workingColorSpace)
                    
                    #if os(macOS) || targetEnvironment(macCatalyst)
                    
                    if texture.storageMode == .managed {
                        let blitCommandEncoder = commandBuffer.makeBlitCommandEncoder()
                        blitCommandEncoder?.synchronize(resource: texture)
                        blitCommandEncoder?.endEncoding()
                    }
                    
                    #endif
                    
                    return (block, texture)
                }
            }
            
            for (block, texture) in textures {

            
            for (block, (texture, offset_x, offset_y)) in blocks {
                
                let _minX = max(block.minX, minX)
                let _minY = max(block.minY, minY)
                let _maxX = min(block.maxX, maxX)
                let _maxY = min(block.maxY, maxY)
                
                let width = _maxX - _minX
                let height = _maxY - _minY
