Coverage Report

Created: 2026-09-28 08:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/rhi/qrhi.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 QRHI_H
6
#define QRHI_H
7
8
//
9
//  W A R N I N G
10
//  -------------
11
//
12
// This file is part of the RHI API, with limited compatibility guarantees.
13
// Usage of this API may make your code source and binary incompatible with
14
// future versions of Qt.
15
//
16
17
#include <QtGui/qtguiglobal.h>
18
#include <QtCore/qsize.h>
19
#include <QtCore/qlist.h>
20
#include <QtCore/qvarlengtharray.h>
21
#include <QtCore/qthread.h>
22
#include <QtGui/qmatrix4x4.h>
23
#include <QtGui/qcolor.h>
24
#include <QtGui/qimage.h>
25
#include <functional>
26
#include <array>
27
28
#include <rhi/qshader.h>
29
30
QT_BEGIN_NAMESPACE
31
32
class QWindow;
33
class QRhi;
34
class QRhiImplementation;
35
class QRhiBuffer;
36
class QRhiRenderBuffer;
37
class QRhiTexture;
38
class QRhiSampler;
39
class QRhiCommandBuffer;
40
class QRhiResourceUpdateBatch;
41
class QRhiResourceUpdateBatchPrivate;
42
class QRhiSwapChain;
43
class QRhiShadingRateMap;
44
class QRhiIndirectCommandBuffer;
45
struct QRhiIndirectCommandBufferBuildInfo;
46
47
class Q_GUI_EXPORT QRhiDepthStencilClearValue
48
{
49
public:
50
    QRhiDepthStencilClearValue() = default;
51
    QRhiDepthStencilClearValue(float d, quint32 s);
52
53
0
    float depthClearValue() const { return m_d; }
54
0
    void setDepthClearValue(float d) { m_d = d; }
55
56
0
    quint32 stencilClearValue() const { return m_s; }
57
0
    void setStencilClearValue(quint32 s) { m_s = s; }
58
59
private:
60
    float m_d = 1.0f;
61
    quint32 m_s = 0;
62
63
    friend bool operator==(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept
64
0
    {
65
0
        return a.m_d == b.m_d && a.m_s == b.m_s;
66
0
    }
67
68
    friend bool operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept
69
0
    {
70
0
        return !(a == b);
71
0
    }
72
73
    friend size_t qHash(const QRhiDepthStencilClearValue &v, size_t seed = 0) noexcept
74
0
    {
75
0
        QtPrivate::QHashCombine hash(seed);
76
0
        seed = hash(seed, v.m_d);
77
0
        seed = hash(seed, v.m_s);
78
0
        return seed;
79
0
    }
80
};
81
82
Q_DECLARE_TYPEINFO(QRhiDepthStencilClearValue, Q_RELOCATABLE_TYPE);
83
84
#ifndef QT_NO_DEBUG_STREAM
85
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiDepthStencilClearValue &);
86
#endif
87
88
class Q_GUI_EXPORT QRhiViewport
89
{
90
public:
91
    QRhiViewport() = default;
92
    QRhiViewport(float x, float y, float w, float h, float minDepth = 0.0f, float maxDepth = 1.0f);
93
94
0
    std::array<float, 4> viewport() const { return m_rect; }
95
0
    void setViewport(float x, float y, float w, float h) {
96
0
        m_rect[0] = x; m_rect[1] = y; m_rect[2] = w; m_rect[3] = h;
97
0
    }
98
99
0
    float minDepth() const { return m_minDepth; }
100
0
    void setMinDepth(float minDepth) { m_minDepth = minDepth; }
101
102
0
    float maxDepth() const { return m_maxDepth; }
103
0
    void setMaxDepth(float maxDepth) { m_maxDepth = maxDepth; }
104
105
private:
106
    std::array<float, 4> m_rect { { 0.0f, 0.0f, 0.0f, 0.0f } };
107
    float m_minDepth = 0.0f;
108
    float m_maxDepth = 1.0f;
109
110
    friend bool operator==(const QRhiViewport &a, const QRhiViewport &b) noexcept
111
0
    {
112
0
        return a.m_rect == b.m_rect
113
0
                && a.m_minDepth == b.m_minDepth
114
0
                && a.m_maxDepth == b.m_maxDepth;
115
0
    }
116
117
    friend bool operator!=(const QRhiViewport &a, const QRhiViewport &b) noexcept
118
0
    {
119
0
        return !(a == b);
120
0
    }
121
122
    friend size_t qHash(const QRhiViewport &v, size_t seed = 0) noexcept
123
0
    {
124
0
        QtPrivate::QHashCombine hash(seed);
125
0
        seed = hash(seed, v.m_rect[0]);
126
0
        seed = hash(seed, v.m_rect[1]);
127
0
        seed = hash(seed, v.m_rect[2]);
128
0
        seed = hash(seed, v.m_rect[3]);
129
0
        seed = hash(seed, v.m_minDepth);
130
0
        seed = hash(seed, v.m_maxDepth);
131
0
        return seed;
132
0
    }
133
};
134
135
Q_DECLARE_TYPEINFO(QRhiViewport, Q_RELOCATABLE_TYPE);
136
137
#ifndef QT_NO_DEBUG_STREAM
138
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiViewport &);
139
#endif
140
141
class Q_GUI_EXPORT QRhiScissor
142
{
143
public:
144
    QRhiScissor() = default;
145
    QRhiScissor(int x, int y, int w, int h);
146
147
0
    std::array<int, 4> scissor() const { return m_rect; }
148
0
    void setScissor(int x, int y, int w, int h) {
149
0
        m_rect[0] = x; m_rect[1] = y; m_rect[2] = w; m_rect[3] = h;
150
0
    }
151
152
private:
153
    std::array<int, 4> m_rect { { 0, 0, 0, 0 } };
154
155
    friend bool operator==(const QRhiScissor &a, const QRhiScissor &b) noexcept
156
0
    {
157
0
        return a.m_rect == b.m_rect;
158
0
    }
159
160
    friend bool operator!=(const QRhiScissor &a, const QRhiScissor &b) noexcept
161
0
    {
162
0
        return !(a == b);
163
0
    }
164
165
    friend size_t qHash(const QRhiScissor &v, size_t seed = 0) noexcept
166
0
    {
167
0
        QtPrivate::QHashCombine hash(seed);
168
0
        seed = hash(seed, v.m_rect[0]);
169
0
        seed = hash(seed, v.m_rect[1]);
170
0
        seed = hash(seed, v.m_rect[2]);
171
0
        seed = hash(seed, v.m_rect[3]);
172
0
        return seed;
173
0
    }
174
};
175
176
Q_DECLARE_TYPEINFO(QRhiScissor, Q_RELOCATABLE_TYPE);
177
178
#ifndef QT_NO_DEBUG_STREAM
179
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiScissor &);
180
#endif
181
182
class Q_GUI_EXPORT QRhiVertexInputBinding
183
{
184
public:
185
    enum Classification {
186
        PerVertex,
187
        PerInstance
188
    };
189
190
    QRhiVertexInputBinding() = default;
191
    QRhiVertexInputBinding(quint32 stride, Classification cls = PerVertex, quint32 stepRate = 1);
192
193
0
    quint32 stride() const { return m_stride; }
194
0
    void setStride(quint32 s) { m_stride = s; }
195
196
0
    Classification classification() const { return m_classification; }
197
0
    void setClassification(Classification c) { m_classification = c; }
198
199
0
    quint32 instanceStepRate() const { return m_instanceStepRate; }
200
0
    void setInstanceStepRate(quint32 rate) { m_instanceStepRate = rate; }
201
202
private:
203
    quint32 m_stride = 0;
204
    Classification m_classification = PerVertex;
205
    quint32 m_instanceStepRate = 1;
206
207
    friend bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept
208
0
    {
209
0
        return a.m_stride == b.m_stride
210
0
                && a.m_classification == b.m_classification
211
0
                && a.m_instanceStepRate == b.m_instanceStepRate;
212
0
    }
213
214
    friend bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept
215
0
    {
216
0
        return !(a == b);
217
0
    }
218
219
    friend size_t qHash(const QRhiVertexInputBinding &v, size_t seed = 0) noexcept
220
0
    {
221
0
        QtPrivate::QHashCombine hash(seed);
222
0
        seed = hash(seed, v.m_stride);
223
0
        seed = hash(seed, v.m_classification);
224
0
        seed = hash(seed, v.m_instanceStepRate);
225
0
        return seed;
226
0
    }
227
};
228
229
Q_DECLARE_TYPEINFO(QRhiVertexInputBinding, Q_RELOCATABLE_TYPE);
230
231
#ifndef QT_NO_DEBUG_STREAM
232
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputBinding &);
233
#endif
234
235
class Q_GUI_EXPORT QRhiVertexInputAttribute
236
{
237
public:
238
    enum Format {
239
        Float4,
240
        Float3,
241
        Float2,
242
        Float,
243
        UNormByte4,
244
        UNormByte2,
245
        UNormByte,
246
        UInt4,
247
        UInt3,
248
        UInt2,
249
        UInt,
250
        SInt4,
251
        SInt3,
252
        SInt2,
253
        SInt,
254
        Half4,
255
        Half3,
256
        Half2,
257
        Half,
258
        UShort4,
259
        UShort3,
260
        UShort2,
261
        UShort,
262
        SShort4,
263
        SShort3,
264
        SShort2,
265
        SShort,
266
    };
267
268
    QRhiVertexInputAttribute() = default;
269
    QRhiVertexInputAttribute(int binding, int location, Format format, quint32 offset, int matrixSlice = -1);
270
271
0
    int binding() const { return m_binding; }
272
0
    void setBinding(int b) { m_binding = b; }
273
274
0
    int location() const { return m_location; }
275
0
    void setLocation(int loc) { m_location = loc; }
276
277
0
    Format format() const { return m_format; }
278
0
    void setFormat(Format f) { m_format = f; }
279
280
0
    quint32 offset() const { return m_offset; }
281
0
    void setOffset(quint32 ofs) { m_offset = ofs; }
282
283
0
    int matrixSlice() const { return m_matrixSlice; }
284
0
    void setMatrixSlice(int slice) { m_matrixSlice = slice; }
285
286
private:
287
    int m_binding = 0;
288
    int m_location = 0;
289
    Format m_format = Float4;
290
    quint32 m_offset = 0;
291
    int m_matrixSlice = -1;
292
293
    friend bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept
294
0
    {
295
0
        return a.m_binding == b.m_binding
296
0
                && a.m_location == b.m_location
297
0
                && a.m_format == b.m_format
298
0
                && a.m_offset == b.m_offset;
299
0
        // matrixSlice excluded intentionally
300
0
    }
301
302
    friend bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept
303
0
    {
304
0
        return !(a == b);
305
0
    }
306
307
    friend size_t qHash(const QRhiVertexInputAttribute &v, size_t seed = 0) noexcept
308
0
    {
309
0
        QtPrivate::QHashCombine hash(seed);
310
0
        seed = hash(seed, v.m_binding);
311
0
        seed = hash(seed, v.m_location);
312
0
        seed = hash(seed, v.m_format);
313
0
        seed = hash(seed, v.m_offset);
314
0
        return seed;
315
0
    }
316
};
317
318
Q_DECLARE_TYPEINFO(QRhiVertexInputAttribute, Q_RELOCATABLE_TYPE);
319
320
#ifndef QT_NO_DEBUG_STREAM
321
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputAttribute &);
322
#endif
323
324
class Q_GUI_EXPORT QRhiVertexInputLayout
325
{
326
public:
327
0
    QRhiVertexInputLayout() = default;
328
329
0
    void setBindings(std::initializer_list<QRhiVertexInputBinding> list) { m_bindings = list; }
330
    template<typename InputIterator>
331
    void setBindings(InputIterator first, InputIterator last)
332
    {
333
        m_bindings.clear();
334
        std::copy(first, last, std::back_inserter(m_bindings));
335
    }
336
0
    const QRhiVertexInputBinding *cbeginBindings() const { return m_bindings.cbegin(); }
337
0
    const QRhiVertexInputBinding *cendBindings() const { return m_bindings.cend(); }
338
0
    const QRhiVertexInputBinding *bindingAt(qsizetype index) const { return &m_bindings.at(index); }
339
0
    qsizetype bindingCount() const { return m_bindings.count(); }
340
341
0
    void setAttributes(std::initializer_list<QRhiVertexInputAttribute> list) { m_attributes = list; }
342
    template<typename InputIterator>
343
    void setAttributes(InputIterator first, InputIterator last)
344
    {
345
        m_attributes.clear();
346
        std::copy(first, last, std::back_inserter(m_attributes));
347
    }
348
0
    const QRhiVertexInputAttribute *cbeginAttributes() const { return m_attributes.cbegin(); }
349
0
    const QRhiVertexInputAttribute *cendAttributes() const { return m_attributes.cend(); }
350
0
    const QRhiVertexInputAttribute *attributeAt(qsizetype index) const { return &m_attributes.at(index); }
351
0
    qsizetype attributeCount() const { return m_attributes.count(); }
352
353
private:
354
    QVarLengthArray<QRhiVertexInputBinding, 8> m_bindings;
355
    QVarLengthArray<QRhiVertexInputAttribute, 8> m_attributes;
356
357
    friend bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept
358
0
    {
359
0
        return a.m_bindings == b.m_bindings && a.m_attributes == b.m_attributes;
360
0
    }
361
362
    friend bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept
363
0
    {
364
0
        return !(a == b);
365
0
    }
366
367
    friend size_t qHash(const QRhiVertexInputLayout &v, size_t seed = 0) noexcept
368
0
    {
369
0
        QtPrivate::QHashCombine hash(seed);
370
0
        seed = hash(seed, v.m_bindings);
371
0
        seed = hash(seed, v.m_attributes);
372
0
        return seed;
373
0
    }
374
375
    friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &);
