Coverage Report

Created: 2026-02-10 07:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/rhi/qshader_p.h
Line
Count
Source
1
// Copyright (C) 2023 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#ifndef QSHADER_P_H
5
#define QSHADER_P_H
6
7
//
8
//  W A R N I N G
9
//  -------------
10
//
11
// This file is not part of the Qt API.  It exists for the convenience
12
// of a number of Qt sources files.  This header file may change from
13
// version to version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#include <QtGui/private/qtguiglobal_p.h>
19
#include <rhi/qshader.h>
20
#include <QtCore/QAtomicInt>
21
#include <QtCore/QMap>
22
23
QT_BEGIN_NAMESPACE
24
25
struct Q_GUI_EXPORT QShaderPrivate
26
{
27
    static const int QSB_VERSION = 9;
28
    static const int QSB_VERSION_WITHOUT_INPUT_OUTPUT_INTERFACE_BLOCKS = 8;
29
    static const int QSB_VERSION_WITHOUT_EXTENDED_STORAGE_BUFFER_INFO = 7;
30
    static const int QSB_VERSION_WITHOUT_NATIVE_SHADER_INFO = 6;
31
    static const int QSB_VERSION_WITHOUT_SEPARATE_IMAGES_AND_SAMPLERS = 5;
32
    static const int QSB_VERSION_WITHOUT_VAR_ARRAYDIMS = 4;
33
    static const int QSB_VERSION_WITH_CBOR = 3;
34
    static const int QSB_VERSION_WITH_BINARY_JSON = 2;
35
    static const int QSB_VERSION_WITHOUT_BINDINGS = 1;
36
37
    enum MslNativeShaderInfoExtraBufferBindings {
38
        MslTessVertIndicesBufferBinding = 0,
39
        MslTessVertTescOutputBufferBinding,
40
        MslTessTescTessLevelBufferBinding,
41
        MslTessTescPatchOutputBufferBinding,
42
        MslTessTescParamsBufferBinding,
43
        MslTessTescInputBufferBinding,
44
        MslBufferSizeBufferBinding,
45
        MslMultiViewMaskBufferBinding
46
    };
47
48
    QShaderPrivate()
49
0
        : ref(1)
50
0
    {
51
0
    }
52
53
    QShaderPrivate(const QShaderPrivate &other)
54
0
        : ref(1),
55
0
          qsbVersion(other.qsbVersion),
56
0
          stage(other.stage),
57
0
          desc(other.desc),
58
0
          shaders(other.shaders),
59
0
          bindings(other.bindings),
60
0
          combinedImageMap(other.combinedImageMap),
61
0
          nativeShaderInfoMap(other.nativeShaderInfoMap)
62
0
    {
63
0
    }
64
65
0
    static QShaderPrivate *get(QShader *s) { return s->d; }
66
0
    static const QShaderPrivate *get(const QShader *s) { return s->d; }
67
0
    static int qtQsbVersion(QShader::SerializedFormatVersion qtVersion) {
68
0
        switch (qtVersion) {
69
0
        case QShader::SerializedFormatVersion::Qt_6_4:
70
0
            return (QShaderPrivate::QSB_VERSION_WITHOUT_SEPARATE_IMAGES_AND_SAMPLERS + 1);
71
0
        case QShader::SerializedFormatVersion::Qt_6_5:
72
0
            return (QShaderPrivate::QSB_VERSION_WITHOUT_EXTENDED_STORAGE_BUFFER_INFO + 1);
73
0
        default:
74
0
            return QShaderPrivate::QSB_VERSION;
75
0
        }
76
0
    }
77
78
    QAtomicInt ref;
79
    int qsbVersion = QSB_VERSION;
80
    QShader::Stage stage = QShader::VertexStage;
81
    QShaderDescription desc;
82
    // QMap not QHash because we need to be able to iterate based on sorted keys
83
    QMap<QShaderKey, QShaderCode> shaders;
84
    QMap<QShaderKey, QShader::NativeResourceBindingMap> bindings;
85
    QMap<QShaderKey, QShader::SeparateToCombinedImageSamplerMappingList> combinedImageMap;
86
    QMap<QShaderKey, QShader::NativeShaderInfo> nativeShaderInfoMap;
87
};
88
89
QT_END_NAMESPACE
90
91
#endif