summaryrefslogtreecommitdiffstats
path: root/tests/auto/render/rhi/rhi_graphicspipelinemanager/tst_rhi_graphicspipelinemanager.cpp
blob: ce83fcaeb4346d8cdc51f05a1062cb0884d87d6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include <QtTest/QTest>
#include <qbackendnodetester.h>
#include <testarbiter.h>
#include <testrenderer.h>
#include <private/shader_p.h>
#include <Qt3DRender/qshaderprogram.h>
#include <Qt3DRender/private/renderviewjobutils_p.h>
#include <rendercommand_p.h>
#include <renderer_p.h>
#include <rhiresourcemanagers_p.h>

QT_BEGIN_NAMESPACE

namespace Qt3DRender {

namespace Render {

namespace Rhi {

class tst_Rhi_GraphicsPipelineManager : public Qt3DCore::QBackendNodeTester
{
    Q_OBJECT

private Q_SLOTS:

    void checkAttributeInfoComparison()
    {
        // GIVEN
        RHIGraphicsPipelineManager pipelineManagers;

        // WHEN
        std::vector<AttributeInfo> infoList1 = {
            { 1, QRhiVertexInputBinding::PerVertex, 32, 0, 0 },
            { 2, QRhiVertexInputBinding::PerVertex, 32, 8, 0 },
        };
        const int infoList1ID = pipelineManagers.getIdForAttributeVec(infoList1);

        // THEN
        QCOMPARE(infoList1ID, 0);

        // WHEN
        std::vector<AttributeInfo> infoList2 = {
            { 1, QRhiVertexInputBinding::PerVertex, 32, 0, 0 },
            { 2, QRhiVertexInputBinding::PerVertex, 32, 8, 0 },
            { 3, QRhiVertexInputBinding::PerVertex, 32, 16, 0 },
        };
        const int infoList2ID = pipelineManagers.getIdForAttributeVec(infoList2);

        // THEN
        QCOMPARE(infoList2ID, 1);

        // WHEN
        std::vector<AttributeInfo> infoList3 = {
            { 1, QRhiVertexInputBinding::PerVertex, 32, 0, 0 },
            { 2, QRhiVertexInputBinding::PerVertex, 32, 8, 0 },
        };
        const int infoList3ID = pipelineManagers.getIdForAttributeVec(infoList3);

        // THEN
        QCOMPARE(infoList3ID, infoList1ID);
    }
};

} // Rhi

} // Render

} // Qt3DRender

QT_END_NAMESPACE

QTEST_MAIN(Qt3DRender::Render::Rhi::tst_Rhi_GraphicsPipelineManager)

#include "tst_rhi_graphicspipelinemanager.moc"