376
};
377
378
#ifndef QT_NO_DEBUG_STREAM
379
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &);
380
#endif
381
382
class Q_GUI_EXPORT QRhiShaderStage
383
{
384
public:
385
    enum Type {
386
        Vertex,
387
        TessellationControl,
388
        TessellationEvaluation,
389
        Geometry,
390
        Fragment,
391
        Compute
392
    };
393
394
0
    QRhiShaderStage() = default;
395
    QRhiShaderStage(Type type, const QShader &shader,
396
                    QShader::Variant v = QShader::StandardShader);
397
398
0
    Type type() const { return m_type; }
399
0
    void setType(Type t) { m_type = t; }
400
401
0
    QShader shader() const { return m_shader; }
402
0
    void setShader(const QShader &s) { m_shader = s; }
403
404
0
    QShader::Variant shaderVariant() const { return m_shaderVariant; }
405
0
    void setShaderVariant(QShader::Variant v) { m_shaderVariant = v; }
406
407
private:
408
    Type m_type = Vertex;
409
    QShader m_shader;
410
    QShader::Variant m_shaderVariant = QShader::StandardShader;
411
412
    friend bool operator==(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept
413
0
    {
414
0
        return a.m_type == b.m_type
415
0
                && a.m_shader == b.m_shader
416
0
                && a.m_shaderVariant == b.m_shaderVariant;
417
0
    }
418
419
    friend bool operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept
420
0
    {
421
0
        return !(a == b);
422
0
    }
423
424
    friend size_t qHash(const QRhiShaderStage &v, size_t seed = 0) noexcept
425
0
    {
426
0
        QtPrivate::QHashCombine hash(seed);
427
0
        seed = hash(seed, v.m_type);
428
0
        seed = hash(seed, v.m_shader);
429
0
        seed = hash(seed, v.m_shaderVariant);
430
0
        return seed;
431
0
    }
432
};
433
434
Q_DECLARE_TYPEINFO(QRhiShaderStage, Q_RELOCATABLE_TYPE);
435
436
#ifndef QT_NO_DEBUG_STREAM
437
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderStage &);
438
#endif
439
440
using QRhiGraphicsShaderStage = QRhiShaderStage;
441
442
class Q_GUI_EXPORT QRhiShaderResourceBinding
443
{
444
public:
445
    enum Type {
446
        UniformBuffer,
447
        SampledTexture,
448
        Texture,
449
        Sampler,
450
        ImageLoad,
451
        ImageStore,
452
        ImageLoadStore,
453
        BufferLoad,
454
        BufferStore,
455
        BufferLoadStore
456
    };
457
458
    enum StageFlag {
459
        VertexStage = 1 << 0,
460
        TessellationControlStage = 1 << 1,
461
        TessellationEvaluationStage = 1 << 2,
462
        GeometryStage = 1 << 3,
463
        FragmentStage = 1 << 4,
464
        ComputeStage = 1 << 5
465
    };
466
    Q_DECLARE_FLAGS(StageFlags, StageFlag)
467
468
0
    QRhiShaderResourceBinding() = default;
469
470
    bool isLayoutCompatible(const QRhiShaderResourceBinding &other) const;
471
472
    static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf);
473
    static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
474
    static QRhiShaderResourceBinding uniformBufferWithDynamicOffset(int binding, StageFlags stage, QRhiBuffer *buf, quint32 size);
475
476
    static QRhiShaderResourceBinding sampledTexture(int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler);
477
478
    struct TextureAndSampler {
479
        QRhiTexture *tex;
480
        QRhiSampler *sampler;
481
    };
482
    static QRhiShaderResourceBinding sampledTextures(int binding, StageFlags stage, int count, const TextureAndSampler *texSamplers);
483
484
    static QRhiShaderResourceBinding texture(int binding, StageFlags stage, QRhiTexture *tex);
485
    static QRhiShaderResourceBinding textures(int binding, StageFlags stage, int count, QRhiTexture **tex);
486
    static QRhiShaderResourceBinding sampler(int binding, StageFlags stage, QRhiSampler *sampler);
487
488
    static QRhiShaderResourceBinding imageLoad(int binding, StageFlags stage, QRhiTexture *tex, int level);
489
    static QRhiShaderResourceBinding imageStore(int binding, StageFlags stage, QRhiTexture *tex, int level);
490
    static QRhiShaderResourceBinding imageLoadStore(int binding, StageFlags stage, QRhiTexture *tex, int level);
491
492
    static QRhiShaderResourceBinding bufferLoad(int binding, StageFlags stage, QRhiBuffer *buf);
493
    static QRhiShaderResourceBinding bufferLoad(int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
494
    static QRhiShaderResourceBinding bufferStore(int binding, StageFlags stage, QRhiBuffer *buf);
495
    static QRhiShaderResourceBinding bufferStore(int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
496
    static QRhiShaderResourceBinding bufferLoadStore(int binding, StageFlags stage, QRhiBuffer *buf);
497
    static QRhiShaderResourceBinding bufferLoadStore(int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
498
499
    struct Data
500
    {
501
        int binding;
502
        QRhiShaderResourceBinding::StageFlags stage;
503
        QRhiShaderResourceBinding::Type type;
504
        struct UniformBufferData {
505
            QRhiBuffer *buf;
506
            quint32 offset;
507
            quint32 maybeSize;
508
            bool hasDynamicOffset;
509
        };
510
        static constexpr int MAX_TEX_SAMPLER_ARRAY_SIZE = 16;
511
        struct TextureAndOrSamplerData {
512
            int count;
513
            TextureAndSampler texSamplers[MAX_TEX_SAMPLER_ARRAY_SIZE];
514
        };
515
        struct StorageImageData {
516
            QRhiTexture *tex;
517
            int level;
518
        };
519
        struct StorageBufferData {
520
            QRhiBuffer *buf;
521
            quint32 offset;
522
            quint32 maybeSize;
523
        };
524
        union {
525
            UniformBufferData ubuf;
526
            TextureAndOrSamplerData stex;
527
            StorageImageData simage;
528
            StorageBufferData sbuf;
529
        } u;
530
531
        int arraySize() const
532
0
        {
533
0
            return type == QRhiShaderResourceBinding::SampledTexture || type == QRhiShaderResourceBinding::Texture
534
0
                    ? u.stex.count
535
0
                    : 1;
536
0
        }
537
538
        template<typename Output>
539
        Output serialize(Output dst) const
540
0
        {
541
            // must write out exactly LAYOUT_DESC_ENTRIES_PER_BINDING elements here
542
0
            *dst++ = quint32(binding);
543
0
            *dst++ = quint32(stage);
544
0
            *dst++ = quint32(type);
545
0
            *dst++ = quint32(arraySize());
546
0
            return dst;
547
0
        }
548
    };
549
550
    static constexpr int LAYOUT_DESC_ENTRIES_PER_BINDING = 4;
551
552
    template<typename Output>
553
    static void serializeLayoutDescription(const QRhiShaderResourceBinding *first,
554
                                           const QRhiShaderResourceBinding *last,
555
                                           Output dst)
556
    {
557
        while (first != last) {
558
            dst = first->d.serialize(dst);
559
            ++first;
560
        }
561
    }
562
563
private:
564
    Data d;
565
    friend class QRhiImplementation;
566
};
567
568
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBinding::StageFlags)
Unexecuted instantiation: operator|(QRhiShaderResourceBinding::StageFlag, QRhiShaderResourceBinding::StageFlag)
Unexecuted instantiation: operator|(QRhiShaderResourceBinding::StageFlag, QFlags<QRhiShaderResourceBinding::StageFlag>)
Unexecuted instantiation: operator&(QRhiShaderResourceBinding::StageFlag, QRhiShaderResourceBinding::StageFlag)
Unexecuted instantiation: operator&(QRhiShaderResourceBinding::StageFlag, QFlags<QRhiShaderResourceBinding::StageFlag>)
Unexecuted instantiation: operator^(QRhiShaderResourceBinding::StageFlag, QRhiShaderResourceBinding::StageFlag)
Unexecuted instantiation: operator^(QRhiShaderResourceBinding::StageFlag, QFlags<QRhiShaderResourceBinding::StageFlag>)
Unexecuted instantiation: operator|(QRhiShaderResourceBinding::StageFlag, int)
569
0
570
0
Q_DECLARE_TYPEINFO(QRhiShaderResourceBinding, Q_PRIMITIVE_TYPE);
571
0
572
0
Q_GUI_EXPORT bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) noexcept;
573
0
Q_GUI_EXPORT bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) noexcept;
574
0
Q_GUI_EXPORT size_t qHash(const QRhiShaderResourceBinding &b, size_t seed = 0) noexcept;
575
0
#ifndef QT_NO_DEBUG_STREAM
576
0
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderResourceBinding &);
577
0
#endif
578
0
579
0
class Q_GUI_EXPORT QRhiColorAttachment
580
0
{
581
0
public:
582
0
    QRhiColorAttachment() = default;
583
0
    QRhiColorAttachment(QRhiTexture *texture);
584
0
    QRhiColorAttachment(QRhiRenderBuffer *renderBuffer);
585
0
586
0
    QRhiTexture *texture() const { return m_texture; }
587
0
    void setTexture(QRhiTexture *tex) { m_texture = tex; }
588
589
0
    QRhiRenderBuffer *renderBuffer() const { return m_renderBuffer; }
590
0
    void setRenderBuffer(QRhiRenderBuffer *rb) { m_renderBuffer = rb; }
591
592
0
    int layer() const { return m_layer; }
593
0
    void setLayer(int layer) { m_layer = layer; }
594
595
0
    int level() const { return m_level; }
596
0
    void setLevel(int level) { m_level = level; }
597
598
0
    QRhiTexture *resolveTexture() const { return m_resolveTexture; }
599
0
    void setResolveTexture(QRhiTexture *tex) { m_resolveTexture = tex; }
600
601
0
    int resolveLayer() const { return m_resolveLayer; }
602
0
    void setResolveLayer(int layer) { m_resolveLayer = layer; }
603
604
0
    int resolveLevel() const { return m_resolveLevel; }
605
0
    void setResolveLevel(int level) { m_resolveLevel = level; }
606
607
0
    int multiViewCount() const { return m_multiViewCount; }
608
0
    void setMultiViewCount(int count) { m_multiViewCount = count; }
609
610
private:
611
    QRhiTexture *m_texture = nullptr;
612
    QRhiRenderBuffer *m_renderBuffer = nullptr;
613
    int m_layer = 0;
614
    int m_level = 0;
615
    QRhiTexture *m_resolveTexture = nullptr;
616
    int m_resolveLayer = 0;
617
    int m_resolveLevel = 0;
618
    int m_multiViewCount = 0;
619
};
620
621
Q_DECLARE_TYPEINFO(QRhiColorAttachment, Q_RELOCATABLE_TYPE);
622
623
class Q_GUI_EXPORT QRhiTextureRenderTargetDescription
624
{
625
public:
626
    QRhiTextureRenderTargetDescription() = default;
627
    QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment);
628
    QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiRenderBuffer *depthStencilBuffer);
629
    QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiTexture *depthTexture);
630
631
0
    void setColorAttachments(std::initializer_list<QRhiColorAttachment> list) { m_colorAttachments = list; }
632
    template<typename InputIterator>
633
    void setColorAttachments(InputIterator first, InputIterator last)
634
    {
635
        m_colorAttachments.clear();
636
        std::copy(first, last, std::back_inserter(m_colorAttachments));
637
    }
638
0
    const QRhiColorAttachment *cbeginColorAttachments() const { return m_colorAttachments.cbegin(); }
639
0
    const QRhiColorAttachment *cendColorAttachments() const { return m_colorAttachments.cend(); }
640
0
    const QRhiColorAttachment *colorAttachmentAt(qsizetype index) const { return &m_colorAttachments.at(index); }
641
0
    qsizetype colorAttachmentCount() const { return m_colorAttachments.count(); }
642
643
0
    QRhiRenderBuffer *depthStencilBuffer() const { return m_depthStencilBuffer; }
644
0
    void setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer) { m_depthStencilBuffer = renderBuffer; }
645
646
0
    QRhiTexture *depthTexture() const { return m_depthTexture; }
647
0
    void setDepthTexture(QRhiTexture *texture) { m_depthTexture = texture; }
648
649
0
    int depthLayer() const { return m_depthLayer; }
650
0
    void setDepthLayer(int depthLayer) { m_depthLayer = depthLayer; }
651
652
0
    QRhiTexture *depthResolveTexture() const { return m_depthResolveTexture; }
653
0
    void setDepthResolveTexture(QRhiTexture *tex) { m_depthResolveTexture = tex; }
654
655
0
    QRhiShadingRateMap *shadingRateMap() const { return m_shadingRateMap; }
656
0
    void setShadingRateMap(QRhiShadingRateMap *map) { m_shadingRateMap = map; }
657
658
private:
659
    QVarLengthArray<QRhiColorAttachment, 8> m_colorAttachments;
660
    QRhiRenderBuffer *m_depthStencilBuffer = nullptr;
