* Wait for pending GPU work to complete. */
| 915 | * Wait for pending GPU work to complete. |
| 916 | */ |
| 917 | void WaitForGPU(D3D12Global &d3d) |
| 918 | { |
| 919 | // Schedule a signal command in the queue |
| 920 | HRESULT hr = d3d.cmdQueue->Signal(d3d.fence, d3d.fenceValues[d3d.frameIndex]); |
| 921 | Utils::Validate(hr, L"Error: failed to signal fence!"); |
| 922 | |
| 923 | // Wait until the fence has been processed |
| 924 | hr = d3d.fence->SetEventOnCompletion(d3d.fenceValues[d3d.frameIndex], d3d.fenceEvent); |
| 925 | Utils::Validate(hr, L"Error: failed to set fence event!"); |
| 926 | |
| 927 | WaitForSingleObjectEx(d3d.fenceEvent, INFINITE, FALSE); |
| 928 | |
| 929 | // Increment the fence value for the current frame |
| 930 | d3d.fenceValues[d3d.frameIndex]++; |
| 931 | } |
| 932 | |
| 933 | /** |
| 934 | * Prepare to render the next frame. |
no test coverage detected