summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/render/backend/renderer.cpp14
-rw-r--r--src/render/backend/renderview_p.h8
-rw-r--r--src/render/framegraph/clearbuffers.cpp26
-rw-r--r--src/render/framegraph/clearbuffers_p.h6
-rw-r--r--src/render/framegraph/qclearbuffers.cpp52
-rw-r--r--src/render/framegraph/qclearbuffers.h13
-rw-r--r--src/render/framegraph/qclearbuffers_p.h3
-rw-r--r--src/render/graphicshelpers/graphicscontext.cpp10
-rw-r--r--src/render/graphicshelpers/graphicscontext_p.h2
-rw-r--r--src/render/jobs/renderviewjobutils.cpp14
10 files changed, 142 insertions, 6 deletions
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index 86e930542..29261806a 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -644,6 +644,8 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren
bool boundFboIdValid = false;
uint lastBoundFBOId = 0;
QColor previousClearColor = renderViews.first()->clearColor();
+ float previousClearDepthValue = renderViews.first()->clearDepthValue();
+ int previousClearStencilValue = renderViews.first()->clearStencilValue();
QSurface *surface = Q_NULLPTR;
QSurface *previousSurface = Q_NULLPTR;
for (int i = 0; i < renderViewsCount; ++i) {
@@ -711,6 +713,18 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren
m_graphicsContext->clearColor(previousClearColor);
}
+ // Set clear depth value if different
+ if (previousClearDepthValue != renderView->clearDepthValue()) {
+ previousClearDepthValue = renderView->clearDepthValue();
+ m_graphicsContext->clearDepthValue(previousClearDepthValue);
+ }
+
+ // Set clear stencil value if different
+ if (previousClearStencilValue != renderView->clearStencilValue()) {
+ previousClearStencilValue = renderView->clearStencilValue();
+ m_graphicsContext->clearStencilValue(previousClearStencilValue);
+ }
+
// Clear BackBuffer
m_graphicsContext->clearBackBuffer(renderView->clearBuffer());
diff --git a/src/render/backend/renderview_p.h b/src/render/backend/renderview_p.h
index 44bdfee58..50ad3d7b0 100644
--- a/src/render/backend/renderview_p.h
+++ b/src/render/backend/renderview_p.h
@@ -221,6 +221,12 @@ public:
inline void setClearBuffer(QClearBuffers::BufferType clearBuffer) Q_DECL_NOEXCEPT { m_clearBuffer = clearBuffer; }
inline QClearBuffers::BufferType clearBuffer() const Q_DECL_NOEXCEPT { return m_clearBuffer; }
+ inline void setClearDepthValue(float clearDepthValue) Q_DECL_NOEXCEPT { m_clearDepthValue = clearDepthValue; }
+ inline float clearDepthValue() const Q_DECL_NOEXCEPT { return m_clearDepthValue; }
+
+ inline void setClearStencilValue(int clearStencilValue) Q_DECL_NOEXCEPT { m_clearStencilValue = clearStencilValue; }
+ inline int clearStencilValue() const Q_DECL_NOEXCEPT { return m_clearStencilValue; }
+
RenderRenderPassList passesAndParameters(ParameterInfoList *parameter, Entity *node, bool useDefaultMaterials = true);
void buildRenderCommands(Entity *rootEntity, const Plane *planes);
@@ -290,6 +296,8 @@ private:
QSurface *m_surface;
AttachmentPack m_attachmentPack;
QClearBuffers::BufferType m_clearBuffer;
+ float m_clearDepthValue;
+ int m_clearStencilValue;
RenderStateSet *m_stateSet;
bool m_noDraw:1;
bool m_compute:1;
diff --git a/src/render/framegraph/clearbuffers.cpp b/src/render/framegraph/clearbuffers.cpp
index 41f9d563e..e4ed3d796 100644
--- a/src/render/framegraph/clearbuffers.cpp
+++ b/src/render/framegraph/clearbuffers.cpp
@@ -50,6 +50,8 @@ namespace Render {
ClearBuffers::ClearBuffers()
: FrameGraphNode(FrameGraphNode::ClearBuffers)
, m_type(QClearBuffers::None)
+ , m_clearDepthValue(1.f)
+ , m_clearStencilValue(0)
{
}
@@ -57,6 +59,9 @@ void ClearBuffers::updateFromPeer(Qt3DCore::QNode *peer)
{
QClearBuffers *clearBuffers = static_cast<QClearBuffers *>(peer);
m_type = clearBuffers->buffers();
+ m_clearColor = clearBuffers->clearColor();
+ m_clearDepthValue = clearBuffers->clearDepthValue();
+ m_clearStencilValue = clearBuffers->clearStencilValue();
setEnabled(clearBuffers->isEnabled());
}
@@ -66,6 +71,12 @@ void ClearBuffers::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
if (propertyChange->propertyName() == QByteArrayLiteral("buffers"))
m_type = static_cast<QClearBuffers::BufferType>(propertyChange->value().toInt());
+ else if (propertyChange->propertyName() == QByteArrayLiteral("clearColor"))
+ m_clearColor = propertyChange->value().value<QColor>();
+ else if (propertyChange->propertyName() == QByteArrayLiteral("clearDepthValue"))
+ m_clearDepthValue = propertyChange->value().toFloat();
+ else if (propertyChange->propertyName() == QByteArrayLiteral("clearStencilValue"))
+ m_clearStencilValue = propertyChange->value().toInt();
else if (propertyChange->propertyName() == QByteArrayLiteral("enabled"))
setEnabled(propertyChange->value().toBool());
markDirty(AbstractRenderer::AllDirty);
@@ -77,6 +88,21 @@ QClearBuffers::BufferType ClearBuffers::type() const
return m_type;
}
+QColor ClearBuffers::clearColor() const
+{
+ return m_clearColor;
+}
+
+float ClearBuffers::clearDepthValue() const
+{
+ return m_clearDepthValue;
+}
+
+int ClearBuffers::clearStencilValue() const
+{
+ return m_clearStencilValue;
+}
+
} // namespace Render
} // namespace Qt3DRender
diff --git a/src/render/framegraph/clearbuffers_p.h b/src/render/framegraph/clearbuffers_p.h
index eca512a0b..f5a06d9e5 100644
--- a/src/render/framegraph/clearbuffers_p.h
+++ b/src/render/framegraph/clearbuffers_p.h
@@ -70,9 +70,15 @@ public:
void updateFromPeer(Qt3DCore::QNode *peer) Q_DECL_OVERRIDE;
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE;
QClearBuffers::BufferType type() const;
+ QColor clearColor() const;
+ float clearDepthValue() const;
+ int clearStencilValue() const;
private:
QClearBuffers::BufferType m_type;
+ QColor m_clearColor;
+ float m_clearDepthValue;
+ int m_clearStencilValue;
};
} // namespace Render
diff --git a/src/render/framegraph/qclearbuffers.cpp b/src/render/framegraph/qclearbuffers.cpp
index d0c323086..94371c637 100644
--- a/src/render/framegraph/qclearbuffers.cpp
+++ b/src/render/framegraph/qclearbuffers.cpp
@@ -48,6 +48,8 @@ namespace Qt3DRender {
QClearBuffersPrivate::QClearBuffersPrivate()
: QFrameGraphNodePrivate()
, m_buffersType(QClearBuffers::None)
+ , m_clearDepthValue(1.f)
+ , m_clearStencilValue(0)
{
}
@@ -56,6 +58,9 @@ void QClearBuffers::copy(const QNode *ref)
QFrameGraphNode::copy(ref);
const QClearBuffers *b = static_cast<const QClearBuffers*>(ref);
d_func()->m_buffersType = b->d_func()->m_buffersType;
+ d_func()->m_clearColor = b->d_func()->m_clearColor;
+ d_func()->m_clearDepthValue = b->d_func()->m_clearDepthValue;
+ d_func()->m_clearStencilValue = b->d_func()->m_clearStencilValue;
}
QClearBuffers::QClearBuffers(QNode *parent)
@@ -81,6 +86,24 @@ QClearBuffers::BufferType QClearBuffers::buffers() const
return d->m_buffersType;
}
+QColor QClearBuffers::clearColor() const
+{
+ Q_D(const QClearBuffers);
+ return d->m_clearColor;
+}
+
+float QClearBuffers::clearDepthValue() const
+{
+ Q_D(const QClearBuffers);
+ return d->m_clearDepthValue;
+}
+
+int QClearBuffers::clearStencilValue() const
+{
+ Q_D(const QClearBuffers);
+ return d->m_clearStencilValue;
+}
+
void QClearBuffers::setBuffers(QClearBuffers::BufferType buffers)
{
Q_D(QClearBuffers);
@@ -90,6 +113,35 @@ void QClearBuffers::setBuffers(QClearBuffers::BufferType buffers)
}
}
+void QClearBuffers::setClearColor(const QColor &color)
+{
+ Q_D(QClearBuffers);
+ if (d->m_clearColor != color) {
+ d->m_clearColor = color;
+ emit clearColorChanged(color);
+ }
+}
+
+void QClearBuffers::setClearDepthValue(float clearDepthValue)
+{
+ Q_D(QClearBuffers);
+ if (d->m_clearDepthValue != clearDepthValue) {
+ if (clearDepthValue >= 0.f && clearDepthValue <= 1.f) {
+ d->m_clearDepthValue = clearDepthValue;
+ emit clearDepthValueChanged(clearDepthValue);
+ } else qWarning() << "Invalid clear depth value";
+ }
+}
+
+void QClearBuffers::setClearStencilValue(int clearStencilValue)
+{
+ Q_D(QClearBuffers);
+ if (d->m_clearStencilValue != clearStencilValue) {
+ d->m_clearStencilValue = clearStencilValue;
+ emit clearStencilValueChanged(clearStencilValue);
+ }
+}
+
} // namespace Qt3DRender
QT_END_NAMESPACE
diff --git a/src/render/framegraph/qclearbuffers.h b/src/render/framegraph/qclearbuffers.h
index 9a145d0b0..ce1920603 100644
--- a/src/render/framegraph/qclearbuffers.h
+++ b/src/render/framegraph/qclearbuffers.h
@@ -41,6 +41,7 @@
#define QT3DRENDER_QCLEARBUFFERS_H
#include <Qt3DRender/qframegraphnode.h>
+#include <QColor>
QT_BEGIN_NAMESPACE
@@ -52,6 +53,9 @@ class QT3DRENDERSHARED_EXPORT QClearBuffers : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(BufferType buffers READ buffers WRITE setBuffers NOTIFY buffersChanged)
+ Q_PROPERTY(QColor clearColor READ clearColor WRITE setClearColor NOTIFY clearColorChanged)
+ Q_PROPERTY(float clearDepthValue READ clearDepthValue WRITE setClearDepthValue NOTIFY clearDepthValueChanged)
+ Q_PROPERTY(int clearStencilValue READ clearStencilValue WRITE setClearStencilValue NOTIFY clearStencilValueChanged)
public:
explicit QClearBuffers(Qt3DCore::QNode *parent = 0);
~QClearBuffers();
@@ -69,12 +73,21 @@ public:
Q_ENUM(BufferType)
BufferType buffers() const;
+ QColor clearColor() const;
+ float clearDepthValue() const;
+ int clearStencilValue() const;
public Q_SLOTS:
void setBuffers(BufferType buffers);
+ void setClearColor(const QColor& color);
+ void setClearDepthValue(float clearDepthValue);
+ void setClearStencilValue(int clearStencilValue);
Q_SIGNALS:
void buffersChanged(BufferType buffers);
+ void clearColorChanged(const QColor& color);
+ void clearDepthValueChanged(float clearDepthValue);
+ void clearStencilValueChanged(int clearStencilValue);
protected:
QClearBuffers(QClearBuffersPrivate &dd, Qt3DCore::QNode *parent = 0);
diff --git a/src/render/framegraph/qclearbuffers_p.h b/src/render/framegraph/qclearbuffers_p.h
index 69fc62e4d..57467c27d 100644
--- a/src/render/framegraph/qclearbuffers_p.h
+++ b/src/render/framegraph/qclearbuffers_p.h
@@ -65,6 +65,9 @@ public:
Q_DECLARE_PUBLIC(QClearBuffers)
QClearBuffers::BufferType m_buffersType;
+ QColor m_clearColor;
+ float m_clearDepthValue;
+ int m_clearStencilValue;
};
} // namespace Qt3DRender
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp
index ce10a25f3..539ebec41 100644
--- a/src/render/graphicshelpers/graphicscontext.cpp
+++ b/src/render/graphicshelpers/graphicscontext.cpp
@@ -852,6 +852,16 @@ void GraphicsContext::clearColor(const QColor &color)
m_gl->functions()->glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
}
+void GraphicsContext::clearDepthValue(float depth)
+{
+ m_gl->functions()->glClearDepthf(depth);
+}
+
+void GraphicsContext::clearStencilValue(int stencil)
+{
+ m_gl->functions()->glClearStencil(stencil);
+}
+
void GraphicsContext::enableClipPlane(int clipPlane)
{
m_glHelper->enableClipPlane(clipPlane);
diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h
index ddf01ce0c..ea6db02ed 100644
--- a/src/render/graphicshelpers/graphicscontext_p.h
+++ b/src/render/graphicshelpers/graphicscontext_p.h
@@ -187,6 +187,8 @@ public:
GLuint boundFrameBufferObject();
void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer);
void clearColor(const QColor &color);
+ void clearDepthValue(float depth);
+ void clearStencilValue(int stencil);
void cullFace(GLenum mode);
void depthMask(GLenum mode);
void depthTest(GLenum mode);
diff --git a/src/render/jobs/renderviewjobutils.cpp b/src/render/jobs/renderviewjobutils.cpp
index dde0b7184..a6b51ca54 100644
--- a/src/render/jobs/renderviewjobutils.cpp
+++ b/src/render/jobs/renderviewjobutils.cpp
@@ -152,9 +152,15 @@ void setRenderViewConfigFromFrameGraphLeafNode(RenderView *rv, const FrameGraphN
break;
}
- case FrameGraphNode::ClearBuffers:
- rv->setClearBuffer(static_cast<const ClearBuffers *>(node)->type());
+ case FrameGraphNode::ClearBuffers: {
+ const ClearBuffers* cbNode = static_cast<const ClearBuffers *>(node);
+ rv->setClearBuffer(cbNode->type());
+ rv->setClearDepthValue(cbNode->clearDepthValue());
+ rv->setClearStencilValue(cbNode->clearStencilValue());
+ if (cbNode->clearColor().isValid())
+ rv->setClearColor(cbNode->clearColor());
break;
+ }
case FrameGraphNode::TechniqueFilter:
// Can be set once
@@ -169,10 +175,6 @@ void setRenderViewConfigFromFrameGraphLeafNode(RenderView *rv, const FrameGraphN
// a subregion relative to that of the parent viewport
const ViewportNode *vpNode = static_cast<const ViewportNode *>(node);
rv->setViewport(computeViewport(rv->viewport(), vpNode));
-
- // We take the clear color from the viewport node nearest the leaf
- if (!rv->clearColor().isValid())
- rv->setClearColor(vpNode->clearColor());
break;
}