// Render the scene. void D3D12Fullscreen::OnRender() { if (m_windowVisible) { PIXBeginEvent(m_commandQueue.Get(), 0, L"Render"); // Record all the commands we need to render the scene into the command list. PopulateCommandList(); // Execute the command list. ID3D12CommandList* ppCommandLists[] = { m_commandList.Get() }; m_commandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists); PIXEndEvent(m_commandQueue.Get()); // When using sync interval 0, it is recommended to always pass the tearing // flag when it is available, even when presenting in windowed mode. // However, this flag cannot be used if the app is in fullscreen mode as a // result of calling SetFullscreenState. UINT presentFlags = (m_tearingSupport && m_windowedMode) ? DXGI_PRESENT_ALLOW_TEARING : 0; // Present the frame. ThrowIfFailed(m_swapChain->Present(0, presentFlags)); MoveToNextFrame(); } }
// Render the scene. void D3D12SmallResources::OnRender() { PIXBeginEvent(m_commandQueue.Get(), 0, L"Render"); // Record all the commands we need to render the scene into the command list. PopulateCommandList(); // Execute the command list. ID3D12CommandList* ppCommandLists[] = { m_commandList.Get() }; m_commandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists); PIXEndEvent(m_commandQueue.Get()); DXGI_QUERY_VIDEO_MEMORY_INFO memoryInfo; m_adapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &memoryInfo); WCHAR text[100]; WCHAR usageString[20]; swprintf_s(text, L"[ResourceType: %s] - Memory Used: %s", m_usePlacedResources ? L"Placed" : L"Committed", FormatMemoryUsage(memoryInfo.CurrentUsage, usageString)); SetCustomWindowText(text); // Present the frame. ThrowIfFailed(m_swapChain->Present(1, 0)); MoveToNextFrame(); }
// Render the scene. void D3D12ExecuteIndirect::OnRender() { // Record all the commands we need to render the scene into the command list. PopulateCommandLists(); // Execute the compute work. if (m_enableCulling) { ID3D12CommandList* ppCommandLists[] = { m_computeCommandList.Get() }; m_computeCommandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists); m_computeCommandQueue->Signal(m_computeFence.Get(), m_fenceValues[m_frameIndex]); // Execute the rendering work only when the compute work is complete. m_commandQueue->Wait(m_computeFence.Get(), m_fenceValues[m_frameIndex]); } // Execute the rendering work. ID3D12CommandList* ppCommandLists[] = { m_commandList.Get() }; m_commandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists); // Present the frame. ThrowIfFailed(m_swapChain->Present(1, 0)); MoveToNextFrame(); }
// Render the scene. void D3D12PredicationQueries::OnRender() { // Record all the commands we need to render the scene into the command list. PopulateCommandList(); // Execute the command list. ID3D12CommandList* ppCommandLists[] = { m_commandList.Get() }; m_commandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists); // Present the frame. ThrowIfFailed(m_swapChain->Present(0, 0)); MoveToNextFrame(); }
void Video::Update(int delta) { if (IsFinished()) { return; } pCurFrame->Update(delta); while (!IsFinished() && pCurFrame->GetIsFinished()) { MoveToNextFrame(); } }
void Video::Finish() { unsigned int lastFrameIndex = curFrameIndex; while (!IsFinished() && !pCurFrame->GetIsForever()) { MoveToNextFrame(); // If we've looped all the way around, then we know that finishing is impossible, // so we'll exit. if (lastFrameIndex == curFrameIndex) { break; } } }
// Render the scene. void D3D12HeterogeneousMultiadapter::OnRender() { // Record all the commands we need to render the scene into the command lists. PopulateCommandLists(); // Execute the command lists. { { ID3D12CommandList* ppRenderCommandLists[] = { m_directCommandLists[Primary].Get() }; m_directCommandQueues[Primary]->ExecuteCommandLists(_countof(ppRenderCommandLists), ppRenderCommandLists); // Signal the copy queue to indicate render is complete. ThrowIfFailed(m_directCommandQueues[Primary]->Signal(m_renderFence.Get(), m_currentRenderFenceValue)); } { // GPU Wait for the primary adapter to finish rendering. ThrowIfFailed(m_copyCommandQueue->Wait(m_renderFence.Get(), m_currentRenderFenceValue)); m_currentRenderFenceValue++; ID3D12CommandList* ppCopyCommandLists[] = { m_copyCommandList.Get() }; m_copyCommandQueue->ExecuteCommandLists(_countof(ppCopyCommandLists), ppCopyCommandLists); // Signal the secondary adapter to indicate the copy is complete. ThrowIfFailed(m_copyCommandQueue->Signal(m_crossAdapterFences[Primary].Get(), m_currentCrossAdapterFenceValue)); } { // GPU Wait for the primary adapter to finish copying. ThrowIfFailed(m_directCommandQueues[Secondary]->Wait(m_crossAdapterFences[Secondary].Get(), m_currentCrossAdapterFenceValue)); m_currentCrossAdapterFenceValue++; ID3D12CommandList* ppBlurCommandLists[] = { m_directCommandLists[Secondary].Get() }; m_directCommandQueues[Secondary]->ExecuteCommandLists(_countof(ppBlurCommandLists), ppBlurCommandLists); } } // Present the frame. ThrowIfFailed(m_swapChain->Present(1, 0)); // Signal the frame is complete. ThrowIfFailed(m_directCommandQueues[Secondary]->Signal(m_frameFence.Get(), m_currentPresentFenceValue)); m_frameFenceValues[m_frameIndex] = m_currentPresentFenceValue; m_currentPresentFenceValue++; MoveToNextFrame(); }
// Render the scene. void D3D12PipelineStateCache::OnRender() { // Record all the commands we need to render the scene into the command list. PopulateCommandList(); // Execute the command list. ID3D12CommandList* ppCommandLists[] = { m_commandList.Get() }; m_commandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists); // Present the frame. ThrowIfFailed(m_swapChain->Present(0, 0)); m_drawIndex = 0; m_psoLibrary.EndFrame(); MoveToNextFrame(); }
// Present the contents of the swap chain to the screen. void Direct3DManager::Present() { // The first argument instructs DXGI to block until VSync, putting the application // to sleep until the next VSync. This ensures we don't waste any cycles rendering // frames that will never be displayed to the screen. HRESULT hr = mSwapChain->Present(mUseVsync ? 1 : 0, 0); // If the device was removed either by a disconnection or a driver upgrade, we // must recreate all device resources. if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) { mDeviceRemoved = true; } else { Direct3DUtils::ThrowIfHRESULTFailed(hr); MoveToNextFrame(); } }
// Render the scene. void D3D12HDR::OnRender() { if (m_windowVisible) { if (m_enableUI) { PIXBeginEvent(m_commandQueue.Get(), 0, L"Render UI"); m_uiLayer->Render(); PIXEndEvent(m_commandQueue.Get()); } PIXBeginEvent(m_commandQueue.Get(), 0, L"Render Scene"); RenderScene(); PIXEndEvent(m_commandQueue.Get()); // Present the frame. ThrowIfFailed(m_swapChain->Present(1, 0)); MoveToNextFrame(); } }
// Render the scene. void D3D12Fullscreen::OnRender() { if (m_windowVisible) { PIXBeginEvent(m_commandQueue.Get(), 0, L"Render"); // Record all the commands we need to render the scene into the command list. PopulateCommandList(); // Execute the command list. ID3D12CommandList* ppCommandLists[] = { m_commandList.Get() }; m_commandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists); PIXEndEvent(m_commandQueue.Get()); // Present the frame. ThrowIfFailed(m_swapChain->Present(0, 0)); MoveToNextFrame(); } }
// Render the scene. void D3D1211on12::OnRender() { PIXBeginEvent(m_commandQueue.Get(), 0, L"Render 3D"); // Record all the commands we need to render the scene into the command list. PopulateCommandList(); // Execute the command list. ID3D12CommandList* ppCommandLists[] = { m_commandList.Get() }; m_commandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists); PIXEndEvent(m_commandQueue.Get()); PIXBeginEvent(m_commandQueue.Get(), 0, L"Render UI"); RenderUI(); PIXEndEvent(m_commandQueue.Get()); // Present the frame. ThrowIfFailed(m_swapChain->Present(1, 0)); MoveToNextFrame(); }