6#include <QLoggingCategory>
19#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
1181#ifndef QT_NO_DEBUG_STREAM
1185 dbg.nospace() <<
"QRhiDepthStencilClearValue(depth-clear=" <<
v.depthClearValue()
1186 <<
" stencil-clear=" <<
v.stencilClearValue()
1240 : m_rect { {
x,
y,
w,
h } },
1241 m_minDepth(minDepth),
1242 m_maxDepth(maxDepth)
1301#ifndef QT_NO_DEBUG_STREAM
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()
1357 : m_rect { {
x,
y,
w,
h } }
1394#ifndef QT_NO_DEBUG_STREAM
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]
1491 m_classification(cls),
1492 m_instanceStepRate(stepRate)
1546#ifndef QT_NO_DEBUG_STREAM
1550 dbg.nospace() <<
"QRhiVertexInputBinding(stride=" <<
b.stride()
1551 <<
" cls=" <<
b.classification()
1552 <<
" step-rate=" <<
b.instanceStepRate()
1685 : m_binding(binding),
1689 m_matrixSlice(matrixSlice)
1774#ifndef QT_NO_DEBUG_STREAM
1778 dbg.nospace() <<
"QRhiVertexInputAttribute(binding=" <<
a.binding()
1779 <<
" location=" <<
a.location()
1780 <<
" format=" <<
a.format()
1781 <<
" offset=" <<
a.offset()
1835 return 4 *
sizeof(float);
1837 return 4 *
sizeof(float);
1839 return 2 *
sizeof(float);
1841 return sizeof(float);
1844 return 4 *
sizeof(
quint8);
1846 return 2 *
sizeof(
quint8);
1860 return 4 *
sizeof(
qint32);
1862 return 4 *
sizeof(
qint32);
1864 return 2 *
sizeof(
qint32);
1878 Q_UNREACHABLE_RETURN(1);
1999#ifndef QT_NO_DEBUG_STREAM
2003 dbg.nospace() <<
"QRhiVertexInputLayout(bindings=" <<
v.m_bindings
2004 <<
" attributes=" <<
v.m_attributes
2146#ifndef QT_NO_DEBUG_STREAM
2150 dbg.nospace() <<
"QRhiShaderStage(type=" <<
s.type()
2151 <<
" shader=" <<
s.shader()
2152 <<
" variant=" <<
s.shaderVariant()
2221 : m_renderBuffer(renderBuffer)
2504 m_colorAttachments.
append(colorAttachment);
2514 : m_depthStencilBuffer(depthStencilBuffer)
2516 m_colorAttachments.
append(colorAttachment);
2529 : m_depthTexture(depthTexture)
2531 m_colorAttachments.
append(colorAttachment);
3705 m_type(type_), m_usage(usage_), m_size(size_)
3934 int sampleCount_,
Flags flags_,
3937 m_type(type_), m_pixelSize(pixelSize_), m_sampleCount(sampleCount_), m_flags(flags_),
3938 m_backingFormatHint(backingFormatHint_)
4295 int arraySize_,
int sampleCount_,
Flags flags_)
4297 m_format(format_), m_pixelSize(pixelSize_), m_depth(depth_),
4298 m_arraySize(arraySize_), m_sampleCount(sampleCount_), m_flags(flags_)
4546 m_magFilter(magFilter_), m_minFilter(minFilter_), m_mipmapMode(mipmapMode_),
4547 m_addressU(u_), m_addressV(v_), m_addressW(w_),
4828 m_swapchain(swapchain_)
5154 auto layoutDescAppender = std::back_inserter(srb->
m_layoutDesc);
5158 ^
uint(
d->arraySize());
5159 layoutDescAppender =
d->serialize(layoutDescAppender);
5296 b.d.binding = binding;
5299 b.d.u.ubuf.buf =
buf;
5300 b.d.u.ubuf.offset = 0;
5301 b.d.u.ubuf.maybeSize = 0;
5302 b.d.u.ubuf.hasDynamicOffset =
false;
5334 b.d.binding = binding;
5337 b.d.u.ubuf.buf =
buf;
5339 b.d.u.ubuf.maybeSize =
size;
5340 b.d.u.ubuf.hasDynamicOffset =
false;
5371 b.d.binding = binding;
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;
5410 b.d.binding = binding;
5413 b.d.u.stex.count = 1;
5414 b.d.u.stex.texSamplers[0] = { tex,
sampler };
5457 b.d.binding = binding;
5460 b.d.u.stex.count =
count;
5463 b.d.u.stex.texSamplers[
i] = texSamplers[
i];
5465 b.d.u.stex.texSamplers[
i] = {
nullptr,
nullptr };
5502 b.d.binding = binding;
5505 b.d.u.stex.count = 1;
5506 b.d.u.stex.texSamplers[0] = { tex,
nullptr };
5534 b.d.binding = binding;
5537 b.d.u.stex.count =
count;
5540 b.d.u.stex.texSamplers[
i] = { tex[
i],
nullptr };
5542 b.d.u.stex.texSamplers[
i] = {
nullptr,
nullptr };
5578 b.d.binding = binding;
5581 b.d.u.stex.count = 1;
5582 b.d.u.stex.texSamplers[0] = {
nullptr,
sampler };
5613 b.d.binding = binding;
5616 b.d.u.simage.tex = tex;
5617 b.d.u.simage.level =
level;
5648 b.d.binding = binding;
5651 b.d.u.simage.tex = tex;
5652 b.d.u.simage.level =
level;
5683 b.d.binding = binding;
5686 b.d.u.simage.tex = tex;
5687 b.d.u.simage.level =
level;
5716 b.d.binding = binding;
5719 b.d.u.sbuf.buf =
buf;
5720 b.d.u.sbuf.offset = 0;
5721 b.d.u.sbuf.maybeSize = 0;
5752 b.d.binding = binding;
5755 b.d.u.sbuf.buf =
buf;
5757 b.d.u.sbuf.maybeSize =
size;
5786 b.d.binding = binding;
5789 b.d.u.sbuf.buf =
buf;
5790 b.d.u.sbuf.offset = 0;
5791 b.d.u.sbuf.maybeSize = 0;
5822 b.d.binding = binding;
5825 b.d.u.sbuf.buf =
buf;
5827 b.d.u.sbuf.maybeSize =
size;
5856 b.d.binding = binding;
5859 b.d.u.sbuf.buf =
buf;
5860 b.d.u.sbuf.offset = 0;
5861 b.d.u.sbuf.maybeSize = 0;
5892 b.d.binding = binding;
5895 b.d.u.sbuf.buf =
buf;
5897 b.d.u.sbuf.maybeSize =
size;
5979 Q_UNREACHABLE_RETURN(
false);
6036#ifndef QT_NO_DEBUG_STREAM
6041 dbg.nospace() <<
"QRhiShaderResourceBinding("
6042 <<
"binding=" <<
d->binding
6043 <<
" stage=" <<
d->stage
6044 <<
" type=" <<
d->type;
6047 dbg.nospace() <<
" UniformBuffer("
6048 <<
"buffer=" <<
d->u.ubuf.buf
6049 <<
" offset=" <<
d->u.ubuf.offset
6050 <<
" maybeSize=" <<
d->u.ubuf.maybeSize
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;
6060 dbg.nospace() <<
')';
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() <<
')';
6070 dbg.nospace() <<
" Sampler("
6071 <<
" sampler=" <<
d->u.stex.texSamplers[0].sampler
6075 dbg.nospace() <<
" ImageLoad("
6076 <<
"texture=" <<
d->u.simage.tex
6077 <<
" level=" <<
d->u.simage.level
6081 dbg.nospace() <<
" ImageStore("
6082 <<
"texture=" <<
d->u.simage.tex
6083 <<
" level=" <<
d->u.simage.level
6087 dbg.nospace() <<
" ImageLoadStore("
6088 <<
"texture=" <<
d->u.simage.tex
6089 <<
" level=" <<
d->u.simage.level
6093 dbg.nospace() <<
" BufferLoad("
6094 <<
"buffer=" <<
d->u.sbuf.buf
6095 <<
" offset=" <<
d->u.sbuf.offset
6096 <<
" maybeSize=" <<
d->u.sbuf.maybeSize
6100 dbg.nospace() <<
" BufferStore("
6101 <<
"buffer=" <<
d->u.sbuf.buf
6102 <<
" offset=" <<
d->u.sbuf.offset
6103 <<
" maybeSize=" <<
d->u.sbuf.maybeSize
6107 dbg.nospace() <<
" BufferLoadStore("
6108 <<
"buffer=" <<
d->u.sbuf.buf
6109 <<
" offset=" <<
d->u.sbuf.offset
6110 <<
" maybeSize=" <<
d->u.sbuf.maybeSize
6114 dbg.nospace() <<
" UNKNOWN()";
6117 dbg.nospace() <<
')';
6122#ifndef QT_NO_DEBUG_STREAM
6126 dbg.nospace() <<
"QRhiShaderResourceBindings("
7482 info.isHardCodedDefaults =
true;
7484 info.limits.luminanceInNits.minLuminance = 0.0f;
7485 info.limits.luminanceInNits.maxLuminance = 1000.0f;
7489#ifndef QT_NO_DEBUG_STREAM
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;
7500 dbg.nospace() <<
" maxColorComponentValue=" <<
info.limits.colorComponentValue.maxColorComponentValue;
7501 dbg.nospace() <<
" maxPotentialColorComponentValue=" <<
info.limits.colorComponentValue.maxPotentialColorComponentValue;
7504 dbg.nospace() <<
')';
7667 switch (
res->resourceType()) {
7675 return "RenderBuffer";
7677 return "RenderPassDescriptor";
7679 return "SwapChainRenderTarget";
7681 return "TextureRenderTarget";
7683 return "ShaderResourceBindings";
7685 return "GraphicsPipeline";
7689 return "ComputePipeline";
7691 return "CommandBuffer";
7694 Q_UNREACHABLE_RETURN(
"");
7706 static bool leakCheck =
true;
7713 qWarning(
"QRhi %p going down with %d unreleased resources that own native graphics objects. This is not nice.",
7714 q,
int(resources.
size()));
7718 const bool ownsNativeResources =
it.value();
7719 if (leakCheck && ownsNativeResources)
7726 res->m_rhi =
nullptr;
7740 QSize *blockDim)
const
7853 *byteSize = wblocks * hblocks *
blockSize;
7855 *blockDim =
QSize(xdim, ydim);
7926 *bytesPerPixel = bpc;
7943 qWarning(
"Cannot build a graphics pipeline without any stages");
7947 bool hasVertexStage =
false;
7949 if (!
it->shader().isValid()) {
7950 qWarning(
"Empty shader passed to graphics pipeline");
7954 hasVertexStage =
true;
7956 if (!hasVertexStage) {
7957 qWarning(
"Cannot build a graphics pipeline without a vertex stage");
7962 qWarning(
"Cannot build a graphics pipeline without a QRhiRenderPassDescriptor");
7967 qWarning(
"Cannot build a graphics pipeline without QRhiShaderResourceBindings");
7977 bool bindingsOk =
true;
7978 const int CHECKED_BINDINGS_COUNT = 64;
7979 bool bindingSeen[CHECKED_BINDINGS_COUNT] = {};
7982 if (binding >= CHECKED_BINDINGS_COUNT)
7985 qWarning(
"Invalid binding number %d", binding);
7991 if (!bindingSeen[binding]) {
7992 bindingSeen[binding] =
true;
7994 qWarning(
"Uniform buffer duplicates an existing binding number %d", binding);
7999 if (!bindingSeen[binding]) {
8000 bindingSeen[binding] =
true;
8002 qWarning(
"Combined image sampler duplicates an existing binding number %d", binding);
8007 if (!bindingSeen[binding]) {
8008 bindingSeen[binding] =
true;
8010 qWarning(
"Texture duplicates an existing binding number %d", binding);
8015 if (!bindingSeen[binding]) {
8016 bindingSeen[binding] =
true;
8018 qWarning(
"Sampler duplicates an existing binding number %d", binding);
8025 if (!bindingSeen[binding]) {
8026 bindingSeen[binding] =
true;
8028 qWarning(
"Image duplicates an existing binding number %d", binding);
8035 if (!bindingSeen[binding]) {
8036 bindingSeen[binding] =
true;
8038 qWarning(
"Buffer duplicates an existing binding number %d", binding);
8075 d->pendingDeleteResources.
clear();
8131 std::unique_ptr<QRhi>
r(
new QRhi);
8138#if QT_CONFIG(vulkan)
8144 qWarning(
"This build of Qt has no Vulkan support");
8153 qWarning(
"This build of Qt has no OpenGL support");
8162 qWarning(
"This platform has no Direct3D 11 support");
8166#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
8171 qWarning(
"This platform has no Metal support");
8176#ifdef QRHI_D3D12_AVAILABLE
8177 r->d =
new QRhiD3D12(
static_cast<QRhiD3D12InitParams *
>(
params),
8178 static_cast<QRhiD3D12NativeHandles *
>(importDevice));
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.");
8188 qWarning(
"This platform has no Direct3D 12 support");
8194 r->d->prepareForCreate(
r.get(), impl,
flags);
8224 if (impl ==
Metal) {
8225#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
8230 ok = rhi !=
nullptr;
8276#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
8315 Q_UNREACHABLE_RETURN(
"Unknown");
8384#ifndef QT_NO_DEBUG_STREAM
8391 return "Integrated";
8402 Q_UNREACHABLE_RETURN(
nullptr);
8407 dbg.nospace() <<
"QRhiDriverInfo(deviceName=" <<
info.deviceName
8409 <<
" vendorId=0x" <<
info.vendorId
8430 return d->implThread;
8463 d->cleanupCallbacks.
clear();
8599 const int opListSize = d->
bufferOps.size();
8600 if (idx < opListSize)
8619 if (idx < d->bufferOps.size())
8632 if (
buf->size() > 0) {
8634 if (idx < d->bufferOps.size())
8668 if (idx < d->bufferOps.size())
8683 if (
desc.cbeginEntries() !=
desc.cendEntries()) {
8685 if (idx < d->textureOps.size())
8721 if (idx < d->textureOps.size())
8791 if (idx < d->textureOps.size())
8815 if (idx < d->textureOps.size())
8874 if (!(d->resUpdPoolMap &
mask)) {
8875 d->resUpdPoolMap |=
mask;
8878 if (!preferMemoryOverPerformance)
8879 d->lastResUpdIdx =
i;
8885 for (
int i = d->lastResUpdIdx + 1;
i <
poolSize; ++
i) {
8889 for (
int i = 0;
i <= d->lastResUpdIdx; ++
i) {
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)
8903 u = nextFreeBatch();
8905 qWarning(
"Resource update batch pool exhausted (max is 64)");
8908 if (preferMemoryOverPerformance && u)
8988 if (resourceUpdates)
9046 const QColor &colorClearValue,
9049 BeginPassFlags
flags)
9051 m_rhi->
beginPass(
this, rt, colorClearValue, depthStencilClearValue, resourceUpdates,
flags);
9141 int dynamicOffsetCount,
9206 m_rhi->
setVertexInput(
this, startBinding, bindingCount, bindings, indexBuf, indexOffset, indexFormat);
9573 return (
v + byteAlign - 1) & ~(byteAlign - 1);
9590 const int w =
qMax(1, baseLevelSize.
width() >> mipLevel);
9591 const int h =
qMax(1, baseLevelSize.
height() >> mipLevel);
9751 if (u->d->poolIndex < 0)
9752 u->d->trimOpLists();
9967#ifndef QT_NO_DEBUG_STREAM
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
10080 QRhiBuffer::UsageFlags
usage,
10107 const QSize &pixelSize,
10109 QRhiRenderBuffer::Flags
flags,
10134 const QSize &pixelSize,
10136 QRhiTexture::Flags
flags)
10138 if (pixelSize.
height() == 0)
10169 QRhiTexture::Flags
flags)
10209 const QSize &pixelSize,
10211 QRhiTexture::Flags
flags)
10215 if (pixelSize.
height() == 0)
10235 return d->
createSampler(magFilter, minFilter, mipmapMode, addressU, addressV, addressW);
10246 QRhiTextureRenderTarget::Flags
flags)
10311 qWarning(
"Attempted to call beginFrame() within a still active frame; ignored");
10346 qWarning(
"Attempted to call endFrame() without an active frame; ignored");
10353 d->pendingDeleteResources.
clear();
10459 qWarning(
"Attempted to call beginOffscreenFrame() within a still active frame; ignored");
10478 qWarning(
"Attempted to call endOffscreenFrame() without an active frame; ignored");
10483 d->pendingDeleteResources.
clear();
10540 return counter.fetchAndAddRelaxed(1) + 1;
10545 return m_buffers.isEmpty() && m_textures.isEmpty();
10551 m_textures.clear();
10563 auto it = m_buffers.find(
buf);
10564 if (
it != m_buffers.end()) {
10567 qWarning(
"Buffer %p (%s) used with different accesses within the same pass, this is not allowed.",
10571 if (
it->stage != *stage) {
10573 *stage =
it->stage;
10582 b.stateAtPassBegin =
state;
10583 m_buffers.insert(
buf,
b);
10602 auto it = m_textures.find(tex);
10603 if (
it != m_textures.end()) {
10614 qWarning(
"Texture %p (%s) used with different accesses within the same pass, this is not allowed.",
10615 tex,
name.constData());
10618 if (
it->stage != *stage) {
10620 *stage =
it->stage;
10628 t.stateAtPassBegin =
state;
10629 m_textures.insert(tex,
t);
The QColor class provides colors based on RGB, HSV or CMYK values.
const_iterator cbegin() const noexcept
qsizetype size() const noexcept
Returns the number of items in the hash.
const_iterator cend() const noexcept
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
virtual char * beginFullDynamicBufferUpdateForCurrentFrame()
QRhiResource::Type resourceType() const override
Type
Specifies storage type of buffer resource.
QRhiBuffer(QRhiImplementation *rhi, Type type_, UsageFlags usage_, quint32 size_)
\variable QRhiBuffer::NativeBuffer::objects
virtual void endFullDynamicBufferUpdateForCurrentFrame()
To be called when the entire contents of the buffer data has been updated in the memory block returne...
virtual NativeBuffer nativeBuffer()
QRhiColorAttachment()=default
Constructs an empty color attachment description.
void endPass(QRhiResourceUpdateBatch *resourceUpdates=nullptr)
Records ending the current render pass.
void debugMarkMsg(const QByteArray &msg)
Inserts a debug message msg into the command stream.
void draw(quint32 vertexCount, quint32 instanceCount=1, quint32 firstVertex=0, quint32 firstInstance=0)
Records a non-indexed draw.
void setBlendConstants(const QColor &c)
Records setting the active blend constants to c.
void endExternal()
To be called once the externally added commands are recorded to the command buffer or context.
void setScissor(const QRhiScissor &scissor)
Records setting the active scissor rectangle specified in scissor.
void beginComputePass(QRhiResourceUpdateBatch *resourceUpdates=nullptr, BeginPassFlags flags={})
Records starting a new compute pass.
void drawIndexed(quint32 indexCount, quint32 instanceCount=1, quint32 firstIndex=0, qint32 vertexOffset=0, quint32 firstInstance=0)
Records an indexed draw.
void setStencilRef(quint32 refValue)
Records setting the active stencil reference value to refValue.
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
const QRhiNativeHandles * nativeHandles()
QRhiCommandBuffer(QRhiImplementation *rhi)
void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates)
Sometimes committing resource updates is necessary or just more convenient without starting a render ...
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...
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.
double lastCompletedGpuTime()
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...
void beginExternal()
To be called when the application before the application is about to enqueue commands to the current ...
void debugMarkBegin(const QByteArray &name)
Records a named debug group on the command buffer with the specified name.
void setViewport(const QRhiViewport &viewport)
Records setting the active viewport rectangle specified in viewport.
QRhiResource::Type resourceType() const override
void debugMarkEnd()
Records the end of a debug group.
void endComputePass(QRhiResourceUpdateBatch *resourceUpdates=nullptr)
Records ending the current compute pass.
QPair< int, quint32 > DynamicOffset
Synonym for QPair<int, quint32>.
IndexFormat
Specifies the index data type.
void setComputePipeline(QRhiComputePipeline *ps)
Records setting a new compute pipeline ps.
void setVertexInput(int startBinding, int bindingCount, const VertexInput *bindings, QRhiBuffer *indexBuf=nullptr, quint32 indexOffset=0, IndexFormat indexFormat=IndexUInt16)
Records vertex input bindings.
void setGraphicsPipeline(QRhiGraphicsPipeline *ps)
Records setting a new graphics pipeline ps.
QRhiResource::Type resourceType() const override
QRhiComputePipeline(QRhiImplementation *rhi)
\variable QRhiD3D11InitParams::enableDebugLayer
\variable QRhiGles2InitParams::format
const QRhiShaderStage * cendShaderStages() const
QRhiShaderResourceBindings * shaderResourceBindings() const
QRhiRenderPassDescriptor * renderPassDescriptor() const
QRhiGraphicsPipeline(QRhiImplementation *rhi)
\variable QRhiGraphicsPipeline::StencilOpState::failOp
QRhiResource::Type resourceType() const override
const QRhiShaderStage * cbeginShaderStages() const
virtual bool isClipDepthZeroToOne() const =0
bool isStencilSupportingFormat(QRhiTexture::Format format) const
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()
virtual bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const =0
virtual QRhiDriverInfo driverInfo() const =0
bool isCompressedFormat(QRhiTexture::Format format) const
static const QRhiShaderResourceBinding::Data * shaderResourceBindingData(const QRhiShaderResourceBinding &binding)
void updateLayoutDesc(QRhiShaderResourceBindings *srb)
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
virtual QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags)=0
virtual void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
bool sanityCheckShaderResourceBindings(QRhiShaderResourceBindings *srb)
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)
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
virtual void dispatch(QRhiCommandBuffer *cb, int x, int y, int z)=0
virtual bool makeThreadLocalNativeContextCurrent()=0
void addDeleteLater(QRhiResource *res)
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)
virtual void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg)=0
QRhiVertexInputAttribute::Format shaderDescVariableFormatToVertexInputFormat(QShaderDescription::VariableType type) const
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)
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
virtual void draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance)=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
static TextureStage toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages)
static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages)
void registerBuffer(QRhiBuffer *buf, int slot, BufferAccess *access, BufferStage *stage, const UsageState &state)
void registerTexture(QRhiTexture *tex, TextureAccess *access, TextureStage *stage, const UsageState &state)
QRhiReadbackDescription()=default
Constructs an empty texture readback description.
QRhiRenderBuffer(QRhiImplementation *rhi, Type type_, const QSize &pixelSize_, int sampleCount_, Flags flags_, QRhiTexture::Format backingFormatHint_)
QRhiResource::Type resourceType() const override
Type
Specifies the type of the renderbuffer.
virtual bool createFrom(NativeRenderBuffer src)
Similar to create() except that no new native renderbuffer objects are created.
QRhiResource::Type resourceType() const override
virtual const QRhiNativeHandles * nativeHandles()
QRhiRenderPassDescriptor(QRhiImplementation *rhi)
QRhiRenderTarget(QRhiImplementation *rhi)
QVarLengthArray< BufferOp, BUFFER_OPS_STATIC_ALLOC > bufferOps
bool hasOptimalCapacity() const
QVarLengthArray< TextureOp, TEXTURE_OPS_STATIC_ALLOC > textureOps
static const int BUFFER_OPS_STATIC_ALLOC
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
void merge(QRhiResourceUpdateBatchPrivate *other)
static const int TEXTURE_OPS_STATIC_ALLOC
~QRhiResourceUpdateBatch()
void merge(QRhiResourceUpdateBatch *other)
Copies all queued operations from the other batch into this one.
void generateMips(QRhiTexture *tex)
Enqueues a mipmap generation operation for the specified texture tex.
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.
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...
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...
void readBackTexture(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
Enqueues a texture-to-host copy operation as described by rb.
void readBackBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result)
Enqueues reading back a region of the QRhiBuffer buf.
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.
bool hasOptimalCapacity() const
QRhiResource(QRhiImplementation *rhi)
Type
Specifies type of the resource.
virtual ~QRhiResource()
Destructor.
quint64 globalResourceId() const
void setName(const QByteArray &name)
Sets a name for the object.
QRhiImplementation * m_rhi
void deleteLater()
When called without a frame being recorded, this function is equivalent to deleting the object.
Filter
Specifies the minification, magnification, or mipmap filtering.
QRhiResource::Type resourceType() const override
AddressMode
Specifies the addressing mode.
QRhiSampler(QRhiImplementation *rhi, Filter magFilter_, Filter minFilter_, Filter mipmapMode_, AddressMode u_, AddressMode v_, AddressMode w_)
QRhiScissor()=default
Constructs an empty scissor.
static QRhiShaderResourceBinding bufferStore(int binding, StageFlags stage, QRhiBuffer *buf)
static QRhiShaderResourceBinding imageLoadStore(int binding, StageFlags stage, QRhiTexture *tex, int level)
bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) noexcept
size_t qHash(const QRhiShaderResourceBinding &b, size_t seed) noexcept
bool isLayoutCompatible(const QRhiShaderResourceBinding &other) const
static QRhiShaderResourceBinding bufferLoad(int binding, StageFlags stage, QRhiBuffer *buf)
static QRhiShaderResourceBinding sampledTexture(int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
static QRhiShaderResourceBinding imageLoad(int binding, StageFlags stage, QRhiTexture *tex, int level)
static QRhiShaderResourceBinding sampler(int binding, StageFlags stage, QRhiSampler *sampler)
static QRhiShaderResourceBinding texture(int binding, StageFlags stage, QRhiTexture *tex)
bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) noexcept
static QRhiShaderResourceBinding textures(int binding, StageFlags stage, int count, QRhiTexture **tex)
static QRhiShaderResourceBinding bufferLoadStore(int binding, StageFlags stage, QRhiBuffer *buf)
static QRhiShaderResourceBinding imageStore(int binding, StageFlags stage, QRhiTexture *tex, int level)
@ TessellationEvaluationStage
@ TessellationControlStage
static QRhiShaderResourceBinding sampledTextures(int binding, StageFlags stage, int count, const TextureAndSampler *texSamplers)
static QRhiShaderResourceBinding uniformBufferWithDynamicOffset(int binding, StageFlags stage, QRhiBuffer *buf, quint32 size)
static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf)
static const int LAYOUT_DESC_ENTRIES_PER_BINDING
bool isLayoutCompatible(const QRhiShaderResourceBindings *other) const
QVarLengthArray< QRhiShaderResourceBinding, BINDING_PREALLOC > m_bindings
QRhiShaderResourceBindings(QRhiImplementation *rhi)
const QRhiShaderResourceBinding * cbeginBindings() const
static const int BINDING_PREALLOC
QVector< quint32 > m_layoutDesc
const QRhiShaderResourceBinding * cendBindings() const
QRhiResource::Type resourceType() const override
QRhiShaderStage()=default
Constructs a shader stage description for the vertex stage with an empty QShader.
QRhiResource::Type resourceType() const override
QRhiSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain_)
QRhiResource::Type resourceType() const override
virtual QRhiRenderTarget * currentFrameRenderTarget()=0
QRhiSwapChain(QRhiImplementation *rhi)
StereoTargetBuffer
Selects the backbuffer to use with a stereoscopic swapchain.
virtual QRhiSwapChainHdrInfo hdrInfo()
\variable QRhiSwapChainHdrInfo::isHardCodedDefaults
QRhiTextureRenderTargetDescription()=default
Constructs an empty texture render target description.
QRhiResource::Type resourceType() const override
QRhiTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc_, Flags flags_)
QRhiTextureSubresourceUploadDescription()=default
Constructs an empty subresource description.
QRhiTextureUploadDescription()=default
Constructs an empty texture upload description.
QRhiTextureUploadEntry()=default
Constructs an empty QRhiTextureUploadEntry targeting layer 0 and level 0.
QRhiTexture(QRhiImplementation *rhi, Format format_, const QSize &pixelSize_, int depth_, int arraySize_, int sampleCount_, Flags flags_)
\variable QRhiTexture::NativeTexture::object
QRhiResource::Type resourceType() const override
Format
Specifies the texture format.
virtual void setNativeLayout(int layout)
With some graphics APIs, such as Vulkan, integrating custom rendering code that uses the graphics API...
virtual bool createFrom(NativeTexture src)
Similar to create(), except that no new native textures are created.
virtual NativeTexture nativeTexture()
QRhiViewport()=default
Constructs a viewport description with an empty rectangle and a depth range of 0.0f - 1....
\variable QRhiVulkanInitParams::inst
QRhiBuffer * newBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size)
bool isClipDepthZeroToOne() const
FrameOpResult endOffscreenFrame(EndFrameFlags flags={})
Ends, submits, and waits for the offscreen frame.
bool makeThreadLocalNativeContextCurrent()
With OpenGL this makes the OpenGL context current on the current thread.
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags={}) const
int ubufAligned(int v) const
QRhiStats statistics() const
Gathers and returns statistics about the timings and allocations of graphics resources.
int resourceLimit(ResourceLimit limit) const
QRhiTexture * newTextureArray(QRhiTexture::Format format, int arraySize, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
QMatrix4x4 clipSpaceCorrMatrix() const
bool isYUpInFramebuffer() const
static QRhiSwapChainProxyData updateSwapChainProxyData(Implementation impl, QWindow *window)
Generates and returns a QRhiSwapChainProxyData struct containing opaque data specific to the backend ...
bool isFeatureSupported(QRhi::Feature feature) const
void runCleanup()
Invokes all registered cleanup functions.
QRhiShaderResourceBindings * newShaderResourceBindings()
QList< int > supportedSampleCounts() const
QRhiRenderBuffer * newRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount=1, QRhiRenderBuffer::Flags flags={}, QRhiTexture::Format backingFormatHint=QRhiTexture::UnknownFormat)
Implementation backend() const
Implementation
Describes which graphics API-specific backend gets used by a QRhi instance.
static int mipLevelsForSize(const QSize &size)
int currentFrameSlot() const
FrameOpResult beginFrame(QRhiSwapChain *swapChain, BeginFrameFlags flags={})
Starts a new frame targeting the next available buffer of swapChain.
QRhi::FrameOpResult finish()
Waits for any work on the graphics queue (where applicable) to complete, then executes all deferred o...
QRhiComputePipeline * newComputePipeline()
QRhiSwapChain * newSwapChain()
FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags={})
Starts a new offscreen frame.
QRhiSampler * newSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode addressU, QRhiSampler::AddressMode addressV, QRhiSampler::AddressMode addressW=QRhiSampler::Repeat)
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
bool isRecordingFrame() const
const char * backendName() const
QRhiGraphicsPipeline * newGraphicsPipeline()
static bool probe(Implementation impl, QRhiInitParams *params)
void addCleanupCallback(const CleanupCallback &callback)
Registers a callback that is invoked either when the QRhi is destroyed, or when runCleanup() is calle...
static QRhi * create(Implementation impl, QRhiInitParams *params, Flags flags={}, QRhiNativeHandles *importDevice=nullptr)
QByteArray pipelineCacheData()
FrameOpResult endFrame(QRhiSwapChain *swapChain, EndFrameFlags flags={})
Ends, commits, and presents a frame that was started in the last beginFrame() on swapChain.
ResourceLimit
Describes the resource limit to query.
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
void setPipelineCacheData(const QByteArray &data)
Loads data into the pipeline cache, when applicable.
QRhiDriverInfo driverInfo() const
Feature
Flag values to indicate what features are supported by the backend currently in use.
const QRhiNativeHandles * nativeHandles()
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
static QSize sizeForMipLevel(int mipLevel, const QSize &baseLevelSize)
int ubufAlignment() const
FrameOpResult
Describes the result of operations that can have a soft failure.
bool isDeviceLost() const
void releaseCachedResources()
Attempts to release resources in the backend's caches.
std::function< void(QRhi *)> CleanupCallback
VariableType
Represents the type of a variable or block member.
Variant
Describes what kind of shader code an entry contains.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
static QThread * currentThread()
constexpr size_type size() const noexcept
void resize(qsizetype sz)
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
QHash< int, QWidget * > hash
[35multi]
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
#define Q_LOGGING_CATEGORY(name,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
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]
GLenum GLenum GLsizei count
const void GLsizei GLsizei stride
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
GLsizeiptr const void GLenum usage
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
static const char * resourceTypeStr(const QRhiResource *res)
static QRhiPassResourceTracker::BufferStage earlierStage(QRhiPassResourceTracker::BufferStage a, QRhiPassResourceTracker::BufferStage b)
QDebug operator<<(QDebug dbg, const QRhiDepthStencilClearValue &v)
static bool isImageLoadStore(QRhiPassResourceTracker::TextureAccess access)
static const char * deviceTypeStr(QRhiDriverInfo::DeviceType type)
\variable QRhiDriverInfo::deviceName
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
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
unsigned long long quint64
QFileInfo info(fileName)
[8]
view viewport() -> scroll(dx, dy, deviceRect)
DeviceType
Specifies the graphics device's type, when the information is available.
\variable QRhiReadbackResult::completed
static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
static BufferOp read(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result)
static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
static TextureOp copy(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc)
static TextureOp upload(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
static TextureOp genMips(QRhiTexture *tex)
static TextureOp read(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
TextureAndSampler texSamplers[MAX_TEX_SAMPLER_ARRAY_SIZE]
TextureAndOrSamplerData stex
QRhiShaderResourceBinding::StageFlags stage
static const int MAX_TEX_SAMPLER_ARRAY_SIZE
union QRhiShaderResourceBinding::Data::@328 u
QRhiShaderResourceBinding::Type type