summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJean-Michaƫl Celerier <jean-michael.celerier@kdab.com>2020-06-30 08:32:59 +0200
committerPaul Lemire <paul.lemire@kdab.com>2020-07-07 08:34:50 +0200
commit872966f3205682ecc8c1e9353b64c04c59adf0b6 (patch)
treecd970db3c99cac7917760cd67e175a7904d329d3 /src
parentf0a196185600f98a0028642343e3c17dcaf39a44 (diff)
rhi: replace QVector by std::vector wherever possible
Change-Id: I0020df0a0ce3b53e62dd9e4e5faad92583f9dbcc Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/vector_helper_p.h14
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp20
-rw-r--r--src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp2
-rw-r--r--src/plugins/renderers/rhi/jobs/materialparametergathererjob_p.h6
-rw-r--r--src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp14
-rw-r--r--src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h8
-rw-r--r--src/plugins/renderers/rhi/renderer/commandexecuter.cpp4
-rw-r--r--src/plugins/renderers/rhi/renderer/commandexecuter_p.h6
-rw-r--r--src/plugins/renderers/rhi/renderer/rendercommand_p.h2
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer.cpp287
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer_p.h31
-rw-r--r--src/plugins/renderers/rhi/renderer/renderqueue.cpp2
-rw-r--r--src/plugins/renderers/rhi/renderer/renderqueue_p.h6
-rw-r--r--src/plugins/renderers/rhi/renderer/renderview.cpp8
-rw-r--r--src/plugins/renderers/rhi/renderer/renderview_p.h14
-rw-r--r--src/plugins/renderers/rhi/renderer/rhishader.cpp96
-rw-r--r--src/plugins/renderers/rhi/renderer/rhishader_p.h100
-rw-r--r--src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h2
-rw-r--r--src/plugins/renderers/rhi/textures/texture.cpp11
-rw-r--r--src/plugins/renderers/rhi/textures/texture_p.h14
20 files changed, 299 insertions, 348 deletions
diff --git a/src/core/vector_helper_p.h b/src/core/vector_helper_p.h
index 9274a11ca..77cfd9a52 100644
--- a/src/core/vector_helper_p.h
+++ b/src/core/vector_helper_p.h
@@ -54,6 +54,7 @@
#include <Qt3DCore/private/qt3dcore-config_p.h>
#include <qobjectdefs.h>
#include <vector>
+#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -67,6 +68,19 @@ void moveAtEnd(std::vector<T>& destination, std::vector<U>&& source)
std::make_move_iterator(source.end()));
}
+template<typename T, typename U>
+void append(std::vector<T>& destination, const U& source)
+{
+ destination.insert(destination.end(),
+ source.cbegin(),
+ source.cend());
+}
+
+template<typename T, typename U>
+bool contains(const std::vector<T>& destination, const U& element) noexcept
+{
+ return std::find(destination.begin(), destination.end(), element) != destination.end();
+}
} // namespace Qt3DCore
QT_END_NAMESPACE
diff --git a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
index 50bfd02f0..3af1be523 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
+++ b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
@@ -967,7 +967,7 @@ void SubmissionContext::activateDrawBuffers(const AttachmentPack &attachments)
{
Q_UNUSED(attachments);
RHI_UNIMPLEMENTED;
- //* const QVector<int> activeDrawBuffers = attachments.getGlDrawBuffers();
+ //* const std::vector<int> activeDrawBuffers = attachments.getGlDrawBuffers();
//*
//* if (m_glHelper->checkFrameBufferComplete()) {
//* if (activeDrawBuffers.size() > 1) {// We need MRT
@@ -1167,18 +1167,18 @@ void SubmissionContext::applyStateSet(const RenderStateSet *ss,
graphicsPipeline->setTargetBlends({blend});
- const QVector<StateVariant> statesToSet = ss->states();
+ const auto &statesToSet = ss->states();
for (const StateVariant &ds : statesToSet)
applyState(ds, graphicsPipeline);
}
StateVariant *SubmissionContext::getState(RenderStateSet *ss, StateMask type) const
{
- const QVector<StateVariant> &statesToSet = ss->states();
+ const auto &statesToSet = ss->states();
for (int i = 0, m = statesToSet.size(); i < m; ++i) {
const StateVariant &ds = statesToSet.at(i);
if (ds.type == type)
- return ss->states().begin() + i;
+ return ss->states().data() + i;
}
return nullptr;
}
@@ -1337,7 +1337,7 @@ bool SubmissionContext::setParameters(ShaderParameterPack &parameterPack, RHISha
// Update uniforms in the Default Uniform Block
const PackUniformHash& values = parameterPack.uniforms();
const auto &activeUniformsIndices = parameterPack.submissionUniformIndices();
- const QVector<ShaderUniform> &shaderUniforms = shader->uniforms();
+ const std::vector<ShaderUniform> &shaderUniforms = shader->uniforms();
for (const int shaderUniformIndex : activeUniformsIndices) {
const ShaderUniform &uniform = shaderUniforms[shaderUniformIndex];
@@ -1428,7 +1428,7 @@ void SubmissionContext::uploadDataToRHIBuffer(Buffer *buffer, RHIBuffer *b, bool
// Note: we are only storing the updates data CPU side at this point
// actually upload will be performed when the buffer will be bound
// as we would otherwise need to know the usage type of the buffer
- QVector<Qt3DCore::QBufferUpdate> updates = std::move(buffer->pendingBufferUpdates());
+ auto updates = std::move(buffer->pendingBufferUpdates());
for (auto it = updates.begin(); it != updates.end(); ++it) {
auto update = it;
// We have a partial update
@@ -1583,7 +1583,7 @@ constexpr int getFirstAvailableBit(const std::bitset<N> &bits)
return -1;
}
// This function ensures that the shader stages all have the same bindings
-void preprocessRHIShader(QVector<QByteArray> &shaderCodes)
+void preprocessRHIShader(std::vector<QByteArray> &shaderCodes)
{
// Map the variable names to bindings
std::map<QByteArray, int> bindings;
@@ -1750,11 +1750,13 @@ void SubmissionContext::loadShader(Shader *shaderNode, ShaderManager *shaderMana
// We create or adopt an already created rhiShader
rhiShader = rhiShaderManager->createOrAdoptExisting(shaderNode);
- const QVector<Qt3DCore::QNodeId> sharedShaderIds =
+ const std::vector<Qt3DCore::QNodeId> &sharedShaderIds =
rhiShaderManager->shaderIdsForProgram(rhiShader);
if (sharedShaderIds.size() == 1) {
// Shader in the cache hasn't been loaded yet
- QVector<QByteArray> shaderCodes = shaderNode->shaderCode();
+ // We want a copy of the QByteArray as preprocessRHIShader will
+ // modify them
+ std::vector<QByteArray> shaderCodes = shaderNode->shaderCode();
preprocessRHIShader(shaderCodes);
rhiShader->setShaderCode(shaderCodes);
diff --git a/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp b/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp
index 657e5eea7..9c8a6dcbf 100644
--- a/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp
+++ b/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp
@@ -81,7 +81,7 @@ void FilterCompatibleTechniqueJob::run()
Q_ASSERT(m_manager != nullptr && m_renderer != nullptr);
Q_ASSERT(m_renderer->isRunning() && m_renderer->submissionContext()->isInitialized());
- const QVector<Qt3DCore::QNodeId> dirtyTechniqueIds = m_manager->takeDirtyTechniques();
+ const auto& dirtyTechniqueIds = m_manager->takeDirtyTechniques();
for (const Qt3DCore::QNodeId techniqueId : dirtyTechniqueIds) {
Technique *technique = m_manager->lookupResource(techniqueId);
if (Q_LIKELY(technique != nullptr))
diff --git a/src/plugins/renderers/rhi/jobs/materialparametergathererjob_p.h b/src/plugins/renderers/rhi/jobs/materialparametergathererjob_p.h
index f635755d7..eb7f17a66 100644
--- a/src/plugins/renderers/rhi/jobs/materialparametergathererjob_p.h
+++ b/src/plugins/renderers/rhi/jobs/materialparametergathererjob_p.h
@@ -86,12 +86,12 @@ public:
{
m_renderPassFilter = renderPassFilter;
}
- inline const QHash<Qt3DCore::QNodeId, QVector<RenderPassParameterData>> &
+ inline const QHash<Qt3DCore::QNodeId, std::vector<RenderPassParameterData>> &
materialToPassAndParameter() Q_DECL_NOTHROW
{
return m_parameters;
}
- inline void setHandles(const QVector<HMaterial> &handles) Q_DECL_NOTHROW
+ inline void setHandles(const std::vector<HMaterial> &handles) Q_DECL_NOTHROW
{
m_handles = handles;
}
@@ -108,7 +108,7 @@ private:
// Material id to array of RenderPasse with parameters
MaterialParameterGathererData m_parameters;
- QVector<HMaterial> m_handles;
+ std::vector<HMaterial> m_handles;
};
typedef QSharedPointer<MaterialParameterGathererJob> MaterialParameterGathererJobPtr;
diff --git a/src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp b/src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp
index ee3fc3ca4..595811026 100644
--- a/src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp
+++ b/src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp
@@ -320,7 +320,7 @@ Technique *findTechniqueForEffect(NodeManagers *manager, const TechniqueFilter *
if (!effect)
return nullptr;
- QVector<Technique *> matchingTechniques;
+ std::vector<Technique *> matchingTechniques;
const bool hasInvalidTechniqueFilter =
(techniqueFilter == nullptr || techniqueFilter->filters().isEmpty());
@@ -337,17 +337,17 @@ Technique *findTechniqueForEffect(NodeManagers *manager, const TechniqueFilter *
if (technique->isCompatibleWithRenderer()
&& (hasInvalidTechniqueFilter
|| technique->isCompatibleWithFilters(techniqueFilter->filters())))
- matchingTechniques.append(technique);
+ matchingTechniques.push_back(technique);
}
if (matchingTechniques.size() == 0) // We failed to find a suitable technique to use :(
return nullptr;
if (matchingTechniques.size() == 1)
- return matchingTechniques.first();
+ return matchingTechniques.front();
// Several compatible techniques, return technique with highest major and minor version
- Technique *highest = matchingTechniques.first();
+ Technique *highest = matchingTechniques.front();
GraphicsApiFilterData filter = *highest->graphicsApiFilter();
for (auto it = matchingTechniques.cbegin() + 1; it < matchingTechniques.cend(); ++it) {
if (filter < *(*it)->graphicsApiFilter()) {
@@ -467,7 +467,7 @@ const int qNodeIdTypeId = qMetaTypeId<QNodeId>();
}
UniformBlockValueBuilder::UniformBlockValueBuilder(
- const QVector<int> &uniformNamesIds,
+ const std::vector<int> &uniformNamesIds,
ShaderDataManager *shaderDataManager,
TextureManager *textureManager,
const Matrix4x4 &matrix)
@@ -505,7 +505,7 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(
}
}
} else { // Array of scalar/vec qmlPropertyName[0]
- if (m_uniformNamesIds.contains(propertyInBlockNameId)) {
+ if (Qt3DCore::contains(m_uniformNamesIds, propertyInBlockNameId)) {
activeUniformNamesToValue.insert(propertyInBlockNameId, value->value);
}
}
@@ -520,7 +520,7 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(
activeUniformNamesToValue.insert(propertyInBlockNameId, value->value);
}
} else { // Scalar / Vec
- if (m_uniformNamesIds.contains(propertyInBlockNameId)) {
+ if (Qt3DCore::contains(m_uniformNamesIds, propertyInBlockNameId)) {
// If the property needs to be transformed, we transform it here as
// the shaderdata cannot hold transformed properties for multiple
// thread contexts at once
diff --git a/src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h b/src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h
index 54c079625..e61b76baf 100644
--- a/src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h
+++ b/src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h
@@ -122,7 +122,7 @@ struct ParameterInfo
bool operator<(const int otherNameId) const Q_DECL_NOEXCEPT;
bool operator<(const ParameterInfo &other) const Q_DECL_NOEXCEPT;
};
-typedef QVector<ParameterInfo> ParameterInfoList;
+typedef std::vector<ParameterInfo> ParameterInfoList;
struct RenderPassParameterData
{
@@ -131,7 +131,7 @@ struct RenderPassParameterData
};
QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, Rhi, RenderPassParameterData, Q_MOVABLE_TYPE)
-using MaterialParameterGathererData = QHash<Qt3DCore::QNodeId, QVector<RenderPassParameterData>>;
+using MaterialParameterGathererData = QHash<Qt3DCore::QNodeId, std::vector<RenderPassParameterData>>;
Q_AUTOTEST_EXPORT void parametersFromMaterialEffectTechnique(ParameterInfoList *infoList,
ParameterManager *manager,
@@ -159,7 +159,7 @@ typedef QHash<int, QVariant> UniformBlockValueBuilderHash;
struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder
{
- explicit UniformBlockValueBuilder(const QVector<int> &uniformNamesIds,
+ explicit UniformBlockValueBuilder(const std::vector<int> &uniformNamesIds,
ShaderDataManager *shaderDataManager,
TextureManager *textureManager,
const Matrix4x4 &matrix);
@@ -177,7 +177,7 @@ struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder
UniformBlockValueBuilderHash activeUniformNamesToValue;
private:
- const QVector<int> &m_uniformNamesIds;
+ const std::vector<int> &m_uniformNamesIds;
ShaderDataManager *m_shaderDataManager = nullptr;
TextureManager *m_textureManager = nullptr;
const Matrix4x4 &m_viewMatrix;
diff --git a/src/plugins/renderers/rhi/renderer/commandexecuter.cpp b/src/plugins/renderers/rhi/renderer/commandexecuter.cpp
index d4fdf3a6d..d29fae5de 100644
--- a/src/plugins/renderers/rhi/renderer/commandexecuter.cpp
+++ b/src/plugins/renderers/rhi/renderer/commandexecuter.cpp
@@ -301,12 +301,12 @@ CommandExecuter::CommandExecuter(Render::Rhi::Renderer *renderer) : m_renderer(r
// Render thread
void CommandExecuter::performAsynchronousCommandExecution(
- const QVector<Render::Rhi::RenderView *> &views)
+ const std::vector<Render::Rhi::RenderView *> &views)
{
Q_UNUSED(views);
RHI_UNIMPLEMENTED;
//* QMutexLocker lock(&m_pendingCommandsMutex);
- //* const QVector<Qt3DCore::Debug::AsynchronousCommandReply *> shellCommands =
+ //* const std::vector<Qt3DCore::Debug::AsynchronousCommandReply *> shellCommands =
//std::move(m_pendingCommands);
//* lock.unlock();
//*
diff --git a/src/plugins/renderers/rhi/renderer/commandexecuter_p.h b/src/plugins/renderers/rhi/renderer/commandexecuter_p.h
index 924930a49..74f83c082 100644
--- a/src/plugins/renderers/rhi/renderer/commandexecuter_p.h
+++ b/src/plugins/renderers/rhi/renderer/commandexecuter_p.h
@@ -49,7 +49,7 @@
// We mean it.
//
-#include <QVector>
+#include <vector>
#include <QVariant>
#include <QMutex>
@@ -79,13 +79,13 @@ class CommandExecuter
public:
explicit CommandExecuter(Render::Rhi::Renderer *renderer);
- void performAsynchronousCommandExecution(const QVector<Render::Rhi::RenderView *> &views);
+ void performAsynchronousCommandExecution(const std::vector<Render::Rhi::RenderView *> &views);
QVariant executeCommand(const QStringList &args);
private:
Render::Rhi::Renderer *m_renderer;
- QVector<Qt3DCore::Debug::AsynchronousCommandReply *> m_pendingCommands;
+ std::vector<Qt3DCore::Debug::AsynchronousCommandReply *> m_pendingCommands;
QMutex m_pendingCommandsMutex;
};
diff --git a/src/plugins/renderers/rhi/renderer/rendercommand_p.h b/src/plugins/renderers/rhi/renderer/rendercommand_p.h
index 421ea2b8d..704e79c32 100644
--- a/src/plugins/renderers/rhi/renderer/rendercommand_p.h
+++ b/src/plugins/renderers/rhi/renderer/rendercommand_p.h
@@ -128,7 +128,7 @@ public:
// A QAttribute pack might be interesting
// This is a temporary fix in the meantime, to remove the hacked methods in Technique
- QVector<int> m_activeAttributes;
+ std::vector<int> m_activeAttributes;
float m_depth;
int m_changeCost;
diff --git a/src/plugins/renderers/rhi/renderer/renderer.cpp b/src/plugins/renderers/rhi/renderer/renderer.cpp
index b99ae427f..f05164671 100644
--- a/src/plugins/renderers/rhi/renderer/renderer.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderer.cpp
@@ -202,7 +202,7 @@ private:
int locationForAttribute(Attribute *attr, RHIShader *shader) noexcept
{
- const QVector<ShaderAttribute> attribInfo = shader->attributes();
+ const std::vector<ShaderAttribute> &attribInfo = shader->attributes();
const auto it = std::find_if(
attribInfo.begin(), attribInfo.end(),
[attr](const ShaderAttribute &sAttr) { return attr->nameId() == sAttr.m_nameId; });
@@ -389,7 +389,7 @@ QOpenGLContext *Renderer::shareContext() const
void Renderer::loadShader(Shader *shader, HShader shaderHandle)
{
Q_UNUSED(shader);
- if (!m_dirtyShaders.contains(shaderHandle))
+ if (!Qt3DCore::contains(m_dirtyShaders, shaderHandle))
m_dirtyShaders.push_back(shaderHandle);
}
@@ -554,7 +554,7 @@ void Renderer::releaseGraphicsResources()
//{
//*
//* // Clean up the graphics context and any resources
- //* const QVector<HRHITexture> activeTexturesHandles =
+ //* const std::vector<HRHITexture> activeTexturesHandles =
//m_RHIResourceManagers->rhiTextureManager()->activeHandles();
//* for (const HRHITexture &textureHandle : activeTexturesHandles) {
//* RHITexture *tex = m_RHIResourceManagers->rhiTextureManager()->data(textureHandle);
@@ -562,7 +562,7 @@ void Renderer::releaseGraphicsResources()
//* }
//*
//* // Do the same thing with buffers
- //* const QVector<HRHIBuffer> activeBuffers =
+ //* const std::vector<HRHIBuffer> activeBuffers =
//m_RHIResourceManagers->rhiBufferManager()->activeHandles();
//* for (const HRHIBuffer &bufferHandle : activeBuffers) {
//* RHIBuffer *buffer = m_RHIResourceManagers->rhiBufferManager()->data(bufferHandle);
@@ -570,7 +570,7 @@ void Renderer::releaseGraphicsResources()
//* }
//*
//* // Do the same thing with shaders
- //* const QVector<RHIShader *> shaders =
+ //* const std::vector<RHIShader *> shaders =
//m_RHIResourceManagers->rhiShaderManager()->takeActiveResources();
//* qDeleteAll(shaders);
//*
@@ -638,60 +638,29 @@ RenderSettings *Renderer::settings() const
return m_settings;
}
-void Renderer::render()
-{
- // Traversing the framegraph tree from root to lead node
- // Allows us to define the rendering set up
- // Camera, RenderTarget ...
-
- // Utimately the renderer should be a framework
- // For the processing of the list of renderviews
-
- // Matrice update, bounding volumes computation ...
- // Should be jobs
-
- // namespace Qt3DCore has 2 distincts node trees
- // One scene description
- // One framegraph description
-
- while (m_running.loadRelaxed() > 0) {
- doRender();
- // TO DO: Restore windows exposed detection
- // Probably needs to happens some place else though
- }
-}
-
-// Either called by render if Qt3D is in charge of the RenderThread
-// or by QRenderAspectPrivate::renderSynchronous (for Scene3D)
-void Renderer::doRender(bool swapBuffers)
+// Either called by render if Qt3D is in charge of rendering (in the mainthread)
+// or by QRenderAspectPrivate::render (for Scene3D, potentially from a RenderThread)
+// This will wait until renderQueue is ready or shutdown was requested
+void Renderer::render(bool swapBuffers)
{
Renderer::ViewSubmissionResultData submissionData;
- bool hasCleanedQueueAndProceeded = false;
- bool preprocessingComplete = false;
bool beganDrawing = false;
// Blocking until RenderQueue is full
- const bool canSubmit = isReadyToSubmit();
- m_shouldSwapBuffers = swapBuffers;
+ const bool canSubmit = waitUntilReadyToSubmit();
- // Lock the mutex to protect access to the renderQueue while we look for its state
- QMutexLocker locker(m_renderQueue->mutex());
- const bool queueIsComplete = m_renderQueue->isFrameQueueComplete();
+ // If it returns false -> we are shutting down
+ if (!canSubmit)
+ return;
+
+ m_shouldSwapBuffers = swapBuffers;
+ const std::vector<Render::Rhi::RenderView *> &renderViews = m_renderQueue->nextFrameQueue();
const bool queueIsEmpty = m_renderQueue->targetRenderViewCount() == 0;
bool mustCleanResources = false;
- // When using synchronous rendering (QtQuick)
- // We are not sure that the frame queue is actually complete
- // Since a call to render may not be synched with the completions
- // of the RenderViewJobs
- // In such a case we return early, waiting for a next call with
- // the frame queue complete at this point
-
// RenderQueue is complete (but that means it may be of size 0)
- if (canSubmit && (queueIsComplete && !queueIsEmpty)) {
- const QVector<Render::Rhi::RenderView *> renderViews = m_renderQueue->nextFrameQueue();
-
+ if (!queueIsEmpty) {
QTaskLogger submissionStatsPart1(m_services->systemInformation(),
{ JobTypes::FrameSubmissionPart1, 0 },
QTaskLogger::Submission);
@@ -699,77 +668,69 @@ void Renderer::doRender(bool swapBuffers)
{ JobTypes::FrameSubmissionPart2, 0 },
QTaskLogger::Submission);
- QVector<RHIPassInfo> rhiPassesInfo;
+ std::vector<RHIPassInfo> rhiPassesInfo;
- if (canRender()) {
- QSurface *surface = nullptr;
- for (const RenderView *rv : renderViews) {
- surface = rv->surface();
- if (surface)
- break;
- }
+ QSurface *surface = nullptr;
+ for (const RenderView *rv : renderViews) {
+ surface = rv->surface();
+ if (surface)
+ break;
+ }
- // In case we did not draw because e.g. there wase no swapchain,
- // we keep the resource updates from the previous frame.
- if (!m_submissionContext->m_currentUpdates) {
- m_submissionContext->m_currentUpdates =
- m_submissionContext->rhi()->nextResourceUpdateBatch();
- }
+ // In case we did not draw because e.g. there wase no swapchain,
+ // we keep the resource updates from the previous frame.
+ if (!m_submissionContext->m_currentUpdates) {
+ m_submissionContext->m_currentUpdates =
+ m_submissionContext->rhi()->nextResourceUpdateBatch();
+ }
- // 1) Execute commands for buffer uploads, texture updates, shader loading first
- updateResources();
+ // 1) Execute commands for buffer uploads, texture updates, shader loading first
+ updateResources();
- rhiPassesInfo = prepareCommandsSubmission(renderViews);
- // 2) Update Pipelines and copy data into commands to allow concurrent submission
- preprocessingComplete = true;
+ rhiPassesInfo = prepareCommandsSubmission(renderViews);
+ // 2) Update Pipelines and copy data into commands to allow concurrent submission
- bool hasCommands = false;
- for (const RenderView *rv : renderViews) {
- // TODO find a way to break earlier with this pattern.
- rv->forEachCommand([&] (const RenderCommand &cmd) {
- hasCommands |= cmd.isValid();
- });
- if (hasCommands)
- break;
- }
+ bool hasCommands = false;
+ for (const RenderView *rv : renderViews) {
+ // TODO find a way to break earlier with this pattern.
+ rv->forEachCommand([&] (const RenderCommand &cmd) {
+ hasCommands |= cmd.isValid();
+ });
+ if (hasCommands)
+ break;
+ }
- if (hasCommands) {
- // Scoped to destroy surfaceLock
- SurfaceLocker surfaceLock(surface);
- const bool surfaceIsValid = (surface && surfaceLock.isSurfaceValid());
- if (surfaceIsValid) {
- beganDrawing = m_submissionContext->beginDrawing(surface);
- if (beganDrawing) {
- // Purge shader which aren't used any longer
- static int callCount = 0;
- ++callCount;
- const int shaderPurgePeriod = 600;
- if (callCount % shaderPurgePeriod == 0)
- m_RHIResourceManagers->rhiShaderManager()->purge();
- }
+ if (hasCommands) {
+ // Scoped to destroy surfaceLock
+ SurfaceLocker surfaceLock(surface);
+ const bool surfaceIsValid = (surface && surfaceLock.isSurfaceValid());
+ if (surfaceIsValid) {
+ beganDrawing = m_submissionContext->beginDrawing(surface);
+ if (beganDrawing) {
+ // Purge shader which aren't used any longer
+ static int callCount = 0;
+ ++callCount;
+ const int shaderPurgePeriod = 600;
+ if (callCount % shaderPurgePeriod == 0)
+ m_RHIResourceManagers->rhiShaderManager()->purge();
}
}
- // 2) Proceed to next frame and start preparing frame n + 1
- m_renderQueue->reset();
- locker.unlock(); // Done protecting RenderQueue
- m_vsyncFrameAdvanceService->proceedToNextFrame();
- hasCleanedQueueAndProceeded = true;
-
- // Only try to submit the RenderViews if the preprocessing was successful
- // This part of the submission is happening in parallel to the RV building for the next
- // frame
- if (beganDrawing) {
- submissionStatsPart1.end(submissionStatsPart2.restart());
-
- // 3) Submit the render commands for frame n (making sure we never reference
- // something that could be changing) Render using current device state and renderer
- // configuration
- submissionData = submitRenderViews(rhiPassesInfo);
-
- // Perform any required cleanup of the Graphics resources (Buffers deleted, Shader
- // deleted...)
- mustCleanResources = true;
- }
+ }
+
+ // Only try to submit the RenderViews if the preprocessing was successful
+ // This part of the submission is happening in parallel to the RV building for the next
+ // frame
+ if (beganDrawing) {
+ submissionStatsPart1.end(submissionStatsPart2.restart());
+
+ // 3) Submit the render commands for frame n (making sure we never reference
+ // something that could be changing) Render using current device state and renderer
+ // configuration
+ submissionData = submitRenderViews(rhiPassesInfo);
+
+ // Perform any required cleanup of the Graphics resources (Buffers deleted, Shader
+ // deleted...)
+ mustCleanResources = true;
}
// Execute the pending shell commands
@@ -777,27 +738,6 @@ void Renderer::doRender(bool swapBuffers)
// Delete all the RenderViews which will clear the allocators
// that were used for their allocation
- qDeleteAll(renderViews);
- }
-
- // If hasCleanedQueueAndProceeded isn't true this implies that something went wrong
- // with the rendering and/or the renderqueue is incomplete from some reason
- // or alternatively it could be complete but empty (RenderQueue of size 0)
-
- if (!hasCleanedQueueAndProceeded) {
- // RenderQueue was full but something bad happened when
- // trying to render it and therefore proceedToNextFrame was not called
- // Note: in this case the renderQueue mutex is still locked
-
- // Reset the m_renderQueue so that we won't try to render
- // with a queue used by a previous frame with corrupted content
- // if the current queue was correctly submitted
- m_renderQueue->reset();
-
- // We allow the RenderTickClock service to proceed to the next frame
- // In turn this will allow the aspect manager to request a new set of jobs
- // to be performed for each aspect
- m_vsyncFrameAdvanceService->proceedToNextFrame();
}
// Perform the last swapBuffers calls after the proceedToNextFrame
@@ -816,6 +756,15 @@ void Renderer::doRender(bool swapBuffers)
if (mustCleanResources)
cleanGraphicsResources();
}
+
+ // Reset RenderQueue and destroy the renderViews
+ m_renderQueue->reset();
+ qDeleteAll(renderViews);
+
+ // We allow the RenderTickClock service to proceed to the next frame
+ // In turn this will allow the aspect manager to request a new set of jobs
+ // to be performed for each aspect
+ m_vsyncFrameAdvanceService->proceedToNextFrame();
}
// Called by RenderViewJobs
@@ -825,7 +774,7 @@ void Renderer::enqueueRenderView(RenderView *renderView, int submitOrder)
{
QMutexLocker locker(m_renderQueue->mutex()); // Prevent out of order execution
// We cannot use a lock free primitive here because:
- // - QVector is not thread safe
+ // - std::vector is not thread safe
// - Even if the insert is made correctly, the isFrameComplete call
// could be invalid since depending on the order of execution
// the counter could be complete but the renderview not yet added to the
@@ -837,17 +786,7 @@ void Renderer::enqueueRenderView(RenderView *renderView, int submitOrder)
}
}
-bool Renderer::canRender() const
-{
-
- // TO DO: Check if all surfaces have been destroyed...
- // It may be better if the last window to be closed trigger a call to shutdown
- // Rather than having checks for the surface everywhere
-
- return true;
-}
-
-bool Renderer::isReadyToSubmit()
+bool Renderer::waitUntilReadyToSubmit()
{
// Make sure that we've been told to render before rendering
// Prevent ouf of order execution
@@ -1008,20 +947,22 @@ void Renderer::updateGraphicsPipeline(RenderCommand &cmd, RenderView *rv, int re
return onFailure();
}
- QVector<QRhiShaderResourceBinding> uboBindings;
- uboBindings << QRhiShaderResourceBinding::uniformBuffer(
- 0,
- QRhiShaderResourceBinding::VertexStage | QRhiShaderResourceBinding::FragmentStage,
- rvUBO)
- << QRhiShaderResourceBinding::uniformBuffer(
- 1,
- QRhiShaderResourceBinding::VertexStage
- | QRhiShaderResourceBinding::FragmentStage,
- commandUBO);
+ std::vector<QRhiShaderResourceBinding> uboBindings;
+ uboBindings.push_back(
+ QRhiShaderResourceBinding::uniformBuffer(
+ 0,
+ QRhiShaderResourceBinding::VertexStage | QRhiShaderResourceBinding::FragmentStage,
+ rvUBO));
+
+ uboBindings.push_back(
+ QRhiShaderResourceBinding::uniformBuffer(
+ 1,
+ QRhiShaderResourceBinding::VertexStage | QRhiShaderResourceBinding::FragmentStage,
+ commandUBO));
// Create additional empty UBO Buffer for UBO with binding point > 1 (since we assume 0 and
// 1 and for Qt3D standard values)
- const QVector<ShaderUniformBlock> uniformBlocks = cmd.m_rhiShader->uniformBlocks();
+ const std::vector<ShaderUniformBlock> &uniformBlocks = cmd.m_rhiShader->uniformBlocks();
QHash<int, RHIGraphicsPipeline::UBOBuffer> uboBuffers;
for (const ShaderUniformBlock &block : uniformBlocks) {
if (block.m_binding > 1) {
@@ -1032,11 +973,11 @@ void Renderer::updateGraphicsPipeline(RenderCommand &cmd, RenderView *rv, int re
ubo->allocate(m_submissionContext.data(), rawData, true);
ok = ubo->bind(m_submissionContext.data(), RHIBuffer::UniformBuffer);
uboBuffers[block.m_binding] = { handle, ubo };
- uboBindings << QRhiShaderResourceBinding::uniformBuffer(
+ uboBindings.push_back(QRhiShaderResourceBinding::uniformBuffer(
block.m_binding,
QRhiShaderResourceBinding::VertexStage
| QRhiShaderResourceBinding::FragmentStage,
- ubo->rhiBuffer());
+ ubo->rhiBuffer()));
}
}
graphicsPipeline->setUBOs(uboBuffers);
@@ -1101,7 +1042,7 @@ void Renderer::updateGraphicsPipeline(RenderCommand &cmd, RenderView *rv, int re
QRhiVertexInputBinding::Classification classification;
uint attributeDivisor;
};
- QVector<BufferBinding> uniqueBindings;
+ std::vector<BufferBinding> uniqueBindings;
// QRhiVertexInputBinding -> specifies the stride of an attribute, whether it's per vertex
@@ -1355,8 +1296,8 @@ bool Renderer::setupRenderTarget(RenderView *rv, RHIGraphicsPipeline *graphicsPi
}
}
// When this function is called, we must not be processing the commands for frame n+1
-QVector<Renderer::RHIPassInfo>
-Renderer::prepareCommandsSubmission(const QVector<RenderView *> &renderViews)
+std::vector<Renderer::RHIPassInfo>
+Renderer::prepareCommandsSubmission(const std::vector<RenderView *> &renderViews)
{
// TO DO: Find a central place to initialize RHI resources
const int renderViewCount = renderViews.size();
@@ -1365,11 +1306,11 @@ Renderer::prepareCommandsSubmission(const QVector<RenderView *> &renderViews)
// as creating the pass clears the buffers
// 1) We need to find all adjacents RenderViews that have the same renderTarget
// and submit all of these as part of the same RHI pass
- QVector<RHIPassInfo> rhiPassesInfo;
+ std::vector<RHIPassInfo> rhiPassesInfo;
for (int i = 0; i < renderViewCount;) {
- QVector<RenderView *> sameRenderTargetRVs;
- QVector<QRhiBuffer *> rvUbos;
+ std::vector<RenderView *> sameRenderTargetRVs;
+ std::vector<QRhiBuffer *> rvUbos;
RenderView *refRV = renderViews.at(i);
sameRenderTargetRVs.push_back(refRV);
@@ -1605,7 +1546,7 @@ void Renderer::sendShaderChangesToFrontend(Qt3DCore::QAspectManager *manager)
// Executed in a job (in main thread when jobs are done)
void Renderer::sendTextureChangesToFrontend(Qt3DCore::QAspectManager *manager)
{
- const QVector<QPair<Texture::TextureUpdateInfo, Qt3DCore::QNodeIdVector>>
+ const std::vector<QPair<Texture::TextureUpdateInfo, Qt3DCore::QNodeIdVector>>
updateTextureProperties = std::move(m_updatedTextureProperties);
for (const auto &pair : updateTextureProperties) {
const Qt3DCore::QNodeIdVector targetIds = pair.second;
@@ -1678,7 +1619,7 @@ void Renderer::sendDisablesToFrontend(Qt3DCore::QAspectManager *manager)
void Renderer::updateResources()
{
{
- const QVector<HBuffer> dirtyBufferHandles = std::move(m_dirtyBuffers);
+ const std::vector<HBuffer> dirtyBufferHandles = std::move(m_dirtyBuffers);
for (const HBuffer &handle : dirtyBufferHandles) {
Buffer *buffer = m_nodesManager->bufferManager()->data(handle);
@@ -1698,7 +1639,7 @@ void Renderer::updateResources()
#ifndef SHADER_LOADING_IN_COMMAND_THREAD
{
- const QVector<HShader> dirtyShaderHandles = std::move(m_dirtyShaders);
+ const std::vector<HShader> dirtyShaderHandles = std::move(m_dirtyShaders);
ShaderManager *shaderManager = m_nodesManager->shaderManager();
for (const HShader &handle : dirtyShaderHandles) {
Shader *shader = shaderManager->data(handle);
@@ -1715,7 +1656,7 @@ void Renderer::updateResources()
#endif
{
- const QVector<HTexture> activeTextureHandles = std::move(m_dirtyTextures);
+ const std::vector<HTexture> activeTextureHandles = std::move(m_dirtyTextures);
for (const HTexture &handle : activeTextureHandles) {
Texture *texture = m_nodesManager->textureManager()->data(handle);
@@ -1807,7 +1748,7 @@ void Renderer::updateTexture(Texture *texture)
// Will make the texture requestUpload
if (dirtyFlags.testFlag(Texture::DirtyImageGenerators)) {
const QNodeIdVector textureImageIds = texture->textureImageIds();
- QVector<RHITexture::Image> images;
+ std::vector<RHITexture::Image> images;
images.reserve(textureImageIds.size());
// TODO: Move this into RHITexture directly
for (const QNodeId textureImageId : textureImageIds) {
@@ -1869,7 +1810,7 @@ void Renderer::cleanupRenderTarget(const RenderTarget *renderTarget)
// Called by SubmitRenderView
void Renderer::downloadGLBuffers()
{
- const QVector<Qt3DCore::QNodeId> downloadableHandles = std::move(m_downloadableBuffers);
+ const std::vector<Qt3DCore::QNodeId> downloadableHandles = std::move(m_downloadableBuffers);
for (const Qt3DCore::QNodeId &bufferId : downloadableHandles) {
BufferManager *bufferManager = m_nodesManager->bufferManager();
BufferManager::ReadLocker locker(const_cast<const BufferManager *>(bufferManager));
@@ -1887,7 +1828,7 @@ void Renderer::downloadGLBuffers()
// Happens in RenderThread context when all RenderViewJobs are done
// Returns the id of the last bound FBO
Renderer::ViewSubmissionResultData
-Renderer::submitRenderViews(const QVector<RHIPassInfo> &rhiPassesInfo)
+Renderer::submitRenderViews(const std::vector<RHIPassInfo> &rhiPassesInfo)
{
QElapsedTimer timer;
quint64 queueElapsed = 0;
@@ -2091,7 +2032,7 @@ void Renderer::jobsDone(Qt3DCore::QAspectManager *manager)
// called in main thread once all jobs are done running
// sync captured renders to frontend
- const QVector<Qt3DCore::QNodeId> pendingCaptureIds =
+ const std::vector<Qt3DCore::QNodeId> pendingCaptureIds =
std::move(m_pendingRenderCaptureSendRequests);
for (const Qt3DCore::QNodeId &id : qAsConst(pendingCaptureIds)) {
auto *backend = static_cast<Qt3DRender::Render::RenderCapture *>(
@@ -2498,7 +2439,7 @@ bool Renderer::uploadUBOsForCommand(QRhiCommandBuffer *cb, const RenderView *rv,
if (!shader)
return true;
- const QVector<RHIShader::UBO_Member> &uboMembers = shader->uboMembers();
+ const std::vector<RHIShader::UBO_Member> &uboMembers = shader->uboMembers();
const QHash<int, RHIGraphicsPipeline::UBOBuffer> &uboBuffers = pipeline->ubos();
const ShaderParameterPack &parameterPack = command.m_parameterPack;
const PackUniformHash &uniforms = parameterPack.uniforms();
@@ -2574,7 +2515,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
{
bool allCommandsIssued = true;
- const QVector<RenderView *> &renderViews = passInfo.rvs;
+ const std::vector<RenderView *> &renderViews = passInfo.rvs;
QColor clearColor;
QRhiDepthStencilClearValue clearDepthStencil;
diff --git a/src/plugins/renderers/rhi/renderer/renderer_p.h b/src/plugins/renderers/rhi/renderer/renderer_p.h
index d810e0edd..8a0046d93 100644
--- a/src/plugins/renderers/rhi/renderer/renderer_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderer_p.h
@@ -185,8 +185,7 @@ public:
void shutdown() override;
void releaseGraphicsResources() override;
- void render() override;
- void doRender(bool swapBuffers = true) override;
+ void render(bool swapBuffers = true) override;
void cleanGraphicsResources() override;
bool isRunning() const override { return m_running.loadRelaxed(); }
@@ -257,13 +256,13 @@ public:
struct RHIPassInfo
{
- QVector<RenderView *> rvs;
+ std::vector<RenderView *> rvs;
QSurface *surface = nullptr;
Qt3DCore::QNodeId renderTargetId;
AttachmentPack attachmentPack;
};
- QVector<RHIPassInfo> prepareCommandsSubmission(const QVector<RenderView *> &renderViews);
+ std::vector<RHIPassInfo> prepareCommandsSubmission(const std::vector<RenderView *> &renderViews);
bool executeCommandsSubmission(const RHIPassInfo &passInfo);
// For Scene2D rendering
@@ -281,7 +280,7 @@ public:
QList<QKeyEvent> pendingKeyEvents() const;
void enqueueRenderView(RenderView *renderView, int submitOrder);
- bool isReadyToSubmit();
+ bool waitUntilReadyToSubmit();
QVariant executeCommand(const QStringList &args) override;
void setOffscreenSurfaceHelper(OffscreenSurfaceHelper *helper) override;
@@ -294,7 +293,7 @@ public:
QSurface *surface;
};
- ViewSubmissionResultData submitRenderViews(const QVector<RHIPassInfo> &rhiPassesInfo);
+ ViewSubmissionResultData submitRenderViews(const std::vector<RHIPassInfo> &rhiPassesInfo);
RendererCache *cache() { return &m_cache; }
void setScreen(QScreen *scr) override;
@@ -308,8 +307,6 @@ public:
private:
#endif
- bool canRender() const;
-
Qt3DCore::QServiceLocator *m_services;
QRenderAspect *m_aspect;
NodeManagers *m_nodesManager;
@@ -335,8 +332,8 @@ private:
QAtomicInt m_running;
- QVector<Attribute *> m_dirtyAttributes;
- QVector<Geometry *> m_dirtyGeometry;
+ std::vector<Attribute *> m_dirtyAttributes;
+ std::vector<Geometry *> m_dirtyGeometry;
QAtomicInt m_exposed;
struct DirtyBits
@@ -361,7 +358,7 @@ private:
RenderableEntityFilterPtr m_renderableEntityFilterJob;
ComputableEntityFilterPtr m_computableEntityFilterJob;
- QVector<Qt3DCore::QNodeId> m_pendingRenderCaptureSendRequests;
+ std::vector<Qt3DCore::QNodeId> m_pendingRenderCaptureSendRequests;
void performDraw(RenderCommand *command);
void performCompute(const RenderView *rv, RenderCommand *command);
@@ -379,12 +376,12 @@ private:
void sendSetFenceHandlesToFrontend();
void sendDisablesToFrontend(Qt3DCore::QAspectManager *manager);
- QVector<HBuffer> m_dirtyBuffers;
- QVector<Qt3DCore::QNodeId> m_downloadableBuffers;
- QVector<HShader> m_dirtyShaders;
- QVector<HTexture> m_dirtyTextures;
- QVector<QPair<Texture::TextureUpdateInfo, Qt3DCore::QNodeIdVector>> m_updatedTextureProperties;
- QVector<Qt3DCore::QNodeId> m_updatedDisableSubtreeEnablers;
+ std::vector<HBuffer> m_dirtyBuffers;
+ std::vector<Qt3DCore::QNodeId> m_downloadableBuffers;
+ std::vector<HShader> m_dirtyShaders;
+ std::vector<HTexture> m_dirtyTextures;
+ std::vector<QPair<Texture::TextureUpdateInfo, Qt3DCore::QNodeIdVector>> m_updatedTextureProperties;
+ std::vector<Qt3DCore::QNodeId> m_updatedDisableSubtreeEnablers;
Qt3DCore::QNodeIdVector m_textureIdsToCleanup;
std::vector<ShaderBuilderUpdate> m_shaderBuilderUpdates;
diff --git a/src/plugins/renderers/rhi/renderer/renderqueue.cpp b/src/plugins/renderers/rhi/renderer/renderqueue.cpp
index 39eaddc9a..463e4cad8 100644
--- a/src/plugins/renderers/rhi/renderer/renderqueue.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderqueue.cpp
@@ -101,7 +101,7 @@ bool RenderQueue::queueRenderView(RenderView *renderView, uint submissionOrderIn
* A call to reset is required after rendering of the frame. Otherwise under some
* conditions the current but then invalidated frame queue could be reused.
*/
-QVector<RenderView *> RenderQueue::nextFrameQueue()
+const std::vector<RenderView *> &RenderQueue::nextFrameQueue()
{
return m_currentWorkQueue;
}
diff --git a/src/plugins/renderers/rhi/renderer/renderqueue_p.h b/src/plugins/renderers/rhi/renderer/renderqueue_p.h
index 3b6eec13d..515c1ce3e 100644
--- a/src/plugins/renderers/rhi/renderer/renderqueue_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderqueue_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QVector>
+#include <vector>
#include <QtGlobal>
#include <QMutex>
@@ -76,7 +76,7 @@ public:
bool isFrameQueueComplete() const;
bool queueRenderView(RenderView *renderView, uint submissionOrderIndex);
- QVector<RenderView *> nextFrameQueue();
+ const std::vector<RenderView *> &nextFrameQueue();
void reset();
void setNoRender();
@@ -91,7 +91,7 @@ private:
bool m_wasReset;
int m_targetRenderViewCount;
int m_currentRenderViewCount;
- QVector<RenderView *> m_currentWorkQueue;
+ std::vector<RenderView *> m_currentWorkQueue;
QMutex m_mutex;
};
diff --git a/src/plugins/renderers/rhi/renderer/renderview.cpp b/src/plugins/renderers/rhi/renderer/renderview.cpp
index 12f8d01a5..bab5fecfb 100644
--- a/src/plugins/renderers/rhi/renderer/renderview.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderview.cpp
@@ -408,7 +408,7 @@ void sortByMaterial(EntityRenderCommandDataView *view, int begin, const int end)
}
void sortCommandRange(EntityRenderCommandDataView *view, int begin, int end, const int level,
- const QVector<Qt3DRender::QSortPolicy::SortType> &sortingTypes)
+ const std::vector<Qt3DRender::QSortPolicy::SortType> &sortingTypes)
{
if (level >= sortingTypes.size())
return;
@@ -461,7 +461,7 @@ void RenderView::sort()
// We compute the adjacent change cost
// Only perform uniform minimization if we explicitly asked for it
- if (!m_sortingTypes.contains(QSortPolicy::Uniform))
+ if (!Qt3DCore::contains(m_sortingTypes, QSortPolicy::Uniform))
return;
// Minimize uniform changes
@@ -584,7 +584,7 @@ EntityRenderCommandData RenderView::buildDrawRenderCommands(const Entity **entit
const Qt3DCore::QNodeId materialComponentId = entity->componentUuid<Material>();
const HMaterial materialHandle = entity->componentHandle<Material>();
- const QVector<RenderPassParameterData> renderPassData =
+ const std::vector<RenderPassParameterData> renderPassData =
m_parameters.value(materialComponentId);
HGeometry geometryHandle =
@@ -729,7 +729,7 @@ EntityRenderCommandData RenderView::buildComputeRenderCommands(const Entity **en
&& computeJob->isEnabled()) {
const Qt3DCore::QNodeId materialComponentId = entity->componentUuid<Material>();
- const QVector<RenderPassParameterData> &renderPassData =
+ const std::vector<RenderPassParameterData> &renderPassData =
m_parameters.value(materialComponentId);
// 1 RenderCommand per RenderPass pass on an Entity with a Mesh
diff --git a/src/plugins/renderers/rhi/renderer/renderview_p.h b/src/plugins/renderers/rhi/renderer/renderview_p.h
index 172c330a4..9cdca9a3d 100644
--- a/src/plugins/renderers/rhi/renderer/renderview_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderview_p.h
@@ -73,7 +73,7 @@
// TODO: Move out once this is all refactored
#include <renderviewjobutils_p.h>
-#include <QVector>
+#include <vector>
#include <QSurface>
#include <QMutex>
#include <QColor>
@@ -185,10 +185,6 @@ public:
inline void appendProximityFilterId(const Qt3DCore::QNodeId proximityFilterId) { m_proximityFilterIds.push_back(proximityFilterId); }
inline Qt3DCore::QNodeIdVector proximityFilterIds() const { return m_proximityFilterIds; }
- inline void appendInsertFenceId(const Qt3DCore::QNodeId setFenceId) { m_insertFenceIds.push_back(setFenceId); }
- // We prefix with get to avoid confusion when it is called
- inline Qt3DCore::QNodeIdVector insertFenceIds() const { return m_insertFenceIds; }
-
inline void setRenderPassFilter(const RenderPassFilter *rpFilter) Q_DECL_NOTHROW { m_passFilter = rpFilter; }
inline const RenderPassFilter *renderPassFilter() const Q_DECL_NOTHROW { return m_passFilter; }
@@ -252,7 +248,7 @@ public:
void setRenderTargetId(Qt3DCore::QNodeId renderTargetId) Q_DECL_NOTHROW { m_renderTarget = renderTargetId; }
Qt3DCore::QNodeId renderTargetId() const Q_DECL_NOTHROW { return m_renderTarget; }
- void addSortType(const QVector<Qt3DRender::QSortPolicy::SortType> &sortTypes) { m_sortingTypes.append(sortTypes); }
+ void addSortType(const QVector<Qt3DRender::QSortPolicy::SortType> &sortTypes) { Qt3DCore::append(m_sortingTypes, sortTypes); }
void setSurface(QSurface *surface) { m_surface = surface; }
QSurface *surface() const { return m_surface; }
@@ -267,8 +263,6 @@ public:
inline void setRenderCaptureRequest(const QRenderCaptureRequest& request) Q_DECL_NOTHROW { m_renderCaptureRequest = request; }
inline const QRenderCaptureRequest renderCaptureRequest() const Q_DECL_NOTHROW { return m_renderCaptureRequest; }
- void setMemoryBarrier(QMemoryBarrier::Operations barrier) Q_DECL_NOTHROW { m_memoryBarrier = barrier; }
- QMemoryBarrier::Operations memoryBarrier() const Q_DECL_NOTHROW { return m_memoryBarrier; }
bool isDownloadBuffersEnable() const;
void setIsDownloadBuffersEnable(bool isDownloadBuffersEnable);
@@ -341,9 +335,7 @@ private:
bool m_frustumCulling = false;
bool m_showDebugOverlay = false;
int m_workGroups[3] = { 1, 1, 1};
- QMemoryBarrier::Operations m_memoryBarrier = QMemoryBarrier::None;
- QVector<Qt3DCore::QNodeId> m_insertFenceIds;
- QVector<Qt3DRender::QSortPolicy::SortType> m_sortingTypes;
+ std::vector<Qt3DRender::QSortPolicy::SortType> m_sortingTypes;
Qt3DCore::QNodeIdVector m_proximityFilterIds;
Qt3DCore::QNodeIdVector m_layerFilterIds;
Matrix4x4 m_viewMatrix;
diff --git a/src/plugins/renderers/rhi/renderer/rhishader.cpp b/src/plugins/renderers/rhi/renderer/rhishader.cpp
index acc16bba3..268d2fa75 100644
--- a/src/plugins/renderers/rhi/renderer/rhishader.cpp
+++ b/src/plugins/renderers/rhi/renderer/rhishader.cpp
@@ -39,6 +39,7 @@
#include "rhishader_p.h"
#include <QMutexLocker>
+#include <Qt3DCore/private/vector_helper_p.h>
#include <Qt3DRender/private/stringtoint_p.h>
#include <submissioncontext_p.h>
#include <logging_p.h>
@@ -57,37 +58,37 @@ RHIShader::RHIShader() : m_isLoaded(false)
m_shaderCode.resize(static_cast<int>(QShaderProgram::Compute) + 1);
}
-QVector<QString> RHIShader::uniformsNames() const
+const std::vector<QString> &RHIShader::uniformsNames() const
{
return m_uniformsNames;
}
-QVector<QString> RHIShader::attributesNames() const
+const std::vector<QString> &RHIShader::attributesNames() const
{
return m_attributesNames;
}
-QVector<QString> RHIShader::uniformBlockNames() const
+const std::vector<QString> &RHIShader::uniformBlockNames() const
{
return m_uniformBlockNames;
}
-QVector<QString> RHIShader::storageBlockNames() const
+const std::vector<QString> &RHIShader::storageBlockNames() const
{
return m_shaderStorageBlockNames;
}
-QVector<QString> RHIShader::samplerNames() const
+const std::vector<QString> &RHIShader::samplerNames() const
{
return m_samplerNames;
}
-QVector<QString> RHIShader::imagesNames() const
+const std::vector<QString> &RHIShader::imagesNames() const
{
return m_imageNames;
}
-QVector<QByteArray> RHIShader::shaderCode() const
+const std::vector<QByteArray> &RHIShader::shaderCode() const
{
return m_shaderCode;
}
@@ -258,9 +259,9 @@ static constexpr int rhiTypeSize(QShaderDescription::VariableType type)
}
template<typename T, typename Pred>
-QVector<T> stableRemoveDuplicates(QVector<T> in, Pred predicate)
+std::vector<T> stableRemoveDuplicates(std::vector<T> in, Pred predicate)
{
- QVector<T> out;
+ std::vector<T> out;
for (const auto &element : in) {
if (std::none_of(out.begin(), out.end(),
[&](T &other) { return predicate(element, other); }))
@@ -335,8 +336,8 @@ void RHIShader::recordAllUniforms(const QShaderDescription::BlockVariable &membe
m_unqualifiedUniformNames << fullMemberName;
if (isStruct && !isArray) {
- m_structNames << fullMemberName;
- m_structNamesIds << StringToInt::lookupId(fullMemberName);
+ m_structNames.push_back(fullMemberName);
+ m_structNamesIds.push_back(StringToInt::lookupId(fullMemberName));
for (const QShaderDescription::BlockVariable& bv : member.structMembers) {
// recordAllUniforms("baz", "foo.bar.")
@@ -354,8 +355,8 @@ void RHIShader::recordAllUniforms(const QShaderDescription::BlockVariable &membe
else if (isStruct && isArray) {
// Record the struct names
forEachArrayAccessor(member.arrayDims, [&] (const QString& str) {
- m_structNames << (fullMemberName + str);
- m_structNamesIds << StringToInt::lookupId(m_structNames.back());
+ m_structNames.push_back(fullMemberName + str);
+ m_structNamesIds.push_back(StringToInt::lookupId(m_structNames.back()));
});
// Record the struct members
@@ -387,14 +388,14 @@ bool isGeneratedUBOName(const QByteArray& arr)
void RHIShader::introspect()
{
- QVector<QShaderDescription::UniformBlock> rhiUBO;
- QVector<QShaderDescription::StorageBlock> rhiSSBO;
+ std::vector<QShaderDescription::UniformBlock> rhiUBO;
+ std::vector<QShaderDescription::StorageBlock> rhiSSBO;
- QVector<ShaderUniformBlock> uniformBlocks;
- QVector<ShaderStorageBlock> storageBlocks;
- QVector<ShaderAttribute> attributes;
- QVector<ShaderAttribute> samplers;
- QVector<ShaderAttribute> images;
+ std::vector<ShaderUniformBlock> uniformBlocks;
+ std::vector<ShaderStorageBlock> storageBlocks;
+ std::vector<ShaderAttribute> attributes;
+ std::vector<ShaderAttribute> samplers;
+ std::vector<ShaderAttribute> images;
// Introspect shader vertex input
if (m_stages[QShader::VertexStage].isValid()) {
@@ -406,8 +407,8 @@ void RHIShader::introspect()
input.location });
}
- rhiUBO += vtx.uniformBlocks();
- rhiSSBO += vtx.storageBlocks();
+ Qt3DCore::append(rhiUBO, vtx.uniformBlocks());
+ Qt3DCore::append(rhiSSBO, vtx.storageBlocks());
}
// Introspect shader uniforms
@@ -425,8 +426,8 @@ void RHIShader::introspect()
image.binding });
}
- rhiUBO += frag.uniformBlocks();
- rhiSSBO += frag.storageBlocks();
+ Qt3DCore::append(rhiUBO, frag.uniformBlocks());
+ Qt3DCore::append(rhiSSBO, frag.storageBlocks());
}
rhiUBO = stableRemoveDuplicates(rhiUBO,
@@ -448,19 +449,15 @@ void RHIShader::introspect()
// Parse Uniform Block members so that we can later on map a Parameter name to an actual
// member
- const QVector<QShaderDescription::BlockVariable> members = ubo.members;
+ m_uniformsNamesIds.reserve(m_uniformsNamesIds.size() + ubo.members.size());
- QVector<int> namesIds;
- namesIds.reserve(members.size());
-
- for (const QShaderDescription::BlockVariable &member : members) {
- namesIds << StringToInt::lookupId(member.name);
+ for (const QShaderDescription::BlockVariable &member : qAsConst(ubo.members)) {
+ m_uniformsNamesIds.push_back(StringToInt::lookupId(member.name));
if (addUnqualifiedUniforms) {
recordAllUniforms(member, QStringLiteral(""));
}
}
- m_uniformsNamesIds += namesIds;
- m_uboMembers.push_back({ uniformBlocks.last(), members });
+ m_uboMembers.push_back(UBO_Member{ uniformBlocks.back(), ubo.members });
}
for (const QShaderDescription::StorageBlock &ssbo : rhiSSBO) {
@@ -538,20 +535,20 @@ ShaderStorageBlock RHIShader::storageBlockForBlockName(const QString &blockName)
RHIShader::ParameterKind RHIShader::categorizeVariable(int nameId) const noexcept
{
- if (m_uniformsNamesIds.contains(nameId))
+ if (Qt3DCore::contains(m_uniformsNamesIds, nameId))
return ParameterKind::Uniform;
- else if (m_uniformBlockNamesIds.contains(nameId))
+ else if (Qt3DCore::contains(m_uniformBlockNamesIds, nameId))
return ParameterKind::UBO;
- else if (m_shaderStorageBlockNamesIds.contains(nameId))
+ else if (Qt3DCore::contains(m_shaderStorageBlockNamesIds, nameId))
return ParameterKind::SSBO;
- else if (m_structNamesIds.contains(nameId))
+ else if (Qt3DCore::contains(m_structNamesIds, nameId))
return ParameterKind::Struct;
return ParameterKind::Uniform;
}
bool RHIShader::hasUniform(int nameId) const noexcept
{
- return m_uniformsNamesIds.contains(nameId);
+ return Qt3DCore::contains(m_uniformsNamesIds, nameId);
}
bool RHIShader::hasActiveVariables() const noexcept
@@ -560,8 +557,15 @@ bool RHIShader::hasActiveVariables() const noexcept
|| !m_uniformBlockNamesIds.empty() || !m_shaderStorageBlockNamesIds.empty();
}
+void RHIShader::setShaderCode(const std::vector<QByteArray> &shaderCode)
+{
+ m_shaderCode.clear();
+ Qt3DCore::append(m_shaderCode, shaderCode);
+}
+
void RHIShader::prepareUniforms(ShaderParameterPack &pack)
{
+
const PackUniformHash &values = pack.uniforms();
auto it = values.keys.cbegin();
@@ -600,7 +604,7 @@ const QHash<QString, int> RHIShader::fragOutputs() const
return m_fragOutputs;
}
-void RHIShader::initializeAttributes(const QVector<ShaderAttribute> &attributesDescription)
+void RHIShader::initializeAttributes(const std::vector<ShaderAttribute> &attributesDescription)
{
m_attributes = attributesDescription;
m_attributesNames.resize(attributesDescription.size());
@@ -613,7 +617,7 @@ void RHIShader::initializeAttributes(const QVector<ShaderAttribute> &attributesD
}
}
-void RHIShader::initializeSamplers(const QVector<ShaderAttribute> &samplersDescription)
+void RHIShader::initializeSamplers(const std::vector<ShaderAttribute> &samplersDescription)
{
m_samplers = samplersDescription;
m_samplerNames.resize(samplersDescription.size());
@@ -626,7 +630,7 @@ void RHIShader::initializeSamplers(const QVector<ShaderAttribute> &samplersDescr
}
}
-void RHIShader::initializeImages(const QVector<ShaderAttribute> &imagesDescription)
+void RHIShader::initializeImages(const std::vector<ShaderAttribute> &imagesDescription)
{
m_images = imagesDescription;
m_imageNames.resize(imagesDescription.size());
@@ -639,7 +643,7 @@ void RHIShader::initializeImages(const QVector<ShaderAttribute> &imagesDescripti
}
}
-void RHIShader::initializeUniformBlocks(const QVector<ShaderUniformBlock> &uniformBlockDescription)
+void RHIShader::initializeUniformBlocks(const std::vector<ShaderUniformBlock> &uniformBlockDescription)
{
m_uniformBlocks = uniformBlockDescription;
m_uniformBlockNames.resize(uniformBlockDescription.size());
@@ -651,11 +655,11 @@ void RHIShader::initializeUniformBlocks(const QVector<ShaderUniformBlock> &unifo
qCDebug(Shaders) << "Initializing Uniform Block {" << m_uniformBlockNames[i] << "}";
// Find all active uniforms for the shader block
- QVector<ShaderUniform>::const_iterator uniformsIt = m_uniforms.cbegin();
- const QVector<ShaderUniform>::const_iterator uniformsEnd = m_uniforms.cend();
+ std::vector<ShaderUniform>::const_iterator uniformsIt = m_uniforms.cbegin();
+ const std::vector<ShaderUniform>::const_iterator uniformsEnd = m_uniforms.cend();
- QVector<QString>::const_iterator uniformNamesIt = m_uniformsNames.cbegin();
- const QVector<QString>::const_iterator uniformNamesEnd = m_attributesNames.cend();
+ std::vector<QString>::const_iterator uniformNamesIt = m_uniformsNames.cbegin();
+ const std::vector<QString>::const_iterator uniformNamesEnd = m_attributesNames.cend();
QHash<QString, ShaderUniform> activeUniformsInBlock;
@@ -679,7 +683,7 @@ void RHIShader::initializeUniformBlocks(const QVector<ShaderUniformBlock> &unifo
}
void RHIShader::initializeShaderStorageBlocks(
- const QVector<ShaderStorageBlock> &shaderStorageBlockDescription)
+ const std::vector<ShaderStorageBlock> &shaderStorageBlockDescription)
{
m_shaderStorageBlocks = shaderStorageBlockDescription;
m_shaderStorageBlockNames.resize(shaderStorageBlockDescription.size());
diff --git a/src/plugins/renderers/rhi/renderer/rhishader_p.h b/src/plugins/renderers/rhi/renderer/rhishader_p.h
index 774dcbdb0..ba2b3293c 100644
--- a/src/plugins/renderers/rhi/renderer/rhishader_p.h
+++ b/src/plugins/renderers/rhi/renderer/rhishader_p.h
@@ -85,25 +85,25 @@ public:
void setFragOutputs(const QHash<QString, int> &fragOutputs);
const QHash<QString, int> fragOutputs() const;
- inline QVector<int> uniformsNamesIds() const { return m_uniformsNamesIds; }
- inline QVector<int> standardUniformNameIds() const { return m_standardUniformNamesIds; }
- inline QVector<int> uniformBlockNamesIds() const { return m_uniformBlockNamesIds; }
- inline QVector<int> storageBlockNamesIds() const { return m_shaderStorageBlockNamesIds; }
- inline QVector<int> attributeNamesIds() const { return m_attributeNamesIds; }
-
- QVector<QString> uniformsNames() const;
- QVector<QString> attributesNames() const;
- QVector<QString> uniformBlockNames() const;
- QVector<QString> storageBlockNames() const;
- QVector<QString> samplerNames() const;
- QVector<QString> imagesNames() const;
-
- inline QVector<ShaderUniform> uniforms() const { return m_uniforms; }
- inline QVector<ShaderAttribute> attributes() const { return m_attributes; }
- inline QVector<ShaderUniformBlock> uniformBlocks() const { return m_uniformBlocks; }
- inline QVector<ShaderStorageBlock> storageBlocks() const { return m_shaderStorageBlocks; }
- inline QVector<ShaderAttribute> samplers() const { return m_samplers; }
- inline QVector<ShaderAttribute> images() const { return m_images; }
+ inline const std::vector<int> &uniformsNamesIds() const { return m_uniformsNamesIds; }
+ inline const std::vector<int> &standardUniformNameIds() const { return m_standardUniformNamesIds; }
+ inline const std::vector<int> &uniformBlockNamesIds() const { return m_uniformBlockNamesIds; }
+ inline const std::vector<int> &storageBlockNamesIds() const { return m_shaderStorageBlockNamesIds; }
+ inline const std::vector<int> &attributeNamesIds() const { return m_attributeNamesIds; }
+
+ const std::vector<QString> &uniformsNames() const;
+ const std::vector<QString> &attributesNames() const;
+ const std::vector<QString> &uniformBlockNames() const;
+ const std::vector<QString> &storageBlockNames() const;
+ const std::vector<QString> &samplerNames() const;
+ const std::vector<QString> &imagesNames() const;
+
+ inline const std::vector<ShaderUniform> &uniforms() const { return m_uniforms; }
+ inline const std::vector<ShaderAttribute> &attributes() const { return m_attributes; }
+ inline const std::vector<ShaderUniformBlock> &uniformBlocks() const { return m_uniformBlocks; }
+ inline const std::vector<ShaderStorageBlock> &storageBlocks() const { return m_shaderStorageBlocks; }
+ inline const std::vector<ShaderAttribute> &samplers() const { return m_samplers; }
+ inline const std::vector<ShaderAttribute> &images() const { return m_images; }
QHash<QString, ShaderUniform> activeUniformsForUniformBlock(int blockIndex) const;
@@ -121,11 +121,11 @@ public:
bool hasUniform(int nameId) const noexcept;
bool hasActiveVariables() const noexcept;
- void setShaderCode(const QVector<QByteArray> shaderCode) { m_shaderCode = shaderCode; }
- QVector<QByteArray> shaderCode() const;
+ void setShaderCode(const std::vector<QByteArray> &shaderCode);
+ const std::vector<QByteArray> &shaderCode() const;
const QShader &shaderStage(QShader::Stage stage) const noexcept { return m_stages[stage]; }
- QVector<UBO_Member> uboMembers() const { return m_uboMembers; }
+ std::vector<UBO_Member> uboMembers() const { return m_uboMembers; }
const QSet<QString> &unqualifiedUniformNames() const noexcept
{
@@ -138,50 +138,50 @@ private:
bool m_isLoaded;
QShader m_stages[6];
- QVector<QString> m_uniformsNames;
- QVector<int> m_uniformsNamesIds;
- QVector<int> m_standardUniformNamesIds;
- QVector<ShaderUniform> m_uniforms;
+ std::vector<QString> m_uniformsNames;
+ std::vector<int> m_uniformsNamesIds;
+ std::vector<int> m_standardUniformNamesIds;
+ std::vector<ShaderUniform> m_uniforms;
- QVector<QString> m_attributesNames;
- QVector<int> m_attributeNamesIds;
- QVector<ShaderAttribute> m_attributes;
+ std::vector<QString> m_attributesNames;
+ std::vector<int> m_attributeNamesIds;
+ std::vector<ShaderAttribute> m_attributes;
- QVector<QString> m_uniformBlockNames;
- QVector<int> m_uniformBlockNamesIds;
- QVector<ShaderUniformBlock> m_uniformBlocks;
+ std::vector<QString> m_uniformBlockNames;
+ std::vector<int> m_uniformBlockNamesIds;
+ std::vector<ShaderUniformBlock> m_uniformBlocks;
QHash<int, QHash<QString, ShaderUniform>> m_uniformBlockIndexToShaderUniforms;
QSet<QString> m_unqualifiedUniformNames;
- QVector<QString> m_shaderStorageBlockNames;
- QVector<int> m_shaderStorageBlockNamesIds;
- QVector<ShaderStorageBlock> m_shaderStorageBlocks;
+ std::vector<QString> m_shaderStorageBlockNames;
+ std::vector<int> m_shaderStorageBlockNamesIds;
+ std::vector<ShaderStorageBlock> m_shaderStorageBlocks;
- QVector<QString> m_samplerNames;
- QVector<int> m_samplerIds;
- QVector<ShaderAttribute> m_samplers;
+ std::vector<QString> m_samplerNames;
+ std::vector<int> m_samplerIds;
+ std::vector<ShaderAttribute> m_samplers;
- QVector<QString> m_imageNames;
- QVector<int> m_imageIds;
- QVector<ShaderAttribute> m_images;
+ std::vector<QString> m_imageNames;
+ std::vector<int> m_imageIds;
+ std::vector<ShaderAttribute> m_images;
- QVector<QString> m_structNames;
- QVector<int> m_structNamesIds;
+ std::vector<QString> m_structNames;
+ std::vector<int> m_structNamesIds;
QHash<QString, int> m_fragOutputs;
- QVector<QByteArray> m_shaderCode;
+ std::vector<QByteArray> m_shaderCode;
// Private so that only SubmissionContext can call it
friend class SubmissionContext;
- void initializeAttributes(const QVector<ShaderAttribute> &attributesDescription);
- void initializeUniformBlocks(const QVector<ShaderUniformBlock> &uniformBlockDescription);
+ void initializeAttributes(const std::vector<ShaderAttribute> &attributesDescription);
+ void initializeUniformBlocks(const std::vector<ShaderUniformBlock> &uniformBlockDescription);
void
- initializeShaderStorageBlocks(const QVector<ShaderStorageBlock> &shaderStorageBlockDescription);
- void initializeSamplers(const QVector<ShaderAttribute> &samplerDescription);
- void initializeImages(const QVector<ShaderAttribute> &imageDescription);
+ initializeShaderStorageBlocks(const std::vector<ShaderStorageBlock> &shaderStorageBlockDescription);
+ void initializeSamplers(const std::vector<ShaderAttribute> &samplerDescription);
+ void initializeImages(const std::vector<ShaderAttribute> &imageDescription);
void recordAllUniforms(const QShaderDescription::BlockVariable &ubo, QString parentName);
- QVector<UBO_Member> m_uboMembers;
+ std::vector<UBO_Member> m_uboMembers;
mutable QMutex m_mutex;
QMetaObject::Connection m_contextConnection;
diff --git a/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h b/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h
index e285551b7..bd4798072 100644
--- a/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h
+++ b/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h
@@ -53,7 +53,7 @@
#include <QVariant>
#include <QByteArray>
-#include <QVector>
+#include <vector>
#include <QOpenGLShaderProgram>
#include <Qt3DCore/qnodeid.h>
#include <Qt3DRender/private/renderlogging_p.h>
diff --git a/src/plugins/renderers/rhi/textures/texture.cpp b/src/plugins/renderers/rhi/textures/texture.cpp
index a3606f369..2270d1ba6 100644
--- a/src/plugins/renderers/rhi/textures/texture.cpp
+++ b/src/plugins/renderers/rhi/textures/texture.cpp
@@ -43,6 +43,7 @@
#include <private/qdebug_p.h>
#include <private/qrhi_p.h>
#include <QDebug>
+#include <Qt3DCore/private/vector_helper_p.h>
#include <Qt3DRender/qtexture.h>
#include <Qt3DRender/qtexturedata.h>
#include <Qt3DRender/qtextureimagedata.h>
@@ -355,7 +356,7 @@ bool RHITexture::loadTextureDataFromGenerator()
m_properties.layers = m_textureData->layers();
m_properties.format = m_textureData->format();
- const QVector<QTextureImageDataPtr> imageData = m_textureData->imageData();
+ const QVector<QTextureImageDataPtr> &imageData = m_textureData->imageData();
if (!imageData.empty()) {
// Set the mips level based on the first image if autoMipMapGeneration is disabled
@@ -581,7 +582,7 @@ void RHITexture::setProperties(const TextureProperties &props)
}
}
-void RHITexture::setImages(const QVector<Image> &images)
+void RHITexture::setImages(const std::vector<Image> &images)
{
// check if something has changed at all
bool same = (images.size() == m_images.size());
@@ -618,7 +619,7 @@ void RHITexture::setSharedTextureId(int textureId)
void RHITexture::addTextureDataUpdates(const QVector<QTextureDataUpdate> &updates)
{
- m_pendingTextureDataUpdates += updates;
+ Qt3DCore::append(m_pendingTextureDataUpdates, updates);
requestUpload();
}
@@ -685,7 +686,7 @@ void RHITexture::uploadRhiTextureData(SubmissionContext *ctx)
// Upload all QTexImageData set by the QTextureGenerator
if (m_textureData) {
- const QVector<QTextureImageDataPtr> &imgData = m_textureData->imageData();
+ const auto &imgData = m_textureData->imageData();
for (const QTextureImageDataPtr &data : imgData) {
const int mipLevels = data->mipLevels();
@@ -722,7 +723,7 @@ void RHITexture::uploadRhiTextureData(SubmissionContext *ctx)
m_imageData.clear();
// Update data from TextureUpdates
- const QVector<QTextureDataUpdate> textureDataUpdates = std::move(m_pendingTextureDataUpdates);
+ const std::vector<QTextureDataUpdate> textureDataUpdates = std::move(m_pendingTextureDataUpdates);
for (const QTextureDataUpdate &update : textureDataUpdates) {
const QTextureImageDataPtr imgData = update.data();
diff --git a/src/plugins/renderers/rhi/textures/texture_p.h b/src/plugins/renderers/rhi/textures/texture_p.h
index c78bc1c1b..e2378e42b 100644
--- a/src/plugins/renderers/rhi/textures/texture_p.h
+++ b/src/plugins/renderers/rhi/textures/texture_p.h
@@ -137,7 +137,7 @@ public:
inline TextureParameters parameters() const { return m_parameters; }
inline QTextureGeneratorPtr textureGenerator() const { return m_dataFunctor; }
inline int sharedTextureId() const { return m_sharedTextureId; }
- inline QVector<Image> images() const { return m_images; }
+ inline const std::vector<Image> &images() const { return m_images; }
inline QSize size() const { return QSize(m_properties.width, m_properties.height); }
inline QRhiTexture *getRhiTexture() const { return m_rhi; }
@@ -176,7 +176,7 @@ public:
bool isDirty() const { return m_dirtyFlags != None; }
bool hasTextureData() const { return !m_textureData.isNull(); }
- bool hasImagesData() const { return !m_imageData.isEmpty(); }
+ bool hasImagesData() const { return !m_imageData.empty(); }
QFlags<DirtyFlag> dirtyFlags() const { return m_dirtyFlags; }
@@ -191,12 +191,12 @@ public:
void setParameters(const TextureParameters &params);
void setProperties(const TextureProperties &props);
- void setImages(const QVector<Image> &images);
+ void setImages(const std::vector<Image> &images);
void setGenerator(const QTextureGeneratorPtr &generator);
void setSharedTextureId(int textureId);
void addTextureDataUpdates(const QVector<QTextureDataUpdate> &updates);
- QVector<QTextureDataUpdate> textureDataUpdates() const { return m_pendingTextureDataUpdates; }
+ const std::vector<QTextureDataUpdate> &textureDataUpdates() const { return m_pendingTextureDataUpdates; }
QTextureGeneratorPtr dataGenerator() const { return m_dataFunctor; }
private:
@@ -228,12 +228,12 @@ private:
QTextureGeneratorPtr m_dataFunctor;
QTextureGenerator *m_pendingDataFunctor;
- QVector<Image> m_images;
+ std::vector<Image> m_images;
// cache actual image data generated by the functors
QTextureDataPtr m_textureData;
- QVector<QTextureImageDataPtr> m_imageData;
- QVector<QTextureDataUpdate> m_pendingTextureDataUpdates;
+ std::vector<QTextureImageDataPtr> m_imageData;
+ std::vector<QTextureDataUpdate> m_pendingTextureDataUpdates;
int m_sharedTextureId;
bool m_externalRendering;