summaryrefslogtreecommitdiffstats
path: root/src/render/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/backend')
-rw-r--r--src/render/backend/attachmentpack.cpp30
-rw-r--r--src/render/backend/attachmentpack_p.h4
-rw-r--r--src/render/backend/backendnode.cpp3
-rw-r--r--src/render/backend/cameralens.cpp2
-rw-r--r--src/render/backend/entity.cpp3
-rw-r--r--src/render/backend/entity_p.h3
-rw-r--r--src/render/backend/entityaccumulator.cpp11
-rw-r--r--src/render/backend/entityvisitor.cpp11
-rw-r--r--src/render/backend/layer.cpp3
-rw-r--r--src/render/backend/levelofdetail.cpp4
-rw-r--r--src/render/backend/platformsurfacefilter.cpp8
-rw-r--r--src/render/backend/platformsurfacefilter_p.h7
-rw-r--r--src/render/backend/render-backend.pri65
-rw-r--r--src/render/backend/rendersettings.cpp3
-rw-r--r--src/render/backend/rendertarget.cpp3
-rw-r--r--src/render/backend/rendertargetoutput.cpp3
-rw-r--r--src/render/backend/transform.cpp11
-rw-r--r--src/render/backend/transform_p.h4
-rw-r--r--src/render/backend/trianglesvisitor.cpp3
-rw-r--r--src/render/backend/uniform.cpp2
20 files changed, 84 insertions, 99 deletions
diff --git a/src/render/backend/attachmentpack.cpp b/src/render/backend/attachmentpack.cpp
index 59a832a66..8f096e21c 100644
--- a/src/render/backend/attachmentpack.cpp
+++ b/src/render/backend/attachmentpack.cpp
@@ -7,6 +7,13 @@
QT_BEGIN_NAMESPACE
+#ifndef GL_BACK_LEFT
+#define GL_BACK_LEFT 0x0402
+#endif
+#ifndef GL_BACK_RIGHT
+#define GL_BACK_RIGHT 0x0403
+#endif
+
namespace Qt3DRender {
namespace Render {
@@ -39,15 +46,20 @@ AttachmentPack::AttachmentPack(const RenderTarget *target,
// If nothing is specified, use all the attachments as draw buffers
if (drawBuffers.empty()) {
m_drawBuffers.reserve(m_attachments.size());
- for (const Attachment &attachment : std::as_const(m_attachments))
- // only consider Color Attachments
- if (attachment.m_point <= QRenderTargetOutput::Color15)
- m_drawBuffers.push_back((int) attachment.m_point);
+ for (const Attachment &attachment : std::as_const(m_attachments)) {
+ if ((attachment.m_point >= QRenderTargetOutput::Color0 && attachment.m_point <= QRenderTargetOutput::Color15)
+ || attachment.m_point == QRenderTargetOutput::Left
+ || attachment.m_point == QRenderTargetOutput::Right)
+ m_drawBuffers.push_back(attachment.m_point);
+ }
} else {
m_drawBuffers.reserve(drawBuffers.size());
- for (QRenderTargetOutput::AttachmentPoint drawBuffer : drawBuffers)
- if (drawBuffer <= QRenderTargetOutput::Color15)
- m_drawBuffers.push_back((int) drawBuffer);
+ for (QRenderTargetOutput::AttachmentPoint drawBuffer : drawBuffers) {
+ if ((drawBuffer >= QRenderTargetOutput::Color0 && drawBuffer <= QRenderTargetOutput::Color15)
+ || drawBuffer == QRenderTargetOutput::Left
+ || drawBuffer == QRenderTargetOutput::Right)
+ m_drawBuffers.push_back(drawBuffer);
+ }
}
}
@@ -55,7 +67,7 @@ AttachmentPack::AttachmentPack(const RenderTarget *target,
int AttachmentPack::getDrawBufferIndex(QRenderTargetOutput::AttachmentPoint attachmentPoint) const
{
for (size_t i = 0; i < m_drawBuffers.size(); i++)
- if (m_drawBuffers.at(i) == (int)attachmentPoint)
+ if (m_drawBuffers.at(i) == attachmentPoint)
return int(i);
return -1;
}
@@ -78,7 +90,7 @@ bool operator !=(const Attachment &a, const Attachment &b)
bool operator ==(const AttachmentPack &packA, const AttachmentPack &packB)
{
return (packA.attachments() == packB.attachments() &&
- packA.getGlDrawBuffers() == packB.getGlDrawBuffers());
+ packA.getDrawBuffers() == packB.getDrawBuffers());
}
bool operator !=(const AttachmentPack &packA, const AttachmentPack &packB)
diff --git a/src/render/backend/attachmentpack_p.h b/src/render/backend/attachmentpack_p.h
index 8bc9a899f..f1d984e24 100644
--- a/src/render/backend/attachmentpack_p.h
+++ b/src/render/backend/attachmentpack_p.h
@@ -54,14 +54,14 @@ public:
const QList<QRenderTargetOutput::AttachmentPoint> &drawBuffers = {});
const std::vector<Attachment> &attachments() const { return m_attachments; }
- const std::vector<int> &getGlDrawBuffers() const { return m_drawBuffers; }
+ const std::vector<QRenderTargetOutput::AttachmentPoint> &getDrawBuffers() const { return m_drawBuffers; }
// return index of given attachment within actual draw buffers list
int getDrawBufferIndex(QRenderTargetOutput::AttachmentPoint attachmentPoint) const;
private:
std::vector<Attachment> m_attachments;
- std::vector<int> m_drawBuffers;
+ std::vector<QRenderTargetOutput::AttachmentPoint> m_drawBuffers;
};
Q_3DRENDERSHARED_PRIVATE_EXPORT bool operator ==(const Attachment &a, const Attachment &b);
diff --git a/src/render/backend/backendnode.cpp b/src/render/backend/backendnode.cpp
index 7ad6e46cf..06e505888 100644
--- a/src/render/backend/backendnode.cpp
+++ b/src/render/backend/backendnode.cpp
@@ -10,11 +10,12 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
+
BackendNode::BackendNode(Mode mode)
: QBackendNode(mode)
, m_renderer(nullptr)
diff --git a/src/render/backend/cameralens.cpp b/src/render/backend/cameralens.cpp
index 22f693317..374abec47 100644
--- a/src/render/backend/cameralens.cpp
+++ b/src/render/backend/cameralens.cpp
@@ -19,11 +19,11 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
namespace {
diff --git a/src/render/backend/entity.cpp b/src/render/backend/entity.cpp
index 2b90c4996..2f14e23e7 100644
--- a/src/render/backend/entity.cpp
+++ b/src/render/backend/entity.cpp
@@ -34,11 +34,11 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
EntityPrivate::EntityPrivate()
: Qt3DCore::QBackendNodePrivate(Entity::ReadOnly)
@@ -67,6 +67,7 @@ void EntityPrivate::componentRemoved(Qt3DCore::QNode *frontend)
Entity::Entity()
: BackendNode(*new EntityPrivate)
, m_nodeManagers(nullptr)
+ , m_parentLessTransform(true)
, m_boundingDirty(false)
, m_treeEnabled(true)
{
diff --git a/src/render/backend/entity_p.h b/src/render/backend/entity_p.h
index 734bc15ae..e7e6278e2 100644
--- a/src/render/backend/entity_p.h
+++ b/src/render/backend/entity_p.h
@@ -73,6 +73,8 @@ public:
Matrix4x4 *worldTransform();
const Matrix4x4 *worldTransform() const;
+ bool isParentLessTransform() const { return m_parentLessTransform; }
+ void setParentLessTransform(bool v) { m_parentLessTransform = v; }
Sphere *localBoundingVolume() const { return m_localBoundingVolume.data(); }
Sphere *worldBoundingVolume() const { return m_worldBoundingVolume.data(); }
Sphere *worldBoundingVolumeWithChildren() const { return m_worldBoundingVolumeWithChildren.data(); }
@@ -151,6 +153,7 @@ private:
QList<HEntity> m_childrenHandles;
HMatrix m_worldTransform;
+ bool m_parentLessTransform;
QSharedPointer<Sphere> m_localBoundingVolume;
QSharedPointer<Sphere> m_worldBoundingVolume;
QSharedPointer<Sphere> m_worldBoundingVolumeWithChildren;
diff --git a/src/render/backend/entityaccumulator.cpp b/src/render/backend/entityaccumulator.cpp
index e1b84c0af..43dff651c 100644
--- a/src/render/backend/entityaccumulator.cpp
+++ b/src/render/backend/entityaccumulator.cpp
@@ -4,8 +4,10 @@
#include "entityaccumulator_p.h"
#include "entityvisitor_p.h"
-QT_USE_NAMESPACE
-using namespace Qt3DRender::Render;
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
namespace {
@@ -61,3 +63,8 @@ QList<Entity *> EntityAccumulator::apply(Entity *root) const
a.apply(root);
return a.m_entities;
}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/backend/entityvisitor.cpp b/src/render/backend/entityvisitor.cpp
index e0e392159..835512e3a 100644
--- a/src/render/backend/entityvisitor.cpp
+++ b/src/render/backend/entityvisitor.cpp
@@ -5,8 +5,10 @@
#include <Qt3DRender/private/managers_p.h>
#include <Qt3DRender/private/nodemanagers_p.h>
-QT_USE_NAMESPACE
-using namespace Qt3DRender::Render;
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
EntityVisitor::EntityVisitor(NodeManagers *manager)
: m_manager(manager)
@@ -75,3 +77,8 @@ bool EntityVisitor::apply(Entity *root) {
return true;
}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/backend/layer.cpp b/src/render/backend/layer.cpp
index 3cc141e32..0cdf0b938 100644
--- a/src/render/backend/layer.cpp
+++ b/src/render/backend/layer.cpp
@@ -9,11 +9,12 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
+
Layer::Layer()
: BackendNode()
, m_recursive(false)
diff --git a/src/render/backend/levelofdetail.cpp b/src/render/backend/levelofdetail.cpp
index ad800ffd4..517c85d64 100644
--- a/src/render/backend/levelofdetail.cpp
+++ b/src/render/backend/levelofdetail.cpp
@@ -10,11 +10,11 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
-
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
+
LevelOfDetail::LevelOfDetail()
: BackendNode(BackendNode::ReadWrite)
, m_currentIndex(0)
diff --git a/src/render/backend/platformsurfacefilter.cpp b/src/render/backend/platformsurfacefilter.cpp
index 6e0e3810b..473846e2d 100644
--- a/src/render/backend/platformsurfacefilter.cpp
+++ b/src/render/backend/platformsurfacefilter.cpp
@@ -15,7 +15,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
namespace Render {
-QSemaphore PlatformSurfaceFilter::m_surfacesSemaphore(1);
+QBasicMutex PlatformSurfaceFilter::m_surfacesMutex {};
QHash<QSurface *, bool> PlatformSurfaceFilter::m_surfacesValidity;
// Surface protection
@@ -91,18 +91,18 @@ bool PlatformSurfaceFilter::eventFilter(QObject *obj, QEvent *e)
void PlatformSurfaceFilter::lockSurface()
{
- PlatformSurfaceFilter::m_surfacesSemaphore.acquire(1);
+ PlatformSurfaceFilter::m_surfacesMutex.lock();
}
void PlatformSurfaceFilter::releaseSurface()
{
- PlatformSurfaceFilter::m_surfacesSemaphore.release(1);
+ PlatformSurfaceFilter::m_surfacesMutex.unlock();
}
bool PlatformSurfaceFilter::isSurfaceValid(QSurface *surface)
{
// Should be called only when the surface is locked
- // with the semaphore
+ // with the mutex
return m_surfacesValidity.value(surface, false);
}
diff --git a/src/render/backend/platformsurfacefilter_p.h b/src/render/backend/platformsurfacefilter_p.h
index 7074850d9..d6680df89 100644
--- a/src/render/backend/platformsurfacefilter_p.h
+++ b/src/render/backend/platformsurfacefilter_p.h
@@ -17,9 +17,10 @@
#include <private/qt3drender_global_p.h>
+#include <QtCore/qmutex.h>
#include <QtCore/qobject.h>
+#include <QtCore/qpointer.h>
#include <QtGui/qsurface.h>
-#include <QSemaphore>
QT_BEGIN_NAMESPACE
@@ -64,10 +65,10 @@ public:
}
}
private:
- QObject *m_obj;
+ QPointer<QObject> m_obj;
QSurface *m_surface;
- static QSemaphore m_surfacesSemaphore;
+ static QBasicMutex m_surfacesMutex;
static QHash<QSurface *, bool> m_surfacesValidity;
void markSurfaceAsValid();
};
diff --git a/src/render/backend/render-backend.pri b/src/render/backend/render-backend.pri
deleted file mode 100644
index 3f75e2115..000000000
--- a/src/render/backend/render-backend.pri
+++ /dev/null
@@ -1,65 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/parameterpack_p.h \
- $$PWD/rendertarget_p.h \
- $$PWD/attachmentpack_p.h \
- $$PWD/managers_p.h \
- $$PWD/handle_types_p.h \
- $$PWD/platformsurfacefilter_p.h \
- $$PWD/cameralens_p.h \
- $$PWD/entity_p.h \
- $$PWD/entity_p_p.h \
- $$PWD/entityvisitor_p.h \
- $$PWD/entityaccumulator_p.h \
- $$PWD/layer_p.h \
- $$PWD/levelofdetail_p.h \
- $$PWD/nodefunctor_p.h \
- $$PWD/transform_p.h \
- $$PWD/boundingvolumedebug_p.h \
- $$PWD/nodemanagers_p.h \
- $$PWD/triangleboundingvolume_p.h \
- $$PWD/buffervisitor_p.h \
- $$PWD/bufferutils_p.h \
- $$PWD/trianglesvisitor_p.h \
- $$PWD/abstractrenderer_p.h \
- $$PWD/computecommand_p.h \
- $$PWD/rendersettings_p.h \
- $$PWD/stringtoint_p.h \
- $$PWD/backendnode_p.h \
- $$PWD/rendertargetoutput_p.h \
- $$PWD/uniform_p.h \
- $$PWD/offscreensurfacehelper_p.h \
- $$PWD/resourceaccessor_p.h \
- $$PWD/visitorutils_p.h \
- $$PWD/segmentsvisitor_p.h \
- $$PWD/pointsvisitor_p.h \
- $$PWD/apishadermanager_p.h
-
-SOURCES += \
- $$PWD/parameterpack.cpp \
- $$PWD/rendertarget.cpp \
- $$PWD/managers.cpp \
- $$PWD/platformsurfacefilter.cpp \
- $$PWD/cameralens.cpp \
- $$PWD/entity.cpp \
- $$PWD/entityvisitor.cpp \
- $$PWD/entityaccumulator.cpp \
- $$PWD/layer.cpp \
- $$PWD/levelofdetail.cpp \
- $$PWD/transform.cpp \
- $$PWD/boundingvolumedebug.cpp \
- $$PWD/nodemanagers.cpp \
- $$PWD/triangleboundingvolume.cpp \
- $$PWD/trianglesvisitor.cpp \
- $$PWD/computecommand.cpp \
- $$PWD/rendersettings.cpp \
- $$PWD/stringtoint.cpp \
- $$PWD/backendnode.cpp \
- $$PWD/rendertargetoutput.cpp \
- $$PWD/attachmentpack.cpp \
- $$PWD/uniform.cpp \
- $$PWD/offscreensurfacehelper.cpp \
- $$PWD/resourceaccessor.cpp \
- $$PWD/segmentsvisitor.cpp \
- $$PWD/pointsvisitor.cpp
diff --git a/src/render/backend/rendersettings.cpp b/src/render/backend/rendersettings.cpp
index ab2cef42e..70d6425fd 100644
--- a/src/render/backend/rendersettings.cpp
+++ b/src/render/backend/rendersettings.cpp
@@ -10,11 +10,12 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
+
RenderSettings::RenderSettings()
: BackendNode()
, m_renderPolicy(QRenderSettings::OnDemand)
diff --git a/src/render/backend/rendertarget.cpp b/src/render/backend/rendertarget.cpp
index 5db06e929..8d7463e4f 100644
--- a/src/render/backend/rendertarget.cpp
+++ b/src/render/backend/rendertarget.cpp
@@ -10,11 +10,12 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
+
RenderTarget::RenderTarget()
: BackendNode()
, m_dirty(false)
diff --git a/src/render/backend/rendertargetoutput.cpp b/src/render/backend/rendertargetoutput.cpp
index 045ab6c3d..37bbd1c86 100644
--- a/src/render/backend/rendertargetoutput.cpp
+++ b/src/render/backend/rendertargetoutput.cpp
@@ -8,11 +8,12 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
+
RenderTargetOutput::RenderTargetOutput()
: BackendNode()
{
diff --git a/src/render/backend/transform.cpp b/src/render/backend/transform.cpp
index 8999acaed..629ef51b3 100644
--- a/src/render/backend/transform.cpp
+++ b/src/render/backend/transform.cpp
@@ -6,14 +6,16 @@
#include <Qt3DCore/private/qchangearbiter_p.h>
#include <Qt3DCore/qtransform.h>
#include <Qt3DCore/private/qtransform_p.h>
+#include <Qt3DRender/qcamera.h>
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
+
Transform::Transform()
: BackendNode(ReadWrite)
, m_rotation()
@@ -65,6 +67,13 @@ void Transform::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
m_translation = transform->translation();
if (dirty || firstTime) {
+ auto camera = qobject_cast<const Qt3DRender::QCamera *>(transform->parentNode());
+ if (camera) {
+ m_viewMatrix = Matrix4x4(camera->viewMatrix());
+ m_hasViewMatrix = true;
+ } else {
+ m_hasViewMatrix = false;
+ }
updateMatrix();
markDirty(AbstractRenderer::TransformDirty);
}
diff --git a/src/render/backend/transform_p.h b/src/render/backend/transform_p.h
index 84a2f9962..d6ea68c0c 100644
--- a/src/render/backend/transform_p.h
+++ b/src/render/backend/transform_p.h
@@ -36,6 +36,8 @@ public:
void cleanup();
Matrix4x4 transformMatrix() const;
+ bool hasViewMatrix() const { return m_hasViewMatrix; }
+ const Matrix4x4& viewMatrix() const { return m_viewMatrix; }
QVector3D scale() const;
QQuaternion rotation() const;
QVector3D translation() const;
@@ -44,6 +46,8 @@ public:
private:
void updateMatrix();
+ bool m_hasViewMatrix;
+ Matrix4x4 m_viewMatrix;
Matrix4x4 m_transformMatrix;
QQuaternion m_rotation;
QVector3D m_scale;
diff --git a/src/render/backend/trianglesvisitor.cpp b/src/render/backend/trianglesvisitor.cpp
index 54172bdf4..b5b7e2664 100644
--- a/src/render/backend/trianglesvisitor.cpp
+++ b/src/render/backend/trianglesvisitor.cpp
@@ -18,12 +18,13 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+using namespace Qt3DCore;
+
namespace {
bool isTriangleBased(Qt3DRender::QGeometryRenderer::PrimitiveType type) noexcept
diff --git a/src/render/backend/uniform.cpp b/src/render/backend/uniform.cpp
index 6ef9d8927..d534494f6 100644
--- a/src/render/backend/uniform.cpp
+++ b/src/render/backend/uniform.cpp
@@ -193,7 +193,7 @@ UniformValue UniformValue::fromVariant(const QVariant &variant)
}
case QMetaType::QVariantList: {
const QVariantList variants = variant.toList();
- if (variants.size() < 1)
+ if (variants.empty())
break;
const int listEntryType = variants.first().userType();