661
    QRhiTexture *m_depthTexture = nullptr;
662
    QRhiTexture *m_depthResolveTexture = nullptr;
663
    QRhiShadingRateMap *m_shadingRateMap = nullptr;
664
    int m_depthLayer = -1;
665
};
666
667
class Q_GUI_EXPORT QRhiTextureSubresourceUploadDescription
668
{
669
public:
670
    QRhiTextureSubresourceUploadDescription() = default;
671
    explicit QRhiTextureSubresourceUploadDescription(const QImage &image);
672
    QRhiTextureSubresourceUploadDescription(const void *data, quint32 size);
673
    explicit QRhiTextureSubresourceUploadDescription(const QByteArray &data);
674
675
0
    QImage image() const { return m_image; }
676
0
    void setImage(const QImage &image) { m_image = image; }
677
678
0
    QByteArray data() const { return m_data; }
679
0
    void setData(const QByteArray &data) { m_data = data; }
680
681
0
    quint32 dataStride() const { return m_dataStride; }
682
0
    void setDataStride(quint32 stride) { m_dataStride = stride; }
683
684
0
    QPoint destinationTopLeft() const { return m_destinationTopLeft; }
685
0
    void setDestinationTopLeft(const QPoint &p) { m_destinationTopLeft = p; }
686
687
0
    QSize sourceSize() const { return m_sourceSize; }
688
0
    void setSourceSize(const QSize &size) { m_sourceSize = size; }
689
690
0
    QPoint sourceTopLeft() const { return m_sourceTopLeft; }
691
0
    void setSourceTopLeft(const QPoint &p) { m_sourceTopLeft = p; }
692
693
private:
694
    QImage m_image;
695
    QByteArray m_data;
696
    quint32 m_dataStride = 0;
697
    QPoint m_destinationTopLeft;
698
    QSize m_sourceSize;
699
    QPoint m_sourceTopLeft;
700
};
701
702
Q_DECLARE_TYPEINFO(QRhiTextureSubresourceUploadDescription, Q_RELOCATABLE_TYPE);
703
704
class Q_GUI_EXPORT QRhiTextureUploadEntry
705
{
706
public:
707
    QRhiTextureUploadEntry() = default;
708
    QRhiTextureUploadEntry(int layer, int level, const QRhiTextureSubresourceUploadDescription &desc);
709
710
0
    int layer() const { return m_layer; }
711
0
    void setLayer(int layer) { m_layer = layer; }
712
713
0
    int level() const { return m_level; }
714
0
    void setLevel(int level) { m_level = level; }
715
716
0
    QRhiTextureSubresourceUploadDescription description() const { return m_desc; }
717
0
    void setDescription(const QRhiTextureSubresourceUploadDescription &desc) { m_desc = desc; }
718
719
private:
720
    int m_layer = 0;
721
    int m_level = 0;
722
    QRhiTextureSubresourceUploadDescription m_desc;
723
};
724
725
Q_DECLARE_TYPEINFO(QRhiTextureUploadEntry, Q_RELOCATABLE_TYPE);
726
727
class Q_GUI_EXPORT QRhiTextureUploadDescription
728
{
729
public:
730
    QRhiTextureUploadDescription() = default;
731
    QRhiTextureUploadDescription(const QRhiTextureUploadEntry &entry);
732
    QRhiTextureUploadDescription(std::initializer_list<QRhiTextureUploadEntry> list);
733
734
0
    void setEntries(std::initializer_list<QRhiTextureUploadEntry> list) { m_entries = list; }
735
    template<typename InputIterator>
736
    void setEntries(InputIterator first, InputIterator last)
737
    {
738
        m_entries.clear();
739
        std::copy(first, last, std::back_inserter(m_entries));
740
    }
741
0
    const QRhiTextureUploadEntry *cbeginEntries() const { return m_entries.cbegin(); }
742
0
    const QRhiTextureUploadEntry *cendEntries() const { return m_entries.cend(); }
743
0
    const QRhiTextureUploadEntry *entryAt(qsizetype index) const { return &m_entries.at(index); }
744
0
    qsizetype entryCount() const { return m_entries.count(); }
745
746
private:
747
    QVarLengthArray<QRhiTextureUploadEntry, 16> m_entries;
748
};
749
750
class Q_GUI_EXPORT QRhiBufferCopyDescription
751
{
752
public:
753
    QRhiBufferCopyDescription() = default;
754
755
0
    quint32 size() const { return m_size; }
756
0
    void setSize(quint32 sz) { m_size = sz; }
757
758
0
    quint32 sourceOffset() const { return m_sourceOffset; }
759
0
    void setSourceOffset(quint32 offset) { m_sourceOffset = offset; }
760
761
0
    quint32 destinationOffset() const { return m_destinationOffset; }
762
0
    void setDestinationOffset(quint32 offset) { m_destinationOffset = offset; }
763
764
private:
765
    quint32 m_size = 0;
766
    quint32 m_sourceOffset = 0;
767
    quint32 m_destinationOffset = 0;
768
};
769
770
Q_DECLARE_TYPEINFO(QRhiBufferCopyDescription, Q_RELOCATABLE_TYPE);
771
772
class Q_GUI_EXPORT QRhiTextureCopyDescription
773
{
774
public:
775
0
    QRhiTextureCopyDescription() = default;
776
777
0
    QSize pixelSize() const { return m_pixelSize; }
778
0
    void setPixelSize(const QSize &sz) { m_pixelSize = sz; }
779
780
0
    int sourceLayer() const { return m_sourceLayer; }
781
0
    void setSourceLayer(int layer) { m_sourceLayer = layer; }
782
783
0
    int sourceLevel() const { return m_sourceLevel; }
784
0
    void setSourceLevel(int level) { m_sourceLevel = level; }
785
786
0
    QPoint sourceTopLeft() const { return m_sourceTopLeft; }
787
0
    void setSourceTopLeft(const QPoint &p) { m_sourceTopLeft = p; }
788
789
0
    int destinationLayer() const { return m_destinationLayer; }
790
0
    void setDestinationLayer(int layer) { m_destinationLayer = layer; }
791
792
0
    int destinationLevel() const { return m_destinationLevel; }
793
0
    void setDestinationLevel(int level) { m_destinationLevel = level; }
794
795
0
    QPoint destinationTopLeft() const { return m_destinationTopLeft; }
796
0
    void setDestinationTopLeft(const QPoint &p) { m_destinationTopLeft = p; }
797
798
private:
799
    QSize m_pixelSize;
800
    int m_sourceLayer = 0;
801
    int m_sourceLevel = 0;
802
    QPoint m_sourceTopLeft;
803
    int m_destinationLayer = 0;
804
    int m_destinationLevel = 0;
805
    QPoint m_destinationTopLeft;
806
};
807
808
Q_DECLARE_TYPEINFO(QRhiTextureCopyDescription, Q_RELOCATABLE_TYPE);
809
810
class Q_GUI_EXPORT QRhiReadbackDescription
811
{
812
public:
813
0
    QRhiReadbackDescription() = default;
814
    QRhiReadbackDescription(QRhiTexture *texture);
815
816
0
    QRhiTexture *texture() const { return m_texture; }
817
0
    void setTexture(QRhiTexture *tex) { m_texture = tex; }
818
819
0
    int layer() const { return m_layer; }
820
0
    void setLayer(int layer) { m_layer = layer; }
821
822
0
    int level() const { return m_level; }
823
0
    void setLevel(int level) { m_level = level; }
824
825
0
    QRect rect() const { return m_rect; }
826
0
    void setRect(const QRect &rectangle) { m_rect = rectangle; }
827
828
private:
829
    QRhiTexture *m_texture = nullptr;
830
    int m_layer = 0;
831
    int m_level = 0;
832
    QRect m_rect;
833
};
834
835
Q_DECLARE_TYPEINFO(QRhiReadbackDescription, Q_RELOCATABLE_TYPE);
836
837
struct Q_GUI_EXPORT QRhiNativeHandles
838
{
839
};
840
841
class Q_GUI_EXPORT QRhiResource
842
{
843
public:
844
    enum Type {
845
        Buffer,
846
        Texture,
847
        Sampler,
848
        RenderBuffer,
849
        RenderPassDescriptor,
850
        SwapChainRenderTarget,
851
        TextureRenderTarget,
852
        ShaderResourceBindings,
853
        GraphicsPipeline,
854
        SwapChain,
855
        ComputePipeline,
856
        CommandBuffer,
857
        ShadingRateMap,
858
        IndirectCommandBuffer
859
    };
860
861
    virtual ~QRhiResource();
862
863
    virtual Type resourceType() const = 0;
864
865
    virtual void destroy() = 0;
866
867
    void deleteLater();
868
869
    QByteArray name() const;
870
    void setName(const QByteArray &name);
871
872
    quint64 globalResourceId() const;
873
874
    QRhi *rhi() const;
875
876
protected:
877
    QRhiResource(QRhiImplementation *rhi);
878
    Q_DISABLE_COPY(QRhiResource)
879
    friend class QRhiImplementation;
880
    QRhiImplementation *m_rhi = nullptr;
881
    quint64 m_id;
882
    QByteArray m_objectName;
883
};
884
885
class Q_GUI_EXPORT QRhiBuffer : public QRhiResource
886
{
887
public:
888
    enum Type {
889
        Immutable,
890
        Static,
891
        Dynamic
892
    };
893
894
    enum UsageFlag {
895
        VertexBuffer = 1 << 0,
896
        IndexBuffer = 1 << 1,
897
        UniformBuffer = 1 << 2,
898
        StorageBuffer = 1 << 3,
899
        IndirectBuffer = 1 << 4,
900
    };
901
    Q_DECLARE_FLAGS(UsageFlags, UsageFlag)
902
903
    struct NativeBuffer {
904
        const void *objects[3];
905
        int slotCount;
906
    };
907
908
    QRhiResource::Type resourceType() const override;
909
910
0
    Type type() const { return m_type; }
911
0
    void setType(Type t) { m_type = t; }
912
913
0
    UsageFlags usage() const { return m_usage; }
914
0
    void setUsage(UsageFlags u) { m_usage = u; }
915
916
0
    quint32 size() const { return m_size; }
917
0
    void setSize(quint32 sz) { m_size = sz; }
918
919
    virtual bool create() = 0;
920
921
    virtual NativeBuffer nativeBuffer();
922
923
    virtual char *beginFullDynamicBufferUpdateForCurrentFrame();
924
    virtual void endFullDynamicBufferUpdateForCurrentFrame();
925
    virtual void fullDynamicBufferUpdateForCurrentFrame(const void *data, quint32 size = 0);
926
927
protected:
928
    QRhiBuffer(QRhiImplementation *rhi, Type type_, UsageFlags usage_, quint32 size_);
929
    Type m_type;
930
    UsageFlags m_usage;
931
    quint32 m_size;
932
};
933
934
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiBuffer::UsageFlags)
Unexecuted instantiation: operator|(QRhiBuffer::UsageFlag, QRhiBuffer::UsageFlag)
Unexecuted instantiation: operator|(QRhiBuffer::UsageFlag, QFlags<QRhiBuffer::UsageFlag>)
Unexecuted instantiation: operator&(QRhiBuffer::UsageFlag, QRhiBuffer::UsageFlag)
Unexecuted instantiation: operator&(QRhiBuffer::UsageFlag, QFlags<QRhiBuffer::UsageFlag>)
Unexecuted instantiation: operator^(QRhiBuffer::UsageFlag, QRhiBuffer::UsageFlag)
Unexecuted instantiation: operator^(QRhiBuffer::UsageFlag, QFlags<QRhiBuffer::UsageFlag>)
Unexecuted instantiation: operator|(QRhiBuffer::UsageFlag, int)
935
0
936
0
class Q_GUI_EXPORT QRhiTexture : public QRhiResource
937
0
{
938
0
public:
939
0
    enum Flag {
940
0
        RenderTarget = 1 << 0,
941
0
        CubeMap = 1 << 2,
942
0
        MipMapped = 1 << 3,
943
0
        sRGB = 1 << 4,
944
0
        UsedAsTransferSource = 1 << 5,
945
0
        UsedWithGenerateMips = 1 << 6,
946
0
        UsedWithLoadStore = 1 << 7,
947
0
        UsedAsCompressedAtlas = 1 << 8,
948
0
        ExternalOES = 1 << 9,
949
0
        ThreeDimensional = 1 << 10,
950
0
        TextureRectangleGL = 1 << 11,
951
0
        TextureArray = 1 << 12,
952
0
        OneDimensional = 1 << 13,
953
0
        UsedAsShadingRateMap = 1 << 14
954
0
    };
955
0
    Q_DECLARE_FLAGS(Flags, Flag)
956
0
957
0
    enum Format {
958
0
        UnknownFormat,
959
0
960
0
        RGBA8,
961
0
        BGRA8,
962
0
        R8,
963
0
        RG8,
964
0
        R16,
965
0
        RG16,
966
0
        RED_OR_ALPHA8,
967
0
968
0
        RGBA16F,
969
0
        RGBA32F,
970
0
        R16F,
971
0
        R32F,
972
0
973
0
        RGB10A2,
974
0
975
0
        R8SI,
976
0
        R32SI,
977
0
        RG32SI,
978
0
        RGBA32SI,
979
0
980
0
        R8UI,
981
0
        R32UI,
982
0
        RG32UI,
983
0
        RGBA32UI,
984
0
985
0
        D16,
986
0
        D24,
987
0
        D24S8,
988
0
        D32F,
989
0
        D32FS8,
990
0
991
0
        BC1,
992
0
        BC2,
993
0
        BC3,
994
0
        BC4,
995
0
        BC5,
996
0
        BC6H,
997
0
        BC7,
998
0
999
0
        ETC2_RGB8,
1000
0
        ETC2_RGB8A1,
1001
0
        ETC2_RGBA8,
1002
0
1003
0
        ASTC_4x4,
1004
0
        ASTC_5x4,
1005
0
        ASTC_5x5,
1006
0
        ASTC_6x5,
1007
0
        ASTC_6x6,
1008
0
        ASTC_8x5,
1009
0
        ASTC_8x6,
1010
0
        ASTC_8x8,
1011
0
        ASTC_10x5,
1012
0
        ASTC_10x6,
1013
0
        ASTC_10x8,
1014
0
        ASTC_10x10,
1015
0
        ASTC_12x10,
1016
0
        ASTC_12x12
1017
0
    };
1018
0
1019
0
    struct NativeTexture {
1020
0
        quint64 object;
1021
0
        int layout; // or state
1022
0
    };
1023
0
1024
0
    QRhiResource::Type resourceType() const override;
1025
0
1026
0
    Format format() const { return m_format; }
1027
0
    void setFormat(Format fmt) { m_format = fmt; }
1028
1029
0
    QSize pixelSize() const { return m_pixelSize; }
1030
0
    void setPixelSize(const QSize &sz) { m_pixelSize = sz; }
1031
1032
0
    int depth() const { return m_depth; }
1033
0
    void setDepth(int depth) { m_depth = depth; }
1034
1035
0
    int arraySize() const { return m_arraySize; }
1036
0
    void setArraySize(int arraySize) { m_arraySize = arraySize; }
1037
1038
0
    int arrayRangeStart() const { return m_arrayRangeStart; }
1039
0
    int arrayRangeLength() const { return m_arrayRangeLength; }
1040
    void setArrayRange(int startIndex, int count)
1041
0
    {
1042
0
        m_arrayRangeStart = startIndex;
1043
0
        m_arrayRangeLength = count;
1044
0
    }
1045
1046
0
    Flags flags() const { return m_flags; }
1047
0
    void setFlags(Flags f) { m_flags = f; }
1048
1049
0
    int sampleCount() const { return m_sampleCount; }
1050
0
    void setSampleCount(int s) { m_sampleCount = s; }
1051
1052
    struct ViewFormat {
1053
        QRhiTexture::Format format;
1054
        bool srgb;
1055
    };
1056
0
    ViewFormat readViewFormat() const { return m_readViewFormat; }
1057
0
    void setReadViewFormat(const ViewFormat &fmt) { m_readViewFormat = fmt; }
1058
0
    ViewFormat writeViewFormat() const { return m_writeViewFormat; }
1059
0
    void setWriteViewFormat(const ViewFormat &fmt) { m_writeViewFormat = fmt; }
1060
1061
    virtual bool create() = 0;
1062
    virtual NativeTexture nativeTexture();
1063
    virtual bool createFrom(NativeTexture src);
1064
    virtual void setNativeLayout(int layout);
1065
1066
protected:
1067
    QRhiTexture(QRhiImplementation *rhi, Format format_, const QSize &pixelSize_, int depth_,
1068
                int arraySize_, int sampleCount_, Flags flags_);
1069
    Format m_format;
1070
    QSize m_pixelSize;
1071
    int m_depth;
1072
    int m_arraySize;
1073
    int m_sampleCount;
1074
    Flags m_flags;
1075
    int m_arrayRangeStart = -1;
1076
    int m_arrayRangeLength = -1;
1077
    ViewFormat m_readViewFormat = { UnknownFormat, false };
1078
    ViewFormat m_writeViewFormat = { UnknownFormat, false };
1079
};
1080
1081
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiTexture::Flags)
Unexecuted instantiation: operator|(QRhiTexture::Flag, QRhiTexture::Flag)
Unexecuted instantiation: operator|(QRhiTexture::Flag, QFlags<QRhiTexture::Flag>)
Unexecuted instantiation: operator&(QRhiTexture::Flag, QRhiTexture::Flag)
Unexecuted instantiation: operator&(QRhiTexture::Flag, QFlags<QRhiTexture::Flag>)
Unexecuted instantiation: operator^(QRhiTexture::Flag, QRhiTexture::Flag)
Unexecuted instantiation: operator^(QRhiTexture::Flag, QFlags<QRhiTexture::Flag>)
Unexecuted instantiation: operator|(QRhiTexture::Flag, int)
1082
0
1083
0
class Q_GUI_EXPORT QRhiSampler : public QRhiResource
1084
0
{
1085
0
public:
1086
0
    enum Filter {
1087
0
        None,
1088
0
        Nearest,
1089
0
        Linear
1090
0
    };
1091
0
1092
0
    enum AddressMode {
1093
0
        Repeat,
1094
0
        ClampToEdge,
1095
0
        Mirror,
1096
0
    };
1097
0
1098
0
    enum CompareOp {
1099
0
        Never,
1100
0
        Less,
1101
0
        Equal,
1102
0
        LessOrEqual,
1103
0
        Greater,
1104
0
        NotEqual,
1105
0
        GreaterOrEqual,
1106
0
        Always
1107
0
    };
1108
0
1109
0
    QRhiResource::Type resourceType() const override;
1110
0
1111
0
    Filter magFilter() const { return m_magFilter; }
1112
0
    void setMagFilter(Filter f) { m_magFilter = f; }
1113
1114
0
    Filter minFilter() const { return m_minFilter; }
1115
0
    void setMinFilter(Filter f) { m_minFilter = f; }
1116
1117
0
    Filter mipmapMode() const { return m_mipmapMode; }
1118
0
    void setMipmapMode(Filter f) { m_mipmapMode = f; }
1119
1120
0
    AddressMode addressU() const { return m_addressU; }
1121
0
    void setAddressU(AddressMode mode) { m_addressU = mode; }
1122
1123
0
    AddressMode addressV() const { return m_addressV; }
1124
0
    void setAddressV(AddressMode mode) { m_addressV = mode; }
1125
1126
0
    AddressMode addressW() const { return m_addressW; }
1127
0
    void setAddressW(AddressMode mode) { m_addressW = mode; }
1128
1129
0
    CompareOp textureCompareOp() const { return m_compareOp; }
1130
0
    void setTextureCompareOp(CompareOp op) { m_compareOp = op; }
1131
1132
    virtual bool create() = 0;
1133
1134
protected:
1135
    QRhiSampler(QRhiImplementation *rhi,
1136
                Filter magFilter_, Filter minFilter_, Filter mipmapMode_,
1137
                AddressMode u_, AddressMode v_, AddressMode w_);
1138
    Filter m_magFilter;
1139
    Filter m_minFilter;
1140
    Filter m_mipmapMode;
1141
    AddressMode m_addressU;
1142
    AddressMode m_addressV;
1143
    AddressMode m_addressW;
1144
    CompareOp m_compareOp;
1145
};
1146
1147
class Q_GUI_EXPORT QRhiRenderBuffer : public QRhiResource
1148
{
1149
public:
1150
    enum Type {
1151
        DepthStencil,
1152
        Color
1153
    };
1154
1155
    enum Flag {
1156
        UsedWithSwapChainOnly = 1 << 0,
1157
        NoTransientBacking = 1 << 1
1158
    };
1159
    Q_DECLARE_FLAGS(Flags, Flag)
1160
1161
    struct NativeRenderBuffer {
1162
        quint64 object;
1163
    };
1164
1165
    QRhiResource::Type resourceType() const override;
1166
1167
0
    Type type() const { return m_type; }
1168
0
    void setType(Type t) { m_type = t; }
1169
1170
0
    QSize pixelSize() const { return m_pixelSize; }
1171
0
    void setPixelSize(const QSize &sz) { m_pixelSize = sz; }
1172
1173
0
    int sampleCount() const { return m_sampleCount; }
1174
0
    void setSampleCount(int s) { m_sampleCount = s; }
1175
1176
0
    Flags flags() const { return m_flags; }
1177
0
    void setFlags(Flags f) { m_flags = f; }
1178
1179
    virtual bool create() = 0;
1180
    virtual bool createFrom(NativeRenderBuffer src);
1181
1182
    virtual QRhiTexture::Format backingFormat() const = 0;
1183
1184
protected:
1185
    QRhiRenderBuffer(QRhiImplementation *rhi, Type type_, const QSize &pixelSize_,
1186
                     int sampleCount_, Flags flags_, QRhiTexture::Format backingFormatHint_);
1187
    Type m_type;
1188
    QSize m_pixelSize;
1189
    int m_sampleCount;
1190
    Flags m_flags;
1191
    QRhiTexture::Format m_backingFormatHint;
1192
};
1193
1194
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiRenderBuffer::Flags)
Unexecuted instantiation: operator|(QRhiRenderBuffer::Flag, QRhiRenderBuffer::Flag)
Unexecuted instantiation: operator|(QRhiRenderBuffer::Flag, QFlags<QRhiRenderBuffer::Flag>)
Unexecuted instantiation: operator&(QRhiRenderBuffer::Flag, QRhiRenderBuffer::Flag)
Unexecuted instantiation: operator&(QRhiRenderBuffer::Flag, QFlags<QRhiRenderBuffer::Flag>)
Unexecuted instantiation: operator^(QRhiRenderBuffer::Flag, QRhiRenderBuffer::Flag)
Unexecuted instantiation: operator^(QRhiRenderBuffer::Flag, QFlags<QRhiRenderBuffer::Flag>)
Unexecuted instantiation: operator|(QRhiRenderBuffer::Flag, int)
1195
0
1196
0
class Q_GUI_EXPORT QRhiShadingRateMap : public QRhiResource
1197
0
{
1198
0
public:
1199
0
    struct NativeShadingRateMap {
1200
0
        quint64 object;
1201
0
    };
1202
0
1203
0
    QRhiResource::Type resourceType() const override;
1204
0
1205
0
    virtual bool createFrom(NativeShadingRateMap src);
1206
0
    virtual bool createFrom(QRhiTexture *src);
1207
0
1208
0
    virtual QSize logicalSize() const;
1209
0
1210
0
protected:
1211
0
    QRhiShadingRateMap(QRhiImplementation *rhi);
1212
0
};
1213
0
1214
0
class Q_GUI_EXPORT QRhiRenderPassDescriptor : public QRhiResource
1215
0
{
1216
0
public:
1217
0
    QRhiResource::Type resourceType() const override;
1218
0
1219
0
    virtual bool isCompatible(const QRhiRenderPassDescriptor *other) const = 0;
1220
0
    virtual const QRhiNativeHandles *nativeHandles();
1221
0
1222
0
    virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() const = 0;
1223
0
1224
0
    virtual QVector<quint32> serializedFormat() const = 0;
1225
0
1226
0
protected:
1227
0
    QRhiRenderPassDescriptor(QRhiImplementation *rhi);
1228
0
};
1229
0
1230
0
class Q_GUI_EXPORT QRhiRenderTarget : public QRhiResource
1231
0
{
1232
0
public:
1233
0
    virtual QSize pixelSize() const = 0;
1234
0
    virtual float devicePixelRatio() const = 0;
1235
0
    virtual int sampleCount() const = 0;
1236
0
1237
0
    QRhiRenderPassDescriptor *renderPassDescriptor() const { return m_renderPassDesc; }
1238
0
    void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
1239
1240
protected:
1241
    QRhiRenderTarget(QRhiImplementation *rhi);
1242
    QRhiRenderPassDescriptor *m_renderPassDesc = nullptr;
1243
};
1244
1245
class Q_GUI_EXPORT QRhiSwapChainRenderTarget : public QRhiRenderTarget
1246
{
1247
public:
1248
    QRhiResource::Type resourceType() const override;
1249
0
    QRhiSwapChain *swapChain() const { return m_swapchain; }
1250
1251
protected:
1252
    QRhiSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain_);
