1
在清除相關視圖之前立即致電DiscardView
是否安全策略?看起來濫用這個API可能導致不好的事情,所以關於如何有效地使用這個的一些解釋將非常感謝。何時調用RTV/DSV上的DiscardView?
在清除相關視圖之前立即致電DiscardView
是否安全策略?看起來濫用這個API可能導致不好的事情,所以關於如何有效地使用這個的一些解釋將非常感謝。何時調用RTV/DSV上的DiscardView?
DiscardView
是平鋪硬件渲染的優化,所以不是嚴格要求。
在標準的Windows 8商店的Windows Phone 8,和通用Windows應用程序模板,這就是所謂的後右Present
void DX::DeviceResources::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 = m_swapChain->Present(1, 0);
// Discard the contents of the render target.
// This is a valid operation only when the existing contents will be entirely
// overwritten. If dirty or scroll rects are used, this call should be removed.
m_d3dContext->DiscardView(m_d3dRenderTargetView.Get());
// Discard the contents of the depth stencil.
m_d3dContext->DiscardView(m_d3dDepthStencilView.Get());
// 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)
{
HandleDeviceLost();
}
else
{
DX::ThrowIfFailed(hr);
}
}
感謝,該TBDR優化是我後。 由於清除視圖似乎意味着「內容將被覆蓋」,因此在清除視圖之前立即調用DiscardView是正確的(即使假設每幀視圖被丟棄或清除多次)?或者,現在是唯一有效的放棄地點? – user8709
在循環循環中,在「Present」之後或「Clear」之前進行循環操作是等價的。 –