Coverage Report

Created: 2026-08-17 07:50

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