1253
    QRhiSwapChain *m_swapchain;
1254
};
1255
1256
class Q_GUI_EXPORT QRhiTextureRenderTarget : public QRhiRenderTarget
1257
{
1258
public:
1259
    enum Flag {
1260
        PreserveColorContents = 1 << 0,
1261
        PreserveDepthStencilContents = 1 << 1,
1262
        DoNotStoreDepthStencilContents = 1 << 2
1263
    };
1264
    Q_DECLARE_FLAGS(Flags, Flag)
1265
1266
    QRhiResource::Type resourceType() const override;
1267
1268
0
    QRhiTextureRenderTargetDescription description() const { return m_desc; }
1269
0
    void setDescription(const QRhiTextureRenderTargetDescription &desc) { m_desc = desc; }
1270
1271
0
    Flags flags() const { return m_flags; }
1272
0
    void setFlags(Flags f) { m_flags = f; }
1273
1274
    virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() = 0;
1275
1276
    virtual bool create() = 0;
1277
1278
protected:
1279
    QRhiTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc_, Flags flags_);
1280
    QRhiTextureRenderTargetDescription m_desc;
1281
    Flags m_flags;
1282
};
1283
1284
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiTextureRenderTarget::Flags)
Unexecuted instantiation: operator|(QRhiTextureRenderTarget::Flag, QRhiTextureRenderTarget::Flag)
Unexecuted instantiation: operator|(QRhiTextureRenderTarget::Flag, QFlags<QRhiTextureRenderTarget::Flag>)
Unexecuted instantiation: operator&(QRhiTextureRenderTarget::Flag, QRhiTextureRenderTarget::Flag)
Unexecuted instantiation: operator&(QRhiTextureRenderTarget::Flag, QFlags<QRhiTextureRenderTarget::Flag>)
Unexecuted instantiation: operator^(QRhiTextureRenderTarget::Flag, QRhiTextureRenderTarget::Flag)
Unexecuted instantiation: operator^(QRhiTextureRenderTarget::Flag, QFlags<QRhiTextureRenderTarget::Flag>)
Unexecuted instantiation: operator|(QRhiTextureRenderTarget::Flag, int)
1285
0
1286
0
class Q_GUI_EXPORT QRhiShaderResourceBindings : public QRhiResource
1287
0
{
1288
0
public:
1289
0
    QRhiResource::Type resourceType() const override;
1290
0
1291
0
    void setBindings(std::initializer_list<QRhiShaderResourceBinding> list) { m_bindings = list; }
1292
    template<typename InputIterator>
1293
    void setBindings(InputIterator first, InputIterator last)
1294
    {
1295
        m_bindings.clear();
1296
        std::copy(first, last, std::back_inserter(m_bindings));
1297
    }
1298
0
    const QRhiShaderResourceBinding *cbeginBindings() const { return m_bindings.cbegin(); }
1299
0
    const QRhiShaderResourceBinding *cendBindings() const { return m_bindings.cend(); }
1300
0
    const QRhiShaderResourceBinding *bindingAt(qsizetype index) const { return &m_bindings.at(index); }
1301
0
    qsizetype bindingCount() const { return m_bindings.count(); }
1302
1303
    bool isLayoutCompatible(const QRhiShaderResourceBindings *other) const;
1304
1305
0
    QVector<quint32> serializedLayoutDescription() const { return m_layoutDesc; }
1306
1307
    virtual bool create() = 0;
1308
1309
    enum UpdateFlag {
1310
        BindingsAreSorted = 0x01
1311
    };
1312
    Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag)
