summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michaƫl Celerier <jean-michael.celerier@kdab.com>2020-01-03 18:34:15 +0100
committerPaul Lemire <paul.lemire@kdab.com>2020-01-15 07:03:36 +0100
commit825230b872beb5dcfe1a1ce9019f8d80704a1553 (patch)
treec52c578f2f200d1516ac1c899b35dac9775532c9
parent00d90969b270f4ebf9591904827de0fb17368b57 (diff)
Start work on handling shaderswip/rhi-renderer
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicscontext.cpp206
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicscontext_p.h11
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelperes2.cpp1037
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelperes2_p.h184
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3.cpp770
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_1.cpp369
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_1_p.h89
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_2.cpp195
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_2_p.h86
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_p.h110
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl2.cpp937
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl2_p.h185
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_2.cpp1247
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_2_p.h187
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_3.cpp1242
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_3_p.h187
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl4.cpp1444
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl4_p.h184
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelperinterface_p.h102
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/graphicshelpers.pri16
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext.cpp2
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext_p.h2
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/qgraphicsutils_p.h2
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp50
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h3
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext.cpp2
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext_p.h2
-rw-r--r--src/plugins/renderers/rhi/io/buffer.cpp83
-rw-r--r--src/plugins/renderers/rhi/io/buffer_p.h2
-rw-r--r--src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp2
-rw-r--r--src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob_p.h2
-rw-r--r--src/plugins/renderers/rhi/jobs/renderviewbuilderjob_p.h2
-rw-r--r--src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob.cpp2
-rw-r--r--src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob_p.h2
-rw-r--r--src/plugins/renderers/rhi/jobs/renderviewinitializerjob.cpp2
-rw-r--r--src/plugins/renderers/rhi/jobs/renderviewinitializerjob_p.h2
-rw-r--r--src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp2
-rw-r--r--src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h2
-rw-r--r--src/plugins/renderers/rhi/main.cpp2
-rw-r--r--src/plugins/renderers/rhi/managers/handle_types_p.h2
-rw-r--r--src/plugins/renderers/rhi/managers/resourcemanagers.cpp2
-rw-r--r--src/plugins/renderers/rhi/managers/resourcemanagers_p.h2
-rw-r--r--src/plugins/renderers/rhi/renderer/fence_p.h2
-rw-r--r--src/plugins/renderers/rhi/renderer/logging.cpp2
-rw-r--r--src/plugins/renderers/rhi/renderer/logging_p.h2
-rw-r--r--src/plugins/renderers/rhi/renderer/openglvertexarrayobject.cpp25
-rw-r--r--src/plugins/renderers/rhi/renderer/openglvertexarrayobject_p.h7
-rw-r--r--src/plugins/renderers/rhi/renderer/rendercommand.cpp2
-rw-r--r--src/plugins/renderers/rhi/renderer/rendercommand_p.h6
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer.cpp190
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer_p.h11
-rw-r--r--src/plugins/renderers/rhi/renderer/renderqueue.cpp2
-rw-r--r--src/plugins/renderers/rhi/renderer/renderqueue_p.h2
-rw-r--r--src/plugins/renderers/rhi/renderer/renderview.cpp2
-rw-r--r--src/plugins/renderers/rhi/renderer/renderview_p.h2
-rw-r--r--src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp2
-rw-r--r--src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h2
-rw-r--r--src/plugins/renderers/rhi/renderer/shader.cpp177
-rw-r--r--src/plugins/renderers/rhi/renderer/shader_p.h12
-rw-r--r--src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp2
-rw-r--r--src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h2
-rw-r--r--src/plugins/renderers/rhi/renderer/shadervariables_p.h84
-rw-r--r--src/plugins/renderers/rhi/textures/texture.cpp2
-rw-r--r--src/plugins/renderers/rhi/textures/texture_p.h2
-rw-r--r--tests/manual/rhi/main.cpp3
65 files changed, 425 insertions, 9080 deletions
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicscontext.cpp b/src/plugins/renderers/rhi/graphicshelpers/graphicscontext.cpp
index 4cb0104ac..21be15046 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicscontext.cpp
+++ b/src/plugins/renderers/rhi/graphicshelpers/graphicscontext.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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/
**
@@ -70,15 +70,8 @@
#include <QOpenGLFunctions_3_2_Core>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLFunctions_4_3_Core>
-#include <graphicshelpergl2_p.h>
-#include <graphicshelpergl3_2_p.h>
-#include <graphicshelpergl3_3_p.h>
-#include <graphicshelpergl4_p.h>
#endif
-#include <graphicshelperes2_p.h>
-#include <graphicshelperes3_p.h>
-#include <graphicshelperes3_1_p.h>
-#include <graphicshelperes3_2_p.h>
+#include <QShaderBaker>
#include <QSurface>
#include <QWindow>
@@ -131,7 +124,6 @@ void logOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage)
GraphicsContext::GraphicsContext()
: m_initialized(false)
- , m_supportsVAO(false)
, m_maxTextureUnits(0)
, m_maxImageUnits(0)
, m_defaultFBO(0)
@@ -147,13 +139,6 @@ GraphicsContext::~GraphicsContext()
{
}
-void GraphicsContext::setOpenGLContext(QOpenGLContext* ctx)
-{
- RHI_UNIMPLEMENTED;
-//* Q_ASSERT(ctx);
-//* m_gl = ctx;
-}
-
void GraphicsContext::initialize()
{
m_initialized = true;
@@ -196,13 +181,6 @@ void GraphicsContext::clearBackBuffer(QClearBuffers::BufferTypeFlags buffers)
}
}
-bool GraphicsContext::hasValidGLHelper() const
-{
- RHI_UNIMPLEMENTED;
-//* return m_glHelper != nullptr;
- return true;
-}
-
bool GraphicsContext::isInitialized() const
{
return m_initialized;
@@ -243,43 +221,69 @@ void GraphicsContext::doneCurrent()
}
// Called by GL Command Thread
+
+static constexpr QShader::Stage rhiShaderStage(QShaderProgram::ShaderType type) noexcept
+{
+ switch(type)
+ {
+ case QShaderProgram::Vertex: return QShader::VertexStage;
+ case QShaderProgram::Fragment: return QShader::FragmentStage;
+ case QShaderProgram::TessellationControl: return QShader::TessellationControlStage;
+ case QShaderProgram::TessellationEvaluation: return QShader::TessellationEvaluationStage;
+ case QShaderProgram::Geometry: return QShader::GeometryStage;
+ case QShaderProgram::Compute: return QShader::ComputeStage;
+ default: std::abort();
+ }
+}
GraphicsContext::ShaderCreationInfo GraphicsContext::createShaderProgram(RHIShader *shader)
{
- RHI_UNIMPLEMENTED;
- return {true, {}};
-//* QOpenGLShaderProgram *shaderProgram = shader->shaderProgram();
-//*
-//* // Compile shaders
-//* const auto shaderCode = shader->shaderCode();
-//*
-//* QString logs;
-//* for (int i = QShaderProgram::Vertex; i <= QShaderProgram::Compute; ++i) {
-//* const QShaderProgram::ShaderType type = static_cast<QShaderProgram::ShaderType>(i);
-//* if (!shaderCode.at(i).isEmpty()) {
-//* // Note: logs only return the error but not all the shader code
-//* // we could append it
-//* if (!shaderProgram->addCacheableShaderFromSourceCode(shaderType(type), shaderCode.at(i)))
-//* logs += shaderProgram->log();
-//* }
-//* }
-//*
-//* // Call glBindFragDataLocation and link the program
-//* // Since we are sharing shaders in the backend, we assume that if using custom
-//* // fragOutputs, they should all be the same for a given shader
-//* bindFragOutputs(shaderProgram->programId(), shader->fragOutputs());
-//*
-//* const bool linkSucceeded = shaderProgram->link();
-//* logs += shaderProgram->log();
-//*
-//* // Perform shader introspection
-//* introspectShaderInterface(shader);
-//*
-//* return {linkSucceeded, logs};
+ // Compile shaders
+ const auto& shaderCode = shader->shaderCode();
+ QShaderBaker b;
+ b.setGeneratedShaders({
+ {QShader::SpirvShader, 100},
+ {QShader::GlslShader, 120}, // Only GLSL version supported by RHI right now.
+ {QShader::HlslShader, 100},
+ {QShader::MslShader, 100},
+ });
+ b.setGeneratedShaderVariants({QShader::Variant{},
+ QShader::Variant{},
+ QShader::Variant{},
+ QShader::Variant{}});
+
+ // TODO handle caching as QShader does not have a built-in mechanism for that
+ QString logs;
+ bool success = true;
+ for (int i = QShaderProgram::Vertex; i <= QShaderProgram::Compute; ++i) {
+ const QShaderProgram::ShaderType type = static_cast<QShaderProgram::ShaderType>(i);
+ if (!shaderCode.at(i).isEmpty()) {
+ // Note: logs only return the error but not all the shader code
+ // we could append it
+
+ const auto rhiStage = rhiShaderStage(type);
+ b.setSourceString(shaderCode.at(i), rhiStage);
+ auto bakedShader = b.bake();
+ if(b.errorMessage() != QString{})
+ {
+ qDebug() << "Vertex Shader Error: " << b.errorMessage();
+ logs += b.errorMessage();
+ success = false;
+ }
+ shader->m_stages[rhiStage] = std::move(bakedShader);
+ }
+ }
+
+ // Perform shader introspection
+ introspectShaderInterface(shader);
+
+ return {success, logs};
}
// That assumes that the shaderProgram in Shader stays the same
+
void GraphicsContext::introspectShaderInterface(RHIShader *shader)
{
+ shader->introspect();
RHI_UNIMPLEMENTED;
//* QOpenGLShaderProgram *shaderProgram = shader->shaderProgram();
//* GraphicsHelperInterface *glHelper = resolveHighestOpenGLFunctions();
@@ -360,99 +364,6 @@ void GraphicsContext::rasterMode(GLenum faceMode, GLenum rasterMode)
//* m_glHelper->rasterMode(faceMode, rasterMode);
}
-/*!
- * \internal
- * Finds the highest supported opengl version and internally use the most optimized
- * helper for a given version.
- */
-GraphicsHelperInterface *GraphicsContext::resolveHighestOpenGLFunctions()
-{
- RHI_UNIMPLEMENTED;
-//* Q_ASSERT(m_gl);
-//* GraphicsHelperInterface *glHelper = nullptr;
-//*
-//* if (m_gl->isOpenGLES()) {
-//* if (m_gl->format().majorVersion() >= 3) {
-//* if (m_gl->format().minorVersion() >= 2) {
-//* glHelper = new GraphicsHelperES3_2;
-//* qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL ES 3.2 Helper";
-//* } else if (m_gl->format().minorVersion() >= 1) {
-//* glHelper = new GraphicsHelperES3_1;
-//* qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL ES 3.1 Helper";
-//* } else {
-//* glHelper = new GraphicsHelperES3();
-//* qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL ES 3.0 Helper";
-//* }
-//* } else {
-//* glHelper = new GraphicsHelperES2();
-//* qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL ES2 Helper";
-//* }
-//* glHelper->initializeHelper(m_gl, nullptr);
-//* }
-//*#ifndef QT_OPENGL_ES_2
-//* else {
-//* QAbstractOpenGLFunctions *glFunctions = nullptr;
-//* if ((glFunctions = m_gl->versionFunctions<QOpenGLFunctions_4_3_Core>()) != nullptr) {
-//* qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL 4.3";
-//* glHelper = new GraphicsHelperGL4();
-//* } else if ((glFunctions = m_gl->versionFunctions<QOpenGLFunctions_3_3_Core>()) != nullptr) {
-//* qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL 3.3";
-//* glHelper = new GraphicsHelperGL3_3();
-//* } else if ((glFunctions = m_gl->versionFunctions<QOpenGLFunctions_3_2_Core>()) != nullptr) {
-//* qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL 3.2";
-//* glHelper = new GraphicsHelperGL3_2();
-//* } else if ((glFunctions = m_gl->versionFunctions<QOpenGLFunctions_2_0>()) != nullptr) {
-//* qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL 2 Helper";
-//* glHelper = new GraphicsHelperGL2();
-//* }
-//* Q_ASSERT_X(glHelper, "GraphicsContext::resolveHighestOpenGLFunctions", "unable to create valid helper for available OpenGL version");
-//* glHelper->initializeHelper(m_gl, glFunctions);
-//* }
-//*#endif
-//*
-//* // Note: at this point we are certain the context (m_gl) is current with a surface
-//* const QByteArray debugLoggingMode = qgetenv("QT3DRENDER_DEBUG_LOGGING");
-//* const bool enableDebugLogging = !debugLoggingMode.isEmpty();
-//*
-//* if (enableDebugLogging && !m_debugLogger) {
-//* if (m_gl->hasExtension("GL_KHR_debug")) {
-//* qCDebug(Backend) << "Qt3D: Enabling OpenGL debug logging";
-//* m_debugLogger.reset(new QOpenGLDebugLogger);
-//* if (m_debugLogger->initialize()) {
-//* QObject::connect(m_debugLogger.data(), &QOpenGLDebugLogger::messageLogged, &logOpenGLDebugMessage);
-//* const QString mode = QString::fromLocal8Bit(debugLoggingMode);
-//* m_debugLogger->startLogging(mode.startsWith(QLatin1String("sync"), Qt::CaseInsensitive)
-//* ? QOpenGLDebugLogger::SynchronousLogging
-//* : QOpenGLDebugLogger::AsynchronousLogging);
-//*
-//* const auto msgs = m_debugLogger->loggedMessages();
-//* for (const QOpenGLDebugMessage &msg : msgs)
-//* logOpenGLDebugMessage(msg);
-//* }
-//* } else {
-//* qCDebug(Backend) << "Qt3D: OpenGL debug logging requested but GL_KHR_debug not supported";
-//* }
-//* }
-//*
-
- // Set Vendor and Extensions of reference GraphicsApiFilter
- // TO DO: would that vary like the glHelper ?
-
- QStringList extensions;
- //const auto exts = m_gl->extensions();
- //for (const QByteArray &ext : exts)
- // extensions << QString::fromUtf8(ext);
- m_contextInfo.m_major = 3;
- m_contextInfo.m_minor = 2;
- // m_contextInfo.m_major = m_gl->format().version().first;
- // m_contextInfo.m_minor = m_gl->format().version().second;
- m_contextInfo.m_api = QGraphicsApiFilter::RHI;
- //m_contextInfo.m_profile = static_cast<QGraphicsApiFilter::OpenGLProfile>(m_gl->format().profile());
- m_contextInfo.m_extensions = extensions;
- //m_contextInfo.m_vendor = QString::fromUtf8(reinterpret_cast<const char *>(m_gl->functions()->glGetString(GL_VENDOR)));
-
- return nullptr;
-}
const GraphicsApiFilterData *GraphicsContext::contextInfo() const
{
@@ -461,6 +372,7 @@ const GraphicsApiFilterData *GraphicsContext::contextInfo() const
bool GraphicsContext::supportsDrawBuffersBlend() const
{
+ RHI_UNIMPLEMENTED;
return false;
//* return m_glHelper->supportsFeature(GraphicsHelperInterface::DrawBuffersBlend);
}
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicscontext_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicscontext_p.h
index 89da47371..605899823 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicscontext_p.h
+++ b/src/plugins/renderers/rhi/graphicshelpers/graphicscontext_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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/
**
@@ -105,11 +105,8 @@ public:
GraphicsContext();
~GraphicsContext();
- void setOpenGLContext(QOpenGLContext* ctx);
- //QOpenGLContext *openGLContext() { return m_gl; }
bool makeCurrent(QSurface *surface);
void doneCurrent();
- bool hasValidGLHelper() const;
bool isInitialized() const;
// Shaders
@@ -188,21 +185,15 @@ public:
static GLint glDataTypeFromAttributeDataType(QAttribute::VertexBaseType dataType);
bool supportsDrawBuffersBlend() const;
- bool supportsVAO() const { return m_supportsVAO; }
void initialize();
void initializeHelpers(QSurface *surface);
- GraphicsHelperInterface *resolveHighestOpenGLFunctions();
bool m_initialized;
- bool m_supportsVAO;
GLint m_maxTextureUnits;
GLint m_maxImageUnits;
GLuint m_defaultFBO;
- //* QOpenGLContext *m_gl;
- //* GraphicsHelperInterface *m_glHelper;
- //* QHash<QSurface *, GraphicsHelperInterface*> m_glHelpers;
GraphicsApiFilterData m_contextInfo;
QScopedPointer<QOpenGLDebugLogger> m_debugLogger;
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes2.cpp b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes2.cpp
deleted file mode 100644
index 60a59f080..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes2.cpp
+++ /dev/null
@@ -1,1037 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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$
-**
-****************************************************************************/
-
-#include "graphicshelperes2_p.h"
-#include <private/attachmentpack_p.h>
-#include <qgraphicsutils_p.h>
-#include <renderbuffer_p.h>
-#include <logging_p.h>
-#include <QtGui/private/qopenglextensions_p.h>
-
-
-QT_BEGIN_NAMESPACE
-
-// ES 3.0+
-#ifndef GL_SAMPLER_3D
-#define GL_SAMPLER_3D 0x8B5F
-#endif
-#ifndef GL_SAMPLER_2D_SHADOW
-#define GL_SAMPLER_2D_SHADOW 0x8B62
-#endif
-#ifndef GL_SAMPLER_CUBE_SHADOW
-#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
-#endif
-#ifndef GL_SAMPLER_2D_ARRAY
-#define GL_SAMPLER_2D_ARRAY 0x8DC1
-#endif
-#ifndef GL_SAMPLER_2D_ARRAY_SHADOW
-#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
-#endif
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-GraphicsHelperES2::GraphicsHelperES2()
- : m_funcs(0)
- , m_supportFramebufferBlit(false)
-{
-}
-
-GraphicsHelperES2::~GraphicsHelperES2()
-{
-}
-
-void GraphicsHelperES2::initializeHelper(QOpenGLContext *context,
- QAbstractOpenGLFunctions *)
-{
- Q_ASSERT(context);
- m_funcs = context->functions();
- Q_ASSERT(m_funcs);
- m_ext.reset(new QOpenGLExtensions(context));
- if (m_ext->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit))
- m_supportFramebufferBlit = true;
-}
-
-void GraphicsHelperES2::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2";
-
- if (baseVertex != 0)
- qWarning() << "glDrawElementsInstancedBaseVertex is not supported with OpenGL ES 2";
-
- for (GLint i = 0; i < instances; i++)
- drawElements(primitiveType,
- primitiveCount,
- indexType,
- indices);
-}
-
-void GraphicsHelperES2::drawArraysInstanced(GLenum primitiveType,
- GLint first,
- GLsizei count,
- GLsizei instances)
-{
- for (GLint i = 0; i < instances; i++)
- drawArrays(primitiveType,
- first,
- count);
-}
-
-void GraphicsHelperES2::drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawArraysInstancedBaseInstance is not supported with OpenGL ES 2";
- for (GLint i = 0; i < instances; i++)
- drawArrays(primitiveType,
- first,
- count);
-}
-
-void GraphicsHelperES2::drawElements(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLint baseVertex)
-{
- if (baseVertex != 0)
- qWarning() << "glDrawElementsBaseVertex is not supported with OpenGL ES 2";
- QOpenGLExtensions *xfuncs = static_cast<QOpenGLExtensions *>(m_funcs);
- if (indexType == GL_UNSIGNED_INT && !xfuncs->hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint)) {
- static bool warnShown = false;
- if (!warnShown) {
- warnShown = true;
- qWarning("GL_UNSIGNED_INT index type not supported on this system, skipping draw call.");
- }
- return;
- }
- m_funcs->glDrawElements(primitiveType,
- primitiveCount,
- indexType,
- indices);
-}
-
-void GraphicsHelperES2::drawArrays(GLenum primitiveType,
- GLint first,
- GLsizei count)
-{
- m_funcs->glDrawArrays(primitiveType,
- first,
- count);
-}
-
-void GraphicsHelperES2::drawElementsIndirect(GLenum, GLenum, void *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "Indirect Drawing is not supported with OpenGL ES 2";
-}
-
-void GraphicsHelperES2::drawArraysIndirect(GLenum , void *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "Indirect Drawing is not supported with OpenGL ES 2";
-}
-
-void GraphicsHelperES2::setVerticesPerPatch(GLint verticesPerPatch)
-{
- Q_UNUSED(verticesPerPatch);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "Tessellation not supported with OpenGL ES 2";
-}
-
-void GraphicsHelperES2::useProgram(GLuint programId)
-{
- m_funcs->glUseProgram(programId);
-}
-
-QVector<ShaderUniform> GraphicsHelperES2::programUniformsAndLocations(GLuint programId)
-{
- QVector<ShaderUniform> uniforms;
-
- GLint nbrActiveUniforms = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_UNIFORMS, &nbrActiveUniforms);
- uniforms.reserve(nbrActiveUniforms);
- char uniformName[256];
- for (GLint i = 0; i < nbrActiveUniforms; i++) {
- ShaderUniform uniform;
- GLsizei uniformNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveUniform(programId, i, sizeof(uniformName) - 1, &uniformNameLength,
- &uniform.m_size, &uniform.m_type, uniformName);
- uniformName[sizeof(uniformName) - 1] = '\0';
- uniform.m_location = m_funcs->glGetUniformLocation(programId, uniformName);
- uniform.m_name = QString::fromUtf8(uniformName, uniformNameLength);
- // Work around for uniform array names that aren't returned with [0] by some drivers
- if (uniform.m_size > 1 && !uniform.m_name.endsWith(QLatin1String("[0]")))
- uniform.m_name.append(QLatin1String("[0]"));
- uniform.m_rawByteSize = uniformByteSize(uniform);
- uniforms.append(uniform);
- }
- return uniforms;
-}
-
-QVector<ShaderAttribute> GraphicsHelperES2::programAttributesAndLocations(GLuint programId)
-{
- QVector<ShaderAttribute> attributes;
- GLint nbrActiveAttributes = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_ATTRIBUTES, &nbrActiveAttributes);
- attributes.reserve(nbrActiveAttributes);
- char attributeName[256];
- for (GLint i = 0; i < nbrActiveAttributes; i++) {
- ShaderAttribute attribute;
- GLsizei attributeNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveAttrib(programId, i, sizeof(attributeName) - 1, &attributeNameLength,
- &attribute.m_size, &attribute.m_type, attributeName);
- attributeName[sizeof(attributeName) - 1] = '\0';
- attribute.m_location = m_funcs->glGetAttribLocation(programId, attributeName);
- attribute.m_name = QString::fromUtf8(attributeName, attributeNameLength);
- attributes.append(attribute);
- }
- return attributes;
-}
-
-QVector<ShaderUniformBlock> GraphicsHelperES2::programUniformBlocks(GLuint programId)
-{
- Q_UNUSED(programId);
- QVector<ShaderUniformBlock> blocks;
- static bool showWarning = true;
- if (!showWarning)
- return blocks;
- showWarning = false;
- qWarning() << "UBO are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
- return blocks;
-}
-
-QVector<ShaderStorageBlock> GraphicsHelperES2::programShaderStorageBlocks(GLuint programId)
-{
- Q_UNUSED(programId);
- QVector<ShaderStorageBlock> blocks;
- static bool showWarning = true;
- if (!showWarning)
- return blocks;
- showWarning = false;
- qWarning() << "SSBO are not supported by OpenGL ES 2.0 (since OpenGL ES 3.1)";
- return blocks;
-}
-
-void GraphicsHelperES2::vertexAttribDivisor(GLuint index, GLuint divisor)
-{
- Q_UNUSED(index);
- Q_UNUSED(divisor);
-}
-
-void GraphicsHelperES2::vertexAttributePointer(GLenum shaderDataType,
- GLuint index,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const GLvoid *pointer)
-{
- switch (shaderDataType) {
- case GL_FLOAT:
- case GL_FLOAT_VEC2:
- case GL_FLOAT_VEC3:
- case GL_FLOAT_VEC4:
- case GL_FLOAT_MAT2:
- case GL_FLOAT_MAT3:
- case GL_FLOAT_MAT4:
- m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer);
- break;
-
- default:
- qCWarning(Rendering) << "vertexAttribPointer: Unhandled type";
- Q_UNREACHABLE();
- }
-}
-
-void GraphicsHelperES2::readBuffer(GLenum mode)
-{
- Q_UNUSED(mode)
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glReadBuffer not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
-}
-
-void GraphicsHelperES2::drawBuffer(GLenum mode)
-{
- Q_UNUSED(mode);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glDrawBuffer is not supported with OpenGL ES 2";
-}
-
-void *GraphicsHelperES2::fenceSync()
-{
- qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
- return nullptr;
-}
-
-void GraphicsHelperES2::clientWaitSync(void *, GLuint64 )
-{
- qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
-}
-
-void GraphicsHelperES2::waitSync(void *)
-{
- qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
-}
-
-bool GraphicsHelperES2::wasSyncSignaled(void *)
-{
- qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
- return false;
-}
-
-void GraphicsHelperES2::deleteSync(void *)
-{
- qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
-}
-
-void GraphicsHelperES2::rasterMode(GLenum faceMode, GLenum rasterMode)
-{
- Q_UNUSED(faceMode);
- Q_UNUSED(rasterMode);
- qWarning() << "glPolyonMode is not supported with OpenGL ES";
-}
-
-void GraphicsHelperES2::blendEquation(GLenum mode)
-{
- m_funcs->glBlendEquation(mode);
-}
-
-void GraphicsHelperES2::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
-{
- Q_UNUSED(buf);
- Q_UNUSED(sfactor);
- Q_UNUSED(dfactor);
-
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glBlendFunci() not supported by OpenGL ES 2.0";
-}
-
-void GraphicsHelperES2::blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha)
-{
- Q_UNUSED(buf);
- Q_UNUSED(sRGB);
- Q_UNUSED(dRGB);
- Q_UNUSED(sAlpha);
- Q_UNUSED(dAlpha);
-
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glBlendFuncSeparatei() not supported by OpenGL ES 2.0";
-}
-
-void GraphicsHelperES2::alphaTest(GLenum, GLenum)
-{
- qCWarning(Rendering) << Q_FUNC_INFO << "AlphaTest not available with OpenGL ES 2.0";
-}
-
-void GraphicsHelperES2::depthTest(GLenum mode)
-{
- m_funcs->glEnable(GL_DEPTH_TEST);
- m_funcs->glDepthFunc(mode);
-}
-
-void GraphicsHelperES2::depthMask(GLenum mode)
-{
- m_funcs->glDepthMask(mode);
-}
-
-void GraphicsHelperES2::depthRange(GLdouble nearValue, GLdouble farValue)
-{
- m_funcs->glDepthRangef(static_cast<float>(nearValue), static_cast<float>(farValue));
-}
-
-void GraphicsHelperES2::frontFace(GLenum mode)
-{
- m_funcs->glFrontFace(mode);
-}
-
-void GraphicsHelperES2::setMSAAEnabled(bool enabled)
-{
- Q_UNUSED(enabled);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "MSAA not available with OpenGL ES 2.0";
-}
-
-void GraphicsHelperES2::setAlphaCoverageEnabled(bool enabled)
-{
- enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
- : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-GLuint GraphicsHelperES2::createFrameBufferObject()
-{
- GLuint id;
- m_funcs->glGenFramebuffers(1, &id);
- return id;
-}
-
-void GraphicsHelperES2::releaseFrameBufferObject(GLuint frameBufferId)
-{
- m_funcs->glDeleteFramebuffers(1, &frameBufferId);
-}
-
-void GraphicsHelperES2::bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode)
-{
- Q_UNUSED(mode)
- // For ES2 the spec states for target: The symbolic constant must be GL_FRAMEBUFFER
- // so mode is ignored and is always set to GL_FRAMEBUFFER
- m_funcs->glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
-}
-
-void GraphicsHelperES2::bindImageTexture(GLuint imageUnit, GLuint texture,
- GLint mipLevel, GLboolean layered,
- GLint layer, GLenum access, GLenum format)
-{
- Q_UNUSED(imageUnit)
- Q_UNUSED(texture)
- Q_UNUSED(mipLevel)
- Q_UNUSED(layered)
- Q_UNUSED(layer)
- Q_UNUSED(access)
- Q_UNUSED(format)
- qWarning() << "Shader Images are not supported by ES 2.0 (since ES 3.1)";
-
-}
-
-GLuint GraphicsHelperES2::boundFrameBufferObject()
-{
- GLint id = 0;
- m_funcs->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &id);
- return id;
-}
-
-bool GraphicsHelperES2::checkFrameBufferComplete()
-{
- return (m_funcs->glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
-}
-
-bool GraphicsHelperES2::frameBufferNeedsRenderBuffer(const Attachment &attachment)
-{
- // Use a renderbuffer for depth or stencil attachments since this is
- // problematic before GLES 3.2. Keep using textures for everything else.
- // For ES2 individual Depth and Stencil buffers need to be an option because
- // DepthStencil is an extension.
- return attachment.m_point == QRenderTargetOutput::DepthStencil ||
- attachment.m_point == QRenderTargetOutput::Depth ||
- attachment.m_point == QRenderTargetOutput::Stencil;
-}
-
-void GraphicsHelperES2::bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment)
-{
- GLenum attr = GL_COLOR_ATTACHMENT0;
-
- if (attachment.m_point == QRenderTargetOutput::Color0)
- attr = GL_COLOR_ATTACHMENT0;
- else if (attachment.m_point == QRenderTargetOutput::Depth)
- attr = GL_DEPTH_ATTACHMENT;
- else if (attachment.m_point == QRenderTargetOutput::Stencil)
- attr = GL_STENCIL_ATTACHMENT;
- else
- qCritical() << "Unsupported FBO attachment OpenGL ES 2.0";
-
- const QOpenGLTexture::Target target = texture->target();
-
- if (target == QOpenGLTexture::TargetCubeMap && attachment.m_face == QAbstractTexture::AllFaces) {
- qWarning() << "OpenGL ES 2.0 doesn't handle attaching all the faces of a cube map texture at once to an FBO";
- return;
- }
-
- texture->bind();
- if (target == QOpenGLTexture::Target2D)
- m_funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, attr, target, texture->textureId(), attachment.m_mipLevel);
- else if (target == QOpenGLTexture::TargetCubeMap)
- m_funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel);
- else
- qCritical() << "Unsupported Texture FBO attachment format";
- texture->release();
-}
-
-void GraphicsHelperES2::bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment)
-{
- if (attachment.m_point != QRenderTargetOutput::DepthStencil &&
- attachment.m_point != QRenderTargetOutput::Depth &&
- attachment.m_point != QRenderTargetOutput::Stencil) {
- qCritical() << "Renderbuffers only supported for combined depth-stencil, depth, or stencil, but got attachment point"
- << attachment.m_point;
- return;
- }
-
- renderBuffer->bind();
- if (attachment.m_point == QRenderTargetOutput::DepthStencil ||
- attachment.m_point == QRenderTargetOutput::Depth)
- m_funcs->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderBuffer->renderBufferId());
- if (attachment.m_point == QRenderTargetOutput::DepthStencil ||
- attachment.m_point == QRenderTargetOutput::Stencil)
- m_funcs->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer->renderBufferId());
- renderBuffer->release();
-}
-
-bool GraphicsHelperES2::supportsFeature(GraphicsHelperInterface::Feature feature) const
-{
- switch (feature) {
- case RenderBufferDimensionRetrieval:
- return true;
- case BlitFramebuffer:
- return m_supportFramebufferBlit;
- default:
- return false;
- }
-}
-
-void GraphicsHelperES2::drawBuffers(GLsizei, const int *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "drawBuffers is not supported by ES 2.0";
-}
-
-void GraphicsHelperES2::bindFragDataLocation(GLuint , const QHash<QString, int> &)
-{
- qCritical() << "bindFragDataLocation is not supported by ES 2.0";
-}
-
-void GraphicsHelperES2::bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
-{
- Q_UNUSED(programId);
- Q_UNUSED(uniformBlockIndex);
- Q_UNUSED(uniformBlockBinding);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "UBO are not supported by ES 2.0 (since ES 3.0)";
-}
-
-void GraphicsHelperES2::bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding)
-{
- Q_UNUSED(programId);
- Q_UNUSED(shaderStorageBlockIndex);
- Q_UNUSED(shaderStorageBlockBinding);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "SSBO are not supported by ES 2.0 (since ES 3.1)";
-}
-
-void GraphicsHelperES2::bindBufferBase(GLenum target, GLuint index, GLuint buffer)
-{
- Q_UNUSED(target);
- Q_UNUSED(index);
- Q_UNUSED(buffer);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "bindBufferBase is not supported by ES 2.0 (since ES 3.0)";
-}
-
-void GraphicsHelperES2::buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer)
-{
- Q_UNUSED(v);
- Q_UNUSED(description);
- Q_UNUSED(buffer);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "UBO are not supported by ES 2.0 (since ES 3.0)";
-}
-
-uint GraphicsHelperES2::uniformByteSize(const ShaderUniform &description)
-{
- uint rawByteSize = 0;
- int arrayStride = qMax(description.m_arrayStride, 0);
- int matrixStride = qMax(description.m_matrixStride, 0);
-
- switch (description.m_type) {
-
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- rawByteSize = 8;
- break;
-
- case GL_FLOAT_VEC3:
- case GL_INT_VEC3:
- rawByteSize = 12;
- break;
-
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- rawByteSize = 16;
- break;
-
- case GL_FLOAT_MAT2:
- rawByteSize = matrixStride ? 2 * matrixStride : 16;
- break;
-
- case GL_FLOAT_MAT3:
- rawByteSize = matrixStride ? 3 * matrixStride : 36;
- break;
-
- case GL_FLOAT_MAT4:
- rawByteSize = matrixStride ? 4 * matrixStride : 64;
- break;
-
- case GL_BOOL:
- rawByteSize = 1;
- break;
-
- case GL_BOOL_VEC2:
- rawByteSize = 2;
- break;
-
- case GL_BOOL_VEC3:
- rawByteSize = 3;
- break;
-
- case GL_BOOL_VEC4:
- rawByteSize = 4;
- break;
-
- case GL_INT:
- case GL_FLOAT:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_CUBE:
- rawByteSize = 4;
- break;
- }
-
- return arrayStride ? rawByteSize * arrayStride : rawByteSize;
-}
-
-void GraphicsHelperES2::enableClipPlane(int)
-{
-}
-
-void GraphicsHelperES2::disableClipPlane(int)
-{
-}
-
-void GraphicsHelperES2::setClipPlane(int, const QVector3D &, float)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "Clip planes not supported by OpenGL ES 2.0";
-}
-
-GLint GraphicsHelperES2::maxClipPlaneCount()
-{
- return 0;
-}
-
-void GraphicsHelperES2::memoryBarrier(QMemoryBarrier::Operations barriers)
-{
- Q_UNUSED(barriers);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "memory barrier is not supported by OpenGL ES 2.0 (since 4.3)";
-}
-
-void GraphicsHelperES2::enablePrimitiveRestart(int)
-{
-}
-
-void GraphicsHelperES2::enableVertexAttributeArray(int location)
-{
- m_funcs->glEnableVertexAttribArray(location);
-}
-
-void GraphicsHelperES2::disablePrimitiveRestart()
-{
-}
-
-void GraphicsHelperES2::clearBufferf(GLint drawbuffer, const QVector4D &values)
-{
- Q_UNUSED(drawbuffer);
- Q_UNUSED(values);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glClearBuffer*() not supported by OpenGL ES 2.0";
-}
-
-void GraphicsHelperES2::pointSize(bool programmable, GLfloat value)
-{
- // If this is not a reset to default values, print a warning
- if (programmable || !qFuzzyCompare(value, 1.0f)) {
- static bool warned = false;
- if (!warned) {
- qWarning() << "glPointSize() and GL_PROGRAM_POINT_SIZE are not supported by ES 2.0";
- warned = true;
- }
- }
-}
-
-void GraphicsHelperES2::enablei(GLenum cap, GLuint index)
-{
- Q_UNUSED(cap);
- Q_UNUSED(index);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glEnablei() not supported by OpenGL ES 2.0";
-}
-
-void GraphicsHelperES2::disablei(GLenum cap, GLuint index)
-{
- Q_UNUSED(cap);
- Q_UNUSED(index);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glDisablei() not supported by OpenGL ES 2.0";
-}
-
-void GraphicsHelperES2::setSeamlessCubemap(bool enable)
-{
- Q_UNUSED(enable);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "GL_TEXTURE_CUBE_MAP_SEAMLESS not supported by OpenGL ES 2.0";
-}
-
-QSize GraphicsHelperES2::getRenderBufferDimensions(GLuint renderBufferId)
-{
- GLint width = 0;
- GLint height = 0;
-
- m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, renderBufferId);
- m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
- m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
- m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, 0);
-
- return QSize(width, height);
-}
-
-QSize GraphicsHelperES2::getTextureDimensions(GLuint textureId, GLenum target, uint level)
-{
- Q_UNUSED(textureId);
- Q_UNUSED(target);
- Q_UNUSED(level);
- qCritical() << "getTextureDimensions is not supported by ES 2.0";
- return QSize(0, 0);
-}
-
-void GraphicsHelperES2::dispatchCompute(GLuint wx, GLuint wy, GLuint wz)
-{
- Q_UNUSED(wx);
- Q_UNUSED(wy);
- Q_UNUSED(wz);
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "Compute Shaders are not supported by ES 2.0 (since ES 3.1)";
-}
-
-char *GraphicsHelperES2::mapBuffer(GLenum target, GLsizeiptr size)
-{
- Q_UNUSED(target);
- Q_UNUSED(size);
- static bool showWarning = true;
- if (!showWarning)
- return nullptr;
- showWarning = false;
- qWarning() << "Map buffer is not a core requirement for ES 2.0";
- return nullptr;
-}
-
-GLboolean GraphicsHelperES2::unmapBuffer(GLenum target)
-{
- Q_UNUSED(target);
- static bool showWarning = true;
- if (!showWarning)
- return false;
- showWarning = false;
- qWarning() << "unMap buffer is not a core requirement for ES 2.0";
- return false;
-}
-
-void GraphicsHelperES2::glUniform1fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform1fv(location, count, values);
-}
-
-void GraphicsHelperES2::glUniform2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform2fv(location, count, values);
-}
-
-void GraphicsHelperES2::glUniform3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform3fv(location, count, values);
-}
-
-void GraphicsHelperES2::glUniform4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform4fv(location, count, values);
-}
-
-void GraphicsHelperES2::glUniform1iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform1iv(location, count, values);
-}
-
-void GraphicsHelperES2::glUniform2iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform2iv(location, count, values);
-}
-
-void GraphicsHelperES2::glUniform3iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform3iv(location, count, values);
-}
-
-void GraphicsHelperES2::glUniform4iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform4iv(location, count, values);
-}
-
-void GraphicsHelperES2::glUniform1uiv(GLint , GLsizei , const GLuint *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniform1uiv not supported by ES 2";
-}
-
-void GraphicsHelperES2::glUniform2uiv(GLint , GLsizei , const GLuint *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniform2uiv not supported by ES 2";
-}
-
-void GraphicsHelperES2::glUniform3uiv(GLint , GLsizei , const GLuint *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniform3uiv not supported by ES 2";
-}
-
-void GraphicsHelperES2::glUniform4uiv(GLint , GLsizei , const GLuint *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniform4uiv not supported by ES 2";
-}
-
-void GraphicsHelperES2::glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2fv(location, count, false, values);
-}
-
-void GraphicsHelperES2::glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3fv(location, count, false, values);
-}
-
-void GraphicsHelperES2::glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4fv(location, count, false, values);
-}
-
-void GraphicsHelperES2::glUniformMatrix2x3fv(GLint , GLsizei , const GLfloat *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniformMatrix2x3fv not supported by ES 2";
-}
-
-void GraphicsHelperES2::glUniformMatrix3x2fv(GLint , GLsizei , const GLfloat *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniformMatrix3x2fv not supported by ES 2";
-}
-
-void GraphicsHelperES2::glUniformMatrix2x4fv(GLint , GLsizei , const GLfloat *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniformMatrix2x4fv not supported by ES 2";
-}
-
-void GraphicsHelperES2::glUniformMatrix4x2fv(GLint , GLsizei , const GLfloat *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniformMatrix4x2fv not supported by ES 2";
-}
-
-void GraphicsHelperES2::glUniformMatrix3x4fv(GLint , GLsizei , const GLfloat *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniformMatrix3x4fv not supported by ES 2";
-}
-
-void GraphicsHelperES2::glUniformMatrix4x3fv(GLint , GLsizei , const GLfloat *)
-{
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "glUniformMatrix4x3fv not supported by ES 2";
-}
-
-UniformType GraphicsHelperES2::uniformTypeFromGLType(GLenum type)
-{
- switch (type) {
- case GL_FLOAT:
- return UniformType::Float;
- case GL_FLOAT_VEC2:
- return UniformType::Vec2;
- case GL_FLOAT_VEC3:
- return UniformType::Vec3;
- case GL_FLOAT_VEC4:
- return UniformType::Vec4;
- case GL_FLOAT_MAT2:
- return UniformType::Mat2;
- case GL_FLOAT_MAT3:
- return UniformType::Mat3;
- case GL_FLOAT_MAT4:
- return UniformType::Mat4;
- case GL_INT:
- return UniformType::Int;
- case GL_INT_VEC2:
- return UniformType::IVec2;
- case GL_INT_VEC3:
- return UniformType::IVec3;
- case GL_INT_VEC4:
- return UniformType::IVec4;
- case GL_BOOL:
- return UniformType::Bool;
- case GL_BOOL_VEC2:
- return UniformType::BVec2;
- case GL_BOOL_VEC3:
- return UniformType::BVec3;
- case GL_BOOL_VEC4:
- return UniformType::BVec4;
-
- case GL_SAMPLER_2D:
- case GL_SAMPLER_CUBE:
- return UniformType::Sampler;
- default:
- Q_UNREACHABLE();
- return UniformType::Float;
- }
-}
-
-void GraphicsHelperES2::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
-{
- if (!m_supportFramebufferBlit) {
- static bool showWarning = true;
- if (!showWarning)
- return;
- showWarning = false;
- qWarning() << "Framebuffer blits are not supported by ES 2.0 (since ES 3.1)";
- } else
- m_ext->glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-}
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes2_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes2_p.h
deleted file mode 100644
index 80f497464..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes2_p.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_RENDER_RHI_GRAPHICSHELPERES2_H
-#define QT3DRENDER_RENDER_RHI_GRAPHICSHELPERES2_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <graphicshelperinterface_p.h>
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLExtensions;
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-class GraphicsHelperES2 : public GraphicsHelperInterface
-{
-public:
- GraphicsHelperES2();
- virtual ~GraphicsHelperES2();
-
- // QGraphicHelperInterface interface
- void alphaTest(GLenum mode1, GLenum mode2) override;
- void bindBufferBase(GLenum target, GLuint index, GLuint buffer) override;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) override;
- bool frameBufferNeedsRenderBuffer(const Attachment &attachment) override;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) override;
- void bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment) override;
- void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) override;
- void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) override;
- void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) override;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override;
- void blendEquation(GLenum mode) override;
- void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) override;
- void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha) override;
- void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override;
- GLuint boundFrameBufferObject() override;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) override;
- bool checkFrameBufferComplete() override;
- void clearBufferf(GLint drawbuffer, const QVector4D &values) override;
- GLuint createFrameBufferObject() override;
- void depthMask(GLenum mode) override;
- void depthRange(GLdouble nearValue, GLdouble farValue) override;
- void depthTest(GLenum mode) override;
- void disableClipPlane(int clipPlane) override;
- void disablei(GLenum cap, GLuint index) override;
- void disablePrimitiveRestart() override;
- void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) override;
- char *mapBuffer(GLenum target, GLsizeiptr size) override;
- GLboolean unmapBuffer(GLenum target) override;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) override;
- void drawArraysIndirect(GLenum mode,void *indirect) override;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) override;
- void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) override;
- void drawBuffers(GLsizei n, const int *bufs) override;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) override;
- void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) override;
- void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) override;
- void enableClipPlane(int clipPlane) override;
- void enablei(GLenum cap, GLuint index) override;
- void enablePrimitiveRestart(int primitiveRestartIndex) override;
- void enableVertexAttributeArray(int location) override;
- void frontFace(GLenum mode) override;
- QSize getRenderBufferDimensions(GLuint renderBufferId) override;
- QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) override;
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) override;
- void pointSize(bool programmable, GLfloat value) override;
- GLint maxClipPlaneCount() override;
- void memoryBarrier(QMemoryBarrier::Operations barriers) override;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) override;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) override;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) override;
- QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) override;
- void releaseFrameBufferObject(GLuint frameBufferId) override;
- void setMSAAEnabled(bool enable) override;
- void setAlphaCoverageEnabled(bool enable) override;
- void setClipPlane(int clipPlane, const QVector3D &normal, float distance) override;
- void setSeamlessCubemap(bool enable) override;
- void setVerticesPerPatch(GLint verticesPerPatch) override;
- bool supportsFeature(Feature feature) const override;
- uint uniformByteSize(const ShaderUniform &description) override;
- void useProgram(GLuint programId) override;
- void vertexAttribDivisor(GLuint index, GLuint divisor) override;
- void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) override;
- void readBuffer(GLenum mode) override;
- void drawBuffer(GLenum mode) override;
- void rasterMode(GLenum faceMode, GLenum rasterMode) override;
-
- void *fenceSync() override;
- void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
- void waitSync(void *sync) override;
- bool wasSyncSignaled(void *sync) override;
- void deleteSync(void *sync) override;
-
- void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- void glUniform1iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform2iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform3iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform4iv(GLint location, GLsizei count, const GLint *value) override;
-
- void glUniform1uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform2uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform3uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform4uiv(GLint location, GLsizei count, const GLuint *value) override;
-
- void glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- UniformType uniformTypeFromGLType(GLenum glType) override;
-
-protected:
- QOpenGLFunctions *m_funcs;
- bool m_supportFramebufferBlit;
- QScopedPointer<QOpenGLExtensions> m_ext;
-};
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // QT3DRENDER_RENDER_RHI_GRAPHICSHELPERES2_H
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3.cpp b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3.cpp
deleted file mode 100644
index fcb99f21b..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3.cpp
+++ /dev/null
@@ -1,770 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 Svenn-Arne Dragly.
-** 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$
-**
-****************************************************************************/
-
-#include "graphicshelperes3_p.h"
-#include <private/attachmentpack_p.h>
-#include <qgraphicsutils_p.h>
-#include <logging_p.h>
-#include <QOpenGLExtraFunctions>
-
-QT_BEGIN_NAMESPACE
-
-// ES 3.0+
-#ifndef GL_SAMPLER_3D
-#define GL_SAMPLER_3D 0x8B5F
-#endif
-#ifndef GL_SAMPLER_2D_SHADOW
-#define GL_SAMPLER_2D_SHADOW 0x8B62
-#endif
-#ifndef GL_SAMPLER_CUBE_SHADOW
-#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
-#endif
-#ifndef GL_SAMPLER_2D_ARRAY
-#define GL_SAMPLER_2D_ARRAY 0x8DC1
-#endif
-#ifndef GL_SAMPLER_2D_ARRAY_SHADOW
-#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
-#endif
-#ifndef GL_FLOAT_MAT2x3
-#define GL_FLOAT_MAT2x3 0x8B65
-#endif
-#ifndef GL_FLOAT_MAT2x4
-#define GL_FLOAT_MAT2x4 0x8B66
-#endif
-#ifndef GL_FLOAT_MAT3x2
-#define GL_FLOAT_MAT3x2 0x8B67
-#endif
-#ifndef GL_FLOAT_MAT3x4
-#define GL_FLOAT_MAT3x4 0x8B68
-#endif
-#ifndef GL_FLOAT_MAT4x2
-#define GL_FLOAT_MAT4x2 0x8B69
-#endif
-#ifndef GL_FLOAT_MAT4x3
-#define GL_FLOAT_MAT4x3 0x8B6A
-#endif
-#ifndef GL_UNSIGNED_INT_VEC2
-#define GL_UNSIGNED_INT_VEC2 0x8DC6
-#endif
-#ifndef GL_UNSIGNED_INT_VEC3
-#define GL_UNSIGNED_INT_VEC3 0x8DC7
-#endif
-#ifndef GL_UNSIGNED_INT_VEC4
-#define GL_UNSIGNED_INT_VEC4 0x8DC8
-#endif
-#ifndef GL_INT_SAMPLER_2D
-#define GL_INT_SAMPLER_2D 0x8DCA
-#endif
-#ifndef GL_INT_SAMPLER_3D
-#define GL_INT_SAMPLER_3D 0x8DCB
-#endif
-#ifndef GL_INT_SAMPLER_CUBE
-#define GL_INT_SAMPLER_CUBE 0x8DCC
-#endif
-#ifndef GL_INT_SAMPLER_2D_ARRAY
-#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
-#endif
-#ifndef GL_UNSIGNED_INT_SAMPLER_2D
-#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
-#endif
-#ifndef GL_UNSIGNED_INT_SAMPLER_3D
-#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
-#endif
-#ifndef GL_UNSIGNED_INT_SAMPLER_CUBE
-#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
-#endif
-#ifndef GL_UNSIGNED_INT_SAMPLER_2D_ARRAY
-#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
-#endif
-
-#ifndef GL_ACTIVE_UNIFORM_BLOCKS
-#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
-#endif
-#ifndef GL_UNIFORM_BLOCK_INDEX
-#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
-#endif
-#ifndef GL_UNIFORM_OFFSET
-#define GL_UNIFORM_OFFSET 0x8A3B
-#endif
-#ifndef GL_UNIFORM_ARRAY_STRIDE
-#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
-#endif
-#ifndef GL_UNIFORM_MATRIX_STRIDE
-#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
-#endif
-#ifndef GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
-#endif
-#ifndef GL_UNIFORM_BLOCK_BINDING
-#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
-#endif
-#ifndef GL_UNIFORM_BLOCK_DATA_SIZE
-#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
-#endif
-
-#ifndef GL_DRAW_FRAMEBUFFER
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#endif
-
-#ifndef GL_READ_FRAMEBUFFER
-#define GL_READ_FRAMEBUFFER 0x8CA8
-#endif
-
-#ifndef GL_SIGNALED
-#define GL_SIGNALED 0x9119
-#endif
-
-#ifndef GL_SYNC_STATUS
-#define GL_SYNC_STATUS 0x9114
-#endif
-
-#ifndef GL_TIMEOUT_IGNORED
-#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
-#endif
-
-#ifndef GL_SYNC_GPU_COMMANDS_COMPLETE
-#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
-#endif
-
-#ifndef GL_SYNC_FLUSH_COMMANDS_BIT
-#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
-#endif
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-GraphicsHelperES3::GraphicsHelperES3()
-{
-}
-
-GraphicsHelperES3::~GraphicsHelperES3()
-{
-}
-
-void GraphicsHelperES3::initializeHelper(QOpenGLContext *context,
- QAbstractOpenGLFunctions *functions)
-{
- GraphicsHelperES2::initializeHelper(context, functions);
- m_extraFuncs = context->extraFunctions();
- Q_ASSERT(m_extraFuncs);
-}
-
-void GraphicsHelperES3::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 3";
-
- if (baseVertex != 0)
- qWarning() << "glDrawElementsInstancedBaseVertex is not supported with OpenGL ES 3";
-
- m_extraFuncs->glDrawElementsInstanced(primitiveType,
- primitiveCount,
- indexType,
- indices,
- instances);
-}
-
-void GraphicsHelperES3::vertexAttribDivisor(GLuint index, GLuint divisor)
-{
- m_extraFuncs->glVertexAttribDivisor(index, divisor);
-}
-
-void GraphicsHelperES3::vertexAttributePointer(GLenum shaderDataType,
- GLuint index,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const GLvoid *pointer)
-{
- switch (shaderDataType) {
- case GL_FLOAT:
- case GL_FLOAT_VEC2:
- case GL_FLOAT_VEC3:
- case GL_FLOAT_VEC4:
- case GL_FLOAT_MAT2:
- case GL_FLOAT_MAT2x3:
- case GL_FLOAT_MAT2x4:
- case GL_FLOAT_MAT3:
- case GL_FLOAT_MAT3x2:
- case GL_FLOAT_MAT3x4:
- case GL_FLOAT_MAT4x2:
- case GL_FLOAT_MAT4x3:
- case GL_FLOAT_MAT4:
- m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer);
- break;
-
- case GL_INT:
- case GL_INT_VEC2:
- case GL_INT_VEC3:
- case GL_INT_VEC4:
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_INT_VEC2:
- case GL_UNSIGNED_INT_VEC3:
- case GL_UNSIGNED_INT_VEC4:
- m_extraFuncs->glVertexAttribIPointer(index, size, type, stride, pointer);
- break;
-
- default:
- qCWarning(Rendering) << "vertexAttribPointer: Unhandled type";
- Q_UNREACHABLE();
- }
-}
-
-void GraphicsHelperES3::drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances)
-{
- m_extraFuncs->glDrawArraysInstanced(primitiveType,
- first,
- count,
- instances);
-}
-
-void GraphicsHelperES3::readBuffer(GLenum mode)
-{
- m_extraFuncs->glReadBuffer(mode);
-}
-
-void GraphicsHelperES3::drawBuffer(GLenum mode)
-{
- Q_UNUSED(mode);
- qWarning() << "glDrawBuffer is not supported with OpenGL ES 3";
-}
-
-void GraphicsHelperES3::bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment)
-{
- GLenum attr = GL_COLOR_ATTACHMENT0;
-
- if (attachment.m_point <= QRenderTargetOutput::Color15)
- attr = GL_COLOR_ATTACHMENT0 + attachment.m_point;
- else if (attachment.m_point == QRenderTargetOutput::Depth)
- attr = GL_DEPTH_ATTACHMENT;
- else if (attachment.m_point == QRenderTargetOutput::Stencil)
- attr = GL_STENCIL_ATTACHMENT;
- else
- qCritical() << "Unsupported FBO attachment OpenGL ES 3.0";
-
- const QOpenGLTexture::Target target = texture->target();
-
- if (target == QOpenGLTexture::TargetCubeMap && attachment.m_face == QAbstractTexture::AllFaces) {
- qWarning() << "OpenGL ES 3.0 doesn't handle attaching all the faces of a cube map texture at once to an FBO";
- return;
- }
-
- texture->bind();
- if (target == QOpenGLTexture::Target2D)
- m_funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, attr, target, texture->textureId(), attachment.m_mipLevel);
- else if (target == QOpenGLTexture::TargetCubeMap)
- m_funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel);
- else
- qCritical() << "Unsupported Texture FBO attachment format";
- texture->release();
-}
-
-void GraphicsHelperES3::bindFrameBufferObject(GLuint frameBufferId, GraphicsHelperInterface::FBOBindMode mode)
-{
- switch (mode) {
- case FBODraw:
- m_funcs->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferId);
- return;
- case FBORead:
- m_funcs->glBindFramebuffer(GL_READ_FRAMEBUFFER, frameBufferId);
- return;
- case FBOReadAndDraw:
- default:
- m_funcs->glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
- return;
- }
-}
-
-bool GraphicsHelperES3::supportsFeature(GraphicsHelperInterface::Feature feature) const
-{
- switch (feature) {
- case RenderBufferDimensionRetrieval:
- case MRT:
- case BlitFramebuffer:
- case UniformBufferObject:
- case MapBuffer:
- case Fences:
- return true;
- default:
- return false;
- }
-}
-
-void GraphicsHelperES3::drawBuffers(GLsizei n, const int *bufs)
-{
- QVarLengthArray<GLenum, 16> drawBufs(n);
-
- for (int i = 0; i < n; i++)
- drawBufs[i] = GL_COLOR_ATTACHMENT0 + bufs[i];
- m_extraFuncs->glDrawBuffers(n, drawBufs.constData());
-}
-
-UniformType GraphicsHelperES3::uniformTypeFromGLType(GLenum glType)
-{
- switch (glType) {
- case GL_SAMPLER_3D:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- return UniformType::Sampler;
- default:
- return GraphicsHelperES2::uniformTypeFromGLType(glType);
- }
-}
-
-uint GraphicsHelperES3::uniformByteSize(const ShaderUniform &description)
-{
- uint rawByteSize = 0;
- int arrayStride = qMax(description.m_arrayStride, 0);
- int matrixStride = qMax(description.m_matrixStride, 0);
-
- switch (description.m_type) {
-
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- case GL_UNSIGNED_INT_VEC2:
- rawByteSize = 8;
- break;
-
- case GL_FLOAT_VEC3:
- case GL_INT_VEC3:
- case GL_UNSIGNED_INT_VEC3:
- rawByteSize = 12;
- break;
-
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- case GL_UNSIGNED_INT_VEC4:
- rawByteSize = 16;
- break;
-
- case GL_FLOAT_MAT2:
- rawByteSize = matrixStride ? 2 * matrixStride : 16;
- break;
-
- case GL_FLOAT_MAT2x4:
- rawByteSize = matrixStride ? 2 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT4x2:
- rawByteSize = matrixStride ? 4 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT3:
- rawByteSize = matrixStride ? 3 * matrixStride : 36;
- break;
-
- case GL_FLOAT_MAT2x3:
- rawByteSize = matrixStride ? 2 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT3x2:
- rawByteSize = matrixStride ? 3 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT4:
- rawByteSize = matrixStride ? 4 * matrixStride : 64;
- break;
-
- case GL_FLOAT_MAT4x3:
- rawByteSize = matrixStride ? 4 * matrixStride : 48;
- break;
-
- case GL_FLOAT_MAT3x4:
- rawByteSize = matrixStride ? 3 * matrixStride : 48;
- break;
-
- case GL_BOOL:
- rawByteSize = 1;
- break;
-
- case GL_BOOL_VEC2:
- rawByteSize = 2;
- break;
-
- case GL_BOOL_VEC3:
- rawByteSize = 3;
- break;
-
- case GL_BOOL_VEC4:
- rawByteSize = 4;
- break;
-
- case GL_INT:
- case GL_FLOAT:
- case GL_UNSIGNED_INT:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_CUBE:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- rawByteSize = 4;
- break;
- }
-
- return arrayStride ? rawByteSize * arrayStride : rawByteSize;
-}
-
-void *GraphicsHelperES3::fenceSync()
-{
- return m_extraFuncs->glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
-}
-
-void GraphicsHelperES3::clientWaitSync(void *sync, GLuint64 nanoSecTimeout)
-{
- m_extraFuncs->glClientWaitSync(static_cast<GLsync>(sync), GL_SYNC_FLUSH_COMMANDS_BIT, nanoSecTimeout);
-}
-
-void GraphicsHelperES3::waitSync(void *sync)
-{
- m_extraFuncs->glWaitSync(static_cast<GLsync>(sync), 0, GL_TIMEOUT_IGNORED);
-}
-
-bool GraphicsHelperES3::wasSyncSignaled(void *sync)
-{
- GLint v;
- m_extraFuncs->glGetSynciv(static_cast<GLsync>(sync),
- GL_SYNC_STATUS,
- sizeof(v),
- nullptr,
- &v);
- return v == GL_SIGNALED;
-}
-
-void GraphicsHelperES3::deleteSync(void *sync)
-{
- m_extraFuncs->glDeleteSync(static_cast<GLsync>(sync));
-}
-
-void GraphicsHelperES3::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
-{
- m_extraFuncs->glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-}
-
-void GraphicsHelperES3::bindBufferBase(GLenum target, GLuint index, GLuint buffer)
-{
- m_extraFuncs->glBindBufferBase(target, index, buffer);
-}
-
-bool GraphicsHelperES3::frameBufferNeedsRenderBuffer(const Attachment &attachment)
-{
- // Use a renderbuffer for combined depth+stencil attachments since this is
- // problematic before GLES 3.2. Keep using textures for everything else.
- return attachment.m_point == QRenderTargetOutput::DepthStencil;
-}
-
-void GraphicsHelperES3::bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
-{
- m_extraFuncs->glUniformBlockBinding(programId, uniformBlockIndex, uniformBlockBinding);
-}
-
-void GraphicsHelperES3::buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer)
-{
- char *bufferData = buffer.data();
-
- switch (description.m_type) {
-
- case GL_FLOAT: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_FLOAT_VEC2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_FLOAT_VEC3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_FLOAT_VEC4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_FLOAT_MAT2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 4);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 2);
- break;
- }
-
- case GL_FLOAT_MAT2x3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 6);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 3);
- break;
- }
-
- case GL_FLOAT_MAT2x4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 8);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 4);
- break;
- }
-
- case GL_FLOAT_MAT3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 9);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 3);
- break;
- }
-
- case GL_FLOAT_MAT3x2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 6);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 2);
- break;
- }
-
- case GL_FLOAT_MAT3x4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 12);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 4);
- break;
- }
-
- case GL_FLOAT_MAT4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 16);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 4);
- break;
- }
-
- case GL_FLOAT_MAT4x2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 8);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 2);
- break;
- }
-
- case GL_FLOAT_MAT4x3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 12);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 3);
- break;
- }
-
- case GL_INT: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_INT_VEC2: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_INT_VEC3: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_INT_VEC4: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_UNSIGNED_INT: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC2: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC3: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC4: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_BOOL: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_BOOL_VEC2: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_BOOL_VEC3: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_BOOL_VEC4: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- // note: only GLES 3.0 supported types, not the same as OpenGL proper
- // (also, no MS samplers before ES 3.1)
- case GL_SAMPLER_2D:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_CUBE:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- {
- Q_ASSERT(description.m_size == 1);
- int value = v.toInt();
- QGraphicsUtils::fillDataArray<GLint>(bufferData, &value, description, 1);
- break;
- }
-
- default:
- qWarning() << Q_FUNC_INFO << "unsupported uniform type:" << description.m_type << "for " << description.m_name;
- break;
- }
-}
-
-char *GraphicsHelperES3::mapBuffer(GLenum target, GLsizeiptr size)
-{
- return static_cast<char*>(m_extraFuncs->glMapBufferRange(target, 0, size, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT));
-}
-
-GLboolean GraphicsHelperES3::unmapBuffer(GLenum target)
-{
- return m_extraFuncs->glUnmapBuffer(target);
-}
-
-QVector<ShaderUniform> GraphicsHelperES3::programUniformsAndLocations(GLuint programId)
-{
- QVector<ShaderUniform> uniforms;
-
- GLint nbrActiveUniforms = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_UNIFORMS, &nbrActiveUniforms);
- uniforms.reserve(nbrActiveUniforms);
- char uniformName[256];
- for (GLint i = 0; i < nbrActiveUniforms; i++) {
- ShaderUniform uniform;
- GLsizei uniformNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveUniform(programId, i, sizeof(uniformName) - 1, &uniformNameLength,
- &uniform.m_size, &uniform.m_type, uniformName);
- uniformName[sizeof(uniformName) - 1] = '\0';
- uniform.m_location = m_funcs->glGetUniformLocation(programId, uniformName);
- uniform.m_name = QString::fromUtf8(uniformName, uniformNameLength);
- m_extraFuncs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_BLOCK_INDEX, &uniform.m_blockIndex);
- m_extraFuncs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_OFFSET, &uniform.m_offset);
- m_extraFuncs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_ARRAY_STRIDE, &uniform.m_arrayStride);
- m_extraFuncs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_MATRIX_STRIDE, &uniform.m_matrixStride);
- uniform.m_rawByteSize = uniformByteSize(uniform);
- uniforms.append(uniform);
- qCDebug(Rendering) << uniform.m_name << "size" << uniform.m_size
- << " offset" << uniform.m_offset
- << " rawSize" << uniform.m_rawByteSize;
- }
-
- return uniforms;
-}
-
-QVector<ShaderUniformBlock> GraphicsHelperES3::programUniformBlocks(GLuint programId)
-{
- QVector<ShaderUniformBlock> blocks;
- GLint nbrActiveUniformsBlocks = 0;
- m_extraFuncs->glGetProgramiv(programId, GL_ACTIVE_UNIFORM_BLOCKS, &nbrActiveUniformsBlocks);
- blocks.reserve(nbrActiveUniformsBlocks);
- for (GLint i = 0; i < nbrActiveUniformsBlocks; i++) {
- QByteArray uniformBlockName(256, '\0');
- GLsizei length = 0;
- ShaderUniformBlock uniformBlock;
- m_extraFuncs->glGetActiveUniformBlockName(programId, i, 256, &length, uniformBlockName.data());
- uniformBlock.m_name = QString::fromUtf8(uniformBlockName.left(length));
- uniformBlock.m_index = i;
- m_extraFuncs->glGetActiveUniformBlockiv(programId, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &uniformBlock.m_activeUniformsCount);
- m_extraFuncs->glGetActiveUniformBlockiv(programId, i, GL_UNIFORM_BLOCK_BINDING, &uniformBlock.m_binding);
- m_extraFuncs->glGetActiveUniformBlockiv(programId, i, GL_UNIFORM_BLOCK_DATA_SIZE, &uniformBlock.m_size);
- blocks.append(uniformBlock);
- }
- return blocks;
-}
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_1.cpp b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_1.cpp
deleted file mode 100644
index f2f5b7b0c..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_1.cpp
+++ /dev/null
@@ -1,369 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: http://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$
-**
-****************************************************************************/
-
-#include "graphicshelperes3_1_p.h"
-#include <qgraphicsutils_p.h>
-#include <QOpenGLExtraFunctions>
-
-QT_BEGIN_NAMESPACE
-
-// ES 3.1+
-#ifndef GL_SAMPLER_2D_MULTISAMPLE
-#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
-#endif
-#ifndef GL_INT_SAMPLER_2D_MULTISAMPLE
-#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
-#endif
-#ifndef GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
-#endif
-#ifndef GL_ACTIVE_RESOURCES
-#define GL_ACTIVE_RESOURCES 0x92F5
-#endif
-#ifndef GL_BUFFER_BINDING
-#define GL_BUFFER_BINDING 0x9302
-#endif
-#ifndef GL_BUFFER_DATA_SIZE
-#define GL_BUFFER_DATA_SIZE 0x9303
-#endif
-#ifndef GL_NUM_ACTIVE_VARIABLES
-#define GL_NUM_ACTIVE_VARIABLES 0x9304
-#endif
-#ifndef GL_SHADER_STORAGE_BLOCK
-#define GL_SHADER_STORAGE_BLOCK 0x92E6
-#endif
-#ifndef GL_ALL_BARRIER_BITS
-#define GL_ALL_BARRIER_BITS 0xFFFFFFFF
-#endif
-#ifndef GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT
-#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
-#endif
-#ifndef GL_ELEMENT_ARRAY_BARRIER_BIT
-#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002
-#endif
-#ifndef GL_UNIFORM_BARRIER_BIT
-#define GL_UNIFORM_BARRIER_BIT 0x00000004
-#endif
-#ifndef GL_TEXTURE_FETCH_BARRIER_BIT
-#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008
-#endif
-#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
-#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
-#endif
-#ifndef GL_COMMAND_BARRIER_BIT
-#define GL_COMMAND_BARRIER_BIT 0x00000040
-#endif
-#ifndef GL_PIXEL_BUFFER_BARRIER_BIT
-#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080
-#endif
-#ifndef GL_TEXTURE_UPDATE_BARRIER_BIT
-#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100
-#endif
-#ifndef GL_BUFFER_UPDATE_BARRIER_BIT
-#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200
-#endif
-#ifndef GL_FRAMEBUFFER_BARRIER_BIT
-#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400
-#endif
-#ifndef GL_TRANSFORM_FEEDBACK_BARRIER_BIT
-#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
-#endif
-#ifndef GL_ATOMIC_COUNTER_BARRIER_BIT
-#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000
-#endif
-#ifndef GL_SHADER_STORAGE_BARRIER_BIT
-#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000
-#endif
-#ifndef GL_IMAGE_2D
-#define GL_IMAGE_2D 0x904D
-#endif
-#ifndef GL_IMAGE_3D
-#define GL_IMAGE_3D 0x904E
-#endif
-#ifndef GL_IMAGE_CUBE
-#define GL_IMAGE_CUBE 0x9050
-#endif
-#ifndef GL_IMAGE_2D_ARRAY
-#define GL_IMAGE_2D_ARRAY 0x9053
-#endif
-#ifndef GL_INT_IMAGE_2D
-#define GL_INT_IMAGE_2D 0x9058
-#endif
-#ifndef GL_INT_IMAGE_3D
-#define GL_INT_IMAGE_3D 0x9059
-#endif
-#ifndef GL_INT_IMAGE_CUBE
-#define GL_INT_IMAGE_CUBE 0x905B
-#endif
-#ifndef GL_INT_IMAGE_2D_ARRAY
-#define GL_INT_IMAGE_2D_ARRAY 0x905E
-#endif
-#ifndef GL_UNSIGNED_INT_IMAGE_2D
-#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
-#endif
-#ifndef GL_UNSIGNED_INT_IMAGE_3D
-#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
-#endif
-#ifndef GL_UNSIGNED_INT_IMAGE_CUBE
-#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
-#endif
-#ifndef GL_UNSIGNED_INT_IMAGE_2D_ARRAY
-#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
-#endif
-
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-namespace {
-
-GLbitfield memoryBarrierGLBitfield(QMemoryBarrier::Operations barriers)
-{
- GLbitfield bits = 0;
-
- if (barriers.testFlag(QMemoryBarrier::All)) {
- bits |= GL_ALL_BARRIER_BITS;
- return bits;
- }
-
- if (barriers.testFlag(QMemoryBarrier::VertexAttributeArray))
- bits |= GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::ElementArray))
- bits |= GL_ELEMENT_ARRAY_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::Uniform))
- bits |= GL_UNIFORM_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::TextureFetch))
- bits |= GL_TEXTURE_FETCH_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::ShaderImageAccess))
- bits |= GL_SHADER_IMAGE_ACCESS_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::Command))
- bits |= GL_COMMAND_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::PixelBuffer))
- bits |= GL_PIXEL_BUFFER_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::TextureUpdate))
- bits |= GL_TEXTURE_UPDATE_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::BufferUpdate))
- bits |= GL_BUFFER_UPDATE_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::FrameBuffer))
- bits |= GL_FRAMEBUFFER_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::TransformFeedback))
- bits |= GL_TRANSFORM_FEEDBACK_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::AtomicCounter))
- bits |= GL_ATOMIC_COUNTER_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::ShaderStorage))
- bits |= GL_SHADER_STORAGE_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::QueryBuffer))
- qWarning() << "QueryBuffer barrier not supported by ES 3.1";
-
- return bits;
-}
-
-} // anonymous
-
-
-GraphicsHelperES3_1::GraphicsHelperES3_1()
-{
-}
-
-GraphicsHelperES3_1::~GraphicsHelperES3_1()
-{
-}
-
-bool GraphicsHelperES3_1::supportsFeature(GraphicsHelperInterface::Feature feature) const
-{
- switch (feature) {
- case GraphicsHelperInterface::Compute:
- case GraphicsHelperInterface::ShaderStorageObject:
- case GraphicsHelperInterface::IndirectDrawing:
- case GraphicsHelperInterface::ShaderImage:
- return true;
- default:
- break;
- }
- return GraphicsHelperES3::supportsFeature(feature);
-}
-
-void GraphicsHelperES3_1::bindImageTexture(GLuint imageUnit, GLuint texture,
- GLint mipLevel, GLboolean layered,
- GLint layer, GLenum access, GLenum format)
-{
- m_extraFuncs->glBindImageTexture(imageUnit,
- texture,
- mipLevel,
- layered,
- layer,
- access,
- format);
-}
-
-void GraphicsHelperES3_1::dispatchCompute(GLuint wx, GLuint wy, GLuint wz)
-{
- m_extraFuncs->glDispatchCompute(wx, wy, wz);
-}
-
-void GraphicsHelperES3_1::memoryBarrier(QMemoryBarrier::Operations barriers)
-{
- m_extraFuncs->glMemoryBarrier(memoryBarrierGLBitfield(barriers));
-}
-
-void GraphicsHelperES3_1::drawArraysIndirect(GLenum mode, void *indirect)
-{
- m_extraFuncs->glDrawArraysIndirect(mode, indirect);
-}
-
-void GraphicsHelperES3_1::drawElementsIndirect(GLenum mode, GLenum type, void *indirect)
-{
- m_extraFuncs->glDrawElementsIndirect(mode, type, indirect);
-}
-
-void GraphicsHelperES3_1::bindShaderStorageBlock(GLuint , GLuint , GLuint )
-{
- // ES 3.1 has no API for that, bindings have to be specified directly in the shader
- // with layout(std430, binding = 3)
- qWarning() << "ES 3.1 has no bindShaderStorageBlock API, it uses binding declaration from the shader storage block";
-}
-
-QVector<ShaderStorageBlock> GraphicsHelperES3_1::programShaderStorageBlocks(GLuint programId)
-{
- QVector<ShaderStorageBlock> blocks;
- GLint nbrActiveShaderStorageBlocks = 0;
- m_extraFuncs->glGetProgramInterfaceiv(programId, GL_SHADER_STORAGE_BLOCK, GL_ACTIVE_RESOURCES, &nbrActiveShaderStorageBlocks);
- blocks.reserve(nbrActiveShaderStorageBlocks);
- for (GLint i = 0; i < nbrActiveShaderStorageBlocks; ++i) {
- QByteArray storageBlockName(256, '\0');
- GLsizei length = 0;
- ShaderStorageBlock storageBlock;
- m_extraFuncs->glGetProgramResourceName(programId, GL_SHADER_STORAGE_BLOCK, i, 256, &length, storageBlockName.data());
- storageBlock.m_index = i;
- storageBlock.m_name = QString::fromUtf8(storageBlockName.left(length));
- GLenum prop = GL_BUFFER_BINDING;
- m_extraFuncs->glGetProgramResourceiv(programId, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 4, NULL, &storageBlock.m_binding);
- prop = GL_BUFFER_DATA_SIZE;
- m_extraFuncs->glGetProgramResourceiv(programId, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 4, NULL, &storageBlock.m_size);
- prop = GL_NUM_ACTIVE_VARIABLES;
- m_extraFuncs->glGetProgramResourceiv(programId, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 4, NULL, &storageBlock.m_activeVariablesCount);
- blocks.push_back(storageBlock);
- }
- return blocks;
-}
-
-UniformType GraphicsHelperES3_1::uniformTypeFromGLType(GLenum glType)
-{
- switch (glType) {
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- return UniformType::Sampler;
- case GL_IMAGE_2D:
- case GL_IMAGE_3D:
- case GL_IMAGE_CUBE:
- case GL_IMAGE_2D_ARRAY:
- case GL_INT_IMAGE_2D:
- case GL_INT_IMAGE_3D:
- case GL_INT_IMAGE_CUBE:
- case GL_INT_IMAGE_2D_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_2D:
- case GL_UNSIGNED_INT_IMAGE_3D:
- case GL_UNSIGNED_INT_IMAGE_CUBE:
- case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
- return UniformType::Image;
-
- default:
- return GraphicsHelperES3::uniformTypeFromGLType(glType);
- }
-}
-
-uint GraphicsHelperES3_1::uniformByteSize(const ShaderUniform &description)
-{
- uint rawByteSize = 0;
-
- switch (description.m_type) {
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_IMAGE_2D:
- case GL_IMAGE_3D:
- case GL_IMAGE_CUBE:
- case GL_IMAGE_2D_ARRAY:
- case GL_INT_IMAGE_2D:
- case GL_INT_IMAGE_3D:
- case GL_INT_IMAGE_CUBE:
- case GL_INT_IMAGE_2D_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_2D:
- case GL_UNSIGNED_INT_IMAGE_3D:
- case GL_UNSIGNED_INT_IMAGE_CUBE:
- case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
- rawByteSize = 4;
- break;
-
- default:
- rawByteSize = GraphicsHelperES3::uniformByteSize(description);
- break;
- }
-
- return rawByteSize;
-}
-
-void GraphicsHelperES3_1::buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer)
-{
- char *bufferData = buffer.data();
-
- switch (description.m_type) {
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- {
- Q_ASSERT(description.m_size == 1);
- int value = v.toInt();
- QGraphicsUtils::fillDataArray<GLint>(bufferData, &value, description, 1);
- break;
- }
-
- default:
- GraphicsHelperES3::buildUniformBuffer(v, description, buffer);
- break;
- }
-}
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_1_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_1_p.h
deleted file mode 100644
index 68526fffc..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_1_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: http://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$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_RENDER_GRAPHICSHELPERES3_1_H
-#define QT3DRENDER_RENDER_GRAPHICSHELPERES3_1_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <graphicshelperes3_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-class GraphicsHelperES3_1 : public GraphicsHelperES3
-{
-public:
- GraphicsHelperES3_1();
- ~GraphicsHelperES3_1();
-
- bool supportsFeature(Feature feature) const override;
- void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) override;
- void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) override;
- void memoryBarrier(QMemoryBarrier::Operations barriers) override;
- void drawArraysIndirect(GLenum mode,void *indirect) override;
- void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) override;
- void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) override;
- QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) override;
-
- // QGraphicHelperInterface interface
- UniformType uniformTypeFromGLType(GLenum glType) override;
- uint uniformByteSize(const ShaderUniform &description) override;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) override;
-};
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // QT3DRENDER_RENDER_GRAPHICSHELPERES3_1_H
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_2.cpp b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_2.cpp
deleted file mode 100644
index face2e43e..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_2.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://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$
-**
-****************************************************************************/
-
-#include "graphicshelperes3_2_p.h"
-#include <QOpenGLExtraFunctions>
-#include <Qt3DRender/qrendertargetoutput.h>
-#include <private/attachmentpack_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef GL_DRAW_FRAMEBUFFER
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#endif
-
-#ifndef GL_DEPTH_STENCIL_ATTACHMENT
-#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
-#endif
-
-#ifndef GL_PATCH_VERTICES
-#define GL_PATCH_VERTICES 36466
-#endif
-
-#ifndef GL_IMAGE_BUFFER
-#define GL_IMAGE_BUFFER 0x9051
-#endif
-#ifndef GL_IMAGE_CUBE_MAP_ARRAY
-#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
-#endif
-#ifndef GL_INT_IMAGE_BUFFER
-#define GL_INT_IMAGE_BUFFER 0x905C
-#endif
-#ifndef GL_INT_IMAGE_CUBE_MAP_ARRAY
-#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
-#endif
-#ifndef GL_UNSIGNED_INT_IMAGE_BUFFER
-#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
-#endif
-#ifndef GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY
-#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
-#endif
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-GraphicsHelperES3_2::GraphicsHelperES3_2()
-{
-}
-
-GraphicsHelperES3_2::~GraphicsHelperES3_2()
-{
-}
-
-bool GraphicsHelperES3_2::supportsFeature(GraphicsHelperInterface::Feature feature) const
-{
- switch (feature) {
- case GraphicsHelperInterface::Tessellation:
- return true;
- default:
- break;
- }
- return GraphicsHelperES3_1::supportsFeature(feature);
-}
-
-bool GraphicsHelperES3_2::frameBufferNeedsRenderBuffer(const Attachment &attachment)
-{
- Q_UNUSED(attachment);
- // This is first ES version where we have glFramebufferTexture, so
- // attaching a D24S8 texture to the combined depth-stencil attachment point
- // should work.
- return false;
-}
-
-void GraphicsHelperES3_2::bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment)
-{
- GLenum attr = GL_COLOR_ATTACHMENT0;
-
- if (attachment.m_point <= QRenderTargetOutput::Color15)
- attr = GL_COLOR_ATTACHMENT0 + attachment.m_point;
- else if (attachment.m_point == QRenderTargetOutput::Depth)
- attr = GL_DEPTH_ATTACHMENT;
- else if (attachment.m_point == QRenderTargetOutput::Stencil)
- attr = GL_STENCIL_ATTACHMENT;
- else if (attachment.m_point == QRenderTargetOutput::DepthStencil)
- attr = GL_DEPTH_STENCIL_ATTACHMENT;
- else
- qCritical() << "Unsupported FBO attachment OpenGL ES 3.2";
-
- const QOpenGLTexture::Target target = texture->target();
-
- texture->bind();
- if (target == QOpenGLTexture::TargetCubeMap && attachment.m_face != QAbstractTexture::AllFaces)
- m_funcs->glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel);
- else
- m_extraFuncs->glFramebufferTexture(GL_DRAW_FRAMEBUFFER, attr, texture->textureId(), attachment.m_mipLevel);
- texture->release();
-}
-
-void GraphicsHelperES3_2::setVerticesPerPatch(GLint verticesPerPatch)
-{
- m_extraFuncs->glPatchParameteri(GL_PATCH_VERTICES, verticesPerPatch);
-}
-
-void GraphicsHelperES3_2::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex, GLint baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2";
-
- m_extraFuncs->glDrawElementsInstancedBaseVertex(primitiveType,
- primitiveCount,
- indexType,
- indices,
- instances,
- baseVertex);
-}
-
-UniformType GraphicsHelperES3_2::uniformTypeFromGLType(GLenum glType)
-{
- switch (glType) {
- case GL_IMAGE_BUFFER:
- case GL_IMAGE_CUBE_MAP_ARRAY:
- case GL_INT_IMAGE_BUFFER:
- case GL_INT_IMAGE_CUBE_MAP_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_BUFFER:
- case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
- return UniformType::Image;
-
- default:
- return GraphicsHelperES3_1::uniformTypeFromGLType(glType);
- }
-}
-
-uint GraphicsHelperES3_2::uniformByteSize(const ShaderUniform &description)
-{
- uint rawByteSize = 0;
-
- switch (description.m_type) {
- case GL_IMAGE_BUFFER:
- case GL_IMAGE_CUBE_MAP_ARRAY:
- case GL_INT_IMAGE_BUFFER:
- case GL_INT_IMAGE_CUBE_MAP_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_BUFFER:
- case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
- rawByteSize = 4;
- break;
-
- default:
- rawByteSize = GraphicsHelperES3_1::uniformByteSize(description);
- break;
- }
-
- return rawByteSize;
-}
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_2_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_2_p.h
deleted file mode 100644
index 36f0d0cab..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_2_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://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$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_RENDER_RHI_GRAPHICSHELPERES3_2_H
-#define QT3DRENDER_RENDER_RHI_GRAPHICSHELPERES3_2_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <graphicshelperes3_1_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-class GraphicsHelperES3_2 : public GraphicsHelperES3_1
-{
-public:
- GraphicsHelperES3_2();
- ~GraphicsHelperES3_2();
-
- bool supportsFeature(Feature feature) const override;
-
- // QGraphicHelperInterface interface
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) override;
- bool frameBufferNeedsRenderBuffer(const Attachment &attachment) override;
- void setVerticesPerPatch(GLint verticesPerPatch) override;
- void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) override;
- UniformType uniformTypeFromGLType(GLenum glType) override;
- uint uniformByteSize(const ShaderUniform &description) override;
-
-};
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // QT3DRENDER_RENDER_RHI_GRAPHICSHELPERES3_2_H
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_p.h
deleted file mode 100644
index b816b43db..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperes3_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 Svenn-Arne Dragly.
-** 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$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_RENDER_RHI_GRAPHICSHELPERES3_H
-#define QT3DRENDER_RENDER_RHI_GRAPHICSHELPERES3_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <graphicshelperes2_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-class GraphicsHelperES3 : public GraphicsHelperES2
-{
-public:
- GraphicsHelperES3();
- ~GraphicsHelperES3();
-
- // QGraphicHelperInterface interface
- void bindBufferBase(GLenum target, GLuint index, GLuint buffer) override;
- bool frameBufferNeedsRenderBuffer(const Attachment &attachment) override;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) override;
- void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) override;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override;
- void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) override;
- void drawBuffers(GLsizei n, const int *bufs) override;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) override;
- void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) override;
- void readBuffer(GLenum mode) override;
- void drawBuffer(GLenum mode) override;
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) override;
- char *mapBuffer(GLenum target, GLsizeiptr size) override;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) override;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) override;
- bool supportsFeature(Feature feature) const override;
- GLboolean unmapBuffer(GLenum target) override;
- void vertexAttribDivisor(GLuint index, GLuint divisor) override;
- void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) override;
-
- UniformType uniformTypeFromGLType(GLenum glType) override;
- uint uniformByteSize(const ShaderUniform &description) override;
-
- void *fenceSync() override;
- void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
- void waitSync(void *sync) override;
- bool wasSyncSignaled(void *sync) override;
- void deleteSync(void *sync) override;
-
-protected:
- QOpenGLExtraFunctions *m_extraFuncs = nullptr;
-};
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // QT3DRENDER_RENDER_RHI_GRAPHICSHELPERES3_H
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl2.cpp b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl2.cpp
deleted file mode 100644
index 6ee08d0df..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl2.cpp
+++ /dev/null
@@ -1,937 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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$
-**
-****************************************************************************/
-
-#include "graphicshelpergl2_p.h"
-#ifndef QT_OPENGL_ES_2
-#include <QOpenGLFunctions_2_0>
-#include <private/attachmentpack_p.h>
-#include <QtOpenGLExtensions/QOpenGLExtensions>
-#include <qgraphicsutils_p.h>
-#include <logging_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-GraphicsHelperGL2::GraphicsHelperGL2()
- : m_funcs(nullptr)
- , m_fboFuncs(nullptr)
-{
-
-}
-
-void GraphicsHelperGL2::initializeHelper(QOpenGLContext *context,
- QAbstractOpenGLFunctions *functions)
-{
- Q_UNUSED(context);
- m_funcs = static_cast<QOpenGLFunctions_2_0*>(functions);
- const bool ok = m_funcs->initializeOpenGLFunctions();
- Q_ASSERT(ok);
- Q_UNUSED(ok);
- if (context->hasExtension(QByteArrayLiteral("GL_ARB_framebuffer_object"))) {
- m_fboFuncs = new QOpenGLExtension_ARB_framebuffer_object();
- const bool extensionOk = m_fboFuncs->initializeOpenGLFunctions();
- Q_ASSERT(extensionOk);
- Q_UNUSED(extensionOk);
- }
-}
-
-void GraphicsHelperGL2::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2";
-
- if (baseVertex != 0)
- qWarning() << "glDrawElementsInstancedBaseVertex is not supported with OpenGL ES 2";
-
- for (GLint i = 0; i < instances; i++)
- drawElements(primitiveType,
- primitiveCount,
- indexType,
- indices);
-}
-
-void GraphicsHelperGL2::drawArraysInstanced(GLenum primitiveType,
- GLint first,
- GLsizei count,
- GLsizei instances)
-{
- for (GLint i = 0; i < instances; i++)
- drawArrays(primitiveType,
- first,
- count);
-}
-
-void GraphicsHelperGL2::drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawArraysInstancedBaseInstance is not supported with OpenGL 2";
- for (GLint i = 0; i < instances; i++)
- drawArrays(primitiveType,
- first,
- count);
-}
-
-void GraphicsHelperGL2::drawElements(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLint baseVertex)
-{
- if (baseVertex != 0)
- qWarning() << "glDrawElementsBaseVertex is not supported with OpenGL 2";
-
- m_funcs->glDrawElements(primitiveType,
- primitiveCount,
- indexType,
- indices);
-}
-
-void GraphicsHelperGL2::drawArrays(GLenum primitiveType,
- GLint first,
- GLsizei count)
-{
- m_funcs->glDrawArrays(primitiveType,
- first,
- count);
-}
-
-void GraphicsHelperGL2::drawElementsIndirect(GLenum, GLenum, void *)
-{
- qWarning() << "Indirect Drawing is not supported with OpenGL 2";
-}
-
-void GraphicsHelperGL2::drawArraysIndirect(GLenum , void *)
-{
- qWarning() << "Indirect Drawing is not supported with OpenGL 2";
-}
-
-void GraphicsHelperGL2::setVerticesPerPatch(GLint verticesPerPatch)
-{
- Q_UNUSED(verticesPerPatch);
- qWarning() << "Tessellation not supported with OpenGL 2";
-}
-
-void GraphicsHelperGL2::useProgram(GLuint programId)
-{
- m_funcs->glUseProgram(programId);
-}
-
-QVector<ShaderUniform> GraphicsHelperGL2::programUniformsAndLocations(GLuint programId)
-{
- QVector<ShaderUniform> uniforms;
-
- GLint nbrActiveUniforms = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_UNIFORMS, &nbrActiveUniforms);
- uniforms.reserve(nbrActiveUniforms);
- char uniformName[256];
- for (GLint i = 0; i < nbrActiveUniforms; i++) {
- ShaderUniform uniform;
- GLsizei uniformNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveUniform(programId, i, sizeof(uniformName) - 1, &uniformNameLength,
- &uniform.m_size, &uniform.m_type, uniformName);
- uniformName[sizeof(uniformName) - 1] = '\0';
- uniform.m_location = m_funcs->glGetUniformLocation(programId, uniformName);
- uniform.m_name = QString::fromUtf8(uniformName, uniformNameLength);
- // Work around for uniform array names that aren't returned with [0] by some drivers
- if (uniform.m_size > 1 && !uniform.m_name.endsWith(QLatin1String("[0]")))
- uniform.m_name.append(QLatin1String("[0]"));
- uniform.m_rawByteSize = uniformByteSize(uniform);
- uniforms.append(uniform);
- }
- return uniforms;
-}
-
-QVector<ShaderAttribute> GraphicsHelperGL2::programAttributesAndLocations(GLuint programId)
-{
- QVector<ShaderAttribute> attributes;
- GLint nbrActiveAttributes = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_ATTRIBUTES, &nbrActiveAttributes);
- attributes.reserve(nbrActiveAttributes);
- char attributeName[256];
- for (GLint i = 0; i < nbrActiveAttributes; i++) {
- ShaderAttribute attribute;
- GLsizei attributeNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveAttrib(programId, i, sizeof(attributeName) - 1, &attributeNameLength,
- &attribute.m_size, &attribute.m_type, attributeName);
- attributeName[sizeof(attributeName) - 1] = '\0';
- attribute.m_location = m_funcs->glGetAttribLocation(programId, attributeName);
- attribute.m_name = QString::fromUtf8(attributeName, attributeNameLength);
- attributes.append(attribute);
- }
- return attributes;
-}
-
-QVector<ShaderUniformBlock> GraphicsHelperGL2::programUniformBlocks(GLuint programId)
-{
- Q_UNUSED(programId);
- QVector<ShaderUniformBlock> blocks;
- qWarning() << "UBO are not supported by OpenGL 2.0 (since OpenGL 3.1)";
- return blocks;
-}
-
-QVector<ShaderStorageBlock> GraphicsHelperGL2::programShaderStorageBlocks(GLuint programId)
-{
- Q_UNUSED(programId);
- qWarning() << "SSBO are not supported by OpenGL 2.0 (since OpenGL 4.3)";
- return QVector<ShaderStorageBlock>();
-}
-
-void GraphicsHelperGL2::vertexAttribDivisor(GLuint index,
- GLuint divisor)
-{
- Q_UNUSED(index);
- Q_UNUSED(divisor);
-}
-
-void GraphicsHelperGL2::vertexAttributePointer(GLenum shaderDataType,
- GLuint index,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const GLvoid *pointer)
-{
- switch (shaderDataType) {
- case GL_FLOAT:
- case GL_FLOAT_VEC2:
- case GL_FLOAT_VEC3:
- case GL_FLOAT_VEC4:
- case GL_FLOAT_MAT2:
- case GL_FLOAT_MAT2x3:
- case GL_FLOAT_MAT2x4:
- case GL_FLOAT_MAT3:
- case GL_FLOAT_MAT3x2:
- case GL_FLOAT_MAT3x4:
- case GL_FLOAT_MAT4x2:
- case GL_FLOAT_MAT4x3:
- case GL_FLOAT_MAT4:
- m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer);
- break;
-
- default:
- qCWarning(Rendering) << "vertexAttribPointer: Unhandled type";
- Q_UNREACHABLE();
- }
-}
-
-void GraphicsHelperGL2::readBuffer(GLenum mode)
-{
- m_funcs->glReadBuffer(mode);
-}
-
-void GraphicsHelperGL2::drawBuffer(GLenum mode)
-{
- m_funcs->glDrawBuffer(mode);
-}
-
-void *GraphicsHelperGL2::fenceSync()
-{
- qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
- return nullptr;
-}
-
-void GraphicsHelperGL2::clientWaitSync(void *, GLuint64 )
-{
- qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
-}
-
-void GraphicsHelperGL2::waitSync(void *)
-{
- qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
-}
-
-bool GraphicsHelperGL2::wasSyncSignaled(void *)
-{
- qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
- return false;
-}
-
-void GraphicsHelperGL2::deleteSync(void *)
-{
- qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
-}
-
-void GraphicsHelperGL2::rasterMode(GLenum faceMode, GLenum rasterMode)
-{
- m_funcs->glPolygonMode(faceMode, rasterMode);
-}
-
-void GraphicsHelperGL2::blendEquation(GLenum mode)
-{
- m_funcs->glBlendEquation(mode);
-}
-
-void GraphicsHelperGL2::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
-{
- Q_UNUSED(buf);
- Q_UNUSED(sfactor);
- Q_UNUSED(dfactor);
-
- qWarning() << "glBlendFunci() not supported by OpenGL 2.0 (since OpenGL 4.0)";
-}
-
-void GraphicsHelperGL2::blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha)
-{
- Q_UNUSED(buf);
- Q_UNUSED(sRGB);
- Q_UNUSED(dRGB);
- Q_UNUSED(sAlpha);
- Q_UNUSED(dAlpha);
-
- qWarning() << "glBlendFuncSeparatei() not supported by OpenGL 2.0 (since OpenGL 4.0)";
-}
-
-void GraphicsHelperGL2::alphaTest(GLenum mode1, GLenum mode2)
-{
- m_funcs->glEnable(GL_ALPHA_TEST);
- m_funcs->glAlphaFunc(mode1, mode2);
-}
-
-void GraphicsHelperGL2::depthTest(GLenum mode)
-{
- m_funcs->glEnable(GL_DEPTH_TEST);
- m_funcs->glDepthFunc(mode);
-}
-
-void GraphicsHelperGL2::depthMask(GLenum mode)
-{
- m_funcs->glDepthMask(mode);
-}
-
-void GraphicsHelperGL2::depthRange(GLdouble nearValue, GLdouble farValue)
-{
- m_funcs->glDepthRange(nearValue, farValue);
-}
-
-void GraphicsHelperGL2::frontFace(GLenum mode)
-{
- m_funcs->glFrontFace(mode);
-}
-
-void GraphicsHelperGL2::setMSAAEnabled(bool enabled)
-{
- enabled ? m_funcs->glEnable(GL_MULTISAMPLE)
- : m_funcs->glDisable(GL_MULTISAMPLE);
-}
-
-void GraphicsHelperGL2::setAlphaCoverageEnabled(bool enabled)
-{
- enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
- : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-GLuint GraphicsHelperGL2::createFrameBufferObject()
-{
- if (m_fboFuncs != nullptr) {
- GLuint id;
- m_fboFuncs->glGenFramebuffers(1, &id);
- return id;
- }
- qWarning() << "FBO not supported by your OpenGL hardware";
- return 0;
-}
-
-void GraphicsHelperGL2::releaseFrameBufferObject(GLuint frameBufferId)
-{
- if (m_fboFuncs != nullptr)
- m_fboFuncs->glDeleteFramebuffers(1, &frameBufferId);
- else
- qWarning() << "FBO not supported by your OpenGL hardware";
-}
-
-bool GraphicsHelperGL2::checkFrameBufferComplete()
-{
- if (m_fboFuncs != nullptr)
- return (m_fboFuncs->glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
- return false;
-}
-
-bool GraphicsHelperGL2::frameBufferNeedsRenderBuffer(const Attachment &attachment)
-{
- Q_UNUSED(attachment);
- return false;
-}
-
-void GraphicsHelperGL2::bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment)
-{
- if (m_fboFuncs != nullptr) {
- GLenum attr = GL_DEPTH_STENCIL_ATTACHMENT;
-
- if (attachment.m_point <= QRenderTargetOutput::Color15)
- attr = GL_COLOR_ATTACHMENT0 + attachment.m_point;
- else if (attachment.m_point == QRenderTargetOutput::Depth)
- attr = GL_DEPTH_ATTACHMENT;
- else if (attachment.m_point == QRenderTargetOutput::Stencil)
- attr = GL_STENCIL_ATTACHMENT;
- else
- qCritical() << "DepthStencil Attachment not supported on OpenGL 2.0";
-
- const QOpenGLTexture::Target target = texture->target();
-
- if (target == QOpenGLTexture::TargetCubeMap && attachment.m_face == QAbstractTexture::AllFaces) {
- qWarning() << "OpenGL 2.0 doesn't handle attaching all the faces of a cube map texture at once to an FBO";
- return;
- }
-
- texture->bind();
- if (target == QOpenGLTexture::Target3D)
- m_fboFuncs->glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, attr, target, texture->textureId(), attachment.m_mipLevel, attachment.m_layer);
- else if (target == QOpenGLTexture::TargetCubeMap)
- m_fboFuncs->glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel);
- else if (target == QOpenGLTexture::Target1D)
- m_fboFuncs->glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, attr, target, texture->textureId(), attachment.m_mipLevel);
- else if (target == QOpenGLTexture::Target2D || target == QOpenGLTexture::TargetRectangle)
- m_fboFuncs->glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attr, target, texture->textureId(), attachment.m_mipLevel);
- else
- qCritical() << "Texture format not supported for Attachment on OpenGL 2.0";
- texture->release();
- }
-}
-
-void GraphicsHelperGL2::bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment)
-{
- Q_UNUSED(renderBuffer);
- Q_UNUSED(attachment);
- Q_UNREACHABLE();
-}
-
-bool GraphicsHelperGL2::supportsFeature(GraphicsHelperInterface::Feature feature) const
-{
- switch (feature) {
- case MRT:
- return (m_fboFuncs != nullptr);
- case TextureDimensionRetrieval:
- case MapBuffer:
- return true;
- default:
- return false;
- }
-}
-
-void GraphicsHelperGL2::drawBuffers(GLsizei n, const int *bufs)
-{
- QVarLengthArray<GLenum, 16> drawBufs(n);
-
- for (int i = 0; i < n; i++)
- drawBufs[i] = GL_COLOR_ATTACHMENT0 + bufs[i];
- m_funcs->glDrawBuffers(n, drawBufs.constData());
-}
-
-void GraphicsHelperGL2::bindFragDataLocation(GLuint, const QHash<QString, int> &)
-{
- qCritical() << "bindFragDataLocation is not supported by GL 2.0";
-}
-
-void GraphicsHelperGL2::bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode)
-{
- if (m_fboFuncs != nullptr) {
- switch (mode) {
- case FBODraw:
- m_fboFuncs->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferId);
- return;
- case FBORead:
- m_fboFuncs->glBindFramebuffer(GL_READ_FRAMEBUFFER, frameBufferId);
- return;
- case FBOReadAndDraw:
- default:
- m_fboFuncs->glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
- return;
- }
- } else {
- qWarning() << "FBO not supported by your OpenGL hardware";
- }
-}
-
-void GraphicsHelperGL2::bindImageTexture(GLuint imageUnit, GLuint texture,
- GLint mipLevel, GLboolean layered,
- GLint layer, GLenum access, GLenum format)
-{
- Q_UNUSED(imageUnit)
- Q_UNUSED(texture)
- Q_UNUSED(mipLevel)
- Q_UNUSED(layered)
- Q_UNUSED(layer)
- Q_UNUSED(access)
- Q_UNUSED(format)
- qWarning() << "Shader Images are not supported by OpenGL 2.0 (since OpenGL 4.2)";
-
-}
-
-GLuint GraphicsHelperGL2::boundFrameBufferObject()
-{
- GLint id = 0;
- m_funcs->glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &id);
- return id;
-}
-
-void GraphicsHelperGL2::bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
-{
- Q_UNUSED(programId);
- Q_UNUSED(uniformBlockIndex);
- Q_UNUSED(uniformBlockBinding);
- qWarning() << "UBO are not supported by OpenGL 2.0 (since OpenGL 3.1)";
-}
-
-void GraphicsHelperGL2::bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding)
-{
- Q_UNUSED(programId);
- Q_UNUSED(shaderStorageBlockIndex);
- Q_UNUSED(shaderStorageBlockBinding);
- qWarning() << "SSBO are not supported by OpenGL 2.0 (since OpenGL 4.3)";
-}
-
-void GraphicsHelperGL2::bindBufferBase(GLenum target, GLuint index, GLuint buffer)
-{
- Q_UNUSED(target);
- Q_UNUSED(index);
- Q_UNUSED(buffer);
- qWarning() << "bindBufferBase is not supported by OpenGL 2.0 (since OpenGL 3.0)";
-}
-
-void GraphicsHelperGL2::buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer)
-{
- Q_UNUSED(v);
- Q_UNUSED(description);
- Q_UNUSED(buffer);
- qWarning() << "UBO are not supported by OpenGL 2.0 (since OpenGL 3.1)";
-}
-
-uint GraphicsHelperGL2::uniformByteSize(const ShaderUniform &description)
-{
- uint rawByteSize = 0;
- int arrayStride = qMax(description.m_arrayStride, 0);
- int matrixStride = qMax(description.m_matrixStride, 0);
-
- switch (description.m_type) {
-
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- rawByteSize = 8;
- break;
-
- case GL_FLOAT_VEC3:
- case GL_INT_VEC3:
- rawByteSize = 12;
- break;
-
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- rawByteSize = 16;
- break;
-
- case GL_FLOAT_MAT2:
- rawByteSize = matrixStride ? 2 * matrixStride : 16;
- break;
-
- case GL_FLOAT_MAT2x4:
- rawByteSize = matrixStride ? 2 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT4x2:
- rawByteSize = matrixStride ? 4 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT3:
- rawByteSize = matrixStride ? 3 * matrixStride : 36;
- break;
-
- case GL_FLOAT_MAT2x3:
- rawByteSize = matrixStride ? 2 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT3x2:
- rawByteSize = matrixStride ? 3 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT4:
- rawByteSize = matrixStride ? 4 * matrixStride : 64;
- break;
-
- case GL_FLOAT_MAT4x3:
- rawByteSize = matrixStride ? 4 * matrixStride : 48;
- break;
-
- case GL_FLOAT_MAT3x4:
- rawByteSize = matrixStride ? 3 * matrixStride : 48;
- break;
-
- case GL_BOOL:
- rawByteSize = 1;
- break;
-
- case GL_BOOL_VEC2:
- rawByteSize = 2;
- break;
-
- case GL_BOOL_VEC3:
- rawByteSize = 3;
- break;
-
- case GL_BOOL_VEC4:
- rawByteSize = 4;
- break;
-
- case GL_INT:
- case GL_FLOAT:
- case GL_SAMPLER_1D:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_CUBE:
- rawByteSize = 4;
- break;
-
- default:
- Q_UNREACHABLE();
- }
-
- return arrayStride ? rawByteSize * arrayStride : rawByteSize;
-}
-
-void GraphicsHelperGL2::enableClipPlane(int clipPlane)
-{
- m_funcs->glEnable(GL_CLIP_DISTANCE0 + clipPlane);
-}
-
-void GraphicsHelperGL2::disableClipPlane(int clipPlane)
-{
- m_funcs->glDisable(GL_CLIP_DISTANCE0 + clipPlane);
-}
-
-void GraphicsHelperGL2::setClipPlane(int clipPlane, const QVector3D &normal, float distance)
-{
- double plane[4];
- plane[0] = normal.x();
- plane[1] = normal.y();
- plane[2] = normal.z();
- plane[3] = distance;
-
- m_funcs->glClipPlane(GL_CLIP_PLANE0 + clipPlane, plane);
-}
-
-GLint GraphicsHelperGL2::maxClipPlaneCount()
-{
- GLint max = 0;
- m_funcs->glGetIntegerv(GL_MAX_CLIP_DISTANCES, &max);
- return max;
-}
-
-void GraphicsHelperGL2::memoryBarrier(QMemoryBarrier::Operations barriers)
-{
- Q_UNUSED(barriers);
- qWarning() << "memory barrier is not supported by OpenGL 2.0 (since 4.3)";
-}
-
-void GraphicsHelperGL2::enablePrimitiveRestart(int)
-{
-}
-
-void GraphicsHelperGL2::enableVertexAttributeArray(int location)
-{
- m_funcs->glEnableVertexAttribArray(location);
-}
-
-void GraphicsHelperGL2::disablePrimitiveRestart()
-{
-}
-
-void GraphicsHelperGL2::clearBufferf(GLint drawbuffer, const QVector4D &values)
-{
- Q_UNUSED(drawbuffer);
- Q_UNUSED(values);
- qWarning() << "glClearBuffer*() not supported by OpenGL 2.0";
-}
-
-void GraphicsHelperGL2::pointSize(bool programmable, GLfloat value)
-{
- m_funcs->glEnable(GL_POINT_SPRITE);
- if (programmable)
- m_funcs->glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
- else
- m_funcs->glPointSize(value);
-}
-
-void GraphicsHelperGL2::enablei(GLenum cap, GLuint index)
-{
- Q_UNUSED(cap);
- Q_UNUSED(index);
- qWarning() << "glEnablei() not supported by OpenGL 2.0 (since 3.0)";
-}
-
-void GraphicsHelperGL2::disablei(GLenum cap, GLuint index)
-{
- Q_UNUSED(cap);
- Q_UNUSED(index);
- qWarning() << "glDisablei() not supported by OpenGL 2.0 (since 3.0)";
-}
-
-void GraphicsHelperGL2::setSeamlessCubemap(bool enable)
-{
- Q_UNUSED(enable);
- qWarning() << "GL_TEXTURE_CUBE_MAP_SEAMLESS not supported by OpenGL 2.0 (since 3.2)";
-}
-
-QSize GraphicsHelperGL2::getRenderBufferDimensions(GLuint renderBufferId)
-{
- Q_UNUSED(renderBufferId);
- qCritical() << "RenderBuffer dimensions retrival not supported on OpenGL 2.0";
- return QSize(0,0);
-}
-
-QSize GraphicsHelperGL2::getTextureDimensions(GLuint textureId, GLenum target, uint level)
-{
- GLint width = 0;
- GLint height = 0;
-
- m_funcs->glBindTexture(target, textureId);
- m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
- m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
- m_funcs->glBindTexture(target, 0);
-
- return QSize(width, height);
-}
-
-void GraphicsHelperGL2::dispatchCompute(GLuint wx, GLuint wy, GLuint wz)
-{
- Q_UNUSED(wx);
- Q_UNUSED(wy);
- Q_UNUSED(wz);
- qWarning() << "Compute Shaders are not supported by OpenGL 2.0 (since OpenGL 4.3)";
-}
-
-char *GraphicsHelperGL2::mapBuffer(GLenum target, GLsizeiptr size)
-{
- Q_UNUSED(size);
- return static_cast<char*>(m_funcs->glMapBuffer(target, GL_READ_WRITE));
-}
-
-GLboolean GraphicsHelperGL2::unmapBuffer(GLenum target)
-{
- return m_funcs->glUnmapBuffer(target);
-}
-
-void GraphicsHelperGL2::glUniform1fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform1fv(location, count, values);
-}
-
-void GraphicsHelperGL2::glUniform2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform2fv(location, count, values);
-}
-
-void GraphicsHelperGL2::glUniform3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform3fv(location, count, values);
-}
-
-void GraphicsHelperGL2::glUniform4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform4fv(location, count, values);
-}
-
-void GraphicsHelperGL2::glUniform1iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform1iv(location, count, values);
-}
-
-void GraphicsHelperGL2::glUniform2iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform2iv(location, count, values);
-}
-
-void GraphicsHelperGL2::glUniform3iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform3iv(location, count, values);
-}
-
-void GraphicsHelperGL2::glUniform4iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform4iv(location, count, values);
-}
-
-void GraphicsHelperGL2::glUniform1uiv(GLint , GLsizei , const GLuint *)
-{
- qWarning() << "glUniform1uiv not supported by GL 2";
-}
-
-void GraphicsHelperGL2::glUniform2uiv(GLint , GLsizei , const GLuint *)
-{
- qWarning() << "glUniform2uiv not supported by GL 2";
-}
-
-void GraphicsHelperGL2::glUniform3uiv(GLint , GLsizei , const GLuint *)
-{
- qWarning() << "glUniform3uiv not supported by GL 2";
-}
-
-void GraphicsHelperGL2::glUniform4uiv(GLint , GLsizei , const GLuint *)
-{
- qWarning() << "glUniform4uiv not supported by GL 2";
-}
-
-void GraphicsHelperGL2::glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL2::glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3fv(location, count, false, values);
-}
-
-void GraphicsHelperGL2::glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL2::glUniformMatrix2x3fv(GLint , GLsizei , const GLfloat *)
-{
- qWarning() << "glUniformMatrix2x3fv not supported by GL 2";
-}
-
-void GraphicsHelperGL2::glUniformMatrix3x2fv(GLint , GLsizei , const GLfloat *)
-{
- qWarning() << "glUniformMatrix3x2fv not supported by GL 2";
-}
-
-void GraphicsHelperGL2::glUniformMatrix2x4fv(GLint , GLsizei , const GLfloat *)
-{
- qWarning() << "glUniformMatrix2x4fv not supported by GL 2";
-}
-
-void GraphicsHelperGL2::glUniformMatrix4x2fv(GLint , GLsizei , const GLfloat *)
-{
- qWarning() << "glUniformMatrix4x2fv not supported by GL 2";
-}
-
-void GraphicsHelperGL2::glUniformMatrix3x4fv(GLint , GLsizei , const GLfloat *)
-{
- qWarning() << "glUniformMatrix3x4fv not supported by GL 2";
-}
-
-void GraphicsHelperGL2::glUniformMatrix4x3fv(GLint , GLsizei , const GLfloat *)
-{
- qWarning() << "glUniformMatrix4x3fv not supported by GL 2";
-}
-
-UniformType GraphicsHelperGL2::uniformTypeFromGLType(GLenum type)
-{
- switch (type) {
- case GL_FLOAT:
- return UniformType::Float;
- case GL_FLOAT_VEC2:
- return UniformType::Vec2;
- case GL_FLOAT_VEC3:
- return UniformType::Vec3;
- case GL_FLOAT_VEC4:
- return UniformType::Vec4;
- case GL_FLOAT_MAT2:
- return UniformType::Mat2;
- case GL_FLOAT_MAT3:
- return UniformType::Mat3;
- case GL_FLOAT_MAT4:
- return UniformType::Mat4;
- case GL_INT:
- return UniformType::Int;
- case GL_INT_VEC2:
- return UniformType::IVec2;
- case GL_INT_VEC3:
- return UniformType::IVec3;
- case GL_INT_VEC4:
- return UniformType::IVec4;
- case GL_BOOL:
- return UniformType::Bool;
- case GL_BOOL_VEC2:
- return UniformType::BVec2;
- case GL_BOOL_VEC3:
- return UniformType::BVec3;
- case GL_BOOL_VEC4:
- return UniformType::BVec4;
-
- case GL_SAMPLER_1D:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_3D:
- return UniformType::Sampler;
-
- default:
- Q_UNREACHABLE();
- return UniformType::Float;
- }
-}
-
-void GraphicsHelperGL2::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
-{
- Q_UNUSED(srcX0);
- Q_UNUSED(srcX1);
- Q_UNUSED(srcY0);
- Q_UNUSED(srcY1);
- Q_UNUSED(dstX0);
- Q_UNUSED(dstX1);
- Q_UNUSED(dstY0);
- Q_UNUSED(dstY1);
- Q_UNUSED(mask);
- Q_UNUSED(filter);
- qWarning() << "Framebuffer blits are not supported by ES 2.0 (since ES 3.1)";
-}
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // !QT_OPENGL_ES_2
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl2_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl2_p.h
deleted file mode 100644
index 689e956a2..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl2_p.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL2_H
-#define QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL2_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <graphicshelperinterface_p.h>
-
-#ifndef QT_OPENGL_ES_2
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLFunctions_2_0;
-class QOpenGLExtension_ARB_framebuffer_object;
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-class Q_AUTOTEST_EXPORT GraphicsHelperGL2 : public GraphicsHelperInterface
-{
-public:
- GraphicsHelperGL2();
-
- // QGraphicHelperInterface interface
- void alphaTest(GLenum mode1, GLenum mode2) override;
- void bindBufferBase(GLenum target, GLuint index, GLuint buffer) override;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) override;
- bool frameBufferNeedsRenderBuffer(const Attachment &attachment) override;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) override;
- void bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment) override;
- void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) override;
- void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) override;
- void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) override;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override;
- void blendEquation(GLenum mode) override;
- void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) override;
- void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha) override;
- void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override;
- GLuint boundFrameBufferObject() override;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) override;
- bool checkFrameBufferComplete() override;
- void clearBufferf(GLint drawbuffer, const QVector4D &values) override;
- GLuint createFrameBufferObject() override;
- void depthMask(GLenum mode) override;
- void depthRange(GLdouble nearValue, GLdouble farValue) override;
- void depthTest(GLenum mode) override;
- void disableClipPlane(int clipPlane) override;
- void disablei(GLenum cap, GLuint index) override;
- void disablePrimitiveRestart() override;
- void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) override;
- char *mapBuffer(GLenum target, GLsizeiptr size) override;
- GLboolean unmapBuffer(GLenum target) override;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) override;
- void drawArraysIndirect(GLenum mode,void *indirect) override;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) override;
- void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) override;
- void drawBuffers(GLsizei n, const int *bufs) override;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) override;
- void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) override;
- void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) override;
- void enableClipPlane(int clipPlane) override;
- void enablei(GLenum cap, GLuint index) override;
- void enablePrimitiveRestart(int primitiveRestartIndex) override;
- void enableVertexAttributeArray(int location) override;
- void frontFace(GLenum mode) override;
- QSize getRenderBufferDimensions(GLuint renderBufferId) override;
- QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) override;
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) override;
- void pointSize(bool programmable, GLfloat value) override;
- GLint maxClipPlaneCount() override;
- void memoryBarrier(QMemoryBarrier::Operations barriers) override;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) override;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) override;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) override;
- QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) override;
- void releaseFrameBufferObject(GLuint frameBufferId) override;
- void setMSAAEnabled(bool enable) override;
- void setAlphaCoverageEnabled(bool enable) override;
- void setClipPlane(int clipPlane, const QVector3D &normal, float distance) override;
- void setSeamlessCubemap(bool enable) override;
- void setVerticesPerPatch(GLint verticesPerPatch) override;
- bool supportsFeature(Feature feature) const override;
- uint uniformByteSize(const ShaderUniform &description) override;
- void useProgram(GLuint programId) override;
- void vertexAttribDivisor(GLuint index, GLuint divisor) override;
- void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) override;
- void readBuffer(GLenum mode) override;
- void drawBuffer(GLenum mode) override;
- void rasterMode(GLenum faceMode, GLenum rasterMode) override;
-
- void *fenceSync() override;
- void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
- void waitSync(void *sync) override;
- bool wasSyncSignaled(void *sync) override;
- void deleteSync(void *sync) override;
-
- void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- void glUniform1iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform2iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform3iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform4iv(GLint location, GLsizei count, const GLint *value) override;
-
- void glUniform1uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform2uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform3uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform4uiv(GLint location, GLsizei count, const GLuint *value) override;
-
- void glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- UniformType uniformTypeFromGLType(GLenum glType) override;
-
-private:
- QOpenGLFunctions_2_0 *m_funcs;
- QOpenGLExtension_ARB_framebuffer_object *m_fboFuncs;
-};
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // !QT_OPENGL_ES_2
-
-#endif // QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL2_H
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_2.cpp b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_2.cpp
deleted file mode 100644
index 13be202c8..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_2.cpp
+++ /dev/null
@@ -1,1247 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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$
-**
-****************************************************************************/
-
-#include "graphicshelpergl3_2_p.h"
-
-#ifndef QT_OPENGL_ES_2
-#include <QOpenGLFunctions_3_2_Core>
-#include <QOpenGLFunctions_3_3_Core>
-#include <QtOpenGLExtensions/qopenglextensions.h>
-#include <private/attachmentpack_p.h>
-#include <logging_p.h>
-#include <qgraphicsutils_p.h>
-
-QT_BEGIN_NAMESPACE
-
-# ifndef QT_OPENGL_3
-# define GL_PATCH_VERTICES 36466
-# define GL_ACTIVE_RESOURCES 0x92F5
-# define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
-# define GL_BUFFER_BINDING 0x9302
-# define GL_BUFFER_DATA_SIZE 0x9303
-# define GL_NUM_ACTIVE_VARIABLES 0x9304
-# define GL_SHADER_STORAGE_BLOCK 0x92E6
-# define GL_UNIFORM 0x92E1
-# define GL_UNIFORM_BLOCK 0x92E2
-# define GL_UNIFORM_BLOCK_INDEX 0x8A3A
-# define GL_UNIFORM_OFFSET 0x8A3B
-# define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
-# define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
-# define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
-# define GL_UNIFORM_BLOCK_BINDING 0x8A3F
-# define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
-# endif
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-GraphicsHelperGL3_2::GraphicsHelperGL3_2()
- : m_funcs(nullptr)
- , m_tessFuncs()
-{
-}
-
-GraphicsHelperGL3_2::~GraphicsHelperGL3_2()
-{
-}
-
-void GraphicsHelperGL3_2::initializeHelper(QOpenGLContext *context,
- QAbstractOpenGLFunctions *functions)
-{
- m_funcs = static_cast<QOpenGLFunctions_3_2_Core*>(functions);
- const bool ok = m_funcs->initializeOpenGLFunctions();
- Q_ASSERT(ok);
- Q_UNUSED(ok);
-
- if (context->hasExtension(QByteArrayLiteral("GL_ARB_tessellation_shader"))) {
- m_tessFuncs.reset(new QOpenGLExtension_ARB_tessellation_shader);
- m_tessFuncs->initializeOpenGLFunctions();
- }
-}
-
-void GraphicsHelperGL3_2::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2";
-
- // glDrawElements OpenGL 3.1 or greater
- m_funcs->glDrawElementsInstancedBaseVertex(primitiveType,
- primitiveCount,
- indexType,
- indices,
- instances,
- baseVertex);
-}
-
-void GraphicsHelperGL3_2::drawArraysInstanced(GLenum primitiveType,
- GLint first,
- GLsizei count,
- GLsizei instances)
-{
- // glDrawArraysInstanced OpenGL 3.1 or greater
- m_funcs->glDrawArraysInstanced(primitiveType,
- first,
- count,
- instances);
-}
-
-void GraphicsHelperGL3_2::drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawArraysInstancedBaseInstance is not supported with OpenGL 3";
- m_funcs->glDrawArraysInstanced(primitiveType,
- first,
- count,
- instances);
-}
-
-void GraphicsHelperGL3_2::drawElements(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLint baseVertex)
-{
- m_funcs->glDrawElementsBaseVertex(primitiveType,
- primitiveCount,
- indexType,
- indices,
- baseVertex);
-}
-
-void GraphicsHelperGL3_2::drawArrays(GLenum primitiveType,
- GLint first,
- GLsizei count)
-{
- m_funcs->glDrawArrays(primitiveType,
- first,
- count);
-}
-
-void GraphicsHelperGL3_2::drawElementsIndirect(GLenum, GLenum, void *)
-{
- qWarning() << "Indirect Drawing is not supported with OpenGL 3.2";
-}
-
-void GraphicsHelperGL3_2::drawArraysIndirect(GLenum , void *)
-{
- qWarning() << "Indirect Drawing is not supported with OpenGL 3.2";
-}
-
-void GraphicsHelperGL3_2::setVerticesPerPatch(GLint verticesPerPatch)
-{
-#if defined(QT_OPENGL_4)
- if (!m_tessFuncs) {
- qWarning() << "Tessellation not supported with OpenGL 3 without GL_ARB_tessellation_shader";
- return;
- }
-
- m_tessFuncs->glPatchParameteri(GL_PATCH_VERTICES, verticesPerPatch);
-#else
- Q_UNUSED(verticesPerPatch);
- qWarning() << "Tessellation not supported";
-#endif
-}
-
-void GraphicsHelperGL3_2::useProgram(GLuint programId)
-{
- m_funcs->glUseProgram(programId);
-}
-
-QVector<ShaderUniform> GraphicsHelperGL3_2::programUniformsAndLocations(GLuint programId)
-{
- QVector<ShaderUniform> uniforms;
-
- GLint nbrActiveUniforms = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_UNIFORMS, &nbrActiveUniforms);
- uniforms.reserve(nbrActiveUniforms);
- char uniformName[256];
- for (GLint i = 0; i < nbrActiveUniforms; i++) {
- ShaderUniform uniform;
- GLsizei uniformNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveUniform(programId, i, sizeof(uniformName) - 1, &uniformNameLength,
- &uniform.m_size, &uniform.m_type, uniformName);
- uniformName[sizeof(uniformName) - 1] = '\0';
- uniform.m_location = m_funcs->glGetUniformLocation(programId, uniformName);
- uniform.m_name = QString::fromUtf8(uniformName, uniformNameLength);
- // Work around for uniform array names that aren't returned with [0] by some drivers
- if (uniform.m_size > 1 && !uniform.m_name.endsWith(QLatin1String("[0]")))
- uniform.m_name.append(QLatin1String("[0]"));
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_BLOCK_INDEX, &uniform.m_blockIndex);
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_OFFSET, &uniform.m_offset);
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_ARRAY_STRIDE, &uniform.m_arrayStride);
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_MATRIX_STRIDE, &uniform.m_matrixStride);
- uniform.m_rawByteSize = uniformByteSize(uniform);
- uniforms.append(uniform);
- qCDebug(Rendering) << uniform.m_name << "size" << uniform.m_size
- << " offset" << uniform.m_offset
- << " rawSize" << uniform.m_rawByteSize;
- }
-
- return uniforms;
-}
-
-QVector<ShaderAttribute> GraphicsHelperGL3_2::programAttributesAndLocations(GLuint programId)
-{
- QVector<ShaderAttribute> attributes;
- GLint nbrActiveAttributes = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_ATTRIBUTES, &nbrActiveAttributes);
- attributes.reserve(nbrActiveAttributes);
- char attributeName[256];
- for (GLint i = 0; i < nbrActiveAttributes; i++) {
- ShaderAttribute attribute;
- GLsizei attributeNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveAttrib(programId, i, sizeof(attributeName) - 1, &attributeNameLength,
- &attribute.m_size, &attribute.m_type, attributeName);
- attributeName[sizeof(attributeName) - 1] = '\0';
- attribute.m_location = m_funcs->glGetAttribLocation(programId, attributeName);
- attribute.m_name = QString::fromUtf8(attributeName, attributeNameLength);
- attributes.append(attribute);
- }
- return attributes;
-}
-
-QVector<ShaderUniformBlock> GraphicsHelperGL3_2::programUniformBlocks(GLuint programId)
-{
- QVector<ShaderUniformBlock> blocks;
- GLint nbrActiveUniformsBlocks = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_UNIFORM_BLOCKS, &nbrActiveUniformsBlocks);
- blocks.reserve(nbrActiveUniformsBlocks);
- for (GLint i = 0; i < nbrActiveUniformsBlocks; i++) {
- QByteArray uniformBlockName(256, '\0');
- GLsizei length = 0;
- ShaderUniformBlock uniformBlock;
- m_funcs->glGetActiveUniformBlockName(programId, i, 256, &length, uniformBlockName.data());
- uniformBlock.m_name = QString::fromUtf8(uniformBlockName.left(length));
- uniformBlock.m_index = i;
- m_funcs->glGetActiveUniformBlockiv(programId, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &uniformBlock.m_activeUniformsCount);
- m_funcs->glGetActiveUniformBlockiv(programId, i, GL_UNIFORM_BLOCK_BINDING, &uniformBlock.m_binding);
- m_funcs->glGetActiveUniformBlockiv(programId, i, GL_UNIFORM_BLOCK_DATA_SIZE, &uniformBlock.m_size);
- blocks.append(uniformBlock);
- }
- return blocks;
-}
-
-QVector<ShaderStorageBlock> GraphicsHelperGL3_2::programShaderStorageBlocks(GLuint programId)
-{
- Q_UNUSED(programId);
- QVector<ShaderStorageBlock> blocks;
- qWarning() << "SSBO are not supported by OpenGL 3.2 (since OpenGL 4.3)";
- return blocks;
-}
-
-void GraphicsHelperGL3_2::vertexAttribDivisor(GLuint index, GLuint divisor)
-{
- Q_UNUSED(index);
- Q_UNUSED(divisor);
- qCWarning(Rendering) << "Vertex attribute divisor not available with OpenGL 3.2 core";
-}
-
-void GraphicsHelperGL3_2::vertexAttributePointer(GLenum shaderDataType,
- GLuint index,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const GLvoid *pointer)
-{
- switch (shaderDataType) {
- case GL_FLOAT:
- case GL_FLOAT_VEC2:
- case GL_FLOAT_VEC3:
- case GL_FLOAT_VEC4:
- case GL_FLOAT_MAT2:
- case GL_FLOAT_MAT2x3:
- case GL_FLOAT_MAT2x4:
- case GL_FLOAT_MAT3:
- case GL_FLOAT_MAT3x2:
- case GL_FLOAT_MAT3x4:
- case GL_FLOAT_MAT4x2:
- case GL_FLOAT_MAT4x3:
- case GL_FLOAT_MAT4:
- m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer);
- break;
-
- case GL_INT:
- case GL_INT_VEC2:
- case GL_INT_VEC3:
- case GL_INT_VEC4:
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_INT_VEC2:
- case GL_UNSIGNED_INT_VEC3:
- case GL_UNSIGNED_INT_VEC4:
- m_funcs->glVertexAttribIPointer(index, size, type, stride, pointer);
- break;
-
- default:
- qCWarning(Rendering) << "vertexAttribPointer: Unhandled type";
- Q_UNREACHABLE();
- }
-}
-
-void GraphicsHelperGL3_2::readBuffer(GLenum mode)
-{
- m_funcs->glReadBuffer(mode);
-}
-
-void GraphicsHelperGL3_2::drawBuffer(GLenum mode)
-{
- m_funcs->glDrawBuffer(mode);
-}
-
-void *GraphicsHelperGL3_2::fenceSync()
-{
- return m_funcs->glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
-}
-
-void GraphicsHelperGL3_2::clientWaitSync(void *sync, GLuint64 nanoSecTimeout)
-{
- m_funcs->glClientWaitSync(static_cast<GLsync>(sync), GL_SYNC_FLUSH_COMMANDS_BIT, nanoSecTimeout);
-}
-
-void GraphicsHelperGL3_2::waitSync(void *sync)
-{
- m_funcs->glWaitSync(static_cast<GLsync>(sync), 0, GL_TIMEOUT_IGNORED);
-}
-
-bool GraphicsHelperGL3_2::wasSyncSignaled(void *sync)
-{
- GLint v;
- m_funcs->glGetSynciv(static_cast<GLsync>(sync),
- GL_SYNC_STATUS,
- sizeof(v),
- nullptr,
- &v);
- return v == GL_SIGNALED;
-}
-
-void GraphicsHelperGL3_2::deleteSync(void *sync)
-{
- m_funcs->glDeleteSync(static_cast<GLsync>(sync));
-}
-
-void GraphicsHelperGL3_2::rasterMode(GLenum faceMode, GLenum rasterMode)
-{
- m_funcs->glPolygonMode(faceMode, rasterMode);
-}
-
-void GraphicsHelperGL3_2::blendEquation(GLenum mode)
-{
- m_funcs->glBlendEquation(mode);
-}
-
-void GraphicsHelperGL3_2::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
-{
- Q_UNUSED(buf);
- Q_UNUSED(sfactor);
- Q_UNUSED(dfactor);
-
- qWarning() << "glBlendFunci() not supported by OpenGL 3.0 (since OpenGL 4.0)";
-}
-
-void GraphicsHelperGL3_2::blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha)
-{
- Q_UNUSED(buf);
- Q_UNUSED(sRGB);
- Q_UNUSED(dRGB);
- Q_UNUSED(sAlpha);
- Q_UNUSED(dAlpha);
-
- qWarning() << "glBlendFuncSeparatei() not supported by OpenGL 3.0 (since OpenGL 4.0)";
-}
-
-void GraphicsHelperGL3_2::alphaTest(GLenum, GLenum)
-{
- qCWarning(Rendering) << "AlphaTest not available with OpenGL 3.2 core";
-}
-
-void GraphicsHelperGL3_2::depthTest(GLenum mode)
-{
- m_funcs->glEnable(GL_DEPTH_TEST);
- m_funcs->glDepthFunc(mode);
-}
-
-void GraphicsHelperGL3_2::depthMask(GLenum mode)
-{
- m_funcs->glDepthMask(mode);
-}
-
-void GraphicsHelperGL3_2::depthRange(GLdouble nearValue, GLdouble farValue)
-{
- m_funcs->glDepthRange(nearValue, farValue);
-}
-
-void GraphicsHelperGL3_2::frontFace(GLenum mode)
-{
- m_funcs->glFrontFace(mode);
-
-}
-
-void GraphicsHelperGL3_2::setMSAAEnabled(bool enabled)
-{
- enabled ? m_funcs->glEnable(GL_MULTISAMPLE)
- : m_funcs->glDisable(GL_MULTISAMPLE);
-}
-
-void GraphicsHelperGL3_2::setAlphaCoverageEnabled(bool enabled)
-{
- enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
- : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-GLuint GraphicsHelperGL3_2::createFrameBufferObject()
-{
- GLuint id;
- m_funcs->glGenFramebuffers(1, &id);
- return id;
-}
-
-void GraphicsHelperGL3_2::releaseFrameBufferObject(GLuint frameBufferId)
-{
- m_funcs->glDeleteFramebuffers(1, &frameBufferId);
-}
-
-void GraphicsHelperGL3_2::bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode)
-{
- switch (mode) {
- case FBODraw:
- m_funcs->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferId);
- return;
- case FBORead:
- m_funcs->glBindFramebuffer(GL_READ_FRAMEBUFFER, frameBufferId);
- return;
- case FBOReadAndDraw:
- default:
- m_funcs->glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
- return;
- }
-}
-
-void GraphicsHelperGL3_2::bindImageTexture(GLuint imageUnit, GLuint texture,
- GLint mipLevel, GLboolean layered,
- GLint layer, GLenum access, GLenum format)
-{
- Q_UNUSED(imageUnit)
- Q_UNUSED(texture)
- Q_UNUSED(mipLevel)
- Q_UNUSED(layered)
- Q_UNUSED(layer)
- Q_UNUSED(access)
- Q_UNUSED(format)
- qWarning() << "Shader Images are not supported by OpenGL 3.2 (since OpenGL 4.2)";
-
-}
-
-GLuint GraphicsHelperGL3_2::boundFrameBufferObject()
-{
- GLint id = 0;
- m_funcs->glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &id);
- return id;
-}
-
-bool GraphicsHelperGL3_2::checkFrameBufferComplete()
-{
- return (m_funcs->glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
-}
-
-bool GraphicsHelperGL3_2::frameBufferNeedsRenderBuffer(const Attachment &attachment)
-{
- Q_UNUSED(attachment);
- return false;
-}
-
-void GraphicsHelperGL3_2::bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment)
-{
- GLenum attr = GL_DEPTH_STENCIL_ATTACHMENT;
-
- if (attachment.m_point <= QRenderTargetOutput::Color15)
- attr = GL_COLOR_ATTACHMENT0 + attachment.m_point;
- else if (attachment.m_point == QRenderTargetOutput::Depth)
- attr = GL_DEPTH_ATTACHMENT;
- else if (attachment.m_point == QRenderTargetOutput::Stencil)
- attr = GL_STENCIL_ATTACHMENT;
-
- texture->bind();
- QOpenGLTexture::Target target = texture->target();
- if (target == QOpenGLTexture::Target1DArray || target == QOpenGLTexture::Target2DArray ||
- target == QOpenGLTexture::Target2DMultisampleArray || target == QOpenGLTexture::Target3D)
- m_funcs->glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, attr, texture->textureId(), attachment.m_mipLevel, attachment.m_layer);
- else if (target == QOpenGLTexture::TargetCubeMapArray)
- m_funcs->glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel, attachment.m_layer);
- else if (target == QOpenGLTexture::TargetCubeMap)
- m_funcs->glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel);
- else
- m_funcs->glFramebufferTexture(GL_DRAW_FRAMEBUFFER, attr, texture->textureId(), attachment.m_mipLevel);
- texture->release();
-}
-
-void GraphicsHelperGL3_2::bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment)
-{
- Q_UNUSED(renderBuffer);
- Q_UNUSED(attachment);
- Q_UNREACHABLE();
-}
-
-bool GraphicsHelperGL3_2::supportsFeature(GraphicsHelperInterface::Feature feature) const
-{
- switch (feature) {
- case MRT:
- case UniformBufferObject:
- case PrimitiveRestart:
- case RenderBufferDimensionRetrieval:
- case TextureDimensionRetrieval:
- case BindableFragmentOutputs:
- case BlitFramebuffer:
- case Fences:
- return true;
- case Tessellation:
- return !m_tessFuncs.isNull();
- default:
- return false;
- }
-}
-
-void GraphicsHelperGL3_2::drawBuffers(GLsizei n, const int *bufs)
-{
- // Use QVarLengthArray here
- QVarLengthArray<GLenum, 16> drawBufs(n);
-
- for (int i = 0; i < n; i++)
- drawBufs[i] = GL_COLOR_ATTACHMENT0 + bufs[i];
- m_funcs->glDrawBuffers(n, drawBufs.constData());
-}
-
-void GraphicsHelperGL3_2::bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs)
-{
- for (auto it = outputs.begin(), end = outputs.end(); it != end; ++it)
- m_funcs->glBindFragDataLocation(shader, it.value(), it.key().toStdString().c_str());
-}
-
-void GraphicsHelperGL3_2::bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
-{
- m_funcs->glUniformBlockBinding(programId, uniformBlockIndex, uniformBlockBinding);
-}
-
-void GraphicsHelperGL3_2::bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding)
-{
- Q_UNUSED(programId);
- Q_UNUSED(shaderStorageBlockIndex);
- Q_UNUSED(shaderStorageBlockBinding);
- qWarning() << "SSBO are not supported by OpenGL 3.0 (since OpenGL 4.3)";
-}
-
-void GraphicsHelperGL3_2::bindBufferBase(GLenum target, GLuint index, GLuint buffer)
-{
- m_funcs->glBindBufferBase(target, index, buffer);
-}
-
-void GraphicsHelperGL3_2::buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer)
-{
- char *bufferData = buffer.data();
-
- switch (description.m_type) {
-
- case GL_FLOAT: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_FLOAT_VEC2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_FLOAT_VEC3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_FLOAT_VEC4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_FLOAT_MAT2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 4);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 2);
- break;
- }
-
- case GL_FLOAT_MAT2x3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 6);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 3);
- break;
- }
-
- case GL_FLOAT_MAT2x4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 8);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 4);
- break;
- }
-
- case GL_FLOAT_MAT3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 9);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 3);
- break;
- }
-
- case GL_FLOAT_MAT3x2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 6);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 2);
- break;
- }
-
- case GL_FLOAT_MAT3x4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 12);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 4);
- break;
- }
-
- case GL_FLOAT_MAT4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 16);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 4);
- break;
- }
-
- case GL_FLOAT_MAT4x2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 8);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 2);
- break;
- }
-
- case GL_FLOAT_MAT4x3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 12);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 3);
- break;
- }
-
- case GL_INT: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_INT_VEC2: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_INT_VEC3: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_INT_VEC4: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_UNSIGNED_INT: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC2: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC3: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC4: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_BOOL: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_BOOL_VEC2: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_BOOL_VEC3: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_BOOL_VEC4: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_SAMPLER_1D:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_BUFFER:
- case GL_SAMPLER_2D_RECT:
- case GL_INT_SAMPLER_1D:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_2D_RECT:
- case GL_UNSIGNED_INT_SAMPLER_1D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_1D_ARRAY:
- case GL_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_1D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_1D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_RECT_SHADOW:
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: {
- Q_ASSERT(description.m_size == 1);
- int value = v.toInt();
- QGraphicsUtils::fillDataArray<GLint>(bufferData, &value, description, 1);
- break;
- }
-
- default:
- qWarning() << Q_FUNC_INFO << "unsupported uniform type:" << description.m_type << "for " << description.m_name;
- break;
- }
-}
-
-uint GraphicsHelperGL3_2::uniformByteSize(const ShaderUniform &description)
-{
- uint rawByteSize = 0;
- int arrayStride = qMax(description.m_arrayStride, 0);
- int matrixStride = qMax(description.m_matrixStride, 0);
-
- switch (description.m_type) {
-
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- case GL_UNSIGNED_INT_VEC2:
- rawByteSize = 8;
- break;
-
- case GL_FLOAT_VEC3:
- case GL_INT_VEC3:
- case GL_UNSIGNED_INT_VEC3:
- rawByteSize = 12;
- break;
-
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- case GL_UNSIGNED_INT_VEC4:
- rawByteSize = 16;
- break;
-
- case GL_FLOAT_MAT2:
- rawByteSize = matrixStride ? 2 * matrixStride : 16;
- break;
-
- case GL_FLOAT_MAT2x4:
- rawByteSize = matrixStride ? 2 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT4x2:
- rawByteSize = matrixStride ? 4 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT3:
- rawByteSize = matrixStride ? 3 * matrixStride : 36;
- break;
-
- case GL_FLOAT_MAT2x3:
- rawByteSize = matrixStride ? 2 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT3x2:
- rawByteSize = matrixStride ? 3 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT4:
- rawByteSize = matrixStride ? 4 * matrixStride : 64;
- break;
-
- case GL_FLOAT_MAT4x3:
- rawByteSize = matrixStride ? 4 * matrixStride : 48;
- break;
-
- case GL_FLOAT_MAT3x4:
- rawByteSize = matrixStride ? 3 * matrixStride : 48;
- break;
-
- case GL_BOOL:
- rawByteSize = 1;
- break;
-
- case GL_BOOL_VEC2:
- rawByteSize = 2;
- break;
-
- case GL_BOOL_VEC3:
- rawByteSize = 3;
- break;
-
- case GL_BOOL_VEC4:
- rawByteSize = 4;
- break;
-
- case GL_INT:
- case GL_FLOAT:
- case GL_UNSIGNED_INT:
- case GL_SAMPLER_1D:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_BUFFER:
- case GL_SAMPLER_2D_RECT:
- case GL_INT_SAMPLER_1D:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_2D_RECT:
- case GL_UNSIGNED_INT_SAMPLER_1D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_1D_ARRAY:
- case GL_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_1D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_1D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_RECT_SHADOW:
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- rawByteSize = 4;
- break;
- }
-
- return arrayStride ? rawByteSize * arrayStride : rawByteSize;
-}
-
-void GraphicsHelperGL3_2::enableClipPlane(int clipPlane)
-{
- m_funcs->glEnable(GL_CLIP_DISTANCE0 + clipPlane);
-}
-
-void GraphicsHelperGL3_2::disableClipPlane(int clipPlane)
-{
- m_funcs->glDisable(GL_CLIP_DISTANCE0 + clipPlane);
-}
-
-void GraphicsHelperGL3_2::setClipPlane(int clipPlane, const QVector3D &normal, float distance)
-{
- // deprecated
- Q_UNUSED(clipPlane);
- Q_UNUSED(normal);
- Q_UNUSED(distance);
-}
-
-GLint GraphicsHelperGL3_2::maxClipPlaneCount()
-{
- GLint max = 0;
- m_funcs->glGetIntegerv(GL_MAX_CLIP_DISTANCES, &max);
- return max;
-}
-
-void GraphicsHelperGL3_2::memoryBarrier(QMemoryBarrier::Operations barriers)
-{
- Q_UNUSED(barriers);
- qWarning() << "memory barrier is not supported by OpenGL 3.0 (since 4.3)";
-}
-
-void GraphicsHelperGL3_2::enablePrimitiveRestart(int primitiveRestartIndex)
-{
- m_funcs->glPrimitiveRestartIndex(primitiveRestartIndex);
- m_funcs->glEnable(GL_PRIMITIVE_RESTART);
-}
-
-void GraphicsHelperGL3_2::enableVertexAttributeArray(int location)
-{
- m_funcs->glEnableVertexAttribArray(location);
-}
-
-void GraphicsHelperGL3_2::disablePrimitiveRestart()
-{
- m_funcs->glDisable(GL_PRIMITIVE_RESTART);
-}
-
-void GraphicsHelperGL3_2::clearBufferf(GLint drawbuffer, const QVector4D &values)
-{
- GLfloat vec[4] = {values[0], values[1], values[2], values[3]};
- m_funcs->glClearBufferfv(GL_COLOR, drawbuffer, vec);
-}
-
-void GraphicsHelperGL3_2::pointSize(bool programmable, GLfloat value)
-{
- if (programmable) {
- m_funcs->glEnable(GL_PROGRAM_POINT_SIZE);
- } else {
- m_funcs->glDisable(GL_PROGRAM_POINT_SIZE);
- m_funcs->glPointSize(value);
- }
-}
-
-void GraphicsHelperGL3_2::enablei(GLenum cap, GLuint index)
-{
- m_funcs->glEnablei(cap, index);
-}
-
-void GraphicsHelperGL3_2::disablei(GLenum cap, GLuint index)
-{
- m_funcs->glDisablei(cap, index);
-}
-
-void GraphicsHelperGL3_2::setSeamlessCubemap(bool enable)
-{
- if (enable)
- m_funcs->glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
- else
- m_funcs->glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
-}
-
-QSize GraphicsHelperGL3_2::getRenderBufferDimensions(GLuint renderBufferId)
-{
- GLint width = 0;
- GLint height = 0;
-
- m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, renderBufferId);
- m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
- m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
- m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, 0);
-
- return QSize(width, height);
-}
-
-QSize GraphicsHelperGL3_2::getTextureDimensions(GLuint textureId, GLenum target, uint level)
-{
- GLint width = 0;
- GLint height = 0;
-
- m_funcs->glBindTexture(target, textureId);
- m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
- m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
- m_funcs->glBindTexture(target, 0);
-
- return QSize(width, height);
-}
-
-void GraphicsHelperGL3_2::dispatchCompute(GLuint wx, GLuint wy, GLuint wz)
-{
- Q_UNUSED(wx);
- Q_UNUSED(wy);
- Q_UNUSED(wz);
- qWarning() << "Compute Shaders are not supported by OpenGL 3.2 (since OpenGL 4.3)";
-}
-
-char *GraphicsHelperGL3_2::mapBuffer(GLenum target, GLsizeiptr size)
-{
- return static_cast<char*>(m_funcs->glMapBufferRange(target, 0, size, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT));
-}
-
-GLboolean GraphicsHelperGL3_2::unmapBuffer(GLenum target)
-{
- return m_funcs->glUnmapBuffer(target);
-}
-
-void GraphicsHelperGL3_2::glUniform1fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform1fv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform2fv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform3fv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform4fv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform1iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform1iv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform2iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform2iv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform3iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform3iv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform4iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform4iv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform1uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform1uiv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform2uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform2uiv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform3uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform3uiv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniform4uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform4uiv(location, count, values);
-}
-
-void GraphicsHelperGL3_2::glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_2::glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_2::glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_2::glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2x3fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_2::glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3x2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_2::glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2x4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_2::glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4x2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_2::glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3x4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_2::glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4x3fv(location, count, false, values);
-}
-
-UniformType GraphicsHelperGL3_2::uniformTypeFromGLType(GLenum type)
-{
- switch (type) {
- case GL_FLOAT:
- return UniformType::Float;
- case GL_FLOAT_VEC2:
- return UniformType::Vec2;
- case GL_FLOAT_VEC3:
- return UniformType::Vec3;
- case GL_FLOAT_VEC4:
- return UniformType::Vec4;
- case GL_FLOAT_MAT2:
- return UniformType::Mat2;
- case GL_FLOAT_MAT3:
- return UniformType::Mat3;
- case GL_FLOAT_MAT4:
- return UniformType::Mat4;
- case GL_FLOAT_MAT2x3:
- return UniformType::Mat2x3;
- case GL_FLOAT_MAT3x2:
- return UniformType::Mat3x2;
- case GL_FLOAT_MAT2x4:
- return UniformType::Mat2x4;
- case GL_FLOAT_MAT4x2:
- return UniformType::Mat4x2;
- case GL_FLOAT_MAT3x4:
- return UniformType::Mat3x4;
- case GL_FLOAT_MAT4x3:
- return UniformType::Mat4x3;
- case GL_INT:
- return UniformType::Int;
- case GL_INT_VEC2:
- return UniformType::IVec2;
- case GL_INT_VEC3:
- return UniformType::IVec3;
- case GL_INT_VEC4:
- return UniformType::IVec4;
- case GL_UNSIGNED_INT:
- return UniformType::UInt;
- case GL_UNSIGNED_INT_VEC2:
- return UniformType::UIVec2;
- case GL_UNSIGNED_INT_VEC3:
- return UniformType::UIVec3;
- case GL_UNSIGNED_INT_VEC4:
- return UniformType::UIVec4;
- case GL_BOOL:
- return UniformType::Bool;
- case GL_BOOL_VEC2:
- return UniformType::BVec2;
- case GL_BOOL_VEC3:
- return UniformType::BVec3;
- case GL_BOOL_VEC4:
- return UniformType::BVec4;
-
- case GL_SAMPLER_BUFFER:
- case GL_SAMPLER_1D:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_2D_RECT:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_2D_RECT_SHADOW:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_1D_ARRAY:
- case GL_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_SAMPLER_3D:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_1D:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_1D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_1D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- return UniformType::Sampler;
- default:
- Q_UNREACHABLE();
- return UniformType::Float;
- }
-}
-
-void GraphicsHelperGL3_2::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
-{
- m_funcs->glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-}
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // !QT_OPENGL_ES_2
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_2_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_2_p.h
deleted file mode 100644
index 1c2553f89..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_2_p.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL3_H
-#define QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL3_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <graphicshelperinterface_p.h>
-#include <QtCore/qscopedpointer.h>
-
-#ifndef QT_OPENGL_ES_2
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLFunctions_3_2_Core;
-class QOpenGLExtension_ARB_tessellation_shader;
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-class Q_AUTOTEST_EXPORT GraphicsHelperGL3_2 : public GraphicsHelperInterface
-{
-public:
- GraphicsHelperGL3_2();
- ~GraphicsHelperGL3_2();
-
- // QGraphicHelperInterface interface
- void alphaTest(GLenum mode1, GLenum mode2) override;
- void bindBufferBase(GLenum target, GLuint index, GLuint buffer) override;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) override;
- bool frameBufferNeedsRenderBuffer(const Attachment &attachment) override;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) override;
- void bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment) override;
- void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) override;
- void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) override;
- void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) override;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override;
- void blendEquation(GLenum mode) override;
- void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) override;
- void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha) override;
- void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override;
- GLuint boundFrameBufferObject() override;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) override;
- bool checkFrameBufferComplete() override;
- void clearBufferf(GLint drawbuffer, const QVector4D &values) override;
- GLuint createFrameBufferObject() override;
- void depthMask(GLenum mode) override;
- void depthRange(GLdouble nearValue, GLdouble farValue) override;
- void depthTest(GLenum mode) override;
- void disableClipPlane(int clipPlane) override;
- void disablei(GLenum cap, GLuint index) override;
- void disablePrimitiveRestart() override;
- void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) override;
- char *mapBuffer(GLenum target, GLsizeiptr size) override;
- GLboolean unmapBuffer(GLenum target) override;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) override;
- void drawArraysIndirect(GLenum mode,void *indirect) override;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) override;
- void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) override;
- void drawBuffers(GLsizei n, const int *bufs) override;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) override;
- void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) override;
- void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) override;
- void enableClipPlane(int clipPlane) override;
- void enablei(GLenum cap, GLuint index) override;
- void enablePrimitiveRestart(int primitiveRestartIndex) override;
- void enableVertexAttributeArray(int location) override;
- void frontFace(GLenum mode) override;
- QSize getRenderBufferDimensions(GLuint renderBufferId) override;
- QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) override;
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) override;
- void pointSize(bool programmable, GLfloat value) override;
- GLint maxClipPlaneCount() override;
- void memoryBarrier(QMemoryBarrier::Operations barriers) override;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) override;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) override;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) override;
- QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) override;
- void releaseFrameBufferObject(GLuint frameBufferId) override;
- void setMSAAEnabled(bool enable) override;
- void setAlphaCoverageEnabled(bool enable) override;
- void setClipPlane(int clipPlane, const QVector3D &normal, float distance) override;
- void setSeamlessCubemap(bool enable) override;
- void setVerticesPerPatch(GLint verticesPerPatch) override;
- bool supportsFeature(Feature feature) const override;
- uint uniformByteSize(const ShaderUniform &description) override;
- void useProgram(GLuint programId) override;
- void vertexAttribDivisor(GLuint index, GLuint divisor) override;
- void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) override;
- void readBuffer(GLenum mode) override;
- void drawBuffer(GLenum mode) override;
- void rasterMode(GLenum faceMode, GLenum rasterMode) override;
-
- void *fenceSync() override;
- void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
- void waitSync(void *sync) override;
- bool wasSyncSignaled(void *sync) override;
- void deleteSync(void *sync) override;
-
- void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- void glUniform1iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform2iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform3iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform4iv(GLint location, GLsizei count, const GLint *value) override;
-
- void glUniform1uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform2uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform3uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform4uiv(GLint location, GLsizei count, const GLuint *value) override;
-
- void glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- UniformType uniformTypeFromGLType(GLenum glType) override;
-
-private:
- QOpenGLFunctions_3_2_Core *m_funcs;
- QScopedPointer<QOpenGLExtension_ARB_tessellation_shader> m_tessFuncs;
-};
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // !QT_OPENGL_ES_2
-
-#endif // QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL3_H
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_3.cpp b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_3.cpp
deleted file mode 100644
index 09a0e1cc4..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_3.cpp
+++ /dev/null
@@ -1,1242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 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$
-**
-****************************************************************************/
-
-#include "graphicshelpergl3_3_p.h"
-
-#ifndef QT_OPENGL_ES_2
-#include <QOpenGLFunctions_3_3_Core>
-#include <QtOpenGLExtensions/qopenglextensions.h>
-#include <private/attachmentpack_p.h>
-#include <logging_p.h>
-#include <qgraphicsutils_p.h>
-
-# ifndef QT_OPENGL_3_2
-# define GL_PATCH_VERTICES 36466
-# define GL_ACTIVE_RESOURCES 0x92F5
-# define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
-# define GL_BUFFER_BINDING 0x9302
-# define GL_BUFFER_DATA_SIZE 0x9303
-# define GL_NUM_ACTIVE_VARIABLES 0x9304
-# define GL_SHADER_STORAGE_BLOCK 0x92E6
-# define GL_UNIFORM 0x92E1
-# define GL_UNIFORM_BLOCK 0x92E2
-# define GL_UNIFORM_BLOCK_INDEX 0x8A3A
-# define GL_UNIFORM_OFFSET 0x8A3B
-# define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
-# define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
-# define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
-# define GL_UNIFORM_BLOCK_BINDING 0x8A3F
-# define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
-# endif
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-GraphicsHelperGL3_3::GraphicsHelperGL3_3()
- : m_funcs(nullptr)
- , m_tessFuncs()
-{
-}
-
-GraphicsHelperGL3_3::~GraphicsHelperGL3_3()
-{
-}
-
-void GraphicsHelperGL3_3::initializeHelper(QOpenGLContext *context,
- QAbstractOpenGLFunctions *functions)
-{
- m_funcs = static_cast<QOpenGLFunctions_3_3_Core*>(functions);
- const bool ok = m_funcs->initializeOpenGLFunctions();
- Q_ASSERT(ok);
- Q_UNUSED(ok);
-
- if (context->hasExtension(QByteArrayLiteral("GL_ARB_tessellation_shader"))) {
- m_tessFuncs.reset(new QOpenGLExtension_ARB_tessellation_shader);
- m_tessFuncs->initializeOpenGLFunctions();
- }
-}
-
-void GraphicsHelperGL3_3::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL 3";
-
- // glDrawElements OpenGL 3.1 or greater
- m_funcs->glDrawElementsInstancedBaseVertex(primitiveType,
- primitiveCount,
- indexType,
- indices,
- instances,
- baseVertex);
-}
-
-void GraphicsHelperGL3_3::drawArraysInstanced(GLenum primitiveType,
- GLint first,
- GLsizei count,
- GLsizei instances)
-{
- // glDrawArraysInstanced OpenGL 3.1 or greater
- m_funcs->glDrawArraysInstanced(primitiveType,
- first,
- count,
- instances);
-}
-
-void GraphicsHelperGL3_3::drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawArraysInstancedBaseInstance is not supported with OpenGL 3";
- m_funcs->glDrawArraysInstanced(primitiveType,
- first,
- count,
- instances);
-}
-
-void GraphicsHelperGL3_3::drawElements(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLint baseVertex)
-{
- m_funcs->glDrawElementsBaseVertex(primitiveType,
- primitiveCount,
- indexType,
- indices,
- baseVertex);
-}
-
-void GraphicsHelperGL3_3::drawElementsIndirect(GLenum, GLenum, void *)
-{
- qWarning() << "Indirect Drawing is not supported with OpenGL 3";
-}
-
-void GraphicsHelperGL3_3::drawArrays(GLenum primitiveType,
- GLint first,
- GLsizei count)
-{
- m_funcs->glDrawArrays(primitiveType,
- first,
- count);
-}
-
-void GraphicsHelperGL3_3::drawArraysIndirect(GLenum , void *)
-{
- qWarning() << "Indirect Drawing is not supported with OpenGL 3";
-}
-
-void GraphicsHelperGL3_3::setVerticesPerPatch(GLint verticesPerPatch)
-{
-#if defined(QT_OPENGL_4)
- if (!m_tessFuncs) {
- qWarning() << "Tessellation not supported with OpenGL 3 without GL_ARB_tessellation_shader";
- return;
- }
-
- m_tessFuncs->glPatchParameteri(GL_PATCH_VERTICES, verticesPerPatch);
-#else
- Q_UNUSED(verticesPerPatch);
- qWarning() << "Tessellation not supported";
-#endif
-}
-
-void GraphicsHelperGL3_3::useProgram(GLuint programId)
-{
- m_funcs->glUseProgram(programId);
-}
-
-QVector<ShaderUniform> GraphicsHelperGL3_3::programUniformsAndLocations(GLuint programId)
-{
- QVector<ShaderUniform> uniforms;
-
- GLint nbrActiveUniforms = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_UNIFORMS, &nbrActiveUniforms);
- uniforms.reserve(nbrActiveUniforms);
- char uniformName[256];
- for (GLint i = 0; i < nbrActiveUniforms; i++) {
- ShaderUniform uniform;
- GLsizei uniformNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveUniform(programId, i, sizeof(uniformName) - 1, &uniformNameLength,
- &uniform.m_size, &uniform.m_type, uniformName);
- uniformName[sizeof(uniformName) - 1] = '\0';
- uniform.m_location = m_funcs->glGetUniformLocation(programId, uniformName);
- uniform.m_name = QString::fromUtf8(uniformName, uniformNameLength);
- // Work around for uniform array names that aren't returned with [0] by some drivers
- if (uniform.m_size > 1 && !uniform.m_name.endsWith(QLatin1String("[0]")))
- uniform.m_name.append(QLatin1String("[0]"));
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_BLOCK_INDEX, &uniform.m_blockIndex);
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_OFFSET, &uniform.m_offset);
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_ARRAY_STRIDE, &uniform.m_arrayStride);
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_MATRIX_STRIDE, &uniform.m_matrixStride);
- uniform.m_rawByteSize = uniformByteSize(uniform);
- uniforms.append(uniform);
- qCDebug(Rendering) << uniform.m_name << "size" << uniform.m_size
- << " offset" << uniform.m_offset
- << " rawSize" << uniform.m_rawByteSize;
- }
-
- return uniforms;
-}
-
-QVector<ShaderAttribute> GraphicsHelperGL3_3::programAttributesAndLocations(GLuint programId)
-{
- QVector<ShaderAttribute> attributes;
- GLint nbrActiveAttributes = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_ATTRIBUTES, &nbrActiveAttributes);
- attributes.reserve(nbrActiveAttributes);
- char attributeName[256];
- for (GLint i = 0; i < nbrActiveAttributes; i++) {
- ShaderAttribute attribute;
- GLsizei attributeNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveAttrib(programId, i, sizeof(attributeName) - 1, &attributeNameLength,
- &attribute.m_size, &attribute.m_type, attributeName);
- attributeName[sizeof(attributeName) - 1] = '\0';
- attribute.m_location = m_funcs->glGetAttribLocation(programId, attributeName);
- attribute.m_name = QString::fromUtf8(attributeName, attributeNameLength);
- attributes.append(attribute);
- }
- return attributes;
-}
-
-QVector<ShaderUniformBlock> GraphicsHelperGL3_3::programUniformBlocks(GLuint programId)
-{
- QVector<ShaderUniformBlock> blocks;
- GLint nbrActiveUniformsBlocks = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_UNIFORM_BLOCKS, &nbrActiveUniformsBlocks);
- blocks.reserve(nbrActiveUniformsBlocks);
- for (GLint i = 0; i < nbrActiveUniformsBlocks; i++) {
- QByteArray uniformBlockName(256, '\0');
- GLsizei length = 0;
- ShaderUniformBlock uniformBlock;
- m_funcs->glGetActiveUniformBlockName(programId, i, 256, &length, uniformBlockName.data());
- uniformBlock.m_name = QString::fromUtf8(uniformBlockName.left(length));
- uniformBlock.m_index = i;
- m_funcs->glGetActiveUniformBlockiv(programId, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &uniformBlock.m_activeUniformsCount);
- m_funcs->glGetActiveUniformBlockiv(programId, i, GL_UNIFORM_BLOCK_BINDING, &uniformBlock.m_binding);
- m_funcs->glGetActiveUniformBlockiv(programId, i, GL_UNIFORM_BLOCK_DATA_SIZE, &uniformBlock.m_size);
- blocks.append(uniformBlock);
- }
- return blocks;
-}
-
-QVector<ShaderStorageBlock> GraphicsHelperGL3_3::programShaderStorageBlocks(GLuint programId)
-{
- Q_UNUSED(programId);
- QVector<ShaderStorageBlock> blocks;
- qWarning() << "SSBO are not supported by OpenGL 3.3 (since OpenGL 4.3)";
- return blocks;
-}
-
-void GraphicsHelperGL3_3::vertexAttribDivisor(GLuint index, GLuint divisor)
-{
- m_funcs->glVertexAttribDivisor(index, divisor);
-}
-
-void GraphicsHelperGL3_3::vertexAttributePointer(GLenum shaderDataType,
- GLuint index,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const GLvoid *pointer)
-{
- switch (shaderDataType) {
- case GL_FLOAT:
- case GL_FLOAT_VEC2:
- case GL_FLOAT_VEC3:
- case GL_FLOAT_VEC4:
- case GL_FLOAT_MAT2:
- case GL_FLOAT_MAT2x3:
- case GL_FLOAT_MAT2x4:
- case GL_FLOAT_MAT3:
- case GL_FLOAT_MAT3x2:
- case GL_FLOAT_MAT3x4:
- case GL_FLOAT_MAT4x2:
- case GL_FLOAT_MAT4x3:
- case GL_FLOAT_MAT4:
- m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer);
- break;
-
- case GL_INT:
- case GL_INT_VEC2:
- case GL_INT_VEC3:
- case GL_INT_VEC4:
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_INT_VEC2:
- case GL_UNSIGNED_INT_VEC3:
- case GL_UNSIGNED_INT_VEC4:
- m_funcs->glVertexAttribIPointer(index, size, type, stride, pointer);
- break;
-
- default:
- qCWarning(Rendering) << "vertexAttribPointer: Unhandled type";
- }
-}
-
-void GraphicsHelperGL3_3::readBuffer(GLenum mode)
-{
- m_funcs->glReadBuffer(mode);
-}
-
-void GraphicsHelperGL3_3::drawBuffer(GLenum mode)
-{
- m_funcs->glDrawBuffer(mode);
-}
-
-void *GraphicsHelperGL3_3::fenceSync()
-{
- return m_funcs->glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
-}
-
-void GraphicsHelperGL3_3::clientWaitSync(void *sync, GLuint64 nanoSecTimeout)
-{
- m_funcs->glClientWaitSync(static_cast<GLsync>(sync), GL_SYNC_FLUSH_COMMANDS_BIT, nanoSecTimeout);
-}
-
-void GraphicsHelperGL3_3::waitSync(void *sync)
-{
- m_funcs->glWaitSync(static_cast<GLsync>(sync), 0, GL_TIMEOUT_IGNORED);
-}
-
-bool GraphicsHelperGL3_3::wasSyncSignaled(void *sync)
-{
- GLint v;
- m_funcs->glGetSynciv(static_cast<GLsync>(sync),
- GL_SYNC_STATUS,
- sizeof(v),
- nullptr,
- &v);
- return v == GL_SIGNALED;
-}
-
-void GraphicsHelperGL3_3::deleteSync(void *sync)
-{
- m_funcs->glDeleteSync(static_cast<GLsync>(sync));
-}
-
-void GraphicsHelperGL3_3::rasterMode(GLenum faceMode, GLenum rasterMode)
-{
- m_funcs->glPolygonMode(faceMode, rasterMode);
-}
-
-void GraphicsHelperGL3_3::blendEquation(GLenum mode)
-{
- m_funcs->glBlendEquation(mode);
-}
-
-void GraphicsHelperGL3_3::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
-{
- Q_UNUSED(buf);
- Q_UNUSED(sfactor);
- Q_UNUSED(dfactor);
-
- qWarning() << "glBlendFunci() not supported by OpenGL 3.3 (since OpenGL 4.0)";
-}
-
-void GraphicsHelperGL3_3::blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha)
-{
- Q_UNUSED(buf);
- Q_UNUSED(sRGB);
- Q_UNUSED(dRGB);
- Q_UNUSED(sAlpha);
- Q_UNUSED(dAlpha);
-
- qWarning() << "glBlendFuncSeparatei() not supported by OpenGL 3.3 (since OpenGL 4.0)";
-}
-
-void GraphicsHelperGL3_3::alphaTest(GLenum, GLenum)
-{
- qCWarning(Rendering) << "AlphaTest not available with OpenGL 3.2 core";
-}
-
-void GraphicsHelperGL3_3::depthTest(GLenum mode)
-{
- m_funcs->glEnable(GL_DEPTH_TEST);
- m_funcs->glDepthFunc(mode);
-}
-
-void GraphicsHelperGL3_3::depthMask(GLenum mode)
-{
- m_funcs->glDepthMask(mode);
-}
-
-void GraphicsHelperGL3_3::depthRange(GLdouble nearValue, GLdouble farValue)
-{
- m_funcs->glDepthRange(nearValue, farValue);
-}
-
-void GraphicsHelperGL3_3::frontFace(GLenum mode)
-{
- m_funcs->glFrontFace(mode);
-
-}
-
-void GraphicsHelperGL3_3::setMSAAEnabled(bool enabled)
-{
- enabled ? m_funcs->glEnable(GL_MULTISAMPLE)
- : m_funcs->glDisable(GL_MULTISAMPLE);
-}
-
-void GraphicsHelperGL3_3::setAlphaCoverageEnabled(bool enabled)
-{
- enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
- : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-GLuint GraphicsHelperGL3_3::createFrameBufferObject()
-{
- GLuint id;
- m_funcs->glGenFramebuffers(1, &id);
- return id;
-}
-
-void GraphicsHelperGL3_3::releaseFrameBufferObject(GLuint frameBufferId)
-{
- m_funcs->glDeleteFramebuffers(1, &frameBufferId);
-}
-
-void GraphicsHelperGL3_3::bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode)
-{
- switch (mode) {
- case FBODraw:
- m_funcs->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferId);
- return;
- case FBORead:
- m_funcs->glBindFramebuffer(GL_READ_FRAMEBUFFER, frameBufferId);
- return;
- case FBOReadAndDraw:
- default:
- m_funcs->glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
- return;
- }
-}
-
-GLuint GraphicsHelperGL3_3::boundFrameBufferObject()
-{
- GLint id = 0;
- m_funcs->glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &id);
- return id;
-}
-
-bool GraphicsHelperGL3_3::checkFrameBufferComplete()
-{
- return (m_funcs->glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
-}
-
-bool GraphicsHelperGL3_3::frameBufferNeedsRenderBuffer(const Attachment &attachment)
-{
- Q_UNUSED(attachment);
- return false;
-}
-
-void GraphicsHelperGL3_3::bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment)
-{
- GLenum attr = GL_DEPTH_STENCIL_ATTACHMENT;
-
- if (attachment.m_point <= QRenderTargetOutput::Color15)
- attr = GL_COLOR_ATTACHMENT0 + attachment.m_point;
- else if (attachment.m_point == QRenderTargetOutput::Depth)
- attr = GL_DEPTH_ATTACHMENT;
- else if (attachment.m_point == QRenderTargetOutput::Stencil)
- attr = GL_STENCIL_ATTACHMENT;
-
- texture->bind();
- QOpenGLTexture::Target target = texture->target();
- if (target == QOpenGLTexture::Target1DArray || target == QOpenGLTexture::Target2DArray ||
- target == QOpenGLTexture::Target2DMultisampleArray || target == QOpenGLTexture::Target3D)
- m_funcs->glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, attr, texture->textureId(), attachment.m_mipLevel, attachment.m_layer);
- else if (target == QOpenGLTexture::TargetCubeMapArray)
- m_funcs->glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel, attachment.m_layer);
- else if (target == QOpenGLTexture::TargetCubeMap && attachment.m_face != QAbstractTexture::AllFaces)
- m_funcs->glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel);
- else
- m_funcs->glFramebufferTexture(GL_DRAW_FRAMEBUFFER, attr, texture->textureId(), attachment.m_mipLevel);
- texture->release();
-}
-
-void GraphicsHelperGL3_3::bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment)
-{
- Q_UNUSED(renderBuffer);
- Q_UNUSED(attachment);
- Q_UNREACHABLE();
-}
-
-bool GraphicsHelperGL3_3::supportsFeature(GraphicsHelperInterface::Feature feature) const
-{
- switch (feature) {
- case MRT:
- case UniformBufferObject:
- case PrimitiveRestart:
- case RenderBufferDimensionRetrieval:
- case TextureDimensionRetrieval:
- case BindableFragmentOutputs:
- case BlitFramebuffer:
- case Fences:
- return true;
- case Tessellation:
- return !m_tessFuncs.isNull();
- default:
- return false;
- }
-}
-
-void GraphicsHelperGL3_3::drawBuffers(GLsizei n, const int *bufs)
-{
- // Use QVarLengthArray here
- QVarLengthArray<GLenum, 16> drawBufs(n);
-
- for (int i = 0; i < n; i++)
- drawBufs[i] = GL_COLOR_ATTACHMENT0 + bufs[i];
- m_funcs->glDrawBuffers(n, drawBufs.constData());
-}
-
-void GraphicsHelperGL3_3::bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs)
-{
- for (auto it = outputs.begin(), end = outputs.end(); it != end; ++it)
- m_funcs->glBindFragDataLocation(shader, it.value(), it.key().toStdString().c_str());
-}
-
-void GraphicsHelperGL3_3::bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
-{
- m_funcs->glUniformBlockBinding(programId, uniformBlockIndex, uniformBlockBinding);
-}
-
-void GraphicsHelperGL3_3::bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding)
-{
- Q_UNUSED(programId);
- Q_UNUSED(shaderStorageBlockIndex);
- Q_UNUSED(shaderStorageBlockBinding);
- qWarning() << "SSBO are not supported by OpenGL 3.3 (since OpenGL 4.3)";
-}
-
-void GraphicsHelperGL3_3::bindImageTexture(GLuint imageUnit, GLuint texture,
- GLint mipLevel, GLboolean layered,
- GLint layer, GLenum access, GLenum format)
-{
- Q_UNUSED(imageUnit)
- Q_UNUSED(texture)
- Q_UNUSED(mipLevel)
- Q_UNUSED(layered)
- Q_UNUSED(layer)
- Q_UNUSED(access)
- Q_UNUSED(format)
- qWarning() << "Shader Images are not supported by OpenGL 3.3 (since OpenGL 4.2)";
-}
-
-void GraphicsHelperGL3_3::bindBufferBase(GLenum target, GLuint index, GLuint buffer)
-{
- m_funcs->glBindBufferBase(target, index, buffer);
-}
-
-void GraphicsHelperGL3_3::buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer)
-{
- char *bufferData = buffer.data();
-
- switch (description.m_type) {
-
- case GL_FLOAT: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_FLOAT_VEC2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_FLOAT_VEC3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_FLOAT_VEC4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_FLOAT_MAT2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 4);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 2);
- break;
- }
-
- case GL_FLOAT_MAT2x3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 6);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 3);
- break;
- }
-
- case GL_FLOAT_MAT2x4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 8);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 4);
- break;
- }
-
- case GL_FLOAT_MAT3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 9);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 3);
- break;
- }
-
- case GL_FLOAT_MAT3x2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 6);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 2);
- break;
- }
-
- case GL_FLOAT_MAT3x4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 12);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 4);
- break;
- }
-
- case GL_FLOAT_MAT4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 16);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 4);
- break;
- }
-
- case GL_FLOAT_MAT4x2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 8);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 2);
- break;
- }
-
- case GL_FLOAT_MAT4x3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 12);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 3);
- break;
- }
-
- case GL_INT: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_INT_VEC2: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_INT_VEC3: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_INT_VEC4: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_UNSIGNED_INT: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC2: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC3: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC4: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_BOOL: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_BOOL_VEC2: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_BOOL_VEC3: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_BOOL_VEC4: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_SAMPLER_1D:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_BUFFER:
- case GL_SAMPLER_2D_RECT:
- case GL_INT_SAMPLER_1D:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_2D_RECT:
- case GL_UNSIGNED_INT_SAMPLER_1D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_1D_ARRAY:
- case GL_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_1D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_1D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_RECT_SHADOW:
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: {
- Q_ASSERT(description.m_size == 1);
- int value = v.toInt();
- QGraphicsUtils::fillDataArray<GLint>(bufferData, &value, description, 1);
- break;
- }
-
- default:
- qWarning() << Q_FUNC_INFO << "unsupported uniform type:" << description.m_type << "for " << description.m_name;
- break;
- }
-}
-
-uint GraphicsHelperGL3_3::uniformByteSize(const ShaderUniform &description)
-{
- uint rawByteSize = 0;
- int arrayStride = qMax(description.m_arrayStride, 0);
- int matrixStride = qMax(description.m_matrixStride, 0);
-
- switch (description.m_type) {
-
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- case GL_UNSIGNED_INT_VEC2:
- rawByteSize = 8;
- break;
-
- case GL_FLOAT_VEC3:
- case GL_INT_VEC3:
- case GL_UNSIGNED_INT_VEC3:
- rawByteSize = 12;
- break;
-
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- case GL_UNSIGNED_INT_VEC4:
- rawByteSize = 16;
- break;
-
- case GL_FLOAT_MAT2:
- rawByteSize = matrixStride ? 2 * matrixStride : 16;
- break;
-
- case GL_FLOAT_MAT2x4:
- rawByteSize = matrixStride ? 2 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT4x2:
- rawByteSize = matrixStride ? 4 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT3:
- rawByteSize = matrixStride ? 3 * matrixStride : 36;
- break;
-
- case GL_FLOAT_MAT2x3:
- rawByteSize = matrixStride ? 2 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT3x2:
- rawByteSize = matrixStride ? 3 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT4:
- rawByteSize = matrixStride ? 4 * matrixStride : 64;
- break;
-
- case GL_FLOAT_MAT4x3:
- rawByteSize = matrixStride ? 4 * matrixStride : 48;
- break;
-
- case GL_FLOAT_MAT3x4:
- rawByteSize = matrixStride ? 3 * matrixStride : 48;
- break;
-
- case GL_BOOL:
- rawByteSize = 1;
- break;
-
- case GL_BOOL_VEC2:
- rawByteSize = 2;
- break;
-
- case GL_BOOL_VEC3:
- rawByteSize = 3;
- break;
-
- case GL_BOOL_VEC4:
- rawByteSize = 4;
- break;
-
- case GL_INT:
- case GL_FLOAT:
- case GL_UNSIGNED_INT:
- case GL_SAMPLER_1D:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_BUFFER:
- case GL_SAMPLER_2D_RECT:
- case GL_INT_SAMPLER_1D:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_2D_RECT:
- case GL_UNSIGNED_INT_SAMPLER_1D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_1D_ARRAY:
- case GL_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_1D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_1D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_RECT_SHADOW:
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- rawByteSize = 4;
- break;
- }
-
- return arrayStride ? rawByteSize * arrayStride : rawByteSize;
-}
-
-void GraphicsHelperGL3_3::enableClipPlane(int clipPlane)
-{
- m_funcs->glEnable(GL_CLIP_DISTANCE0 + clipPlane);
-}
-
-void GraphicsHelperGL3_3::disableClipPlane(int clipPlane)
-{
- m_funcs->glDisable(GL_CLIP_DISTANCE0 + clipPlane);
-}
-
-void GraphicsHelperGL3_3::setClipPlane(int clipPlane, const QVector3D &normal, float distance)
-{
- // deprecated
- Q_UNUSED(clipPlane);
- Q_UNUSED(normal);
- Q_UNUSED(distance);
-}
-
-GLint GraphicsHelperGL3_3::maxClipPlaneCount()
-{
- GLint max = 0;
- m_funcs->glGetIntegerv(GL_MAX_CLIP_DISTANCES, &max);
- return max;
-}
-
-void GraphicsHelperGL3_3::memoryBarrier(QMemoryBarrier::Operations barriers)
-{
- Q_UNUSED(barriers);
- qWarning() << "memory barrier is not supported by OpenGL 3.3 (since 4.3)";
-}
-
-void GraphicsHelperGL3_3::enablePrimitiveRestart(int primitiveRestartIndex)
-{
- m_funcs->glPrimitiveRestartIndex(primitiveRestartIndex);
- m_funcs->glEnable(GL_PRIMITIVE_RESTART);
-}
-
-void GraphicsHelperGL3_3::enableVertexAttributeArray(int location)
-{
- m_funcs->glEnableVertexAttribArray(location);
-}
-
-void GraphicsHelperGL3_3::disablePrimitiveRestart()
-{
- m_funcs->glDisable(GL_PRIMITIVE_RESTART);
-}
-
-void GraphicsHelperGL3_3::clearBufferf(GLint drawbuffer, const QVector4D &values)
-{
- GLfloat vec[4] = {values[0], values[1], values[2], values[3]};
- m_funcs->glClearBufferfv(GL_COLOR, drawbuffer, vec);
-}
-
-void GraphicsHelperGL3_3::pointSize(bool programmable, GLfloat value)
-{
- if (programmable) {
- m_funcs->glEnable(GL_PROGRAM_POINT_SIZE);
- } else {
- m_funcs->glDisable(GL_PROGRAM_POINT_SIZE);
- m_funcs->glPointSize(value);
- }
-}
-
-void GraphicsHelperGL3_3::enablei(GLenum cap, GLuint index)
-{
- m_funcs->glEnablei(cap, index);
-}
-
-void GraphicsHelperGL3_3::disablei(GLenum cap, GLuint index)
-{
- m_funcs->glDisablei(cap, index);
-}
-
-void GraphicsHelperGL3_3::setSeamlessCubemap(bool enable)
-{
- if (enable)
- m_funcs->glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
- else
- m_funcs->glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
-}
-
-QSize GraphicsHelperGL3_3::getRenderBufferDimensions(GLuint renderBufferId)
-{
- GLint width = 0;
- GLint height = 0;
-
- m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, renderBufferId);
- m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
- m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
- m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, 0);
-
- return QSize(width, height);
-}
-
-QSize GraphicsHelperGL3_3::getTextureDimensions(GLuint textureId, GLenum target, uint level)
-{
- GLint width = 0;
- GLint height = 0;
-
- m_funcs->glBindTexture(target, textureId);
- m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
- m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
- m_funcs->glBindTexture(target, 0);
-
- return QSize(width, height);
-}
-
-void GraphicsHelperGL3_3::dispatchCompute(GLuint wx, GLuint wy, GLuint wz)
-{
- Q_UNUSED(wx);
- Q_UNUSED(wy);
- Q_UNUSED(wz);
- qWarning() << "Compute Shaders are not supported by OpenGL 3.3 (since OpenGL 4.3)";
-}
-
-char *GraphicsHelperGL3_3::mapBuffer(GLenum target, GLsizeiptr size)
-{
- return static_cast<char*>(m_funcs->glMapBufferRange(target, 0, size, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT));
-}
-
-GLboolean GraphicsHelperGL3_3::unmapBuffer(GLenum target)
-{
- return m_funcs->glUnmapBuffer(target);
-}
-
-void GraphicsHelperGL3_3::glUniform1fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform1fv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform2fv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform3fv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform4fv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform1iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform1iv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform2iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform2iv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform3iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform3iv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform4iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform4iv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform1uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform1uiv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform2uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform2uiv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform3uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform3uiv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniform4uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform4uiv(location, count, values);
-}
-
-void GraphicsHelperGL3_3::glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_3::glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_3::glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_3::glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2x3fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_3::glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3x2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_3::glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2x4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_3::glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4x2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_3::glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3x4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL3_3::glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4x3fv(location, count, false, values);
-}
-
-UniformType GraphicsHelperGL3_3::uniformTypeFromGLType(GLenum type)
-{
- switch (type) {
- case GL_FLOAT:
- return UniformType::Float;
- case GL_FLOAT_VEC2:
- return UniformType::Vec2;
- case GL_FLOAT_VEC3:
- return UniformType::Vec3;
- case GL_FLOAT_VEC4:
- return UniformType::Vec4;
- case GL_FLOAT_MAT2:
- return UniformType::Mat2;
- case GL_FLOAT_MAT3:
- return UniformType::Mat3;
- case GL_FLOAT_MAT4:
- return UniformType::Mat4;
- case GL_FLOAT_MAT2x3:
- return UniformType::Mat2x3;
- case GL_FLOAT_MAT3x2:
- return UniformType::Mat3x2;
- case GL_FLOAT_MAT2x4:
- return UniformType::Mat2x4;
- case GL_FLOAT_MAT4x2:
- return UniformType::Mat4x2;
- case GL_FLOAT_MAT3x4:
- return UniformType::Mat3x4;
- case GL_FLOAT_MAT4x3:
- return UniformType::Mat4x3;
- case GL_INT:
- return UniformType::Int;
- case GL_INT_VEC2:
- return UniformType::IVec2;
- case GL_INT_VEC3:
- return UniformType::IVec3;
- case GL_INT_VEC4:
- return UniformType::IVec4;
- case GL_UNSIGNED_INT:
- return UniformType::UInt;
- case GL_UNSIGNED_INT_VEC2:
- return UniformType::UIVec2;
- case GL_UNSIGNED_INT_VEC3:
- return UniformType::UIVec3;
- case GL_UNSIGNED_INT_VEC4:
- return UniformType::UIVec4;
- case GL_BOOL:
- return UniformType::Bool;
- case GL_BOOL_VEC2:
- return UniformType::BVec2;
- case GL_BOOL_VEC3:
- return UniformType::BVec3;
- case GL_BOOL_VEC4:
- return UniformType::BVec4;
-
- case GL_SAMPLER_BUFFER:
- case GL_SAMPLER_1D:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_1D_ARRAY:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_2D_RECT:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_2D_RECT_SHADOW:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_SAMPLER_3D:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_1D:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_1D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_1D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- return UniformType::Sampler;
- default:
- Q_UNREACHABLE();
- return UniformType::Float;
- }
-}
-
-void GraphicsHelperGL3_3::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
-{
- m_funcs->glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-}
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // !QT_OPENGL_ES_2
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_3_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_3_p.h
deleted file mode 100644
index 46baaec95..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl3_3_p.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 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$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL3_3_P_H
-#define QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL3_3_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <graphicshelperinterface_p.h>
-#include <QtCore/qscopedpointer.h>
-
-#ifndef QT_OPENGL_ES_2
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLFunctions_3_3_Core;
-class QOpenGLExtension_ARB_tessellation_shader;
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-class Q_AUTOTEST_EXPORT GraphicsHelperGL3_3 : public GraphicsHelperInterface
-{
-public:
- GraphicsHelperGL3_3();
- ~GraphicsHelperGL3_3();
-
- // QGraphicHelperInterface interface
- void alphaTest(GLenum mode1, GLenum mode2) override;
- void bindBufferBase(GLenum target, GLuint index, GLuint buffer) override;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) override;
- bool frameBufferNeedsRenderBuffer(const Attachment &attachment) override;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) override;
- void bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment) override;
- void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) override;
- void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) override;
- void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) override;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override;
- void blendEquation(GLenum mode) override;
- void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) override;
- void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha) override;
- void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override;
- GLuint boundFrameBufferObject() override;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) override;
- bool checkFrameBufferComplete() override;
- void clearBufferf(GLint drawbuffer, const QVector4D &values) override;
- GLuint createFrameBufferObject() override;
- void depthMask(GLenum mode) override;
- void depthRange(GLdouble nearValue, GLdouble farValue) override;
- void depthTest(GLenum mode) override;
- void disableClipPlane(int clipPlane) override;
- void disablei(GLenum cap, GLuint index) override;
- void disablePrimitiveRestart() override;
- void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) override;
- char *mapBuffer(GLenum target, GLsizeiptr size) override;
- GLboolean unmapBuffer(GLenum target) override;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) override;
- void drawArraysIndirect(GLenum mode,void *indirect) override;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) override;
- void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) override;
- void drawBuffers(GLsizei n, const int *bufs) override;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) override;
- void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) override;
- void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) override;
- void enableClipPlane(int clipPlane) override;
- void enablei(GLenum cap, GLuint index) override;
- void enablePrimitiveRestart(int primitiveRestartIndex) override;
- void enableVertexAttributeArray(int location) override;
- void frontFace(GLenum mode) override;
- QSize getRenderBufferDimensions(GLuint renderBufferId) override;
- QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) override;
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) override;
- void pointSize(bool programmable, GLfloat value) override;
- GLint maxClipPlaneCount() override;
- void memoryBarrier(QMemoryBarrier::Operations barriers) override;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) override;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) override;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) override;
- QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) override;
- void releaseFrameBufferObject(GLuint frameBufferId) override;
- void setMSAAEnabled(bool enable) override;
- void setAlphaCoverageEnabled(bool enable) override;
- void setClipPlane(int clipPlane, const QVector3D &normal, float distance) override;
- void setSeamlessCubemap(bool enable) override;
- void setVerticesPerPatch(GLint verticesPerPatch) override;
- bool supportsFeature(Feature feature) const override;
- uint uniformByteSize(const ShaderUniform &description) override;
- void useProgram(GLuint programId) override;
- void vertexAttribDivisor(GLuint index, GLuint divisor) override;
- void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) override;
- void readBuffer(GLenum mode) override;
- void drawBuffer(GLenum mode) override;
- void rasterMode(GLenum faceMode, GLenum rasterMode) override;
-
- void *fenceSync() override;
- void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
- void waitSync(void *sync) override;
- bool wasSyncSignaled(void *sync) override;
- void deleteSync(void *sync) override;
-
- void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- void glUniform1iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform2iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform3iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform4iv(GLint location, GLsizei count, const GLint *value) override;
-
- void glUniform1uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform2uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform3uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform4uiv(GLint location, GLsizei count, const GLuint *value) override;
-
- void glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- UniformType uniformTypeFromGLType(GLenum glType) override;
-
-private:
- QOpenGLFunctions_3_3_Core *m_funcs;
- QScopedPointer<QOpenGLExtension_ARB_tessellation_shader> m_tessFuncs;
-};
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // !QT_OPENGL_ES_2
-
-#endif // QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL3_3_P_H
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl4.cpp b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl4.cpp
deleted file mode 100644
index 42dafd14b..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl4.cpp
+++ /dev/null
@@ -1,1444 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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$
-**
-****************************************************************************/
-
-#include "graphicshelpergl4_p.h"
-
-#ifndef QT_OPENGL_ES_2
-#include <QOpenGLFunctions_4_3_Core>
-#include <QtOpenGLExtensions/qopenglextensions.h>
-#include <private/attachmentpack_p.h>
-#include <qgraphicsutils_p.h>
-#include <logging_p.h>
-
-# ifndef QT_OPENGL_4_3
-# ifndef GL_PATCH_VERTICES
-# define GL_PATCH_VERTICES 36466
-# endif
-# define GL_ACTIVE_RESOURCES 0x92F5
-# define GL_BUFFER_BINDING 0x9302
-# define GL_BUFFER_DATA_SIZE 0x9303
-# define GL_NUM_ACTIVE_VARIABLES 0x9304
-# define GL_SHADER_STORAGE_BLOCK 0x92E6
-# define GL_UNIFORM 0x92E1
-# define GL_UNIFORM_BLOCK 0x92E2
-# define GL_UNIFORM_BLOCK_INDEX 0x8A3A
-# define GL_UNIFORM_OFFSET 0x8A3B
-# define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
-# define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
-# define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
-# define GL_UNIFORM_BLOCK_BINDING 0x8A3F
-# define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
-# define GL_ALL_BARRIER_BITS 0xFFFFFFFF
-# define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
-# define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002
-# define GL_UNIFORM_BARRIER_BIT 0x00000004
-# define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008
-# define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
-# define GL_COMMAND_BARRIER_BIT 0x00000040
-# define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080
-# define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100
-# define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200
-# define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400
-# define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
-# define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000
-# define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000
-# define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000
-# define GL_IMAGE_1D 0x904C
-# define GL_IMAGE_2D 0x904D
-# define GL_IMAGE_3D 0x904E
-# define GL_IMAGE_2D_RECT 0x904F
-# define GL_IMAGE_CUBE 0x9050
-# define GL_IMAGE_BUFFER 0x9051
-# define GL_IMAGE_1D_ARRAY 0x9052
-# define GL_IMAGE_2D_ARRAY 0x9053
-# define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
-# define GL_IMAGE_2D_MULTISAMPLE 0x9055
-# define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056
-# define GL_INT_IMAGE_1D 0x9057
-# define GL_INT_IMAGE_2D 0x9058
-# define GL_INT_IMAGE_3D 0x9059
-# define GL_INT_IMAGE_2D_RECT 0x905A
-# define GL_INT_IMAGE_CUBE 0x905B
-# define GL_INT_IMAGE_BUFFER 0x905C
-# define GL_INT_IMAGE_1D_ARRAY 0x905D
-# define GL_INT_IMAGE_2D_ARRAY 0x905E
-# define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
-# define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060
-# define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
-# define GL_UNSIGNED_INT_IMAGE_1D 0x9062
-# define GL_UNSIGNED_INT_IMAGE_2D 0x9063
-# define GL_UNSIGNED_INT_IMAGE_3D 0x9064
-# define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065
-# define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
-# define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
-# define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068
-# define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
-# define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
-# define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
-# define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
-# endif
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-namespace {
-
-GLbitfield memoryBarrierGLBitfield(QMemoryBarrier::Operations barriers)
-{
- GLbitfield bits = 0;
-
- if (barriers.testFlag(QMemoryBarrier::All)) {
- bits |= GL_ALL_BARRIER_BITS;
- return bits;
- }
-
- if (barriers.testFlag(QMemoryBarrier::VertexAttributeArray))
- bits |= GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::ElementArray))
- bits |= GL_ELEMENT_ARRAY_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::Uniform))
- bits |= GL_UNIFORM_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::TextureFetch))
- bits |= GL_TEXTURE_FETCH_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::ShaderImageAccess))
- bits |= GL_SHADER_IMAGE_ACCESS_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::Command))
- bits |= GL_COMMAND_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::PixelBuffer))
- bits |= GL_PIXEL_BUFFER_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::TextureUpdate))
- bits |= GL_TEXTURE_UPDATE_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::BufferUpdate))
- bits |= GL_BUFFER_UPDATE_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::FrameBuffer))
- bits |= GL_FRAMEBUFFER_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::TransformFeedback))
- bits |= GL_TRANSFORM_FEEDBACK_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::AtomicCounter))
- bits |= GL_ATOMIC_COUNTER_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::ShaderStorage))
- bits |= GL_SHADER_STORAGE_BARRIER_BIT;
- if (barriers.testFlag(QMemoryBarrier::QueryBuffer))
- bits |= GL_QUERY_BUFFER_BARRIER_BIT;
-
- return bits;
-}
-
-}
-
-GraphicsHelperGL4::GraphicsHelperGL4()
- : m_funcs(nullptr)
-{
-}
-
-void GraphicsHelperGL4::initializeHelper(QOpenGLContext *context,
- QAbstractOpenGLFunctions *functions)
-{
- Q_UNUSED(context);
- m_funcs = static_cast<QOpenGLFunctions_4_3_Core*>(functions);
- const bool ok = m_funcs->initializeOpenGLFunctions();
- Q_ASSERT(ok);
- Q_UNUSED(ok);
-}
-
-void GraphicsHelperGL4::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
-{
- if (baseInstance != 0)
- qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2";
-
- // glDrawElements OpenGL 3.1 or greater
- m_funcs->glDrawElementsInstancedBaseVertex(primitiveType,
- primitiveCount,
- indexType,
- indices,
- instances,
- baseVertex);
-}
-
-void GraphicsHelperGL4::drawArraysInstanced(GLenum primitiveType,
- GLint first,
- GLsizei count,
- GLsizei instances)
-{
- // glDrawArraysInstanced OpenGL 3.1 or greater
- m_funcs->glDrawArraysInstanced(primitiveType,
- first,
- count,
- instances);
-}
-
-void GraphicsHelperGL4::drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance)
-{
- m_funcs->glDrawArraysInstancedBaseInstance(primitiveType,
- first,
- count,
- instances,
- baseInstance);
-}
-
-void GraphicsHelperGL4::drawElements(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLint baseVertex)
-{
- m_funcs->glDrawElementsBaseVertex(primitiveType,
- primitiveCount,
- indexType,
- indices,
- baseVertex);
-}
-
-void GraphicsHelperGL4::drawElementsIndirect(GLenum mode,
- GLenum type,
- void *indirect)
-{
- m_funcs->glDrawElementsIndirect(mode, type, indirect);
-}
-
-void GraphicsHelperGL4::drawArrays(GLenum primitiveType,
- GLint first,
- GLsizei count)
-{
- m_funcs->glDrawArrays(primitiveType,
- first,
- count);
-}
-
-void GraphicsHelperGL4::drawArraysIndirect(GLenum mode, void *indirect)
-{
- m_funcs->glDrawArraysIndirect(mode, indirect);
-}
-
-void GraphicsHelperGL4::setVerticesPerPatch(GLint verticesPerPatch)
-{
- m_funcs->glPatchParameteri(GL_PATCH_VERTICES, verticesPerPatch);
-}
-
-void GraphicsHelperGL4::useProgram(GLuint programId)
-{
- m_funcs->glUseProgram(programId);
-}
-
-QVector<ShaderUniform> GraphicsHelperGL4::programUniformsAndLocations(GLuint programId)
-{
- QVector<ShaderUniform> uniforms;
-
- GLint nbrActiveUniforms = 0;
- m_funcs->glGetProgramInterfaceiv(programId, GL_UNIFORM, GL_ACTIVE_RESOURCES, &nbrActiveUniforms);
- uniforms.reserve(nbrActiveUniforms);
- char uniformName[256];
- for (GLint i = 0; i < nbrActiveUniforms; ++i) {
- ShaderUniform uniform;
- GLsizei uniformNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveUniform(programId, i, sizeof(uniformName) - 1, &uniformNameLength,
- &uniform.m_size, &uniform.m_type, uniformName);
- uniformName[sizeof(uniformName) - 1] = '\0';
- uniform.m_location = m_funcs->glGetUniformLocation(programId, uniformName);
- uniform.m_name = QString::fromUtf8(uniformName, uniformNameLength);
- // Work around for uniform array names that aren't returned with [0] by some drivers
- if (uniform.m_size > 1 && !uniform.m_name.endsWith(QLatin1String("[0]")))
- uniform.m_name.append(QLatin1String("[0]"));
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_BLOCK_INDEX, &uniform.m_blockIndex);
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_OFFSET, &uniform.m_offset);
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_ARRAY_STRIDE, &uniform.m_arrayStride);
- m_funcs->glGetActiveUniformsiv(programId, 1, (GLuint*)&i, GL_UNIFORM_MATRIX_STRIDE, &uniform.m_matrixStride);
- uniform.m_rawByteSize = uniformByteSize(uniform);
- uniforms.append(uniform);
- qCDebug(Rendering) << uniform.m_name << "size" << uniform.m_size
- << " offset" << uniform.m_offset
- << " rawSize" << uniform.m_rawByteSize;
- }
-
- return uniforms;
-}
-
-QVector<ShaderAttribute> GraphicsHelperGL4::programAttributesAndLocations(GLuint programId)
-{
- QVector<ShaderAttribute> attributes;
- GLint nbrActiveAttributes = 0;
- m_funcs->glGetProgramiv(programId, GL_ACTIVE_ATTRIBUTES, &nbrActiveAttributes);
- attributes.reserve(nbrActiveAttributes);
- char attributeName[256];
- for (GLint i = 0; i < nbrActiveAttributes; ++i) {
- ShaderAttribute attribute;
- GLsizei attributeNameLength = 0;
- // Size is 1 for scalar and more for struct or arrays
- // Type is the GL Type
- m_funcs->glGetActiveAttrib(programId, i, sizeof(attributeName) - 1, &attributeNameLength,
- &attribute.m_size, &attribute.m_type, attributeName);
- attributeName[sizeof(attributeName) - 1] = '\0';
- attribute.m_location = m_funcs->glGetAttribLocation(programId, attributeName);
- attribute.m_name = QString::fromUtf8(attributeName, attributeNameLength);
- attributes.append(attribute);
- }
- return attributes;
-}
-
-QVector<ShaderUniformBlock> GraphicsHelperGL4::programUniformBlocks(GLuint programId)
-{
- QVector<ShaderUniformBlock> blocks;
- GLint nbrActiveUniformsBlocks = 0;
- m_funcs->glGetProgramInterfaceiv(programId, GL_UNIFORM_BLOCK, GL_ACTIVE_RESOURCES, &nbrActiveUniformsBlocks);
- blocks.reserve(nbrActiveUniformsBlocks);
- for (GLint i = 0; i < nbrActiveUniformsBlocks; ++i) {
- QByteArray uniformBlockName(256, '\0');
- GLsizei length = 0;
- ShaderUniformBlock uniformBlock;
- m_funcs->glGetProgramResourceName(programId, GL_UNIFORM_BLOCK, i, 256, &length, uniformBlockName.data());
- uniformBlock.m_name = QString::fromUtf8(uniformBlockName.left(length));
- uniformBlock.m_index = i;
- GLenum prop = GL_BUFFER_BINDING;
- m_funcs->glGetProgramResourceiv(programId, GL_UNIFORM_BLOCK, i, 1, &prop, 4, NULL, &uniformBlock.m_binding);
- prop = GL_BUFFER_DATA_SIZE;
- m_funcs->glGetProgramResourceiv(programId, GL_UNIFORM_BLOCK, i, 1, &prop, 4, NULL, &uniformBlock.m_size);
- prop = GL_NUM_ACTIVE_VARIABLES;
- m_funcs->glGetProgramResourceiv(programId, GL_UNIFORM_BLOCK, i, 1, &prop, 4, NULL, &uniformBlock.m_activeUniformsCount);
- blocks.append(uniformBlock);
- }
- return blocks;
-}
-
-QVector<ShaderStorageBlock> GraphicsHelperGL4::programShaderStorageBlocks(GLuint programId)
-{
- QVector<ShaderStorageBlock> blocks;
- GLint nbrActiveShaderStorageBlocks = 0;
- m_funcs->glGetProgramInterfaceiv(programId, GL_SHADER_STORAGE_BLOCK, GL_ACTIVE_RESOURCES, &nbrActiveShaderStorageBlocks);
- blocks.reserve(nbrActiveShaderStorageBlocks);
- for (GLint i = 0; i < nbrActiveShaderStorageBlocks; ++i) {
- QByteArray storageBlockName(256, '\0');
- GLsizei length = 0;
- ShaderStorageBlock storageBlock;
- m_funcs->glGetProgramResourceName(programId, GL_SHADER_STORAGE_BLOCK, i, 256, &length, storageBlockName.data());
- storageBlock.m_index = i;
- storageBlock.m_name = QString::fromUtf8(storageBlockName.left(length));
- GLenum prop = GL_BUFFER_BINDING;
- m_funcs->glGetProgramResourceiv(programId, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 4, NULL, &storageBlock.m_binding);
- prop = GL_BUFFER_DATA_SIZE;
- m_funcs->glGetProgramResourceiv(programId, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 4, NULL, &storageBlock.m_size);
- prop = GL_NUM_ACTIVE_VARIABLES;
- m_funcs->glGetProgramResourceiv(programId, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 4, NULL, &storageBlock.m_activeVariablesCount);
- blocks.push_back(storageBlock);
- }
- return blocks;
-}
-
-void GraphicsHelperGL4::vertexAttribDivisor(GLuint index, GLuint divisor)
-{
- m_funcs->glVertexAttribDivisor(index, divisor);
-}
-
-void GraphicsHelperGL4::vertexAttributePointer(GLenum shaderDataType,
- GLuint index,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const GLvoid *pointer)
-{
- switch (shaderDataType) {
- case GL_FLOAT:
- case GL_FLOAT_VEC2:
- case GL_FLOAT_VEC3:
- case GL_FLOAT_VEC4:
- case GL_FLOAT_MAT2:
- case GL_FLOAT_MAT2x3:
- case GL_FLOAT_MAT2x4:
- case GL_FLOAT_MAT3:
- case GL_FLOAT_MAT3x2:
- case GL_FLOAT_MAT3x4:
- case GL_FLOAT_MAT4x2:
- case GL_FLOAT_MAT4x3:
- case GL_FLOAT_MAT4:
- m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer);
- break;
-
- case GL_INT:
- case GL_INT_VEC2:
- case GL_INT_VEC3:
- case GL_INT_VEC4:
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_INT_VEC2:
- case GL_UNSIGNED_INT_VEC3:
- case GL_UNSIGNED_INT_VEC4:
- m_funcs->glVertexAttribIPointer(index, size, type, stride, pointer);
- break;
-
- case GL_DOUBLE:
- case GL_DOUBLE_VEC2:
- case GL_DOUBLE_VEC3:
- case GL_DOUBLE_VEC4:
- m_funcs->glVertexAttribLPointer(index, size, type, stride, pointer);
- break;
-
- default:
- qCWarning(Rendering) << "vertexAttribPointer: Unhandled type";
- Q_UNREACHABLE();
- }
-}
-
-void GraphicsHelperGL4::readBuffer(GLenum mode)
-{
- m_funcs->glReadBuffer(mode);
-}
-
-void GraphicsHelperGL4::drawBuffer(GLenum mode)
-{
- m_funcs->glDrawBuffer(mode);
-}
-
-void *GraphicsHelperGL4::fenceSync()
-{
- return m_funcs->glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
-}
-
-void GraphicsHelperGL4::clientWaitSync(void *sync, GLuint64 nanoSecTimeout)
-{
- qDebug() << Q_FUNC_INFO << sync << static_cast<GLsync>(sync);
- GLenum e = m_funcs->glClientWaitSync(static_cast<GLsync>(sync), GL_SYNC_FLUSH_COMMANDS_BIT, nanoSecTimeout);
- qDebug() << e;
-}
-
-void GraphicsHelperGL4::waitSync(void *sync)
-{
- m_funcs->glWaitSync(static_cast<GLsync>(sync), 0, GL_TIMEOUT_IGNORED);
-}
-
-bool GraphicsHelperGL4::wasSyncSignaled(void *sync)
-{
- GLint v = 0;
- m_funcs->glGetSynciv(static_cast<GLsync>(sync),
- GL_SYNC_STATUS,
- sizeof(v),
- nullptr,
- &v);
- return v == GL_SIGNALED;
-}
-
-void GraphicsHelperGL4::deleteSync(void *sync)
-{
- m_funcs->glDeleteSync(static_cast<GLsync>(sync));
-}
-
-void GraphicsHelperGL4::rasterMode(GLenum faceMode, GLenum rasterMode)
-{
- m_funcs->glPolygonMode(faceMode, rasterMode);
-}
-
-void GraphicsHelperGL4::glUniform1fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform1fv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform2fv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform3fv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniform4fv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform1iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform1iv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform2iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform2iv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform3iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform3iv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform4iv(GLint location, GLsizei count, const GLint *values)
-{
- m_funcs->glUniform4iv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform1uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform1uiv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform2uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform2uiv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform3uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform3uiv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniform4uiv(GLint location, GLsizei count, const GLuint *values)
-{
- m_funcs->glUniform4uiv(location, count, values);
-}
-
-void GraphicsHelperGL4::glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL4::glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3fv(location, count, false, values);
-}
-
-void GraphicsHelperGL4::glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL4::glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2x3fv(location, count, false, values);
-}
-
-void GraphicsHelperGL4::glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3x2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL4::glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix2x4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL4::glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4x2fv(location, count, false, values);
-}
-
-void GraphicsHelperGL4::glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix3x4fv(location, count, false, values);
-}
-
-void GraphicsHelperGL4::glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *values)
-{
- m_funcs->glUniformMatrix4x3fv(location, count, false, values);
-}
-
-UniformType GraphicsHelperGL4::uniformTypeFromGLType(GLenum type)
-{
- switch (type) {
- case GL_FLOAT:
- return UniformType::Float;
- case GL_FLOAT_VEC2:
- return UniformType::Vec2;
- case GL_FLOAT_VEC3:
- return UniformType::Vec3;
- case GL_FLOAT_VEC4:
- return UniformType::Vec4;
- case GL_FLOAT_MAT2:
- return UniformType::Mat2;
- case GL_FLOAT_MAT3:
- return UniformType::Mat3;
- case GL_FLOAT_MAT4:
- return UniformType::Mat4;
- case GL_FLOAT_MAT2x3:
- return UniformType::Mat2x3;
- case GL_FLOAT_MAT3x2:
- return UniformType::Mat3x2;
- case GL_FLOAT_MAT2x4:
- return UniformType::Mat2x4;
- case GL_FLOAT_MAT4x2:
- return UniformType::Mat4x2;
- case GL_FLOAT_MAT3x4:
- return UniformType::Mat3x4;
- case GL_FLOAT_MAT4x3:
- return UniformType::Mat4x3;
- case GL_INT:
- return UniformType::Int;
- case GL_INT_VEC2:
- return UniformType::IVec2;
- case GL_INT_VEC3:
- return UniformType::IVec3;
- case GL_INT_VEC4:
- return UniformType::IVec4;
- case GL_UNSIGNED_INT:
- return UniformType::UInt;
- case GL_UNSIGNED_INT_VEC2:
- return UniformType::UIVec2;
- case GL_UNSIGNED_INT_VEC3:
- return UniformType::UIVec3;
- case GL_UNSIGNED_INT_VEC4:
- return UniformType::UIVec4;
- case GL_BOOL:
- return UniformType::Bool;
- case GL_BOOL_VEC2:
- return UniformType::BVec2;
- case GL_BOOL_VEC3:
- return UniformType::BVec3;
- case GL_BOOL_VEC4:
- return UniformType::BVec4;
-
- case GL_SAMPLER_1D:
- case GL_SAMPLER_1D_ARRAY:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_2D_RECT:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_2D_RECT_SHADOW:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_CUBE_MAP_ARRAY:
- case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
- case GL_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_1D:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
- case GL_INT_SAMPLER_1D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_1D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
- return UniformType::Sampler;
-
- case GL_IMAGE_1D:
- case GL_IMAGE_2D:
- case GL_IMAGE_3D:
- case GL_IMAGE_2D_RECT:
- case GL_IMAGE_CUBE:
- case GL_IMAGE_BUFFER:
- case GL_IMAGE_1D_ARRAY:
- case GL_IMAGE_2D_ARRAY:
- case GL_IMAGE_CUBE_MAP_ARRAY:
- case GL_IMAGE_2D_MULTISAMPLE:
- case GL_IMAGE_2D_MULTISAMPLE_ARRAY:
- case GL_INT_IMAGE_1D:
- case GL_INT_IMAGE_2D:
- case GL_INT_IMAGE_3D:
- case GL_INT_IMAGE_2D_RECT:
- case GL_INT_IMAGE_CUBE:
- case GL_INT_IMAGE_BUFFER:
- case GL_INT_IMAGE_1D_ARRAY:
- case GL_INT_IMAGE_2D_ARRAY:
- case GL_INT_IMAGE_CUBE_MAP_ARRAY:
- case GL_INT_IMAGE_2D_MULTISAMPLE:
- case GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_1D:
- case GL_UNSIGNED_INT_IMAGE_2D:
- case GL_UNSIGNED_INT_IMAGE_3D:
- case GL_UNSIGNED_INT_IMAGE_2D_RECT:
- case GL_UNSIGNED_INT_IMAGE_CUBE:
- case GL_UNSIGNED_INT_IMAGE_BUFFER:
- case GL_UNSIGNED_INT_IMAGE_1D_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY:
- return UniformType::Image;
-
- default:
- // TO DO: Add support for Doubles and Images
- Q_UNREACHABLE();
- return UniformType::Float;
- }
-}
-
-void GraphicsHelperGL4::blendEquation(GLenum mode)
-{
- m_funcs->glBlendEquation(mode);
-}
-
-void GraphicsHelperGL4::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
-{
- m_funcs->glBlendFunci(buf, sfactor, dfactor);
-}
-
-void GraphicsHelperGL4::blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha)
-{
- m_funcs->glBlendFuncSeparatei(buf, sRGB, dRGB, sAlpha, dAlpha);
-}
-
-void GraphicsHelperGL4::alphaTest(GLenum, GLenum)
-{
- qCWarning(Rendering) << "AlphaTest not available with OpenGL 3.2 core";
-}
-
-void GraphicsHelperGL4::depthTest(GLenum mode)
-{
- m_funcs->glEnable(GL_DEPTH_TEST);
- m_funcs->glDepthFunc(mode);
-}
-
-void GraphicsHelperGL4::depthMask(GLenum mode)
-{
- m_funcs->glDepthMask(mode);
-}
-
-void GraphicsHelperGL4::depthRange(GLdouble nearValue, GLdouble farValue)
-{
- m_funcs->glDepthRange(nearValue, farValue);
-}
-
-void GraphicsHelperGL4::frontFace(GLenum mode)
-{
- m_funcs->glFrontFace(mode);
-
-}
-
-void GraphicsHelperGL4::setMSAAEnabled(bool enabled)
-{
- enabled ? m_funcs->glEnable(GL_MULTISAMPLE)
- : m_funcs->glDisable(GL_MULTISAMPLE);
-}
-
-void GraphicsHelperGL4::setAlphaCoverageEnabled(bool enabled)
-{
- enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
- : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-GLuint GraphicsHelperGL4::createFrameBufferObject()
-{
- GLuint id;
- m_funcs->glGenFramebuffers(1, &id);
- return id;
-}
-
-void GraphicsHelperGL4::releaseFrameBufferObject(GLuint frameBufferId)
-{
- m_funcs->glDeleteFramebuffers(1, &frameBufferId);
-}
-
-void GraphicsHelperGL4::bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode)
-{
- switch (mode) {
- case FBODraw:
- m_funcs->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferId);
- return;
- case FBORead:
- m_funcs->glBindFramebuffer(GL_READ_FRAMEBUFFER, frameBufferId);
- return;
- case FBOReadAndDraw:
- default:
- m_funcs->glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
- return;
- }
-}
-
-void GraphicsHelperGL4::bindImageTexture(GLuint imageUnit, GLuint texture,
- GLint mipLevel, GLboolean layered,
- GLint layer, GLenum access, GLenum format)
-{
- m_funcs->glBindImageTexture(imageUnit,
- texture,
- mipLevel,
- layered,
- layer,
- access,
- format);
-}
-
-GLuint GraphicsHelperGL4::boundFrameBufferObject()
-{
- GLint id = 0;
- m_funcs->glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &id);
- return id;
-}
-
-bool GraphicsHelperGL4::checkFrameBufferComplete()
-{
- return (m_funcs->glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
-}
-
-bool GraphicsHelperGL4::frameBufferNeedsRenderBuffer(const Attachment &attachment)
-{
- Q_UNUSED(attachment);
- return false;
-}
-
-void GraphicsHelperGL4::bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment)
-{
- GLenum attr = GL_DEPTH_STENCIL_ATTACHMENT;
-
- if (attachment.m_point <= QRenderTargetOutput::Color15)
- attr = GL_COLOR_ATTACHMENT0 + attachment.m_point;
- else if (attachment.m_point == QRenderTargetOutput::Depth)
- attr = GL_DEPTH_ATTACHMENT;
- else if (attachment.m_point == QRenderTargetOutput::Stencil)
- attr = GL_STENCIL_ATTACHMENT;
-
- texture->bind();
- QOpenGLTexture::Target target = texture->target();
- if (target == QOpenGLTexture::Target1DArray || target == QOpenGLTexture::Target2DArray ||
- target == QOpenGLTexture::Target2DMultisampleArray || target == QOpenGLTexture::Target3D)
- m_funcs->glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, attr, texture->textureId(), attachment.m_mipLevel, attachment.m_layer);
- else if (target == QOpenGLTexture::TargetCubeMapArray)
- m_funcs->glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel, attachment.m_layer);
- else if (target == QOpenGLTexture::TargetCubeMap && attachment.m_face != QAbstractTexture::AllFaces)
- m_funcs->glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attr, attachment.m_face, texture->textureId(), attachment.m_mipLevel);
- else
- m_funcs->glFramebufferTexture(GL_DRAW_FRAMEBUFFER, attr, texture->textureId(), attachment.m_mipLevel);
- texture->release();
-}
-
-void GraphicsHelperGL4::bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment)
-{
- Q_UNUSED(renderBuffer);
- Q_UNUSED(attachment);
- Q_UNREACHABLE();
-}
-
-bool GraphicsHelperGL4::supportsFeature(GraphicsHelperInterface::Feature feature) const
-{
- switch (feature) {
- case MRT:
- case Tessellation:
- case UniformBufferObject:
- case BindableFragmentOutputs:
- case PrimitiveRestart:
- case RenderBufferDimensionRetrieval:
- case TextureDimensionRetrieval:
- case ShaderStorageObject:
- case Compute:
- case DrawBuffersBlend:
- case BlitFramebuffer:
- case IndirectDrawing:
- case MapBuffer:
- case Fences:
- case ShaderImage:
- return true;
- default:
- return false;
- }
-}
-
-void GraphicsHelperGL4::drawBuffers(GLsizei n, const int *bufs)
-{
- // Use QVarLengthArray here
- QVarLengthArray<GLenum, 16> drawBufs(n);
-
- for (int i = 0; i < n; i++)
- drawBufs[i] = GL_COLOR_ATTACHMENT0 + bufs[i];
- m_funcs->glDrawBuffers(n, drawBufs.constData());
-}
-
-void GraphicsHelperGL4::bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs)
-{
- for (auto it = outputs.begin(), end = outputs.end(); it != end; ++it)
- m_funcs->glBindFragDataLocation(shader, it.value(), it.key().toStdString().c_str());
-}
-
-void GraphicsHelperGL4::bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
-{
- m_funcs->glUniformBlockBinding(programId, uniformBlockIndex, uniformBlockBinding);
-}
-
-void GraphicsHelperGL4::bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding)
-{
- m_funcs->glShaderStorageBlockBinding(programId, shaderStorageBlockIndex, shaderStorageBlockBinding);
-}
-
-void GraphicsHelperGL4::bindBufferBase(GLenum target, GLuint index, GLuint buffer)
-{
- m_funcs->glBindBufferBase(target, index, buffer);
-}
-
-void GraphicsHelperGL4::buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer)
-{
- char *bufferData = buffer.data();
-
- switch (description.m_type) {
-
- case GL_FLOAT: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_FLOAT_VEC2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_FLOAT_VEC3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_FLOAT_VEC4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_FLOAT_MAT2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 4);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 2);
- break;
- }
-
- case GL_FLOAT_MAT2x3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 6);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 3);
- break;
- }
-
- case GL_FLOAT_MAT2x4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 8);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 2, 4);
- break;
- }
-
- case GL_FLOAT_MAT3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 9);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 3);
- break;
- }
-
- case GL_FLOAT_MAT3x2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 6);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 2);
- break;
- }
-
- case GL_FLOAT_MAT3x4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 12);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 3, 4);
- break;
- }
-
- case GL_FLOAT_MAT4: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 16);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 4);
- break;
- }
-
- case GL_FLOAT_MAT4x2: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 8);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 2);
- break;
- }
-
- case GL_FLOAT_MAT4x3: {
- const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, description.m_size, 12);
- QGraphicsUtils::fillDataMatrixArray(bufferData, data, description, 4, 3);
- break;
- }
-
- case GL_INT: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_INT_VEC2: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_INT_VEC3: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_INT_VEC4: {
- const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_UNSIGNED_INT: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC2: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC3: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_UNSIGNED_INT_VEC4: {
- const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_BOOL: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 1);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 1);
- break;
- }
-
- case GL_BOOL_VEC2: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 2);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 2);
- break;
- }
-
- case GL_BOOL_VEC3: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 3);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 3);
- break;
- }
-
- case GL_BOOL_VEC4: {
- const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, description.m_size, 4);
- QGraphicsUtils::fillDataArray(bufferData, data, description, 4);
- break;
- }
-
- case GL_SAMPLER_1D:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_BUFFER:
- case GL_SAMPLER_2D_RECT:
- case GL_INT_SAMPLER_1D:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_2D_RECT:
- case GL_UNSIGNED_INT_SAMPLER_1D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_1D_ARRAY:
- case GL_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_1D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_1D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_RECT_SHADOW:
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_IMAGE_1D:
- case GL_IMAGE_2D:
- case GL_IMAGE_3D:
- case GL_IMAGE_2D_RECT:
- case GL_IMAGE_CUBE:
- case GL_IMAGE_BUFFER:
- case GL_IMAGE_1D_ARRAY:
- case GL_IMAGE_2D_ARRAY:
- case GL_IMAGE_CUBE_MAP_ARRAY:
- case GL_IMAGE_2D_MULTISAMPLE:
- case GL_IMAGE_2D_MULTISAMPLE_ARRAY:
- case GL_INT_IMAGE_1D:
- case GL_INT_IMAGE_2D:
- case GL_INT_IMAGE_3D:
- case GL_INT_IMAGE_2D_RECT:
- case GL_INT_IMAGE_CUBE:
- case GL_INT_IMAGE_BUFFER:
- case GL_INT_IMAGE_1D_ARRAY:
- case GL_INT_IMAGE_2D_ARRAY:
- case GL_INT_IMAGE_CUBE_MAP_ARRAY:
- case GL_INT_IMAGE_2D_MULTISAMPLE:
- case GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_1D:
- case GL_UNSIGNED_INT_IMAGE_2D:
- case GL_UNSIGNED_INT_IMAGE_3D:
- case GL_UNSIGNED_INT_IMAGE_2D_RECT:
- case GL_UNSIGNED_INT_IMAGE_CUBE:
- case GL_UNSIGNED_INT_IMAGE_BUFFER:
- case GL_UNSIGNED_INT_IMAGE_1D_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY: {
- Q_ASSERT(description.m_size == 1);
- int value = v.toInt();
- QGraphicsUtils::fillDataArray<GLint>(bufferData, &value, description, 1);
- break;
- }
-
- default:
- qWarning() << Q_FUNC_INFO << "unsupported uniform type:" << description.m_type << "for " << description.m_name;
- break;
- }
-}
-
-uint GraphicsHelperGL4::uniformByteSize(const ShaderUniform &description)
-{
- uint rawByteSize = 0;
- int arrayStride = qMax(description.m_arrayStride, 0);
- int matrixStride = qMax(description.m_matrixStride, 0);
-
- switch (description.m_type) {
-
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- case GL_UNSIGNED_INT_VEC2:
- rawByteSize = 8;
- break;
-
- case GL_FLOAT_VEC3:
- case GL_INT_VEC3:
- case GL_UNSIGNED_INT_VEC3:
- rawByteSize = 12;
- break;
-
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- case GL_UNSIGNED_INT_VEC4:
- rawByteSize = 16;
- break;
-
- case GL_FLOAT_MAT2:
- rawByteSize = matrixStride ? 2 * matrixStride : 16;
- break;
-
- case GL_FLOAT_MAT2x4:
- rawByteSize = matrixStride ? 2 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT4x2:
- rawByteSize = matrixStride ? 4 * matrixStride : 32;
- break;
-
- case GL_FLOAT_MAT3:
- rawByteSize = matrixStride ? 3 * matrixStride : 36;
- break;
-
- case GL_FLOAT_MAT2x3:
- rawByteSize = matrixStride ? 2 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT3x2:
- rawByteSize = matrixStride ? 3 * matrixStride : 24;
- break;
-
- case GL_FLOAT_MAT4:
- rawByteSize = matrixStride ? 4 * matrixStride : 64;
- break;
-
- case GL_FLOAT_MAT4x3:
- rawByteSize = matrixStride ? 4 * matrixStride : 48;
- break;
-
- case GL_FLOAT_MAT3x4:
- rawByteSize = matrixStride ? 3 * matrixStride : 48;
- break;
-
- case GL_BOOL:
- rawByteSize = 1;
- break;
-
- case GL_BOOL_VEC2:
- rawByteSize = 2;
- break;
-
- case GL_BOOL_VEC3:
- rawByteSize = 3;
- break;
-
- case GL_BOOL_VEC4:
- rawByteSize = 4;
- break;
-
- case GL_INT:
- case GL_FLOAT:
- case GL_UNSIGNED_INT:
- case GL_SAMPLER_1D:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_3D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_BUFFER:
- case GL_SAMPLER_2D_RECT:
- case GL_INT_SAMPLER_1D:
- case GL_INT_SAMPLER_2D:
- case GL_INT_SAMPLER_3D:
- case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_2D_RECT:
- case GL_UNSIGNED_INT_SAMPLER_1D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_2D_SHADOW:
- case GL_SAMPLER_CUBE_SHADOW:
- case GL_SAMPLER_1D_ARRAY:
- case GL_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_1D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_1D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_SAMPLER_2D_RECT_SHADOW:
- case GL_SAMPLER_2D_MULTISAMPLE:
- case GL_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
- case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
- case GL_IMAGE_1D:
- case GL_IMAGE_2D:
- case GL_IMAGE_3D:
- case GL_IMAGE_2D_RECT:
- case GL_IMAGE_CUBE:
- case GL_IMAGE_BUFFER:
- case GL_IMAGE_1D_ARRAY:
- case GL_IMAGE_2D_ARRAY:
- case GL_IMAGE_CUBE_MAP_ARRAY:
- case GL_IMAGE_2D_MULTISAMPLE:
- case GL_IMAGE_2D_MULTISAMPLE_ARRAY:
- case GL_INT_IMAGE_1D:
- case GL_INT_IMAGE_2D:
- case GL_INT_IMAGE_3D:
- case GL_INT_IMAGE_2D_RECT:
- case GL_INT_IMAGE_CUBE:
- case GL_INT_IMAGE_BUFFER:
- case GL_INT_IMAGE_1D_ARRAY:
- case GL_INT_IMAGE_2D_ARRAY:
- case GL_INT_IMAGE_CUBE_MAP_ARRAY:
- case GL_INT_IMAGE_2D_MULTISAMPLE:
- case GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_1D:
- case GL_UNSIGNED_INT_IMAGE_2D:
- case GL_UNSIGNED_INT_IMAGE_3D:
- case GL_UNSIGNED_INT_IMAGE_2D_RECT:
- case GL_UNSIGNED_INT_IMAGE_CUBE:
- case GL_UNSIGNED_INT_IMAGE_BUFFER:
- case GL_UNSIGNED_INT_IMAGE_1D_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE:
- case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY:
- rawByteSize = 4;
- break;
-
- default: {
- qWarning() << Q_FUNC_INFO << "unable to deduce rawByteSize for uniform type:" << description.m_type << "for uniform" << description.m_name;
- break;
- }
-
- }
-
- return arrayStride ? rawByteSize * arrayStride : rawByteSize;
-}
-
-void GraphicsHelperGL4::enableClipPlane(int clipPlane)
-{
- m_funcs->glEnable(GL_CLIP_DISTANCE0 + clipPlane);
-}
-
-void GraphicsHelperGL4::disableClipPlane(int clipPlane)
-{
- m_funcs->glDisable(GL_CLIP_DISTANCE0 + clipPlane);
-}
-
-void GraphicsHelperGL4::setClipPlane(int, const QVector3D &, float)
-{
- // deprecated
-}
-
-GLint GraphicsHelperGL4::maxClipPlaneCount()
-{
- GLint max = 0;
- m_funcs->glGetIntegerv(GL_MAX_CLIP_DISTANCES, &max);
- return max;
-}
-
-void GraphicsHelperGL4::memoryBarrier(QMemoryBarrier::Operations barriers)
-{
- m_funcs->glMemoryBarrier(memoryBarrierGLBitfield(barriers));
-}
-
-void GraphicsHelperGL4::enablePrimitiveRestart(int primitiveRestartIndex)
-{
- m_funcs->glPrimitiveRestartIndex(primitiveRestartIndex);
- m_funcs->glEnable(GL_PRIMITIVE_RESTART);
-}
-
-void GraphicsHelperGL4::enableVertexAttributeArray(int location)
-{
- m_funcs->glEnableVertexAttribArray(location);
-}
-
-void GraphicsHelperGL4::disablePrimitiveRestart()
-{
- m_funcs->glDisable(GL_PRIMITIVE_RESTART);
-}
-
-void GraphicsHelperGL4::clearBufferf(GLint drawbuffer, const QVector4D &values)
-{
- GLfloat vec[4] = {values[0], values[1], values[2], values[3]};
- m_funcs->glClearBufferfv(GL_COLOR, drawbuffer, vec);
-}
-
-void GraphicsHelperGL4::pointSize(bool programmable, GLfloat value)
-{
- if (programmable) {
- m_funcs->glEnable(GL_PROGRAM_POINT_SIZE);
- } else {
- m_funcs->glDisable(GL_PROGRAM_POINT_SIZE);
- m_funcs->glPointSize(value);
- }
-}
-
-void GraphicsHelperGL4::enablei(GLenum cap, GLuint index)
-{
- m_funcs->glEnablei(cap, index);
-}
-
-void GraphicsHelperGL4::disablei(GLenum cap, GLuint index)
-{
- m_funcs->glDisablei(cap, index);
-}
-
-void GraphicsHelperGL4::setSeamlessCubemap(bool enable)
-{
- if (enable)
- m_funcs->glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
- else
- m_funcs->glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
-}
-
-QSize GraphicsHelperGL4::getRenderBufferDimensions(GLuint renderBufferId)
-{
- GLint width = 0;
- GLint height = 0;
-
- m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, renderBufferId);
- m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
- m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
- m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, 0);
-
- return QSize(width, height);
-}
-
-QSize GraphicsHelperGL4::getTextureDimensions(GLuint textureId, GLenum target, uint level)
-{
- GLint width = 0;
- GLint height = 0;
-
- m_funcs->glBindTexture(target, textureId);
- m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
- m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
- m_funcs->glBindTexture(target, 0);
-
- return QSize(width, height);
-}
-
-void GraphicsHelperGL4::dispatchCompute(GLuint wx, GLuint wy, GLuint wz)
-{
- m_funcs->glDispatchCompute(wx, wy, wz);
-}
-
-char *GraphicsHelperGL4::mapBuffer(GLenum target, GLsizeiptr size)
-{
- return static_cast<char*>(m_funcs->glMapBufferRange(target, 0, size, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT));
-}
-
-GLboolean GraphicsHelperGL4::unmapBuffer(GLenum target)
-{
- return m_funcs->glUnmapBuffer(target);
-}
-
-void GraphicsHelperGL4::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
-{
- m_funcs->glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-}
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // !QT_OPENGL_ES_2
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl4_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl4_p.h
deleted file mode 100644
index e7d16410d..000000000
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpergl4_p.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL4_H
-#define QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL4_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <graphicshelperinterface_p.h>
-#include <QtCore/qscopedpointer.h>
-
-#ifndef QT_OPENGL_ES_2
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLFunctions_4_3_Core;
-
-namespace Qt3DRender {
-namespace Render {
-namespace Rhi {
-
-class Q_AUTOTEST_EXPORT GraphicsHelperGL4 : public GraphicsHelperInterface
-{
-public:
- GraphicsHelperGL4();
-
- // QGraphicHelperInterface interface
- void alphaTest(GLenum mode1, GLenum mode2) override;
- void bindBufferBase(GLenum target, GLuint index, GLuint buffer) override;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) override;
- bool frameBufferNeedsRenderBuffer(const Attachment &attachment) override;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) override;
- void bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment) override;
- void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) override;
- void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) override;
- void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) override;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override;
- void blendEquation(GLenum mode) override;
- void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) override;
- void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha) override;
- void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override;
- GLuint boundFrameBufferObject() override;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) override;
- bool checkFrameBufferComplete() override;
- void clearBufferf(GLint drawbuffer, const QVector4D &values) override;
- GLuint createFrameBufferObject() override;
- void depthMask(GLenum mode) override;
- void depthRange(GLdouble nearValue, GLdouble farValue) override;
- void depthTest(GLenum mode) override;
- void disableClipPlane(int clipPlane) override;
- void disablei(GLenum cap, GLuint index) override;
- void disablePrimitiveRestart() override;
- void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) override;
- char *mapBuffer(GLenum target, GLsizeiptr size) override;
- GLboolean unmapBuffer(GLenum target) override;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) override;
- void drawArraysIndirect(GLenum mode,void *indirect) override;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) override;
- void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) override;
- void drawBuffers(GLsizei n, const int *bufs) override;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) override;
- void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) override;
- void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) override;
- void enableClipPlane(int clipPlane) override;
- void enablei(GLenum cap, GLuint index) override;
- void enablePrimitiveRestart(int primitiveRestartIndex) override;
- void enableVertexAttributeArray(int location) override;
- void frontFace(GLenum mode) override;
- QSize getRenderBufferDimensions(GLuint renderBufferId) override;
- QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) override;
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) override;
- void pointSize(bool programmable, GLfloat value) override;
- GLint maxClipPlaneCount() override;
- void memoryBarrier(QMemoryBarrier::Operations barriers) override;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) override;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) override;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) override;
- QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) override;
- void releaseFrameBufferObject(GLuint frameBufferId) override;
- void setMSAAEnabled(bool enable) override;
- void setAlphaCoverageEnabled(bool enable) override;
- void setClipPlane(int clipPlane, const QVector3D &normal, float distance) override;
- void setSeamlessCubemap(bool enable) override;
- void setVerticesPerPatch(GLint verticesPerPatch) override;
- bool supportsFeature(Feature feature) const override;
- uint uniformByteSize(const ShaderUniform &description) override;
- void useProgram(GLuint programId) override;
- void vertexAttribDivisor(GLuint index, GLuint divisor) override;
- void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) override;
- void readBuffer(GLenum mode) override;
- void drawBuffer(GLenum mode) override;
- void rasterMode(GLenum faceMode, GLenum rasterMode) override;
-
- void *fenceSync() override;
- void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
- void waitSync(void *sync) override;
- bool wasSyncSignaled(void *sync) override;
- void deleteSync(void *sync) override;
-
- void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- void glUniform1iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform2iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform3iv(GLint location, GLsizei count, const GLint *value) override;
- void glUniform4iv(GLint location, GLsizei count, const GLint *value) override;
-
- void glUniform1uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform2uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform3uiv(GLint location, GLsizei count, const GLuint *value) override;
- void glUniform4uiv(GLint location, GLsizei count, const GLuint *value) override;
-
- void glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *value) override;
- void glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *value) override;
-
- UniformType uniformTypeFromGLType(GLenum glType) override;
-
-private:
- QOpenGLFunctions_4_3_Core *m_funcs;
-};
-
-} // namespace Rhi
-} // namespace Render
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // !QT_OPENGL_ES_2
-
-#endif // QT3DRENDER_RENDER_RHI_GRAPHICSHELPERGL4_H
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperinterface_p.h b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperinterface_p.h
index 7b1b88d46..5be79ba4b 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelperinterface_p.h
+++ b/src/plugins/renderers/rhi/graphicshelpers/graphicshelperinterface_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
@@ -95,106 +95,6 @@ public:
FBORead,
FBOReadAndDraw
};
-
- virtual ~GraphicsHelperInterface() {}
- virtual void alphaTest(GLenum mode1, GLenum mode2) = 0;
- virtual void bindBufferBase(GLenum target, GLuint index, GLuint buffer) = 0;
- virtual void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) = 0;
- virtual bool frameBufferNeedsRenderBuffer(const Attachment &attachment) = 0;
- virtual void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) = 0;
- virtual void bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment) = 0;
- virtual void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) = 0;
- virtual void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) = 0;
- virtual void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) = 0;
- virtual void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0;
- virtual void blendEquation(GLenum mode) = 0;
- virtual void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) = 0;
- virtual void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha) = 0;
- virtual void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = 0;
- virtual GLuint boundFrameBufferObject() = 0;
- virtual void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) = 0;
- virtual bool checkFrameBufferComplete() = 0;
- virtual void clearBufferf(GLint drawbuffer, const QVector4D &values) = 0;
- virtual GLuint createFrameBufferObject() = 0;
- virtual void depthRange(GLdouble nearValue, GLdouble farValue) = 0;
- virtual void depthMask(GLenum mode) = 0;
- virtual void depthTest(GLenum mode) = 0;
- virtual void disableClipPlane(int clipPlane) = 0;
- virtual void disablei(GLenum cap, GLuint index) = 0;
- virtual void disablePrimitiveRestart() = 0;
- virtual void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) = 0;
- virtual char *mapBuffer(GLenum target, GLsizeiptr size) = 0;
- virtual GLboolean unmapBuffer(GLenum target) = 0;
- virtual void drawArrays(GLenum primitiveType, GLint first, GLsizei count) = 0;
- virtual void drawArraysIndirect(GLenum mode,void *indirect) = 0;
- virtual void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) = 0;
- virtual void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseinstance) = 0;
- virtual void drawBuffers(GLsizei n, const int *bufs) = 0;
- virtual void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex) = 0;
- virtual void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) = 0;
- virtual void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex, GLint baseInstance) = 0;
- virtual void enableClipPlane(int clipPlane) = 0;
- virtual void enablei(GLenum cap, GLuint index) = 0;
- virtual void enablePrimitiveRestart(int primitiveRestartIndex) = 0;
- virtual void enableVertexAttributeArray(int location) = 0;
- virtual void frontFace(GLenum mode) = 0;
- virtual QSize getRenderBufferDimensions(GLuint renderBufferId) = 0;
- virtual QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) = 0;
- virtual void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) = 0;
- virtual GLint maxClipPlaneCount() = 0;
- virtual void memoryBarrier(QMemoryBarrier::Operations barriers) = 0;
- virtual void pointSize(bool programmable, GLfloat value) = 0;
- virtual QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) = 0;
- virtual QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) = 0;
- virtual QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) = 0;
- virtual QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) = 0;
- virtual void releaseFrameBufferObject(GLuint frameBufferId) = 0;
- virtual void setAlphaCoverageEnabled(bool enable) = 0;
- virtual void setClipPlane(int clipPlane, const QVector3D &normal, float distance) = 0;
- virtual void setMSAAEnabled(bool enable) = 0;
- virtual void setSeamlessCubemap(bool enable) = 0;
- virtual void setVerticesPerPatch(GLint verticesPerPatch) = 0;
- virtual bool supportsFeature(Feature feature) const = 0;
- virtual uint uniformByteSize(const ShaderUniform &description) = 0;
- virtual void useProgram(GLuint programId) = 0;
- virtual void vertexAttribDivisor(GLuint index, GLuint divisor) = 0;
- virtual void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) = 0;
- virtual void readBuffer(GLenum mode) = 0;
- virtual void drawBuffer(GLenum mode) = 0;
- virtual void rasterMode(GLenum faceMode, GLenum rasterMode) = 0;
-
- virtual void *fenceSync() = 0;
- virtual void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) = 0;
- virtual void waitSync(void *sync) = 0;
- virtual bool wasSyncSignaled(void *sync) = 0;
- virtual void deleteSync(void *sync) = 0;
-
- virtual void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
-
- virtual void glUniform1iv(GLint location, GLsizei count, const GLint *value) = 0;
- virtual void glUniform2iv(GLint location, GLsizei count, const GLint *value) = 0;
- virtual void glUniform3iv(GLint location, GLsizei count, const GLint *value) = 0;
- virtual void glUniform4iv(GLint location, GLsizei count, const GLint *value) = 0;
-
- virtual void glUniform1uiv(GLint location, GLsizei count, const GLuint *value) = 0;
- virtual void glUniform2uiv(GLint location, GLsizei count, const GLuint *value) = 0;
- virtual void glUniform3uiv(GLint location, GLsizei count, const GLuint *value) = 0;
- virtual void glUniform4uiv(GLint location, GLsizei count, const GLuint *value) = 0;
-
- virtual void glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
- virtual void glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
-
- virtual UniformType uniformTypeFromGLType(GLenum glType) = 0;
};
} // namespace Rhi
diff --git a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpers.pri b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpers.pri
index 3cfa445ce..a97ef463d 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/graphicshelpers.pri
+++ b/src/plugins/renderers/rhi/graphicshelpers/graphicshelpers.pri
@@ -5,14 +5,6 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/graphicscontext_p.h \
$$PWD/graphicshelperinterface_p.h \
- $$PWD/graphicshelperes2_p.h \
- $$PWD/graphicshelperes3_p.h \
- $$PWD/graphicshelperes3_1_p.h \
- $$PWD/graphicshelperes3_2_p.h \
- $$PWD/graphicshelpergl2_p.h \
- $$PWD/graphicshelpergl3_3_p.h \
- $$PWD/graphicshelpergl4_p.h \
- $$PWD/graphicshelpergl3_2_p.h \
$$PWD/imagesubmissioncontext_p.h \
$$PWD/submissioncontext_p.h \
$$PWD/texturesubmissioncontext_p.h \
@@ -20,14 +12,6 @@ HEADERS += \
SOURCES += \
$$PWD/graphicscontext.cpp \
- $$PWD/graphicshelperes2.cpp \
- $$PWD/graphicshelperes3.cpp \
- $$PWD/graphicshelperes3_1.cpp \
- $$PWD/graphicshelperes3_2.cpp \
- $$PWD/graphicshelpergl2.cpp \
- $$PWD/graphicshelpergl3_3.cpp \
- $$PWD/graphicshelpergl4.cpp \
- $$PWD/graphicshelpergl3_2.cpp \
$$PWD/imagesubmissioncontext.cpp \
$$PWD/submissioncontext.cpp \
$$PWD/texturesubmissioncontext.cpp
diff --git a/src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext.cpp b/src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext.cpp
index f95b0f615..fbc0f1a4a 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext.cpp
+++ b/src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext_p.h b/src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext_p.h
index 35f8d50e7..40807592d 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext_p.h
+++ b/src/plugins/renderers/rhi/graphicshelpers/imagesubmissioncontext_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/graphicshelpers/qgraphicsutils_p.h b/src/plugins/renderers/rhi/graphicshelpers/qgraphicsutils_p.h
index 924b55d6f..dc444e08a 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/qgraphicsutils_p.h
+++ b/src/plugins/renderers/rhi/graphicshelpers/qgraphicsutils_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
index 23c1dcb33..1eca362cc 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
+++ b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
@@ -66,35 +66,12 @@
#include <openglvertexarrayobject_p.h>
#include <QOpenGLShaderProgram>
-#if !defined(QT_OPENGL_ES_2)
-#include <QOpenGLFunctions_2_0>
-#include <QOpenGLFunctions_3_2_Core>
-#include <QOpenGLFunctions_3_3_Core>
-#include <QOpenGLFunctions_4_3_Core>
-#include <graphicshelpergl2_p.h>
-#include <graphicshelpergl3_2_p.h>
-#include <graphicshelpergl3_3_p.h>
-#include <graphicshelpergl4_p.h>
-#endif
-#include <graphicshelperes2_p.h>
-#include <graphicshelperes3_p.h>
-
#include <private/qdebug_p.h>
#include <QSurface>
#include <QWindow>
-#include <QOpenGLTexture>
-#include <QOpenGLDebugLogger>
QT_BEGIN_NAMESPACE
-#ifndef GL_READ_FRAMEBUFFER
-#define GL_READ_FRAMEBUFFER 0x8CA8
-#endif
-
-#ifndef GL_DRAW_FRAMEBUFFER
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#endif
-
namespace Qt3DRender {
namespace Render {
namespace Rhi {
@@ -782,22 +759,12 @@ void SubmissionContext::setViewport(const QRectF &viewport, const QSize &surface
void SubmissionContext::releaseOpenGL()
{
m_renderBufferHash.clear();
-
- // Stop and destroy the OpenGL logger
- if (m_debugLogger) {
- m_debugLogger->stopLogging();
- m_debugLogger.reset(nullptr);
- }
-}
-
-// The OpenGLContext is not current on any surface at this point
-void SubmissionContext::setOpenGLContext(QOpenGLContext* ctx)
-{
RHI_UNIMPLEMENTED;
- //* Q_ASSERT(ctx);
- //*
- //* releaseOpenGL();
- //* m_gl = ctx;
+//* // Stop and destroy the OpenGL logger
+//* if (m_debugLogger) {
+//* m_debugLogger->stopLogging();
+//* m_debugLogger.reset(nullptr);
+//* }
}
// Called only from RenderThread
@@ -1334,8 +1301,9 @@ void SubmissionContext::enableAttribute(const VAOVertexAttribute &attr)
void SubmissionContext::disableAttribute(const SubmissionContext::VAOVertexAttribute &attr)
{
- QOpenGLShaderProgram *prog = activeShader();
- prog->disableAttributeArray(attr.location);
+ RHI_UNIMPLEMENTED;
+//* QOpenGLShaderProgram *prog = activeShader();
+//* prog->disableAttributeArray(attr.location);
}
// Note: needs to be called while VAO is bound
diff --git a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h
index de64aed74..ad5c6ae12 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h
+++ b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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/
**
@@ -100,7 +100,6 @@ public:
bool beginDrawing(QSurface *surface);
void endDrawing(bool swapBuffers);
void releaseOpenGL();
- void setOpenGLContext(QOpenGLContext* ctx);
// Viewport
void setViewport(const QRectF &viewport, const QSize &surfaceSize);
diff --git a/src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext.cpp b/src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext.cpp
index 38c1bc398..9151a9555 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext.cpp
+++ b/src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext_p.h b/src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext_p.h
index 44b37d80e..c35f4248e 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext_p.h
+++ b/src/plugins/renderers/rhi/graphicshelpers/texturesubmissioncontext_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/io/buffer.cpp b/src/plugins/renderers/rhi/io/buffer.cpp
index 697cf841a..cd790944b 100644
--- a/src/plugins/renderers/rhi/io/buffer.cpp
+++ b/src/plugins/renderers/rhi/io/buffer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
@@ -39,29 +39,6 @@
#include "buffer_p.h"
#include <graphicscontext_p.h>
-
-#if !defined(GL_UNIFORM_BUFFER)
-#define GL_UNIFORM_BUFFER 0x8A11
-#endif
-#if !defined(GL_ARRAY_BUFFER)
-#define GL_ARRAY_BUFFER 0x8892
-#endif
-#if !defined(GL_ELEMENT_ARRAY_BUFFER)
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#endif
-#if !defined(GL_SHADER_STORAGE_BUFFER)
-#define GL_SHADER_STORAGE_BUFFER 0x90D2
-#endif
-#if !defined(GL_PIXEL_PACK_BUFFER)
-#define GL_PIXEL_PACK_BUFFER 0x88EB
-#endif
-#if !defined(GL_PIXEL_UNPACK_BUFFER)
-#define GL_PIXEL_UNPACK_BUFFER 0x88EC
-#endif
-#if !defined(GL_DRAW_INDIRECT_BUFFER)
-#define GL_DRAW_INDIRECT_BUFFER 0x8F3F
-#endif
-
#include <QtGui/private/qrhi_p.h>
QT_BEGIN_NAMESPACE
@@ -74,20 +51,6 @@ namespace Rhi {
// A UBO is created for each ShaderData Shader Pair
// That means a UBO is unique to a shader/shaderdata
-namespace {
-
-GLenum glBufferTypes[] = {
- GL_ARRAY_BUFFER,
- GL_UNIFORM_BUFFER,
- GL_ELEMENT_ARRAY_BUFFER,
- GL_SHADER_STORAGE_BUFFER,
- GL_PIXEL_PACK_BUFFER,
- GL_PIXEL_UNPACK_BUFFER,
- GL_DRAW_INDIRECT_BUFFER
-};
-
-} // anonymous
-
RHIBuffer::RHIBuffer()
: m_bufferId(0)
, m_dynamic(true)
@@ -105,21 +68,23 @@ bool RHIBuffer::bind(GraphicsContext *ctx, Type t)
{
const auto kind = m_dynamic ? QRhiBuffer::Dynamic : QRhiBuffer::Static;
const auto usage = [&] {
- if(t == Type::ArrayBuffer) return QRhiBuffer::VertexBuffer;
- if(t == Type::IndexBuffer) return QRhiBuffer::IndexBuffer;
- if(t == Type::UniformBuffer) return QRhiBuffer::UniformBuffer;
- RHI_UNIMPLEMENTED;
- return QRhiBuffer::StorageBuffer;
+ switch(t) {
+ case Type::ArrayBuffer: return QRhiBuffer::VertexBuffer;
+ case Type::IndexBuffer: return QRhiBuffer::IndexBuffer;
+ case Type::UniformBuffer: return QRhiBuffer::UniformBuffer;
+ default:
+ RHI_UNIMPLEMENTED;
+ return QRhiBuffer::StorageBuffer;
+ }
}();
if(m_allocSize <= 0)
return false;
- if(m_rhiBuffer && m_rhiBuffer->type() != t)
+ if(m_rhiBuffer)
{
- m_rhiBuffer->release();
- delete m_rhiBuffer;
- m_rhiBuffer = nullptr;
+ // RHI does not seem to support using the same buffer with different types
+ assert(m_rhiBuffer->usage() == usage);
}
if(!m_rhiBuffer)
@@ -210,24 +175,28 @@ void RHIBuffer::update(GraphicsContext *ctx, const QByteArray& data, int offset)
QByteArray RHIBuffer::download(GraphicsContext *ctx, uint size)
{
- char *gpu_ptr = ctx->mapBuffer(m_lastTarget, size);
- QByteArray data;
- if (gpu_ptr != nullptr) {
- data.resize(size);
- std::copy(gpu_ptr, gpu_ptr+size, data.data());
- }
- ctx->unmapBuffer(m_lastTarget);
- return data;
+ RHI_UNIMPLEMENTED;
+ return {};
+//* char *gpu_ptr = ctx->mapBuffer(m_lastTarget, size);
+//* QByteArray data;
+//* if (gpu_ptr != nullptr) {
+//* data.resize(size);
+//* std::copy(gpu_ptr, gpu_ptr+size, data.data());
+//* }
+//* ctx->unmapBuffer(m_lastTarget);
+//* return data;
}
void RHIBuffer::bindBufferBase(GraphicsContext *ctx, int bindingPoint, RHIBuffer::Type t)
{
- ctx->bindBufferBase(glBufferTypes[t], bindingPoint, m_bufferId);
+ RHI_UNIMPLEMENTED;
+//* ctx->bindBufferBase(glBufferTypes[t], bindingPoint, m_bufferId);
}
void RHIBuffer::bindBufferBase(GraphicsContext *ctx, int bindingPoint)
{
- ctx->bindBufferBase(m_lastTarget, bindingPoint, m_bufferId);
+ RHI_UNIMPLEMENTED;
+//* ctx->bindBufferBase(m_lastTarget, bindingPoint, m_bufferId);
}
} // namespace Rhi
diff --git a/src/plugins/renderers/rhi/io/buffer_p.h b/src/plugins/renderers/rhi/io/buffer_p.h
index 43092d3e6..6be1f7f55 100644
--- a/src/plugins/renderers/rhi/io/buffer_p.h
+++ b/src/plugins/renderers/rhi/io/buffer_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp b/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp
index 466990b6a..649b67eb3 100644
--- a/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp
+++ b/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob_p.h b/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob_p.h
index 415b5d931..ec7c067fd 100644
--- a/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob_p.h
+++ b/src/plugins/renderers/rhi/jobs/filtercompatibletechniquejob_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/jobs/renderviewbuilderjob_p.h b/src/plugins/renderers/rhi/jobs/renderviewbuilderjob_p.h
index ffdb406f3..4231711de 100644
--- a/src/plugins/renderers/rhi/jobs/renderviewbuilderjob_p.h
+++ b/src/plugins/renderers/rhi/jobs/renderviewbuilderjob_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob.cpp b/src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob.cpp
index 2409573db..ee063bf77 100644
--- a/src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob.cpp
+++ b/src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob_p.h b/src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob_p.h
index 7107cb7f8..0832772d3 100644
--- a/src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob_p.h
+++ b/src/plugins/renderers/rhi/jobs/renderviewcommandbuilderjob_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/jobs/renderviewinitializerjob.cpp b/src/plugins/renderers/rhi/jobs/renderviewinitializerjob.cpp
index 973df8479..3af0d89cc 100644
--- a/src/plugins/renderers/rhi/jobs/renderviewinitializerjob.cpp
+++ b/src/plugins/renderers/rhi/jobs/renderviewinitializerjob.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
** Copyright (C) 2016 Paul Lemire
** Contact: https://www.qt.io/licensing/
**
diff --git a/src/plugins/renderers/rhi/jobs/renderviewinitializerjob_p.h b/src/plugins/renderers/rhi/jobs/renderviewinitializerjob_p.h
index afd9f4d14..d28b10a95 100644
--- a/src/plugins/renderers/rhi/jobs/renderviewinitializerjob_p.h
+++ b/src/plugins/renderers/rhi/jobs/renderviewinitializerjob_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 Paul Lemire
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp b/src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp
index 3c921c370..026f8dfb7 100644
--- a/src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp
+++ b/src/plugins/renderers/rhi/jobs/renderviewjobutils.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h b/src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h
index af2b12c0f..241737aef 100644
--- a/src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h
+++ b/src/plugins/renderers/rhi/jobs/renderviewjobutils_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/main.cpp b/src/plugins/renderers/rhi/main.cpp
index 9da9bd7da..b8d3e4890 100644
--- a/src/plugins/renderers/rhi/main.cpp
+++ b/src/plugins/renderers/rhi/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/managers/handle_types_p.h b/src/plugins/renderers/rhi/managers/handle_types_p.h
index 6fdf21658..9c4d6f87f 100644
--- a/src/plugins/renderers/rhi/managers/handle_types_p.h
+++ b/src/plugins/renderers/rhi/managers/handle_types_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/managers/resourcemanagers.cpp b/src/plugins/renderers/rhi/managers/resourcemanagers.cpp
index 936ef3e17..7e01aa394 100644
--- a/src/plugins/renderers/rhi/managers/resourcemanagers.cpp
+++ b/src/plugins/renderers/rhi/managers/resourcemanagers.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/managers/resourcemanagers_p.h b/src/plugins/renderers/rhi/managers/resourcemanagers_p.h
index ac713ca12..7d4a81e7d 100644
--- a/src/plugins/renderers/rhi/managers/resourcemanagers_p.h
+++ b/src/plugins/renderers/rhi/managers/resourcemanagers_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/fence_p.h b/src/plugins/renderers/rhi/renderer/fence_p.h
index 2581026d9..169e01914 100644
--- a/src/plugins/renderers/rhi/renderer/fence_p.h
+++ b/src/plugins/renderers/rhi/renderer/fence_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/logging.cpp b/src/plugins/renderers/rhi/renderer/logging.cpp
index 6a90c4a61..29bdb2145 100644
--- a/src/plugins/renderers/rhi/renderer/logging.cpp
+++ b/src/plugins/renderers/rhi/renderer/logging.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/logging_p.h b/src/plugins/renderers/rhi/renderer/logging_p.h
index f3f8d7068..45d63978d 100644
--- a/src/plugins/renderers/rhi/renderer/logging_p.h
+++ b/src/plugins/renderers/rhi/renderer/logging_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/openglvertexarrayobject.cpp b/src/plugins/renderers/rhi/renderer/openglvertexarrayobject.cpp
index 7aea905fc..afc205cf9 100644
--- a/src/plugins/renderers/rhi/renderer/openglvertexarrayobject.cpp
+++ b/src/plugins/renderers/rhi/renderer/openglvertexarrayobject.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
@@ -52,17 +52,12 @@ namespace Rhi {
RHIVertexArrayObject::RHIVertexArrayObject()
: m_ctx(nullptr)
, m_specified(false)
- , m_supportsVao(false)
{}
void RHIVertexArrayObject::bind()
{
Q_ASSERT(m_ctx);
- if (m_supportsVao) {
- Q_ASSERT(!m_vao.isNull());
- Q_ASSERT(m_vao->isCreated());
- m_vao->bind();
- } else {
+ {
// Unbind any other VAO that may have been bound and not released correctly
if (m_ctx->m_currentVAO != nullptr && m_ctx->m_currentVAO != this)
m_ctx->m_currentVAO->release();
@@ -80,11 +75,7 @@ void RHIVertexArrayObject::bind()
void RHIVertexArrayObject::release()
{
Q_ASSERT(m_ctx);
- if (m_supportsVao) {
- Q_ASSERT(!m_vao.isNull());
- Q_ASSERT(m_vao->isCreated());
- m_vao->release();
- } else {
+ {
if (m_ctx->m_currentVAO == this) {
for (const SubmissionContext::VAOVertexAttribute &attr : qAsConst(m_vertexAttributes))
m_ctx->disableAttribute(attr);
@@ -98,14 +89,10 @@ void RHIVertexArrayObject::create(SubmissionContext *ctx, const VAOIdentifier &k
{
QMutexLocker lock(&m_mutex);
- Q_ASSERT(!m_ctx && !m_vao);
+ Q_ASSERT(!m_ctx);
m_ctx = ctx;
- m_supportsVao = m_ctx->supportsVAO();
- if (m_supportsVao) {
- m_vao.reset(new QOpenGLVertexArrayObject());
- m_vao->create();
- }
+
m_owners = key;
}
@@ -125,10 +112,8 @@ void RHIVertexArrayObject::destroy()
void RHIVertexArrayObject::cleanup()
{
- m_vao.reset();
m_ctx = nullptr;
m_specified = false;
- m_supportsVao = false;
m_indexAttribute = SubmissionContext::VAOIndexAttribute();
m_vertexAttributes.clear();
}
diff --git a/src/plugins/renderers/rhi/renderer/openglvertexarrayobject_p.h b/src/plugins/renderers/rhi/renderer/openglvertexarrayobject_p.h
index 72e816f9b..a873d8d25 100644
--- a/src/plugins/renderers/rhi/renderer/openglvertexarrayobject_p.h
+++ b/src/plugins/renderers/rhi/renderer/openglvertexarrayobject_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
@@ -82,9 +82,6 @@ public:
bool isAbandoned(GeometryManager *geomMgr, RHIShaderManager *shaderMgr);
- QOpenGLVertexArrayObject *vao() { return m_vao.data(); }
- const QOpenGLVertexArrayObject *vao() const { return m_vao.data(); }
-
void setSpecified(bool b) { m_specified = b; }
bool isSpecified() const { return m_specified; }
@@ -92,9 +89,7 @@ public:
private:
QMutex m_mutex;
SubmissionContext *m_ctx;
- QScopedPointer<QOpenGLVertexArrayObject> m_vao;
bool m_specified;
- bool m_supportsVao;
VAOIdentifier m_owners;
friend class SubmissionContext;
diff --git a/src/plugins/renderers/rhi/renderer/rendercommand.cpp b/src/plugins/renderers/rhi/renderer/rendercommand.cpp
index 9a360c750..395eeab78 100644
--- a/src/plugins/renderers/rhi/renderer/rendercommand.cpp
+++ b/src/plugins/renderers/rhi/renderer/rendercommand.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/rendercommand_p.h b/src/plugins/renderers/rhi/renderer/rendercommand_p.h
index 25ffab3e6..baaf79f7c 100644
--- a/src/plugins/renderers/rhi/renderer/rendercommand_p.h
+++ b/src/plugins/renderers/rhi/renderer/rendercommand_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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/
**
@@ -106,8 +106,8 @@ public:
float m_depth;
int m_changeCost;
- QRhiShaderResourceBindings *srb = nullptr;
- QRhiGraphicsPipeline *ps = nullptr;
+ QRhiShaderResourceBindings *shaderResourceBindings = nullptr;
+ QRhiGraphicsPipeline *graphicsPipeline = nullptr;
enum CommandType {
Draw,
Compute
diff --git a/src/plugins/renderers/rhi/renderer/renderer.cpp b/src/plugins/renderers/rhi/renderer/renderer.cpp
index 0d588ef41..055b420bc 100644
--- a/src/plugins/renderers/rhi/renderer/renderer.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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/
**
@@ -535,7 +535,7 @@ void Renderer::initialize()
m_rp = m_sc->newCompatibleRenderPassDescriptor();
m_sc->setRenderPassDescriptor(m_rp);
}
-/*
+
// Awake setScenegraphRoot in case it was waiting
m_waitForInitializationToBeCompleted.release(1);
@@ -543,76 +543,10 @@ void Renderer::initialize()
m_vsyncFrameAdvanceService->proceedToNextFrame();
// Force initial refresh
- markDirty(AllDirty, nullptr);*/
- }
-
-
-
-
-
-
-
-
-
- /*
- QOpenGLContext* ctx = m_glContext;
-
- {
- // If we are using our own context (not provided by QtQuick),
- // we need to create it
- if (!m_glContext) {
- ctx = new QOpenGLContext;
- if (m_screen)
- ctx->setScreen(m_screen);
- ctx->setShareContext(qt_gl_global_share_context());
-
- // TO DO: Shouldn't we use the highest context available and trust
- // QOpenGLContext to fall back on the best lowest supported ?
- const QByteArray debugLoggingMode = qgetenv("QT3DRENDER_DEBUG_LOGGING");
-
- if (!debugLoggingMode.isEmpty()) {
- QSurfaceFormat sf = ctx->format();
- sf.setOption(QSurfaceFormat::DebugContext);
- ctx->setFormat(sf);
- }
-
- // Create OpenGL context<<<<<<< HEAD
-
- if (ctx->create())
- qCDebug(Backend) << "OpenGL context created with actual format" << ctx->format();
- else
- qCWarning(Backend) << Q_FUNC_INFO << "OpenGL context creation failed";
- m_ownedContext = true;
- } else {
- // Context is not owned by us, so we need to know if it gets destroyed
- m_contextConnection = QObject::connect(m_glContext, &QOpenGLContext::aboutToBeDestroyed,
- [this] { releaseGraphicsResources(); });
- }
-
- qCDebug(Backend) << "Qt3D shared context:" << ctx->shareContext();
- qCDebug(Backend) << "Qt global shared context:" << qt_gl_global_share_context();
-
- // Note: we don't have a surface at this point
- // The context will be made current later on (at render time)
- m_submissionContext->setOpenGLContext(ctx);
-
- // Store the format used by the context and queue up creating an
- // offscreen surface in the main thread so that it is available
- // for use when we want to shutdown the renderer. We need to create
- // the offscreen surface on the main thread because on some platforms
- // (MS Windows), an offscreen surface is just a hidden QWindow.
- m_format = ctx->format();
- QMetaObject::invokeMethod(m_offscreenHelper, "createOffscreenSurface");
+ markDirty(AllDirty, nullptr);
+ return;
}
- */
- // Awake setScenegraphRoot in case it was waiting
- m_waitForInitializationToBeCompleted.release(1);
- // Allow the aspect manager to proceed
- m_vsyncFrameAdvanceService->proceedToNextFrame();
-
- // Force initial refresh
- markDirty(AllDirty, nullptr);
}
/*!
@@ -905,7 +839,7 @@ void Renderer::doRender(bool swapBuffers)
beganDrawing = m_submissionContext->beginDrawing(surface);
if (beganDrawing) {
// 1) Execute commands for buffer uploads, texture updates, shader loading first
- updateGLResources();
+ updateResources();
// 2) Update VAO and copy data into commands to allow concurrent submission
prepareCommandsSubmission(renderViews);
preprocessingComplete = true;
@@ -1056,12 +990,8 @@ QSurfaceFormat Renderer::format()
{
return m_format;
}
-void Renderer::setupRHICommand(RenderCommand& cmd)
+void Renderer::setupDrawCommand(RenderCommand& cmd)
{
- auto shaders = cmd.m_glShader->shaderCode();
- if(shaders.empty())
- return;
-
// Create UBOs
auto standard_ubuf = m_r->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, sizeof(float) * 16);
standard_ubuf->build();
@@ -1074,8 +1004,12 @@ void Renderer::setupRHICommand(RenderCommand& cmd)
this->m_submissionContext->m_currentUpdates->updateDynamicBuffer(custom_ubuf, 0, sizeof(float), &f);
- cmd.srb = m_r->newShaderResourceBindings();
- cmd.srb->setBindings({
+ bool ok = true;
+
+ cmd.shaderResourceBindings = m_r->newShaderResourceBindings();
+ assert(cmd.shaderResourceBindings);
+
+ cmd.shaderResourceBindings->setBindings({
QRhiShaderResourceBinding::uniformBuffer(
0,
QRhiShaderResourceBinding::VertexStage | QRhiShaderResourceBinding::FragmentStage,
@@ -1085,54 +1019,47 @@ void Renderer::setupRHICommand(RenderCommand& cmd)
QRhiShaderResourceBinding::VertexStage | QRhiShaderResourceBinding::FragmentStage,
custom_ubuf),
});
- cmd.srb->build();
-
+ ok = cmd.shaderResourceBindings->build();
+ assert(ok);
// Create pipeline
- cmd.ps = m_r->newGraphicsPipeline();
- auto vert = shaders[0];
- auto frag = shaders[1];
- QShaderBaker b;
- b.setGeneratedShaders({
- {QShader::SpirvShader, 100},
- {QShader::GlslShader, 120}, // Only GLSL version supported by RHI right now.
- {QShader::HlslShader, 100},
- {QShader::MslShader, 100},
- });
- b.setGeneratedShaderVariants({QShader::Variant{},
- QShader::Variant{},
- QShader::Variant{},
- QShader::Variant{}});
-
- b.setSourceString(vert, QShader::VertexStage);
- auto vs = b.bake();
- if(b.errorMessage() != QString{})
- qDebug() << "Vertex Shader Error: " << b.errorMessage();
-
- b.setSourceString(frag, QShader::FragmentStage);
- auto fs = b.bake();
- if(b.errorMessage() != QString{})
- qDebug() << "Fragment Shader Error: " << b.errorMessage();
-
- cmd.ps->setShaderStages({
- { QRhiShaderStage::Vertex, vs },
- { QRhiShaderStage::Fragment, fs }
- });
+ cmd.graphicsPipeline = m_r->newGraphicsPipeline();
+ assert(cmd.graphicsPipeline);
- QRhiVertexInputLayout inputLayout;
- inputLayout.setBindings({
- { 3 * sizeof(float) }
- });
- inputLayout.setAttributes({
- { 0, 0, QRhiVertexInputAttribute::Float3, 0 },
- //{ 0, 1, QRhiVertexInputAttribute::Float4, 3 * sizeof(float) }
+ cmd.graphicsPipeline->setShaderStages({
+ { QRhiShaderStage::Vertex, cmd.m_glShader->shaderStage(QShader::VertexStage) },
+ { QRhiShaderStage::Fragment, cmd.m_glShader->shaderStage(QShader::FragmentStage) }
});
- cmd.ps->setVertexInputLayout(inputLayout);
- cmd.ps->setShaderResourceBindings(cmd.srb);
- cmd.ps->setRenderPassDescriptor(m_rp);
+ QRhiVertexInputLayout inputLayout = cmd.m_glShader->inputLayout();
+ QVarLengthArray<QRhiVertexInputBinding, 8> inputBindings;
+
+ const auto geom = cmd.m_geometry;
+ const auto& attributes = geom->attributes();
+ for(Qt3DCore::QNodeId attribute_id : attributes)
+ {
+ Attribute* attrib = m_nodesManager->attributeManager()->lookupResource(attribute_id);
+ if(attrib->attributeType() == QAttribute::VertexAttribute)
+ {
+ inputBindings.resize(std::max((std::size_t)inputBindings.size(), (std::size_t)attrib->location() + 1));
+ // TODO handle the other arguments to QRhiVertexInputBinding
+ inputBindings[attrib->location()] = QRhiVertexInputBinding{attrib->byteStride()};
+ }
+ }
+
+ inputLayout.setBindings(inputBindings.begin(), inputBindings.end());
+
+ cmd.graphicsPipeline->setVertexInputLayout(inputLayout);
+ cmd.graphicsPipeline->setShaderResourceBindings(cmd.shaderResourceBindings);
+ cmd.graphicsPipeline->setRenderPassDescriptor(m_rp);
+
+ ok = cmd.graphicsPipeline->build();
+ assert(ok);
+}
+
+void Renderer::setupComputeCommand(RenderCommand &command)
+{
- cmd.ps->build();
}
// When this function is called, we must not be processing the commands for frame n+1
@@ -1203,7 +1130,7 @@ void Renderer::prepareCommandsSubmission(const QVector<RenderView *> &renderView
// Prepare the ShaderParameterPack based on the active uniforms of the shader
shader->prepareUniforms(command.m_parameterPack);
- setupRHICommand(command);
+ setupDrawCommand(command);
} else if (command.m_type == RenderCommand::Compute) {
RHI_UNIMPLEMENTED;
@@ -1475,7 +1402,7 @@ void Renderer::sendDisablesToFrontend(Qt3DCore::QAspectManager *manager)
// may contain destruction changes targeting resources. When the above
// happens, this can result in the dirtyResource vectors containing handles of
// objects that may already have been destroyed
-void Renderer::updateGLResources()
+void Renderer::updateResources()
{
{
// Update active fence objects:
@@ -1918,11 +1845,14 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren
// lastBoundFBOId != m_graphicsContext->activeFBO() when the last FrameGraph leaf node/renderView
// contains RenderTargetSelector/RenderTarget
if (lastBoundFBOId != m_submissionContext->activeFBO())
- m_submissionContext->bindFramebuffer(lastBoundFBOId, GraphicsHelperInterface::FBOReadAndDraw);
+ {
+ RHI_UNIMPLEMENTED;
+//* m_submissionContext->bindFramebuffer(lastBoundFBOId, GraphicsHelperInterface::FBOReadAndDraw);
+ }
// Reset state and call doneCurrent if the surface
// is valid and was actually activated
- if (lastUsedSurface && m_submissionContext->hasValidGLHelper()) {
+ if (lastUsedSurface) {
// Reset state to the default state if the last stateset is not the
// defaultRenderStateSet
if (m_submissionContext->currentStateSet() != m_defaultRenderStateSet)
@@ -2391,14 +2321,22 @@ bool Renderer::prepareDraw(QRhiCommandBuffer *cb, const RenderView *rv, RenderCo
break;
}
}
+
+ for(const BlockToUBO& pack : command.m_parameterPack.uniformBuffers())
+ {
+ qDebug() << pack.m_bufferID;
+ Buffer *cpuBuffer = nodeManagers()->bufferManager()->lookupResource(pack.m_bufferID);
+ RHIBuffer *ubo = m_submissionContext->glBufferForRenderBuffer(cpuBuffer);
+ ubo->bind(&*m_submissionContext, RHIBuffer::UniformBuffer);
+ }
return true;
}
bool Renderer::performDraw(QRhiCommandBuffer *cb, const RenderView *rv, RenderCommand& command)
{
// Setup the rendering pass
- cb->setGraphicsPipeline(command.ps);
- cb->setShaderResources(command.ps->shaderResourceBindings());
+ cb->setGraphicsPipeline(command.graphicsPipeline);
+ cb->setShaderResources(command.graphicsPipeline->shaderResourceBindings());
// Send the draw command
if (Q_UNLIKELY(!command.indexBuffer))
diff --git a/src/plugins/renderers/rhi/renderer/renderer_p.h b/src/plugins/renderers/rhi/renderer/renderer_p.h
index e59ddad9d..2f7b18a61 100644
--- a/src/plugins/renderers/rhi/renderer/renderer_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderer_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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/
**
@@ -265,7 +265,7 @@ public:
void loadShader(Shader *shader, Qt3DRender::Render::HShader shaderHandle) override;
- void updateGLResources();
+ void updateResources();
void updateTexture(Texture *texture);
void cleanupTexture(Qt3DCore::QNodeId cleanedUpTextureId);
void cleanupShader(const Shader *shader);
@@ -470,9 +470,12 @@ private:
QOffscreenSurface *m_fallbackSurface{};
bool m_hasSwapChain = false;
- void setupRHICommand(RenderCommand& command);
- bool performDraw(QRhiCommandBuffer *cb, const RenderView *rv, RenderCommand &command);
+
+ void setupDrawCommand(RenderCommand& command);
bool prepareDraw(QRhiCommandBuffer *cb, const RenderView *rv, RenderCommand &command);
+ bool performDraw(QRhiCommandBuffer *cb, const RenderView *rv, RenderCommand &command);
+
+ void setupComputeCommand(RenderCommand& command);
};
} // namespace Rhi
diff --git a/src/plugins/renderers/rhi/renderer/renderqueue.cpp b/src/plugins/renderers/rhi/renderer/renderqueue.cpp
index f592187e0..ae4145c76 100644
--- a/src/plugins/renderers/rhi/renderer/renderqueue.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderqueue.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/renderqueue_p.h b/src/plugins/renderers/rhi/renderer/renderqueue_p.h
index 7abfe5272..3b6eec13d 100644
--- a/src/plugins/renderers/rhi/renderer/renderqueue_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderqueue_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/renderview.cpp b/src/plugins/renderers/rhi/renderer/renderview.cpp
index 68c282433..fca3fc8eb 100644
--- a/src/plugins/renderers/rhi/renderer/renderview.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderview.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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/
**
diff --git a/src/plugins/renderers/rhi/renderer/renderview_p.h b/src/plugins/renderers/rhi/renderer/renderview_p.h
index 1c0c265ff..b1667a76a 100644
--- a/src/plugins/renderers/rhi/renderer/renderview_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderview_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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/
**
diff --git a/src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp b/src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp
index f2715dc5e..9e25307ef 100644
--- a/src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderviewbuilder.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h b/src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h
index 82ef97f34..379a6f26f 100644
--- a/src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderviewbuilder_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/shader.cpp b/src/plugins/renderers/rhi/renderer/shader.cpp
index 114fe92cc..b6be8f029 100644
--- a/src/plugins/renderers/rhi/renderer/shader.cpp
+++ b/src/plugins/renderers/rhi/renderer/shader.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
@@ -101,6 +101,181 @@ QVector<QByteArray> RHIShader::shaderCode() const
return m_shaderCode;
}
+static auto rhiInputType(QShaderDescription::VariableType type)
+{
+ switch(type)
+ {
+ case QShaderDescription::Vec4: return QRhiVertexInputAttribute::Float4;
+ case QShaderDescription::Vec3: return QRhiVertexInputAttribute::Float3;
+ case QShaderDescription::Vec2: return QRhiVertexInputAttribute::Float2;
+ case QShaderDescription::Float: return QRhiVertexInputAttribute::Float;
+ default:
+ // TODO UNormByte4, UNormByte2, UNormByte
+ RHI_UNIMPLEMENTED;
+ return QRhiVertexInputAttribute::UNormByte;
+ break;
+ }
+}
+
+static constexpr int rhiTypeSize(QShaderDescription::VariableType type)
+{
+ switch(type)
+ {
+ case QShaderDescription::Unknown: return 0;
+
+ case QShaderDescription::Float: return 1;
+ case QShaderDescription::Vec2: return 2;
+ case QShaderDescription::Vec3: return 3;
+ case QShaderDescription::Vec4: return 4;
+ case QShaderDescription::Mat2: return 2*2;
+ case QShaderDescription::Mat2x3: return 2*3;
+ case QShaderDescription::Mat2x4: return 2*4;
+ case QShaderDescription::Mat3: return 3*3;
+ case QShaderDescription::Mat3x2: return 3*2;
+ case QShaderDescription::Mat3x4: return 3*4;
+ case QShaderDescription::Mat4: return 4*4;
+ case QShaderDescription::Mat4x2: return 4*2;
+ case QShaderDescription::Mat4x3: return 4*3;
+
+ case QShaderDescription::Int: return 1;
+ case QShaderDescription::Int2: return 2;
+ case QShaderDescription::Int3: return 3;
+ case QShaderDescription::Int4: return 4;
+
+ case QShaderDescription::Uint: return 1;
+ case QShaderDescription::Uint2: return 2;
+ case QShaderDescription::Uint3: return 3;
+ case QShaderDescription::Uint4: return 4;
+
+ case QShaderDescription::Bool: return 1;
+ case QShaderDescription::Bool2: return 2;
+ case QShaderDescription::Bool3: return 3;
+ case QShaderDescription::Bool4: return 4;
+
+ case QShaderDescription::Double: return 1;
+ case QShaderDescription::Double2: return 2;
+ case QShaderDescription::Double3: return 3;
+ case QShaderDescription::Double4: return 4;
+ case QShaderDescription::DMat2: return 2*2;
+ case QShaderDescription::DMat2x3: return 2*3;
+ case QShaderDescription::DMat2x4: return 2*4;
+ case QShaderDescription::DMat3: return 3*3;
+ case QShaderDescription::DMat3x2: return 3*2;
+ case QShaderDescription::DMat3x4: return 3*4;
+ case QShaderDescription::DMat4: return 4*4;
+ case QShaderDescription::DMat4x2: return 4*2;
+ case QShaderDescription::DMat4x3: return 4*3;
+
+ case QShaderDescription::Sampler1D: return 0;
+ case QShaderDescription::Sampler2D: return 0;
+ case QShaderDescription::Sampler2DMS: return 0;
+ case QShaderDescription::Sampler3D: return 0;
+ case QShaderDescription::SamplerCube: return 0;
+ case QShaderDescription::Sampler1DArray: return 0;
+ case QShaderDescription::Sampler2DArray: return 0;
+ case QShaderDescription::Sampler2DMSArray: return 0;
+ case QShaderDescription::Sampler3DArray: return 0;
+ case QShaderDescription::SamplerCubeArray: return 0;
+ case QShaderDescription::SamplerRect: return 0;
+ case QShaderDescription::SamplerBuffer: return 0;
+
+ case QShaderDescription::Image1D: return 0;
+ case QShaderDescription::Image2D: return 0;
+ case QShaderDescription::Image2DMS: return 0;
+ case QShaderDescription::Image3D: return 0;
+ case QShaderDescription::ImageCube: return 0;
+ case QShaderDescription::Image1DArray: return 0;
+ case QShaderDescription::Image2DArray: return 0;
+ case QShaderDescription::Image2DMSArray: return 0;
+ case QShaderDescription::Image3DArray: return 0;
+ case QShaderDescription::ImageCubeArray: return 0;
+ case QShaderDescription::ImageRect: return 0;
+ case QShaderDescription::ImageBuffer: return 0;
+
+ case QShaderDescription::Struct: return 0;
+ default: return 0;
+ }
+}
+
+template<typename T, typename Pred>
+auto stableRemoveDuplicates(QVector<T> in, Pred predicate)
+{
+ QVector<T> out;
+ for(const auto& element : in)
+ {
+ if(std::none_of(out.begin(), out.end(), [&] (auto& other) { return predicate(element, other); }))
+ out.push_back(element);
+ }
+ return out;
+}
+void RHIShader::introspect()
+{
+ QVector<QShaderDescription::UniformBlock> rhiUBO;
+ QVector<QShaderDescription::StorageBlock> rhiSSBO;
+
+ QVector<ShaderUniformBlock> uniformBlocks;
+ QVector<ShaderStorageBlock> storageBlocks;
+ QVector<ShaderAttribute> attributes;
+
+ QRhiVertexInputLayout lay;
+
+ // Introspect shader vertex input
+ if(m_stages[QShader::VertexStage].isValid())
+ {
+ const QShaderDescription& vtx = m_stages[QShader::VertexStage].description();
+
+ QVarLengthArray<QRhiVertexInputAttribute, 8> rhiAttributes;
+
+ for(const QShaderDescription::InOutVariable& input : vtx.inputVariables())
+ {
+ // TODO offset ?
+ rhiAttributes.push_back({ 0, input.location, rhiInputType(input.type), 0 });
+ qDebug() << "Pushing attribute: " << rhiAttributes.back();
+
+ attributes.push_back(ShaderAttribute{input.name, -1, input.type, rhiTypeSize(input.type), input.location});
+ }
+ lay.setAttributes(rhiAttributes.begin(), rhiAttributes.end());
+
+ for(const auto& var: vtx.uniformBlocks())
+ rhiUBO.push_back(var);
+ for(const auto& var: vtx.storageBlocks())
+ rhiSSBO.push_back(var);
+ }
+ m_input = std::move(lay);
+
+ // Introspect shader uniforms
+
+ if(m_stages[QShader::FragmentStage].isValid())
+ {
+ const QShaderDescription& frag = m_stages[QShader::FragmentStage].description();
+ for(const auto& var: frag.uniformBlocks())
+ rhiUBO.push_back(var);
+ for(const auto& var: frag.storageBlocks())
+ rhiSSBO.push_back(var);
+ }
+
+ rhiUBO = stableRemoveDuplicates(rhiUBO, [] (const QShaderDescription::UniformBlock& lhs, const QShaderDescription::UniformBlock& rhs) {
+ return lhs.blockName == rhs.blockName;
+ });
+ rhiSSBO = stableRemoveDuplicates(rhiSSBO, [] (const QShaderDescription::StorageBlock& lhs, const QShaderDescription::StorageBlock& rhs) {
+ return lhs.blockName == rhs.blockName;
+ });
+
+ for(const QShaderDescription::UniformBlock& ubo : rhiUBO)
+ {
+ uniformBlocks.push_back(ShaderUniformBlock{ubo.blockName, -1, -1, ubo.binding, 0, 0});
+ }
+
+ for(const QShaderDescription::StorageBlock& ssbo : rhiSSBO)
+ {
+ storageBlocks.push_back(ShaderStorageBlock{ssbo.blockName, -1, -1, ssbo.binding, 0, 0});
+ }
+
+ initializeAttributes(attributes);
+ initializeUniformBlocks(uniformBlocks);
+ initializeShaderStorageBlocks(storageBlocks);
+}
+
QHash<QString, ShaderUniform> RHIShader::activeUniformsForUniformBlock(int blockIndex) const
{
return m_uniformBlockIndexToShaderUniforms.value(blockIndex);
diff --git a/src/plugins/renderers/rhi/renderer/shader_p.h b/src/plugins/renderers/rhi/renderer/shader_p.h
index 3520aaa2c..abf06d9a7 100644
--- a/src/plugins/renderers/rhi/renderer/shader_p.h
+++ b/src/plugins/renderers/rhi/renderer/shader_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
@@ -56,6 +56,8 @@
#include <shaderparameterpack_p.h>
#include <Qt3DRender/qshaderprogram.h>
#include <QMutex>
+#include <QtGui/private/qshader_p.h>
+#include <QtGui/private/qrhi_p.h>
QT_BEGIN_NAMESPACE
@@ -115,8 +117,16 @@ public:
void setShaderCode(const QVector<QByteArray> shaderCode) { m_shaderCode = shaderCode; }
QVector<QByteArray> shaderCode() const;
+ const QShader& shaderStage(QShader::Stage stage) const noexcept { return m_stages[stage]; }
+ const QRhiVertexInputLayout& inputLayout() const noexcept { return m_input; }
+
+ void introspect();
private:
bool m_isLoaded;
+ QShader m_stages[6];
+
+ QRhiVertexInputLayout m_input;
+
QOpenGLShaderProgram m_shader;
GraphicsContext *m_graphicsContext;
diff --git a/src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp b/src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp
index 8fa0943fd..d129c742d 100644
--- a/src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp
+++ b/src/plugins/renderers/rhi/renderer/shaderparameterpack.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h b/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h
index 67f52feea..5aa6ed695 100644
--- a/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h
+++ b/src/plugins/renderers/rhi/renderer/shaderparameterpack_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/renderer/shadervariables_p.h b/src/plugins/renderers/rhi/renderer/shadervariables_p.h
index e2cf3667e..40f906b18 100644
--- a/src/plugins/renderers/rhi/renderer/shadervariables_p.h
+++ b/src/plugins/renderers/rhi/renderer/shadervariables_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
@@ -52,6 +52,7 @@
//
#include <Qt3DRender/qt3drender_global.h>
+#include <QtGui/private/qshaderdescription_p.h>
#include <QOpenGLContext>
QT_BEGIN_NAMESPACE
@@ -64,84 +65,49 @@ namespace Rhi {
struct ShaderAttribute
{
- ShaderAttribute()
- : m_nameId(-1)
- , m_type(0)
- , m_size(0)
- , m_location(-1)
- {}
-
QString m_name;
- int m_nameId;
- GLenum m_type;
- int m_size;
- int m_location;
+ int m_nameId{-1};
+ QShaderDescription::VariableType m_type{};
+ int m_size{};
+ int m_location{-1};
};
QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, Rhi, ShaderAttribute, Q_MOVABLE_TYPE)
struct ShaderUniform
{
- ShaderUniform()
- : m_nameId(-1)
- , m_type(GL_NONE)
- , m_size(0)
- , m_offset(-1)
- , m_location(-1)
- , m_blockIndex(-1)
- , m_arrayStride(-1)
- , m_matrixStride(-1)
- , m_rawByteSize(0)
- {}
-
QString m_name;
- int m_nameId;
- GLenum m_type;
- int m_size;
- int m_offset; // -1 default, >= 0 if uniform defined in uniform block
- int m_location; // -1 if uniform defined in a uniform block
- int m_blockIndex; // -1 is the default, >= 0 if uniform defined in uniform block
- int m_arrayStride; // -1 is the default, >= 0 if uniform defined in uniform block and if it's an array
- int m_matrixStride; // -1 is the default, >= 0 uniform defined in uniform block and is a matrix
- uint m_rawByteSize; // contains byte size (size / type / strides)
+ int m_nameId{-1};
+ QShaderDescription::VariableType m_type{QShaderDescription::Unknown};
+ int m_size{0};
+ int m_offset{-1}; // -1 default, >= 0 if uniform defined in uniform block
+ int m_location{-1}; // -1 if uniform defined in a uniform block
+ int m_blockIndex{-1}; // -1 is the default, >= 0 if uniform defined in uniform block
+ int m_arrayStride{-1}; // -1 is the default, >= 0 if uniform defined in uniform block and if it's an array
+ int m_matrixStride{-1}; // -1 is the default, >= 0 uniform defined in uniform block and is a matrix
+ uint m_rawByteSize{0}; // contains byte size (size / type / strides)
// size, offset and strides are in bytes
};
QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, Rhi, ShaderUniform, Q_MOVABLE_TYPE)
struct ShaderUniformBlock
{
- ShaderUniformBlock()
- : m_nameId(-1)
- , m_index(-1)
- , m_binding(-1)
- , m_activeUniformsCount(0)
- , m_size(0)
- {}
-
QString m_name;
- int m_nameId;
- int m_index;
- int m_binding;
- int m_activeUniformsCount;
- int m_size;
+ int m_nameId{-1};
+ int m_index{-1};
+ int m_binding{-1};
+ int m_activeUniformsCount{0};
+ int m_size{0};
};
QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, Rhi, ShaderUniformBlock, Q_MOVABLE_TYPE)
struct ShaderStorageBlock
{
- ShaderStorageBlock()
- : m_nameId(-1)
- , m_index(-1)
- , m_binding(-1)
- , m_size(0)
- , m_activeVariablesCount(0)
- {}
-
QString m_name;
- int m_nameId;
- int m_index;
- int m_binding;
- int m_size;
- int m_activeVariablesCount;
+ int m_nameId{-1};
+ int m_index{-1};
+ int m_binding{-1};
+ int m_size{0};
+ int m_activeVariablesCount{0};
};
QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, Rhi, ShaderStorageBlock, Q_MOVABLE_TYPE)
diff --git a/src/plugins/renderers/rhi/textures/texture.cpp b/src/plugins/renderers/rhi/textures/texture.cpp
index ed306bb41..97852d9a2 100644
--- a/src/plugins/renderers/rhi/textures/texture.cpp
+++ b/src/plugins/renderers/rhi/textures/texture.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/src/plugins/renderers/rhi/textures/texture_p.h b/src/plugins/renderers/rhi/textures/texture_p.h
index 552e532c5..014990b26 100644
--- a/src/plugins/renderers/rhi/textures/texture_p.h
+++ b/src/plugins/renderers/rhi/textures/texture_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** 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.
diff --git a/tests/manual/rhi/main.cpp b/tests/manual/rhi/main.cpp
index 69361d10b..d81810911 100644
--- a/tests/manual/rhi/main.cpp
+++ b/tests/manual/rhi/main.cpp
@@ -108,6 +108,9 @@ static const constexpr auto fragment_shader = R"_(#version 450
layout(location = 0) out vec4 fragColor;
+layout(std140, binding = 0) uniform qt3d_uniforms {
+ mat4 mvp;
+};
layout(std140, binding = 1) uniform custom_uniforms {
float example;
};