microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
5.88k stars 2k forks source link

[Question] SetEventOnCompletion(value, valid_handle) + WaitForSingleObject() vs SetEventOnCompletion(value, nullptr) #877

Closed seungha-yang closed 2 days ago

seungha-yang commented 2 days ago

While ID3D12Fence::SetEventOnCompletion() with null event handle will block the calling cpu thread already, every sample code here seems to be using ID3D12Fence::SetEventOnCompletion() + immediate WaitForSingleObject() pattern.

Is there any point of creating event handle and passing it to SetEventOnCompletion(), then immediate WaitForSingleObject() call, instead of SetEventOnCompletion() with null event handle?

jenatali commented 2 days ago

Only if you want a timeout or to wait for it at some other point.