1313
1314
    virtual void updateResources(UpdateFlags flags = {}) = 0;
1315
1316
protected:
1317
    static constexpr int BINDING_PREALLOC = 12;
1318
    QRhiShaderResourceBindings(QRhiImplementation *rhi);
1319
    QVarLengthArray<QRhiShaderResourceBinding, BINDING_PREALLOC> m_bindings;
1320
    size_t m_layoutDescHash = 0;
1321
    // Intentionally not using QVLA for m_layoutDesc: clients like Qt Quick are much
1322
    // better served with an implicitly shared container here, because they will likely
1323
    // throw this directly into structs serving as cache keys.
1324
    QVector<quint32> m_layoutDesc;
1325
    friend class QRhiImplementation;
1326
#ifndef QT_NO_DEBUG_STREAM
1327
    friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderResourceBindings &);
1328
#endif
1329
};
1330
1331
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBindings::UpdateFlags)
Unexecuted instantiation: operator|(QRhiShaderResourceBindings::UpdateFlag, QRhiShaderResourceBindings::UpdateFlag)
Unexecuted instantiation: operator|(QRhiShaderResourceBindings::UpdateFlag, QFlags<QRhiShaderResourceBindings::UpdateFlag>)
Unexecuted instantiation: operator&(QRhiShaderResourceBindings::UpdateFlag, QRhiShaderResourceBindings::UpdateFlag)
Unexecuted instantiation: operator&(QRhiShaderResourceBindings::UpdateFlag, QFlags<QRhiShaderResourceBindings::UpdateFlag>)
Unexecuted instantiation: operator^(QRhiShaderResourceBindings::UpdateFlag, QRhiShaderResourceBindings::UpdateFlag)
Unexecuted instantiation: operator^(QRhiShaderResourceBindings::UpdateFlag, QFlags<QRhiShaderResourceBindings::UpdateFlag>)
Unexecuted instantiation: operator|(QRhiShaderResourceBindings::UpdateFlag, int)
1332
0
1333
0
#ifndef QT_NO_DEBUG_STREAM
1334
0
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderResourceBindings &);
1335
0
#endif
1336
0
1337
0
// The proper name. Until it gets rolled out universally, have the better name
1338
0
// as a typedef. Eventually it should be reversed (the old name being a typedef
1339
0
// to the new one).
1340
0
using QRhiShaderResourceBindingSet = QRhiShaderResourceBindings;
1341
0
1342
0
class Q_GUI_EXPORT QRhiGraphicsPipeline : public QRhiResource
1343
0
{
1344
0
public:
1345
0
    enum Flag {
1346
0
        UsesBlendConstants = 1 << 0,
1347
0
        UsesStencilRef = 1 << 1,
1348
0
        UsesScissor = 1 << 2,
1349
0
        CompileShadersWithDebugInfo = 1 << 3,
1350
0
        UsesShadingRate = 1 << 4,
1351
0
        UsesIndirectDraws = 1 << 5
1352
0
    };
1353
0
    Q_DECLARE_FLAGS(Flags, Flag)
1354
0
1355
0
    enum Topology {
1356
0
        Triangles,
1357
0
        TriangleStrip,
1358
0
        TriangleFan,
1359
0
        Lines,
1360
0
        LineStrip,
1361
0
        Points,
1362
0
        Patches
1363
0
    };
1364
0
1365
0
    enum CullMode {
1366
0
        None,
1367
0
        Front,
1368
0
        Back
1369
0
    };
1370
0
1371
0
    enum FrontFace {
1372
0
        CCW,
1373
0
        CW
1374
0
    };
1375
0
1376
0
    enum ColorMaskComponent {
1377
0
        R = 1 << 0,
1378
0
        G = 1 << 1,
1379
0
        B = 1 << 2,
1380
0
        A = 1 << 3
1381
0
    };
1382
0
    Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)
1383
0
1384
0
    enum BlendFactor {
1385
0
        Zero,
1386
0
        One,
1387
0
        SrcColor,
1388
0
        OneMinusSrcColor,
1389
0
        DstColor,
1390
0
        OneMinusDstColor,
1391
0
        SrcAlpha,
1392
0
        OneMinusSrcAlpha,
1393
0
        DstAlpha,
1394
0
        OneMinusDstAlpha,
1395
0
        ConstantColor,
1396
0
        OneMinusConstantColor,
1397
0
        ConstantAlpha,
1398
0
        OneMinusConstantAlpha,
1399
0
        SrcAlphaSaturate,
1400
0
        Src1Color,
1401
0
        OneMinusSrc1Color,
1402
0
        Src1Alpha,
1403
0
        OneMinusSrc1Alpha
1404
0
    };
1405
0
1406
0
    enum BlendOp {
1407
0
        Add,
1408
0
        Subtract,
1409
0
        ReverseSubtract,
1410
0
        Min,
1411
0
        Max
1412
0
    };
1413
0
1414
0
    struct TargetBlend {
1415
0
        ColorMask colorWrite = ColorMask(0xF); // R | G | B | A
1416
0
        bool enable = false;
1417
0
        BlendFactor srcColor = One;
1418
0
        BlendFactor dstColor = OneMinusSrcAlpha;
1419
0
        BlendOp opColor = Add;
1420
0
        BlendFactor srcAlpha = One;
1421
0
        BlendFactor dstAlpha = OneMinusSrcAlpha;
1422
0
        BlendOp opAlpha = Add;
1423
0
    };
1424
0
1425
0
    enum CompareOp {
1426
0
        Never,
1427
0
        Less,
1428
0
        Equal,
1429
0
        LessOrEqual,
1430
0
        Greater,
1431
0
        NotEqual,
1432
0
        GreaterOrEqual,
1433
0
        Always
1434
0
    };
1435
0
1436
0
    enum StencilOp {
1437
0
        StencilZero,
1438
0
        Keep,
1439
0
        Replace,
1440
0
        IncrementAndClamp,
1441
0
        DecrementAndClamp,
1442
0
        Invert,
1443
0
        IncrementAndWrap,
1444
0
        DecrementAndWrap
1445
0
    };
1446
0
1447
0
    struct StencilOpState {
1448
0
        StencilOp failOp = Keep;
1449
0
        StencilOp depthFailOp = Keep;
1450
0
        StencilOp passOp = Keep;
1451
0
        CompareOp compareOp = Always;
1452
0
    };
1453
0
1454
0
    enum PolygonMode {
1455
0
        Fill,
1456
0
        Line
1457
0
    };
1458
0
1459
0
    QRhiResource::Type resourceType() const override;
1460
0
1461
0
    Flags flags() const { return m_flags; }
1462
0
    void setFlags(Flags f) { m_flags = f; }
1463
1464
0
    Topology topology() const { return m_topology; }
1465
0
    void setTopology(Topology t) { m_topology = t; }
1466
1467
0
    CullMode cullMode() const { return m_cullMode; }
1468
0
    void setCullMode(CullMode mode) { m_cullMode = mode; }
1469
1470
0
    FrontFace frontFace() const { return m_frontFace; }
1471
0
    void setFrontFace(FrontFace f) { m_frontFace = f; }
1472
1473
0
    void setTargetBlends(std::initializer_list<TargetBlend> list) { m_targetBlends = list; }
1474
    template<typename InputIterator>
1475
    void setTargetBlends(InputIterator first, InputIterator last)
1476
    {
1477
        m_targetBlends.clear();
1478
        std::copy(first, last, std::back_inserter(m_targetBlends));
1479
    }
1480
0
    const TargetBlend *cbeginTargetBlends() const { return m_targetBlends.cbegin(); }
1481
0
    const TargetBlend *cendTargetBlends() const { return m_targetBlends.cend(); }
1482
0
    const TargetBlend *targetBlendAt(qsizetype index) const { return &m_targetBlends.at(index); }
1483
0
    qsizetype targetBlendCount() const { return m_targetBlends.count(); }
1484
1485
0
    bool hasDepthTest() const { return m_depthTest; }
1486
0
    void setDepthTest(bool enable) { m_depthTest = enable; }
1487
1488
0
    bool hasDepthWrite() const { return m_depthWrite; }
1489
0
    void setDepthWrite(bool enable) { m_depthWrite = enable; }
1490
1491
0
    bool hasDepthClamp() const { return m_depthClamp; }
1492
0
    void setDepthClamp(bool enable) { m_depthClamp = enable; }
1493
1494
0
    CompareOp depthOp() const { return m_depthOp; }
1495
0
    void setDepthOp(CompareOp op) { m_depthOp = op; }
1496
1497
0
    bool hasStencilTest() const { return m_stencilTest; }
1498
0
    void setStencilTest(bool enable) { m_stencilTest = enable; }
1499
1500
0
    StencilOpState stencilFront() const { return m_stencilFront; }
1501
0
    void setStencilFront(const StencilOpState &state) { m_stencilFront = state; }
1502
1503
0
    StencilOpState stencilBack() const { return m_stencilBack; }
1504
0
    void setStencilBack(const StencilOpState &state) { m_stencilBack = state; }
1505
1506
0
    quint32 stencilReadMask() const { return m_stencilReadMask; }
1507
0
    void setStencilReadMask(quint32 mask) { m_stencilReadMask = mask; }
1508
1509
0
    quint32 stencilWriteMask() const { return m_stencilWriteMask; }
1510
0
    void setStencilWriteMask(quint32 mask) { m_stencilWriteMask = mask; }
1511
1512
0
    int sampleCount() const { return m_sampleCount; }
1513
0
    void setSampleCount(int s) { m_sampleCount = s; }
1514
1515
0
    float lineWidth() const { return m_lineWidth; }
1516
0
    void setLineWidth(float width) { m_lineWidth = width; }
1517
1518
0
    int depthBias() const { return m_depthBias; }
1519
0
    void setDepthBias(int bias) { m_depthBias = bias; }
1520
1521
0
    float slopeScaledDepthBias() const { return m_slopeScaledDepthBias; }
1522
0
    void setSlopeScaledDepthBias(float bias) { m_slopeScaledDepthBias = bias; }
1523
1524
0
    void setShaderStages(std::initializer_list<QRhiShaderStage> list) { m_shaderStages = list; }
1525
    template<typename InputIterator>
1526
    void setShaderStages(InputIterator first, InputIterator last)
1527
    {
1528
        m_shaderStages.clear();
1529
        std::copy(first, last, std::back_inserter(m_shaderStages));
1530
    }
1531
0
    const QRhiShaderStage *cbeginShaderStages() const { return m_shaderStages.cbegin(); }
1532
0
    const QRhiShaderStage *cendShaderStages() const { return m_shaderStages.cend(); }
1533
0
    const QRhiShaderStage *shaderStageAt(qsizetype index) const { return &m_shaderStages.at(index); }
1534
0
    qsizetype shaderStageCount() const { return m_shaderStages.count(); }
1535
1536
0
    QRhiVertexInputLayout vertexInputLayout() const { return m_vertexInputLayout; }
1537
0
    void setVertexInputLayout(const QRhiVertexInputLayout &layout) { m_vertexInputLayout = layout; }
1538
1539
0
    QRhiShaderResourceBindings *shaderResourceBindings() const { return m_shaderResourceBindings; }
1540
0
    void setShaderResourceBindings(QRhiShaderResourceBindings *srb) { m_shaderResourceBindings = srb; }
1541
1542
0
    QRhiRenderPassDescriptor *renderPassDescriptor() const { return m_renderPassDesc; }
1543
0
    void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
1544
1545
0
    int patchControlPointCount() const { return m_patchControlPointCount; }
