diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-07-01 12:58:33 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-07-01 11:37:11 +0000 |
commit | 3e0763077a5ce420f42606418917ab7d87b6b763 (patch) | |
tree | d063ac326685166164754f8421edde5ab65adf8d /examples/quick/scenegraph/rendernode/d3d12renderer.cpp | |
parent | 262dbaaa8ddc38dbadbeec1106f87b464727e13b (diff) |
D3D12: Fix the rendernode example for multisampling
Show how this can be handled in the custom QSGRenderNode implementation.
Change-Id: Id6f18ca568a4850060f957998532815bce5c4ac5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'examples/quick/scenegraph/rendernode/d3d12renderer.cpp')
-rw-r--r-- | examples/quick/scenegraph/rendernode/d3d12renderer.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/examples/quick/scenegraph/rendernode/d3d12renderer.cpp b/examples/quick/scenegraph/rendernode/d3d12renderer.cpp index bc03720407..b7dc62fe86 100644 --- a/examples/quick/scenegraph/rendernode/d3d12renderer.cpp +++ b/examples/quick/scenegraph/rendernode/d3d12renderer.cpp @@ -153,7 +153,20 @@ void D3D12RenderNode::init() psoDesc.NumRenderTargets = 1; psoDesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; psoDesc.DSVFormat = DXGI_FORMAT_D24_UNORM_S8_UINT; // not in use due to !DepthEnable, but this would be the correct format otherwise - psoDesc.SampleDesc.Count = 1; + // We are rendering on the default render target so if the QuickWindow/View + // has requested samples > 0 then we have to follow suit. + const uint samples = qMax(1, m_item->window()->format().samples()); + psoDesc.SampleDesc.Count = samples; + if (samples > 1) { + D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS msaaInfo = {}; + msaaInfo.Format = psoDesc.RTVFormats[0]; + msaaInfo.SampleCount = samples; + if (SUCCEEDED(m_device->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &msaaInfo, sizeof(msaaInfo)))) { + if (msaaInfo.NumQualityLevels > 0) + psoDesc.SampleDesc.Quality = msaaInfo.NumQualityLevels - 1; + } + } + if (FAILED(m_device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pipelineState)))) { qWarning("Failed to create graphics pipeline state"); return; |