vk_denoise icon indicating copy to clipboard operation
vk_denoise copied to clipboard

Synchronization problems between Vulkan and CUDA

Open antaalt opened this issue 4 years ago • 2 comments

I think there might be synchronization issues with the denoiser between CUDA and Vulkan. The denoiser is run once per frame after raytracing the image, and before tonemapping it.

But the command buffer is being built then submitted to the graphics queue while the optix denoiser is run immediatly while building command buffer and it waits for completion with cudaStreamSynchronize. Which means that each frame, the denoiser will denoise the previous frame instead of the one that was just processed, as the command buffer is not submitted yet. The first frame will then be an undefined output.

Is this an intended features ?

antaalt avatar Mar 09 '20 13:03 antaalt

Yeah. also interested in how optix syncs with vulkan.

wumo avatar Jun 29 '20 06:06 wumo

I managed to fix this by using external semaphore to sync vulkan command buffers with cuda streams used by the optix 7 denoiser. There is a good example in the CUDA SDK for synchronization between Cuda and Vulkan here vulkanCUDASinewave.cu. This way, you can wait for a semaphore to be signaled by a vulkan command buffer before running the Cuda stream.

antaalt avatar Jun 29 '20 12:06 antaalt