diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-06 11:08:21 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-11 23:17:18 +0200 |
commit | aa37e67ef7f5ff22da0ef95fb5221bc1fff9b3ca (patch) | |
tree | be5e1a9733987aed8602eb47618cd1673a594570 /src/gui/rhi/qrhimetal.mm | |
parent | fd2685c2f0a219c091e028a98ba6cdd154986fec (diff) |
Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.
Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace, with manual
unstaging of the actual definition and documentation in dist/,
src/corelib/doc/ and src/corelib/global/.
Task-number: QTBUG-99313
Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhimetal.mm')
-rw-r--r-- | src/gui/rhi/qrhimetal.mm | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index b0926d5e21..731d60ecf4 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -1164,7 +1164,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD { QMetalShaderResourceBindingsData bindingData; - for (const QRhiShaderResourceBinding &binding : qAsConst(srbD->sortedBindings)) { + for (const QRhiShaderResourceBinding &binding : std::as_const(srbD->sortedBindings)) { const QRhiShaderResourceBinding::Data *b = binding.data(); switch (b->type) { case QRhiShaderResourceBinding::UniformBuffer: @@ -1306,7 +1306,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD return a.nativeBinding < b.nativeBinding; }); - for (const QMetalShaderResourceBindingsData::Stage::Buffer &buf : qAsConst(bindingData.res[stage].buffers)) { + for (const QMetalShaderResourceBindingsData::Stage::Buffer &buf : std::as_const(bindingData.res[stage].buffers)) { bindingData.res[stage].bufferBatches.feed(buf.nativeBinding, buf.mtlbuf); bindingData.res[stage].bufferOffsetBatches.feed(buf.nativeBinding, buf.offset); } @@ -1339,10 +1339,10 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD return a.nativeBinding < b.nativeBinding; }); - for (const QMetalShaderResourceBindingsData::Stage::Texture &t : qAsConst(bindingData.res[stage].textures)) + for (const QMetalShaderResourceBindingsData::Stage::Texture &t : std::as_const(bindingData.res[stage].textures)) bindingData.res[stage].textureBatches.feed(t.nativeBinding, t.mtltex); - for (const QMetalShaderResourceBindingsData::Stage::Sampler &s : qAsConst(bindingData.res[stage].samplers)) + for (const QMetalShaderResourceBindingsData::Stage::Sampler &s : std::as_const(bindingData.res[stage].samplers)) bindingData.res[stage].samplerBatches.feed(s.nativeBinding, s.mtlsampler); bindingData.res[stage].textureBatches.finish(); @@ -2050,7 +2050,7 @@ QRhi::FrameOpResult QRhiMetal::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginF // commands+present to complete, while for others just for the commands // (for this same frame slot) but not sure how to do that in a sane way so // wait for full cb completion for now. - for (QMetalSwapChain *sc : qAsConst(swapchains)) { + for (QMetalSwapChain *sc : std::as_const(swapchains)) { dispatch_semaphore_t sem = sc->d->sem[swapChainD->currentFrameSlot]; dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER); if (sc != swapChainD) @@ -2144,7 +2144,7 @@ QRhi::FrameOpResult QRhiMetal::beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi: currentFrameSlot = (currentFrameSlot + 1) % QMTL_FRAMES_IN_FLIGHT; if (swapchains.count() > 1) { - for (QMetalSwapChain *sc : qAsConst(swapchains)) { + for (QMetalSwapChain *sc : std::as_const(swapchains)) { // wait+signal is the general pattern to ensure the commands for a // given frame slot have completed (if sem is 1, we go 0 then 1; if // sem is 0 we go -1, block, completion increments to 0, then us to 1) @@ -2198,7 +2198,7 @@ QRhi::FrameOpResult QRhiMetal::finish() } } - for (QMetalSwapChain *sc : qAsConst(swapchains)) { + for (QMetalSwapChain *sc : std::as_const(swapchains)) { for (int i = 0; i < QMTL_FRAMES_IN_FLIGHT; ++i) { if (currentSwapChain && sc == currentSwapChain && i == currentFrameSlot) { // no wait as this is the thing we're going to be commit below and @@ -2446,7 +2446,7 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate qsizetype stagingSize = 0; for (int layer = 0, maxLayer = u.subresDesc.count(); layer < maxLayer; ++layer) { for (int level = 0; level < QRhi::MAX_MIP_LEVELS; ++level) { - for (const QRhiTextureSubresourceUploadDescription &subresDesc : qAsConst(u.subresDesc[layer][level])) + for (const QRhiTextureSubresourceUploadDescription &subresDesc : std::as_const(u.subresDesc[layer][level])) stagingSize += subresUploadByteSize(subresDesc); } } @@ -2460,7 +2460,7 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate qsizetype curOfs = 0; for (int layer = 0, maxLayer = u.subresDesc.count(); layer < maxLayer; ++layer) { for (int level = 0; level < QRhi::MAX_MIP_LEVELS; ++level) { - for (const QRhiTextureSubresourceUploadDescription &subresDesc : qAsConst(u.subresDesc[layer][level])) + for (const QRhiTextureSubresourceUploadDescription &subresDesc : std::as_const(u.subresDesc[layer][level])) enqueueSubresUpload(utexD, mp, blitEnc, layer, level, subresDesc, &curOfs); } } @@ -2573,7 +2573,7 @@ void QRhiMetal::executeBufferHostWritesForSlot(QMetalBuffer *bufD, int slot) void *p = [bufD->d->buf[slot] contents]; quint32 changeBegin = UINT32_MAX; quint32 changeEnd = 0; - for (const QMetalBufferData::BufferUpdate &u : qAsConst(bufD->d->pendingUpdates[slot])) { + for (const QMetalBufferData::BufferUpdate &u : std::as_const(bufD->d->pendingUpdates[slot])) { memcpy(static_cast<char *>(p) + u.offset, u.data.constData(), size_t(u.data.size())); if (u.offset < changeBegin) changeBegin = u.offset; @@ -4511,7 +4511,7 @@ bool QMetalGraphicsPipeline::createVertexFragmentPipeline() // buffers not just the resource binding layout), so leave // rpDesc.vertex/fragmentBuffers at the defaults. - for (const QRhiShaderStage &shaderStage : qAsConst(m_shaderStages)) { + for (const QRhiShaderStage &shaderStage : std::as_const(m_shaderStages)) { auto cacheIt = rhiD->d->shaderCache.constFind(shaderStage); if (cacheIt != rhiD->d->shaderCache.constEnd()) { switch (shaderStage.type()) { @@ -5131,7 +5131,7 @@ bool QMetalGraphicsPipeline::create() QShader tesc; QShader tese; QShader tessFrag; - for (const QRhiShaderStage &shaderStage : qAsConst(m_shaderStages)) { + for (const QRhiShaderStage &shaderStage : std::as_const(m_shaderStages)) { switch (shaderStage.type()) { case QRhiShaderStage::Vertex: tessVert = shaderStage.shader(); |