diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/render/renderers/opengl/renderer/renderer.cpp | 3 | ||||
-rw-r--r-- | src/render/renderers/opengl/renderer/renderview.cpp | 23 | ||||
-rw-r--r-- | src/render/texture/qabstracttexture.cpp | 108 | ||||
-rw-r--r-- | src/render/texture/qtexture.cpp | 77 |
4 files changed, 210 insertions, 1 deletions
diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp index 9dfdf7d06..121a6aa8f 100644 --- a/src/render/renderers/opengl/renderer/renderer.cpp +++ b/src/render/renderers/opengl/renderer/renderer.cpp @@ -500,7 +500,8 @@ void Renderer::releaseGraphicsResources() QOpenGLContext *context = m_submissionContext->openGLContext(); Q_ASSERT(context); - if (context->makeCurrent(offscreenSurface)) { + + if (context->thread() == QThread::currentThread() && context->makeCurrent(offscreenSurface)) { // Clean up the graphics context and any resources const QVector<HGLTexture> activeTexturesHandles = m_nodesManager->glTextureManager()->activeHandles(); diff --git a/src/render/renderers/opengl/renderer/renderview.cpp b/src/render/renderers/opengl/renderer/renderview.cpp index 8fbe8e188..aa9f4d1a5 100644 --- a/src/render/renderers/opengl/renderer/renderview.cpp +++ b/src/render/renderers/opengl/renderer/renderview.cpp @@ -102,6 +102,12 @@ int LIGHT_COLOR_NAMES[MAX_LIGHTS]; int LIGHT_INTENSITY_NAMES[MAX_LIGHTS]; QString LIGHT_STRUCT_NAMES[MAX_LIGHTS]; +int LIGHT_POSITION_UNROLL_NAMES[MAX_LIGHTS]; +int LIGHT_TYPE_UNROLL_NAMES[MAX_LIGHTS]; +int LIGHT_COLOR_UNROLL_NAMES[MAX_LIGHTS]; +int LIGHT_INTENSITY_UNROLL_NAMES[MAX_LIGHTS]; +QString LIGHT_STRUCT_UNROLL_NAMES[MAX_LIGHTS]; + bool wasInitialized = false; } // anonymous namespace @@ -261,6 +267,12 @@ RenderView::RenderView() LIGHT_TYPE_NAMES[i] = StringToInt::lookupId(LIGHT_STRUCT_NAMES[i] + LIGHT_TYPE_NAME); LIGHT_COLOR_NAMES[i] = StringToInt::lookupId(LIGHT_STRUCT_NAMES[i] + LIGHT_COLOR_NAME); LIGHT_INTENSITY_NAMES[i] = StringToInt::lookupId(LIGHT_STRUCT_NAMES[i] + LIGHT_INTENSITY_NAME); + + LIGHT_STRUCT_UNROLL_NAMES[i] = QLatin1String("light_") + QLatin1Char(char('0' + i)); + LIGHT_POSITION_UNROLL_NAMES[i] = StringToInt::lookupId(LIGHT_STRUCT_UNROLL_NAMES[i] + LIGHT_POSITION_NAME); + LIGHT_TYPE_UNROLL_NAMES[i] = StringToInt::lookupId(LIGHT_STRUCT_UNROLL_NAMES[i] + LIGHT_TYPE_NAME); + LIGHT_COLOR_UNROLL_NAMES[i] = StringToInt::lookupId(LIGHT_STRUCT_UNROLL_NAMES[i] + LIGHT_COLOR_NAME); + LIGHT_INTENSITY_UNROLL_NAMES[i] = StringToInt::lookupId(LIGHT_STRUCT_UNROLL_NAMES[i] + LIGHT_INTENSITY_NAME); } } } @@ -1008,6 +1020,11 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, setUniformValue(command->m_parameterPack, LIGHT_COLOR_NAMES[lightIdx], Vector3D(1.0f, 1.0f, 1.0f)); setUniformValue(command->m_parameterPack, LIGHT_INTENSITY_NAMES[lightIdx], 0.5f); + setUniformValue(command->m_parameterPack, LIGHT_POSITION_UNROLL_NAMES[lightIdx], worldPos); + setUniformValue(command->m_parameterPack, LIGHT_TYPE_UNROLL_NAMES[lightIdx], int(QAbstractLight::PointLight)); + setUniformValue(command->m_parameterPack, LIGHT_COLOR_UNROLL_NAMES[lightIdx], Vector3D(1.0f, 1.0f, 1.0f)); + setUniformValue(command->m_parameterPack, LIGHT_INTENSITY_UNROLL_NAMES[lightIdx], 0.5f); + // There is no risk in doing that even if multithreaded // since we are sure that a shaderData is unique for a given light // and won't ever be referenced as a Component either @@ -1016,6 +1033,7 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, shaderData->updateWorldTransform(*worldTransform); setDefaultUniformBlockShaderDataValue(command->m_parameterPack, shader, shaderData, LIGHT_STRUCT_NAMES[lightIdx]); + setDefaultUniformBlockShaderDataValue(command->m_parameterPack, shader, shaderData, LIGHT_STRUCT_UNROLL_NAMES[lightIdx]); ++lightIdx; } } @@ -1030,6 +1048,11 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, setUniformValue(command->m_parameterPack, LIGHT_TYPE_NAMES[0], int(QAbstractLight::PointLight)); setUniformValue(command->m_parameterPack, LIGHT_COLOR_NAMES[0], Vector3D(1.0f, 1.0f, 1.0f)); setUniformValue(command->m_parameterPack, LIGHT_INTENSITY_NAMES[0], 0.5f); + + setUniformValue(command->m_parameterPack, LIGHT_POSITION_UNROLL_NAMES[0], Vector3D(10.0f, 10.0f, 0.0f)); + setUniformValue(command->m_parameterPack, LIGHT_TYPE_UNROLL_NAMES[0], int(QAbstractLight::PointLight)); + setUniformValue(command->m_parameterPack, LIGHT_COLOR_UNROLL_NAMES[0], Vector3D(1.0f, 1.0f, 1.0f)); + setUniformValue(command->m_parameterPack, LIGHT_INTENSITY_UNROLL_NAMES[0], 0.5f); } // Environment Light diff --git a/src/render/texture/qabstracttexture.cpp b/src/render/texture/qabstracttexture.cpp index ab9f01d39..7fca2ba3f 100644 --- a/src/render/texture/qabstracttexture.cpp +++ b/src/render/texture/qabstracttexture.cpp @@ -139,6 +139,27 @@ void QAbstractTexturePrivate::setHandleType(QAbstractTexture::HandleType type) */ /*! + \qmltype AbstractTexture + \instantiates Qt3DRender::QAbstractTexture + \inqmlmodule Qt3D.Render + \since 5.5 + \brief A base class to be used to provide textures. + + The AbstractTexture class shouldn't be used directly but rather through one + of its subclasses. Each subclass implements a given texture target (2D, + 2DArray, 3D, CubeMap ...) Each subclass provides a set of functors for each + layer, cube map face and mipmap level. In turn the backend uses those + functor to properly fill a corresponding OpenGL texture with data. It is + expected the functor does as minimal processing as possible so as not to + slow down textures generation and upload. If the content of a texture is + the result of a slow procedural generation process, it is recommended not + to implement this directly in a functor. + + All textures are unique. If you instantiate twice the same texture this + will create 2 identical textures on the GPU, no sharing will take place. + */ + +/*! \enum Qt3DRender::QAbstractTexture::CubeMapFace This enum identifies the faces of a cube map texture @@ -409,6 +430,12 @@ void QAbstractTexture::setSize(int w, int h, int d) Holds the width of the texture provider. */ /*! + \qmlproperty int Qt3DRender::QAbstractTexture::width + + Holds the width of the texture provider. + */ + +/*! Set the width of the texture provider to \a width. */ void QAbstractTexture::setWidth(int width) @@ -426,6 +453,11 @@ void QAbstractTexture::setWidth(int width) Holds the height of the texture provider. */ /*! + \qmlproperty int Qt3DRender::QAbstractTexture::height + + Holds the height of the texture provider. + */ +/*! Set the height to \a height. */ void QAbstractTexture::setHeight(int height) @@ -443,6 +475,11 @@ void QAbstractTexture::setHeight(int height) Holds the depth of the texture provider. */ /*! + \qmlproperty int Qt3DRender::QAbstractTexture::depth + + Holds the depth of the texture provider. + */ +/*! Set the depth of the texture to \a depth. */ void QAbstractTexture::setDepth(int depth) @@ -491,6 +528,15 @@ int QAbstractTexture::depth() const array target formats. */ /*! + \qmlproperty int Qt3DRender::QAbstractTexture::layers + + Holds the maximum layer count of the texture provider. By default, the + maximum layer count is 1. + + \note this has a meaning only for texture providers that have 3D or + array target formats. + */ +/*! Set the maximum layer count to \a layers. */ void QAbstractTexture::setLayers(int layers) @@ -524,6 +570,15 @@ int QAbstractTexture::layers() const formats. */ /*! + \qmlproperty int Qt3DRender::QAbstractTexture::samples + + Holds the number of samples per texel for the texture provider. + By default, the number of samples is 1. + + \note this has a meaning only for texture providers that have multisample + formats. + */ +/*! Set the number of samples per texel to \a samples. */ void QAbstractTexture::setSamples(int samples) @@ -553,6 +608,11 @@ int QAbstractTexture::samples() const Holds the format of the texture provider. */ /*! + \qmlproperty TextureFormat Qt3DRender::QAbstractTexture::format + + Holds the format of the texture provider. + */ +/*! Set the texture format to \a format. */ void QAbstractTexture::setFormat(TextureFormat format) @@ -578,6 +638,11 @@ QAbstractTexture::TextureFormat QAbstractTexture::format() const Holds the current status of the texture provider. */ +/*! + \qmlproperty Status Qt3DRender::QAbstractTexture::status readonly + + Holds the current status of the texture provider. + */ /*! \enum Qt3DRender::QAbstractTexture::Status @@ -648,6 +713,13 @@ QAbstractTexture::Status QAbstractTexture::status() const \note The target format can only be set once. */ /*! + \qmlproperty Target Qt3DRender::QAbstractTexture::target readonly + + Holds the target format of the texture provider. + + \note The target format can only be set once. + */ +/*! \enum Qt3DRender::QAbstractTexture::Target \value TargetAutomatic @@ -741,6 +813,11 @@ QVector<QAbstractTextureImage *> QAbstractTexture::textureImages() const Holds whether the texture provider should auto generate mipmaps. */ /*! + \qmlproperty bool Qt3DRender::QAbstractTexture::generateMipMaps + + Holds whether the texture provider should auto generate mipmaps. + */ +/*! Boolean parameter \a gen sets a flag indicating whether the texture provider should generate mipmaps or not. */ @@ -765,6 +842,11 @@ bool QAbstractTexture::generateMipMaps() const Holds the minification filter of the texture provider. */ /*! + \qmlproperty Filter Qt3DRender::QAbstractTexture::minificationFilter + + Holds the minification filter of the texture provider. + */ +/*! Set the minification filter to the specified value \a f. */ void QAbstractTexture::setMinificationFilter(Filter f) @@ -799,6 +881,11 @@ void QAbstractTexture::setMinificationFilter(Filter f) Holds the magnification filter of the texture provider. */ /*! + \qmlproperty Filter Qt3DRender::QAbstractTexture::magnificationFilter + + Holds the magnification filter of the texture provider. + */ +/*! Set the magnification filter to \a f. */ void QAbstractTexture::setMagnificationFilter(Filter f) @@ -828,6 +915,11 @@ QAbstractTexture::Filter QAbstractTexture::magnificationFilter() const Holds the wrap mode of the texture provider. */ /*! + \qmlproperty QTextureWrapMode Qt3DRender::QAbstractTexture::wrapMode + + Holds the wrap mode of the texture provider. + */ +/*! Set the wrapmode to the value specified in \a wrapMode. */ void QAbstractTexture::setWrapMode(const QTextureWrapMode &wrapMode) @@ -859,6 +951,11 @@ QTextureWrapMode *QAbstractTexture::wrapMode() Holds the maximum anisotropy of the texture provider. */ /*! + \qmlproperty bool Qt3DRender::QAbstractTexture::maximumAnisotropy + + Holds the maximum anisotropy of the texture provider. + */ +/*! Sets the maximum anisotropy to \a anisotropy. */ void QAbstractTexture::setMaximumAnisotropy(float anisotropy) @@ -885,6 +982,11 @@ float QAbstractTexture::maximumAnisotropy() const Holds the comparison function of the texture provider. */ /*! + \qmlproperty ComparisonFunction Qt3DRender::QAbstractTexture::ComparisonFunction + + Holds the comparison function of the texture provider. + */ +/*! Set the comparison function to \a function. */ void QAbstractTexture::setComparisonFunction(QAbstractTexture::ComparisonFunction function) @@ -910,6 +1012,12 @@ QAbstractTexture::ComparisonFunction QAbstractTexture::comparisonFunction() cons Holds the comparison mode of the texture provider. */ + +/*! + \qmlproperty ComparisonMode Qt3DRender::QAbstractTexture::ComparisonMode + + Holds the comparison mode of the texture provider. + */ /*! Set the comparison mode to \a mode. */ diff --git a/src/render/texture/qtexture.cpp b/src/render/texture/qtexture.cpp index b28004aa0..bca66e630 100644 --- a/src/render/texture/qtexture.cpp +++ b/src/render/texture/qtexture.cpp @@ -1161,6 +1161,13 @@ void TextureDownloadRequest::onCompleted() \since 5.5 \brief A QAbstractTexture with a Target1D target format. */ +/*! + \qmltype Texture1D + \instantiates Qt3DRender::QTexture1D + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a Target1D target format. + */ /*! Constructs a new Qt3DRender::QTexture1D instance with \a parent as parent. @@ -1182,6 +1189,13 @@ QTexture1D::~QTexture1D() \since 5.5 \brief A QAbstractTexture with a Target1DArray target format. */ +/*! + \qmltype Texture1DArray + \instantiates Qt3DRender::QTexture1DArray + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a Target1DArray target format. + */ /*! Constructs a new Qt3DRender::QTexture1DArray instance with \a parent as parent. @@ -1203,6 +1217,13 @@ QTexture1DArray::~QTexture1DArray() \since 5.5 \brief A QAbstractTexture with a Target2D target format. */ +/*! + \qmltype Texture2D + \instantiates Qt3DRender::QTexture2D + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a Target2D target format. + */ /*! Constructs a new Qt3DRender::QTexture2D instance with \a parent as parent. @@ -1224,6 +1245,13 @@ QTexture2D::~QTexture2D() \since 5.5 \brief A QAbstractTexture with a Target2DArray target format. */ +/*! + \qmltype Texture2DArray + \instantiates Qt3DRender::QTexture2DArray + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a Target2DArray target format. + */ /*! Constructs a new Qt3DRender::QTexture2DArray instance with \a parent as parent. @@ -1245,6 +1273,13 @@ QTexture2DArray::~QTexture2DArray() \since 5.5 \brief A QAbstractTexture with a Target3D target format. */ +/*! + \qmltype Texture3D + \instantiates Qt3DRender::QTexture3D + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a Target3D target format. + */ /*! Constructs a new Qt3DRender::QTexture3D instance with \a parent as parent. @@ -1266,6 +1301,13 @@ QTexture3D::~QTexture3D() \since 5.5 \brief A QAbstractTexture with a TargetCubeMap target format. */ +/*! + \qmltype TextureCubeMap + \instantiates Qt3DRender::QTextureCubeMap + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a TargetCubeMap target format. + */ /*! Constructs a new Qt3DRender::QTextureCubeMap instance with \a parent as parent. @@ -1287,6 +1329,13 @@ QTextureCubeMap::~QTextureCubeMap() \since 5.5 \brief A QAbstractTexture with a TargetCubeMapArray target format. */ +/*! + \qmltype TextureCubeMapArray + \instantiates Qt3DRender::QTextureCubeMapArray + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a TargetCubeMapArray target format. + */ /*! Constructs a new Qt3DRender::QTextureCubeMapArray instance with \a parent as parent. @@ -1308,6 +1357,13 @@ QTextureCubeMapArray::~QTextureCubeMapArray() \since 5.5 \brief A QAbstractTexture with a Target2DMultisample target format. */ +/*! + \qmltype Texture2DMultisample + \instantiates Qt3DRender::QTexture2DMultisample + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a Target2DMultisample target format. + */ /*! Constructs a new Qt3DRender::QTexture2DMultisample instance with \a parent as parent. @@ -1329,6 +1385,13 @@ QTexture2DMultisample::~QTexture2DMultisample() \since 5.5 \brief A QAbstractTexture with a Target2DMultisampleArray target format. */ +/*! + \qmltype Texture2DMultisampleArray + \instantiates Qt3DRender::QTexture2DMultisampleArray + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a Target2DMultisampleArray target format. + */ /*! Constructs a new Qt3DRender::QTexture2DMultisampleArray instance with \a parent as parent. @@ -1350,6 +1413,13 @@ QTexture2DMultisampleArray::~QTexture2DMultisampleArray() \since 5.5 \brief A QAbstractTexture with a TargetRectangle target format. */ +/*! + \qmltype TextureRectangle + \instantiates Qt3DRender::QTextureRectangle + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a TargetRectangle target format. + */ /*! Constructs a new Qt3DRender::QTextureRectangle instance with \a parent as parent. @@ -1371,6 +1441,13 @@ QTextureRectangle::~QTextureRectangle() \since 5.5 \brief A QAbstractTexture with a TargetBuffer target format. */ +/*! + \qmltype TextureBuffer + \instantiates Qt3DRender::QTextureBuffer + \inqmlmodule Qt3D.Render + \since 5.5 + \brief An AbstractTexture with a TargetBuffer target format. + */ /*! Constructs a new Qt3DRender::QTextureBuffer instance with \a parent as parent. |