         }
         commandEncoder = nil
         commandBuffer = nil
+        command_counter = 0
     }
     
     func alloc_texture() throws -> MTLBuffer {

            self.commit(waitUntilCompleted: true)
            guard let _commandBuffer = renderer.queue.makeCommandBuffer() else { throw MetalRenderer.Error(description: "MTLCommandQueue.makeCommandBuffer failed.") }
            self.commandBuffer = _commandBuffer
            command_counter = 0
        }
        
        command_counter += 1

            self.commit(waitUntilCompleted: true)
            guard let _commandBuffer = renderer.queue.makeCommandBuffer() else { throw MetalRenderer.Error(description: "MTLCommandQueue.makeCommandBuffer failed.") }
            self.commandBuffer = _commandBuffer
        }
        
        command_counter += 1
