mirror of https://github.com/qt/qt3d.git
Update textures and disables in postJobs
Work was done in postFrame() in main thread anyway, so reduce amount of jobs slightly Change-Id: I8bbb3efcaf9246eb8df1033bde133bc16233f889 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
This commit is contained in:
parent
e77c85a200
commit
94e79666cc
|
|
@ -277,13 +277,7 @@ Renderer::Renderer(QRenderAspect::RenderType type)
|
|||
, m_bufferGathererJob(SynchronizerJobPtr::create([this] { lookForDirtyBuffers(); }, JobTypes::DirtyBufferGathering))
|
||||
, m_vaoGathererJob(SynchronizerJobPtr::create([this] { lookForAbandonedVaos(); }, JobTypes::DirtyVaoGathering))
|
||||
, m_textureGathererJob(SynchronizerJobPtr::create([this] { lookForDirtyTextures(); }, JobTypes::DirtyTextureGathering))
|
||||
, m_sendTextureChangesToFrontendJob(SynchronizerPostFramePtr::create([] {},
|
||||
[this] (Qt3DCore::QAspectManager *m) { sendTextureChangesToFrontend(m); },
|
||||
JobTypes::SendTextureChangesToFrontend))
|
||||
, m_sendSetFenceHandlesToFrontendJob(SynchronizerJobPtr::create([this] { sendSetFenceHandlesToFrontend(); }, JobTypes::SendSetFenceHandlesToFrontend))
|
||||
, m_sendDisablesToFrontendJob(SynchronizerPostFramePtr::create([] {},
|
||||
[this] (Qt3DCore::QAspectManager *m) { sendDisablesToFrontend(m); },
|
||||
JobTypes::SendDisablesToFrontend))
|
||||
, m_introspectShaderJob(SynchronizerPostFramePtr::create([this] { reloadDirtyShaders(); },
|
||||
[this] (Qt3DCore::QAspectManager *m) { sendShaderChangesToFrontend(m); },
|
||||
JobTypes::DirtyShaderGathering))
|
||||
|
|
@ -434,7 +428,7 @@ QOpenGLContext *Renderer::shareContext() const
|
|||
// Executed in the reloadDirtyShader job
|
||||
void Renderer::loadShader(Shader *shader, HShader shaderHandle)
|
||||
{
|
||||
Q_UNUSED(shader);
|
||||
Q_UNUSED(shader)
|
||||
m_dirtyShaders.push_back(shaderHandle);
|
||||
}
|
||||
|
||||
|
|
@ -1114,7 +1108,7 @@ void Renderer::reloadDirtyShaders()
|
|||
// If api of the renderer matches the one from the technique
|
||||
if (technique->isCompatibleWithRenderer()) {
|
||||
const auto passIds = technique->renderPasses();
|
||||
for (const QNodeId passId : passIds) {
|
||||
for (const QNodeId &passId : passIds) {
|
||||
RenderPass *renderPass = m_nodesManager->renderPassManager()->lookupResource(passId);
|
||||
HShader shaderHandle = m_nodesManager->shaderManager()->lookupHandle(renderPass->shaderProgram());
|
||||
Shader *shader = m_nodesManager->shaderManager()->data(shaderHandle);
|
||||
|
|
@ -1154,7 +1148,7 @@ void Renderer::reloadDirtyShaders()
|
|||
}
|
||||
}
|
||||
|
||||
// Executed in job postFrame
|
||||
// Executed in job (in main thread when jobs are done)
|
||||
void Renderer::sendShaderChangesToFrontend(Qt3DCore::QAspectManager *manager)
|
||||
{
|
||||
Q_ASSERT(isRunning());
|
||||
|
|
@ -1181,14 +1175,13 @@ void Renderer::sendShaderChangesToFrontend(Qt3DCore::QAspectManager *manager)
|
|||
}
|
||||
}
|
||||
|
||||
// Executed in a job (as postFrame)
|
||||
// Executed in a job (in main thread when jobs are done)
|
||||
void Renderer::sendTextureChangesToFrontend(Qt3DCore::QAspectManager *manager)
|
||||
{
|
||||
const QVector<QPair<Texture::TextureUpdateInfo, Qt3DCore::QNodeIdVector>> updateTextureProperties = std::move(m_updatedTextureProperties);
|
||||
for (const auto &pair : updateTextureProperties) {
|
||||
const Qt3DCore::QNodeIdVector targetIds = pair.second;
|
||||
for (const Qt3DCore::QNodeId targetId: targetIds) {
|
||||
|
||||
for (const Qt3DCore::QNodeId &targetId: targetIds) {
|
||||
// Lookup texture
|
||||
Texture *t = m_nodesManager->textureManager()->lookupResource(targetId);
|
||||
// If backend texture is Dirty, some property has changed and the properties we are
|
||||
|
|
@ -1234,7 +1227,7 @@ void Renderer::sendSetFenceHandlesToFrontend()
|
|||
}
|
||||
}
|
||||
|
||||
// Executed in a job postFrame
|
||||
// Executed in a job (in main thread when jobs done)
|
||||
void Renderer::sendDisablesToFrontend(Qt3DCore::QAspectManager *manager)
|
||||
{
|
||||
// SubtreeEnabled
|
||||
|
|
@ -1713,7 +1706,7 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren
|
|||
|
||||
void Renderer::markDirty(BackendNodeDirtySet changes, BackendNode *node)
|
||||
{
|
||||
Q_UNUSED(node);
|
||||
Q_UNUSED(node)
|
||||
m_dirtyBits.marked |= changes;
|
||||
}
|
||||
|
||||
|
|
@ -1760,6 +1753,12 @@ void Renderer::jobsDone(Qt3DCore::QAspectManager *manager)
|
|||
(m_nodesManager->frameGraphManager()->lookupNode(id));
|
||||
backend->syncRenderCapturesToFrontend(manager);
|
||||
}
|
||||
|
||||
// Do we need to notify any texture about property changes?
|
||||
if (m_updatedTextureProperties.size() > 0)
|
||||
sendTextureChangesToFrontend(manager);
|
||||
|
||||
sendDisablesToFrontend(manager);
|
||||
}
|
||||
|
||||
// Jobs we may have to run even if no rendering will happen
|
||||
|
|
@ -1767,10 +1766,6 @@ QVector<QAspectJobPtr> Renderer::preRenderingJobs()
|
|||
{
|
||||
QVector<QAspectJobPtr> jobs;
|
||||
|
||||
// Do we need to notify any texture about property changes?
|
||||
if (m_updatedTextureProperties.size() > 0)
|
||||
jobs.push_back(m_sendTextureChangesToFrontendJob);
|
||||
|
||||
// Do we need to notify frontend about fence change?
|
||||
if (m_updatedSetFences.size() > 0)
|
||||
jobs.push_back(m_sendSetFenceHandlesToFrontendJob);
|
||||
|
|
@ -1841,7 +1836,6 @@ QVector<Qt3DCore::QAspectJobPtr> Renderer::renderBinJobs()
|
|||
renderBinJobs.push_back(m_updateSkinningPaletteJob);
|
||||
renderBinJobs.push_back(m_updateLevelOfDetailJob);
|
||||
renderBinJobs.push_back(m_cleanupJob);
|
||||
renderBinJobs.push_back(m_sendDisablesToFrontendJob);
|
||||
renderBinJobs.append(bufferJobs);
|
||||
|
||||
// Jobs to prepare GL Resource upload
|
||||
|
|
|
|||
|
|
@ -233,7 +233,6 @@ public:
|
|||
inline SynchronizerPostFramePtr introspectShadersJob() const { return m_introspectShaderJob; }
|
||||
inline Qt3DCore::QAspectJobPtr bufferGathererJob() const { return m_bufferGathererJob; }
|
||||
inline Qt3DCore::QAspectJobPtr textureGathererJob() const { return m_textureGathererJob; }
|
||||
inline Qt3DCore::QAspectJobPtr sendTextureChangesToFrontendJob() const { return m_sendTextureChangesToFrontendJob; }
|
||||
inline UpdateEntityLayersJobPtr updateEntityLayersJob() const { return m_updateEntityLayersJob; }
|
||||
inline LightGathererPtr lightGathererJob() const { return m_lightGathererJob; }
|
||||
inline RenderableEntityFilterPtr renderableEntityFilterJob() const { return m_renderableEntityFilterJob; }
|
||||
|
|
@ -394,9 +393,7 @@ private:
|
|||
SynchronizerJobPtr m_bufferGathererJob;
|
||||
SynchronizerJobPtr m_vaoGathererJob;
|
||||
SynchronizerJobPtr m_textureGathererJob;
|
||||
SynchronizerPostFramePtr m_sendTextureChangesToFrontendJob;
|
||||
SynchronizerJobPtr m_sendSetFenceHandlesToFrontendJob;
|
||||
SynchronizerPostFramePtr m_sendDisablesToFrontendJob;
|
||||
SynchronizerPostFramePtr m_introspectShaderJob;
|
||||
SynchronizerJobPtr m_syncLoadingJobs;
|
||||
SynchronizerJobPtr m_cacheRenderableEntitiesJob;
|
||||
|
|
|
|||
|
|
@ -54,11 +54,6 @@ public:
|
|||
~tst_Renderer() {
|
||||
shutdown();
|
||||
}
|
||||
|
||||
Qt3DRender::Render::SynchronizerPostFramePtr sendDisablesToFrontendJob() const
|
||||
{
|
||||
return m_sendDisablesToFrontendJob;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -337,8 +332,7 @@ private Q_SLOTS:
|
|||
QCOMPARE(computeCommand.isEnabled(), true);
|
||||
|
||||
// WHEN
|
||||
auto sendDisablesJob = renderer.sendDisablesToFrontendJob();
|
||||
Qt3DCore::QAspectJobPrivate::get(sendDisablesJob.data())->postFrame(&manager);
|
||||
renderer.jobsDone(&manager); // so Renderer::sendDisablesToFrontend gets called
|
||||
|
||||
// THEN
|
||||
QCOMPARE(computeCommand.isEnabled(), false);
|
||||
|
|
|
|||
|
|
@ -100,20 +100,6 @@ private Q_SLOTS:
|
|||
1); // SendSetFenceHandlesJob
|
||||
// Note: pending set fence handles are only cleared when the job is run
|
||||
|
||||
// WHEN
|
||||
renderer.m_updatedTextureProperties.push_back({{}, {}});
|
||||
jobs = renderer.preRenderingJobs();
|
||||
|
||||
// THEN
|
||||
QCOMPARE(jobs.size(),
|
||||
1 + // PickBoundingVolumeJob
|
||||
1 + // RayCastingJob
|
||||
1 + // SendBufferCaptureJob
|
||||
1 + // SendSetFenceHandlesJob
|
||||
1); // SendTextureChangesToFrontend
|
||||
|
||||
// Note: pending texture changes are only cleared when the job is run
|
||||
|
||||
// Properly shutdown command thread
|
||||
renderer.shutdown();
|
||||
}
|
||||
|
|
@ -182,7 +168,6 @@ private Q_SLOTS:
|
|||
1 + // SyncLoadingJobs
|
||||
1 + // updateLevelOfDetailJob
|
||||
1 + // cleanupJob
|
||||
1 + // sendDisablesToFrontend
|
||||
1 + // VAOGatherer
|
||||
1 + // BufferGathererJob
|
||||
1 + // TexturesGathererJob
|
||||
|
|
@ -212,7 +197,6 @@ private Q_SLOTS:
|
|||
1 + // VAOGatherer
|
||||
1 + // updateSkinningPaletteJob
|
||||
1 + // SyncLoadingJobs
|
||||
1 + // sendDisablesToFrontend
|
||||
singleRenderViewJobCount +
|
||||
singleRenderViewCommandRebuildJobCount +
|
||||
renderViewBuilderMaterialCacheJobCount +
|
||||
|
|
@ -233,7 +217,6 @@ private Q_SLOTS:
|
|||
1 + // VAOGatherer
|
||||
1 + // updateSkinningPaletteJob
|
||||
1 + // SyncLoadingJobs
|
||||
1 + // sendDisablesToFrontend
|
||||
singleRenderViewJobCount +
|
||||
singleRenderViewCommandRebuildJobCount +
|
||||
renderViewBuilderMaterialCacheJobCount +
|
||||
|
|
@ -253,7 +236,6 @@ private Q_SLOTS:
|
|||
1 + // VAOGatherer
|
||||
1 + // updateSkinningPaletteJob
|
||||
1 + // SyncLoadingJobs
|
||||
1 + // sendDisablesToFrontend
|
||||
1 + // EntityEnabledDirty
|
||||
singleRenderViewJobCount +
|
||||
layerCacheJobCount);
|
||||
|
|
@ -275,7 +257,6 @@ private Q_SLOTS:
|
|||
1 + // UpdateShaderDataTransform
|
||||
1 + // updateSkinningPaletteJob
|
||||
1 + // SyncLoadingJobs
|
||||
1 + // sendDisablesToFrontend
|
||||
1 + // ExpandBoundingVolumeJob
|
||||
singleRenderViewJobCount);
|
||||
|
||||
|
|
@ -293,7 +274,6 @@ private Q_SLOTS:
|
|||
1 + // VAOGatherer
|
||||
1 + // updateSkinningPaletteJob
|
||||
1 + // SyncLoadingJobs
|
||||
1 + // sendDisablesToFrontend
|
||||
singleRenderViewJobCount +
|
||||
singleRenderViewCommandRebuildJobCount +
|
||||
renderViewBuilderMaterialCacheJobCount);
|
||||
|
|
@ -317,7 +297,6 @@ private Q_SLOTS:
|
|||
1 + // ExpandBoundingVolumeJob
|
||||
1 + // RenderableEntityFilterPtr
|
||||
1 + // SyncRenderableEntities
|
||||
1 + // sendDisablesToFrontend
|
||||
singleRenderViewCommandRebuildJobCount +
|
||||
singleRenderViewJobCount);
|
||||
|
||||
|
|
@ -338,7 +317,6 @@ private Q_SLOTS:
|
|||
1 + // CalculateBoundingVolumeJob
|
||||
1 + // UpdateMeshTriangleListJob
|
||||
1 + // BufferGathererJob
|
||||
1 + // sendDisablesToFrontend
|
||||
singleRenderViewJobCount);
|
||||
|
||||
renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty);
|
||||
|
|
@ -356,7 +334,6 @@ private Q_SLOTS:
|
|||
1 + // TexturesGathererJob
|
||||
1 + // updateSkinningPaletteJob
|
||||
1 + // SyncTexturesGathererJob
|
||||
1 + // sendDisablesToFrontend
|
||||
singleRenderViewJobCount);
|
||||
|
||||
renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty);
|
||||
|
|
|
|||
Loading…
Reference in New Issue