summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhid3d11.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-10-13 15:47:27 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-10-14 22:35:19 +0200
commit63790184c79d2765ea726488726cd9f2b43b91d1 (patch)
tree6fefd355602e18efcbdc432b038c40646f02963e /src/gui/rhi/qrhid3d11.cpp
parent61dee37d667e083fd2979ecc166efbc1bfcaf0e7 (diff)
rhi: Fix up vertex inputs with matrices
In order to prevent too much voodoo in backends like D3D11, the input layout is expected to specify the slice index for vecX that are part of an unrolled matrix. Also deoptimize the instancing manual test to exercise a matrix too instead of just vectors. Change-Id: If2dcbcbc483645ce2420b2f87dda765b95da6e80 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhid3d11.cpp')
-rw-r--r--src/gui/rhi/qrhid3d11.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp
index 48e626106c..ce954c9fe0 100644
--- a/src/gui/rhi/qrhid3d11.cpp
+++ b/src/gui/rhi/qrhid3d11.cpp
@@ -4019,15 +4019,29 @@ bool QD3D11GraphicsPipeline::create()
d3dTopology = toD3DTopology(m_topology);
if (!vsByteCode.isEmpty()) {
+ QByteArrayList matrixSliceSemantics;
QVarLengthArray<D3D11_INPUT_ELEMENT_DESC, 4> inputDescs;
for (auto it = m_vertexInputLayout.cbeginAttributes(), itEnd = m_vertexInputLayout.cendAttributes();
it != itEnd; ++it)
{
D3D11_INPUT_ELEMENT_DESC desc;
memset(&desc, 0, sizeof(desc));
- // the output from SPIRV-Cross uses TEXCOORD<location> as the semantic
- desc.SemanticName = "TEXCOORD";
- desc.SemanticIndex = UINT(it->location());
+ // The output from SPIRV-Cross uses TEXCOORD<location> as the
+ // semantic, except for matrices that are unrolled into consecutive
+ // vec2/3/4s attributes and need TEXCOORD<location>_ as
+ // SemanticName and row/column index as SemanticIndex.
+ const int matrixSlice = it->matrixSlice();
+ if (matrixSlice < 0) {
+ desc.SemanticName = "TEXCOORD";
+ desc.SemanticIndex = UINT(it->location());
+ } else {
+ QByteArray sem;
+ sem.resize(16);
+ qsnprintf(sem.data(), sem.size(), "TEXCOORD%d_", it->location() - matrixSlice);
+ matrixSliceSemantics.append(sem);
+ desc.SemanticName = matrixSliceSemantics.last().constData();
+ desc.SemanticIndex = UINT(matrixSlice);
+ }
desc.Format = toD3DAttributeFormat(it->format());
desc.InputSlot = UINT(it->binding());
desc.AlignedByteOffset = it->offset();