1546
0
    void setPatchControlPointCount(int count) { m_patchControlPointCount = count; }
1547
1548
0
    PolygonMode polygonMode() const {return m_polygonMode; }
1549
0
    void setPolygonMode(PolygonMode mode) {m_polygonMode = mode; }
1550
1551
0
    int multiViewCount() const { return m_multiViewCount; }
1552
0
    void setMultiViewCount(int count) { m_multiViewCount = count; }
1553
1554
    virtual bool create() = 0;
1555
1556
protected:
1557
    QRhiGraphicsPipeline(QRhiImplementation *rhi);
1558
    Flags m_flags;
1559
    Topology m_topology = Triangles;
1560
    CullMode m_cullMode = None;
1561
    FrontFace m_frontFace = CCW;
1562
    QVarLengthArray<TargetBlend, 8> m_targetBlends;
1563
    bool m_depthTest = false;
1564
    bool m_depthWrite = false;
1565
    bool m_depthClamp = false;
1566
    CompareOp m_depthOp = Less;
1567
    bool m_stencilTest = false;
1568
    StencilOpState m_stencilFront;
1569
    StencilOpState m_stencilBack;
1570
    quint32 m_stencilReadMask = 0xFF;
1571
    quint32 m_stencilWriteMask = 0xFF;
1572
    int m_sampleCount = 1;
1573
    float m_lineWidth = 1.0f;
1574
    int m_depthBias = 0;
1575
    float m_slopeScaledDepthBias = 0.0f;
1576
    int m_patchControlPointCount = 3;
1577
    PolygonMode m_polygonMode = Fill;
1578
    int m_multiViewCount = 0;
1579
    QVarLengthArray<QRhiShaderStage, 4> m_shaderStages;
1580
    QRhiVertexInputLayout m_vertexInputLayout;
1581
    QRhiShaderResourceBindings *m_shaderResourceBindings = nullptr;
1582
    QRhiRenderPassDescriptor *m_renderPassDesc = nullptr;
1583
};
1584
1585
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::Flags)
Unexecuted instantiation: operator|(QRhiGraphicsPipeline::Flag, QRhiGraphicsPipeline::Flag)
Unexecuted instantiation: operator|(QRhiGraphicsPipeline::Flag, QFlags<QRhiGraphicsPipeline::Flag>)
Unexecuted instantiation: operator&(QRhiGraphicsPipeline::Flag, QRhiGraphicsPipeline::Flag)
Unexecuted instantiation: operator&(QRhiGraphicsPipeline::Flag, QFlags<QRhiGraphicsPipeline::Flag>)
Unexecuted instantiation: operator^(QRhiGraphicsPipeline::Flag, QRhiGraphicsPipeline::Flag)
Unexecuted instantiation: operator^(QRhiGraphicsPipeline::Flag, QFlags<QRhiGraphicsPipeline::Flag>)
Unexecuted instantiation: operator|(QRhiGraphicsPipeline::Flag, int)
1586
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::ColorMask)
Unexecuted instantiation: operator|(QRhiGraphicsPipeline::ColorMaskComponent, QRhiGraphicsPipeline::ColorMaskComponent)
Unexecuted instantiation: operator|(QRhiGraphicsPipeline::ColorMaskComponent, QFlags<QRhiGraphicsPipeline::ColorMaskComponent>)
Unexecuted instantiation: operator&(QRhiGraphicsPipeline::ColorMaskComponent, QRhiGraphicsPipeline::ColorMaskComponent)
Unexecuted instantiation: operator&(QRhiGraphicsPipeline::ColorMaskComponent, QFlags<QRhiGraphicsPipeline::ColorMaskComponent>)
Unexecuted instantiation: operator^(QRhiGraphicsPipeline::ColorMaskComponent, QRhiGraphicsPipeline::ColorMaskComponent)
Unexecuted instantiation: operator^(QRhiGraphicsPipeline::ColorMaskComponent, QFlags<QRhiGraphicsPipeline::ColorMaskComponent>)
Unexecuted instantiation: operator|(QRhiGraphicsPipeline::ColorMaskComponent, int)
1587
0
Q_DECLARE_TYPEINFO(QRhiGraphicsPipeline::TargetBlend, Q_RELOCATABLE_TYPE);
1588
0
1589
0
struct QRhiSwapChainHdrInfo
1590
0
{
1591
0
    enum LimitsType {
1592
0
        LuminanceInNits,
1593
0
        ColorComponentValue
1594
0
    };
1595
0
1596
0
    enum LuminanceBehavior {
1597
0
        SceneReferred,
1598
0
        DisplayReferred
1599
0
    };
1600
0
1601
0
    LimitsType limitsType;
1602
0
    union {
1603
0
        struct {
1604
0
            float minLuminance;
1605
0
            float maxLuminance;
1606
0
        } luminanceInNits;
1607
0
        struct {
1608
0
            float maxColorComponentValue;
1609
0
            float maxPotentialColorComponentValue;
1610
0
        } colorComponentValue;
1611
0
    } limits;
1612
0
    LuminanceBehavior luminanceBehavior;
1613
0
    float sdrWhiteLevel;
1614
0
};
1615
0
1616
0
Q_DECLARE_TYPEINFO(QRhiSwapChainHdrInfo, Q_RELOCATABLE_TYPE);
1617
0
1618
0
#ifndef QT_NO_DEBUG_STREAM
1619
0
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiSwapChainHdrInfo &);
1620
0
#endif
1621
0
1622
0
struct QRhiSwapChainProxyData
1623
0
{
1624
0
    void *reserved[2] = {};
1625
0
};
1626
0
1627
0
class Q_GUI_EXPORT QRhiSwapChain : public QRhiResource
1628
0
{
1629
0
public:
1630
0
    enum Flag {
1631
0
        SurfaceHasPreMulAlpha = 1 << 0,
1632
0
        SurfaceHasNonPreMulAlpha = 1 << 1,
1633
0
        sRGB = 1 << 2,
1634
0
        UsedAsTransferSource = 1 << 3,
1635
0
        NoVSync = 1 << 4,
1636
0
        MinimalBufferCount = 1 << 5
1637
0
    };
1638
0
    Q_DECLARE_FLAGS(Flags, Flag)
1639
0
1640
0
    enum Format {
1641
0
        SDR,
1642
0
        HDRExtendedSrgbLinear,
1643
0
        HDR10,
1644
0
        HDRExtendedDisplayP3Linear
1645
0
    };
1646
0
1647
0
    enum StereoTargetBuffer {
1648
0
        LeftBuffer,
1649
0
        RightBuffer
1650
0
    };
1651
0
1652
0
    QRhiResource::Type resourceType() const override;
1653
0
1654
0
    QWindow *window() const { return m_window; }
1655
0
    void setWindow(QWindow *window) { m_window = window; }
1656
1657
0
    QRhiSwapChainProxyData proxyData() const { return m_proxyData; }
1658
0
    void setProxyData(const QRhiSwapChainProxyData &d) { m_proxyData = d; }
1659
1660
0
    Flags flags() const { return m_flags; }
1661
0
    void setFlags(Flags f) { m_flags = f; }
1662
1663
0
    Format format() const { return m_format; }
1664
0
    void setFormat(Format f) { m_format = f; }
1665
1666
0
    QRhiRenderBuffer *depthStencil() const { return m_depthStencil; }
1667
0
    void setDepthStencil(QRhiRenderBuffer *ds) { m_depthStencil = ds; }
1668
1669
0
    int sampleCount() const { return m_sampleCount; }
1670
0
    void setSampleCount(int samples) { m_sampleCount = samples; }
1671
1672
0
    QRhiRenderPassDescriptor *renderPassDescriptor() const { return m_renderPassDesc; }
1673
0
    void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
1674
1675
0
    QRhiShadingRateMap *shadingRateMap() const { return m_shadingRateMap; }
1676
0
    void setShadingRateMap(QRhiShadingRateMap *map) { m_shadingRateMap = map; }
1677
1678
0
    QSize currentPixelSize() const { return m_currentPixelSize; }
1679
1680
    virtual QRhiCommandBuffer *currentFrameCommandBuffer() = 0;
1681
    virtual QRhiRenderTarget *currentFrameRenderTarget() = 0;
1682
    virtual QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer);
1683
    virtual QSize surfacePixelSize() = 0;
1684
    virtual bool isFormatSupported(Format f) = 0;
1685
    virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() = 0;
1686
    virtual bool createOrResize() = 0;
1687
    virtual QRhiSwapChainHdrInfo hdrInfo();
1688
1689
protected:
1690
    QRhiSwapChain(QRhiImplementation *rhi);
1691
    QWindow *m_window = nullptr;
1692
    Flags m_flags;
1693
    Format m_format = SDR;
1694
    QRhiRenderBuffer *m_depthStencil = nullptr;
1695
    int m_sampleCount = 1;
1696
    QRhiRenderPassDescriptor *m_renderPassDesc = nullptr;
1697
    QSize m_currentPixelSize;
1698
    QRhiSwapChainProxyData m_proxyData;
1699
    QRhiShadingRateMap *m_shadingRateMap = nullptr;
1700
};
1701
1702
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiSwapChain::Flags)
Unexecuted instantiation: operator|(QRhiSwapChain::Flag, QRhiSwapChain::Flag)
Unexecuted instantiation: operator|(QRhiSwapChain::Flag, QFlags<QRhiSwapChain::Flag>)
Unexecuted instantiation: operator&(QRhiSwapChain::Flag, QRhiSwapChain::Flag)
Unexecuted instantiation: operator&(QRhiSwapChain::Flag, QFlags<QRhiSwapChain::Flag>)
Unexecuted instantiation: operator^(QRhiSwapChain::Flag, QRhiSwapChain::Flag)
Unexecuted instantiation: operator^(QRhiSwapChain::Flag, QFlags<QRhiSwapChain::Flag>)
Unexecuted instantiation: operator|(QRhiSwapChain::Flag, int)
1703
0
1704
0
class Q_GUI_EXPORT QRhiComputePipeline : public QRhiResource
1705
0
{
1706
0
public:
1707
0
    enum Flag {
1708
0
        CompileShadersWithDebugInfo = 1 << 0
1709
0
    };
1710
0
    Q_DECLARE_FLAGS(Flags, Flag)
1711
0
1712
0
    QRhiResource::Type resourceType() const override;
1713
0
    virtual bool create() = 0;
1714
0
1715
0
    Flags flags() const { return m_flags; }
1716
0
    void setFlags(Flags f) { m_flags = f; }
1717
1718
0
    QRhiShaderStage shaderStage() const { return m_shaderStage; }
1719
0
    void setShaderStage(const QRhiShaderStage &stage) { m_shaderStage = stage; }
1720
1721
0
    QRhiShaderResourceBindings *shaderResourceBindings() const { return m_shaderResourceBindings; }
1722
0
    void setShaderResourceBindings(QRhiShaderResourceBindings *srb) { m_shaderResourceBindings = srb; }
1723
1724
protected:
1725
    QRhiComputePipeline(QRhiImplementation *rhi);
1726
    Flags m_flags;
1727
    QRhiShaderStage m_shaderStage;
1728
    QRhiShaderResourceBindings *m_shaderResourceBindings = nullptr;
1729
};
1730
1731
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiComputePipeline::Flags)
Unexecuted instantiation: operator|(QRhiComputePipeline::Flag, QRhiComputePipeline::Flag)
Unexecuted instantiation: operator|(QRhiComputePipeline::Flag, QFlags<QRhiComputePipeline::Flag>)
Unexecuted instantiation: operator&(QRhiComputePipeline::Flag, QRhiComputePipeline::Flag)
Unexecuted instantiation: operator&(QRhiComputePipeline::Flag, QFlags<QRhiComputePipeline::Flag>)
Unexecuted instantiation: operator^(QRhiComputePipeline::Flag, QRhiComputePipeline::Flag)
Unexecuted instantiation: operator^(QRhiComputePipeline::Flag, QFlags<QRhiComputePipeline::Flag>)
Unexecuted instantiation: operator|(QRhiComputePipeline::Flag, int)
1732
0
1733
0
struct QRhiIndirectDrawCommand
1734
0
{
1735
0
    quint32 vertexCount;
1736
0
    quint32 instanceCount = 1;
1737
0
    quint32 firstVertex = 0;
1738
0
    quint32 firstInstance = 0;
1739
0
};
1740
0
1741
0
struct QRhiIndexedIndirectDrawCommand
1742
0
{
1743
0
    quint32 indexCount;
1744
0
    quint32 instanceCount = 1;
1745
0
    quint32 firstIndex = 0;
1746
0
    qint32  vertexOffset = 0;
1747
0
    quint32 firstInstance = 0;
1748
0
};
1749
0
1750
0
struct QRhiDispatchIndirectCommand
1751
0
{
1752
0
    quint32 x;
1753
0
    quint32 y = 1;
1754
0
    quint32 z = 1;
1755
0
};
1756
0
1757
0
// Check that the compiler isn't doing anything nasty.
1758
0
static_assert(sizeof(QRhiIndirectDrawCommand) == 16);
1759
0
static_assert(sizeof(QRhiIndexedIndirectDrawCommand) == 20);
1760
0
static_assert(sizeof(QRhiDispatchIndirectCommand) == 12);
1761
0
1762
0
class Q_GUI_EXPORT QRhiIndirectCommandBuffer : public QRhiResource
1763
0
{
1764
0
public:
1765
0
    enum Type {
1766
0
        Draws,
1767
0
        IndexedDraws
1768
0
    };
1769
0
1770
0
    QRhiResource::Type resourceType() const override;
1771
0
1772
0
    Type type() const { return m_type; }
1773
0
    void setType(Type t) { m_type = t; }
1774
1775
0
    quint32 maxCommandCount() const { return m_maxCommandCount; }
1776
0
    void setMaxCommandCount(quint32 count) { m_maxCommandCount = count; }
1777
1778
    virtual bool create() = 0;
1779
1780
    void clear();
1781
    void draw(quint32 vertexCount, quint32 instanceCount = 1,
1782
              quint32 firstVertex = 0, quint32 firstInstance = 0);
1783
    void drawIndexed(quint32 indexCount, quint32 instanceCount = 1, quint32 firstIndex = 0,
1784
                     qint32 vertexOffset = 0, quint32 firstInstance = 0);
1785
1786
0
    quint32 recordedCommandCount() const { return m_commandCount; }
1787
0
    bool isGpuBuilt() const { return m_gpuBuilt; }
1788
0
    quint32 commandCount() const { return m_gpuBuilt ? m_gpuBuiltCommandCount : m_commandCount; }
1789
1790
protected:
1791
    QRhiIndirectCommandBuffer(QRhiImplementation *rhi, Type type_, quint32 maxCommandCount_);
1792
1793
    Type m_type;
1794
    quint32 m_maxCommandCount;
1795
    QByteArray m_data;
1796
    quint32 m_commandCount = 0;
1797
    quint64 m_generation = 0;
1798
    bool m_gpuBuilt = false;
1799
    quint32 m_gpuBuiltCommandCount = 0;
1800
};
1801
1802
class Q_GUI_EXPORT QRhiCommandBuffer : public QRhiResource
1803
{
1804
public:
1805
    enum IndexFormat {
1806
        IndexUInt16,
1807
        IndexUInt32
1808
    };
1809
1810
    enum BeginPassFlag {
1811
        ExternalContent = 0x01,
1812
        DoNotTrackResourcesForCompute = 0x02
1813
    };
1814
    Q_DECLARE_FLAGS(BeginPassFlags, BeginPassFlag)
1815
1816
    QRhiResource::Type resourceType() const override;
1817
1818
    void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates);
