Regeneration on ever 'n' now, but it gets scheduled on every frame in that semaphore group

This commit is contained in:
Eryn Wells 2018-11-07 17:05:28 -05:00
parent 11b9cba8ac
commit 1a5ed92c14

View file

@ -170,10 +170,13 @@ class Renderer: NSObject, MTKViewDelegate {
_ = inFlightSemaphore.wait(timeout: DispatchTime.distantFuture) _ = inFlightSemaphore.wait(timeout: DispatchTime.distantFuture)
if let commandBuffer = commandQueue.makeCommandBuffer() { if let commandBuffer = commandQueue.makeCommandBuffer() {
let semaphore = inFlightSemaphore var didScheduleAlgorithmIteration = false
let inFlightSem = self.inFlightSemaphore
commandBuffer.addCompletedHandler { (_ commandBuffer)-> Swift.Void in commandBuffer.addCompletedHandler { (_ commandBuffer)-> Swift.Void in
if didScheduleAlgorithmIteration && self.iterateTerrainAlgorithm {
self.iterateTerrainAlgorithm = false self.iterateTerrainAlgorithm = false
semaphore.signal() }
inFlightSem.signal()
} }
self.updateDynamicBufferState() self.updateDynamicBufferState()
@ -187,6 +190,7 @@ class Renderer: NSObject, MTKViewDelegate {
terrain.algorithm.encode(in: computeEncoder) terrain.algorithm.encode(in: computeEncoder)
computeEncoder.popDebugGroup() computeEncoder.popDebugGroup()
computeEncoder.endEncoding() computeEncoder.endEncoding()
didScheduleAlgorithmIteration = true
} }
/// Delay getting the currentRenderPassDescriptor until we absolutely need it to avoid /// Delay getting the currentRenderPassDescriptor until we absolutely need it to avoid