summaryrefslogtreecommitdiffstats
path: root/src/plugins/renderers/rhi
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/renderers/rhi')
-rw-r--r--src/plugins/renderers/rhi/CMakeLists.txt9
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpers.pri9
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp188
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h54
-rw-r--r--src/plugins/renderers/rhi/io/io.pri8
-rw-r--r--src/plugins/renderers/rhi/io/rhibuffer.cpp45
-rw-r--r--src/plugins/renderers/rhi/io/rhibuffer_p.h40
-rw-r--r--src/plugins/renderers/rhi/main.cpp40
-rw-r--r--src/plugins/renderers/rhi/managers/managers.pri8
-rw-r--r--src/plugins/renderers/rhi/managers/rhihandle_types_p.h40
-rw-r--r--src/plugins/renderers/rhi/managers/rhiresourcemanagers.cpp42
-rw-r--r--src/plugins/renderers/rhi/managers/rhiresourcemanagers_p.h40
-rw-r--r--src/plugins/renderers/rhi/renderer/commandexecuter.cpp46
-rw-r--r--src/plugins/renderers/rhi/renderer/commandexecuter_p.h42
-rw-r--r--src/plugins/renderers/rhi/renderer/logging.cpp40
-rw-r--r--src/plugins/renderers/rhi/renderer/logging_p.h40
-rw-r--r--src/plugins/renderers/rhi/renderer/pipelineuboset.cpp80
-rw-r--r--src/plugins/renderers/rhi/renderer/pipelineuboset_p.h42
-rw-r--r--src/plugins/renderers/rhi/renderer/rendercommand.cpp46
-rw-r--r--src/plugins/renderers/rhi/renderer/rendercommand_p.h48
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer.cpp308
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer.pri26
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer_p.h45
-rw-r--r--src/plugins/renderers/rhi/renderer/renderview.cpp77
-rw-r--r--src/plugins/renderers/rhi/renderer/renderview_p.h42
-rw-r--r--src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp45
-rw-r--r--src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h40
-rw-r--r--src/plugins/renderers/rhi/renderer/rhigraphicspipeline.cpp40
-rw-r--r--src/plugins/renderers/rhi/renderer/rhigraphicspipeline_p.h42
-rw-r--r--src/plugins/renderers/rhi/renderer/rhirendertarget.cpp40
-rw-r--r--src/plugins/renderers/rhi/renderer/rhirendertarget_p.h55
-rw-r--r--src/plugins/renderers/rhi/renderer/rhishader.cpp163
-rw-r--r--src/plugins/renderers/rhi/renderer/rhishader_p.h59
-rw-r--r--src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp42
-rw-r--r--src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h40
-rw-r--r--src/plugins/renderers/rhi/renderer/shadervariables_p.h40
-rw-r--r--src/plugins/renderers/rhi/rhi.cmake3
-rw-r--r--src/plugins/renderers/rhi/rhi.pri16
-rw-r--r--src/plugins/renderers/rhi/rhi.pro36
-rw-r--r--src/plugins/renderers/rhi/textures/renderbuffer.cpp40
-rw-r--r--src/plugins/renderers/rhi/textures/renderbuffer_p.h40
-rw-r--r--src/plugins/renderers/rhi/textures/texture.cpp82
-rw-r--r--src/plugins/renderers/rhi/textures/texture_p.h40
-rw-r--r--src/plugins/renderers/rhi/textures/textures.pri9
44 files changed, 523 insertions, 1754 deletions
diff --git a/src/plugins/renderers/rhi/CMakeLists.txt b/src/plugins/renderers/rhi/CMakeLists.txt
index f2a9a485b..9e0699a8d 100644
--- a/src/plugins/renderers/rhi/CMakeLists.txt
+++ b/src/plugins/renderers/rhi/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
# Generated from rhi.pro.
set(rhiRendererSources graphicshelpers/submissioncontext.cpp graphicshelpers/submissioncontext_p.h
@@ -20,8 +23,6 @@ set(rhiRendererSources graphicshelpers/submissioncontext.cpp graphicshelpers/sub
textures/texture.cpp textures/texture_p.h
)
-find_package(Qt6 REQUIRED COMPONENTS ShaderTools)
-
#####################################################################
## Static library used for Unit Tests:
#####################################################################
@@ -55,7 +56,6 @@ if(QT_FEATURE_private_tests)
target_compile_definitions(RhiRendererLib PRIVATE
BUILD_QT3D_MODULE
QT_BUILDING_QT
- QT_NO_FOREACH
)
endif()
@@ -94,6 +94,9 @@ qt_internal_add_plugin(RhiRendererPlugin
Qt::ShaderToolsPrivate
)
+# QTransform conflicts
+set_target_properties(RhiRendererPlugin PROPERTIES UNITY_BUILD OFF)
+
#### Keys ignored in scope 1:.:.:rhi.pro:<TRUE>:
# DISTFILES = "rhirenderer.json"
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpers.pri b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpers.pri
deleted file mode 100644
index e156d3ce5..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpers.pri
+++ /dev/null
@@ -1,9 +0,0 @@
-#DEFINES += QT3D_RENDER_ASPECT_OPENGL_DEBUG
-
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/submissioncontext_p.h
-
-SOURCES += \
- $$PWD/submissioncontext.cpp
diff --git a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
index 6d62a6e51..f0dcb044f 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
+++ b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "submissioncontext_p.h"
@@ -62,7 +26,9 @@
#include <Qt3DRender/private/managers_p.h>
#include <Qt3DRender/private/attachmentpack_p.h>
#include <Qt3DRender/private/stringtoint_p.h>
-#include <Qt3DRender/private/vulkaninstance_p.h>
+#if QT_CONFIG(qt3d_vulkan) && QT_CONFIG(vulkan)
+# include <Qt3DRender/private/vulkaninstance_p.h>
+#endif
#include <QGuiApplication>
#include <texture_p.h>
#include <rendercommand_p.h>
@@ -75,46 +41,17 @@
#include <private/qdebug_p.h>
#include <QSurface>
#include <QWindow>
-#include <QtShaderTools/private/qshaderbaker_p.h>
-
-#ifdef Q_OS_WIN
-#include <QtGui/private/qrhid3d11_p.h>
-#endif
-
-#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
-#include <QtGui/private/qrhimetal_p.h>
-#endif
-
-#ifndef QT_NO_OPENGL
-#include <QtGui/private/qrhigles2_p.h>
-#endif
+#include <rhi/qrhi.h>
+#include <rhi/qshaderbaker.h>
-#if QT_CONFIG(qt3d_vulkan)
-#include <QtGui/private/qrhivulkan_p.h>
-#endif
#include <bitset>
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
-
namespace Qt3DRender {
namespace Render {
namespace Rhi {
-static QHash<unsigned int, SubmissionContext *> static_contexts;
-
-unsigned int nextFreeContextId() noexcept
-{
- for (unsigned int i = 0; i < 0xffff; ++i) {
- if (!static_contexts.contains(i))
- return i;
- }
-
- qFatal("Couldn't find free context ID");
- return 0;
-}
-
namespace {
//RHIBuffer::Type attributeTypeToGLBufferType(QAttribute::AttributeType type) noexcept
@@ -476,6 +413,13 @@ void applyStateHelper(const StencilMask *state, QRhiGraphicsPipeline *gp) noexce
gp->setStencilReadMask(std::get<1>(values));
}
+void applyStateHelper(const LineWidth *state, QRhiGraphicsPipeline *gp) noexcept
+{
+ const auto values = state->values();
+ gp->setLineWidth(std::get<0>(values));
+ // no GL_LINE_SMOOTH equivalent on RHI
+}
+
static QShader::Stage rhiShaderStage(QShaderProgram::ShaderType type) noexcept
{
switch (type) {
@@ -499,15 +443,11 @@ static QShader::Stage rhiShaderStage(QShaderProgram::ShaderType type) noexcept
} // anonymous
SubmissionContext::SubmissionContext()
- : m_ownsRhiCtx(false),
+ : m_initialized(false),
+ m_ownsRhiCtx(false),
m_drivenExternally(false),
- m_id(nextFreeContextId()),
- m_surface(nullptr),
- m_renderTargetFormat(QAbstractTexture::NoFormat),
m_material(nullptr),
m_renderer(nullptr),
- m_uboTempArray(QByteArray(1024, 0)),
- m_initialized(false),
m_rhi(nullptr),
m_currentSwapChain(nullptr),
m_currentRenderPassDescriptor(nullptr),
@@ -518,7 +458,6 @@ SubmissionContext::SubmissionContext()
m_fallbackSurface(nullptr)
#endif
{
- static_contexts[m_id] = this;
m_contextInfo.m_api = QGraphicsApiFilter::RHI;
// We set those version numbers because QShaderGenerator wants major > 0
@@ -529,9 +468,6 @@ SubmissionContext::SubmissionContext()
SubmissionContext::~SubmissionContext()
{
releaseResources();
-
- Q_ASSERT(static_contexts[m_id] == this);
- static_contexts.remove(m_id);
}
void SubmissionContext::initialize()
@@ -578,7 +514,7 @@ void SubmissionContext::initialize()
QRhi::Flags rhiFlags = QRhi::EnableDebugMarkers;
-#if QT_CONFIG(qt3d_vulkan)
+#if QT_CONFIG(qt3d_vulkan) && QT_CONFIG(vulkan)
if (requestedApi == Qt3DRender::API::Vulkan) {
QRhiVulkanInitParams params;
params.inst = &Qt3DRender::staticVulkanInstance();
@@ -645,8 +581,6 @@ bool SubmissionContext::beginDrawing(QSurface *surface)
{
Q_ASSERT(surface);
- m_surface = surface;
-
Q_ASSERT(isInitialized());
// In the Scene3D case it does not make sense to create SwapChains as we
@@ -661,7 +595,7 @@ bool SubmissionContext::beginDrawing(QSurface *surface)
QRhiSwapChain *swapChain = swapChainInfo->swapChain;
// Resize swapchain if needed
- if (m_surface->size() != swapChain->currentPixelSize()) {
+ if (surface->size() != swapChain->currentPixelSize()) {
bool couldRebuild = swapChain->createOrResize();
if (!couldRebuild)
return false;
@@ -838,6 +772,11 @@ void SubmissionContext::releaseResources()
m_renderBufferHash.clear();
RHI_UNIMPLEMENTED;
+ if (m_currentUpdates) {
+ m_currentUpdates->release();
+ m_currentUpdates = nullptr;
+ }
+
// Free RHI resources
{
qCDebug(Backend) << Q_FUNC_INFO;
@@ -1308,7 +1247,7 @@ void SubmissionContext::uploadDataToRHIBuffer(Buffer *buffer, RHIBuffer *b)
// We have a partial update
if (update->offset >= 0) {
// accumulate sequential updates as single one
- int bufferSize = update->data.size();
+ qsizetype bufferSize = update->data.size();
auto it2 = it + 1;
while ((it2 != updates.end()) && (it2->offset - update->offset == bufferSize)) {
bufferSize += it2->data.size();
@@ -1390,7 +1329,7 @@ void preprocessRHIShader(std::vector<QByteArray> &shaderCodes)
"\\s*,\\s*std140.*)\\)\\s*uniform\\s*([a-zA-Z0-9_]+)"));
auto replaceBinding = [&bindings, &assignedBindings](
- int &offset, QRegularExpressionMatch &match, QString &code,
+ qsizetype &offset, QRegularExpressionMatch &match, QString &code,
int indexCapture, int variableCapture) noexcept {
int index = match.captured(indexCapture).toInt();
QByteArray variable = match.captured(variableCapture).toUtf8();
@@ -1404,9 +1343,9 @@ void preprocessRHIShader(std::vector<QByteArray> &shaderCodes)
return;
}
- const int indexStartOffset = match.capturedStart(indexCapture);
- const int indexEndOffset = match.capturedEnd(indexCapture);
- const int indexLength = indexEndOffset - indexStartOffset;
+ const qsizetype indexStartOffset = match.capturedStart(indexCapture);
+ const qsizetype indexEndOffset = match.capturedEnd(indexCapture);
+ const qsizetype indexLength = indexEndOffset - indexStartOffset;
code.replace(indexStartOffset, indexLength, QByteArray::number(index));
}
@@ -1414,9 +1353,9 @@ void preprocessRHIShader(std::vector<QByteArray> &shaderCodes)
bindings.emplace(std::move(variable), index);
} else {
int indexToUse = it->second;
- const int indexStartOffset = match.capturedStart(indexCapture);
- const int indexEndOffset = match.capturedEnd(indexCapture);
- const int indexLength = indexEndOffset - indexStartOffset;
+ const qsizetype indexStartOffset = match.capturedStart(indexCapture);
+ const qsizetype indexEndOffset = match.capturedEnd(indexCapture);
+ const qsizetype indexLength = indexEndOffset - indexStartOffset;
code.replace(indexStartOffset, indexLength, QByteArray::number(indexToUse));
}
// This may fail in the case where the replaced offset is an incredibly long number,
@@ -1429,7 +1368,7 @@ void preprocessRHIShader(std::vector<QByteArray> &shaderCodes)
QString shaderString = shaderCode;
// Regex for the sampler variables
- int offset = 0;
+ qsizetype offset = 0;
auto match = samplerRegex.match(shaderString, offset);
while (match.hasMatch()) {
const int indexCapture = 1;
@@ -1454,26 +1393,45 @@ void preprocessRHIShader(std::vector<QByteArray> &shaderCodes)
}
}
-int glslVersionForFormat(const QSurfaceFormat &format) noexcept
+QShaderVersion glslVersionForFormat(const QSurfaceFormat &format) noexcept
{
const int major = format.majorVersion();
const int minor = format.minorVersion();
-
- static const QHash<std::pair<int, int>, int> glVersionToGLSLVersion = {
- { { 4, 6 }, 460 }, { { 4, 5 }, 450 }, { { 4, 4 }, 440 }, { { 4, 3 }, 430 },
- { { 4, 2 }, 420 }, { { 4, 1 }, 410 }, { { 4, 0 }, 400 }, { { 3, 3 }, 330 },
- { { 3, 2 }, 150 }, { { 3, 2 }, 120 }, { { 3, 1 }, 120 },
- };
-
- const auto it = glVersionToGLSLVersion.find({ major, minor });
- if (it == glVersionToGLSLVersion.end()) {
- if (major < 3) {
- return 120;
+ const auto type = format.renderableType();
+
+ if (type != QSurfaceFormat::OpenGLES) {
+ static const QHash<std::pair<int, int>, int> glVersionToGLSLVersion = {
+ { { 4, 6 }, 460 }, { { 4, 5 }, 450 }, { { 4, 4 }, 440 }, { { 4, 3 }, 430 },
+ { { 4, 2 }, 420 }, { { 4, 1 }, 410 }, { { 4, 0 }, 400 }, { { 3, 3 }, 330 },
+ { { 3, 2 }, 150 }, { { 3, 2 }, 120 }, { { 3, 1 }, 120 },
+ };
+
+ const auto it = glVersionToGLSLVersion.find({ major, minor });
+ if (it == glVersionToGLSLVersion.end()) {
+ if (major < 3) {
+ return 120;
+ } else {
+ return major * 100 + minor * 10;
+ }
} else {
- return major * 100 + minor * 10;
+ return *it;
+ }
+ }
+ else {
+ static const QHash<std::pair<int, int>, int> glVersionToGLSLVersion = {
+ { { 3, 2 }, 320 }, { { 3, 1 }, 310 }, { { 3, 0 }, 300 },
+ };
+
+ const auto it = glVersionToGLSLVersion.find({ major, minor });
+ if (it == glVersionToGLSLVersion.end()) {
+ if (major < 3) {
+ return {100, QShaderVersion::GlslEs};
+ } else {
+ return {major * 100 + minor * 10, QShaderVersion::GlslEs};
+ }
+ } else {
+ return {*it, QShaderVersion::GlslEs};
}
- } else {
- return *it;
}
}
}
@@ -1559,12 +1517,14 @@ void SubmissionContext::loadShader(Shader *shaderNode, ShaderManager *shaderMana
const std::vector<Qt3DCore::QNodeId> &sharedShaderIds =
rhiShaderManager->shaderIdsForProgram(rhiShader);
if (sharedShaderIds.size() == 1) {
- // Shader in the cache hasn't been loaded yet
- // We want a copy of the QByteArray as preprocessRHIShader will
- // modify them
- std::vector<QByteArray> shaderCodes = shaderNode->shaderCode();
- preprocessRHIShader(shaderCodes);
- rhiShader->setShaderCode(shaderCodes);
+ {
+ // Shader in the cache hasn't been loaded yet
+ // We want a copy of the QByteArray as preprocessRHIShader will
+ // modify them
+ std::vector<QByteArray> shaderCodes = shaderNode->shaderCode();
+ preprocessRHIShader(shaderCodes);
+ rhiShader->setShaderCode(std::move(shaderCodes));
+ }
const ShaderCreationInfo loadResult = createShaderProgram(rhiShader);
shaderNode->setStatus(loadResult.linkSucceeded ? QShaderProgram::Ready
diff --git a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h
index f48c11234..bb639ccfc 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h
+++ b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_SUBMISSIONCONTEXT_H
#define QT3DRENDER_RENDER_RHI_SUBMISSIONCONTEXT_H
@@ -63,8 +27,8 @@
#include <shadervariables_p.h>
#include <rhihandle_types_p.h>
#include <QSurface>
-#include <QtGui/private/qrhi_p.h>
#include <QOffscreenSurface>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
@@ -207,23 +171,15 @@ private:
// States
void applyState(const StateVariant &state, QRhiGraphicsPipeline *graphicsPipeline);
+ bool m_initialized;
bool m_ownsRhiCtx;
bool m_drivenExternally;
- const unsigned int m_id;
- QSurface *m_surface;
- QSize m_surfaceSize;
QHash<Qt3DCore::QNodeId, HRHIBuffer> m_renderBufferHash;
- QHash<Qt3DCore::QNodeId, GLuint> m_renderTargets;
- QHash<GLuint, QSize> m_renderTargetsSize;
- QAbstractTexture::TextureFormat m_renderTargetFormat;
Material *m_material;
Renderer *m_renderer;
- QByteArray m_uboTempArray;
-
- bool m_initialized;
GraphicsApiFilterData m_contextInfo;
diff --git a/src/plugins/renderers/rhi/io/io.pri b/src/plugins/renderers/rhi/io/io.pri
deleted file mode 100644
index bac06ba95..000000000
--- a/src/plugins/renderers/rhi/io/io.pri
+++ /dev/null
@@ -1,8 +0,0 @@
-INCLUDEPATH += $$PWD
-
-SOURCES += \
- $$PWD/rhibuffer.cpp
-
-HEADERS += \
- $$PWD/rhibuffer_p.h
-
diff --git a/src/plugins/renderers/rhi/io/rhibuffer.cpp b/src/plugins/renderers/rhi/io/rhibuffer.cpp
index f20d3c4d1..9607e8c32 100644
--- a/src/plugins/renderers/rhi/io/rhibuffer.cpp
+++ b/src/plugins/renderers/rhi/io/rhibuffer.cpp
@@ -1,45 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "rhibuffer_p.h"
#include <submissioncontext_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
+
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
@@ -86,7 +51,7 @@ bool RHIBuffer::bind(SubmissionContext *ctx, Type t)
return bool(m_rhiBuffer);
const auto uploadMethod = m_dynamic ? &QRhiResourceUpdateBatch::updateDynamicBuffer
- : qOverload<QRhiBuffer *, int, int, const void *>(
+ : qOverload<QRhiBuffer *, quint32, quint32, const void *>(
&QRhiResourceUpdateBatch::uploadStaticBuffer);
if (!m_rhiBuffer) {
if (m_allocSize <= 0)
diff --git a/src/plugins/renderers/rhi/io/rhibuffer_p.h b/src/plugins/renderers/rhi/io/rhibuffer_p.h
index 52023332b..383363081 100644
--- a/src/plugins/renderers/rhi/io/rhibuffer_p.h
+++ b/src/plugins/renderers/rhi/io/rhibuffer_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RHIBUFFER_P_H
#define QT3DRENDER_RENDER_RHI_RHIBUFFER_P_H
diff --git a/src/plugins/renderers/rhi/main.cpp b/src/plugins/renderers/rhi/main.cpp
index 174b385de..13ff951b8 100644
--- a/src/plugins/renderers/rhi/main.cpp
+++ b/src/plugins/renderers/rhi/main.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <Qt3DRender/private/qrendererplugin_p.h>
#include <renderer_p.h>
diff --git a/src/plugins/renderers/rhi/managers/managers.pri b/src/plugins/renderers/rhi/managers/managers.pri
deleted file mode 100644
index de3f29b30..000000000
--- a/src/plugins/renderers/rhi/managers/managers.pri
+++ /dev/null
@@ -1,8 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/rhihandle_types_p.h \
- $$PWD/rhiresourcemanagers_p.h
-
-SOURCES += \
- $$PWD/rhiresourcemanagers.cpp
diff --git a/src/plugins/renderers/rhi/managers/rhihandle_types_p.h b/src/plugins/renderers/rhi/managers/rhihandle_types_p.h
index 8ae440e6d..5659db2a6 100644
--- a/src/plugins/renderers/rhi/managers/rhihandle_types_p.h
+++ b/src/plugins/renderers/rhi/managers/rhihandle_types_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RHIHANDLE_TYPES_P_H
#define QT3DRENDER_RENDER_RHI_RHIHANDLE_TYPES_P_H
diff --git a/src/plugins/renderers/rhi/managers/rhiresourcemanagers.cpp b/src/plugins/renderers/rhi/managers/rhiresourcemanagers.cpp
index 5be374aa2..bd7ebce0b 100644
--- a/src/plugins/renderers/rhi/managers/rhiresourcemanagers.cpp
+++ b/src/plugins/renderers/rhi/managers/rhiresourcemanagers.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "rhiresourcemanagers_p.h"
@@ -81,7 +45,7 @@ void RHIResourceManagers::releaseAllResources()
releaseAll(m_rhiTextureManager);
releaseAll(m_rhiBufferManager);
- // releaseAll(m_rhiShaderManager);
+ qDeleteAll(m_rhiShaderManager->takeActiveResources());
releaseAll(m_rhiRenderTargetManager);
releaseAll(m_rhiGraphicsPipelineManager);
releaseAll(m_rhiComputePipelineManager);
diff --git a/src/plugins/renderers/rhi/managers/rhiresourcemanagers_p.h b/src/plugins/renderers/rhi/managers/rhiresourcemanagers_p.h
index 0e15afe91..85c01a09e 100644
--- a/src/plugins/renderers/rhi/managers/rhiresourcemanagers_p.h
+++ b/src/plugins/renderers/rhi/managers/rhiresourcemanagers_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RHIRESOURCEMANAGERS_P_H
#define QT3DRENDER_RENDER_RHI_RHIRESOURCEMANAGERS_P_H
diff --git a/src/plugins/renderers/rhi/renderer/commandexecuter.cpp b/src/plugins/renderers/rhi/renderer/commandexecuter.cpp
index 359e377bc..eaceb270a 100644
--- a/src/plugins/renderers/rhi/renderer/commandexecuter.cpp
+++ b/src/plugins/renderers/rhi/renderer/commandexecuter.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 Paul Lemire <paul.lemire350@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2016 Paul Lemire <paul.lemire350@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "commandexecuter_p.h"
@@ -304,7 +268,9 @@ QJsonObject parameterPackToJson(const Render::Rhi::ShaderParameterPack &pack) no
} // anonymous
-CommandExecuter::CommandExecuter(Render::Rhi::Renderer *renderer) : m_renderer(renderer) { }
+CommandExecuter::CommandExecuter(Render::Rhi::Renderer *renderer) : m_renderer(renderer) {
+ Q_UNUSED(m_renderer)
+}
// Render thread
void CommandExecuter::performAsynchronousCommandExecution(
diff --git a/src/plugins/renderers/rhi/renderer/commandexecuter_p.h b/src/plugins/renderers/rhi/renderer/commandexecuter_p.h
index e683253a7..1ee60afe3 100644
--- a/src/plugins/renderers/rhi/renderer/commandexecuter_p.h
+++ b/src/plugins/renderers/rhi/renderer/commandexecuter_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 Paul Lemire <paul.lemire350@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2016 Paul Lemire <paul.lemire350@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_DEBUG_COMMANDEXECUTER_H
#define QT3DRENDER_DEBUG_COMMANDEXECUTER_H
diff --git a/src/plugins/renderers/rhi/renderer/logging.cpp b/src/plugins/renderers/rhi/renderer/logging.cpp
index 1aaa68208..265a48bca 100644
--- a/src/plugins/renderers/rhi/renderer/logging.cpp
+++ b/src/plugins/renderers/rhi/renderer/logging.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "logging_p.h"
diff --git a/src/plugins/renderers/rhi/renderer/logging_p.h b/src/plugins/renderers/rhi/renderer/logging_p.h
index 45d63978d..295181685 100644
--- a/src/plugins/renderers/rhi/renderer/logging_p.h
+++ b/src/plugins/renderers/rhi/renderer/logging_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RENDERLOGGING_P_H
#define QT3DRENDER_RENDER_RHI_RENDERLOGGING_P_H
diff --git a/src/plugins/renderers/rhi/renderer/pipelineuboset.cpp b/src/plugins/renderers/rhi/renderer/pipelineuboset.cpp
index ce53de1ab..8cffaac4f 100644
--- a/src/plugins/renderers/rhi/renderer/pipelineuboset.cpp
+++ b/src/plugins/renderers/rhi/renderer/pipelineuboset.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "pipelineuboset_p.h"
#include <rendercommand_p.h>
@@ -46,7 +10,7 @@
#include <rhigraphicspipeline_p.h>
#include <rhiresourcemanagers_p.h>
#include <submissioncontext_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <Qt3DRender/private/nodemanagers_p.h>
#include <Qt3DRender/private/buffermanager_p.h>
#include <Qt3DRender/private/stringtoint_p.h>
@@ -220,14 +184,14 @@ std::vector<QRhiCommandBuffer::DynamicOffset> PipelineUBOSet::offsets(const Rend
const size_t dToCmd = distanceToCommand(cmd);
{
// Compute offset relative to the select UBO in the subset
- const size_t localOffset = m_commandsUBO.localOffsetInBufferForCommand(dToCmd);
- offsets.push_back({1, localOffset});
+ const auto localOffset = m_commandsUBO.localOffsetInBufferForCommand(dToCmd);
+ offsets.push_back({1, quint32(localOffset)});
}
for (const MultiUBOBufferWithBindingAndBlockSize &materialUBO : m_materialsUBOs) {
// Compute offset relative to the select UBO in the subset
const size_t localOffset = materialUBO.localOffsetInBufferForCommand(dToCmd);
- offsets.push_back({materialUBO.binding, localOffset});
+ offsets.push_back({materialUBO.binding, quint32(localOffset)});
}
return offsets;
@@ -279,7 +243,7 @@ std::vector<QRhiShaderResourceBinding> PipelineUBOSet::resourceBindings(const Re
{
RHITextureManager *textureManager = m_resourceManagers->rhiTextureManager();
RHIShader *shader = command.m_rhiShader;
- const QRhiShaderResourceBinding::StageFlags stages = QRhiShaderResourceBinding::VertexStage|QRhiShaderResourceBinding::FragmentStage;
+ const QRhiShaderResourceBinding::StageFlags stages = QRhiShaderResourceBinding::ComputeStage|QRhiShaderResourceBinding::VertexStage|QRhiShaderResourceBinding::FragmentStage;
std::vector<QRhiShaderResourceBinding> bindings = {
QRhiShaderResourceBinding::uniformBuffer(0, stages, m_rvUBO.buffer->rhiBuffer()),
};
@@ -359,9 +323,10 @@ std::vector<QRhiShaderResourceBinding> PipelineUBOSet::resourceBindings(const Re
for (const BlockToSSBO &ssbo : command.m_parameterPack.shaderStorageBuffers()) {
RHIBuffer *buffer = m_resourceManagers->rhiBufferManager()->lookupResource(ssbo.m_bufferID);
if (buffer) {
+ Q_ASSERT(stages & QRhiShaderResourceBinding::ComputeStage);
bindings.push_back(QRhiShaderResourceBinding::bufferLoadStore(
ssbo.m_bindingIndex,
- stages|QRhiShaderResourceBinding::ComputeStage,
+ stages,
buffer->rhiBuffer()));
}
}
@@ -618,31 +583,36 @@ void PipelineUBOSet::uploadUBOsForCommand(const RenderCommand &command,
if (ubo == nullptr)
continue;
- for (const RHIShader::UBO_Member &member : qAsConst(uboBlock.members)) {
+ for (const RHIShader::UBO_Member &member : std::as_const(uboBlock.members)) {
const QShaderDescription::BlockVariable &blockVariable = member.blockVariable;
+
+ // Array
if (!blockVariable.arrayDims.empty()) {
- if (!blockVariable.structMembers.empty()) {
- const int arr0 = blockVariable.arrayDims[0];
- for (int i = 0; i < arr0; i++) {
- for (const RHIShader::UBO_Member &structMember : member.structMembers) {
+ if (!blockVariable.structMembers.empty()) { // Array of structs
+ // we treat structMembers as arrayMembers when we are dealing with an array of structs´
+ const size_t arr0 = size_t(blockVariable.arrayDims[0]);
+ const size_t m = std::max(arr0, member.structMembers.size());
+ for (size_t i = 0; i < m; ++i) {
+ const RHIShader::UBO_Member &arrayMember = member.structMembers[i];
+ for (const RHIShader::UBO_Member &arrayStructMember : arrayMember.structMembers) {
uploadUniform(uniforms, ubo,
- structMember,
+ arrayStructMember,
distanceToCommand,
- i * blockVariable.size / arr0);
+ int(i * blockVariable.size / arr0));
}
}
- } else {
+ } else { // Array of scalars
uploadUniform(uniforms, ubo,
member, distanceToCommand);
}
} else {
- if (!blockVariable.structMembers.empty()) {
+ if (!blockVariable.structMembers.empty()) { // Struct
for (const RHIShader::UBO_Member &structMember : member.structMembers) {
uploadUniform(uniforms, ubo,
structMember,
distanceToCommand);
}
- } else {
+ } else { // Scalar
uploadUniform(uniforms, ubo,
member, distanceToCommand);
}
@@ -692,7 +662,7 @@ void PipelineUBOSet::uploadUBOsForCommand(const RenderCommand &command,
continue;
// Upload ShaderData property that match members of each UBO block instance
- for (const RHIShader::UBO_Member &uboInstance : qAsConst(block->members)) {
+ for (const RHIShader::UBO_Member &uboInstance : std::as_const(block->members)) {
uploadShaderDataProperty(shaderData, materialsUBO,
uboInstance, distanceToCommand);
}
diff --git a/src/plugins/renderers/rhi/renderer/pipelineuboset_p.h b/src/plugins/renderers/rhi/renderer/pipelineuboset_p.h
index e3902a5c6..55c3bbb60 100644
--- a/src/plugins/renderers/rhi/renderer/pipelineuboset_p.h
+++ b/src/plugins/renderers/rhi/renderer/pipelineuboset_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_PIPELINEUBOSET_H
#define QT3DRENDER_RENDER_RHI_PIPELINEUBOSET_H
@@ -52,7 +16,7 @@
//
#include <rhihandle_types_p.h>
-#include <private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <shadervariables_p.h>
#include <rhishader_p.h>
diff --git a/src/plugins/renderers/rhi/renderer/rendercommand.cpp b/src/plugins/renderers/rhi/renderer/rendercommand.cpp
index 06fb3bec0..e9ef1e99b 100644
--- a/src/plugins/renderers/rhi/renderer/rendercommand.cpp
+++ b/src/plugins/renderers/rhi/renderer/rendercommand.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "rendercommand_p.h"
#include "rhigraphicspipeline_p.h"
@@ -95,6 +59,12 @@ RenderCommand::RenderCommand()
m_workGroups[2] = 0;
}
+RenderCommand::~RenderCommand()
+{
+ if (shaderResourceBindings)
+ shaderResourceBindings->deleteLater();
+}
+
bool RenderCommand::isValid() const noexcept
{
return m_isValid && m_rhiShader && pipeline.isValid();
diff --git a/src/plugins/renderers/rhi/renderer/rendercommand_p.h b/src/plugins/renderers/rhi/renderer/rendercommand_p.h
index 9e2585588..392650385 100644
--- a/src/plugins/renderers/rhi/renderer/rendercommand_p.h
+++ b/src/plugins/renderers/rhi/renderer/rendercommand_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RENDERCOMMAND_H
#define QT3DRENDER_RENDER_RHI_RENDERCOMMAND_H
@@ -62,7 +26,7 @@
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QMatrix4x4>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <Qt3DCore/qattribute.h>
#include <variant>
@@ -93,8 +57,9 @@ struct CommandUBO
float mvp[16];
float inverseModelViewProjectionMatrix[16];
float modelViewNormalMatrix[12];
+ float skinningPalette[100 * 16];
};
-static_assert(sizeof(CommandUBO) == 6 * (16 * sizeof(float)) + 2 * (12 * sizeof(float)),
+static_assert(sizeof(CommandUBO) == 6 * (16 * sizeof(float)) + 2 * (12 * sizeof(float)) + 100 * (16 * sizeof(float)),
"UBO doesn't match std140");
struct Q_AUTOTEST_EXPORT AttributeInfo
@@ -113,6 +78,7 @@ class Q_AUTOTEST_EXPORT RenderCommand
{
public:
RenderCommand();
+ ~RenderCommand();
bool isValid() const noexcept;
diff --git a/src/plugins/renderers/rhi/renderer/renderer.cpp b/src/plugins/renderers/rhi/renderer/renderer.cpp
index 7774c91fe..4a25bb464 100644
--- a/src/plugins/renderers/rhi/renderer/renderer.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderer.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "renderer_p.h"
#include "rhirendertarget_p.h"
@@ -129,8 +93,6 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
-
namespace Qt3DRender {
namespace Render {
namespace Rhi {
@@ -372,7 +334,7 @@ void Renderer::setNodeManagers(NodeManagers *managers)
m_computableEntityFilterJob->setManager(m_nodesManager->renderNodesManager());
}
-void Renderer::setServices(QServiceLocator *services)
+void Renderer::setServices(Qt3DCore::QServiceLocator *services)
{
m_services = services;
@@ -649,12 +611,12 @@ void Renderer::render(bool swapBuffers)
// RenderQueue is complete (but that means it may be of size 0)
if (!queueIsEmpty) {
- QTaskLogger submissionStatsPart1(m_services->systemInformation(),
- { JobTypes::FrameSubmissionPart1, 0 },
- QTaskLogger::Submission);
- QTaskLogger submissionStatsPart2(m_services->systemInformation(),
- { JobTypes::FrameSubmissionPart2, 0 },
- QTaskLogger::Submission);
+ Qt3DCore::QTaskLogger submissionStatsPart1(m_services->systemInformation(),
+ { JobTypes::FrameSubmissionPart1, 0 },
+ Qt3DCore::QTaskLogger::Submission);
+ Qt3DCore::QTaskLogger submissionStatsPart2(m_services->systemInformation(),
+ { JobTypes::FrameSubmissionPart2, 0 },
+ Qt3DCore::QTaskLogger::Submission);
std::vector<RHIPassInfo> rhiPassesInfo;
@@ -795,8 +757,8 @@ QSurfaceFormat Renderer::format()
namespace {
std::optional<QRhiVertexInputAttribute::Format> rhiAttributeType(Attribute *attr) {
switch (attr->vertexBaseType()) {
- case QAttribute::Byte:
- case QAttribute::UnsignedByte: {
+ case Qt3DCore::QAttribute::Byte:
+ case Qt3DCore::QAttribute::UnsignedByte: {
if (attr->vertexSize() == 1)
return QRhiVertexInputAttribute::UNormByte;
if (attr->vertexSize() == 2)
@@ -805,7 +767,18 @@ std::optional<QRhiVertexInputAttribute::Format> rhiAttributeType(Attribute *attr
return QRhiVertexInputAttribute::UNormByte4;
break;
}
- case QAttribute::UnsignedInt: {
+ case Qt3DCore::QAttribute::Int: {
+ if (attr->vertexSize() == 1)
+ return QRhiVertexInputAttribute::SInt;
+ if (attr->vertexSize() == 2)
+ return QRhiVertexInputAttribute::SInt2;
+ if (attr->vertexSize() == 3)
+ return QRhiVertexInputAttribute::SInt3;
+ if (attr->vertexSize() == 4)
+ return QRhiVertexInputAttribute::SInt4;
+ break;
+ }
+ case Qt3DCore::QAttribute::UnsignedInt: {
if (attr->vertexSize() == 1)
return QRhiVertexInputAttribute::UInt;
if (attr->vertexSize() == 2)
@@ -816,7 +789,18 @@ std::optional<QRhiVertexInputAttribute::Format> rhiAttributeType(Attribute *attr
return QRhiVertexInputAttribute::UInt4;
break;
}
- case QAttribute::Float: {
+ case Qt3DCore::QAttribute::HalfFloat: {
+ if (attr->vertexSize() == 1)
+ return QRhiVertexInputAttribute::Half;
+ if (attr->vertexSize() == 2)
+ return QRhiVertexInputAttribute::Half2;
+ if (attr->vertexSize() == 3)
+ return QRhiVertexInputAttribute::Half3;
+ if (attr->vertexSize() >= 4)
+ return QRhiVertexInputAttribute::Half4;
+ break;
+ }
+ case Qt3DCore::QAttribute::Float: {
if (attr->vertexSize() == 1)
return QRhiVertexInputAttribute::Float;
if (attr->vertexSize() == 2)
@@ -1179,16 +1163,24 @@ void Renderer::createRenderTarget(RenderTarget *target)
}
};
+ RHIRenderTarget::BackBuffer backBuffer = RHIRenderTarget::BackBuffer::None;
+
// Look up attachments to populate the RT description
// Attachments are sorted by attachment point (Color0 is first)
for (const Attachment &attachment : pack.attachments()) {
+
+ if (attachment.m_point == QRenderTargetOutput::Left || attachment.m_point == QRenderTargetOutput::Right) {
+ backBuffer = attachment.m_point == QRenderTargetOutput::Left ? RHIRenderTarget::BackBuffer::Left : RHIRenderTarget::BackBuffer::Right;
+ break;
+ }
+
RHITexture *tex = texman->lookupResource(attachment.m_textureUuid);
if (tex && tex->getRhiTexture()) {
-
auto rhiTex = tex->getRhiTexture();
if (!rhiTex->flags().testFlag(QRhiTexture::RenderTarget) ||
!rhiTex->flags().testFlag(QRhiTexture::UsedAsTransferSource)) {
// UsedAsTransferSource is required if we ever want to read back from the texture
+ rhiTex->destroy();
rhiTex->setFlags(rhiTex->flags() | QRhiTexture::RenderTarget|QRhiTexture::UsedAsTransferSource);
rhiTex->create();
}
@@ -1221,6 +1213,12 @@ void Renderer::createRenderTarget(RenderTarget *target)
}
}
+ rhiTarget->backBuffer = backBuffer;
+ // If we are targeting one of the back buffers directly, don't create an offscreen RT
+ if (backBuffer != RHIRenderTarget::BackBuffer::None)
+ return;
+
+ // Otherwise, create QRhiRenderBuffer and associated resources
if (targetSize.width() <= 0 || targetSize.height() <= 0) {
cleanAllocatedResources();
return;
@@ -1270,6 +1268,12 @@ bool Renderer::setupRenderTarget(RenderView *rv,
const auto &managers = *nodeManagers();
auto &renderTargetManager = *managers.renderTargetManager();
+ auto useSwapchainForPipeline = [&]() {
+ Q_ASSERT(swapchain);
+ rhiPipeline->setRenderPassDescriptor(swapchain->renderPassDescriptor());
+ rhiPipeline->setSampleCount(swapchain->sampleCount());
+ };
+
auto *renderTarget = renderTargetManager.lookupResource(rv->renderTargetId());
if (renderTarget) {
// Render to texture
@@ -1277,14 +1281,25 @@ bool Renderer::setupRenderTarget(RenderView *rv,
RHIRenderTargetManager *rhiRenderTargetManager = m_RHIResourceManagers->rhiRenderTargetManager();
RHIRenderTarget *rhiTarget = rhiRenderTargetManager->lookupResource(renderTargetId);
- if (!rhiTarget || !rhiTarget->renderTarget) {
+ if (!rhiTarget) {
qWarning(Backend) << "Invalid RenderTarget " << renderTargetId << " for Pipeline";
return false;
}
- rhiPipeline->setRenderPassDescriptor(rhiTarget->renderPassDescriptor);
- rhiPipeline->setSampleCount(rhiTarget->renderTarget->sampleCount());
+ // The RenderTarget we reference might actually be referencing a swapchain back buffer
+ if (rhiTarget->backBuffer != RHIRenderTarget::BackBuffer::None) {
+ // Render to the default framebuffer on our swapchain
+ useSwapchainForPipeline();
+ } else {
+ if (!rhiTarget->renderTarget) {
+ qWarning(Backend) << "Invalid RenderTarget " << renderTargetId << " for Pipeline";
+ return false;
+ }
+ rhiPipeline->setRenderPassDescriptor(rhiTarget->renderPassDescriptor);
+ rhiPipeline->setSampleCount(rhiTarget->renderTarget->sampleCount());
+ }
return true;
+
} else if (m_submissionContext->defaultRenderTarget()) {
// Use default RenderTarget if set Default FBO set by Scene3D
QRhiRenderTarget *defaultTarget = m_submissionContext->defaultRenderTarget();;
@@ -1292,10 +1307,8 @@ bool Renderer::setupRenderTarget(RenderView *rv,
rhiPipeline->setSampleCount(defaultTarget->sampleCount());
return true;
} else {
- Q_ASSERT(swapchain);
// Render to the default framebuffer on our swapchain
- rhiPipeline->setRenderPassDescriptor(swapchain->renderPassDescriptor());
- rhiPipeline->setSampleCount(swapchain->sampleCount());
+ useSwapchainForPipeline();
return true;
}
}
@@ -1422,11 +1435,11 @@ Renderer::prepareCommandsSubmission(const std::vector<RenderView *> &renderViews
// Note: we cannot do it in the loop above as we want to be sure that all
// the VAO which reference the geometry/attributes are properly updated
RHI_UNIMPLEMENTED;
- for (Attribute *attribute : qAsConst(m_dirtyAttributes))
+ for (Attribute *attribute : std::as_const(m_dirtyAttributes))
attribute->unsetDirty();
m_dirtyAttributes.clear();
- for (Geometry *geometry : qAsConst(m_dirtyGeometry))
+ for (Geometry *geometry : std::as_const(m_dirtyGeometry))
geometry->unsetDirty();
m_dirtyGeometry.clear();
@@ -1478,10 +1491,10 @@ void Renderer::lookForDirtyTextures()
const std::vector<HTexture> &activeTextureHandles = textureManager->activeHandles();
for (const HTexture &handle : activeTextureHandles) {
Texture *texture = textureManager->data(handle);
- const QNodeIdVector imageIds = texture->textureImageIds();
+ const Qt3DCore::QNodeIdVector imageIds = texture->textureImageIds();
// Does the texture reference any of the dirty texture images?
- for (const QNodeId &imageId : imageIds) {
+ for (const Qt3DCore::QNodeId &imageId : imageIds) {
if (dirtyImageIds.contains(imageId)) {
texture->addDirtyFlag(Texture::DirtyImageGenerators);
break;
@@ -1511,7 +1524,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 Qt3DCore::QNodeId &passId : passIds) {
RenderPass *renderPass =
m_nodesManager->renderPassManager()->lookupResource(passId);
HShader shaderHandle =
@@ -1564,12 +1577,15 @@ void Renderer::sendShaderChangesToFrontend(Qt3DCore::QAspectManager *manager)
const std::vector<HShader> &activeShaders = m_nodesManager->shaderManager()->activeHandles();
for (const HShader &handle : activeShaders) {
Shader *s = m_nodesManager->shaderManager()->data(handle);
+ if (!s)
+ continue;
+
if (s->requiresFrontendSync()) {
QShaderProgram *frontend =
static_cast<decltype(frontend)>(manager->lookupNode(s->peerId()));
if (frontend) {
QShaderProgramPrivate *dFrontend =
- static_cast<decltype(dFrontend)>(QNodePrivate::get(frontend));
+ static_cast<decltype(dFrontend)>(Qt3DCore::QNodePrivate::get(frontend));
dFrontend->setStatus(s->status());
dFrontend->setLog(s->log());
s->unsetRequiresFrontendSync();
@@ -1581,8 +1597,11 @@ void Renderer::sendShaderChangesToFrontend(Qt3DCore::QAspectManager *manager)
for (const ShaderBuilderUpdate &update : m_shaderBuilderUpdates) {
QShaderProgramBuilder *builder =
static_cast<decltype(builder)>(manager->lookupNode(update.builderId));
+ if (!builder)
+ continue;
+
QShaderProgramBuilderPrivate *dBuilder =
- static_cast<decltype(dBuilder)>(QNodePrivate::get(builder));
+ static_cast<decltype(dBuilder)>(Qt3DCore::QNodePrivate::get(builder));
dBuilder->setShaderCode(update.shaderCode, update.shaderType);
}
m_shaderBuilderUpdates.clear();
@@ -1618,8 +1637,7 @@ void Renderer::sendTextureChangesToFrontend(Qt3DCore::QAspectManager *manager)
texture->blockNotifications(blocked);
QAbstractTexturePrivate *dTexture =
- static_cast<QAbstractTexturePrivate *>(QNodePrivate::get(texture));
-
+ static_cast<QAbstractTexturePrivate *>(Qt3DCore::QNodePrivate::get(texture));
dTexture->setStatus(properties.status);
dTexture->setHandleType(pair.first.handleType);
dTexture->setHandle(pair.first.handle);
@@ -1657,7 +1675,7 @@ bool Renderer::prepareGeometryInputBindings(const Geometry *geometry, const RHIS
QHash<int, int> &attributeNameToBinding)
{
// shader requires no attributes
- if (shader->attributes().size() == 0)
+ if (shader->attributes().empty())
return true;
// QRhiVertexInputBinding -> specifies the stride of an attribute,
@@ -1679,7 +1697,7 @@ bool Renderer::prepareGeometryInputBindings(const Geometry *geometry, const RHIS
for (Qt3DCore::QNodeId attribute_id : attributesIds) {
Attribute *attrib = m_nodesManager->attributeManager()->lookupResource(attribute_id);
- if (attrib->attributeType() != QAttribute::VertexAttribute)
+ if (attrib->attributeType() != Qt3DCore::QAttribute::VertexAttribute)
continue;
const int location = locationForAttribute(attrib, shader);
// In case the shader doesn't use the attribute, we would get no
@@ -1693,20 +1711,20 @@ bool Renderer::prepareGeometryInputBindings(const Geometry *geometry, const RHIS
? QRhiVertexInputBinding::PerInstance
: QRhiVertexInputBinding::PerVertex;
- auto getAttributeByteSize = [] (const QAttribute::VertexBaseType type) {
+ auto getAttributeByteSize = [](const Qt3DCore::QAttribute::VertexBaseType type) {
switch (type) {
- case QAttribute::Byte:
- case QAttribute::UnsignedByte:
+ case Qt3DCore::QAttribute::Byte:
+ case Qt3DCore::QAttribute::UnsignedByte:
return 1;
- case QAttribute::Short:
- case QAttribute::UnsignedShort:
- case QAttribute::HalfFloat:
+ case Qt3DCore::QAttribute::Short:
+ case Qt3DCore::QAttribute::UnsignedShort:
+ case Qt3DCore::QAttribute::HalfFloat:
return 2;
- case QAttribute::Int:
- case QAttribute::UnsignedInt:
- case QAttribute::Float:
+ case Qt3DCore::QAttribute::Int:
+ case Qt3DCore::QAttribute::UnsignedInt:
+ case Qt3DCore::QAttribute::Float:
return 4;
- case QAttribute::Double:
+ case Qt3DCore::QAttribute::Double:
return 8;
}
return 0;
@@ -1773,7 +1791,7 @@ bool Renderer::prepareGeometryInputBindings(const Geometry *geometry, const RHIS
//*/
inputBindings[i] = QRhiVertexInputBinding{ binding.stride, binding.classification,
- int(binding.attributeDivisor) };
+ binding.attributeDivisor };
}
return true;
@@ -1834,6 +1852,12 @@ void Renderer::updateResources()
}
}
+ std::vector<RHITexture *> updatedRHITextures;
+
+ // Create/Update textures. We record the update info to later fill
+ // m_updatedTextureProperties once we are use the RHITextures have been
+ // fully created (as creating the RenderTargets below could change existing
+ // RHITextures)
{
const std::vector<HTexture> activeTextureHandles = Qt3DCore::moveAndClear(m_dirtyTextures);
for (const HTexture &handle : activeTextureHandles) {
@@ -1852,31 +1876,29 @@ void Renderer::updateResources()
// RHITexture
if (m_submissionContext != nullptr) {
RHITextureManager *rhiTextureManager = m_RHIResourceManagers->rhiTextureManager();
- const std::vector<HRHITexture> &glTextureHandles = rhiTextureManager->activeHandles();
+ const std::vector<HRHITexture> &rhiTextureHandles = rhiTextureManager->activeHandles();
// Upload texture data
- for (const HRHITexture &glTextureHandle : glTextureHandles) {
+ for (const HRHITexture &rhiTextureHandle : rhiTextureHandles) {
RHI_UNIMPLEMENTED;
- RHITexture *glTexture = rhiTextureManager->data(glTextureHandle);
+ RHITexture *rhiTexture = rhiTextureManager->data(rhiTextureHandle);
- // We create/update the actual GL texture using the GL context at this point
+ // We create/update the actual RHI texture using the RHI context at this point
const RHITexture::TextureUpdateInfo info =
- glTexture->createOrUpdateRhiTexture(m_submissionContext.data());
-
- // RHITexture creation provides us width/height/format ... information
- // for textures which had not initially specified these information
- // (TargetAutomatic...) Gather these information and store them to be distributed by
- // a change next frame
- const QNodeIdVector referenceTextureIds = {
- rhiTextureManager->texNodeIdForRHITexture.value(glTexture)
- };
- // Store properties and referenceTextureIds
+ rhiTexture->createOrUpdateRhiTexture(m_submissionContext.data());
+
if (info.wasUpdated) {
+ // RHITexture creation provides us width/height/format ... information
+ // for textures which had not initially specified these information
+ // (TargetAutomatic...) Gather these information and store them to be distributed by
+ // a change next frame
+ const Qt3DCore::QNodeIdVector referenceTextureIds = { rhiTextureManager->texNodeIdForRHITexture.value(rhiTexture) };
+ // Store properties and referenceTextureIds
Texture::TextureUpdateInfo updateInfo;
updateInfo.properties = info.properties;
- updateInfo.handleType = QAbstractTexture::OpenGLTextureId;
- // updateInfo.handle = info.texture ?
- // QVariant(info.texture->textureId()) : QVariant();
+ // Record texture updates to notify frontend (we are sure at this stage
+ // that the internal QRHITexture won't be updated further for this frame
m_updatedTextureProperties.push_back({ updateInfo, referenceTextureIds });
+ updatedRHITextures.push_back(rhiTexture);
}
}
}
@@ -1890,6 +1912,10 @@ void Renderer::updateResources()
// -> attachments added/removed
// -> attachments textures updated (new dimensions, format ...)
// -> destroy pipelines associated with dirty renderTargets
+
+ // Note: we might end up recreating some of the internal textures when
+ // creating the RenderTarget as those might have been created above without
+ // the proper RenderTarget/TransformSource flags
{
RHIRenderTargetManager *rhiRenderTargetManager = m_RHIResourceManagers->rhiRenderTargetManager();
RenderTargetManager *renderTargetManager = m_nodesManager->renderTargetManager();
@@ -1930,6 +1956,22 @@ void Renderer::updateResources()
}
}
+
+ // Note: we can only retrieve the internal QRhiResource handle to set on
+ // the frontend nodes after we are sure we are no going to modify the
+ // QRhiTextures (which happens when we create the Textures or the
+ // RenderTargets)
+ {
+ for (size_t i = 0, m = m_updatedTextureProperties.size(); i < m; ++i) {
+ auto &updateInfoPair = m_updatedTextureProperties[i];
+ RHITexture *rhiTexture = updatedRHITextures[i];
+ QRhiTexture *qRhiTexture = rhiTexture->getRhiTexture();
+ Texture::TextureUpdateInfo &updateInfo = updateInfoPair.first;
+ updateInfo.handleType = QAbstractTexture::RHITextureId;
+ updateInfo.handle = qRhiTexture ? QVariant(qRhiTexture->nativeTexture().object) : QVariant();
+ }
+ }
+
// Record list of buffer that might need uploading
lookForDownloadableBuffers();
}
@@ -1971,11 +2013,11 @@ void Renderer::updateTexture(Texture *texture)
// Will make the texture requestUpload
if (dirtyFlags.testFlag(Texture::DirtyImageGenerators)) {
- const QNodeIdVector textureImageIds = texture->textureImageIds();
+ const Qt3DCore::QNodeIdVector textureImageIds = texture->textureImageIds();
std::vector<RHITexture::Image> images;
images.reserve(textureImageIds.size());
// TODO: Move this into RHITexture directly
- for (const QNodeId &textureImageId : textureImageIds) {
+ for (const Qt3DCore::QNodeId &textureImageId : textureImageIds) {
const TextureImage *img =
m_nodesManager->textureImageManager()->lookupResource(textureImageId);
if (img == nullptr) {
@@ -2199,16 +2241,18 @@ void Renderer::jobsDone(Qt3DCore::QAspectManager *manager)
// called in main thread once all jobs are done running
// sync captured renders to frontend
+ QMutexLocker lock(&m_pendingRenderCaptureSendRequestsMutex);
const std::vector<Qt3DCore::QNodeId> pendingCaptureIds =
Qt3DCore::moveAndClear(m_pendingRenderCaptureSendRequests);
- for (const Qt3DCore::QNodeId &id : qAsConst(pendingCaptureIds)) {
+ lock.unlock();
+ for (const Qt3DCore::QNodeId &id : std::as_const(pendingCaptureIds)) {
auto *backend = static_cast<Qt3DRender::Render::RenderCapture *>(
m_nodesManager->frameGraphManager()->lookupNode(id));
backend->syncRenderCapturesToFrontend(manager);
}
// Do we need to notify any texture about property changes?
- if (m_updatedTextureProperties.size() > 0)
+ if (!m_updatedTextureProperties.empty())
sendTextureChangesToFrontend(manager);
sendDisablesToFrontend(manager);
@@ -2229,7 +2273,7 @@ bool Renderer::processKeyEvent(QObject *object, QKeyEvent *event)
}
// Jobs we may have to run even if no rendering will happen
-std::vector<QAspectJobPtr> Renderer::preRenderingJobs()
+std::vector<Qt3DCore::QAspectJobPtr> Renderer::preRenderingJobs()
{
if (m_sendBufferCaptureJob->hasRequests())
return { m_sendBufferCaptureJob };
@@ -2243,10 +2287,10 @@ std::vector<QAspectJobPtr> Renderer::preRenderingJobs()
// for the rendering of the scene
std::vector<Qt3DCore::QAspectJobPtr> Renderer::renderBinJobs()
{
- std::vector<QAspectJobPtr> renderBinJobs;
+ std::vector<Qt3DCore::QAspectJobPtr> renderBinJobs;
// Remove previous dependencies
- m_cleanupJob->removeDependency(QWeakPointer<QAspectJob>());
+ m_cleanupJob->removeDependency(QWeakPointer<Qt3DCore::QAspectJob>());
const bool dirtyParametersForCurrentFrame = m_dirtyBits.marked & AbstractRenderer::ParameterDirty;
const BackendNodeDirtySet dirtyBitsForFrame = m_dirtyBits.marked | m_dirtyBits.remaining;
@@ -2320,7 +2364,7 @@ std::vector<Qt3DCore::QAspectJobPtr> Renderer::renderBinJobs()
m_updatedDisableSubtreeEnablers.push_back(node->peerId());
}
- int idealThreadCount = QAspectJobManager::idealThreadCount();
+ int idealThreadCount = Qt3DCore::QAspectJobManager::idealThreadCount();
const size_t fgBranchCount = m_frameGraphLeaves.size();
if (fgBranchCount > 1) {
@@ -2384,7 +2428,7 @@ std::vector<Qt3DCore::QAspectJobPtr> Renderer::renderBinJobs()
return renderBinJobs;
}
-QAbstractFrameAdvanceService *Renderer::frameAdvanceService() const
+Qt3DCore::QAbstractFrameAdvanceService *Renderer::frameAdvanceService() const
{
return static_cast<Qt3DCore::QAbstractFrameAdvanceService *>(m_vsyncFrameAdvanceService.data());
}
@@ -2409,12 +2453,12 @@ bool Renderer::performCompute(QRhiCommandBuffer *cb, RenderCommand &command)
return true;
}
-static auto rhiIndexFormat(QAttribute::VertexBaseType type)
+static auto rhiIndexFormat(Qt3DCore::QAttribute::VertexBaseType type)
{
switch (type) {
- case QAttribute::VertexBaseType ::UnsignedShort:
+ case Qt3DCore::QAttribute::VertexBaseType ::UnsignedShort:
return QRhiCommandBuffer::IndexUInt16;
- case QAttribute::VertexBaseType ::UnsignedInt:
+ case Qt3DCore::QAttribute::VertexBaseType ::UnsignedInt:
return QRhiCommandBuffer::IndexUInt32;
default:
std::abort();
@@ -2486,7 +2530,7 @@ bool Renderer::uploadBuffersForCommand(RHIGraphicsPipeline* graphicsPipeline, Re
Buffer *buffer = m_nodesManager->bufferManager()->lookupResource(attrib->bufferId());
RHIBuffer *hbuf = m_RHIResourceManagers->rhiBufferManager()->lookupResource(buffer->peerId());
switch (attrib->attributeType()) {
- case QAttribute::VertexAttribute: {
+ case Qt3DCore::QAttribute::VertexAttribute: {
if (!hbuf->bind(&*m_submissionContext, RHIBuffer::Type((int)RHIBuffer::Type::ArrayBuffer | (int)RHIBuffer::Type::ShaderStorageBuffer)))
return false;
assert(hbuf->rhiBuffer());
@@ -2499,7 +2543,7 @@ bool Renderer::uploadBuffersForCommand(RHIGraphicsPipeline* graphicsPipeline, Re
command.vertex_input[bindingIndex] = { hbuf->rhiBuffer(), 0 };
break;
}
- case QAttribute::IndexAttribute: {
+ case Qt3DCore::QAttribute::IndexAttribute: {
if (!hbuf->bind(&*m_submissionContext, RHIBuffer::Type::IndexBuffer))
return false;
assert(hbuf->rhiBuffer());
@@ -2508,7 +2552,7 @@ bool Renderer::uploadBuffersForCommand(RHIGraphicsPipeline* graphicsPipeline, Re
command.indexAttribute = attrib;
break;
}
- case QAttribute::DrawIndirectAttribute:
+ case Qt3DCore::QAttribute::DrawIndirectAttribute:
RHI_UNIMPLEMENTED;
break;
}
@@ -2647,12 +2691,19 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
auto &renderTargetManager = *managers.rhiRenderTargetManager();
auto *renderTarget = renderTargetManager.lookupResource(passInfo.renderTargetId);
- if (renderTarget)
- rhiRenderTarget = renderTarget->renderTarget;
- else if (m_submissionContext->defaultRenderTarget())
+ if (renderTarget) {
+ // Is our RenderTarget targeting offscreen attachments?
+ if (renderTarget->backBuffer == RHIRenderTarget::BackBuffer::None)
+ rhiRenderTarget = renderTarget->renderTarget;
+ else // Or one of the back buffers?
+ rhiRenderTarget = m_submissionContext->currentSwapChain()->currentFrameRenderTarget(renderTarget->backBuffer == RHIRenderTarget::BackBuffer::Left
+ ? QRhiSwapChain::LeftBuffer
+ : QRhiSwapChain::RightBuffer);
+ } else if (m_submissionContext->defaultRenderTarget()) {
rhiRenderTarget = m_submissionContext->defaultRenderTarget();
- else
+ } else {
rhiRenderTarget = m_submissionContext->currentSwapChain()->currentFrameRenderTarget();
+ }
}
auto executeDrawRenderView = [&] (RenderView* rv) {
@@ -2712,7 +2763,6 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
// All the RVs in the current passinfo target the same RenderTarget
// A single beginPass should take place, unless Computes RVs are intermingled
- QRhiResourceUpdateBatch *inPassUpdates = nullptr;
static const bool supportsCompute = m_submissionContext->rhi()->isFeatureSupported(QRhi::Compute);
// Per Pass Global States
@@ -2720,7 +2770,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
if (rv->isCompute()) {
// If we were running draw calls we stop the draw pass
if (inDraw) {
- cb->endPass();
+ cb->endPass(m_submissionContext->m_currentUpdates);
m_submissionContext->m_currentUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch();
inDraw = false;
}
@@ -2730,6 +2780,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
if (supportsCompute) {
if (!inCompute) {
cb->beginComputePass(m_submissionContext->m_currentUpdates);
+ m_submissionContext->m_currentUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch();
inCompute = true;
}
executeComputeRenderView(rv);
@@ -2739,7 +2790,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
} else {
// Same logic than above but reversed
if (inCompute) {
- cb->endComputePass();
+ cb->endComputePass(m_submissionContext->m_currentUpdates);
m_submissionContext->m_currentUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch();
inCompute = false;
}
@@ -2751,6 +2802,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
continue;
}
cb->beginPass(rhiRenderTarget, clearColor, clearDepthStencil, m_submissionContext->m_currentUpdates);
+ m_submissionContext->m_currentUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch();
inDraw = true;
}
@@ -2759,7 +2811,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
const Qt3DCore::QNodeId renderCaptureId = rv->renderCaptureNodeId();
if (!renderCaptureId.isNull()) {
const QRenderCaptureRequest request = rv->renderCaptureRequest();
- QRhiRenderTarget *rhiTarget = nullptr;
+ QRhiRenderTarget *rhiTarget = m_submissionContext->defaultRenderTarget();
RHIRenderTarget *target = nullptr;
if (rv->renderTargetId()) {
@@ -2774,20 +2826,21 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
QRect rect(QPoint(0, 0), size);
if (!request.rect.isEmpty())
rect = rect.intersected(request.rect);
- QImage image;
if (!rect.isEmpty()) {
// Bind fbo as read framebuffer
QRhiReadbackResult *readBackResult = new QRhiReadbackResult;
readBackResult->completed = [this, readBackResult, renderCaptureId, request] () {
const QImage::Format fmt = QImage::Format_RGBA8888_Premultiplied; // fits QRhiTexture::RGBA8
const uchar *p = reinterpret_cast<const uchar *>(readBackResult->data.constData());
- const QImage image(p, readBackResult->pixelSize.width(), readBackResult->pixelSize.height(), fmt);
+ const QImage image(p, readBackResult->pixelSize.width(), readBackResult->pixelSize.height(), fmt, [] (void *ptr) {
+ delete static_cast<QRhiReadbackResult *>(ptr);
+ }, readBackResult);
Render::RenderCapture *renderCapture = static_cast<Render::RenderCapture*>(m_nodesManager->frameGraphManager()->lookupNode(renderCaptureId));
renderCapture->addRenderCapture(request.captureId, image);
+ QMutexLocker lock(&m_pendingRenderCaptureSendRequestsMutex);
if (!Qt3DCore::contains(m_pendingRenderCaptureSendRequests, renderCaptureId))
m_pendingRenderCaptureSendRequests.push_back(renderCaptureId);
- delete readBackResult;
};
QRhiReadbackDescription readbackDesc;
@@ -2798,8 +2851,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
const QRhiColorAttachment *color0Att = desc.colorAttachmentAt(0);
readbackDesc.setTexture(color0Att->texture());
}
- inPassUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch();
- inPassUpdates->readBackTexture(readbackDesc, readBackResult);
+ m_submissionContext->m_currentUpdates->readBackTexture(readbackDesc, readBackResult);
} else {
qCWarning(Backend) << "Requested capture rectangle is outside framebuffer";
}
@@ -2811,9 +2863,9 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
}
if (Q_LIKELY(inDraw))
- cb->endPass(inPassUpdates);
+ cb->endPass(m_submissionContext->m_currentUpdates);
else if (inCompute)
- cb->endComputePass();
+ cb->endComputePass(m_submissionContext->m_currentUpdates);
m_submissionContext->m_currentUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch();
diff --git a/src/plugins/renderers/rhi/renderer/renderer.pri b/src/plugins/renderers/rhi/renderer/renderer.pri
deleted file mode 100644
index 761a6ce9b..000000000
--- a/src/plugins/renderers/rhi/renderer/renderer.pri
+++ /dev/null
@@ -1,26 +0,0 @@
-INCLUDEPATH += $$PWD
-
-SOURCES += \
- $$PWD/rendercommand.cpp \
- $$PWD/renderer.cpp \
- $$PWD/renderview.cpp \
- $$PWD/renderviewbuilder.cpp \
- $$PWD/rhigraphicspipeline.cpp \
- $$PWD/rhishader.cpp \
- $$PWD/shaderparameterpack.cpp \
- $$PWD/logging.cpp \
- $$PWD/commandexecuter.cpp \
- $$PWD/pipelineuboset.cpp
-
-HEADERS += \
- $$PWD/rendercommand_p.h \
- $$PWD/renderer_p.h \
- $$PWD/renderview_p.h \
- $$PWD/renderviewbuilder_p.h \
- $$PWD/rhigraphicspipeline_p.h \
- $$PWD/rhishader_p.h \
- $$PWD/shaderparameterpack_p.h \
- $$PWD/shadervariables_p.h \
- $$PWD/logging_p.h \
- $$PWD/commandexecuter_p.h \
- $$PWD/pipelineuboset_p.h
diff --git a/src/plugins/renderers/rhi/renderer/renderer_p.h b/src/plugins/renderers/rhi/renderer/renderer_p.h
index 1c89bd52b..6f4590ef5 100644
--- a/src/plugins/renderers/rhi/renderer/renderer_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderer_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RENDERER_H
#define QT3DRENDER_RENDER_RHI_RENDERER_H
@@ -73,7 +37,7 @@
#include <Qt3DRender/private/renderercache_p.h>
#include <Qt3DRender/private/renderviewinitializerjob_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <shaderparameterpack_p.h>
#include <logging_p.h>
@@ -360,6 +324,7 @@ private:
RenderableEntityFilterPtr m_renderableEntityFilterJob;
ComputableEntityFilterPtr m_computableEntityFilterJob;
+ QMutex m_pendingRenderCaptureSendRequestsMutex;
std::vector<Qt3DCore::QNodeId> m_pendingRenderCaptureSendRequests;
SynchronizerJobPtr m_bufferGathererJob;
diff --git a/src/plugins/renderers/rhi/renderer/renderview.cpp b/src/plugins/renderers/rhi/renderer/renderview.cpp
index cf8d27871..c8ae4e7f1 100644
--- a/src/plugins/renderers/rhi/renderer/renderview.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderview.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "renderview_p.h"
#include <Qt3DRender/qmaterial.h>
@@ -417,8 +381,7 @@ struct AdjacentSubRangeFinder
{
static bool adjacentSubRange(const RenderCommand &, const RenderCommand &)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
};
@@ -605,6 +568,10 @@ struct SubRangeSorter<QSortPolicy::Texture>
return identicalTextureCount < smallestVector.size();
});
+#else
+ Q_UNUSED(view);
+ Q_UNUSED(begin);
+ Q_UNUSED(end);
#endif
}
};
@@ -627,8 +594,7 @@ int findSubRange(const EntityRenderCommandDataView *view,
case QSortPolicy::Uniform:
return end;
default:
- Q_UNREACHABLE();
- return end;
+ Q_UNREACHABLE_RETURN(end);
}
}
@@ -641,7 +607,7 @@ void sortByMaterial(EntityRenderCommandDataView *view, int begin, const int end)
while (begin != end) {
if (begin + 1 < rangeEnd) {
std::stable_sort(commandIndices.begin() + begin + 1, commandIndices.begin() + rangeEnd,
- [&commands] (const int &iA, const int &iB) {
+ [&commands] (const size_t &iA, const size_t &iB) {
const RenderCommand &a = commands[iA];
const RenderCommand &b = commands[iB];
return a.m_material.handle() < b.m_material.handle();
@@ -1198,6 +1164,13 @@ void RenderView::updateRenderCommand(const EntityRenderCommandDataSubView &subVi
memcpy(&command.m_commandUBO.inverseModelViewProjectionMatrix,
&inverseModelViewProjection, sizeof(Matrix4x4));
copyNormalMatrix(command.m_commandUBO.modelViewNormalMatrix, modelViewNormalMatrix.constData());
+
+ const Armature *armature = entity->renderComponent<Armature>();
+ if (armature) {
+ const UniformValue &skinningPalette = armature->skinningPaletteUniform();
+ memcpy(&command.m_commandUBO.skinningPalette, skinningPalette.constData<float>(),
+ qMin<size_t>(skinningPalette.byteSize(), 100 * 16 * sizeof(float)));
+ }
}
});
}
@@ -1206,8 +1179,16 @@ void RenderView::updateMatrices()
{
if (m_renderCameraNode && m_renderCameraLens
&& m_renderCameraLens->isEnabled()) {
- const Matrix4x4 cameraWorld = *(m_renderCameraNode->worldTransform());
- setViewMatrix(m_renderCameraLens->viewMatrix(cameraWorld));
+ auto transform = m_renderCameraNode->renderComponent<Transform>();
+ if (m_renderCameraNode->isParentLessTransform() && transform && transform->hasViewMatrix()) {
+ // optimization: if the entity is a QCamera and it doesn't have a parent with a transform component,
+ // then we use the frontend version of the viewMatrix to avoid extra calculations that may introduce
+ // rounding errors
+ setViewMatrix(transform->viewMatrix());
+ } else {
+ const Matrix4x4 cameraWorld = *(m_renderCameraNode->worldTransform());
+ setViewMatrix(m_renderCameraLens->viewMatrix(cameraWorld));
+ }
setViewProjectionMatrix(m_renderCameraLens->projection() * viewMatrix());
// To get the eyePosition of the camera, we need to use the inverse of the
@@ -1410,7 +1391,7 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, ParameterInfoList
// only update values of uniforms that have changed
// If parameters add been added/removed, the command would have been rebuild
// and the parameter pack would be empty
- const bool updateUniformsOnly = command->m_parameterPack.submissionUniformIndices().size() > 0;
+ const bool updateUniformsOnly = !command->m_parameterPack.submissionUniformIndices().empty();
if (!updateUniformsOnly) {
// Builds the QUniformPack, sets shader standard uniforms and store attributes name / glname
@@ -1465,7 +1446,7 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, ParameterInfoList
break;
const Entity *lightEntity = lightSource.entity;
const Matrix4x4 lightWorldTransform = *(lightEntity->worldTransform());
- const Vector3D worldPos = lightWorldTransform * Vector3D(0.0f, 0.0f, 0.0f);
+ const Vector3D worldPos = lightWorldTransform.map(Vector3D(0.0f, 0.0f, 0.0f));
for (Light *light : lightSource.lights) {
if (!light->isEnabled())
continue;
diff --git a/src/plugins/renderers/rhi/renderer/renderview_p.h b/src/plugins/renderers/rhi/renderer/renderview_p.h
index 6c8ea7541..5ef63f4be 100644
--- a/src/plugins/renderers/rhi/renderer/renderview_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderview_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RENDERVIEW_H
#define QT3DRENDER_RENDER_RHI_RENDERVIEW_H
diff --git a/src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp b/src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp
index 832f550eb..035848e13 100644
--- a/src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp
@@ -1,46 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "renderviewbuilder_p.h"
#include <Qt3DRender/private/qrenderaspect_p.h>
-
-#include <QThread>
+#include <Qt3DCore/private/qaspectjobmanager_p.h>
QT_BEGIN_NAMESPACE
@@ -63,7 +26,7 @@ RenderViewBuilder::RenderViewBuilder(Render::FrameGraphNode *leafNode, int rende
// In some cases having less jobs is better (especially on fast cpus where
// splitting just adds more overhead). Ideally, we should try to set the value
// depending on the platform/CPU/nbr of cores
- m_optimalParallelJobCount = QThread::idealThreadCount();
+ m_optimalParallelJobCount = Qt3DCore::QAspectJobManager::idealThreadCount();
}
RenderViewInitializerJobPtr RenderViewBuilder::renderViewJob() const
diff --git a/src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h b/src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h
index f7c4f606c..eb7484d15 100644
--- a/src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RENDERVIEWBUILDER_H
#define QT3DRENDER_RENDER_RHI_RENDERVIEWBUILDER_H
diff --git a/src/plugins/renderers/rhi/renderer/rhigraphicspipeline.cpp b/src/plugins/renderers/rhi/renderer/rhigraphicspipeline.cpp
index 824609b7f..feec0aceb 100644
--- a/src/plugins/renderers/rhi/renderer/rhigraphicspipeline.cpp
+++ b/src/plugins/renderers/rhi/renderer/rhigraphicspipeline.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "rhigraphicspipeline_p.h"
diff --git a/src/plugins/renderers/rhi/renderer/rhigraphicspipeline_p.h b/src/plugins/renderers/rhi/renderer/rhigraphicspipeline_p.h
index ff619c56d..020d4583a 100644
--- a/src/plugins/renderers/rhi/renderer/rhigraphicspipeline_p.h
+++ b/src/plugins/renderers/rhi/renderer/rhigraphicspipeline_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RHIGRAPHICSPIPELINE_H
#define QT3DRENDER_RENDER_RHI_RHIGRAPHICSPIPELINE_H
@@ -51,7 +15,7 @@
// We mean it.
//
-#include <private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <rhihandle_types_p.h>
#include <pipelineuboset_p.h>
#include <Qt3DCore/qnodeid.h>
diff --git a/src/plugins/renderers/rhi/renderer/rhirendertarget.cpp b/src/plugins/renderers/rhi/renderer/rhirendertarget.cpp
index c7f4d0720..db11f5f88 100644
--- a/src/plugins/renderers/rhi/renderer/rhirendertarget.cpp
+++ b/src/plugins/renderers/rhi/renderer/rhirendertarget.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "rhirendertarget_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/renderers/rhi/renderer/rhirendertarget_p.h b/src/plugins/renderers/rhi/renderer/rhirendertarget_p.h
index 74a85196d..f699db687 100644
--- a/src/plugins/renderers/rhi/renderer/rhirendertarget_p.h
+++ b/src/plugins/renderers/rhi/renderer/rhirendertarget_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RHIRENDERTARGET_H
#define QT3DRENDER_RENDER_RHI_RHIRENDERTARGET_H
@@ -51,7 +15,7 @@
// We mean it.
//
-#include <private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <rhihandle_types_p.h>
#include <private/attachmentpack_p.h>
@@ -66,9 +30,16 @@ struct RHIRenderTarget {
// Note: only used when rendering to a FBO
// as we don't want to remove the default framebuffer's rendertarget
// TODO: at some point separate render target and graphics pipeline as the former can be reused
- QRhiRenderTarget *renderTarget{};
- QRhiRenderPassDescriptor *renderPassDescriptor{};
- QRhiRenderBuffer *depthStencilBuffer{};
+ QRhiRenderTarget *renderTarget{ nullptr };
+ QRhiRenderPassDescriptor *renderPassDescriptor{ nullptr };
+ QRhiRenderBuffer *depthStencilBuffer{ nullptr };
+
+ enum class BackBuffer {
+ None,
+ Left,
+ Right,
+ };
+ BackBuffer backBuffer{ BackBuffer::None };
~RHIRenderTarget();
void cleanup();
diff --git a/src/plugins/renderers/rhi/renderer/rhishader.cpp b/src/plugins/renderers/rhi/renderer/rhishader.cpp
index 5684e27ce..5c170346f 100644
--- a/src/plugins/renderers/rhi/renderer/rhishader.cpp
+++ b/src/plugins/renderers/rhi/renderer/rhishader.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "rhishader_p.h"
#include <QMutexLocker>
@@ -332,7 +296,14 @@ void RHIShader::recordAllUniforms(UBO_Member &uboMember,
// We iterate through all the [l][n][m] by building [0][0][0] and incrementing
forEachArrayAccessor(member.arrayDims, [&](const QString &str) {
// "foo.bar[1][2]"
- m_unqualifiedUniformNames << (fullMemberName + str);
+ const QString unqualifiedMemberName = (fullMemberName + str);
+ m_unqualifiedUniformNames << unqualifiedMemberName;
+
+ // Record as an individual uniform
+ m_uniformsNames.push_back(unqualifiedMemberName);
+ const int nameId = StringToInt::lookupId(unqualifiedMemberName);
+ m_uniformsNamesIds.push_back(nameId);
+
// Question : does it make sense to also record foo[0], foo[0][0], etc...
// if there are e.g. 3 dimensions ?
});
@@ -344,20 +315,29 @@ void RHIShader::recordAllUniforms(UBO_Member &uboMember,
m_structNamesIds.push_back(StringToInt::lookupId(m_structNames.back()));
});
- // Record the struct members
- for (const QShaderDescription::BlockVariable& bv : member.structMembers) {
- forEachArrayAccessor(member.arrayDims, [&] (const QString& str) {
+ // Record the array times the struct members => entry[i].struct_member
+ forEachArrayAccessor(member.arrayDims, [&] (const QString& str) {
+ UBO_Member arrayMember {StringToInt::lookupId(fullMemberName + str), {}, {}};
+ // Record all struct member into the array member[i]
+ for (const QShaderDescription::BlockVariable& bv : member.structMembers) {
//recordAllUniforms("baz", "foo.bar[1][2].")
const QString structMemberNamePrefix = fullMemberName + str + QLatin1Char('.');
UBO_Member innerMember {StringToInt::lookupId(structMemberNamePrefix), bv, {}};
recordAllUniforms(innerMember, structMemberNamePrefix);
- uboMember.structMembers.push_back(innerMember);
- });
- }
+ arrayMember.structMembers.push_back(innerMember);
+ }
+ // When dealing with an array of structs, we treat structMembers as arrayMembers
+ uboMember.structMembers.push_back(arrayMember);
+ });
} else {
// Final member (not array or struct)
// Replace nameId with final nameId name
uboMember.nameId = StringToInt::lookupId(fullMemberName);
+
+ // Record as an individual uniform
+ m_uniformsNames.push_back(fullMemberName);
+ const int nameId = StringToInt::lookupId(fullMemberName);
+ m_uniformsNamesIds.push_back(nameId);
}
}
@@ -370,7 +350,7 @@ bool isGeneratedUBOName(const QByteArray& arr)
return false;
if (!arr.startsWith('_'))
return false;
- for (int i = 1, N = arr.size(); i < N; i++) {
+ for (qsizetype i = 1, N = arr.size(); i < N; i++) {
if (arr[i] < '0' || arr[i] > '9')
return false;
}
@@ -454,7 +434,7 @@ void RHIShader::introspect()
std::vector<UBO_Member> uboMembers;
uboMembers.reserve(ubo.members.size());
- for (const QShaderDescription::BlockVariable &member : qAsConst(ubo.members)) {
+ for (const QShaderDescription::BlockVariable &member : std::as_const(ubo.members)) {
m_uniformsNames.push_back(member.name);
const int nameId = StringToInt::lookupId(member.name);
m_uniformsNamesIds.push_back(nameId);
@@ -492,7 +472,7 @@ QHash<QString, ShaderUniform> RHIShader::activeUniformsForUniformBlock(int block
ShaderUniformBlock RHIShader::uniformBlockForBlockIndex(int blockIndex) const noexcept
{
- for (int i = 0, m = m_uniformBlocks.size(); i < m; ++i) {
+ for (size_t i = 0, m = m_uniformBlocks.size(); i < m; ++i) {
if (m_uniformBlocks[i].m_index == blockIndex) {
return m_uniformBlocks[i];
}
@@ -502,7 +482,7 @@ ShaderUniformBlock RHIShader::uniformBlockForBlockIndex(int blockIndex) const no
ShaderUniformBlock RHIShader::uniformBlockForBlockNameId(int blockNameId) const noexcept
{
- for (int i = 0, m = m_uniformBlocks.size(); i < m; ++i) {
+ for (size_t i = 0, m = m_uniformBlocks.size(); i < m; ++i) {
if (m_uniformBlocks[i].m_nameId == blockNameId) {
return m_uniformBlocks[i];
}
@@ -512,7 +492,7 @@ ShaderUniformBlock RHIShader::uniformBlockForBlockNameId(int blockNameId) const
ShaderUniformBlock RHIShader::uniformBlockForBlockName(const QString &blockName) const noexcept
{
- for (int i = 0, m = m_uniformBlocks.size(); i < m; ++i) {
+ for (size_t i = 0, m = m_uniformBlocks.size(); i < m; ++i) {
if (m_uniformBlocks[i].m_name == blockName) {
return m_uniformBlocks[i];
}
@@ -539,7 +519,7 @@ ShaderUniformBlock RHIShader::uniformBlockForInstanceNameId(int instanceNameId)
ShaderStorageBlock RHIShader::storageBlockForBlockIndex(int blockIndex) const noexcept
{
- for (int i = 0, m = m_shaderStorageBlockNames.size(); i < m; ++i) {
+ for (size_t i = 0, m = m_shaderStorageBlockNames.size(); i < m; ++i) {
if (m_shaderStorageBlocks[i].m_index == blockIndex)
return m_shaderStorageBlocks[i];
}
@@ -548,7 +528,7 @@ ShaderStorageBlock RHIShader::storageBlockForBlockIndex(int blockIndex) const no
ShaderStorageBlock RHIShader::storageBlockForBlockNameId(int blockNameId) const noexcept
{
- for (int i = 0, m = m_shaderStorageBlockNames.size(); i < m; ++i) {
+ for (size_t i = 0, m = m_shaderStorageBlockNames.size(); i < m; ++i) {
if (m_shaderStorageBlocks[i].m_nameId == blockNameId)
return m_shaderStorageBlocks[i];
}
@@ -557,7 +537,7 @@ ShaderStorageBlock RHIShader::storageBlockForBlockNameId(int blockNameId) const
ShaderStorageBlock RHIShader::storageBlockForBlockName(const QString &blockName) const noexcept
{
- for (int i = 0, m = m_shaderStorageBlockNames.size(); i < m; ++i) {
+ for (size_t i = 0, m = m_shaderStorageBlockNames.size(); i < m; ++i) {
if (m_shaderStorageBlocks[i].m_name == blockName)
return m_shaderStorageBlocks[i];
}
@@ -586,72 +566,71 @@ bool RHIShader::hasActiveVariables() const noexcept
|| !m_uniformBlockNamesIds.empty() || !m_shaderStorageBlockNamesIds.empty();
}
-void RHIShader::setShaderCode(const std::vector<QByteArray> &shaderCode)
+void RHIShader::setShaderCode(std::vector<QByteArray> shaderCode)
{
- m_shaderCode.clear();
- Qt3DCore::append(m_shaderCode, shaderCode);
+ m_shaderCode = std::move(shaderCode);
}
-void RHIShader::setFragOutputs(const QHash<QString, int> &fragOutputs)
+void RHIShader::setFragOutputs(QHash<QString, int> fragOutputs)
{
{
QMutexLocker lock(&m_mutex);
- m_fragOutputs = fragOutputs;
+ m_fragOutputs = std::move(fragOutputs);
}
// updateDNA();
}
-const QHash<QString, int> RHIShader::fragOutputs() const
+const QHash<QString, int> &RHIShader::fragOutputs() const
{
QMutexLocker lock(&m_mutex);
return m_fragOutputs;
}
-void RHIShader::initializeAttributes(const std::vector<ShaderAttribute> &attributesDescription)
+void RHIShader::initializeAttributes(std::vector<ShaderAttribute> attributesDescription)
{
- m_attributes = attributesDescription;
- m_attributesNames.resize(attributesDescription.size());
- m_attributeNamesIds.resize(attributesDescription.size());
- for (int i = 0, m = attributesDescription.size(); i < m; i++) {
- m_attributesNames[i] = attributesDescription[i].m_name;
+ m_attributes = std::move(attributesDescription);
+ m_attributesNames.resize(m_attributes.size());
+ m_attributeNamesIds.resize(m_attributes.size());
+ for (size_t i = 0, m = m_attributes.size(); i < m; i++) {
+ m_attributesNames[i] = m_attributes[i].m_name;
m_attributes[i].m_nameId = StringToInt::lookupId(m_attributesNames[i]);
m_attributeNamesIds[i] = m_attributes[i].m_nameId;
- qCDebug(Shaders) << "Active Attribute " << attributesDescription[i].m_name;
+ qCDebug(Shaders) << "Active Attribute " << m_attributes[i].m_name;
}
}
-void RHIShader::initializeSamplers(const std::vector<ShaderAttribute> &samplersDescription)
+void RHIShader::initializeSamplers(std::vector<ShaderAttribute> samplersDescription)
{
- m_samplers = samplersDescription;
- m_samplerNames.resize(samplersDescription.size());
- m_samplerIds.resize(samplersDescription.size());
- for (int i = 0, m = samplersDescription.size(); i < m; i++) {
- m_samplerNames[i] = samplersDescription[i].m_name;
+ m_samplers = std::move(samplersDescription);
+ m_samplerNames.resize(m_samplers.size());
+ m_samplerIds.resize(m_samplers.size());
+ for (size_t i = 0, m = m_samplers.size(); i < m; i++) {
+ m_samplerNames[i] = m_samplers[i].m_name;
m_samplers[i].m_nameId = StringToInt::lookupId(m_samplerNames[i]);
m_samplerIds[i] = m_samplers[i].m_nameId;
- qCDebug(Shaders) << "Active sampler " << samplersDescription[i].m_name;
+ qCDebug(Shaders) << "Active sampler " << m_samplers[i].m_name;
}
}
-void RHIShader::initializeImages(const std::vector<ShaderAttribute> &imagesDescription)
+void RHIShader::initializeImages(std::vector<ShaderAttribute> imagesDescription)
{
- m_images = imagesDescription;
- m_imageNames.resize(imagesDescription.size());
- m_imageIds.resize(imagesDescription.size());
- for (int i = 0, m = imagesDescription.size(); i < m; i++) {
- m_imageNames[i] = imagesDescription[i].m_name;
+ m_images = std::move(imagesDescription);
+ m_imageNames.resize(m_images.size());
+ m_imageIds.resize(m_images.size());
+ for (size_t i = 0, m = m_images.size(); i < m; i++) {
+ m_imageNames[i] = m_images[i].m_name;
m_images[i].m_nameId = StringToInt::lookupId(m_imageNames[i]);
m_imageIds[i] = m_images[i].m_nameId;
- qCDebug(Shaders) << "Active image " << imagesDescription[i].m_name;
+ qCDebug(Shaders) << "Active image " << m_images[i].m_name;
}
}
-void RHIShader::initializeUniformBlocks(const std::vector<ShaderUniformBlock> &uniformBlockDescription)
+void RHIShader::initializeUniformBlocks(std::vector<ShaderUniformBlock> uniformBlockDescription)
{
- m_uniformBlocks = uniformBlockDescription;
- m_uniformBlockNames.resize(uniformBlockDescription.size());
- m_uniformBlockNamesIds.resize(uniformBlockDescription.size());
- for (int i = 0, m = uniformBlockDescription.size(); i < m; ++i) {
+ m_uniformBlocks = std::move(uniformBlockDescription);
+ m_uniformBlockNames.resize(m_uniformBlocks.size());
+ m_uniformBlockNamesIds.resize(m_uniformBlocks.size());
+ for (size_t i = 0, m = m_uniformBlocks.size(); i < m; ++i) {
m_uniformBlockNames[i] = m_uniformBlocks[i].m_name;
m_uniformBlockNamesIds[i] = StringToInt::lookupId(m_uniformBlockNames[i]);
m_uniformBlocks[i].m_nameId = m_uniformBlockNamesIds[i];
@@ -667,7 +646,7 @@ void RHIShader::initializeUniformBlocks(const std::vector<ShaderUniformBlock> &u
QHash<QString, ShaderUniform> activeUniformsInBlock;
while (uniformsIt != uniformsEnd && uniformNamesIt != uniformNamesEnd) {
- if (uniformsIt->m_blockIndex == uniformBlockDescription[i].m_index) {
+ if (uniformsIt->m_blockIndex == m_uniformBlocks[i].m_index) {
QString uniformName = *uniformNamesIt;
if (!m_uniformBlockNames[i].isEmpty()
&& !uniformName.startsWith(m_uniformBlockNames[i]))
@@ -680,19 +659,19 @@ void RHIShader::initializeUniformBlocks(const std::vector<ShaderUniformBlock> &u
++uniformsIt;
++uniformNamesIt;
}
- m_uniformBlockIndexToShaderUniforms.insert(uniformBlockDescription[i].m_index,
+ m_uniformBlockIndexToShaderUniforms.insert(m_uniformBlocks[i].m_index,
activeUniformsInBlock);
}
}
void RHIShader::initializeShaderStorageBlocks(
- const std::vector<ShaderStorageBlock> &shaderStorageBlockDescription)
+ std::vector<ShaderStorageBlock> shaderStorageBlockDescription)
{
- m_shaderStorageBlocks = shaderStorageBlockDescription;
- m_shaderStorageBlockNames.resize(shaderStorageBlockDescription.size());
- m_shaderStorageBlockNamesIds.resize(shaderStorageBlockDescription.size());
+ m_shaderStorageBlocks = std::move(shaderStorageBlockDescription);
+ m_shaderStorageBlockNames.resize(m_shaderStorageBlocks.size());
+ m_shaderStorageBlockNamesIds.resize(m_shaderStorageBlocks.size());
- for (int i = 0, m = shaderStorageBlockDescription.size(); i < m; ++i) {
+ for (size_t i = 0, m = m_shaderStorageBlocks.size(); i < m; ++i) {
m_shaderStorageBlockNames[i] = m_shaderStorageBlocks[i].m_name;
m_shaderStorageBlockNamesIds[i] = StringToInt::lookupId(m_shaderStorageBlockNames[i]);
m_shaderStorageBlocks[i].m_nameId = m_shaderStorageBlockNamesIds[i];
diff --git a/src/plugins/renderers/rhi/renderer/rhishader_p.h b/src/plugins/renderers/rhi/renderer/rhishader_p.h
index d23c85938..f566f03ae 100644
--- a/src/plugins/renderers/rhi/renderer/rhishader_p.h
+++ b/src/plugins/renderers/rhi/renderer/rhishader_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_GLSHADER_P_H
#define QT3DRENDER_RENDER_RHI_GLSHADER_P_H
@@ -56,7 +20,7 @@
#include <Qt3DRender/qshaderprogram.h>
#include <QMutex>
#include <QtGui/private/qshader_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
@@ -88,8 +52,8 @@ public:
bool isLoaded() const { return m_isLoaded; }
void setLoaded(bool loaded) { m_isLoaded = loaded; }
- void setFragOutputs(const QHash<QString, int> &fragOutputs);
- const QHash<QString, int> fragOutputs() const;
+ void setFragOutputs(QHash<QString, int> fragOutputs);
+ const QHash<QString, int> &fragOutputs() const;
inline const std::vector<int> &uniformsNamesIds() const { return m_uniformsNamesIds; }
inline const std::vector<int> &standardUniformNameIds() const { return m_standardUniformNamesIds; }
@@ -130,7 +94,7 @@ public:
bool hasUniform(int nameId) const noexcept;
bool hasActiveVariables() const noexcept;
- void setShaderCode(const std::vector<QByteArray> &shaderCode);
+ void setShaderCode(std::vector<QByteArray> shaderCode);
const std::vector<QByteArray> &shaderCode() const;
const QShader &shaderStage(QShader::Stage stage) const noexcept { return m_stages[stage]; }
@@ -182,12 +146,11 @@ private:
// Private so that only SubmissionContext can call it
friend class SubmissionContext;
- void initializeAttributes(const std::vector<ShaderAttribute> &attributesDescription);
- void initializeUniformBlocks(const std::vector<ShaderUniformBlock> &uniformBlockDescription);
- void
- initializeShaderStorageBlocks(const std::vector<ShaderStorageBlock> &shaderStorageBlockDescription);
- void initializeSamplers(const std::vector<ShaderAttribute> &samplerDescription);
- void initializeImages(const std::vector<ShaderAttribute> &imageDescription);
+ void initializeAttributes(std::vector<Qt3DRender::Render::Rhi::ShaderAttribute> attributesDescription);
+ void initializeUniformBlocks(std::vector<ShaderUniformBlock> uniformBlockDescription);
+ void initializeShaderStorageBlocks(std::vector<ShaderStorageBlock> shaderStorageBlockDescription);
+ void initializeSamplers(std::vector<ShaderAttribute> samplerDescription);
+ void initializeImages(std::vector<ShaderAttribute> imageDescription);
void recordAllUniforms(UBO_Member &uboMember, QString parentName);
std::vector<UBO_Block> m_uboBlocks;
diff --git a/src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp b/src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp
index 46f6480e4..c07769afc 100644
--- a/src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp
+++ b/src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "shaderparameterpack_p.h"
@@ -86,7 +50,7 @@ void ShaderParameterPack::setTexture(const int glslNameId, int uniformArrayIndex
void ShaderParameterPack::setImage(const int glslNameId, int uniformArrayIndex, Qt3DCore::QNodeId id)
{
- for (int i=0, m = m_images.size(); i < m; ++i) {
+ for (size_t i=0, m = m_images.size(); i < m; ++i) {
if (m_images[i].glslNameId != glslNameId || m_images[i].uniformArrayIndex != uniformArrayIndex)
continue;
diff --git a/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h b/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h
index c69a33f17..be110828f 100644
--- a/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h
+++ b/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_SHADERPARAMETERPACK_P_H
#define QT3DRENDER_RENDER_RHI_SHADERPARAMETERPACK_P_H
diff --git a/src/plugins/renderers/rhi/renderer/shadervariables_p.h b/src/plugins/renderers/rhi/renderer/shadervariables_p.h
index bb8d205b5..de4f5207e 100644
--- a/src/plugins/renderers/rhi/renderer/shadervariables_p.h
+++ b/src/plugins/renderers/rhi/renderer/shadervariables_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_SHADERVARIABLES_P_H
#define QT3DRENDER_RENDER_RHI_SHADERVARIABLES_P_H
diff --git a/src/plugins/renderers/rhi/rhi.cmake b/src/plugins/renderers/rhi/rhi.cmake
index 292cb0103..737f3d96f 100644
--- a/src/plugins/renderers/rhi/rhi.cmake
+++ b/src/plugins/renderers/rhi/rhi.cmake
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
function(qt3d_setup_rhi_renderer_target target)
set(rhiplugindir ${PROJECT_SOURCE_DIR}/src/plugins/renderers/rhi)
diff --git a/src/plugins/renderers/rhi/rhi.pri b/src/plugins/renderers/rhi/rhi.pri
deleted file mode 100644
index 5fdb77c00..000000000
--- a/src/plugins/renderers/rhi/rhi.pri
+++ /dev/null
@@ -1,16 +0,0 @@
-
-include (renderer/renderer.pri)
-include (io/io.pri)
-include (textures/textures.pri)
-include (graphicshelpers/graphicshelpers.pri)
-include (managers/managers.pri)
-
-INCLUDEPATH += $$PWD
-
-# Qt3D is free of Q_FOREACH - make sure it stays that way:
-DEFINES += QT_NO_FOREACH
-
-gcov {
- QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
- QMAKE_LFLAGS += -fprofile-arcs -ftest-coverage
-}
diff --git a/src/plugins/renderers/rhi/rhi.pro b/src/plugins/renderers/rhi/rhi.pro
deleted file mode 100644
index a767223f4..000000000
--- a/src/plugins/renderers/rhi/rhi.pro
+++ /dev/null
@@ -1,36 +0,0 @@
-TARGET = rhirenderer
-
-PLUGIN_TYPE = renderers
-PLUGIN_CLASS_NAME = RhiRendererPlugin
-load(qt_plugin)
-
-QT += core-private gui-private 3dcore 3dcore-private 3drender 3drender-private
-
-greaterThan(QT_MAJOR_VERSION, 5) {
- QT += shadertools shadertools-private
-}
-
-# Qt3D is free of Q_FOREACH - make sure it stays that way:
-DEFINES += QT_NO_FOREACH
-
-# We use QT_AUTOTEST_EXPORT to test the plug-ins, which needs QT_BUILDING_QT
-DEFINES += QT_BUILDING_QT
-
-SOURCES += \
- main.cpp
-
-DISTFILES += \
- rhirenderer.json
-
-include(rhi.pri)
-
-qtConfig(qt3d-simd-avx2) {
- CONFIG += simd
- QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_AVX2
-}
-
-qtConfig(qt3d-simd-sse2):!qtConfig(qt3d-simd-avx2) {
- CONFIG += simd
- QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_SSE2
-}
-
diff --git a/src/plugins/renderers/rhi/textures/renderbuffer.cpp b/src/plugins/renderers/rhi/textures/renderbuffer.cpp
index 9dd28ad50..cdf4b2b02 100644
--- a/src/plugins/renderers/rhi/textures/renderbuffer.cpp
+++ b/src/plugins/renderers/rhi/textures/renderbuffer.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "renderbuffer_p.h"
#include <QtGui/QOpenGLContext>
diff --git a/src/plugins/renderers/rhi/textures/renderbuffer_p.h b/src/plugins/renderers/rhi/textures/renderbuffer_p.h
index 48ad7453d..9187ec624 100644
--- a/src/plugins/renderers/rhi/textures/renderbuffer_p.h
+++ b/src/plugins/renderers/rhi/textures/renderbuffer_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_RENDERBUFFER_P_H
#define QT3DRENDER_RENDER_RHI_RENDERBUFFER_P_H
diff --git a/src/plugins/renderers/rhi/textures/texture.cpp b/src/plugins/renderers/rhi/textures/texture.cpp
index 4d99acc52..4561aa936 100644
--- a/src/plugins/renderers/rhi/textures/texture.cpp
+++ b/src/plugins/renderers/rhi/textures/texture.cpp
@@ -1,47 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <QtCore/qhash.h>
#include "texture_p.h"
#include <private/qdebug_p.h>
-#include <private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <QDebug>
#include <Qt3DCore/private/vector_helper_p.h>
#include <Qt3DRender/qtexture.h>
@@ -55,8 +19,6 @@
QT_BEGIN_NAMESPACE
-using namespace Qt3DCore;
-
namespace Qt3DRender {
namespace Render {
namespace Rhi {
@@ -122,8 +84,7 @@ QRhiTexture::Format rhiFormatFromTextureFormat(QAbstractTexture::TextureFormat f
return QRhiTexture::D24;
default:
qDebug() << "Unhandled texture format:" << format;
- Q_UNREACHABLE();
- return QRhiTexture::UnknownFormat;
+ Q_UNREACHABLE_RETURN(QRhiTexture::UnknownFormat);
}
}
@@ -139,8 +100,7 @@ QRhiSampler::Filter rhiFilterFromTextureFilter(QAbstractTexture::Filter filter)
case QAbstractTexture::LinearMipMapLinear:
return QRhiSampler::Linear;
default:
- Q_UNREACHABLE();
- return QRhiSampler::Nearest;
+ Q_UNREACHABLE_RETURN(QRhiSampler::Nearest);
}
}
@@ -159,8 +119,7 @@ QRhiSampler::Filter rhiMipMapFilterFromTextureFilter(QAbstractTexture::Filter fi
case QAbstractTexture::LinearMipMapLinear:
return QRhiSampler::Linear;
default:
- Q_UNREACHABLE();
- return QRhiSampler::None;
+ Q_UNREACHABLE_RETURN(QRhiSampler::None);
}
}
@@ -232,15 +191,12 @@ void filterLayersAndFaces(const QTextureImageData &data, F f)
f(createUploadEntry(level, 0, data.data(0, 0, level)));
}
} else if (layers > 1 && faces == 1) {
- qWarning() << Q_FUNC_INFO << "Unsupported case, see QTBUG-83343";
- /*
for (int layer = 0; layer < data.layers(); layer++) {
- for (int level = 0; level < mipLevels; level++) {
+ for (int level = 0; level < miplevels; level++) {
f(createUploadEntry(level, layer, data.data(layer, 0, level)));
}
}
- */
- } else if (faces > 1 && layers == 1) {
+ } else if (faces > 1 && layers == 1) {
// Mip levels do not seem to be supported by cubemaps...
for (int face = 0; face < data.faces(); face++) {
f(createUploadEntry(0, face, data.data(0, face, 0)));
@@ -257,8 +213,7 @@ void filterLayerAndFace(int layer, int face, F f)
if (layer == 0 && face == 0) {
f(0);
} else if (layer > 0 && face == 0) {
- qWarning() << Q_FUNC_INFO << "Unsupported case, see QTBUG-83343";
- // f(layer);
+ f(layer);
} else if (layer == 0 && face > 0) {
f(face);
} else {
@@ -371,7 +326,7 @@ bool RHITexture::loadTextureDataFromGenerator()
void RHITexture::loadTextureDataFromImages()
{
int maxMipLevel = 0;
- for (const Image &img : qAsConst(m_images)) {
+ for (const Image &img : std::as_const(m_images)) {
const QTextureImageDataPtr imgData = img.generator->operator()();
// imgData may be null in the following cases:
// - Texture is created with TextureImages which have yet to be
@@ -671,7 +626,20 @@ QRhiTexture *RHITexture::buildRhiTexture(SubmissionContext *ctx)
}
}
- QRhiTexture *rhiTexture = ctx->rhi()->newTexture(rhiFormat, pixelSize, sampleCount, rhiFlags);
+ if(actualTarget == QAbstractTexture::Target3D)
+ rhiFlags |= QRhiTexture::ThreeDimensional;
+
+ QRhiTexture *rhiTexture = nullptr;
+ switch (m_properties.target) {
+ case QAbstractTexture::Target1DArray:
+ case QAbstractTexture::Target2DArray:
+ //This will setup the array flags correctly
+ rhiTexture = ctx->rhi()->newTextureArray(rhiFormat, m_properties.layers, pixelSize, sampleCount, rhiFlags);
+ break;
+ default:
+ rhiTexture = ctx->rhi()->newTexture(rhiFormat, pixelSize, sampleCount, rhiFlags);
+ break;
+ }
if (!rhiTexture->create()) {
qWarning() << Q_FUNC_INFO << "creating QRhiTexture failed";
@@ -760,7 +728,7 @@ void RHITexture::uploadRhiTextureData(SubmissionContext *ctx)
});
}
- if (uploadEntries.size() > 0) {
+ if (!uploadEntries.empty()) {
QRhiTextureUploadDescription uploadDescription;
uploadDescription.setEntries(uploadEntries.begin(), uploadEntries.end());
ctx->m_currentUpdates->uploadTexture(m_rhi, uploadDescription);
diff --git a/src/plugins/renderers/rhi/textures/texture_p.h b/src/plugins/renderers/rhi/textures/texture_p.h
index acdcd2455..2ba45f98f 100644
--- a/src/plugins/renderers/rhi/textures/texture_p.h
+++ b/src/plugins/renderers/rhi/textures/texture_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT3DRENDER_RENDER_RHI_GLTEXTURE_H
#define QT3DRENDER_RENDER_RHI_GLTEXTURE_H
diff --git a/src/plugins/renderers/rhi/textures/textures.pri b/src/plugins/renderers/rhi/textures/textures.pri
deleted file mode 100644
index dd9e6404f..000000000
--- a/src/plugins/renderers/rhi/textures/textures.pri
+++ /dev/null
@@ -1,9 +0,0 @@
-INCLUDEPATH += $$PWD
-
-SOURCES += \
- $$PWD/renderbuffer.cpp \
- $$PWD/texture.cpp
-
-HEADERS += \
- $$PWD/renderbuffer_p.h \
- $$PWD/texture_p.h