1819
1820
    void beginPass(QRhiRenderTarget *rt,
1821
                   const QColor &colorClearValue,
1822
                   const QRhiDepthStencilClearValue &depthStencilClearValue,
1823
                   QRhiResourceUpdateBatch *resourceUpdates = nullptr,
1824
                   BeginPassFlags flags = {});
1825
    void endPass(QRhiResourceUpdateBatch *resourceUpdates = nullptr);
1826
1827
    void setGraphicsPipeline(QRhiGraphicsPipeline *ps);
1828
    using DynamicOffset = std::pair<int, quint32>; // binding, offset
1829
    void setShaderResources(QRhiShaderResourceBindings *srb = nullptr,
1830
                            int dynamicOffsetCount = 0,
1831
                            const DynamicOffset *dynamicOffsets = nullptr);
1832
    using VertexInput = std::pair<QRhiBuffer *, quint32>; // buffer, offset
1833
    void setVertexInput(int startBinding, int bindingCount, const VertexInput *bindings,
1834
                        QRhiBuffer *indexBuf = nullptr, quint32 indexOffset = 0,
1835
                        IndexFormat indexFormat = IndexUInt16);
1836
1837
    void setViewport(const QRhiViewport &viewport);
1838
    void setScissor(const QRhiScissor &scissor);
1839
    void setBlendConstants(const QColor &c);
1840
    void setStencilRef(quint32 refValue);
1841
    void setShadingRate(const QSize &coarsePixelSize);
1842
    void setPushConstants(quint32 offset, quint32 size, const void *data);
1843
1844
    void draw(quint32 vertexCount,
1845
              quint32 instanceCount = 1,
1846
              quint32 firstVertex = 0,
1847
              quint32 firstInstance = 0);
1848
1849
    void drawIndexed(quint32 indexCount,
1850
                     quint32 instanceCount = 1,
1851
                     quint32 firstIndex = 0,
1852
                     qint32 vertexOffset = 0,
1853
                     quint32 firstInstance = 0);
1854
1855
    void drawIndirect(QRhiBuffer *indirectBuffer,
1856
                      quint32 indirectBufferOffset,
1857
                      quint32 drawCount,
1858
                      quint32 stride = sizeof(QRhiIndirectDrawCommand));
1859
1860
    void drawIndexedIndirect(QRhiBuffer *indirectBuffer,
1861
                             quint32 indirectBufferOffset,
1862
                             quint32 drawCount,
1863
                             quint32 stride = sizeof(QRhiIndexedIndirectDrawCommand));
1864
1865
    void drawIndirectCount(QRhiBuffer *indirectBuffer,
1866
                           quint32 indirectBufferOffset,
1867
                           QRhiBuffer *countBuffer,
1868
                           quint32 countBufferOffset,
1869
                           quint32 maxDrawCount,
1870
                           quint32 stride = sizeof(QRhiIndirectDrawCommand));
1871
1872
    void drawIndexedIndirectCount(QRhiBuffer *indirectBuffer,
1873
                                  quint32 indirectBufferOffset,
1874
                                  QRhiBuffer *countBuffer,
1875
                                  quint32 countBufferOffset,
1876
                                  quint32 maxDrawCount,
1877
                                  quint32 stride = sizeof(QRhiIndexedIndirectDrawCommand));
1878
1879
    void buildIndirect(QRhiIndirectCommandBuffer *icb,
1880
                       const QRhiIndirectCommandBufferBuildInfo &info);
1881
1882
    void executeIndirect(QRhiIndirectCommandBuffer *icb,
1883
                         quint32 firstCommand = 0,
1884
                         quint32 commandCount = 0xFFFFFFFFu);
1885
1886
    void debugMarkBegin(const QByteArray &name);
1887
    void debugMarkEnd();
1888
    void debugMarkMsg(const QByteArray &msg);
1889
1890
    void beginComputePass(QRhiResourceUpdateBatch *resourceUpdates = nullptr, BeginPassFlags flags = {});
1891
    void endComputePass(QRhiResourceUpdateBatch *resourceUpdates = nullptr);
1892
    void setComputePipeline(QRhiComputePipeline *ps);
1893
    void dispatch(int x, int y, int z);
1894
    void dispatchIndirect(QRhiBuffer *indirectBuffer,
1895
                          quint32 indirectBufferOffset = 0);
1896
1897
    const QRhiNativeHandles *nativeHandles();
1898
    void beginExternal();
1899
    void endExternal();
1900
1901
    double lastCompletedGpuTime();
1902
1903
protected:
1904
    QRhiCommandBuffer(QRhiImplementation *rhi);
1905
};
1906
1907
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiCommandBuffer::BeginPassFlags)
Unexecuted instantiation: operator|(QRhiCommandBuffer::BeginPassFlag, QRhiCommandBuffer::BeginPassFlag)
Unexecuted instantiation: operator|(QRhiCommandBuffer::BeginPassFlag, QFlags<QRhiCommandBuffer::BeginPassFlag>)
Unexecuted instantiation: operator&(QRhiCommandBuffer::BeginPassFlag, QRhiCommandBuffer::BeginPassFlag)
Unexecuted instantiation: operator&(QRhiCommandBuffer::BeginPassFlag, QFlags<QRhiCommandBuffer::BeginPassFlag>)
Unexecuted instantiation: operator^(QRhiCommandBuffer::BeginPassFlag, QRhiCommandBuffer::BeginPassFlag)
Unexecuted instantiation: operator^(QRhiCommandBuffer::BeginPassFlag, QFlags<QRhiCommandBuffer::BeginPassFlag>)
Unexecuted instantiation: operator|(QRhiCommandBuffer::BeginPassFlag, int)
1908
0
1909
0
struct QRhiIndirectCommandBufferBuildInfo
1910
0
{
1911
0
    QRhiGraphicsPipeline::Topology topology = QRhiGraphicsPipeline::Triangles;
1912
0
    QRhiBuffer *sourceBuffer = nullptr;
1913
0
    quint32 sourceBufferOffset = 0;
1914
0
    quint32 commandCount = 0;
1915
0
    quint32 stride = 0;
1916
0
    QRhiBuffer *countBuffer = nullptr;
1917
0
    quint32 countBufferOffset = 0;
1918
0
    QRhiBuffer *indexBuffer = nullptr;
1919
0
    quint32 indexBufferOffset = 0;
1920
0
    QRhiCommandBuffer::IndexFormat indexFormat = QRhiCommandBuffer::IndexUInt16;
1921
0
};
1922
0
1923
0
struct Q_GUI_EXPORT QRhiReadbackResult
1924
0
{
1925
0
    std::function<void()> completed = nullptr;
1926
0
    QRhiTexture::Format format;
1927
0
    QSize pixelSize;
1928
0
    QByteArray data;
1929
0
};
1930
0
1931
0
class Q_GUI_EXPORT QRhiResourceUpdateBatch
1932
0
{
1933
0
public:
1934
0
    ~QRhiResourceUpdateBatch();
1935
0
1936
0
    void release();
1937
0
1938
0
    void merge(QRhiResourceUpdateBatch *other);
1939
0
    bool hasOptimalCapacity() const;
1940
0
1941
0
    void updateDynamicBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data);
1942
0
    void updateDynamicBuffer(QRhiBuffer *buf, quint32 offset, QByteArray data);
1943
0
    void uploadStaticBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data);
1944
0
    void uploadStaticBuffer(QRhiBuffer *buf, quint32 offset, QByteArray data);
1945
0
    void uploadStaticBuffer(QRhiBuffer *buf, const void *data);
1946
0
    void uploadStaticBuffer(QRhiBuffer *buf, QByteArray data);
1947
0
    void readBackBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result);
1948
0
    void copyBuffer(QRhiBuffer *dst, QRhiBuffer *src, const QRhiBufferCopyDescription &desc = QRhiBufferCopyDescription());
1949
0
    void uploadTexture(QRhiTexture *tex, const QRhiTextureUploadDescription &desc);
1950
0
    void uploadTexture(QRhiTexture *tex, const QImage &image);
1951
0
    void copyTexture(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc = QRhiTextureCopyDescription());
1952
0
    void readBackTexture(const QRhiReadbackDescription &rb, QRhiReadbackResult *result);
1953
0
    void generateMips(QRhiTexture *tex);
1954
0
    void commitIndirectCommandBuffer(QRhiIndirectCommandBuffer *icb);
1955
0
1956
0
private:
1957
0
    QRhiResourceUpdateBatch(QRhiImplementation *rhi);
1958
0
    Q_DISABLE_COPY(QRhiResourceUpdateBatch)
1959
0
    QRhiResourceUpdateBatchPrivate *d;
1960
0
    friend class QRhiResourceUpdateBatchPrivate;
1961
0
    friend class QRhi;
