diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2020-06-25 16:42:58 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2020-06-30 15:32:16 +0200 |
commit | 4a2ca889fa67a364c83e83ab931d0df0d41188e6 (patch) | |
tree | 38a2ea2a7eadcfa3dd188bb2ad459a0cae677fa5 | |
parent | 0a69fa7279e6f9bbc77483247c2742005675d6a8 (diff) |
Switch to std::vector in QRenderAspect backend and OpenGL renderer
Change-Id: I91dd69fc205401b12f333a9a0534d9612c8e24f8
Reviewed-by: Mike Krus <mike.krus@kdab.com>
27 files changed, 157 insertions, 134 deletions
diff --git a/src/plugins/renderers/opengl/jobs/renderviewcommandbuilderjob.cpp b/src/plugins/renderers/opengl/jobs/renderviewcommandbuilderjob.cpp index 9f253caa3..973aa7512 100644 --- a/src/plugins/renderers/opengl/jobs/renderviewcommandbuilderjob.cpp +++ b/src/plugins/renderers/opengl/jobs/renderviewcommandbuilderjob.cpp @@ -82,6 +82,7 @@ RenderViewCommandBuilderJob::RenderViewCommandBuilderJob() , m_offset(0) , m_count(0) , m_renderView(nullptr) + , m_entities(nullptr) { SET_JOB_RUN_STAT_TYPE(this, JobTypes::RenderViewCommandBuilder, renderViewInstanceCounter++) } diff --git a/src/plugins/renderers/opengl/jobs/renderviewcommandbuilderjob_p.h b/src/plugins/renderers/opengl/jobs/renderviewcommandbuilderjob_p.h index 52c055285..610b396d9 100644 --- a/src/plugins/renderers/opengl/jobs/renderviewcommandbuilderjob_p.h +++ b/src/plugins/renderers/opengl/jobs/renderviewcommandbuilderjob_p.h @@ -71,7 +71,7 @@ public: RenderViewCommandBuilderJob(); inline void setRenderView(RenderView *rv) Q_DECL_NOTHROW { m_renderView = rv; } - inline void setEntities(const QVector<Entity *> &entities, int offset, int count) + inline void setEntities(const Entity **entities, int offset, int count) { m_offset = offset; m_count = count; @@ -85,7 +85,7 @@ private: int m_offset; int m_count; RenderView *m_renderView; - QVector<Entity *> m_entities; + const Entity **m_entities; EntityRenderCommandData m_commandData; Q_DECLARE_PRIVATE(RenderViewCommandBuilderJob) diff --git a/src/plugins/renderers/opengl/renderer/rendercommand_p.h b/src/plugins/renderers/opengl/renderer/rendercommand_p.h index a2305ecdf..344dc426b 100644 --- a/src/plugins/renderers/opengl/renderer/rendercommand_p.h +++ b/src/plugins/renderers/opengl/renderer/rendercommand_p.h @@ -146,7 +146,7 @@ inline bool operator!=(const RenderCommand &lhs, const RenderCommand &rhs) noexc struct EntityRenderCommandData { - std::vector<Entity *> entities; + std::vector<const Entity *> entities; std::vector<RenderCommand> commands; std::vector<RenderPassParameterData> passesData; @@ -159,14 +159,14 @@ struct EntityRenderCommandData inline size_t size() const { return entities.size(); } - inline void push_back(Entity *e, const RenderCommand &c, const RenderPassParameterData &p) + inline void push_back(const Entity *e, const RenderCommand &c, const RenderPassParameterData &p) { entities.push_back(e); commands.push_back(c); passesData.push_back(p); } - inline void push_back(Entity *e, RenderCommand &&c, RenderPassParameterData &&p) + inline void push_back(const Entity *e, RenderCommand &&c, RenderPassParameterData &&p) { entities.push_back(e); commands.push_back(std::move(c)); diff --git a/src/plugins/renderers/opengl/renderer/renderer.cpp b/src/plugins/renderers/opengl/renderer/renderer.cpp index 17c73ddba..cfe7acc39 100644 --- a/src/plugins/renderers/opengl/renderer/renderer.cpp +++ b/src/plugins/renderers/opengl/renderer/renderer.cpp @@ -150,7 +150,12 @@ public: { LightGatherer::run(); - m_cache->gatheredLights = lights(); + m_cache->gatheredLights = std::move(lights()); + std::sort(m_cache->gatheredLights.begin(), m_cache->gatheredLights.end(), + [] (const LightSource &a, const LightSource &b) { + return a.entity < b.entity; + }); + m_cache->environmentLight = environmentLight(); } @@ -171,10 +176,10 @@ public: { RenderableEntityFilter::run(); - QVector<Entity *> selectedEntities = filteredEntities(); + std::vector<Entity *> selectedEntities = std::move(filteredEntities()); std::sort(selectedEntities.begin(), selectedEntities.end()); - m_cache->renderableEntities = selectedEntities; + m_cache->renderableEntities = std::move(selectedEntities); } private: @@ -194,10 +199,10 @@ public: { ComputableEntityFilter::run(); - QVector<Entity *> selectedEntities = filteredEntities(); + std::vector<Entity *> selectedEntities = std::move(filteredEntities()); std::sort(selectedEntities.begin(), selectedEntities.end()); - m_cache->computeEntities = selectedEntities; + m_cache->computeEntities = std::move(selectedEntities); } private: @@ -1618,7 +1623,7 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren // if there are ClearColors set for different draw buffers, // clear each of these draw buffers individually now - const QVector<ClearBufferInfo> clearDrawBuffers = renderView->specificClearColorBufferInfo(); + const std::vector<ClearBufferInfo> &clearDrawBuffers = renderView->specificClearColorBufferInfo(); for (const ClearBufferInfo &clearBuffer : clearDrawBuffers) m_submissionContext->clearBufferf(clearBuffer.drawBufferIndex, clearBuffer.clearColor); } diff --git a/src/plugins/renderers/opengl/renderer/renderercache_p.h b/src/plugins/renderers/opengl/renderer/renderercache_p.h index 15dffbd44..825c96e83 100644 --- a/src/plugins/renderers/opengl/renderer/renderercache_p.h +++ b/src/plugins/renderers/opengl/renderer/renderercache_p.h @@ -73,7 +73,7 @@ struct RendererCache Matrix4x4 viewProjectionMatrix; // Set by the FilterLayerJob // Contains all Entities that satisfy the layer filtering for the RV - QVector<Entity *> filterEntitiesByLayer; + std::vector<Entity *> filterEntitiesByLayer; // Set by the MaterialParameterGatherJob MaterialParameterGathererData materialParameterGatherer; @@ -81,9 +81,9 @@ struct RendererCache // Set by the SyncRenderViewPreCommandUpdateJob // Contains caches of different filtering stages that can // be cached across frame - QVector<Entity *> layeredFilteredRenderables; // Changes rarely - QVector<Entity *> filteredAndCulledRenderables; // Changes if camera is modified - QVector<LightSource> layeredFilteredLightSources; + std::vector<Entity *> layeredFilteredRenderables; // Changes rarely + std::vector<Entity *> filteredAndCulledRenderables; // Changes if camera is modified + std::vector<LightSource> layeredFilteredLightSources; // Cache of RenderCommands EntityRenderCommandDataViewPtr filteredRenderCommandDataViews; @@ -92,13 +92,13 @@ struct RendererCache // Variabled below are shared amongst all RV // Set by CachingRenderableEntityFilterJob - QVector<Entity *> renderableEntities; + std::vector<Entity *> renderableEntities; // Set by CachingComputableEntityFilterJob - QVector<Entity *> computeEntities; + std::vector<Entity *> computeEntities; // Set by CachingLightGathererJob - QVector<LightSource> gatheredLights; + std::vector<LightSource> gatheredLights; EnvironmentLight* environmentLight; diff --git a/src/plugins/renderers/opengl/renderer/renderview.cpp b/src/plugins/renderers/opengl/renderer/renderview.cpp index 70e3707c3..84fd075e2 100644 --- a/src/plugins/renderers/opengl/renderer/renderview.cpp +++ b/src/plugins/renderers/opengl/renderer/renderview.cpp @@ -631,7 +631,7 @@ void RenderView::addClearBuffers(const ClearBuffers *cb) { } // If we are there, we know that entity had a GeometryRenderer + Material -EntityRenderCommandData RenderView::buildDrawRenderCommands(const QVector<Entity *> &entities, +EntityRenderCommandData RenderView::buildDrawRenderCommands(const Entity **entities, int offset, int count) const { GLShaderManager *glShaderManager = m_renderer->glResourceManagers()->glShaderManager(); @@ -641,7 +641,7 @@ EntityRenderCommandData RenderView::buildDrawRenderCommands(const QVector<Entity for (int i = 0; i < count; ++i) { const int idx = offset + i; - Entity *entity = entities.at(idx); + const Entity *entity = entities[idx]; GeometryRenderer *geometryRenderer = nullptr; HGeometryRenderer geometryRendererHandle = entity->componentHandle<GeometryRenderer>(); @@ -760,7 +760,7 @@ EntityRenderCommandData RenderView::buildDrawRenderCommands(const QVector<Entity return commands; } -EntityRenderCommandData RenderView::buildComputeRenderCommands(const QVector<Entity *> &entities, +EntityRenderCommandData RenderView::buildComputeRenderCommands(const Entity **entities, int offset, int count) const { // If the RenderView contains only a ComputeDispatch then it cares about @@ -775,7 +775,7 @@ EntityRenderCommandData RenderView::buildComputeRenderCommands(const QVector<Ent for (int i = 0; i < count; ++i) { const int idx = offset + i; - Entity *entity = entities.at(idx); + const Entity *entity = entities[idx]; ComputeCommand *computeJob = nullptr; HComputeCommand computeCommandHandle = entity->componentHandle<ComputeCommand>(); if ((computeJob = nodeManagers()->computeJobManager()->data(computeCommandHandle)) != nullptr @@ -1102,7 +1102,7 @@ void RenderView::updateLightUniforms(RenderCommand *command, const Entity *entit // For now decide based on the distance by taking the MAX_LIGHTS closest lights. // Replace with more sophisticated mechanisms later. // Copy vector so that we can sort it concurrently and we only want to sort the one for the current command - QVector<LightSource> lightSources = m_lightSources; + std::vector<LightSource> lightSources = m_lightSources; if (lightSources.size() > 1) { const Vector3D entityCenter = entity->worldBoundingVolume()->center(); @@ -1112,14 +1112,14 @@ void RenderView::updateLightUniforms(RenderCommand *command, const Entity *entit const float distB = entityCenter.distanceToPoint(b.entity->worldBoundingVolume()->center()); return distA < distB; }); + m_lightSources = {lightSources.begin(), lightSources.begin() + std::min(lightSources.size(), size_t(MAX_LIGHTS)) }; } - m_lightSources = lightSources.mid(0, std::min(lightSources.size(), MAX_LIGHTS)); int lightIdx = 0; - for (const LightSource &lightSource : qAsConst(m_lightSources)) { + for (const LightSource &lightSource : m_lightSources) { if (lightIdx == MAX_LIGHTS) break; - Entity *lightEntity = lightSource.entity; + const Entity *lightEntity = lightSource.entity; const Matrix4x4 lightWorldTransform = *(lightEntity->worldTransform()); const Vector3D worldPos = lightWorldTransform * Vector3D(0.0f, 0.0f, 0.0f); for (Light *light : lightSource.lights) { @@ -1149,7 +1149,7 @@ void RenderView::updateLightUniforms(RenderCommand *command, const Entity *entit // There is no risk in doing that even if multithreaded // since we are sure that a shaderData is unique for a given light // and won't ever be referenced as a Component either - Matrix4x4 *worldTransform = lightEntity->worldTransform(); + const Matrix4x4 *worldTransform = lightEntity->worldTransform(); if (worldTransform) shaderData->updateWorldTransform(*worldTransform); @@ -1162,7 +1162,7 @@ void RenderView::updateLightUniforms(RenderCommand *command, const Entity *entit setUniformValue(command->m_parameterPack, GLLights::LIGHT_COUNT_NAME_ID, UniformValue(qMax((m_environmentLight ? 0 : 1), lightIdx))); // If no active light sources and no environment light, add a default light - if (m_lightSources.isEmpty() && !m_environmentLight) { + if (m_lightSources.empty() && !m_environmentLight) { // Note: implicit conversion of values to UniformValue if (lightUniformNamesIds.contains(GLLights::LIGHT_TYPE_NAMES[0])) { setUniformValue(command->m_parameterPack, GLLights::LIGHT_POSITION_NAMES[0], Vector3D(10.0f, 10.0f, 0.0f)); diff --git a/src/plugins/renderers/opengl/renderer/renderview_p.h b/src/plugins/renderers/opengl/renderer/renderview_p.h index 992e5acd1..ad8c868a4 100644 --- a/src/plugins/renderers/opengl/renderer/renderview_p.h +++ b/src/plugins/renderers/opengl/renderer/renderview_p.h @@ -209,8 +209,8 @@ public: // color ClearBuffers are collected, as there may be multiple // color buffers to be cleared. we need to apply all these at rendering void addClearBuffers(const ClearBuffers *cb); - inline QVector<ClearBufferInfo> specificClearColorBufferInfo() const { return m_specificClearColorBuffers; } - inline QVector<ClearBufferInfo> &specificClearColorBufferInfo() { return m_specificClearColorBuffers; } + inline const std::vector<ClearBufferInfo> &specificClearColorBufferInfo() const { return m_specificClearColorBuffers; } + inline std::vector<ClearBufferInfo> &specificClearColorBufferInfo() { return m_specificClearColorBuffers; } inline ClearBufferInfo globalClearColorBufferInfo() const { return m_globalClearColorBuffer; } inline QClearBuffers::BufferTypeFlags clearTypes() const { return m_clearBuffer; } @@ -219,9 +219,9 @@ public: RenderPassList passesAndParameters(ParameterInfoList *parameter, Entity *node, bool useDefaultMaterials = true); - EntityRenderCommandData buildDrawRenderCommands(const QVector<Entity *> &entities, + EntityRenderCommandData buildDrawRenderCommands(const Entity **entities, int offset, int count) const; - EntityRenderCommandData buildComputeRenderCommands(const QVector<Entity *> &entities, + EntityRenderCommandData buildComputeRenderCommands(const Entity **entities, int offset, int count) const; void updateRenderCommand(const EntityRenderCommandDataSubView &subView); @@ -237,7 +237,7 @@ public: void setSurface(QSurface *surface) { m_surface = surface; } QSurface *surface() const { return m_surface; } - void setLightSources(const QVector<LightSource> &lightSources) Q_DECL_NOTHROW { m_lightSources = lightSources; } + void setLightSources(const std::vector<LightSource> &lightSources) Q_DECL_NOTHROW { m_lightSources = lightSources; } void setEnvironmentLight(EnvironmentLight *environmentLight) Q_DECL_NOTHROW { m_environmentLight = environmentLight; } void updateMatrices(); @@ -310,7 +310,7 @@ private: float m_clearDepthValue = 1.0f; int m_clearStencilValue = 0; ClearBufferInfo m_globalClearColorBuffer; // global ClearColor - QVector<ClearBufferInfo> m_specificClearColorBuffers; // different draw buffers with distinct colors + std::vector<ClearBufferInfo> m_specificClearColorBuffers; // different draw buffers with distinct colors QScopedPointer<RenderStateSet> m_stateSet; CameraLens *m_renderCameraLens = nullptr; @@ -334,7 +334,7 @@ private: Vector3D m_eyeViewDir; MaterialParameterGathererData m_parameters; - mutable QVector<LightSource> m_lightSources; + mutable std::vector<LightSource> m_lightSources; EnvironmentLight *m_environmentLight = nullptr; enum StandardUniform diff --git a/src/plugins/renderers/opengl/renderer/renderviewbuilder.cpp b/src/plugins/renderers/opengl/renderer/renderviewbuilder.cpp index 990b6abf4..2206a0063 100644 --- a/src/plugins/renderers/opengl/renderer/renderviewbuilder.cpp +++ b/src/plugins/renderers/opengl/renderer/renderviewbuilder.cpp @@ -63,7 +63,7 @@ class SyncPreCommandBuilding { public: explicit SyncPreCommandBuilding(RenderViewInitializerJobPtr renderViewInitializerJob, - const QVector<RenderViewCommandBuilderJobPtr> &renderViewCommandBuilderJobs, + const std::vector<RenderViewCommandBuilderJobPtr> &renderViewCommandBuilderJobs, Renderer *renderer, FrameGraphNode *leafNode) : m_renderViewInitializer(renderViewInitializerJob) @@ -84,7 +84,7 @@ public: // The cache leaf should already have been created so we don't need to protect the access const RendererCache::LeafNodeData &dataCacheForLeaf = cache->leafNodeCache[m_leafNode]; RenderView *rv = m_renderViewInitializer->renderView(); - const auto entities = !rv->isCompute() ? cache->renderableEntities : cache->computeEntities; + const auto &entities = !rv->isCompute() ? cache->renderableEntities : cache->computeEntities; rv->setMaterialParameterTable(dataCacheForLeaf.materialParameterGatherer); @@ -95,16 +95,17 @@ public: // Try to split work into an ideal number of workers const int m = findIdealNumberOfWorkers(entityCount, idealPacketSize, jobCount); + const Entity **entitiesPtr = const_cast<const Entity **>(entities.data()); for (int i = 0; i < m; ++i) { const RenderViewCommandBuilderJobPtr renderViewCommandBuilder = m_renderViewCommandBuilderJobs.at(i); const int count = (i == m - 1) ? entityCount - (i * idealPacketSize) : idealPacketSize; - renderViewCommandBuilder->setEntities(entities, i * idealPacketSize, count); + renderViewCommandBuilder->setEntities(entitiesPtr, i * idealPacketSize, count); } } private: RenderViewInitializerJobPtr m_renderViewInitializer; - QVector<RenderViewCommandBuilderJobPtr> m_renderViewCommandBuilderJobs; + std::vector<RenderViewCommandBuilderJobPtr> m_renderViewCommandBuilderJobs; Renderer *m_renderer; FrameGraphNode *m_leafNode; }; @@ -113,9 +114,8 @@ class SyncRenderViewPostCommandUpdate { public: explicit SyncRenderViewPostCommandUpdate(const RenderViewInitializerJobPtr &renderViewJob, - const QVector<RenderViewCommandUpdaterJobPtr> &renderViewCommandUpdateJobs, - Renderer *renderer, - FrameGraphNode *leafNode) + const std::vector<RenderViewCommandUpdaterJobPtr> &renderViewCommandUpdateJobs, + Renderer *renderer) : m_renderViewJob(renderViewJob) , m_renderViewCommandUpdaterJobs(renderViewCommandUpdateJobs) , m_renderer(renderer) @@ -136,7 +136,7 @@ public: private: RenderViewInitializerJobPtr m_renderViewJob; - QVector<RenderViewCommandUpdaterJobPtr> m_renderViewCommandUpdaterJobs; + std::vector<RenderViewCommandUpdaterJobPtr> m_renderViewCommandUpdaterJobs; Renderer *m_renderer; }; @@ -172,9 +172,9 @@ public: const FrustumCullingJobPtr &frustumCullingJob, const FilterLayerEntityJobPtr &filterEntityByLayerJob, const FilterProximityDistanceJobPtr &filterProximityJob, - const QVector<MaterialParameterGathererJobPtr> &materialGathererJobs, - const QVector<RenderViewCommandUpdaterJobPtr> &renderViewCommandUpdaterJobs, - const QVector<RenderViewCommandBuilderJobPtr> &renderViewCommandBuilderJobs) + const std::vector<MaterialParameterGathererJobPtr> &materialGathererJobs, + const std::vector<RenderViewCommandUpdaterJobPtr> &renderViewCommandUpdaterJobs, + const std::vector<RenderViewCommandBuilderJobPtr> &renderViewCommandBuilderJobs) : m_renderViewJob(renderViewJob) , m_frustumCullingJob(frustumCullingJob) , m_filterEntityByLayerJob(filterEntityByLayerJob) @@ -216,9 +216,9 @@ private: FrustumCullingJobPtr m_frustumCullingJob; FilterLayerEntityJobPtr m_filterEntityByLayerJob; FilterProximityDistanceJobPtr m_filterProximityJob; - QVector<MaterialParameterGathererJobPtr> m_materialGathererJobs; - QVector<RenderViewCommandUpdaterJobPtr> m_renderViewCommandUpdaterJobs; - QVector<RenderViewCommandBuilderJobPtr> m_renderViewCommandBuilderJobs; + std::vector<MaterialParameterGathererJobPtr> m_materialGathererJobs; + std::vector<RenderViewCommandUpdaterJobPtr> m_renderViewCommandUpdaterJobs; + std::vector<RenderViewCommandBuilderJobPtr> m_renderViewCommandBuilderJobs; }; class SyncRenderViewPreCommandUpdate @@ -227,9 +227,9 @@ public: explicit SyncRenderViewPreCommandUpdate(const RenderViewInitializerJobPtr &renderViewJob, const FrustumCullingJobPtr &frustumCullingJob, const FilterProximityDistanceJobPtr &filterProximityJob, - const QVector<MaterialParameterGathererJobPtr> &materialGathererJobs, - const QVector<RenderViewCommandUpdaterJobPtr> &renderViewCommandUpdaterJobs, - const QVector<RenderViewCommandBuilderJobPtr> &renderViewCommandBuilderJobs, + const std::vector<MaterialParameterGathererJobPtr> &materialGathererJobs, + const std::vector<RenderViewCommandUpdaterJobPtr> &renderViewCommandUpdaterJobs, + const std::vector<RenderViewCommandBuilderJobPtr> &renderViewCommandBuilderJobs, Renderer *renderer, FrameGraphNode *leafNode, RebuildFlagSet rebuildFlags) @@ -317,15 +317,22 @@ public: // Should be fairly infrequent if (lightsCacheRebuild) { - // Filter out renderable entities that weren't selected by the + // Filter out light sources that weren't selected by the // layer filters and store that in cache - const QVector<Entity *> &layeredFilteredEntities = cacheForLeaf.filterEntitiesByLayer; - QVector<LightSource> filteredLightSources = cache->gatheredLights; - for (int i = 0; i < filteredLightSources.count(); ++i) { - if (!layeredFilteredEntities.contains(filteredLightSources[i].entity)) - filteredLightSources.removeAt(i--); + const std::vector<Entity *> &layeredFilteredEntities = cacheForLeaf.filterEntitiesByLayer; + std::vector<LightSource> filteredLightSources = cache->gatheredLights; + + auto it = filteredLightSources.begin(); + + while (it != filteredLightSources.end()) { + if (!std::binary_search(layeredFilteredEntities.begin(), + layeredFilteredEntities.end(), + it->entity)) + it = filteredLightSources.erase(it); + else + ++it; } - cacheForLeaf.layeredFilteredLightSources = filteredLightSources; + cacheForLeaf.layeredFilteredLightSources = std::move(filteredLightSources); } // This is likely very frequent @@ -350,7 +357,7 @@ public: // Set the light sources, with layer filters applied. rv->setLightSources(cacheForLeaf.layeredFilteredLightSources); - QVector<Entity *> renderableEntities = isDraw ? cacheForLeaf.filteredAndCulledRenderables : cacheForLeaf.layeredFilteredRenderables; + std::vector<Entity *> renderableEntities = isDraw ? cacheForLeaf.filteredAndCulledRenderables : cacheForLeaf.layeredFilteredRenderables; // TO DO: Find a way to do that only if proximity entities has changed if (isDraw) { @@ -368,7 +375,7 @@ public: // Filter out Render commands for which the Entity wasn't selected because // of frustum, proximity or layer filtering if (commandFilteringRequired) { - const std::vector<Entity *> &entities = filteredCommandData->data.entities; + const std::vector<const Entity *> &entities = filteredCommandData->data.entities; // Because cacheForLeaf.renderableEntities or computeEntities are sorted // What we get out of EntityRenderCommandData is also sorted by Entity auto eIt = renderableEntities.cbegin(); @@ -421,9 +428,9 @@ private: RenderViewInitializerJobPtr m_renderViewJob; FrustumCullingJobPtr m_frustumCullingJob; FilterProximityDistanceJobPtr m_filterProximityJob; - QVector<MaterialParameterGathererJobPtr> m_materialGathererJobs; - QVector<RenderViewCommandUpdaterJobPtr> m_renderViewCommandUpdaterJobs; - QVector<RenderViewCommandBuilderJobPtr> m_renderViewCommandBuilderJobs; + std::vector<MaterialParameterGathererJobPtr> m_materialGathererJobs; + std::vector<RenderViewCommandUpdaterJobPtr> m_renderViewCommandUpdaterJobs; + std::vector<RenderViewCommandBuilderJobPtr> m_renderViewCommandBuilderJobs; Renderer *m_renderer; FrameGraphNode *m_leafNode; RebuildFlagSet m_rebuildFlags; @@ -439,7 +446,7 @@ public: void operator()() { RenderView *rv = m_renderViewJob->renderView(); - QVector<ClearBufferInfo> &clearBuffersInfo = rv->specificClearColorBufferInfo(); + std::vector<ClearBufferInfo> &clearBuffersInfo = rv->specificClearColorBufferInfo(); const AttachmentPack &attachmentPack = rv->attachmentPack(); for (ClearBufferInfo &clearBufferInfo : clearBuffersInfo) clearBufferInfo.drawBufferIndex = attachmentPack.getDrawBufferIndex(clearBufferInfo.attchmentPoint); @@ -468,7 +475,7 @@ public: // The cache leaf should already have been created so we don't need to protect the access RendererCache::LeafNodeData &dataCacheForLeaf = m_renderer->cache()->leafNodeCache[m_leafNode]; // Save the filtered by layer subset into the cache - dataCacheForLeaf.filterEntitiesByLayer = m_filterEntityByLayerJob->filteredEntities(); + dataCacheForLeaf.filterEntitiesByLayer = std::move(m_filterEntityByLayerJob->filteredEntities()); } private: @@ -480,7 +487,7 @@ private: class SyncMaterialParameterGatherer { public: - explicit SyncMaterialParameterGatherer(const QVector<MaterialParameterGathererJobPtr> &materialParameterGathererJobs, + explicit SyncMaterialParameterGatherer(const std::vector<MaterialParameterGathererJobPtr> &materialParameterGathererJobs, Renderer *renderer, FrameGraphNode *leafNode) : m_materialParameterGathererJobs(materialParameterGathererJobs) @@ -507,7 +514,7 @@ public: } private: - QVector<MaterialParameterGathererJobPtr> m_materialParameterGathererJobs; + std::vector<MaterialParameterGathererJobPtr> m_materialParameterGathererJobs; Renderer *m_renderer; FrameGraphNode *m_leafNode; }; @@ -547,17 +554,17 @@ FrustumCullingJobPtr RenderViewBuilder::frustumCullingJob() const return m_frustumCullingJob; } -QVector<RenderViewCommandUpdaterJobPtr> RenderViewBuilder::renderViewCommandUpdaterJobs() const +const std::vector<RenderViewCommandUpdaterJobPtr> &RenderViewBuilder::renderViewCommandUpdaterJobs() const { return m_renderViewCommandUpdaterJobs; } -QVector<RenderViewCommandBuilderJobPtr> RenderViewBuilder::renderViewCommandBuilderJobs() const +const std::vector<RenderViewCommandBuilderJobPtr> &RenderViewBuilder::renderViewCommandBuilderJobs() const { return m_renderViewCommandBuilderJobs; } -QVector<MaterialParameterGathererJobPtr> RenderViewBuilder::materialGathererJobs() const +const std::vector<MaterialParameterGathererJobPtr> &RenderViewBuilder::materialGathererJobs() const { return m_materialGathererJobs; } @@ -690,8 +697,7 @@ void RenderViewBuilder::prepareJobs() m_syncRenderViewPostCommandUpdateJob = CreateSynchronizerJobPtr(SyncRenderViewPostCommandUpdate(m_renderViewJob, m_renderViewCommandUpdaterJobs, - m_renderer, - m_leafNode), + m_renderer), JobTypes::SyncRenderViewPostCommandUpdate); m_syncRenderViewPostInitializationJob = CreateSynchronizerJobPtr(SyncRenderViewPostInitialization(m_renderViewJob, @@ -797,7 +803,7 @@ QVector<Qt3DCore::QAspectJobPtr> RenderViewBuilder::buildJobHierachy() const jobs.push_back(m_setClearDrawBufferIndexJob); // Step 3 if (materialCacheNeedsRebuild) { - for (const auto &materialGatherer : qAsConst(m_materialGathererJobs)) { + for (const auto &materialGatherer : m_materialGathererJobs) { materialGatherer->addDependency(m_syncRenderViewPostInitializationJob); materialGatherer->addDependency(m_renderer->introspectShadersJob()); materialGatherer->addDependency(m_renderer->filterCompatibleTechniqueJob()); @@ -901,9 +907,10 @@ void RenderViewBuilder::setOptimalJobCount(int v) m_optimalParallelJobCount = v; } -QVector<Entity *> RenderViewBuilder::entitiesInSubset(const QVector<Entity *> &entities, const QVector<Entity *> &subset) +std::vector<Entity *> RenderViewBuilder::entitiesInSubset(const std::vector<Entity *> &entities, + const std::vector<Entity *> &subset) { - QVector<Entity *> intersection; + std::vector<Entity *> intersection; intersection.reserve(qMin(entities.size(), subset.size())); std::set_intersection(entities.begin(), entities.end(), subset.begin(), subset.end(), diff --git a/src/plugins/renderers/opengl/renderer/renderviewbuilder_p.h b/src/plugins/renderers/opengl/renderer/renderviewbuilder_p.h index 98ac126f7..ab670665b 100644 --- a/src/plugins/renderers/opengl/renderer/renderviewbuilder_p.h +++ b/src/plugins/renderers/opengl/renderer/renderviewbuilder_p.h @@ -85,9 +85,9 @@ public: RenderViewInitializerJobPtr renderViewJob() const; FilterLayerEntityJobPtr filterEntityByLayerJob() const; FrustumCullingJobPtr frustumCullingJob() const; - QVector<RenderViewCommandBuilderJobPtr> renderViewCommandBuilderJobs() const; - QVector<RenderViewCommandUpdaterJobPtr> renderViewCommandUpdaterJobs() const; - QVector<MaterialParameterGathererJobPtr> materialGathererJobs() const; + const std::vector<RenderViewCommandBuilderJobPtr> &renderViewCommandBuilderJobs() const; + const std::vector<RenderViewCommandUpdaterJobPtr> &renderViewCommandUpdaterJobs() const; + const std::vector<MaterialParameterGathererJobPtr> &materialGathererJobs() const; SynchronizerJobPtr syncRenderViewPostInitializationJob() const; SynchronizerJobPtr syncPreFrustumCullingJob() const; SynchronizerJobPtr syncRenderViewPreCommandBuildingJob() const; @@ -117,7 +117,8 @@ public: int optimalJobCount() const; void setOptimalJobCount(int v); - static QVector<Entity *> entitiesInSubset(const QVector<Entity *> &entities, const QVector<Entity *> &subset); + static std::vector<Entity *> entitiesInSubset(const std::vector<Entity *> &entities, + const std::vector<Entity *> &subset); private: Render::FrameGraphNode *m_leafNode; @@ -128,9 +129,9 @@ private: RenderViewInitializerJobPtr m_renderViewJob; FilterLayerEntityJobPtr m_filterEntityByLayerJob; FrustumCullingJobPtr m_frustumCullingJob; - QVector<RenderViewCommandBuilderJobPtr> m_renderViewCommandBuilderJobs; - QVector<RenderViewCommandUpdaterJobPtr> m_renderViewCommandUpdaterJobs; - QVector<MaterialParameterGathererJobPtr> m_materialGathererJobs; + std::vector<RenderViewCommandBuilderJobPtr> m_renderViewCommandBuilderJobs; + std::vector<RenderViewCommandUpdaterJobPtr> m_renderViewCommandUpdaterJobs; + std::vector<MaterialParameterGathererJobPtr> m_materialGathererJobs; SynchronizerJobPtr m_syncRenderViewPostInitializationJob; SynchronizerJobPtr m_syncPreFrustumCullingJob; diff --git a/src/render/backend/entity_p.h b/src/render/backend/entity_p.h index a66dd2956..0d4a9d980 100644 --- a/src/render/backend/entity_p.h +++ b/src/render/backend/entity_p.h @@ -146,9 +146,12 @@ public: } template<class Backend> - QVector<Backend *> renderComponents() const + std::vector<Backend *> renderComponents() const { - return QVector<Backend *>(); + // We should never reach this, we expect specialization to have been + // specified + Q_UNREACHABLE(); + return {}; } template<class Backend> @@ -233,7 +236,7 @@ private: Q_3DRENDERSHARED_PRIVATE_EXPORT QVector<Handle> Entity::componentsHandle<Type>() const; \ /* Component */ \ template<> \ - Q_3DRENDERSHARED_PRIVATE_EXPORT QVector<Type *> Entity::renderComponents<Type>() const; \ + Q_3DRENDERSHARED_PRIVATE_EXPORT std::vector<Type *> Entity::renderComponents<Type>() const; \ /* Uuid */ \ template<> \ Q_3DRENDERSHARED_PRIVATE_EXPORT Qt3DCore::QNodeIdVector Entity::componentsUuid<Type>() const; @@ -272,10 +275,10 @@ private: } \ /* Component */ \ template<> \ - QVector<Type *> Entity::renderComponents<Type>() const \ + std::vector<Type *> Entity::renderComponents<Type>() const \ { \ Manager *manager = m_nodeManagers->manager<Type, Manager>(); \ - QVector<Type *> entries; \ + std::vector<Type *> entries; \ entries.reserve(variable.size()); \ for (const QNodeId id : variable) \ entries.push_back(manager->lookupResource(id)); \ diff --git a/src/render/jobs/filterentitybycomponentjob_p.h b/src/render/jobs/filterentitybycomponentjob_p.h index 40bb75f37..55f502300 100644 --- a/src/render/jobs/filterentitybycomponentjob_p.h +++ b/src/render/jobs/filterentitybycomponentjob_p.h @@ -78,7 +78,7 @@ public: } inline void setManager(EntityManager *manager) Q_DECL_NOTHROW { m_manager = manager; } - inline QVector<Entity *> &filteredEntities() Q_DECL_NOTHROW { return m_filteredEntities; } + inline std::vector<Entity *> &filteredEntities() Q_DECL_NOTHROW { return m_filteredEntities; } void run() override { @@ -94,7 +94,7 @@ public: private: EntityManager *m_manager; - QVector<Entity *> m_filteredEntities; + std::vector<Entity *> m_filteredEntities; }; template<typename T, typename ... Ts> diff --git a/src/render/jobs/filterlayerentityjob.cpp b/src/render/jobs/filterlayerentityjob.cpp index ae3cced59..00ed76d86 100644 --- a/src/render/jobs/filterlayerentityjob.cpp +++ b/src/render/jobs/filterlayerentityjob.cpp @@ -154,7 +154,7 @@ void FilterLayerEntityJob::filterLayerAndEntity() EntityManager *entityManager = m_manager->renderNodesManager(); const std::vector<HEntity> &handles = entityManager->activeHandles(); - QVector<Entity *> entitiesToFilter; + std::vector<Entity *> entitiesToFilter; entitiesToFilter.reserve(handles.size()); for (const HEntity &handle : handles) { diff --git a/src/render/jobs/filterlayerentityjob_p.h b/src/render/jobs/filterlayerentityjob_p.h index 33023775f..3d32047a4 100644 --- a/src/render/jobs/filterlayerentityjob_p.h +++ b/src/render/jobs/filterlayerentityjob_p.h @@ -72,7 +72,7 @@ public: inline void setManager(NodeManagers *manager) Q_DECL_NOEXCEPT { m_manager = manager; } inline void setLayerFilters(const Qt3DCore::QNodeIdVector &layerIds) Q_DECL_NOEXCEPT { m_layerFilterIds = layerIds; } - inline QVector<Entity *> filteredEntities() const Q_DECL_NOEXCEPT { return m_filteredEntities; } + inline std::vector<Entity *> &filteredEntities() Q_DECL_NOEXCEPT { return m_filteredEntities; } inline bool hasLayerFilter() const Q_DECL_NOTHROW { return !m_layerFilterIds.isEmpty(); } inline Qt3DCore::QNodeIdVector layerFilters() const { return m_layerFilterIds; } @@ -91,7 +91,7 @@ private: NodeManagers *m_manager; Qt3DCore::QNodeIdVector m_layerFilterIds; - QVector<Entity *> m_filteredEntities; + std::vector<Entity *> m_filteredEntities; }; typedef QSharedPointer<FilterLayerEntityJob> FilterLayerEntityJobPtr; diff --git a/src/render/jobs/filterproximitydistancejob.cpp b/src/render/jobs/filterproximitydistancejob.cpp index 56c3baa62..cbfea14a1 100644 --- a/src/render/jobs/filterproximitydistancejob.cpp +++ b/src/render/jobs/filterproximitydistancejob.cpp @@ -60,7 +60,7 @@ void FilterProximityDistanceJob::run() if (hasProximityFilter()) { selectAllEntities(); - QVector<Entity *> entitiesToFilter = std::move(m_filteredEntities); + std::vector<Entity *> entitiesToFilter = std::move(m_filteredEntities); FrameGraphManager *frameGraphManager = m_manager->frameGraphManager(); EntityManager *entityManager = m_manager->renderNodesManager(); @@ -101,7 +101,7 @@ void FilterProximityDistanceJob::selectAllEntities() } } -void FilterProximityDistanceJob::filterEntities(const QVector<Entity *> &entitiesToFilter) +void FilterProximityDistanceJob::filterEntities(const std::vector<Entity *> &entitiesToFilter) { const Sphere *target = m_targetEntity->worldBoundingVolumeWithChildren(); diff --git a/src/render/jobs/filterproximitydistancejob_p.h b/src/render/jobs/filterproximitydistancejob_p.h index e058f011a..fd93d529d 100644 --- a/src/render/jobs/filterproximitydistancejob_p.h +++ b/src/render/jobs/filterproximitydistancejob_p.h @@ -64,7 +64,7 @@ public: // QAspectJob interface void run() final; - QVector<Entity *> filteredEntities() const { return m_filteredEntities; } + const std::vector<Entity *> &filteredEntities() const { return m_filteredEntities; } #if defined (QT_BUILD_INTERNAL) // For unit testing @@ -74,13 +74,13 @@ public: private: void selectAllEntities(); - void filterEntities(const QVector<Entity *> &entitiesToFilter); + void filterEntities(const std::vector<Entity *> &entitiesToFilter); NodeManagers *m_manager; Qt3DCore::QNodeIdVector m_proximityFilterIds; Entity *m_targetEntity; float m_distanceThresholdSquared; - QVector<Entity *> m_filteredEntities; + std::vector<Entity *> m_filteredEntities; }; typedef QSharedPointer<FilterProximityDistanceJob> FilterProximityDistanceJobPtr; diff --git a/src/render/jobs/frustumcullingjob_p.h b/src/render/jobs/frustumcullingjob_p.h index 6c0365c71..60cc05388 100644 --- a/src/render/jobs/frustumcullingjob_p.h +++ b/src/render/jobs/frustumcullingjob_p.h @@ -83,7 +83,7 @@ public: inline void setViewProjection(const Matrix4x4 &viewProjection) Q_DECL_NOTHROW { m_viewProjection = viewProjection; } inline Matrix4x4 viewProjection() const Q_DECL_NOTHROW { return m_viewProjection; } - QVector<Entity *> visibleEntities() const Q_DECL_NOTHROW { return m_visibleEntities; } + const std::vector<Entity *> &visibleEntities() const Q_DECL_NOTHROW { return m_visibleEntities; } void run() final; @@ -105,7 +105,7 @@ private: Matrix4x4 m_viewProjection; Entity *m_root; NodeManagers *m_manager; - QVector<Entity *> m_visibleEntities; + std::vector<Entity *> m_visibleEntities; bool m_active; }; diff --git a/src/render/jobs/lightgatherer.cpp b/src/render/jobs/lightgatherer.cpp index b3500806d..97d0fb8d8 100644 --- a/src/render/jobs/lightgatherer.cpp +++ b/src/render/jobs/lightgatherer.cpp @@ -63,17 +63,17 @@ void LightGatherer::run() m_environmentLight = nullptr; const std::vector<HEntity> &handles = m_manager->activeHandles(); - int envLightCount = 0; + size_t envLightCount = 0; for (const HEntity &handle : handles) { Entity *node = m_manager->data(handle); - const QVector<Light *> lights = node->renderComponents<Light>(); - if (!lights.isEmpty()) - m_lights.push_back(LightSource(node, lights)); - const QVector<EnvironmentLight *> envLights = node->renderComponents<EnvironmentLight>(); + std::vector<Light *> lights = node->renderComponents<Light>(); + if (!lights.empty()) + m_lights.push_back(LightSource(node, std::move(lights))); + const std::vector<EnvironmentLight *> &envLights = node->renderComponents<EnvironmentLight>(); envLightCount += envLights.size(); - if (!envLights.isEmpty() && !m_environmentLight) - m_environmentLight = envLights.first(); + if (!envLights.empty() && !m_environmentLight) + m_environmentLight = envLights.front(); } if (envLightCount > 1) diff --git a/src/render/jobs/lightgatherer_p.h b/src/render/jobs/lightgatherer_p.h index cc3948f12..806426c60 100644 --- a/src/render/jobs/lightgatherer_p.h +++ b/src/render/jobs/lightgatherer_p.h @@ -70,14 +70,14 @@ public: LightGatherer(); inline void setManager(EntityManager *manager) Q_DECL_NOTHROW { m_manager = manager; } - inline QVector<LightSource> &lights() { return m_lights; } + inline std::vector<LightSource> &lights() { return m_lights; } inline EnvironmentLight *environmentLight() const { return m_environmentLight; } void run() override; private: EntityManager *m_manager; - QVector<LightSource> m_lights; + std::vector<LightSource> m_lights; EnvironmentLight *m_environmentLight; }; diff --git a/src/render/jobs/raycastingjob.cpp b/src/render/jobs/raycastingjob.cpp index b7d4c4b7c..f56756ade 100644 --- a/src/render/jobs/raycastingjob.cpp +++ b/src/render/jobs/raycastingjob.cpp @@ -70,8 +70,8 @@ public: explicit EntityCasterGatherer(NodeManagers *manager) : EntityVisitor(manager) { setPruneDisabled(true); } Operation visit(Entity *entity) override { - QVector<RayCaster *> components = entity->renderComponents<RayCaster>(); - for (const auto c: qAsConst(components)) { + const std::vector<RayCaster *> &components = entity->renderComponents<RayCaster>(); + for (const auto c: components) { if (c->isEnabled()) m_result.push_back(qMakePair(entity, c)); } diff --git a/src/render/jobs/updatelevelofdetailjob.cpp b/src/render/jobs/updatelevelofdetailjob.cpp index d7d9c2f67..6207b5728 100644 --- a/src/render/jobs/updatelevelofdetailjob.cpp +++ b/src/render/jobs/updatelevelofdetailjob.cpp @@ -80,7 +80,7 @@ public: if (!entity->isEnabled()) return Prune; // skip disabled sub-trees, since their bounding box is probably not valid anyway - QVector<LevelOfDetail *> lods = entity->renderComponents<LevelOfDetail>(); + const std::vector<LevelOfDetail *> &lods = entity->renderComponents<LevelOfDetail>(); if (!lods.empty()) { LevelOfDetail* lod = lods.front(); // other lods are ignored diff --git a/src/render/jobs/updateshaderdatatransformjob.cpp b/src/render/jobs/updateshaderdatatransformjob.cpp index f5cf3175b..00723b872 100644 --- a/src/render/jobs/updateshaderdatatransformjob.cpp +++ b/src/render/jobs/updateshaderdatatransformjob.cpp @@ -86,7 +86,7 @@ void UpdateShaderDataTransformJob::run() for (const HEntity &handle : handles) { Entity *node = manager->data(handle); // Update transform properties in ShaderDatas and Lights - const QVector<ShaderData *> shaderDatas = node->renderComponents<ShaderData>(); + const std::vector<ShaderData *> &shaderDatas = node->renderComponents<ShaderData>(); for (ShaderData *r : shaderDatas) r->updateWorldTransform(*node->worldTransform()); } diff --git a/src/render/lights/lightsource.cpp b/src/render/lights/lightsource.cpp index 763e4763e..4056c199b 100644 --- a/src/render/lights/lightsource.cpp +++ b/src/render/lights/lightsource.cpp @@ -51,7 +51,7 @@ LightSource::LightSource() : entity(nullptr) { } -LightSource::LightSource(Entity *entity, const QVector<Light *> &lights) +LightSource::LightSource(const Entity *entity, const std::vector<Light *> &lights) : entity(entity) , lights(lights) { diff --git a/src/render/lights/lightsource_p.h b/src/render/lights/lightsource_p.h index bfa2b81f9..35e82b83b 100644 --- a/src/render/lights/lightsource_p.h +++ b/src/render/lights/lightsource_p.h @@ -52,7 +52,7 @@ // #include <Qt3DRender/private/qt3drender_global_p.h> -#include <QVector> +#include <vector> QT_BEGIN_NAMESPACE @@ -65,10 +65,10 @@ class Light; struct Q_3DRENDERSHARED_PRIVATE_EXPORT LightSource { LightSource(); - LightSource(Entity *entity, const QVector<Light *> &lights); + LightSource(const Entity *entity, const std::vector<Light *> &lights); - Entity *entity; - QVector<Light *> lights; + const Entity *entity; + std::vector<Light *> lights; }; } // Render diff --git a/tests/auto/render/filterentitybycomponent/tst_filterentitybycomponent.cpp b/tests/auto/render/filterentitybycomponent/tst_filterentitybycomponent.cpp index 08967ead9..7cfcd3e23 100644 --- a/tests/auto/render/filterentitybycomponent/tst_filterentitybycomponent.cpp +++ b/tests/auto/render/filterentitybycomponent/tst_filterentitybycomponent.cpp @@ -88,8 +88,8 @@ private Q_SLOTS: // THEN QCOMPARE(filterJob.filteredEntities().size(), 2); - QCOMPARE(filterJob.filteredEntities().first()->peerId(), childEntity1->id()); - QCOMPARE(filterJob.filteredEntities().last()->peerId(), childEntity2->id()); + QCOMPARE(filterJob.filteredEntities().front()->peerId(), childEntity1->id()); + QCOMPARE(filterJob.filteredEntities().back()->peerId(), childEntity2->id()); } { @@ -100,7 +100,7 @@ private Q_SLOTS: // THEN QCOMPARE(filterJob.filteredEntities().size(), 1); - QCOMPARE(filterJob.filteredEntities().first()->peerId(), childEntity1->id()); + QCOMPARE(filterJob.filteredEntities().front()->peerId(), childEntity1->id()); } { @@ -121,7 +121,7 @@ private Q_SLOTS: // THEN QCOMPARE(filterJob.filteredEntities().size(), 1); - QCOMPARE(filterJob.filteredEntities().first()->peerId(), childEntity3->id()); + QCOMPARE(filterJob.filteredEntities().front()->peerId(), childEntity3->id()); } } }; diff --git a/tests/auto/render/layerfiltering/tst_layerfiltering.cpp b/tests/auto/render/layerfiltering/tst_layerfiltering.cpp index 96e490752..24f6e5cbb 100644 --- a/tests/auto/render/layerfiltering/tst_layerfiltering.cpp +++ b/tests/auto/render/layerfiltering/tst_layerfiltering.cpp @@ -650,10 +650,10 @@ private Q_SLOTS: filterJob.run(); // THEN - const QVector<Qt3DRender::Render::Entity *> filterEntities = filterJob.filteredEntities(); - QCOMPARE(filterEntities.size(), expectedSelectedEntities.size()); - for (auto i = 0, m = expectedSelectedEntities.size(); i < m; ++i) - QCOMPARE(filterEntities.at(i)->peerId(), expectedSelectedEntities.at(i)); + const std::vector<Qt3DRender::Render::Entity *> filterEntities = std::move(filterJob.filteredEntities()); + QCOMPARE(filterEntities.size(), size_t(expectedSelectedEntities.size())); + for (size_t i = 0, m = expectedSelectedEntities.size(); i < m; ++i) + QCOMPARE(filterEntities[i]->peerId(), expectedSelectedEntities[i]); } }; diff --git a/tests/auto/render/opengl/renderviewbuilder/tst_renderviewbuilder.cpp b/tests/auto/render/opengl/renderviewbuilder/tst_renderviewbuilder.cpp index f29af93c5..846d21828 100644 --- a/tests/auto/render/opengl/renderviewbuilder/tst_renderviewbuilder.cpp +++ b/tests/auto/render/opengl/renderviewbuilder/tst_renderviewbuilder.cpp @@ -476,8 +476,9 @@ private Q_SLOTS: renderer->lightGathererJob()->run(); // THEN - QCOMPARE(renderer->lightGathererJob()->lights().size(), 2); - QVERIFY(renderer->lightGathererJob()->environmentLight() != nullptr); + Qt3DRender::Render::OpenGL::RendererCache *cache = renderer->cache(); + QCOMPARE(cache->gatheredLights.size(), 2); + QVERIFY(cache->environmentLight != nullptr); } void checkRenderableEntitiesFilteringExecution() @@ -496,7 +497,8 @@ private Q_SLOTS: renderer->renderableEntityFilterJob()->run(); // THEN - QCOMPARE(renderer->renderableEntityFilterJob()->filteredEntities().size(), 1); + Qt3DRender::Render::OpenGL::RendererCache *cache = renderer->cache(); + QCOMPARE(cache->renderableEntities.size(), 1); } void checkComputableEntitiesFilteringExecution() @@ -515,7 +517,8 @@ private Q_SLOTS: renderer->computableEntityFilterJob()->run(); // THEN - QCOMPARE(renderer->computableEntityFilterJob()->filteredEntities().size(), 1); + Qt3DRender::Render::OpenGL::RendererCache *cache = renderer->cache(); + QCOMPARE(cache->computeEntities.size(), 1); } void checkSyncRenderViewInitializationExecution() @@ -653,8 +656,9 @@ private Q_SLOTS: renderViewBuilder.syncRenderViewPostInitializationJob()->run(); renderViewBuilder.filterEntityByLayerJob()->run(); - QVector<Qt3DRender::Render::Entity *> renderableEntity = renderer->renderableEntityFilterJob()->filteredEntities(); - QVector<Qt3DRender::Render::Entity *> filteredEntity = renderViewBuilder.filterEntityByLayerJob()->filteredEntities(); + Qt3DRender::Render::OpenGL::RendererCache *cache = renderer->cache(); + std::vector<Qt3DRender::Render::Entity *> renderableEntity = cache->renderableEntities; + std::vector<Qt3DRender::Render::Entity *> filteredEntity = renderViewBuilder.filterEntityByLayerJob()->filteredEntities(); // THEN QCOMPARE(renderableEntity.size(), 200); @@ -668,7 +672,9 @@ private Q_SLOTS: // THEN QCOMPARE(renderableEntity.size(), 100); for (const auto entity : renderableEntity) { - QVERIFY(filteredEntity.contains(entity)); + QVERIFY(std::find(filteredEntity.begin(), + filteredEntity.end(), + entity) != filteredEntity.end()); } } diff --git a/tests/auto/render/proximityfiltering/tst_proximityfiltering.cpp b/tests/auto/render/proximityfiltering/tst_proximityfiltering.cpp index a64f5de71..f55e7cc0f 100644 --- a/tests/auto/render/proximityfiltering/tst_proximityfiltering.cpp +++ b/tests/auto/render/proximityfiltering/tst_proximityfiltering.cpp @@ -328,7 +328,7 @@ private Q_SLOTS: filterJob.run(); // THEN - const QVector<Qt3DRender::Render::Entity *> filterEntities = filterJob.filteredEntities(); + const std::vector<Qt3DRender::Render::Entity *> &filterEntities = filterJob.filteredEntities(); QCOMPARE(filterEntities.size(), expectedSelectedEntities.size()); for (auto i = 0, m = expectedSelectedEntities.size(); i < m; ++i) |