diff --git a/src/gui/rhi/qrhi_p_p.h b/src/gui/rhi/qrhi_p_p.h index 552e2695ce..b5cf660409 100644 --- a/src/gui/rhi/qrhi_p_p.h +++ b/src/gui/rhi/qrhi_p_p.h @@ -228,7 +228,7 @@ private: QBitArray resUpdPoolMap; QSet resources; QSet pendingDeleteResources; - QList cleanupCallbacks; + QVarLengthArray cleanupCallbacks; friend class QRhi; friend class QRhiResourceUpdateBatchPrivate; diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 6157381acb..e5b03e1d0e 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1641,7 +1641,7 @@ void QRhiD3D11::finishActiveReadbacks() if (readback.result->completed) completedCallbacks.append(readback.result->completed); - activeTextureReadbacks.removeAt(i); + activeTextureReadbacks.removeLast(); } for (int i = activeBufferReadbacks.count() - 1; i >= 0; --i) { @@ -1663,7 +1663,7 @@ void QRhiD3D11::finishActiveReadbacks() if (readback.result->completed) completedCallbacks.append(readback.result->completed); - activeBufferReadbacks.removeAt(i); + activeBufferReadbacks.removeLast(); } for (auto f : completedCallbacks) diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index baecc2fe21..c6890ca353 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -469,17 +469,17 @@ struct QD3D11CommandBuffer : public QRhiCommandBuffer ID3D11Buffer *currentVertexBuffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; quint32 currentVertexOffsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; - QList dataRetainPool; - QList imageRetainPool; + QVarLengthArray dataRetainPool; + QVarLengthArray imageRetainPool; // relies heavily on implicit sharing (no copies of the actual data will be made) const uchar *retainData(const QByteArray &data) { dataRetainPool.append(data); - return reinterpret_cast(dataRetainPool.constLast().constData()); + return reinterpret_cast(dataRetainPool.last().constData()); } const uchar *retainImage(const QImage &image) { imageRetainPool.append(image); - return imageRetainPool.constLast().constBits(); + return imageRetainPool.last().constBits(); } void resetCommands() { commands.clear(); @@ -707,13 +707,13 @@ public: QSize pixelSize; QRhiTexture::Format format; }; - QList activeTextureReadbacks; + QVarLengthArray activeTextureReadbacks; struct BufferReadback { QRhiBufferReadbackResult *result; quint32 byteSize; ID3D11Buffer *stagingBuf; }; - QList activeBufferReadbacks; + QVarLengthArray activeBufferReadbacks; struct Shader { Shader() = default; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 9a311101e1..9196a88199 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2746,8 +2746,8 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.ubuf.buf); const QByteArray bufView = QByteArray::fromRawData(bufD->ubuf.constData() + viewOffset, b->u.ubuf.maybeSize ? b->u.ubuf.maybeSize : bufD->m_size); - QVector &uniforms(maybeGraphicsPs ? QRHI_RES(QGles2GraphicsPipeline, maybeGraphicsPs)->uniforms - : QRHI_RES(QGles2ComputePipeline, maybeComputePs)->uniforms); + QGles2UniformDescriptionVector &uniforms(maybeGraphicsPs ? QRHI_RES(QGles2GraphicsPipeline, maybeGraphicsPs)->uniforms + : QRHI_RES(QGles2ComputePipeline, maybeComputePs)->uniforms); for (QGles2UniformDescription &uniform : uniforms) { if (uniform.binding == b->binding) { // in a uniform buffer everything is at least 4 byte aligned @@ -2877,8 +2877,8 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC break; case QRhiShaderResourceBinding::SampledTexture: { - QVector &samplers(maybeGraphicsPs ? QRHI_RES(QGles2GraphicsPipeline, maybeGraphicsPs)->samplers - : QRHI_RES(QGles2ComputePipeline, maybeComputePs)->samplers); + QGles2SamplerDescriptionVector &samplers(maybeGraphicsPs ? QRHI_RES(QGles2GraphicsPipeline, maybeGraphicsPs)->samplers + : QRHI_RES(QGles2ComputePipeline, maybeComputePs)->samplers); for (int elem = 0; elem < b->u.stex.count; ++elem) { QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.stex.texSamplers[elem].tex); QGles2Sampler *samplerD = QRHI_RES(QGles2Sampler, b->u.stex.texSamplers[elem].sampler); @@ -3404,7 +3404,7 @@ void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable int binding, int baseOffset, GLuint program, - QVector *dst) + QGles2UniformDescriptionVector *dst) { if (var.type == QShaderDescription::Struct) { qWarning("Nested structs are not supported at the moment. '%s' ignored.", @@ -3431,7 +3431,7 @@ void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable void QRhiGles2::gatherUniforms(GLuint program, const QShaderDescription::UniformBlock &ub, - QVector *dst) + QGles2UniformDescriptionVector *dst) { QByteArray prefix = ub.structName + '.'; for (const QShaderDescription::BlockVariable &blockMember : ub.members) { @@ -3464,8 +3464,9 @@ void QRhiGles2::gatherUniforms(GLuint program, } } -void QRhiGles2::gatherSamplers(GLuint program, const QShaderDescription::InOutVariable &v, - QVector *dst) +void QRhiGles2::gatherSamplers(GLuint program, + const QShaderDescription::InOutVariable &v, + QGles2SamplerDescriptionVector *dst) { QGles2SamplerDescription sampler; sampler.glslLocation = f->glGetUniformLocation(program, v.name.constData()); diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index 26a0925dee..32e7d1185d 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -266,6 +266,9 @@ struct QGles2SamplerDescription Q_DECLARE_TYPEINFO(QGles2SamplerDescription, Q_MOVABLE_TYPE); +using QGles2UniformDescriptionVector = QVarLengthArray; +using QGles2SamplerDescriptionVector = QVarLengthArray; + struct QGles2GraphicsPipeline : public QRhiGraphicsPipeline { QGles2GraphicsPipeline(QRhiImplementation *rhi); @@ -275,8 +278,8 @@ struct QGles2GraphicsPipeline : public QRhiGraphicsPipeline GLuint program = 0; GLenum drawMode = GL_TRIANGLES; - QList uniforms; - QList samplers; + QGles2UniformDescriptionVector uniforms; + QGles2SamplerDescriptionVector samplers; uint generation = 0; friend class QRhiGles2; }; @@ -289,8 +292,8 @@ struct QGles2ComputePipeline : public QRhiComputePipeline bool create() override; GLuint program = 0; - QList uniforms; - QList samplers; + QGles2UniformDescriptionVector uniforms; + QGles2SamplerDescriptionVector samplers; uint generation = 0; friend class QRhiGles2; }; @@ -574,17 +577,17 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer } } computePassState; - QList dataRetainPool; - QList imageRetainPool; + QVarLengthArray dataRetainPool; + QVarLengthArray imageRetainPool; // relies heavily on implicit sharing (no copies of the actual data will be made) const void *retainData(const QByteArray &data) { dataRetainPool.append(data); - return dataRetainPool.constLast().constData(); + return dataRetainPool.last().constData(); } const void *retainImage(const QImage &image) { imageRetainPool.append(image); - return imageRetainPool.constLast().constBits(); + return imageRetainPool.last().constBits(); } void resetCommands() { commands.clear(); @@ -810,11 +813,11 @@ public: bool linkProgram(GLuint program); void registerUniformIfActive(const QShaderDescription::BlockVariable &var, const QByteArray &namePrefix, int binding, int baseOffset, - GLuint program, QList *dst); + GLuint program, QGles2UniformDescriptionVector *dst); void gatherUniforms(GLuint program, const QShaderDescription::UniformBlock &ub, - QList *dst); + QGles2UniformDescriptionVector *dst); void gatherSamplers(GLuint program, const QShaderDescription::InOutVariable &v, - QList *dst); + QGles2SamplerDescriptionVector *dst); bool isProgramBinaryDiskCacheEnabled() const; enum DiskCacheResult { diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 357e9e792d..6998c55bf9 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -203,7 +203,7 @@ struct QRhiMetalData QSize pixelSize; QRhiTexture::Format format; }; - QVector activeTextureReadbacks; + QVarLengthArray activeTextureReadbacks; API_AVAILABLE(macos(10.13), ios(11.0)) MTLCaptureManager *captureMgr; API_AVAILABLE(macos(10.13), ios(11.0)) id captureScope = nil; @@ -2123,7 +2123,7 @@ void QRhiMetal::finishActiveReadbacks(bool forced) if (readback.result->completed) completedCallbacks.append(readback.result->completed); - d->activeTextureReadbacks.removeAt(i); + d->activeTextureReadbacks.removeLast(); } } diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 06fd6dc719..919f4f039f 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -3525,7 +3525,7 @@ void QRhiVulkan::finishActiveReadbacks(bool forced) if (readback.result->completed) completedCallbacks.append(readback.result->completed); - activeTextureReadbacks.removeAt(i); + activeTextureReadbacks.removeLast(); } } @@ -3549,7 +3549,7 @@ void QRhiVulkan::finishActiveReadbacks(bool forced) if (readback.result->completed) completedCallbacks.append(readback.result->completed); - activeBufferReadbacks.removeAt(i); + activeBufferReadbacks.removeLast(); } } @@ -6719,9 +6719,9 @@ bool QVkSwapChain::ensureSurface() quint32 presModeCount = 0; rhiD->vkGetPhysicalDeviceSurfacePresentModesKHR(rhiD->physDev, surface, &presModeCount, nullptr); - QVector presModes(presModeCount); - rhiD->vkGetPhysicalDeviceSurfacePresentModesKHR(rhiD->physDev, surface, &presModeCount, presModes.data()); - supportedPresentationModes = presModes; + supportedPresentationModes.resize(presModeCount); + rhiD->vkGetPhysicalDeviceSurfacePresentModesKHR(rhiD->physDev, surface, &presModeCount, + supportedPresentationModes.data()); return true; } diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index 3d02806033..cb21945301 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -601,7 +601,7 @@ struct QVkSwapChain : public QRhiSwapChain VkColorSpaceKHR colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR; QVkRenderBuffer *ds = nullptr; VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT; - QList supportedPresentationModes; + QVarLengthArray supportedPresentationModes; VkDeviceMemory msaaImageMem = VK_NULL_HANDLE; QVkReferenceRenderTarget rtWrapper; QVkCommandBuffer cbWrapper; @@ -865,7 +865,7 @@ public: int refCount = 0; int allocedDescSets = 0; }; - QList descriptorPools; + QVarLengthArray descriptorPools; VkQueryPool timestampQueryPool = VK_NULL_HANDLE; QBitArray timestampQueryPoolMap; @@ -894,7 +894,7 @@ public: QSize pixelSize; QRhiTexture::Format format; }; - QList activeTextureReadbacks; + QVarLengthArray activeTextureReadbacks; struct BufferReadback { int activeFrameSlot = -1; QRhiBufferReadbackResult *result; @@ -902,7 +902,7 @@ public: VkBuffer stagingBuf; QVkAlloc stagingAlloc; }; - QList activeBufferReadbacks; + QVarLengthArray activeBufferReadbacks; struct DeferredReleaseEntry { enum Type {