MCPcopy Create free account
hub / github.com/TheRealMJP/SHforHLSL / EndFrame

Function EndFrame

SHTest/SampleFramework12/v1.04/Graphics/DX12.cpp:335–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335void EndFrame(IDXGISwapChain4* swapChain, uint32 syncIntervals)
336{
337 Assert_(Device);
338
339 DXCall(CmdList->Close());
340
341 EndFrame_Upload();
342
343 ID3D12CommandList* commandLists[] = { CmdList };
344 GfxQueue->ExecuteCommandLists(ArraySize_(commandLists), commandLists);
345
346 // Present the frame.
347 if(swapChain)
348 DXCall(swapChain->Present(syncIntervals, syncIntervals == 0 ? DXGI_PRESENT_ALLOW_TEARING : 0));
349
350 ++CurrentCPUFrame;
351
352 // Signal the fence with the current frame number, so that we can check back on it
353 FrameFence.Signal(GfxQueue, CurrentCPUFrame);
354
355 // Wait for the GPU to catch up before we stomp an executing command buffer
356 const uint64 gpuLag = DX12::CurrentCPUFrame - DX12::CurrentGPUFrame;
357 Assert_(gpuLag <= DX12::RenderLatency);
358 if(gpuLag >= DX12::RenderLatency)
359 {
360 // Make sure that the previous frame is finished
361 FrameFence.Wait(DX12::CurrentGPUFrame + 1);
362 ++DX12::CurrentGPUFrame;
363 }
364
365 CurrFrameIdx = DX12::CurrentCPUFrame % NumCmdAllocators;
366
367 // Prepare the command buffers to be used for the next frame
368 DXCall(CmdAllocators[CurrFrameIdx]->Reset());
369 DXCall(CmdList->Reset(CmdAllocators[CurrFrameIdx], nullptr));
370
371 EndFrame_Helpers();
372
373 // See if we have any deferred releases to process
374 ProcessDeferredReleases(CurrFrameIdx);
375 ProcessDeferredSRVCreates(CurrFrameIdx);
376}
377
378void FlushGPU()
379{

Callers 1

RenderMethod · 0.50

Calls 9

DXCallFunction · 0.85
EndFrame_UploadFunction · 0.85
EndFrame_HelpersFunction · 0.85
ProcessDeferredReleasesFunction · 0.85
SignalMethod · 0.80
WaitMethod · 0.80
CloseMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected