From 6a2c89c0433e1202d21a13c9ebfc1fe22465b8fc Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Thu, 13 Aug 2020 12:16:00 +0200 Subject: [PATCH] rhi: sanityCheckGraphicsPipeline handle no vertex attributes It is a valid use case to have a vertex shader with no vertex attributes. Using gl_VertexID or gl_InstanceID is enough to generate vertex data out of thin air. Change-Id: If7689914624a84723923fd2d7aef355bda592e24 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhi.cpp | 8 +------- tests/auto/gui/rhi/qrhi/tst_qrhi.cpp | 7 ------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 76d6622eda2..f2c2ad22848 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -4301,14 +4301,8 @@ bool QRhiImplementation::sanityCheckGraphicsPipeline(QRhiGraphicsPipeline *ps) qWarning("Empty shader passed to graphics pipeline"); return false; } - if (it->type() == QRhiShaderStage::Vertex) { + if (it->type() == QRhiShaderStage::Vertex) hasVertexStage = true; - const QRhiVertexInputLayout inputLayout = ps->vertexInputLayout(); - if (inputLayout.cbeginAttributes() == inputLayout.cendAttributes()) { - qWarning("Vertex stage present without any vertex inputs"); - return false; - } - } } if (!hasVertexStage) { qWarning("Cannot build a graphics pipeline without a vertex stage"); diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp index f5e178de4bb..a20bea7ace5 100644 --- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp +++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp @@ -1338,13 +1338,6 @@ void tst_QRhi::invalidPipeline() pipeline->setRenderPassDescriptor(rpDesc.data()); QVERIFY(!pipeline->create()); - // no vertex inputs - pipeline.reset(rhi->newGraphicsPipeline()); - pipeline->setShaderStages({ { QRhiShaderStage::Vertex, vs }, { QRhiShaderStage::Fragment, fs } }); - pipeline->setRenderPassDescriptor(rpDesc.data()); - pipeline->setShaderResourceBindings(srb.data()); - QVERIFY(!pipeline->create()); - // no renderpass descriptor pipeline.reset(rhi->newGraphicsPipeline()); pipeline->setShaderStages({ { QRhiShaderStage::Vertex, vs }, { QRhiShaderStage::Fragment, fs } });