aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-07-01 12:58:33 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2016-07-01 11:37:11 +0000
commit3e0763077a5ce420f42606418917ab7d87b6b763 (patch)
treed063ac326685166164754f8421edde5ab65adf8d /examples/quick
parent262dbaaa8ddc38dbadbeec1106f87b464727e13b (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')
-rw-r--r--examples/quick/scenegraph/rendernode/d3d12renderer.cpp15
-rw-r--r--examples/quick/scenegraph/rendernode/main.cpp7
2 files changed, 21 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;
diff --git a/examples/quick/scenegraph/rendernode/main.cpp b/examples/quick/scenegraph/rendernode/main.cpp
index 9128cdc5be..3e1714313e 100644
--- a/examples/quick/scenegraph/rendernode/main.cpp
+++ b/examples/quick/scenegraph/rendernode/main.cpp
@@ -49,6 +49,13 @@ int main(int argc, char **argv)
qmlRegisterType<CustomRenderItem>("SceneGraphRendering", 2, 0, "CustomRenderItem");
QQuickView view;
+
+ if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) {
+ QSurfaceFormat fmt;
+ fmt.setSamples(4);
+ view.setFormat(fmt);
+ }
+
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:///scenegraph/rendernode/main.qml"));
view.resize(1024, 768);