1962
0
};
1963
0
1964
0
struct Q_GUI_EXPORT QRhiDriverInfo
1965
0
{
1966
0
    enum DeviceType {
1967
0
        UnknownDevice,
1968
0
        IntegratedDevice,
1969
0
        DiscreteDevice,
1970
0
        ExternalDevice,
1971
0
        VirtualDevice,
1972
0
        CpuDevice
1973
0
    };
1974
0
1975
0
    QByteArray deviceName;
1976
0
    quint64 deviceId = 0;
1977
0
    quint64 vendorId = 0;
1978
0
    DeviceType deviceType = UnknownDevice;
1979
0
};
1980
0
1981
0
Q_DECLARE_TYPEINFO(QRhiDriverInfo, Q_RELOCATABLE_TYPE);
1982
0
1983
0
#ifndef QT_NO_DEBUG_STREAM
1984
0
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiDriverInfo &);
1985
0
#endif
1986
0
1987
0
struct Q_GUI_EXPORT QRhiStats
1988
0
{
1989
0
    qint64 totalPipelineCreationTime = 0;
1990
0
    // Vulkan or D3D12 memory allocator statistics
1991
0
    quint32 blockCount = 0;
1992
0
    quint32 allocCount = 0;
1993
0
    quint64 usedBytes = 0;
1994
0
    quint64 unusedBytes = 0;
1995
0
    // D3D12 only, from IDXGIAdapter3::QueryVideoMemoryInfo(), incl. all resources
1996
0
    quint64 totalUsageBytes = 0;
1997
0
};
1998
0
1999
0
Q_DECLARE_TYPEINFO(QRhiStats, Q_RELOCATABLE_TYPE);
2000
0
2001
0
#ifndef QT_NO_DEBUG_STREAM
2002
0
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiStats &);
2003
0
#endif
2004
0
2005
0
class Q_GUI_EXPORT QRhiAdapter
2006
0
{
2007
0
public:
2008
0
    virtual ~QRhiAdapter();
2009
0
    virtual QRhiDriverInfo info() const = 0;
2010
0
};
2011
0
2012
0
struct Q_GUI_EXPORT QRhiInitParams
2013
0
{
2014
0
};
2015
0
2016
0
class Q_GUI_EXPORT QRhi
2017
0
{
2018
0
public:
2019
0
    enum Implementation {
2020
0
        Null,
2021
0
        Vulkan,
2022
0
        OpenGLES2,
2023
0
        D3D11,
2024
0
        Metal,
2025
0
        D3D12
2026
0
    };
2027
0
2028
0
    enum Flag {
2029
0
        EnableDebugMarkers = 1 << 0,
2030
0
        PreferSoftwareRenderer = 1 << 1,
2031
0
        EnablePipelineCacheDataSave = 1 << 2,
2032
0
        EnableTimestamps = 1 << 3,
2033
0
        SuppressSmokeTestWarnings = 1 << 4
2034
0
    };
2035
0
    Q_DECLARE_FLAGS(Flags, Flag)
2036
0
2037
0
    enum FrameOpResult {
2038
0
        FrameOpSuccess = 0,
2039
0
        FrameOpError,
2040
0
        FrameOpSwapChainOutOfDate,
2041
0
        FrameOpDeviceLost
2042
0
    };
2043
0
2044
0
    enum Feature {
2045
0
        MultisampleTexture = 1,
2046
0
        MultisampleRenderBuffer,
2047
0
        DebugMarkers,
2048
0
        Timestamps,
2049
0
        Instancing,
2050
0
        CustomInstanceStepRate,
2051
0
        PrimitiveRestart,
2052
0
        NonDynamicUniformBuffers,
2053
0
        NonFourAlignedEffectiveIndexBufferOffset,
2054
0
        NPOTTextureRepeat,
2055
0
        RedOrAlpha8IsRed,
2056
0
        ElementIndexUint,
2057
0
        Compute,
2058
0
        WideLines,
2059
0
        VertexShaderPointSize,
2060
0
        BaseVertex,
2061
0
        BaseInstance,
2062
0
        TriangleFanTopology,
2063
0
        ReadBackNonUniformBuffer,
2064
0
        ReadBackNonBaseMipLevel,
2065
0
        TexelFetch,
2066
0
        RenderToNonBaseMipLevel,
2067
0
        IntAttributes,
2068
0
        ScreenSpaceDerivatives,
2069
0
        ReadBackAnyTextureFormat,
2070
0
        PipelineCacheDataLoadSave,
2071
0
        ImageDataStride,
2072
0
        RenderBufferImport,
2073
0
        ThreeDimensionalTextures,
2074
0
        RenderTo3DTextureSlice,
2075
0
        TextureArrays,
2076
0
        Tessellation,
2077
0
        GeometryShader,
2078
0
        TextureArrayRange,
2079
0
        NonFillPolygonMode,
2080
0
        OneDimensionalTextures,
2081
0
        OneDimensionalTextureMipmaps,
2082
0
        HalfAttributes,
2083
0
        RenderToOneDimensionalTexture,
2084
0
        ThreeDimensionalTextureMipmaps,
2085
0
        MultiView,
2086
0
        TextureViewFormat,
2087
0
        ResolveDepthStencil,
2088
0
        VariableRateShading,
2089
0
        VariableRateShadingMap,
2090
0
        VariableRateShadingMapWithTexture,
2091
0
        PerRenderTargetBlending,
2092
0
        SampleVariables,
2093
0
        InstanceIndexIncludesBaseInstance,
2094
0
        DepthClamp,
2095
0
        DrawIndirect,
2096
0
        DrawIndirectMulti,
2097
0
        ShaderDrawParameters,
2098
0
        DispatchIndirect,
2099
0
        DrawIndirectCount,
2100
0
        BufferToBufferCopy,
2101
0
        PushConstants,
2102
0
        StaticBuffersOnGpuTimeline
2103
0
    };
2104
0
2105
0
    enum BeginFrameFlag {
2106
0
    };
2107
0
    Q_DECLARE_FLAGS(BeginFrameFlags, BeginFrameFlag)
2108
0
2109
0
    enum EndFrameFlag {
2110
0
        SkipPresent = 1 << 0
2111
0
    };
2112
0
    Q_DECLARE_FLAGS(EndFrameFlags, EndFrameFlag)
2113
0
2114
0
    enum ResourceLimit {
2115
0
        TextureSizeMin = 1,
2116
0
        TextureSizeMax,
2117
0
        MaxColorAttachments,
2118
0
        FramesInFlight,
2119
0
        MaxAsyncReadbackFrames,
2120
0
        MaxThreadGroupsPerDimension,
2121
0
        MaxThreadsPerThreadGroup,
2122
0
        MaxThreadGroupX,
2123
0
        MaxThreadGroupY,
2124
0
        MaxThreadGroupZ,
2125
0
        TextureArraySizeMax,
2126
0
        MaxUniformBufferRange,
2127
0
        MaxVertexInputs,
2128
0
        MaxVertexOutputs,
2129
0
        ShadingRateImageTileSize,
2130
0
        MaxVertexStorageBuffers,
2131
0
        MaxFragmentStorageBuffers,
2132
0
        MaxPushConstantsSize
2133
0
    };
2134
0
2135
0
    ~QRhi();
2136
0
2137
0
    static QRhi *create(Implementation impl,
2138
0
                        QRhiInitParams *params,
2139
0
                        Flags flags = {},
2140
0
                        QRhiNativeHandles *importDevice = nullptr);
2141
0
    static QRhi *create(Implementation impl,
2142
0
                        QRhiInitParams *params,
2143
0
                        Flags flags,
2144
0
                        QRhiNativeHandles *importDevice,
2145
0
                        QRhiAdapter *adapter);
2146
0
    static bool probe(Implementation impl, QRhiInitParams *params);
2147
0
    using AdapterList = QVector<QRhiAdapter *>;
2148
0
    static AdapterList enumerateAdapters(Implementation impl,
2149
0
                                         QRhiInitParams *params,
2150
0
                                         QRhiNativeHandles *nativeHandles = nullptr);
2151
0
2152
0
    Implementation backend() const;
2153
0
    const char *backendName() const;
2154
0
    static const char *backendName(Implementation impl);
2155
0
    QRhiDriverInfo driverInfo() const;
2156
0
    QThread *thread() const;
2157
0
2158
0
    using CleanupCallback = std::function<void(QRhi *)>;
2159
0
    void addCleanupCallback(const CleanupCallback &callback);
2160
0
    void addCleanupCallback(const void *key, const CleanupCallback &callback);
2161
0
    void removeCleanupCallback(const void *key);
2162
0
2163
0
    QRhiGraphicsPipeline *newGraphicsPipeline();
2164
0
    QRhiComputePipeline *newComputePipeline();
2165
0
    QRhiShaderResourceBindings *newShaderResourceBindings();
2166
0
2167
0
    QRhiBuffer *newBuffer(QRhiBuffer::Type type,
2168
0
                          QRhiBuffer::UsageFlags usage,
2169
0
                          quint32 size);
2170
0
2171
0
    QRhiRenderBuffer *newRenderBuffer(QRhiRenderBuffer::Type type,
2172
0
                                      const QSize &pixelSize,
2173
0
                                      int sampleCount = 1,
2174
0
                                      QRhiRenderBuffer::Flags flags = {},
2175
0
                                      QRhiTexture::Format backingFormatHint = QRhiTexture::UnknownFormat);
2176
0
2177
0
    QRhiTexture *newTexture(QRhiTexture::Format format,
2178
0
                            const QSize &pixelSize,
2179
0
                            int sampleCount = 1,
2180
0
                            QRhiTexture::Flags flags = {});
2181
0
2182
0
    QRhiTexture *newTexture(QRhiTexture::Format format,
2183
0
                            int width, int height, int depth,
2184
0
                            int sampleCount = 1,
2185
0
                            QRhiTexture::Flags flags = {});
2186
0
2187
0
    QRhiTexture *newTextureArray(QRhiTexture::Format format,
2188
0
                                 int arraySize,
2189
0
                                 const QSize &pixelSize,
2190
0
                                 int sampleCount = 1,
2191
0
                                 QRhiTexture::Flags flags = {});
2192
0
2193
0
    QRhiSampler *newSampler(QRhiSampler::Filter magFilter,
2194
0
                            QRhiSampler::Filter minFilter,
2195
0
                            QRhiSampler::Filter mipmapMode,
2196
0
                            QRhiSampler::AddressMode addressU,
2197
0
                            QRhiSampler::AddressMode addressV,
2198
0
                            QRhiSampler::AddressMode addressW = QRhiSampler::Repeat);
2199
0
2200
0
    QRhiShadingRateMap *newShadingRateMap();
2201
0
2202
0
    QRhiIndirectCommandBuffer *newIndirectCommandBuffer(QRhiIndirectCommandBuffer::Type type,
2203
0
                                                        quint32 maxCommandCount);
2204
0
2205
0
    QRhiTextureRenderTarget *newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
2206
0
                                                    QRhiTextureRenderTarget::Flags flags = {});
2207
0
2208
0
    QRhiSwapChain *newSwapChain();
2209
0
    FrameOpResult beginFrame(QRhiSwapChain *swapChain, BeginFrameFlags flags = {});
2210
0
    FrameOpResult endFrame(QRhiSwapChain *swapChain, EndFrameFlags flags = {});
2211
0
    bool isRecordingFrame() const;
2212
0
    int currentFrameSlot() const;
2213
0
2214
0
    FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags = {});
2215
0
    FrameOpResult endOffscreenFrame(EndFrameFlags flags = {});
2216
0
2217
0
    QRhi::FrameOpResult finish();
2218
0
2219
0
    QRhiResourceUpdateBatch *nextResourceUpdateBatch();
2220
0
2221
0
    QList<int> supportedSampleCounts() const;
2222
0
2223
0
    int ubufAlignment() const;
2224
0
    int ubufAligned(int v) const;
2225
0
2226
0
    static int mipLevelsForSize(const QSize &size);
2227
0
    static QSize sizeForMipLevel(int mipLevel, const QSize &baseLevelSize);
2228
0
2229
0
    bool isYUpInFramebuffer() const;
2230
0
    bool isYUpInNDC() const;
2231
0
    bool isClipDepthZeroToOne() const;
2232
0
2233
0
    QMatrix4x4 clipSpaceCorrMatrix() const;
2234
0
2235
0
    bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags = {}) const;
2236
0
    bool isFeatureSupported(QRhi::Feature feature) const;
2237
0
    int resourceLimit(ResourceLimit limit) const;
2238
0
2239
0
    const QRhiNativeHandles *nativeHandles();
2240
0
    bool makeThreadLocalNativeContextCurrent();
2241
0
    void setQueueSubmitParams(QRhiNativeHandles *params);
2242
0
2243
0
    static constexpr int MAX_MIP_LEVELS = 16; // -> max width or height is 65536
2244
0
2245
0
    void releaseCachedResources();
2246
0
2247
0
    bool isDeviceLost() const;
2248
0
2249
0
    QByteArray pipelineCacheData();
2250
0
    void setPipelineCacheData(const QByteArray &data);
2251
0
2252
0
    QRhiStats statistics() const;
2253
0
2254
0
    static QRhiSwapChainProxyData updateSwapChainProxyData(Implementation impl, QWindow *window);
2255
0
2256
0
    QList<QSize> supportedShadingRates(int sampleCount) const;
2257
0
2258
0
protected:
2259
0
    QRhi();
2260
0
2261
0
private:
2262
0
    Q_DISABLE_COPY(QRhi)
2263
0
    QRhiImplementation *d = nullptr;
2264
0
};
2265
0
2266
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::Flags)
Unexecuted instantiation: operator|(QRhi::Flag, QRhi::Flag)
Unexecuted instantiation: operator|(QRhi::Flag, QFlags<QRhi::Flag>)
Unexecuted instantiation: operator&(QRhi::Flag, QRhi::Flag)
Unexecuted instantiation: operator&(QRhi::Flag, QFlags<QRhi::Flag>)
Unexecuted instantiation: operator^(QRhi::Flag, QRhi::Flag)
Unexecuted instantiation: operator^(QRhi::Flag, QFlags<QRhi::Flag>)
Unexecuted instantiation: operator|(QRhi::Flag, int)
2267
0
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::BeginFrameFlags)
Unexecuted instantiation: operator|(QRhi::BeginFrameFlag, QRhi::BeginFrameFlag)
Unexecuted instantiation: operator|(QRhi::BeginFrameFlag, QFlags<QRhi::BeginFrameFlag>)
Unexecuted instantiation: operator&(QRhi::BeginFrameFlag, QRhi::BeginFrameFlag)
Unexecuted instantiation: operator&(QRhi::BeginFrameFlag, QFlags<QRhi::BeginFrameFlag>)
Unexecuted instantiation: operator^(QRhi::BeginFrameFlag, QRhi::BeginFrameFlag)
Unexecuted instantiation: operator^(QRhi::BeginFrameFlag, QFlags<QRhi::BeginFrameFlag>)
Unexecuted instantiation: operator|(QRhi::BeginFrameFlag, int)
2268
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::EndFrameFlags)
Unexecuted instantiation: operator|(QRhi::EndFrameFlag, QRhi::EndFrameFlag)
Unexecuted instantiation: operator|(QRhi::EndFrameFlag, QFlags<QRhi::EndFrameFlag>)
Unexecuted instantiation: operator&(QRhi::EndFrameFlag, QRhi::EndFrameFlag)
Unexecuted instantiation: operator&(QRhi::EndFrameFlag, QFlags<QRhi::EndFrameFlag>)
Unexecuted instantiation: operator^(QRhi::EndFrameFlag, QRhi::EndFrameFlag)
Unexecuted instantiation: operator^(QRhi::EndFrameFlag, QFlags<QRhi::EndFrameFlag>)
Unexecuted instantiation: operator|(QRhi::EndFrameFlag, int)
2269
2270
QT_END_NAMESPACE
2271
2272
#include <rhi/qrhi_platform.h>
2273
2274
#endif