summaryrefslogtreecommitdiffstats
path: root/tests/manual/rhi/multiview/multiview.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-06-20 14:14:24 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2023-06-22 15:20:26 +0200
commitb7d9b7fa6921161da8e4d048d5660f3181d89739 (patch)
tree50987605b0d7d521e133467ca2026d2019b5261d /tests/manual/rhi/multiview/multiview.cpp
parent1d9bf6ea38f12f55acc00cfd1072b1ef040a4cc4 (diff)
rhi: d3d12: Implement multiview support
This relies on qsb being able to invoke dxc instead of fxc when the request HLSL (shader model) version is 6.1. (6.1 is required for SV_ViewID) This currently works only when conditioning offline with qsb (or via CMake), because qsb can easily invoke dxc instead of fxc. When shipping HLSL inside the .qsb package (so when -c is not specified or running the external tool fails), this won't work since the D3D12 backend still uses D3DCompile(), not IDxcCompiler. Support for that will be investigated separately. We also need to bump to ID3D12Device2 and ID3D12GraphicsCommandList1. With Windows 10 version 1703 being quite old now, this should not be a problem at run time. There are however issues at build time, namely that MinGW and MinGW/LLVM and similar seems to have ancient Windows SDK headers according to the CI test runs. None of the MSVC configurations have this in the CI, they have reasonable versions of d3d12.h and similar. Therefore, one important aspect of this change is that the D3D12 backend of QRhi will only be available from now on when the SDK headers are new enough (meaning ID3D12Device2 is declared, which is a several years old type now). Otherwise, QRhi::create() will simply fail when asking for D3D12 with a helpful warning message about the Qt build being crippled. Implementation-wise, there are surprises in store as well: The way the PSO is created needs to be revamped to follow the extensible approach that uses a pipeline state stream description. Both the graphics and compute pipeline creation is changed to use CreatePipelineState() and the associated machinery. This is only really essential for graphics pipelines since we know have to include data for view instancing (multiview). For compute the result is the same as before. Additionally, the view count must now be baked into the QRhiGraphicsPipeline. This means that applications must call setMultiViewCount() with the same value (typically 2) *both* on the render target's color attachment and on the pipeline. Backends that do not care about the pipeline's view count (GL, Vulkan) will of course ignore it, but if it's not set correctly D3D12 will fail. The manual test is updated accordingly. Fixes: QTBUG-114772 Change-Id: I93db7313377e711c2faeb956815899b12132d23b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests/manual/rhi/multiview/multiview.cpp')
-rw-r--r--tests/manual/rhi/multiview/multiview.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/manual/rhi/multiview/multiview.cpp b/tests/manual/rhi/multiview/multiview.cpp
index f4a5db3911..80841d2084 100644
--- a/tests/manual/rhi/multiview/multiview.cpp
+++ b/tests/manual/rhi/multiview/multiview.cpp
@@ -64,7 +64,7 @@ void Window::customInit()
QRhiColorAttachment multiViewAtt(d.tex);
// using array elements 0 and 1
multiViewAtt.setLayer(0);
- multiViewAtt.setMultiViewCount(2);
+ multiViewAtt.setMultiViewCount(2); // the view count must be set both on the render target and the pipeline
QRhiTextureRenderTargetDescription rtDesc(multiViewAtt);
d.rt = m_r->newTextureRenderTarget(rtDesc);
d.releasePool << d.rt;
@@ -155,7 +155,7 @@ void Window::customInit()
{ QRhiShaderStage::Vertex, getShader(QLatin1String(":/multiview.vert.qsb")) },
{ QRhiShaderStage::Fragment, getShader(QLatin1String(":/multiview.frag.qsb")) }
});
-
+ d.triPs->setMultiViewCount(2); // the view count must be set both on the render target and the pipeline
inputLayout.setBindings({
{ 5 * sizeof(float) }
});