Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qrhi.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qrhi_p.h"
5#include <qmath.h>
6#include <QLoggingCategory>
7
8#include "qrhinull_p.h"
9#ifndef QT_NO_OPENGL
10#include "qrhigles2_p.h"
11#endif
12#if QT_CONFIG(vulkan)
13#include "qrhivulkan_p.h"
14#endif
15#ifdef Q_OS_WIN
16#include "qrhid3d11_p.h"
17#include "qrhid3d12_p.h"
18#endif
19#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
20#include "qrhimetal_p.h"
21#endif
22
23#include <memory>
24
26
27Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general")
28
29
1135 : m_d(d),
1136 m_s(s)
1137{
1138}
1139
1181#ifndef QT_NO_DEBUG_STREAM
1183{
1184 QDebugStateSaver saver(dbg);
1185 dbg.nospace() << "QRhiDepthStencilClearValue(depth-clear=" << v.depthClearValue()
1186 << " stencil-clear=" << v.stencilClearValue()
1187 << ')';
1188 return dbg;
1189}
1190#endif
1191
1239QRhiViewport::QRhiViewport(float x, float y, float w, float h, float minDepth, float maxDepth)
1240 : m_rect { { x, y, w, h } },
1241 m_minDepth(minDepth),
1242 m_maxDepth(maxDepth)
1243{
1244}
1245
1301#ifndef QT_NO_DEBUG_STREAM
1303{
1304 QDebugStateSaver saver(dbg);
1305 const std::array<float, 4> r = v.viewport();
1306 dbg.nospace() << "QRhiViewport(bottom-left-x=" << r[0]
1307 << " bottom-left-y=" << r[1]
1308 << " width=" << r[2]
1309 << " height=" << r[3]
1310 << " minDepth=" << v.minDepth()
1311 << " maxDepth=" << v.maxDepth()
1312 << ')';
1313 return dbg;
1314}
1315#endif
1316
1356QRhiScissor::QRhiScissor(int x, int y, int w, int h)
1357 : m_rect { { x, y, w, h } }
1358{
1359}
1360
1394#ifndef QT_NO_DEBUG_STREAM
1396{
1397 QDebugStateSaver saver(dbg);
1398 const std::array<int, 4> r = s.scissor();
1399 dbg.nospace() << "QRhiScissor(bottom-left-x=" << r[0]
1400 << " bottom-left-y=" << r[1]
1401 << " width=" << r[2]
1402 << " height=" << r[3]
1403 << ')';
1404 return dbg;
1405}
1406#endif
1407
1490 : m_stride(stride),
1491 m_classification(cls),
1492 m_instanceStepRate(stepRate)
1493{
1494}
1495
1546#ifndef QT_NO_DEBUG_STREAM
1548{
1549 QDebugStateSaver saver(dbg);
1550 dbg.nospace() << "QRhiVertexInputBinding(stride=" << b.stride()
1551 << " cls=" << b.classification()
1552 << " step-rate=" << b.instanceStepRate()
1553 << ')';
1554 return dbg;
1555}
1556#endif
1557
1685 : m_binding(binding),
1686 m_location(location),
1687 m_format(format),
1688 m_offset(offset),
1689 m_matrixSlice(matrixSlice)
1690{
1691}
1692
1774#ifndef QT_NO_DEBUG_STREAM
1776{
1777 QDebugStateSaver saver(dbg);
1778 dbg.nospace() << "QRhiVertexInputAttribute(binding=" << a.binding()
1779 << " location=" << a.location()
1780 << " format=" << a.format()
1781 << " offset=" << a.offset()
1782 << ')';
1783 return dbg;
1784}
1785#endif
1786
1788{
1789 switch (type) {
1798
1807
1816
1825
1826 default:
1827 Q_UNREACHABLE_RETURN(QRhiVertexInputAttribute::Float);
1828 }
1829}
1830
1832{
1833 switch (format) {
1835 return 4 * sizeof(float);
1837 return 4 * sizeof(float); // vec3 still takes 16 bytes
1839 return 2 * sizeof(float);
1841 return sizeof(float);
1842
1844 return 4 * sizeof(quint8);
1846 return 2 * sizeof(quint8);
1848 return sizeof(quint8);
1849
1851 return 4 * sizeof(quint32);
1853 return 4 * sizeof(quint32); // ivec3 still takes 16 bytes
1855 return 2 * sizeof(quint32);
1857 return sizeof(quint32);
1858
1860 return 4 * sizeof(qint32);
1862 return 4 * sizeof(qint32); // uvec3 still takes 16 bytes
1864 return 2 * sizeof(qint32);
1866 return sizeof(qint32);
1867
1869 return 4 * sizeof(qfloat16);
1871 return 4 * sizeof(qfloat16); // half3 still takes 8 bytes
1873 return 2 * sizeof(qfloat16);
1875 return sizeof(qfloat16);
1876
1877 default:
1878 Q_UNREACHABLE_RETURN(1);
1879 }
1880}
1881
1999#ifndef QT_NO_DEBUG_STREAM
2001{
2002 QDebugStateSaver saver(dbg);
2003 dbg.nospace() << "QRhiVertexInputLayout(bindings=" << v.m_bindings
2004 << " attributes=" << v.m_attributes
2005 << ')';
2006 return dbg;
2007}
2008#endif
2009
2120 : m_type(type),
2121 m_shader(shader),
2122 m_shaderVariant(v)
2123{
2124}
2125
2146#ifndef QT_NO_DEBUG_STREAM
2148{
2149 QDebugStateSaver saver(dbg);
2150 dbg.nospace() << "QRhiShaderStage(type=" << s.type()
2151 << " shader=" << s.shader()
2152 << " variant=" << s.shaderVariant()
2153 << ')';
2154 return dbg;
2155}
2156#endif
2157
2212 : m_texture(texture)
2213{
2214}
2215
2221 : m_renderBuffer(renderBuffer)
2222{
2223}
2224
2503{
2504 m_colorAttachments.append(colorAttachment);
2505}
2506
2513 QRhiRenderBuffer *depthStencilBuffer)
2514 : m_depthStencilBuffer(depthStencilBuffer)
2515{
2516 m_colorAttachments.append(colorAttachment);
2517}
2518
2528 QRhiTexture *depthTexture)
2529 : m_depthTexture(depthTexture)
2530{
2531 m_colorAttachments.append(colorAttachment);
2532}
2533
2707 : m_image(image)
2708{
2709}
2710
2719 : m_data(reinterpret_cast<const char *>(data), size)
2720{
2721}
2722
2728 : m_data(data)
2729{
2730}
2731
2853 : m_layer(layer),
2854 m_level(level),
2855 m_desc(desc)
2856{
2857}
2858
2990{
2991 m_entries.append(entry);
2992}
2993
3003QRhiTextureUploadDescription::QRhiTextureUploadDescription(std::initializer_list<QRhiTextureUploadEntry> list)
3004 : m_entries(list)
3005{
3006}
3007
3192 : m_texture(texture)
3193{
3194}
3195
3339 : m_rhi(rhi)
3340{
3342}
3343
3356{
3357 // destroy() cannot be called here, due to virtuals; it is up to the
3358 // subclasses to do that.
3359}
3360
3420{
3421 if (m_rhi)
3422 m_rhi->addDeleteLater(this);
3423 else
3424 delete this;
3425}
3426
3431{
3432 return m_objectName;
3433}
3434
3456{
3458}
3459
3467{
3468 return m_id;
3469}
3470
3478{
3479 return m_rhi ? m_rhi->q : nullptr;
3480}
3481
3703QRhiBuffer::QRhiBuffer(QRhiImplementation *rhi, Type type_, UsageFlags usage_, quint32 size_)
3704 : QRhiResource(rhi),
3705 m_type(type_), m_usage(usage_), m_size(size_)
3706{
3707}
3708
3713{
3714 return Buffer;
3715}
3716
3806{
3807 return {};
3808}
3809
3845{
3846 return nullptr;
3847}
3848
3855{
3856}
3857
3934 int sampleCount_, Flags flags_,
3935 QRhiTexture::Format backingFormatHint_)
3936 : QRhiResource(rhi),
3937 m_type(type_), m_pixelSize(pixelSize_), m_sampleCount(sampleCount_), m_flags(flags_),
3938 m_backingFormatHint(backingFormatHint_)
3939{
3940}
3941
3946{
3947 return RenderBuffer;
3948}
3949
3994{
3995 Q_UNUSED(src);
3996 return false;
3997}
3998
4294QRhiTexture::QRhiTexture(QRhiImplementation *rhi, Format format_, const QSize &pixelSize_, int depth_,
4295 int arraySize_, int sampleCount_, Flags flags_)
4296 : QRhiResource(rhi),
4297 m_format(format_), m_pixelSize(pixelSize_), m_depth(depth_),
4298 m_arraySize(arraySize_), m_sampleCount(sampleCount_), m_flags(flags_)
4299{
4300}
4301
4306{
4307 return Texture;
4308}
4309
4329{
4330 return {};
4331}
4332
4362{
4363 Q_UNUSED(src);
4364 return false;
4365}
4366
4391{
4393}
4394
4543 Filter magFilter_, Filter minFilter_, Filter mipmapMode_,
4545 : QRhiResource(rhi),
4546 m_magFilter(magFilter_), m_minFilter(minFilter_), m_mipmapMode(mipmapMode_),
4547 m_addressU(u_), m_addressV(v_), m_addressW(w_),
4548 m_compareOp(QRhiSampler::Never)
4549{
4550}
4551
4556{
4557 return Sampler;
4558}
4559
4652 : QRhiResource(rhi)
4653{
4654}
4655
4660{
4661 return RenderPassDescriptor;
4662}
4663
4746{
4747 return nullptr;
4748}
4749
4773 : QRhiResource(rhi)
4774{
4775}
4776
4827 : QRhiRenderTarget(rhi),
4828 m_swapchain(swapchain_)
4829{
4830}
4831
4852{
4853 return SwapChainRenderTarget;
4854}
4855
4922 Flags flags_)
4923 : QRhiRenderTarget(rhi),
4924 m_desc(desc_),
4925 m_flags(flags_)
4926{
4927}
4928
4933{
4934 return TextureRenderTarget;
4935}
4936
5080 : QRhiResource(rhi)
5081{
5083}
5084
5089{
5091}
5092
5115{
5116 if (other == this)
5117 return true;
5118
5119 if (!other)
5120 return false;
5121
5122 // This can become a hot code path. Therefore we do not iterate and call
5123 // isLayoutCompatible() on m_bindings, but rather check a pre-calculated
5124 // hash code and then, if the hash matched, do a uint array comparison
5125 // (that's still more cache friendly).
5126
5127 return m_layoutDescHash == other->m_layoutDescHash
5128 && m_layoutDesc == other->m_layoutDesc;
5129}
5130
5151{
5152 srb->m_layoutDescHash = 0;
5153 srb->m_layoutDesc.clear();
5154 auto layoutDescAppender = std::back_inserter(srb->m_layoutDesc);
5155 for (const QRhiShaderResourceBinding &b : std::as_const(srb->m_bindings)) {
5157 srb->m_layoutDescHash ^= uint(d->binding) ^ uint(d->stage) ^ uint(d->type)
5158 ^ uint(d->arraySize());
5159 layoutDescAppender = d->serialize(layoutDescAppender);
5160 }
5161}
5162
5267{
5268 // everything that goes into a VkDescriptorSetLayoutBinding must match
5269 return d.binding == other.d.binding
5270 && d.stage == other.d.stage
5271 && d.type == other.d.type
5272 && d.arraySize() == other.d.arraySize();
5273}
5274
5293 int binding, StageFlags stage, QRhiBuffer *buf)
5294{
5296 b.d.binding = binding;
5297 b.d.stage = stage;
5298 b.d.type = UniformBuffer;
5299 b.d.u.ubuf.buf = buf;
5300 b.d.u.ubuf.offset = 0;
5301 b.d.u.ubuf.maybeSize = 0; // entire buffer
5302 b.d.u.ubuf.hasDynamicOffset = false;
5303 return b;
5304}
5305
5330 int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
5331{
5332 Q_ASSERT(size > 0);
5334 b.d.binding = binding;
5335 b.d.stage = stage;
5336 b.d.type = UniformBuffer;
5337 b.d.u.ubuf.buf = buf;
5338 b.d.u.ubuf.offset = offset;
5339 b.d.u.ubuf.maybeSize = size;
5340 b.d.u.ubuf.hasDynamicOffset = false;
5341 return b;
5342}
5343
5367 int binding, StageFlags stage, QRhiBuffer *buf, quint32 size)
5368{
5369 Q_ASSERT(size > 0);
5371 b.d.binding = binding;
5372 b.d.stage = stage;
5373 b.d.type = UniformBuffer;
5374 b.d.u.ubuf.buf = buf;
5375 b.d.u.ubuf.offset = 0;
5376 b.d.u.ubuf.maybeSize = size;
5377 b.d.u.ubuf.hasDynamicOffset = true;
5378 return b;
5379}
5380
5407 int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
5408{
5410 b.d.binding = binding;
5411 b.d.stage = stage;
5412 b.d.type = SampledTexture;
5413 b.d.u.stex.count = 1;
5414 b.d.u.stex.texSamplers[0] = { tex, sampler };
5415 return b;
5416}
5417
5453 int binding, StageFlags stage, int count, const TextureAndSampler *texSamplers)
5454{
5457 b.d.binding = binding;
5458 b.d.stage = stage;
5459 b.d.type = SampledTexture;
5460 b.d.u.stex.count = count;
5461 for (int i = 0; i < count; ++i) {
5462 if (texSamplers)
5463 b.d.u.stex.texSamplers[i] = texSamplers[i];
5464 else
5465 b.d.u.stex.texSamplers[i] = { nullptr, nullptr };
5466 }
5467 return b;
5468}
5469
5500{
5502 b.d.binding = binding;
5503 b.d.stage = stage;
5504 b.d.type = Texture;
5505 b.d.u.stex.count = 1;
5506 b.d.u.stex.texSamplers[0] = { tex, nullptr };
5507 return b;
5508}
5509
5531{
5534 b.d.binding = binding;
5535 b.d.stage = stage;
5536 b.d.type = Texture;
5537 b.d.u.stex.count = count;
5538 for (int i = 0; i < count; ++i) {
5539 if (tex)
5540 b.d.u.stex.texSamplers[i] = { tex[i], nullptr };
5541 else
5542 b.d.u.stex.texSamplers[i] = { nullptr, nullptr };
5543 }
5544 return b;
5545}
5546
5576{
5578 b.d.binding = binding;
5579 b.d.stage = stage;
5580 b.d.type = Sampler;
5581 b.d.u.stex.count = 1;
5582 b.d.u.stex.texSamplers[0] = { nullptr, sampler };
5583 return b;
5584}
5585
5610 int binding, StageFlags stage, QRhiTexture *tex, int level)
5611{
5613 b.d.binding = binding;
5614 b.d.stage = stage;
5615 b.d.type = ImageLoad;
5616 b.d.u.simage.tex = tex;
5617 b.d.u.simage.level = level;
5618 return b;
5619}
5620
5645 int binding, StageFlags stage, QRhiTexture *tex, int level)
5646{
5648 b.d.binding = binding;
5649 b.d.stage = stage;
5650 b.d.type = ImageStore;
5651 b.d.u.simage.tex = tex;
5652 b.d.u.simage.level = level;
5653 return b;
5654}
5655
5680 int binding, StageFlags stage, QRhiTexture *tex, int level)
5681{
5683 b.d.binding = binding;
5684 b.d.stage = stage;
5685 b.d.type = ImageLoadStore;
5686 b.d.u.simage.tex = tex;
5687 b.d.u.simage.level = level;
5688 return b;
5689}
5690
5713 int binding, StageFlags stage, QRhiBuffer *buf)
5714{
5716 b.d.binding = binding;
5717 b.d.stage = stage;
5718 b.d.type = BufferLoad;
5719 b.d.u.sbuf.buf = buf;
5720 b.d.u.sbuf.offset = 0;
5721 b.d.u.sbuf.maybeSize = 0; // entire buffer
5722 return b;
5723}
5724
5748 int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
5749{
5750 Q_ASSERT(size > 0);
5752 b.d.binding = binding;
5753 b.d.stage = stage;
5754 b.d.type = BufferLoad;
5755 b.d.u.sbuf.buf = buf;
5756 b.d.u.sbuf.offset = offset;
5757 b.d.u.sbuf.maybeSize = size;
5758 return b;
5759}
5760
5783 int binding, StageFlags stage, QRhiBuffer *buf)
5784{
5786 b.d.binding = binding;
5787 b.d.stage = stage;
5788 b.d.type = BufferStore;
5789 b.d.u.sbuf.buf = buf;
5790 b.d.u.sbuf.offset = 0;
5791 b.d.u.sbuf.maybeSize = 0; // entire buffer
5792 return b;
5793}
5794
5818 int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
5819{
5820 Q_ASSERT(size > 0);
5822 b.d.binding = binding;
5823 b.d.stage = stage;
5824 b.d.type = BufferStore;
5825 b.d.u.sbuf.buf = buf;
5826 b.d.u.sbuf.offset = offset;
5827 b.d.u.sbuf.maybeSize = size;
5828 return b;
5829}
5830
5853 int binding, StageFlags stage, QRhiBuffer *buf)
5854{
5856 b.d.binding = binding;
5857 b.d.stage = stage;
5858 b.d.type = BufferLoadStore;
5859 b.d.u.sbuf.buf = buf;
5860 b.d.u.sbuf.offset = 0;
5861 b.d.u.sbuf.maybeSize = 0; // entire buffer
5862 return b;
5863}
5864
5888 int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
5889{
5890 Q_ASSERT(size > 0);
5892 b.d.binding = binding;
5893 b.d.stage = stage;
5894 b.d.type = BufferLoadStore;
5895 b.d.u.sbuf.buf = buf;
5896 b.d.u.sbuf.offset = offset;
5897 b.d.u.sbuf.maybeSize = size;
5898 return b;
5899}
5900
5912{
5915
5916 if (da == db)
5917 return true;
5918
5919
5920 if (da->binding != db->binding
5921 || da->stage != db->stage
5922 || da->type != db->type)
5923 {
5924 return false;
5925 }
5926
5927 switch (da->type) {
5929 if (da->u.ubuf.buf != db->u.ubuf.buf
5930 || da->u.ubuf.offset != db->u.ubuf.offset
5931 || da->u.ubuf.maybeSize != db->u.ubuf.maybeSize)
5932 {
5933 return false;
5934 }
5935 break;
5937 if (da->u.stex.count != db->u.stex.count)
5938 return false;
5939 for (int i = 0; i < da->u.stex.count; ++i) {
5940 if (da->u.stex.texSamplers[i].tex != db->u.stex.texSamplers[i].tex
5941 || da->u.stex.texSamplers[i].sampler != db->u.stex.texSamplers[i].sampler)
5942 {
5943 return false;
5944 }
5945 }
5946 break;
5948 if (da->u.stex.count != db->u.stex.count)
5949 return false;
5950 for (int i = 0; i < da->u.stex.count; ++i) {
5951 if (da->u.stex.texSamplers[i].tex != db->u.stex.texSamplers[i].tex)
5952 return false;
5953 }
5954 break;
5956 if (da->u.stex.texSamplers[0].sampler != db->u.stex.texSamplers[0].sampler)
5957 return false;
5958 break;
5962 if (da->u.simage.tex != db->u.simage.tex
5963 || da->u.simage.level != db->u.simage.level)
5964 {
5965 return false;
5966 }
5967 break;
5971 if (da->u.sbuf.buf != db->u.sbuf.buf
5972 || da->u.sbuf.offset != db->u.sbuf.offset
5973 || da->u.sbuf.maybeSize != db->u.sbuf.maybeSize)
5974 {
5975 return false;
5976 }
5977 break;
5978 default:
5979 Q_UNREACHABLE_RETURN(false);
5980 }
5981
5982 return true;
5983}
5984
5992{
5993 return !(a == b);
5994}
5995
6001size_t qHash(const QRhiShaderResourceBinding &b, size_t seed) noexcept
6002{
6005 seed = hash(seed, d->binding);
6006 seed = hash(seed, d->stage);
6007 seed = hash(seed, d->type);
6008 switch (d->type) {
6010 seed = hash(seed, reinterpret_cast<quintptr>(d->u.ubuf.buf));
6011 break;
6013 seed = hash(seed, reinterpret_cast<quintptr>(d->u.stex.texSamplers[0].tex));
6014 seed = hash(seed, reinterpret_cast<quintptr>(d->u.stex.texSamplers[0].sampler));
6015 break;
6017 seed = hash(seed, reinterpret_cast<quintptr>(d->u.stex.texSamplers[0].tex));
6018 break;
6020 seed = hash(seed, reinterpret_cast<quintptr>(d->u.stex.texSamplers[0].sampler));
6021 break;
6025 seed = hash(seed, reinterpret_cast<quintptr>(d->u.simage.tex));
6026 break;
6030 seed = hash(seed, reinterpret_cast<quintptr>(d->u.sbuf.buf));
6031 break;
6032 }
6033 return seed;
6034}
6035
6036#ifndef QT_NO_DEBUG_STREAM
6038{
6039 QDebugStateSaver saver(dbg);
6041 dbg.nospace() << "QRhiShaderResourceBinding("
6042 << "binding=" << d->binding
6043 << " stage=" << d->stage
6044 << " type=" << d->type;
6045 switch (d->type) {
6047 dbg.nospace() << " UniformBuffer("
6048 << "buffer=" << d->u.ubuf.buf
6049 << " offset=" << d->u.ubuf.offset
6050 << " maybeSize=" << d->u.ubuf.maybeSize
6051 << ')';
6052 break;
6054 dbg.nospace() << " SampledTextures("
6055 << "count=" << d->u.stex.count;
6056 for (int i = 0; i < d->u.stex.count; ++i) {
6057 dbg.nospace() << " texture=" << d->u.stex.texSamplers[i].tex
6058 << " sampler=" << d->u.stex.texSamplers[i].sampler;
6059 }
6060 dbg.nospace() << ')';
6061 break;
6063 dbg.nospace() << " Textures("
6064 << "count=" << d->u.stex.count;
6065 for (int i = 0; i < d->u.stex.count; ++i)
6066 dbg.nospace() << " texture=" << d->u.stex.texSamplers[i].tex;
6067 dbg.nospace() << ')';
6068 break;
6070 dbg.nospace() << " Sampler("
6071 << " sampler=" << d->u.stex.texSamplers[0].sampler
6072 << ')';
6073 break;
6075 dbg.nospace() << " ImageLoad("
6076 << "texture=" << d->u.simage.tex
6077 << " level=" << d->u.simage.level
6078 << ')';
6079 break;
6081 dbg.nospace() << " ImageStore("
6082 << "texture=" << d->u.simage.tex
6083 << " level=" << d->u.simage.level
6084 << ')';
6085 break;
6087 dbg.nospace() << " ImageLoadStore("
6088 << "texture=" << d->u.simage.tex
6089 << " level=" << d->u.simage.level
6090 << ')';
6091 break;
6093 dbg.nospace() << " BufferLoad("
6094 << "buffer=" << d->u.sbuf.buf
6095 << " offset=" << d->u.sbuf.offset
6096 << " maybeSize=" << d->u.sbuf.maybeSize
6097 << ')';
6098 break;
6100 dbg.nospace() << " BufferStore("
6101 << "buffer=" << d->u.sbuf.buf
6102 << " offset=" << d->u.sbuf.offset
6103 << " maybeSize=" << d->u.sbuf.maybeSize
6104 << ')';
6105 break;
6107 dbg.nospace() << " BufferLoadStore("
6108 << "buffer=" << d->u.sbuf.buf
6109 << " offset=" << d->u.sbuf.offset
6110 << " maybeSize=" << d->u.sbuf.maybeSize
6111 << ')';
6112 break;
6113 default:
6114 dbg.nospace() << " UNKNOWN()";
6115 break;
6116 }
6117 dbg.nospace() << ')';
6118 return dbg;
6119}
6120#endif
6121
6122#ifndef QT_NO_DEBUG_STREAM
6124{
6125 QDebugStateSaver saver(dbg);
6126 dbg.nospace() << "QRhiShaderResourceBindings("
6127 << srb.m_bindings
6128 << ')';
6129 return dbg;
6130}
6131#endif
6132
6471 : QRhiResource(rhi)
6472{
6473}
6474
6479{
6480 return GraphicsPipeline;
6481}
6482
7076 : QRhiResource(rhi)
7077{
7078}
7079
7084{
7085 return SwapChain;
7086}
7087
7235{
7236 Q_UNUSED(targetBuffer);
7237 return currentFrameRenderTarget();
7238}
7239
7480{
7482 info.isHardCodedDefaults = true;
7484 info.limits.luminanceInNits.minLuminance = 0.0f;
7485 info.limits.luminanceInNits.maxLuminance = 1000.0f;
7486 return info;
7487}
7488
7489#ifndef QT_NO_DEBUG_STREAM
7491{
7492 QDebugStateSaver saver(dbg);
7493 dbg.nospace() << "QRhiSwapChainHdrInfo(" << (info.isHardCodedDefaults ? "with hard-coded defaults" : "queried from system");
7494 switch (info.limitsType) {
7496 dbg.nospace() << " minLuminance=" << info.limits.luminanceInNits.minLuminance
7497 << " maxLuminance=" << info.limits.luminanceInNits.maxLuminance;
7498 break;
7500 dbg.nospace() << " maxColorComponentValue=" << info.limits.colorComponentValue.maxColorComponentValue;
7501 dbg.nospace() << " maxPotentialColorComponentValue=" << info.limits.colorComponentValue.maxPotentialColorComponentValue;
7502 break;
7503 }
7504 dbg.nospace() << ')';
7505 return dbg;
7506}
7507#endif
7508
7539{
7540 return ComputePipeline;
7541}
7542
7547 : QRhiResource(rhi)
7548{
7549}
7550
7653 : QRhiResource(rhi)
7654{
7655}
7656
7661{
7662 return CommandBuffer;
7663}
7664
7665static const char *resourceTypeStr(const QRhiResource *res)
7666{
7667 switch (res->resourceType()) {
7669 return "Buffer";
7671 return "Texture";
7673 return "Sampler";
7675 return "RenderBuffer";
7677 return "RenderPassDescriptor";
7679 return "SwapChainRenderTarget";
7681 return "TextureRenderTarget";
7683 return "ShaderResourceBindings";
7685 return "GraphicsPipeline";
7687 return "SwapChain";
7689 return "ComputePipeline";
7691 return "CommandBuffer";
7692 }
7693
7694 Q_UNREACHABLE_RETURN("");
7695}
7696
7698{
7699 qDeleteAll(resUpdPool);
7700
7701 // Be nice and show something about leaked stuff. Though we may not get
7702 // this far with some backends where the allocator or the api may check
7703 // and freak out for unfreed graphics objects in the derived dtor already.
7704#ifndef QT_NO_DEBUG
7705 // debug builds: just do it always
7706 static bool leakCheck = true;
7707#else
7708 // release builds: opt-in
7709 static bool leakCheck = qEnvironmentVariableIntValue("QT_RHI_LEAK_CHECK");
7710#endif
7711 if (!resources.isEmpty()) {
7712 if (leakCheck) {
7713 qWarning("QRhi %p going down with %d unreleased resources that own native graphics objects. This is not nice.",
7714 q, int(resources.size()));
7715 }
7716 for (auto it = resources.cbegin(), end = resources.cend(); it != end; ++it) {
7717 QRhiResource *res = it.key();
7718 const bool ownsNativeResources = it.value();
7719 if (leakCheck && ownsNativeResources)
7720 qWarning(" %s resource %p (%s)", resourceTypeStr(res), res, res->m_objectName.constData());
7721
7722 // Null out the resource's rhi pointer. This is why it makes sense to do null
7723 // checks in the destroy() implementations of the various resource types. It
7724 // allows to survive in bad applications that somehow manage to destroy a
7725 // resource of a QRhi after the QRhi itself.
7726 res->m_rhi = nullptr;
7727 }
7728 }
7729}
7730
7732{
7736}
7737
7739 quint32 *bpl, quint32 *byteSize,
7740 QSize *blockDim) const
7741{
7742 int xdim = 4;
7743 int ydim = 4;
7744 quint32 blockSize = 0;
7745
7746 switch (format) {
7747 case QRhiTexture::BC1:
7748 blockSize = 8;
7749 break;
7750 case QRhiTexture::BC2:
7751 blockSize = 16;
7752 break;
7753 case QRhiTexture::BC3:
7754 blockSize = 16;
7755 break;
7756 case QRhiTexture::BC4:
7757 blockSize = 8;
7758 break;
7759 case QRhiTexture::BC5:
7760 blockSize = 16;
7761 break;
7762 case QRhiTexture::BC6H:
7763 blockSize = 16;
7764 break;
7765 case QRhiTexture::BC7:
7766 blockSize = 16;
7767 break;
7768
7770 blockSize = 8;
7771 break;
7773 blockSize = 8;
7774 break;
7776 blockSize = 16;
7777 break;
7778
7780 blockSize = 16;
7781 break;
7783 blockSize = 16;
7784 xdim = 5;
7785 break;
7787 blockSize = 16;
7788 xdim = ydim = 5;
7789 break;
7791 blockSize = 16;
7792 xdim = 6;
7793 ydim = 5;
7794 break;
7796 blockSize = 16;
7797 xdim = ydim = 6;
7798 break;
7800 blockSize = 16;
7801 xdim = 8;
7802 ydim = 5;
7803 break;
7805 blockSize = 16;
7806 xdim = 8;
7807 ydim = 6;
7808 break;
7810 blockSize = 16;
7811 xdim = ydim = 8;
7812 break;
7814 blockSize = 16;
7815 xdim = 10;
7816 ydim = 5;
7817 break;
7819 blockSize = 16;
7820 xdim = 10;
7821 ydim = 6;
7822 break;
7824 blockSize = 16;
7825 xdim = 10;
7826 ydim = 8;
7827 break;
7829 blockSize = 16;
7830 xdim = ydim = 10;
7831 break;
7833 blockSize = 16;
7834 xdim = 12;
7835 ydim = 10;
7836 break;
7838 blockSize = 16;
7839 xdim = ydim = 12;
7840 break;
7841
7842 default:
7843 Q_UNREACHABLE();
7844 break;
7845 }
7846
7847 const quint32 wblocks = uint((size.width() + xdim - 1) / xdim);
7848 const quint32 hblocks = uint((size.height() + ydim - 1) / ydim);
7849
7850 if (bpl)
7851 *bpl = wblocks * blockSize;
7852 if (byteSize)
7853 *byteSize = wblocks * hblocks * blockSize;
7854 if (blockDim)
7855 *blockDim = QSize(xdim, ydim);
7856}
7857
7859 quint32 *bpl, quint32 *byteSize, quint32 *bytesPerPixel) const
7860{
7862 compressedFormatInfo(format, size, bpl, byteSize, nullptr);
7863 return;
7864 }
7865
7866 quint32 bpc = 0;
7867 switch (format) {
7868 case QRhiTexture::RGBA8:
7869 bpc = 4;
7870 break;
7871 case QRhiTexture::BGRA8:
7872 bpc = 4;
7873 break;
7874 case QRhiTexture::R8:
7875 bpc = 1;
7876 break;
7877 case QRhiTexture::RG8:
7878 bpc = 2;
7879 break;
7880 case QRhiTexture::R16:
7881 bpc = 2;
7882 break;
7883 case QRhiTexture::RG16:
7884 bpc = 4;
7885 break;
7887 bpc = 1;
7888 break;
7889
7891 bpc = 8;
7892 break;
7894 bpc = 16;
7895 break;
7896 case QRhiTexture::R16F:
7897 bpc = 2;
7898 break;
7899 case QRhiTexture::R32F:
7900 bpc = 4;
7901 break;
7902
7904 bpc = 4;
7905 break;
7906
7907 case QRhiTexture::D16:
7908 bpc = 2;
7909 break;
7910 case QRhiTexture::D24:
7911 case QRhiTexture::D24S8:
7912 case QRhiTexture::D32F:
7913 bpc = 4;
7914 break;
7915
7916 default:
7917 Q_UNREACHABLE();
7918 break;
7919 }
7920
7921 if (bpl)
7922 *bpl = uint(size.width()) * bpc;
7923 if (byteSize)
7924 *byteSize = uint(size.width() * size.height()) * bpc;
7925 if (bytesPerPixel)
7926 *bytesPerPixel = bpc;
7927}
7928
7930{
7931 switch (format) {
7932 case QRhiTexture::D24S8:
7933 return true;
7934 default:
7935 break;
7936 }
7937 return false;
7938}
7939
7941{
7942 if (ps->cbeginShaderStages() == ps->cendShaderStages()) {
7943 qWarning("Cannot build a graphics pipeline without any stages");
7944 return false;
7945 }
7946
7947 bool hasVertexStage = false;
7948 for (auto it = ps->cbeginShaderStages(), itEnd = ps->cendShaderStages(); it != itEnd; ++it) {
7949 if (!it->shader().isValid()) {
7950 qWarning("Empty shader passed to graphics pipeline");
7951 return false;
7952 }
7953 if (it->type() == QRhiShaderStage::Vertex)
7954 hasVertexStage = true;
7955 }
7956 if (!hasVertexStage) {
7957 qWarning("Cannot build a graphics pipeline without a vertex stage");
7958 return false;
7959 }
7960
7961 if (!ps->renderPassDescriptor()) {
7962 qWarning("Cannot build a graphics pipeline without a QRhiRenderPassDescriptor");
7963 return false;
7964 }
7965
7966 if (!ps->shaderResourceBindings()) {
7967 qWarning("Cannot build a graphics pipeline without QRhiShaderResourceBindings");
7968 return false;
7969 }
7970
7971 return true;
7972}
7973
7975{
7976#ifndef QT_NO_DEBUG
7977 bool bindingsOk = true;
7978 const int CHECKED_BINDINGS_COUNT = 64;
7979 bool bindingSeen[CHECKED_BINDINGS_COUNT] = {};
7980 for (auto it = srb->cbeginBindings(), end = srb->cendBindings(); it != end; ++it) {
7981 const int binding = shaderResourceBindingData(*it)->binding;
7982 if (binding >= CHECKED_BINDINGS_COUNT)
7983 continue;
7984 if (binding < 0) {
7985 qWarning("Invalid binding number %d", binding);
7986 bindingsOk = false;
7987 continue;
7988 }
7989 switch (shaderResourceBindingData(*it)->type) {
7991 if (!bindingSeen[binding]) {
7992 bindingSeen[binding] = true;
7993 } else {
7994 qWarning("Uniform buffer duplicates an existing binding number %d", binding);
7995 bindingsOk = false;
7996 }
7997 break;
7999 if (!bindingSeen[binding]) {
8000 bindingSeen[binding] = true;
8001 } else {
8002 qWarning("Combined image sampler duplicates an existing binding number %d", binding);
8003 bindingsOk = false;
8004 }
8005 break;
8007 if (!bindingSeen[binding]) {
8008 bindingSeen[binding] = true;
8009 } else {
8010 qWarning("Texture duplicates an existing binding number %d", binding);
8011 bindingsOk = false;
8012 }
8013 break;
8015 if (!bindingSeen[binding]) {
8016 bindingSeen[binding] = true;
8017 } else {
8018 qWarning("Sampler duplicates an existing binding number %d", binding);
8019 bindingsOk = false;
8020 }
8021 break;
8025 if (!bindingSeen[binding]) {
8026 bindingSeen[binding] = true;
8027 } else {
8028 qWarning("Image duplicates an existing binding number %d", binding);
8029 bindingsOk = false;
8030 }
8031 break;
8035 if (!bindingSeen[binding]) {
8036 bindingSeen[binding] = true;
8037 } else {
8038 qWarning("Buffer duplicates an existing binding number %d", binding);
8039 bindingsOk = false;
8040 }
8041 break;
8042 default:
8043 qWarning("Unknown binding type %d", int(shaderResourceBindingData(*it)->type));
8044 bindingsOk = false;
8045 break;
8046 }
8047 }
8048
8049 if (!bindingsOk) {
8050 qWarning() << *srb;
8051 return false;
8052 }
8053#else
8054 Q_UNUSED(srb);
8055#endif
8056 return true;
8057}
8058
8063{
8064}
8065
8070{
8071 if (!d)
8072 return;
8073
8074 qDeleteAll(d->pendingDeleteResources);
8075 d->pendingDeleteResources.clear();
8076
8077 runCleanup();
8078
8079 d->destroy();
8080 delete d;
8081}
8082
8084{
8085 q = rhi;
8086
8087 // Play nice with QSG_INFO since that is still the most commonly used
8088 // way to get graphics info printed from Qt Quick apps, and the Quick
8089 // scenegraph is our primary user.
8090 if (qEnvironmentVariableIsSet("QSG_INFO"))
8091 const_cast<QLoggingCategory &>(QRHI_LOG_INFO()).setEnabled(QtDebugMsg, true);
8092
8094
8095 implType = impl;
8096 implThread = QThread::currentThread();
8097}
8098
8130{
8131 std::unique_ptr<QRhi> r(new QRhi);
8132
8133 switch (impl) {
8134 case Null:
8135 r->d = new QRhiNull(static_cast<QRhiNullInitParams *>(params));
8136 break;
8137 case Vulkan:
8138#if QT_CONFIG(vulkan)
8139 r->d = new QRhiVulkan(static_cast<QRhiVulkanInitParams *>(params),
8140 static_cast<QRhiVulkanNativeHandles *>(importDevice));
8141 break;
8142#else
8143 Q_UNUSED(importDevice);
8144 qWarning("This build of Qt has no Vulkan support");
8145 break;
8146#endif
8147 case OpenGLES2:
8148#ifndef QT_NO_OPENGL
8149 r->d = new QRhiGles2(static_cast<QRhiGles2InitParams *>(params),
8150 static_cast<QRhiGles2NativeHandles *>(importDevice));
8151 break;
8152#else
8153 qWarning("This build of Qt has no OpenGL support");
8154 break;
8155#endif
8156 case D3D11:
8157#ifdef Q_OS_WIN
8158 r->d = new QRhiD3D11(static_cast<QRhiD3D11InitParams *>(params),
8159 static_cast<QRhiD3D11NativeHandles *>(importDevice));
8160 break;
8161#else
8162 qWarning("This platform has no Direct3D 11 support");
8163 break;
8164#endif
8165 case Metal:
8166#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
8167 r->d = new QRhiMetal(static_cast<QRhiMetalInitParams *>(params),
8168 static_cast<QRhiMetalNativeHandles *>(importDevice));
8169 break;
8170#else
8171 qWarning("This platform has no Metal support");
8172 break;
8173#endif
8174 case D3D12:
8175#ifdef Q_OS_WIN
8176#ifdef QRHI_D3D12_AVAILABLE
8177 r->d = new QRhiD3D12(static_cast<QRhiD3D12InitParams *>(params),
8178 static_cast<QRhiD3D12NativeHandles *>(importDevice));
8179 break;
8180#else
8181 qWarning("Qt was built without Direct3D 12 support. "
8182 "This is likely due to having ancient SDK headers (such as d3d12.h) in the Qt build environment. "
8183 "Rebuild Qt with an SDK supporting D3D12 features introduced in Windows 10 version 1703, "
8184 "or use an MSVC build as those typically are built with more up-to-date SDKs.");
8185 break;
8186#endif
8187#else
8188 qWarning("This platform has no Direct3D 12 support");
8189 break;
8190#endif
8191 }
8192
8193 if (r->d) {
8194 r->d->prepareForCreate(r.get(), impl, flags);
8195 if (r->d->create(flags))
8196 return r.release();
8197 }
8198
8199 return nullptr;
8200}
8201
8216{
8217 bool ok = false;
8218
8219 // The only place currently where this makes sense is Metal, where the API
8220 // is simple enough so that a special probing function - doing nothing but
8221 // a MTLCreateSystemDefaultDevice - is reasonable. Elsewhere, just call
8222 // create() and then drop the result.
8223
8224 if (impl == Metal) {
8225#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
8226 ok = QRhiMetal::probe(static_cast<QRhiMetalInitParams *>(params));
8227#endif
8228 } else {
8229 QRhi *rhi = create(impl, params);
8230 ok = rhi != nullptr;
8231 delete rhi;
8232 }
8233 return ok;
8234}
8235
8275{
8276#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
8277 if (impl == Metal)
8279#else
8280 Q_UNUSED(impl);
8282#endif
8283 return {};
8284}
8285
8290{
8291 return d->implType;
8292}
8293
8299{
8300 switch (impl) {
8301 case QRhi::Null:
8302 return "Null";
8303 case QRhi::Vulkan:
8304 return "Vulkan";
8305 case QRhi::OpenGLES2:
8306 return "OpenGL";
8307 case QRhi::D3D11:
8308 return "D3D11";
8309 case QRhi::Metal:
8310 return "Metal";
8311 case QRhi::D3D12:
8312 return "D3D12";
8313 }
8314
8315 Q_UNREACHABLE_RETURN("Unknown");
8316}
8317
8321const char *QRhi::backendName() const
8322{
8323 return backendName(d->implType);
8324}
8325
8384#ifndef QT_NO_DEBUG_STREAM
8386{
8387 switch (type) {
8389 return "Unknown";
8391 return "Integrated";
8393 return "Discrete";
8395 return "External";
8397 return "Virtual";
8399 return "Cpu";
8400 }
8401
8402 Q_UNREACHABLE_RETURN(nullptr);
8403}
8405{
8406 QDebugStateSaver saver(dbg);
8407 dbg.nospace() << "QRhiDriverInfo(deviceName=" << info.deviceName
8408 << " deviceId=0x" << Qt::hex << info.deviceId
8409 << " vendorId=0x" << info.vendorId
8410 << " deviceType=" << deviceTypeStr(info.deviceType)
8411 << ')';
8412 return dbg;
8413}
8414#endif
8415
8421{
8422 return d->driverInfo();
8423}
8424
8429{
8430 return d->implThread;
8431}
8432
8446{
8447 d->addCleanupCallback(callback);
8448}
8449
8459{
8460 for (const CleanupCallback &f : std::as_const(d->cleanupCallbacks))
8461 f(this);
8462
8463 d->cleanupCallbacks.clear();
8464}
8465
8493QRhiResourceUpdateBatch::QRhiResourceUpdateBatch(QRhiImplementation *rhi)
8495{
8496 d->q = this;
8497 d->rhi = rhi;
8498}
8499
8501{
8502 delete d;
8503}
8504
8515{
8516 d->free();
8517}
8518
8554{
8555 d->merge(other->d);
8556}
8557
8572{
8573 return d->hasOptimalCapacity();
8574}
8575
8596{
8597 if (size > 0) {
8598 const int idx = d->activeBufferOpCount++;
8599 const int opListSize = d->bufferOps.size();
8600 if (idx < opListSize)
8602 else
8604 }
8605}
8606
8616{
8617 if (size > 0) {
8618 const int idx = d->activeBufferOpCount++;
8619 if (idx < d->bufferOps.size())
8621 else
8623 }
8624}
8625
8631{
8632 if (buf->size() > 0) {
8633 const int idx = d->activeBufferOpCount++;
8634 if (idx < d->bufferOps.size())
8636 else
8638 }
8639}
8640
8666{
8667 const int idx = d->activeBufferOpCount++;
8668 if (idx < d->bufferOps.size())
8670 else
8672}
8673
8682{
8683 if (desc.cbeginEntries() != desc.cendEntries()) {
8684 const int idx = d->activeTextureOpCount++;
8685 if (idx < d->textureOps.size())
8687 else
8689 }
8690}
8691
8701{
8702 uploadTexture(tex,
8704}
8705
8719{
8720 const int idx = d->activeTextureOpCount++;
8721 if (idx < d->textureOps.size())
8723 else
8725}
8726
8789{
8790 const int idx = d->activeTextureOpCount++;
8791 if (idx < d->textureOps.size())
8793 else
8795}
8796
8813{
8814 const int idx = d->activeTextureOpCount++;
8815 if (idx < d->textureOps.size())
8817 else
8819}
8820
8855{
8856 // By default we prefer spreading out the utilization of the 64 batches as
8857 // much as possible, meaning we won't pick the first one even if it's free,
8858 // but prefer picking one after the last picked one. Relevant due to how
8859 // QVLA and QRhiBufferData allocations behind the bufferOps are reused; in
8860 // typical Qt Quick scenes this leads to a form of (eventually) seeding all
8861 // the 64 resource batches with buffer operation data allocations which are
8862 // then reused in subsequent frames. This comes at the expense of using
8863 // more memory, but has proven good results when (CPU) profiling typical
8864 // Quick/Quick3D apps.
8865 //
8866 // Prefering memory over performance means that we always pick the first
8867 // free batch, and triggering the aggressive deallocating of all backing
8868 // memory (see trimOpLists) before returning it.
8869 static const bool preferMemoryOverPerformance = qEnvironmentVariableIntValue("QT_RHI_MINIMIZE_POOLS");
8870
8871 auto nextFreeBatch = [this]() -> QRhiResourceUpdateBatch * {
8872 auto isFree = [this](int i) -> QRhiResourceUpdateBatch * {
8873 const quint64 mask = 1ULL << quint64(i);
8874 if (!(d->resUpdPoolMap & mask)) {
8875 d->resUpdPoolMap |= mask;
8876 QRhiResourceUpdateBatch *u = d->resUpdPool[i];
8878 if (!preferMemoryOverPerformance)
8879 d->lastResUpdIdx = i;
8880 return u;
8881 }
8882 return nullptr;
8883 };
8884 const int poolSize = d->resUpdPool.size();
8885 for (int i = d->lastResUpdIdx + 1; i < poolSize; ++i) {
8886 if (QRhiResourceUpdateBatch *u = isFree(i))
8887 return u;
8888 }
8889 for (int i = 0; i <= d->lastResUpdIdx; ++i) {
8890 if (QRhiResourceUpdateBatch *u = isFree(i))
8891 return u;
8892 }
8893 return nullptr;
8894 };
8895
8896 QRhiResourceUpdateBatch *u = nextFreeBatch();
8897 if (!u) {
8898 const int oldSize = d->resUpdPool.size();
8899 const int newSize = oldSize + qMin(4, qMax(0, 64 - oldSize));
8900 d->resUpdPool.resize(newSize);
8901 for (int i = oldSize; i < newSize; ++i)
8902 d->resUpdPool[i] = new QRhiResourceUpdateBatch(d);
8903 u = nextFreeBatch();
8904 if (!u)
8905 qWarning("Resource update batch pool exhausted (max is 64)");
8906 }
8907
8908 if (preferMemoryOverPerformance && u)
8909 u->d->trimOpLists();
8910
8911 return u;
8912}
8913
8915{
8916 Q_ASSERT(poolIndex >= 0 && rhi->resUpdPool[poolIndex] == q);
8917
8920
8921 const quint64 mask = 1ULL << quint64(poolIndex);
8922 rhi->resUpdPoolMap &= ~mask;
8923 poolIndex = -1;
8924
8925 // textureOps is cleared, to not keep the potentially large image pixel
8926 // data alive, but it is expected that the container keeps the list alloc
8927 // at least. Only trimOpList() goes for the more aggressive route with squeeze.
8928 textureOps.clear();
8929
8930 // bufferOps is not touched, to allow reusing allocations (incl. in the
8931 // elements' QRhiBufferData) as much as possible when this batch is used
8932 // again in the future, which is important for performance, in particular
8933 // with Qt Quick.
8934}
8935
8937{
8938 int combinedSize = activeBufferOpCount + other->activeBufferOpCount;
8939 if (bufferOps.size() < combinedSize)
8940 bufferOps.resize(combinedSize);
8941 for (int i = activeBufferOpCount; i < combinedSize; ++i)
8942 bufferOps[i] = std::move(other->bufferOps[i - activeBufferOpCount]);
8943 activeBufferOpCount += other->activeBufferOpCount;
8944
8945 combinedSize = activeTextureOpCount + other->activeTextureOpCount;
8946 if (textureOps.size() < combinedSize)
8947 textureOps.resize(combinedSize);
8948 for (int i = activeTextureOpCount; i < combinedSize; ++i)
8949 textureOps[i] = std::move(other->textureOps[i - activeTextureOpCount]);
8950 activeTextureOpCount += other->activeTextureOpCount;
8951}
8952
8954{
8957}
8958
8960{
8961 // Unlike free(), this is expected to aggressively deallocate all memory
8962 // used by both the buffer and texture operation lists. (i.e. using
8963 // squeeze() to only keep the stack prealloc of the QVLAs)
8964 //
8965 // This (e.g. just the destruction of bufferOps elements) may have a
8966 // non-negligible performance impact e.g. with Qt Quick with scenes where
8967 // there are lots of buffer operations per frame.
8968
8970 bufferOps.clear();
8971 bufferOps.squeeze();
8972
8974 textureOps.clear();
8975 textureOps.squeeze();
8976}
8977
8987{
8988 if (resourceUpdates)
8989 m_rhi->resourceUpdate(this, resourceUpdates);
8990}
8991
9046 const QColor &colorClearValue,
9047 const QRhiDepthStencilClearValue &depthStencilClearValue,
9048 QRhiResourceUpdateBatch *resourceUpdates,
9049 BeginPassFlags flags)
9050{
9051 m_rhi->beginPass(this, rt, colorClearValue, depthStencilClearValue, resourceUpdates, flags);
9052}
9053
9063{
9064 m_rhi->endPass(this, resourceUpdates);
9065}
9066
9083{
9084 Q_ASSERT(ps != nullptr);
9085 m_rhi->setGraphicsPipeline(this, ps);
9086}
9087
9141 int dynamicOffsetCount,
9142 const DynamicOffset *dynamicOffsets)
9143{
9144 m_rhi->setShaderResources(this, srb, dynamicOffsetCount, dynamicOffsets);
9145}
9146
9202void QRhiCommandBuffer::setVertexInput(int startBinding, int bindingCount, const VertexInput *bindings,
9203 QRhiBuffer *indexBuf, quint32 indexOffset,
9204 IndexFormat indexFormat)
9205{
9206 m_rhi->setVertexInput(this, startBinding, bindingCount, bindings, indexBuf, indexOffset, indexFormat);
9207}
9208
9224{
9225 m_rhi->setViewport(this, viewport);
9226}
9227
9243{
9244 m_rhi->setScissor(this, scissor);
9245}
9246
9257{
9258 m_rhi->setBlendConstants(this, c);
9259}
9260
9271{
9272 m_rhi->setStencilRef(this, refValue);
9273}
9274
9292 quint32 firstVertex,
9293 quint32 firstInstance)
9294{
9295 m_rhi->draw(this, vertexCount, instanceCount, firstVertex, firstInstance);
9296}
9297
9329 quint32 firstIndex,
9330 qint32 vertexOffset,
9331 quint32 firstInstance)
9332{
9333 m_rhi->drawIndexed(this, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
9334}
9335
9349{
9350 m_rhi->debugMarkBegin(this, name);
9351}
9352
9362{
9363 m_rhi->debugMarkEnd(this);
9364}
9365
9377{
9378 m_rhi->debugMarkMsg(this, msg);
9379}
9380
9401{
9402 m_rhi->beginComputePass(this, resourceUpdates, flags);
9403}
9404
9412{
9413 m_rhi->endComputePass(this, resourceUpdates);
9414}
9415
9430{
9431 m_rhi->setComputePipeline(this, ps);
9432}
9433
9454{
9455 m_rhi->dispatch(this, x, y, z);
9456}
9457
9468{
9469 return m_rhi->nativeHandles(this);
9470}
9471
9512{
9513 m_rhi->beginExternal(this);
9514}
9515
9527{
9528 m_rhi->endExternal(this);
9529}
9530
9562{
9563 return m_rhi->lastCompletedGpuTime(this);
9564}
9565
9570int QRhi::ubufAligned(int v) const
9571{
9572 const int byteAlign = ubufAlignment();
9573 return (v + byteAlign - 1) & ~(byteAlign - 1);
9574}
9575
9580{
9581 return qFloor(std::log2(qMax(size.width(), size.height()))) + 1;
9582}
9583
9588QSize QRhi::sizeForMipLevel(int mipLevel, const QSize &baseLevelSize)
9589{
9590 const int w = qMax(1, baseLevelSize.width() >> mipLevel);
9591 const int h = qMax(1, baseLevelSize.height() >> mipLevel);
9592 return QSize(w, h);
9593}
9594
9602{
9603 return d->isYUpInFramebuffer();
9604}
9605
9616{
9617 return d->isYUpInNDC();
9618}
9619
9641{
9642 return d->isClipDepthZeroToOne();
9643}
9644
9663{
9664 return d->clipSpaceCorrMatrix();
9665}
9666
9674{
9676}
9677
9682{
9683 return d->isFeatureSupported(feature);
9684}
9685
9693{
9694 return d->resourceLimit(limit);
9695}
9696
9709{
9710 return d->nativeHandles();
9711}
9712
9730{
9732}
9733
9747{
9749
9750 for (QRhiResourceUpdateBatch *u : d->resUpdPool) {
9751 if (u->d->poolIndex < 0)
9752 u->d->trimOpLists();
9753 }
9754}
9755
9799{
9800 return d->isDeviceLost();
9801}
9802
9843{
9844 return d->pipelineCacheData();
9845}
9846
9897{
9899}
9900
9967#ifndef QT_NO_DEBUG_STREAM
9969{
9970 QDebugStateSaver saver(dbg);
9971 dbg.nospace() << "QRhiStats("
9972 << "totalPipelineCreationTime=" << info.totalPipelineCreationTime
9973 << " blockCount=" << info.blockCount
9974 << " allocCount=" << info.allocCount
9975 << " usedBytes=" << info.usedBytes
9976 << " unusedBytes=" << info.unusedBytes
9977 << " totalUsageBytes=" << info.totalUsageBytes
9978 << ')';
9979 return dbg;
9980}
9981#endif
9982
10028{
10029 return d->statistics();
10030}
10031
10038{
10039 return d->createGraphicsPipeline();
10040}
10041
10051{
10052 return d->createComputePipeline();
10053}
10054
10061{
10062 return d->createShaderResourceBindings();
10063}
10064
10080 QRhiBuffer::UsageFlags usage,
10081 quint32 size)
10082{
10083 return d->createBuffer(type, usage, size);
10084}
10085
10107 const QSize &pixelSize,
10108 int sampleCount,
10109 QRhiRenderBuffer::Flags flags,
10110 QRhiTexture::Format backingFormatHint)
10111{
10112 return d->createRenderBuffer(type, pixelSize, sampleCount, flags, backingFormatHint);
10113}
10114
10134 const QSize &pixelSize,
10135 int sampleCount,
10136 QRhiTexture::Flags flags)
10137{
10138 if (pixelSize.height() == 0)
10140
10141 return d->createTexture(format, pixelSize, 1, 0, sampleCount, flags);
10142}
10143
10167 int width, int height, int depth,
10168 int sampleCount,
10169 QRhiTexture::Flags flags)
10170{
10171 if (depth > 0)
10173
10174 if (height == 0 && depth == 0)
10176
10177 return d->createTexture(format, QSize(width, height), depth, 0, sampleCount, flags);
10178}
10179
10208 int arraySize,
10209 const QSize &pixelSize,
10210 int sampleCount,
10211 QRhiTexture::Flags flags)
10212{
10214
10215 if (pixelSize.height() == 0)
10217
10218 return d->createTexture(format, pixelSize, 1, arraySize, sampleCount, flags);
10219}
10220
10229 QRhiSampler::Filter minFilter,
10230 QRhiSampler::Filter mipmapMode,
10231 QRhiSampler::AddressMode addressU,
10232 QRhiSampler::AddressMode addressV,
10233 QRhiSampler::AddressMode addressW)
10234{
10235 return d->createSampler(magFilter, minFilter, mipmapMode, addressU, addressV, addressW);
10236}
10237
10246 QRhiTextureRenderTarget::Flags flags)
10247{
10249}
10250
10257{
10258 return d->createSwapChain();
10259}
10260
10309{
10310 if (d->inFrame)
10311 qWarning("Attempted to call beginFrame() within a still active frame; ignored");
10312
10314 if (r == FrameOpSuccess)
10315 d->inFrame = true;
10316
10317 return r;
10318}
10319
10344{
10345 if (!d->inFrame)
10346 qWarning("Attempted to call endFrame() without an active frame; ignored");
10347
10348 QRhi::FrameOpResult r = d->inFrame ? d->endFrame(swapChain, flags) : FrameOpSuccess;
10349 d->inFrame = false;
10350 // deleteLater is a high level QRhi concept the backends know
10351 // nothing about - handle it here.
10352 qDeleteAll(d->pendingDeleteResources);
10353 d->pendingDeleteResources.clear();
10354
10355 return r;
10356}
10357
10366{
10367 return d->inFrame;
10368}
10369
10410{
10411 return d->currentFrameSlot;
10412}
10413
10457{
10458 if (d->inFrame)
10459 qWarning("Attempted to call beginOffscreenFrame() within a still active frame; ignored");
10460
10462 if (r == FrameOpSuccess)
10463 d->inFrame = true;
10464
10465 return r;
10466}
10467
10476{
10477 if (!d->inFrame)
10478 qWarning("Attempted to call endOffscreenFrame() without an active frame; ignored");
10479
10481 d->inFrame = false;
10482 qDeleteAll(d->pendingDeleteResources);
10483 d->pendingDeleteResources.clear();
10484
10485 return r;
10486}
10487
10500{
10501 return d->finish();
10502}
10503
10517{
10518 return d->supportedSampleCounts();
10519}
10520
10532{
10533 return d->ubufAlignment();
10534}
10535
10537
10539{
10540 return counter.fetchAndAddRelaxed(1) + 1;
10541}
10542
10544{
10545 return m_buffers.isEmpty() && m_textures.isEmpty();
10546}
10547
10549{
10550 m_buffers.clear();
10551 m_textures.clear();
10552}
10553
10556{
10557 return QRhiPassResourceTracker::BufferStage(qMin(int(a), int(b)));
10558}
10559
10561 const UsageState &state)
10562{
10563 auto it = m_buffers.find(buf);
10564 if (it != m_buffers.end()) {
10565 if (it->access != *access) {
10566 const QByteArray name = buf->name();
10567 qWarning("Buffer %p (%s) used with different accesses within the same pass, this is not allowed.",
10568 buf, name.constData());
10569 return;
10570 }
10571 if (it->stage != *stage) {
10572 it->stage = earlierStage(it->stage, *stage);
10573 *stage = it->stage;
10574 }
10575 return;
10576 }
10577
10578 Buffer b;
10579 b.slot = slot;
10580 b.access = *access;
10581 b.stage = *stage;
10582 b.stateAtPassBegin = state; // first use -> initial state
10583 m_buffers.insert(buf, b);
10584}
10585
10588{
10589 return QRhiPassResourceTracker::TextureStage(qMin(int(a), int(b)));
10590}
10591
10593{
10597}
10598
10600 const UsageState &state)
10601{
10602 auto it = m_textures.find(tex);
10603 if (it != m_textures.end()) {
10604 if (it->access != *access) {
10605 // Different subresources of a texture may be used for both load
10606 // and store in the same pass. (think reading from one mip level
10607 // and writing to another one in a compute shader) This we can
10608 // handle by treating the entire resource as read-write.
10609 if (isImageLoadStore(it->access) && isImageLoadStore(*access)) {
10611 *access = it->access;
10612 } else {
10613 const QByteArray name = tex->name();
10614 qWarning("Texture %p (%s) used with different accesses within the same pass, this is not allowed.",
10615 tex, name.constData());
10616 }
10617 }
10618 if (it->stage != *stage) {
10619 it->stage = earlierStage(it->stage, *stage);
10620 *stage = it->stage;
10621 }
10622 return;
10623 }
10624
10625 Texture t;
10626 t.access = *access;
10627 t.stage = *stage;
10628 t.stateAtPassBegin = state; // first use -> initial state
10629 m_textures.insert(tex, t);
10630}
10631
10633{
10634 // pick the earlier stage (as this is going to be dstAccessMask)
10647
10648 Q_UNREACHABLE_RETURN(QRhiPassResourceTracker::BufVertexStage);
10649}
10650
10652{
10653 // pick the earlier stage (as this is going to be dstAccessMask)
10666
10667 Q_UNREACHABLE_RETURN(QRhiPassResourceTracker::TexVertexStage);
10668}
10669
NSData * m_data
\inmodule QtCore
Definition qbytearray.h:57
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
\inmodule QtCore
const_iterator cbegin() const noexcept
Definition qhash.h:1204
qsizetype size() const noexcept
Returns the number of items in the hash.
Definition qhash.h:925
const_iterator cend() const noexcept
Definition qhash.h:1208
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
Definition qhash.h:926
\inmodule QtGui
Definition qimage.h:37
Definition qlist.h:74
\inmodule QtCore
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtGui
Definition qrhi.h:834
virtual char * beginFullDynamicBufferUpdateForCurrentFrame()
Definition qrhi.cpp:3844
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:3712
Type
Specifies storage type of buffer resource.
Definition qrhi.h:836
QRhiBuffer(QRhiImplementation *rhi, Type type_, UsageFlags usage_, quint32 size_)
\variable QRhiBuffer::NativeBuffer::objects
Definition qrhi.cpp:3703
virtual void endFullDynamicBufferUpdateForCurrentFrame()
To be called when the entire contents of the buffer data has been updated in the memory block returne...
Definition qrhi.cpp:3854
virtual NativeBuffer nativeBuffer()
Definition qrhi.cpp:3805
\inmodule QtGui
Definition qrhi.h:568
QRhiColorAttachment()=default
Constructs an empty color attachment description.
\inmodule QtGui
Definition qrhi.h:1614
void endPass(QRhiResourceUpdateBatch *resourceUpdates=nullptr)
Records ending the current render pass.
Definition qrhi.cpp:9062
void debugMarkMsg(const QByteArray &msg)
Inserts a debug message msg into the command stream.
Definition qrhi.cpp:9376
void draw(quint32 vertexCount, quint32 instanceCount=1, quint32 firstVertex=0, quint32 firstInstance=0)
Records a non-indexed draw.
Definition qrhi.cpp:9290
void setBlendConstants(const QColor &c)
Records setting the active blend constants to c.
Definition qrhi.cpp:9256
void endExternal()
To be called once the externally added commands are recorded to the command buffer or context.
Definition qrhi.cpp:9526
void setScissor(const QRhiScissor &scissor)
Records setting the active scissor rectangle specified in scissor.
Definition qrhi.cpp:9242
void beginComputePass(QRhiResourceUpdateBatch *resourceUpdates=nullptr, BeginPassFlags flags={})
Records starting a new compute pass.
Definition qrhi.cpp:9400
void drawIndexed(quint32 indexCount, quint32 instanceCount=1, quint32 firstIndex=0, qint32 vertexOffset=0, quint32 firstInstance=0)
Records an indexed draw.
Definition qrhi.cpp:9327
void setStencilRef(quint32 refValue)
Records setting the active stencil reference value to refValue.
Definition qrhi.cpp:9270
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
Definition qrhi.h:1643
const QRhiNativeHandles * nativeHandles()
Definition qrhi.cpp:9467
QRhiCommandBuffer(QRhiImplementation *rhi)
Definition qrhi.cpp:7652
void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates)
Sometimes committing resource updates is necessary or just more convenient without starting a render ...
Definition qrhi.cpp:8986
void dispatch(int x, int y, int z)
Records dispatching compute work items, with x, y, and z specifying the number of local workgroups in...
Definition qrhi.cpp:9453
void beginPass(QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates=nullptr, BeginPassFlags flags={})
Records starting a new render pass targeting the render target rt.
Definition qrhi.cpp:9045
double lastCompletedGpuTime()
Definition qrhi.cpp:9561
void setShaderResources(QRhiShaderResourceBindings *srb=nullptr, int dynamicOffsetCount=0, const DynamicOffset *dynamicOffsets=nullptr)
Records binding a set of shader resources, such as, uniform buffers or textures, that are made visibl...
Definition qrhi.cpp:9140
void beginExternal()
To be called when the application before the application is about to enqueue commands to the current ...
Definition qrhi.cpp:9511
void debugMarkBegin(const QByteArray &name)
Records a named debug group on the command buffer with the specified name.
Definition qrhi.cpp:9348
void setViewport(const QRhiViewport &viewport)
Records setting the active viewport rectangle specified in viewport.
Definition qrhi.cpp:9223
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:7660
void debugMarkEnd()
Records the end of a debug group.
Definition qrhi.cpp:9361
void endComputePass(QRhiResourceUpdateBatch *resourceUpdates=nullptr)
Records ending the current compute pass.
Definition qrhi.cpp:9411
QPair< int, quint32 > DynamicOffset
Synonym for QPair<int, quint32>.
Definition qrhi.h:1639
IndexFormat
Specifies the index data type.
Definition qrhi.h:1616
void setComputePipeline(QRhiComputePipeline *ps)
Records setting a new compute pipeline ps.
Definition qrhi.cpp:9429
void setVertexInput(int startBinding, int bindingCount, const VertexInput *bindings, QRhiBuffer *indexBuf=nullptr, quint32 indexOffset=0, IndexFormat indexFormat=IndexUInt16)
Records vertex input bindings.
Definition qrhi.cpp:9202
void setGraphicsPipeline(QRhiGraphicsPipeline *ps)
Records setting a new graphics pipeline ps.
Definition qrhi.cpp:9082
\inmodule QtGui
Definition qrhi.h:1585
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:7538
QRhiComputePipeline(QRhiImplementation *rhi)
Definition qrhi.cpp:7546
\inmodule QtGui
\variable QRhiD3D11InitParams::enableDebugLayer
\inmodule QtGui
Definition qrhi.h:44
\inmodule QtGui
\variable QRhiGles2InitParams::format
\inmodule QtGui
Definition qrhi.h:1241
const QRhiShaderStage * cendShaderStages() const
Definition qrhi.h:1425
QRhiShaderResourceBindings * shaderResourceBindings() const
Definition qrhi.h:1432
QRhiRenderPassDescriptor * renderPassDescriptor() const
Definition qrhi.h:1435
QRhiGraphicsPipeline(QRhiImplementation *rhi)
\variable QRhiGraphicsPipeline::StencilOpState::failOp
Definition qrhi.cpp:6470
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:6478
const QRhiShaderStage * cbeginShaderStages() const
Definition qrhi.h:1424
virtual bool isClipDepthZeroToOne() const =0
bool isStencilSupportingFormat(QRhiTexture::Format format) const
Definition qrhi.cpp:7929
virtual void endExternal(QRhiCommandBuffer *cb)=0
virtual QRhiTextureRenderTarget * createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags)=0
virtual QRhiComputePipeline * createComputePipeline()=0
virtual QRhiGraphicsPipeline * createGraphicsPipeline()=0
virtual void beginPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags)=0
virtual void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps)=0
virtual void releaseCachedResources()=0
virtual ~QRhiImplementation()
Definition qrhi.cpp:7697
virtual bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const =0
virtual QRhiDriverInfo driverInfo() const =0
bool isCompressedFormat(QRhiTexture::Format format) const
Definition qrhi.cpp:7731
static const QRhiShaderResourceBinding::Data * shaderResourceBindingData(const QRhiShaderResourceBinding &binding)
Definition qrhi_p.h:210
void updateLayoutDesc(QRhiShaderResourceBindings *srb)
Definition qrhi.cpp:5150
virtual QRhiSampler * createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w)=0
virtual QRhiTexture * createTexture(QRhiTexture::Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, QRhiTexture::Flags flags)=0
virtual bool isYUpInFramebuffer() const =0
virtual QList< int > supportedSampleCounts() const =0
virtual void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
virtual void debugMarkEnd(QRhiCommandBuffer *cb)=0
virtual QRhi::FrameOpResult finish()=0
virtual QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags)=0
virtual void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
virtual int ubufAlignment() const =0
void compressedFormatInfo(QRhiTexture::Format format, const QSize &size, quint32 *bpl, quint32 *byteSize, QSize *blockDim) const
Definition qrhi.cpp:7738
virtual QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags)=0
virtual void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
bool sanityCheckShaderResourceBindings(QRhiShaderResourceBindings *srb)
Definition qrhi.cpp:7974
virtual void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags)=0
virtual void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c)=0
virtual void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name)=0
virtual int resourceLimit(QRhi::ResourceLimit limit) const =0
virtual void setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBindings *srb, int dynamicOffsetCount, const QRhiCommandBuffer::DynamicOffset *dynamicOffsets)=0
virtual void setPipelineCacheData(const QByteArray &data)=0
virtual QRhiBuffer * createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size)=0
void prepareForCreate(QRhi *rhi, QRhi::Implementation impl, QRhi::Flags flags)
Definition qrhi.cpp:8083
virtual bool isDeviceLost() const =0
virtual const QRhiNativeHandles * nativeHandles(QRhiCommandBuffer *cb)=0
virtual void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)=0
virtual void beginExternal(QRhiCommandBuffer *cb)=0
virtual QMatrix4x4 clipSpaceCorrMatrix() const =0
quint32 byteSizePerVertexForVertexInputFormat(QRhiVertexInputAttribute::Format format) const
Definition qrhi.cpp:1831
virtual void dispatch(QRhiCommandBuffer *cb, int x, int y, int z)=0
virtual bool makeThreadLocalNativeContextCurrent()=0
void addDeleteLater(QRhiResource *res)
Definition qrhi_p.h:169
virtual void setVertexInput(QRhiCommandBuffer *cb, int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat)=0
virtual QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags)=0
virtual void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue)=0
bool sanityCheckGraphicsPipeline(QRhiGraphicsPipeline *ps)
Definition qrhi.cpp:7940
virtual void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg)=0
QRhiVertexInputAttribute::Format shaderDescVariableFormatToVertexInputFormat(QShaderDescription::VariableType type) const
Definition qrhi.cpp:1787
virtual double lastCompletedGpuTime(QRhiCommandBuffer *cb)=0
virtual QRhiRenderBuffer * createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint)=0
void addCleanupCallback(const QRhi::CleanupCallback &callback)
Definition qrhi_p.h:177
virtual bool isYUpInNDC() const =0
virtual void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance)=0
virtual QRhiShaderResourceBindings * createShaderResourceBindings()=0
virtual bool isFeatureSupported(QRhi::Feature feature) const =0
virtual void setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline *ps)=0
void textureFormatInfo(QRhiTexture::Format format, const QSize &size, quint32 *bpl, quint32 *byteSize, quint32 *bytesPerPixel) const
Definition qrhi.cpp:7858
virtual void draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance)=0
virtual void destroy()=0
virtual QByteArray pipelineCacheData()=0
virtual QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags)=0
virtual QRhiStats statistics()=0
virtual void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)=0
virtual QRhiSwapChain * createSwapChain()=0
\inmodule QtRhi
\inmodule QtRhi
static QRhiSwapChainProxyData updateSwapChainProxyData(QWindow *window)
static bool probe(QRhiMetalInitParams *params)
Definition qrhimetal.mm:488
static TextureStage toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages)
Definition qrhi.cpp:10651
static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages)
Definition qrhi.cpp:10632
bool isEmpty() const
Definition qrhi.cpp:10543
void registerBuffer(QRhiBuffer *buf, int slot, BufferAccess *access, BufferStage *stage, const UsageState &state)
Definition qrhi.cpp:10560
void registerTexture(QRhiTexture *tex, TextureAccess *access, TextureStage *stage, const UsageState &state)
Definition qrhi.cpp:10599
\inmodule QtGui
Definition qrhi.h:765
QRhiReadbackDescription()=default
Constructs an empty texture readback description.
\inmodule QtGui
Definition qrhi.h:1071
QRhiRenderBuffer(QRhiImplementation *rhi, Type type_, const QSize &pixelSize_, int sampleCount_, Flags flags_, QRhiTexture::Format backingFormatHint_)
Definition qrhi.cpp:3933
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:3945
Type
Specifies the type of the renderbuffer.
Definition qrhi.h:1073
virtual bool createFrom(NativeRenderBuffer src)
Similar to create() except that no new native renderbuffer objects are created.
Definition qrhi.cpp:3993
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:4659
virtual const QRhiNativeHandles * nativeHandles()
Definition qrhi.cpp:4745
QRhiRenderPassDescriptor(QRhiImplementation *rhi)
Definition qrhi.cpp:4651
\inmodule QtGui
Definition qrhi.h:1135
QRhiRenderTarget(QRhiImplementation *rhi)
Definition qrhi.cpp:4772
QVarLengthArray< BufferOp, BUFFER_OPS_STATIC_ALLOC > bufferOps
Definition qrhi_p.h:508
bool hasOptimalCapacity() const
Definition qrhi.cpp:8953
QRhiImplementation * rhi
Definition qrhi_p.h:515
QVarLengthArray< TextureOp, TEXTURE_OPS_STATIC_ALLOC > textureOps
Definition qrhi_p.h:512
static const int BUFFER_OPS_STATIC_ALLOC
Definition qrhi_p.h:507
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
Definition qrhi_p.h:523
void merge(QRhiResourceUpdateBatchPrivate *other)
Definition qrhi.cpp:8936
static const int TEXTURE_OPS_STATIC_ALLOC
Definition qrhi_p.h:511
\inmodule QtGui
Definition qrhi.h:1694
void merge(QRhiResourceUpdateBatch *other)
Copies all queued operations from the other batch into this one.
Definition qrhi.cpp:8553
void generateMips(QRhiTexture *tex)
Enqueues a mipmap generation operation for the specified texture tex.
Definition qrhi.cpp:8812
void updateDynamicBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Enqueues updating a region of a QRhiBuffer buf created with the type QRhiBuffer::Dynamic.
Definition qrhi.cpp:8595
void uploadStaticBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Enqueues updating a region of a QRhiBuffer buf created with the type QRhiBuffer::Immutable or QRhiBuf...
Definition qrhi.cpp:8615
void uploadTexture(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
Enqueues uploading the image data for one or more mip levels in one or more layers of the texture tex...
Definition qrhi.cpp:8681
void readBackTexture(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
Enqueues a texture-to-host copy operation as described by rb.
Definition qrhi.cpp:8788
void readBackBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result)
Enqueues reading back a region of the QRhiBuffer buf.
Definition qrhi.cpp:8665
void copyTexture(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc=QRhiTextureCopyDescription())
Enqueues a texture-to-texture copy operation from src into dst as described by desc.
Definition qrhi.cpp:8718
bool hasOptimalCapacity() const
Definition qrhi.cpp:8571
\inmodule QtGui
Definition qrhi.h:792
QRhiResource(QRhiImplementation *rhi)
Definition qrhi.cpp:3338
QByteArray m_objectName
Definition qrhi.h:830
Type
Specifies type of the resource.
Definition qrhi.h:794
@ RenderBuffer
Definition qrhi.h:798
@ RenderPassDescriptor
Definition qrhi.h:799
@ SwapChain
Definition qrhi.h:804
@ ComputePipeline
Definition qrhi.h:805
@ SwapChainRenderTarget
Definition qrhi.h:800
@ GraphicsPipeline
Definition qrhi.h:803
@ CommandBuffer
Definition qrhi.h:806
@ TextureRenderTarget
Definition qrhi.h:801
@ ShaderResourceBindings
Definition qrhi.h:802
virtual ~QRhiResource()
Destructor.
Definition qrhi.cpp:3355
quint64 m_id
Definition qrhi.h:829
QByteArray name() const
Definition qrhi.cpp:3430
quint64 globalResourceId() const
Definition qrhi.cpp:3466
QRhi * rhi() const
Definition qrhi.cpp:3477
void setName(const QByteArray &name)
Sets a name for the object.
Definition qrhi.cpp:3455
QRhiImplementation * m_rhi
Definition qrhi.h:828
void deleteLater()
When called without a frame being recorded, this function is equivalent to deleting the object.
Definition qrhi.cpp:3419
\inmodule QtGui
Definition qrhi.h:1007
Filter
Specifies the minification, magnification, or mipmap filtering.
Definition qrhi.h:1009
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:4555
AddressMode
Specifies the addressing mode.
Definition qrhi.h:1015
QRhiSampler(QRhiImplementation *rhi, Filter magFilter_, Filter minFilter_, Filter mipmapMode_, AddressMode u_, AddressMode v_, AddressMode w_)
Definition qrhi.cpp:4542
\inmodule QtGui
Definition qrhi.h:138
QRhiScissor()=default
Constructs an empty scissor.
\inmodule QtGui
Definition qrhi.h:431
static QRhiShaderResourceBinding bufferStore(int binding, StageFlags stage, QRhiBuffer *buf)
Definition qrhi.cpp:5782
static QRhiShaderResourceBinding imageLoadStore(int binding, StageFlags stage, QRhiTexture *tex, int level)
Definition qrhi.cpp:5679
bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) noexcept
Definition qrhi.cpp:5991
size_t qHash(const QRhiShaderResourceBinding &b, size_t seed) noexcept
Definition qrhi.cpp:6001
bool isLayoutCompatible(const QRhiShaderResourceBinding &other) const
Definition qrhi.cpp:5266
static QRhiShaderResourceBinding bufferLoad(int binding, StageFlags stage, QRhiBuffer *buf)
Definition qrhi.cpp:5712
static QRhiShaderResourceBinding sampledTexture(int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
Definition qrhi.cpp:5406
static QRhiShaderResourceBinding imageLoad(int binding, StageFlags stage, QRhiTexture *tex, int level)
Definition qrhi.cpp:5609
static QRhiShaderResourceBinding sampler(int binding, StageFlags stage, QRhiSampler *sampler)
Definition qrhi.cpp:5575
static QRhiShaderResourceBinding texture(int binding, StageFlags stage, QRhiTexture *tex)
Definition qrhi.cpp:5499
bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) noexcept
Definition qrhi.cpp:5911
static QRhiShaderResourceBinding textures(int binding, StageFlags stage, int count, QRhiTexture **tex)
Definition qrhi.cpp:5530
static QRhiShaderResourceBinding bufferLoadStore(int binding, StageFlags stage, QRhiBuffer *buf)
Definition qrhi.cpp:5852
static QRhiShaderResourceBinding imageStore(int binding, StageFlags stage, QRhiTexture *tex, int level)
Definition qrhi.cpp:5644
static QRhiShaderResourceBinding sampledTextures(int binding, StageFlags stage, int count, const TextureAndSampler *texSamplers)
Definition qrhi.cpp:5452
static QRhiShaderResourceBinding uniformBufferWithDynamicOffset(int binding, StageFlags stage, QRhiBuffer *buf, quint32 size)
Definition qrhi.cpp:5366
static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf)
Definition qrhi.cpp:5292
static const int LAYOUT_DESC_ENTRIES_PER_BINDING
Definition qrhi.h:538
\inmodule QtGui
Definition qrhi.h:1190
bool isLayoutCompatible(const QRhiShaderResourceBindings *other) const
Definition qrhi.cpp:5114
QVarLengthArray< QRhiShaderResourceBinding, BINDING_PREALLOC > m_bindings
Definition qrhi.h:1222
QRhiShaderResourceBindings(QRhiImplementation *rhi)
Definition qrhi.cpp:5079
const QRhiShaderResourceBinding * cbeginBindings() const
Definition qrhi.h:1201
static const int BINDING_PREALLOC
Definition qrhi.h:1220
QVector< quint32 > m_layoutDesc
Definition qrhi.h:1227
const QRhiShaderResourceBinding * cendBindings() const
Definition qrhi.h:1202
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:5088
\inmodule QtGui
Definition qrhi.h:371
QRhiShaderStage()=default
Constructs a shader stage description for the vertex stage with an empty QShader.
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:4851
QRhiSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain_)
Definition qrhi.cpp:4826
\inmodule QtGui
Definition qrhi.h:1513
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:7083
virtual QRhiRenderTarget * currentFrameRenderTarget()=0
QRhiSwapChain(QRhiImplementation *rhi)
Definition qrhi.cpp:7075
StereoTargetBuffer
Selects the backbuffer to use with a stereoscopic swapchain.
Definition qrhi.h:1531
virtual QRhiSwapChainHdrInfo hdrInfo()
\variable QRhiSwapChainHdrInfo::isHardCodedDefaults
Definition qrhi.cpp:7479
\inmodule QtGui
Definition qrhi.h:727
QRhiTextureRenderTargetDescription()=default
Constructs an empty texture render target description.
\inmodule QtGui
Definition qrhi.h:1161
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:4932
QRhiTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc_, Flags flags_)
Definition qrhi.cpp:4920
QRhiTextureSubresourceUploadDescription()=default
Constructs an empty subresource description.
\inmodule QtGui
Definition qrhi.h:704
QRhiTextureUploadDescription()=default
Constructs an empty texture upload description.
\inmodule QtGui
Definition qrhi.h:681
QRhiTextureUploadEntry()=default
Constructs an empty QRhiTextureUploadEntry targeting layer 0 and level 0.
\inmodule QtGui
Definition qrhi.h:883
QRhiTexture(QRhiImplementation *rhi, Format format_, const QSize &pixelSize_, int depth_, int arraySize_, int sampleCount_, Flags flags_)
\variable QRhiTexture::NativeTexture::object
Definition qrhi.cpp:4294
@ ThreeDimensional
Definition qrhi.h:895
@ OneDimensional
Definition qrhi.h:898
@ TextureArray
Definition qrhi.h:897
QRhiResource::Type resourceType() const override
Definition qrhi.cpp:4305
Format
Specifies the texture format.
Definition qrhi.h:902
@ ASTC_10x8
Definition qrhi.h:947
@ ASTC_12x12
Definition qrhi.h:950
@ ASTC_8x5
Definition qrhi.h:942
@ ASTC_10x5
Definition qrhi.h:945
@ RGBA32F
Definition qrhi.h:914
@ ETC2_RGBA8
Definition qrhi.h:935
@ ASTC_5x5
Definition qrhi.h:939
@ ASTC_4x4
Definition qrhi.h:937
@ ASTC_6x6
Definition qrhi.h:941
@ ASTC_12x10
Definition qrhi.h:949
@ ETC2_RGB8
Definition qrhi.h:933
@ ASTC_5x4
Definition qrhi.h:938
@ RED_OR_ALPHA8
Definition qrhi.h:911
@ ASTC_6x5
Definition qrhi.h:940
@ ASTC_8x8
Definition qrhi.h:944
@ RGBA16F
Definition qrhi.h:913
@ RGB10A2
Definition qrhi.h:918
@ ASTC_10x6
Definition qrhi.h:946
@ ASTC_10x10
Definition qrhi.h:948
@ ETC2_RGB8A1
Definition qrhi.h:934
@ ASTC_8x6
Definition qrhi.h:943
virtual void setNativeLayout(int layout)
With some graphics APIs, such as Vulkan, integrating custom rendering code that uses the graphics API...
Definition qrhi.cpp:4390
virtual bool createFrom(NativeTexture src)
Similar to create(), except that no new native textures are created.
Definition qrhi.cpp:4361
virtual NativeTexture nativeTexture()
Definition qrhi.cpp:4328
\inmodule QtGui
Definition qrhi.h:232
QRhiVertexInputAttribute()=default
Constructs a default vertex input attribute description.
Format
Specifies the type of the element data.
Definition qrhi.h:234
\inmodule QtGui
Definition qrhi.h:179
Classification
Describes the input data classification.
Definition qrhi.h:181
QRhiVertexInputBinding()=default
Constructs a default vertex input binding description.
\inmodule QtGui
Definition qrhi.h:313
\inmodule QtGui
Definition qrhi.h:85
QRhiViewport()=default
Constructs a viewport description with an empty rectangle and a depth range of 0.0f - 1....
\inmodule QtGui
\variable QRhiVulkanInitParams::inst
\inmodule QtGui
Definition qrhi.h:1767
QRhiBuffer * newBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size)
Definition qrhi.cpp:10079
bool isClipDepthZeroToOne() const
Definition qrhi.cpp:9640
FrameOpResult endOffscreenFrame(EndFrameFlags flags={})
Ends, submits, and waits for the offscreen frame.
Definition qrhi.cpp:10475
bool makeThreadLocalNativeContextCurrent()
With OpenGL this makes the OpenGL context current on the current thread.
Definition qrhi.cpp:9729
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags={}) const
Definition qrhi.cpp:9673
int ubufAligned(int v) const
Definition qrhi.cpp:9570
QRhiStats statistics() const
Gathers and returns statistics about the timings and allocations of graphics resources.
Definition qrhi.cpp:10027
int resourceLimit(ResourceLimit limit) const
Definition qrhi.cpp:9692
QRhiTexture * newTextureArray(QRhiTexture::Format format, int arraySize, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
Definition qrhi.cpp:10207
QMatrix4x4 clipSpaceCorrMatrix() const
Definition qrhi.cpp:9662
QThread * thread() const
Definition qrhi.cpp:8428
bool isYUpInFramebuffer() const
Definition qrhi.cpp:9601
bool isYUpInNDC() const
Definition qrhi.cpp:9615
static QRhiSwapChainProxyData updateSwapChainProxyData(Implementation impl, QWindow *window)
Generates and returns a QRhiSwapChainProxyData struct containing opaque data specific to the backend ...
Definition qrhi.cpp:8274
bool isFeatureSupported(QRhi::Feature feature) const
Definition qrhi.cpp:9681
void runCleanup()
Invokes all registered cleanup functions.
Definition qrhi.cpp:8458
QRhiShaderResourceBindings * newShaderResourceBindings()
Definition qrhi.cpp:10060
QList< int > supportedSampleCounts() const
Definition qrhi.cpp:10516
QRhiRenderBuffer * newRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount=1, QRhiRenderBuffer::Flags flags={}, QRhiTexture::Format backingFormatHint=QRhiTexture::UnknownFormat)
Definition qrhi.cpp:10106
Implementation backend() const
Definition qrhi.cpp:8289
Implementation
Describes which graphics API-specific backend gets used by a QRhi instance.
Definition qrhi.h:1769
@ Metal
Definition qrhi.h:1774
@ Vulkan
Definition qrhi.h:1771
@ Null
Definition qrhi.h:1770
@ D3D11
Definition qrhi.h:1773
@ D3D12
Definition qrhi.h:1775
@ OpenGLES2
Definition qrhi.h:1772
static int mipLevelsForSize(const QSize &size)
Definition qrhi.cpp:9579
int currentFrameSlot() const
Definition qrhi.cpp:10409
FrameOpResult beginFrame(QRhiSwapChain *swapChain, BeginFrameFlags flags={})
Starts a new frame targeting the next available buffer of swapChain.
Definition qrhi.cpp:10308
QRhi::FrameOpResult finish()
Waits for any work on the graphics queue (where applicable) to complete, then executes all deferred o...
Definition qrhi.cpp:10499
QRhiComputePipeline * newComputePipeline()
Definition qrhi.cpp:10050
QRhiSwapChain * newSwapChain()
Definition qrhi.cpp:10256
FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags={})
Starts a new offscreen frame.
Definition qrhi.cpp:10456
QRhiSampler * newSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode addressU, QRhiSampler::AddressMode addressV, QRhiSampler::AddressMode addressW=QRhiSampler::Repeat)
Definition qrhi.cpp:10228
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
Definition qrhi.cpp:10245
bool isRecordingFrame() const
Definition qrhi.cpp:10365
const char * backendName() const
Definition qrhi.cpp:8321
QRhiGraphicsPipeline * newGraphicsPipeline()
Definition qrhi.cpp:10037
static bool probe(Implementation impl, QRhiInitParams *params)
Definition qrhi.cpp:8215
void addCleanupCallback(const CleanupCallback &callback)
Registers a callback that is invoked either when the QRhi is destroyed, or when runCleanup() is calle...
Definition qrhi.cpp:8445
static QRhi * create(Implementation impl, QRhiInitParams *params, Flags flags={}, QRhiNativeHandles *importDevice=nullptr)
Definition qrhi.cpp:8129
QRhi()
Definition qrhi.cpp:8062
QByteArray pipelineCacheData()
Definition qrhi.cpp:9842
~QRhi()
Destructor.
Definition qrhi.cpp:8069
FrameOpResult endFrame(QRhiSwapChain *swapChain, EndFrameFlags flags={})
Ends, commits, and presents a frame that was started in the last beginFrame() on swapChain.
Definition qrhi.cpp:10343
ResourceLimit
Describes the resource limit to query.
Definition qrhi.h:1846
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
Definition qrhi.cpp:10133
void setPipelineCacheData(const QByteArray &data)
Loads data into the pipeline cache, when applicable.
Definition qrhi.cpp:9896
QRhiDriverInfo driverInfo() const
Definition qrhi.cpp:8420
Feature
Flag values to indicate what features are supported by the backend currently in use.
Definition qrhi.h:1793
const QRhiNativeHandles * nativeHandles()
Definition qrhi.cpp:9708
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
Definition qrhi.cpp:8854
static QSize sizeForMipLevel(int mipLevel, const QSize &baseLevelSize)
Definition qrhi.cpp:9588
int ubufAlignment() const
Definition qrhi.cpp:10531
FrameOpResult
Describes the result of operations that can have a soft failure.
Definition qrhi.h:1786
@ FrameOpSuccess
Definition qrhi.h:1787
bool isDeviceLost() const
Definition qrhi.cpp:9798
void releaseCachedResources()
Attempts to release resources in the backend's caches.
Definition qrhi.cpp:9746
std::function< void(QRhi *)> CleanupCallback
Definition qrhi.h:1877
@ EnableDebugMarkers
Definition qrhi.h:1779
void clear()
Definition qset.h:61
VariableType
Represents the type of a variable or block member.
\inmodule QtGui
Definition qshader.h:81
Variant
Describes what kind of shader code an entry contains.
Definition qshader.h:103
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:132
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
static QThread * currentThread()
Definition qthread.cpp:966
constexpr size_type size() const noexcept
void resize(qsizetype sz)
void append(const T &t)
\inmodule QtGui
Definition qwindow.h:63
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
Definition qfloat16.h:46
QHash< int, QWidget * > hash
[35multi]
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
else opt state
[0]
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
Definition image.cpp:4
#define Q_BASIC_ATOMIC_INITIALIZER(a)
const int blockSize
static int instanceCount
EGLOutputLayerEXT layer
Flags
@ QtDebugMsg
Definition qlogging.h:30
#define qWarning
Definition qlogging.h:162
#define Q_LOGGING_CATEGORY(name,...)
int qFloor(T v)
Definition qmath.h:42
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLint location
GLboolean GLboolean GLboolean b
GLbitfield stages
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum GLuint GLint level
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLuint GLuint end
GLuint sampler
GLenum GLenum GLsizei count
GLfloat GLfloat f
GLenum src
const void GLsizei GLsizei stride
GLint GLsizei width
GLenum type
GLenum GLenum dst
GLenum access
GLenum GLuint GLenum GLsizei const GLchar * buf
GLbitfield flags
GLenum GLuint texture
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLuint name
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLuint counter
void ** params
GLuint res
const GLubyte * c
GLuint entry
GLuint shader
Definition qopenglext.h:665
GLint limit
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
GLsizeiptr const void GLenum usage
Definition qopenglext.h:543
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static const char * resourceTypeStr(const QRhiResource *res)
Definition qrhi.cpp:7665
static QRhiPassResourceTracker::BufferStage earlierStage(QRhiPassResourceTracker::BufferStage a, QRhiPassResourceTracker::BufferStage b)
Definition qrhi.cpp:10554
QDebug operator<<(QDebug dbg, const QRhiDepthStencilClearValue &v)
Definition qrhi.cpp:1182
static bool isImageLoadStore(QRhiPassResourceTracker::TextureAccess access)
Definition qrhi.cpp:10592
static const char * deviceTypeStr(QRhiDriverInfo::DeviceType type)
\variable QRhiDriverInfo::deviceName
Definition qrhi.cpp:8385
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
static constexpr size_t poolSize
Definition qstdweb.cpp:108
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
#define Q_UNUSED(x)
@ desc
unsigned int quint32
Definition qtypes.h:45
size_t quintptr
Definition qtypes.h:72
int qint32
Definition qtypes.h:44
unsigned long long quint64
Definition qtypes.h:56
unsigned int uint
Definition qtypes.h:29
unsigned char quint8
Definition qtypes.h:41
QList< int > list
[14]
QFileInfo info(fileName)
[8]
QVBoxLayout * layout
QMimeDatabase db
[0]
QSharedPointer< T > other(t)
[5]
view viewport() -> scroll(dx, dy, deviceRect)
aWidget window() -> setWindowTitle("New Window Title")
[2]
view create()
\inmodule QtGui
Definition qrhi.h:850
\inmodule QtGui
Definition qrhi.h:1722
DeviceType
Specifies the graphics device's type, when the information is available.
Definition qrhi.h:1723
@ IntegratedDevice
Definition qrhi.h:1725
\inmodule QtGui
Definition qrhi.h:1763
\variable QRhiReadbackResult::completed
Definition qrhi.h:788
\inmodule QtGui
\inmodule QtGui
Definition qrhi.h:1686
static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:421
static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:410
static BufferOp read(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result)
Definition qrhi_p.h:430
static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:390
static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:401
static TextureOp copy(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc)
Definition qrhi_p.h:478
static TextureOp upload(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
Definition qrhi_p.h:462
static TextureOp genMips(QRhiTexture *tex)
Definition qrhi_p.h:497
static TextureOp read(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
Definition qrhi_p.h:488
TextureAndSampler texSamplers[MAX_TEX_SAMPLER_ARRAY_SIZE]
Definition qrhi.h:501
StorageBufferData sbuf
Definition qrhi.h:516
TextureAndOrSamplerData stex
Definition qrhi.h:514
QRhiShaderResourceBinding::StageFlags stage
Definition qrhi.h:490
StorageImageData simage
Definition qrhi.h:515
UniformBufferData ubuf
Definition qrhi.h:513
static const int MAX_TEX_SAMPLER_ARRAY_SIZE
Definition qrhi.h:498
union QRhiShaderResourceBinding::Data::@328 u
QRhiShaderResourceBinding::Type type
Definition qrhi.h:491
\inmodule QtGui
Definition qrhi.h:1745
\inmodule QtGui
Definition qrhi.h:1482
\inmodule QtGui
Definition qrhi.h:1508
\inmodule QtGui
Definition qrhi.h:953
Definition moc.h:24