Fix #106704: Resolve flashing Metal viewport #106914
|
@ -2191,16 +2191,6 @@ void present(MTLRenderPassDescriptor *blit_descriptor,
|
||||||
id<MTLCommandBuffer> cmdbuf = [ctx->queue commandBuffer];
|
id<MTLCommandBuffer> cmdbuf = [ctx->queue commandBuffer];
|
||||||
MTLCommandBufferManager::num_active_cmd_bufs++;
|
MTLCommandBufferManager::num_active_cmd_bufs++;
|
||||||
|
|
||||||
if (MTLCommandBufferManager::sync_event != nil) {
|
|
||||||
/* Release synchronization primitive for current frame to avoid cross-frame dependencies.
|
|
||||||
* We require MTLEvents to ensure correct ordering of workload submissions within a frame,
|
|
||||||
* however, we should not create long chains of dependencies spanning several drawables as any
|
|
||||||
* temporary stalls can then trigger erroneous GPU timeouts in non-dependent submissions. */
|
|
||||||
[MTLCommandBufferManager::sync_event release];
|
|
||||||
MTLCommandBufferManager::sync_event = nil;
|
|
||||||
MTLCommandBufferManager::event_signal_val = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Do Present Call and final Blit to MTLDrawable. */
|
/* Do Present Call and final Blit to MTLDrawable. */
|
||||||
id<MTLRenderCommandEncoder> enc = [cmdbuf renderCommandEncoderWithDescriptor:blit_descriptor];
|
id<MTLRenderCommandEncoder> enc = [cmdbuf renderCommandEncoderWithDescriptor:blit_descriptor];
|
||||||
[enc setRenderPipelineState:blit_pso];
|
[enc setRenderPipelineState:blit_pso];
|
||||||
|
|
|
@ -607,6 +607,19 @@ void MTLFence::wait()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Note(#106431 #106704): `sync_event` is a global cross-context synchronization primitive used
|
||||||
|
* to ensure GPU workloads execute in the correct order across contexts.
|
||||||
|
*
|
||||||
|
* To prevent unexpected GPU stalls, this needs to be reset when used along side explicit
|
||||||
|
* synchronization. Previously this was handled during frame boundaries, however, to eliminate
|
||||||
|
* situational flickering (#106704), only reset this during the cases where we are waiting on
|
||||||
|
* synchronization primitives. */
|
||||||
|
if (MTLCommandBufferManager::sync_event != nil) {
|
||||||
|
[MTLCommandBufferManager::sync_event release];
|
||||||
|
MTLCommandBufferManager::sync_event = nil;
|
||||||
|
MTLCommandBufferManager::event_signal_val = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (signalled_) {
|
if (signalled_) {
|
||||||
MTLContext *ctx = MTLContext::get();
|
MTLContext *ctx = MTLContext::get();
|
||||||
BLI_assert(ctx);
|
BLI_assert(ctx);
|
||||||
|
|
Loading…
Reference in New Issue