diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-02-29 15:00:19 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-03-05 12:00:46 +0000 |
commit | 5e9ecab9df95d1d2e8fa2be58d75d01c5904df21 (patch) | |
tree | 652b2ac33a8ee0c77755b8e40706cff7c2481373 /src | |
parent | afe56dcfcd4ee34c85260871d67e229d383c4186 (diff) |
Make the backend use workgroup sizes from ComputeCommand
Change-Id: I8b68857adad2adf8baf7a58506cb16e2b3c84d01
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/render/backend/computecommand.cpp | 17 | ||||
-rw-r--r-- | src/render/backend/computecommand_p.h | 4 | ||||
-rw-r--r-- | src/render/backend/rendercommand.cpp | 3 | ||||
-rw-r--r-- | src/render/backend/rendercommand_p.h | 1 | ||||
-rw-r--r-- | src/render/backend/renderer.cpp | 8 | ||||
-rw-r--r-- | src/render/backend/renderview.cpp | 3 |
6 files changed, 31 insertions, 5 deletions
diff --git a/src/render/backend/computecommand.cpp b/src/render/backend/computecommand.cpp index 4ec5d931d..ed3a7fea1 100644 --- a/src/render/backend/computecommand.cpp +++ b/src/render/backend/computecommand.cpp @@ -40,6 +40,7 @@ #include "computecommand_p.h" #include <Qt3DCore/qnode.h> #include <Qt3DCore/qscenepropertychange.h> +#include <Qt3DRender/qcomputecommand.h> #include <Qt3DRender/private/abstractrenderer_p.h> QT_BEGIN_NAMESPACE @@ -52,6 +53,9 @@ ComputeCommand::ComputeCommand() : BackendNode(ReadOnly) , m_enabled(false) { + m_workGroups[0] = 1; + m_workGroups[1] = 1; + m_workGroups[2] = 1; } ComputeCommand::~ComputeCommand() @@ -61,11 +65,18 @@ ComputeCommand::~ComputeCommand() void ComputeCommand::cleanup() { m_enabled = false; + m_workGroups[0] = 1; + m_workGroups[1] = 1; + m_workGroups[2] = 1; } void ComputeCommand::updateFromPeer(Qt3DCore::QNode *peer) { m_enabled = peer->isEnabled(); + QComputeCommand *computeCommand = static_cast<QComputeCommand *>(peer); + m_workGroups[0] = computeCommand->workGroupX(); + m_workGroups[1] = computeCommand->workGroupY(); + m_workGroups[2] = computeCommand->workGroupZ(); if (m_renderer != Q_NULLPTR) BackendNode::markDirty(AbstractRenderer::ComputeDirty); } @@ -76,6 +87,12 @@ void ComputeCommand::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) if (e->type() == Qt3DCore::NodeUpdated) { if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) m_enabled = propertyChange->value().toBool(); + else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupX")) + m_workGroups[0] = propertyChange->value().toInt(); + else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupY")) + m_workGroups[1] = propertyChange->value().toInt(); + else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupZ")) + m_workGroups[2] = propertyChange->value().toInt(); markDirty(AbstractRenderer::AllDirty); } } diff --git a/src/render/backend/computecommand_p.h b/src/render/backend/computecommand_p.h index 403845be1..c005c2bce 100644 --- a/src/render/backend/computecommand_p.h +++ b/src/render/backend/computecommand_p.h @@ -73,9 +73,13 @@ public: void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; inline bool isEnabled() const { return m_enabled; } + inline int x() const Q_DECL_NOEXCEPT { return m_workGroups[0]; } + inline int y() const Q_DECL_NOEXCEPT { return m_workGroups[1]; } + inline int z() const Q_DECL_NOEXCEPT { return m_workGroups[2]; } private: bool m_enabled; + int m_workGroups[3]; }; } // Render diff --git a/src/render/backend/rendercommand.cpp b/src/render/backend/rendercommand.cpp index 28e21696f..06f04a88b 100644 --- a/src/render/backend/rendercommand.cpp +++ b/src/render/backend/rendercommand.cpp @@ -54,6 +54,9 @@ RenderCommand::RenderCommand() , m_sortBackToFront(false) { m_sortingType.global = 0; + m_workGroups[0] = 0; + m_workGroups[1] = 0; + m_workGroups[2] = 0; } bool compareCommands(RenderCommand *r1, RenderCommand *r2) diff --git a/src/render/backend/rendercommand_p.h b/src/render/backend/rendercommand_p.h index 300f4daf2..c344d105f 100644 --- a/src/render/backend/rendercommand_p.h +++ b/src/render/backend/rendercommand_p.h @@ -105,6 +105,7 @@ public: } m_sortingType; bool m_sortBackToFront; + int m_workGroups[3]; }; bool compareCommands(RenderCommand *r1, RenderCommand *r2); diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp index db26f4adf..eea21acd7 100644 --- a/src/render/backend/renderer.cpp +++ b/src/render/backend/renderer.cpp @@ -849,11 +849,9 @@ void Renderer::performCompute(const RenderView *rv, RenderCommand *command) if (shader != Q_NULLPTR) { m_graphicsContext->activateShader(shader); m_graphicsContext->setParameters(command->m_parameterPack); - - const int *workGroups = rv->computeWorkGroups(); - m_graphicsContext->dispatchCompute(workGroups[0], - workGroups[1], - workGroups[2]); + m_graphicsContext->dispatchCompute(command->m_workGroups[0], + command->m_workGroups[1], + command->m_workGroups[2]); // HACK: Reset the compute flag to dirty m_changeSet |= AbstractRenderer::ComputeDirty; diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp index 5ef0b98c0..186d20151 100644 --- a/src/render/backend/renderview.cpp +++ b/src/render/backend/renderview.cpp @@ -609,6 +609,9 @@ void RenderView::buildComputeRenderCommands(Entity *node) RenderCommand *command = m_allocator->allocate<RenderCommand>(); command->m_type = RenderCommand::Compute; + command->m_workGroups[0] = std::max(m_workGroups[0], computeJob->x()); + command->m_workGroups[1] = std::max(m_workGroups[1], computeJob->y()); + command->m_workGroups[2] = std::max(m_workGroups[2], computeJob->z()); setShaderAndUniforms(command, pass, globalParameters, |