diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2022-10-28 10:30:24 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2022-11-02 15:20:48 +0200 |
commit | f672753556cf28d44f864457dc6338a55e2e0ed4 (patch) | |
tree | 44cbf4a742916c6ed25abfbbe520427e51252fa5 /tests | |
parent | 7678db1b8ac5a75950b70daf60baa7b42fd826d1 (diff) |
ShaderParameterPack: check we only store a single UBO/SSBO per BlockBinding
Since we cache ShaderParameterPacks over multiple frames, we need to
ensure that we check that when setting a UBO/SSBO we don't already
have an entry matching the block index.
If that's the case we should simply replace the entry rather than
append a new entry. Failing to do so results in appending a growing
number of UBO entries for the same block.
Pick-to: 6.4 6.2 5.15
Change-Id: Ie7535a80b9426ce2fd5ab6ebe16ea71bd7447750
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/render/opengl/renderviews/tst_renderviews.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/render/opengl/renderviews/tst_renderviews.cpp b/tests/auto/render/opengl/renderviews/tst_renderviews.cpp index eba3e9721..69d151dfc 100644 --- a/tests/auto/render/opengl/renderviews/tst_renderviews.cpp +++ b/tests/auto/render/opengl/renderviews/tst_renderviews.cpp @@ -269,6 +269,68 @@ private Q_SLOTS: << QList<ShaderParameterPack> { pack1, minifiedPack1, minifiedPack1, pack1, minifiedPack1, minifiedPack1 }; } + void checkShaderParameterPackStoresSingleUBOPerBlockIndex() + { + // GIVEN + ShaderParameterPack pack; + auto nodeId1 = Qt3DCore::QNodeId::createId(); + auto nodeId2 = Qt3DCore::QNodeId::createId(); + + BlockToUBO ubo1 { 1, nodeId1, false, {}}; + BlockToUBO ubo2 { 1, nodeId2, false, {}}; + + // WHEN + pack.setUniformBuffer(ubo1); + pack.setUniformBuffer(ubo2); + + // THEN + QCOMPARE(pack.uniformBuffers().size(), 1); + QCOMPARE(pack.uniformBuffers().front().m_blockIndex, 1); + QCOMPARE(pack.uniformBuffers().front().m_bufferID, nodeId2); + + // WHEN + BlockToUBO ubo3 { 2, nodeId2, false, {}}; + pack.setUniformBuffer(ubo3); + + // THEN + QCOMPARE(pack.uniformBuffers().size(), 2); + QCOMPARE(pack.uniformBuffers().front().m_blockIndex, 1); + QCOMPARE(pack.uniformBuffers().front().m_bufferID, nodeId2); + QCOMPARE(pack.uniformBuffers().back().m_blockIndex, 2); + QCOMPARE(pack.uniformBuffers().back().m_bufferID, nodeId2); + } + + void checkShaderParameterPackStoresSingleSSBOPerBlockIndex() + { + // GIVEN + ShaderParameterPack pack; + auto nodeId1 = Qt3DCore::QNodeId::createId(); + auto nodeId2 = Qt3DCore::QNodeId::createId(); + + BlockToSSBO ssbo1 { 1, 0, nodeId1}; + BlockToSSBO ssbo2 { 1, 0, nodeId2}; + + // WHEN + pack.setShaderStorageBuffer(ssbo1); + pack.setShaderStorageBuffer(ssbo2); + + // THEN + QCOMPARE(pack.shaderStorageBuffers().size(), 1); + QCOMPARE(pack.shaderStorageBuffers().front().m_blockIndex, 1); + QCOMPARE(pack.shaderStorageBuffers().front().m_bufferID, nodeId2); + + // WHEN + BlockToSSBO ssbo3 { 2, 1, nodeId2}; + pack.setShaderStorageBuffer(ssbo3); + + // THEN + QCOMPARE(pack.shaderStorageBuffers().size(), 2); + QCOMPARE(pack.shaderStorageBuffers().front().m_blockIndex, 1); + QCOMPARE(pack.shaderStorageBuffers().front().m_bufferID, nodeId2); + QCOMPARE(pack.shaderStorageBuffers().back().m_blockIndex, 2); + QCOMPARE(pack.shaderStorageBuffers().back().m_bufferID, nodeId2); + } + void checkRenderViewUniformMinification() { QFETCH(QList<QShaderProgram*>, shaders); |