Metal: Wait for finish when buffers are updated #120050
@ -579,6 +579,10 @@ void MTLStateManager::issue_barrier(eGPUBarrier barrier_bits)
|
||||
BLI_assert(ctx);
|
||||
|
||||
ctx->main_command_buffer.insert_memory_barrier(barrier_bits, before_stages, after_stages);
|
||||
|
||||
if (barrier_bits & GPU_BARRIER_BUFFER_UPDATE) {
|
||||
GPU_finish();
|
||||
}
|
||||
}
|
||||
|
||||
MTLFence::~MTLFence()
|
||||
|
@ -426,16 +426,13 @@ void MTLStorageBuf::read(void *data)
|
||||
else {
|
||||
/** Direct storage buffer read. */
|
||||
/* If we have a synchronization event from a prior memory sync, ensure memory is fully synced.
|
||||
* Otherwise, assume read is synchronous and stall until in-flight work is complete. */
|
||||
* Otherwise, assume read is asynchronous. */
|
||||
if (gpu_write_fence_ != nil) {
|
||||
/* Ensure the GPU updates are visible to the host before reading. */
|
||||
while (gpu_write_fence_.signaledValue < host_read_signal_value_) {
|
||||
BLI_time_sleep_ms(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
GPU_finish();
|
||||
}
|
||||
|
||||
/* Managed buffers need to be explicitly flushed back to host. */
|
||||
if (metal_buffer_->get_resource_options() & MTLResourceStorageModeManaged) {
|
||||
|
Loading…
Reference in New Issue
Block a user