EEVEE-Next: Async read back statistic and result buffers #120048
|
@ -931,6 +931,7 @@ void IrradianceBake::surfels_create(const Object &probe_object)
|
|||
inst_.manager->submit(irradiance_bounds_ps_);
|
||||
|
||||
GPU_memory_barrier(GPU_BARRIER_BUFFER_UPDATE);
|
||||
capture_info_buf_.async_flush_to_host();
|
||||
capture_info_buf_.read();
|
||||
|
||||
auto ordered_int_bits_to_float = [](int32_t int_value) -> float {
|
||||
|
@ -974,6 +975,7 @@ void IrradianceBake::surfels_create(const Object &probe_object)
|
|||
|
||||
/* Allocate surfel pool. */
|
||||
GPU_memory_barrier(GPU_BARRIER_BUFFER_UPDATE);
|
||||
capture_info_buf_.async_flush_to_host();
|
||||
capture_info_buf_.read();
|
||||
if (capture_info_buf_.surfel_len == 0) {
|
||||
/* No surfel to allocated. */
|
||||
|
@ -1023,6 +1025,7 @@ void IrradianceBake::surfels_create(const Object &probe_object)
|
|||
/* Sync with any other following pass using the surfel buffer. */
|
||||
GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE);
|
||||
/* Read back so that following push_update will contain correct surfel count. */
|
||||
capture_info_buf_.async_flush_to_host();
|
||||
capture_info_buf_.read();
|
||||
|
||||
DRW_stats_group_end();
|
||||
|
@ -1162,7 +1165,9 @@ void IrradianceBake::read_surfels(LightProbeGridCacheFrame *cache_frame)
|
|||
}
|
||||
|
||||
GPU_memory_barrier(GPU_BARRIER_BUFFER_UPDATE);
|
||||
capture_info_buf_.async_flush_to_host();
|
||||
capture_info_buf_.read();
|
||||
surfels_buf_.async_flush_to_host();
|
||||
surfels_buf_.read();
|
||||
|
||||
cache_frame->surfels_len = capture_info_buf_.surfel_len;
|
||||
|
|
|
@ -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