summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-02-20 14:37:41 -0800
committerGitHub <noreply@github.com>2022-02-20 14:37:41 -0800
commitc4790309ec46ae2f4f7c49eb50699a950ee7a9a4 (patch)
treee89f2a4a0a8a3fee16ebde5ce5b05ceb1d473398 /tools/gfx/d3d
parente272aec6a9ddb8b0af82f72c061f5393f2b2bdab (diff)
gfx: defer downstream shader compilation until draw/dispatch. (#2139)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tools/gfx/d3d')
-rw-r--r--tools/gfx/d3d/d3d-swapchain.h40
1 files changed, 32 insertions, 8 deletions
diff --git a/tools/gfx/d3d/d3d-swapchain.h b/tools/gfx/d3d/d3d-swapchain.h
index 99343aaf4..1c29b2039 100644
--- a/tools/gfx/d3d/d3d-swapchain.h
+++ b/tools/gfx/d3d/d3d-swapchain.h
@@ -48,17 +48,44 @@ public:
swapChainDesc.OutputWindow = (HWND)window.handleValues[0];
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.Windowed = TRUE;
-
if (!desc.enableVSync)
{
swapChainDesc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
}
// Swap chain needs the queue so that it can force a flush on it.
- ComPtr<IDXGISwapChain> swapChain;
- SLANG_RETURN_ON_FAIL(
- getDXGIFactory()->CreateSwapChain(getOwningDevice(), &swapChainDesc, swapChain.writeRef()));
- SLANG_RETURN_ON_FAIL(swapChain->QueryInterface(m_swapChain.writeRef()));
+ ComPtr<IDXGIFactory2> dxgiFactory2;
+ getDXGIFactory()->QueryInterface(IID_PPV_ARGS(dxgiFactory2.writeRef()));
+ if (!dxgiFactory2)
+ {
+ ComPtr<IDXGISwapChain> swapChain;
+ SLANG_RETURN_ON_FAIL(getDXGIFactory()->CreateSwapChain(
+ getOwningDevice(), &swapChainDesc, swapChain.writeRef()));
+ SLANG_RETURN_ON_FAIL(getDXGIFactory()->MakeWindowAssociation(
+ (HWND)window.handleValues[0], DXGI_MWA_NO_ALT_ENTER));
+ SLANG_RETURN_ON_FAIL(swapChain->QueryInterface(m_swapChain.writeRef()));
+ }
+ else
+ {
+ DXGI_SWAP_CHAIN_DESC1 desc1 = {};
+ desc1.BufferCount = swapChainDesc.BufferCount;
+ desc1.BufferUsage = swapChainDesc.BufferUsage;
+ desc1.Flags = swapChainDesc.Flags;
+ desc1.Format = swapChainDesc.BufferDesc.Format;
+ desc1.Height = swapChainDesc.BufferDesc.Height;
+ desc1.Width = swapChainDesc.BufferDesc.Width;
+ desc1.SampleDesc = swapChainDesc.SampleDesc;
+ desc1.SwapEffect = swapChainDesc.SwapEffect;
+ ComPtr<IDXGISwapChain1> swapChain1;
+ SLANG_RETURN_ON_FAIL(dxgiFactory2->CreateSwapChainForHwnd(
+ getOwningDevice(),
+ (HWND)window.handleValues[0],
+ &desc1,
+ nullptr,
+ nullptr,
+ swapChain1.writeRef()));
+ SLANG_RETURN_ON_FAIL(swapChain1->QueryInterface(m_swapChain.writeRef()));
+ }
if (!desc.enableVSync)
{
@@ -74,9 +101,6 @@ public:
m_swapChain->SetMaximumFrameLatency(maxLatency);
}
- SLANG_RETURN_ON_FAIL(getDXGIFactory()->MakeWindowAssociation(
- (HWND)window.handleValues[0], DXGI_MWA_NO_ALT_ENTER));
-
createSwapchainBufferImages();
return SLANG_OK;
}