From b38d0ac85cd50dea00cf97e01c086dea4ac4ebc5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 18 Feb 2015 15:27:38 +0100 Subject: Make shadow mapping functional on ES 3 To preserve our sanity we will only support ES 3.x, not 2.0 + GL_OES_depth_texture + EXT_shadow_samplers. This way we can provide version 300 es shaders and do not have to introduce yet another filter and technique. Change-Id: Ib5c826d6540b4848f0cb4629e5311150169a9697 Reviewed-by: Sean Harmer --- src/render/backend/qgraphicshelperes2.cpp | 33 +++++++++++++++++++++++++++++++ src/render/backend/qgraphicshelperes2_p.h | 1 + 2 files changed, 34 insertions(+) (limited to 'src') diff --git a/src/render/backend/qgraphicshelperes2.cpp b/src/render/backend/qgraphicshelperes2.cpp index 72190ea15..37cac786d 100644 --- a/src/render/backend/qgraphicshelperes2.cpp +++ b/src/render/backend/qgraphicshelperes2.cpp @@ -41,6 +41,23 @@ 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 Qt3D { namespace Render { @@ -59,6 +76,7 @@ void QGraphicsHelperES2::initializeHelper(QOpenGLContext *context, Q_ASSERT(context); m_funcs = context->functions(); Q_ASSERT(m_funcs); + m_isES3 = context->format().majorVersion() >= 3; } void QGraphicsHelperES2::drawElementsInstanced(GLenum primitiveType, @@ -367,6 +385,21 @@ void QGraphicsHelperES2::bindUniform(const QVariant &v, const ShaderUniform &des break; } + // ES 3.0+ + 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: + if (m_isES3) { + Q_ASSERT(description.m_size == 1); + m_funcs->glUniform1i(description.m_location, v.toInt()); + } else { + qWarning() << Q_FUNC_INFO << "ES 3.0 uniform type" << description.m_type << "for" + << description.m_name << "is not supported in ES 2.0"; + } + break; + default: qWarning() << Q_FUNC_INFO << "unsupported uniform type:" << description.m_type << "for " << description.m_name; break; diff --git a/src/render/backend/qgraphicshelperes2_p.h b/src/render/backend/qgraphicshelperes2_p.h index 7cd58a016..200242578 100644 --- a/src/render/backend/qgraphicshelperes2_p.h +++ b/src/render/backend/qgraphicshelperes2_p.h @@ -89,6 +89,7 @@ public: private: QOpenGLFunctions *m_funcs; + bool m_isES3; }; } // Render -- cgit v1.2.3