From bc7afda3ece9be46bef1ac2308f3b2ce598e5f00 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Fri, 27 Feb 2015 10:06:57 +0100 Subject: RenderShader: Fix for absence of instance names in UBO - Also added debug logging in RenderShader for the Shaders logging category - This restores the deferred-example rendering which was broken since 3abbf9227ada8f68821a5ad473bba4f52e625fb5 Change-Id: Ie1b39c903f8c33f7d9b859317ae185c42043a9e2 Reviewed-by: Laszlo Agocs Reviewed-by: Sean Harmer --- src/render/backend/jobs/renderviewjobutils.cpp | 9 +++++++-- src/render/backend/rendershader.cpp | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/render/backend/jobs/renderviewjobutils.cpp b/src/render/backend/jobs/renderviewjobutils.cpp index 3d341ed2d..4e056c79b 100644 --- a/src/render/backend/jobs/renderviewjobutils.cpp +++ b/src/render/backend/jobs/renderviewjobutils.cpp @@ -35,6 +35,7 @@ ****************************************************************************/ #include "renderviewjobutils_p.h" +#include "renderlogging_p.h" #include #include @@ -376,8 +377,10 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const QStrin } } else { // Array of scalar/vec qmlPropertyName[0] QString varName = blockName + QStringLiteral(".") + qmlPropertyName + QStringLiteral("[0]"); - if (uniforms.contains(varName)) + if (uniforms.contains(varName)) { + qCDebug(Shaders) << "UBO array member " << varName << " set for update"; activeUniformNamesToValue.insert(varName, value); + } } } else if (value.userType() == qNodeIdTypeId) { // Struct qmlPropertyName.structMember RenderShaderData *rSubShaderData = shaderDataManager->lookupResource(value.value()); @@ -387,8 +390,10 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const QStrin qmlPropertyName); } else { // Scalar / Vec QString varName = blockName + QStringLiteral(".") + qmlPropertyName; - if (uniforms.contains(varName)) + if (uniforms.contains(varName)) { + qCDebug(Shaders) << "UBO scalar member " << varName << " set for update"; activeUniformNamesToValue.insert(varName, value); + } } } diff --git a/src/render/backend/rendershader.cpp b/src/render/backend/rendershader.cpp index 48818615b..8d11443da 100644 --- a/src/render/backend/rendershader.cpp +++ b/src/render/backend/rendershader.cpp @@ -35,8 +35,8 @@ ****************************************************************************/ #include "rendershader_p.h" +#include "renderlogging_p.h" -#include #include #include #include @@ -297,8 +297,10 @@ void RenderShader::initializeUniforms(const QVector &uniformsDesc for (int i = 0; i < uniformsDescription.size(); i++) { m_uniformsNames[i] = uniformsDescription[i].m_name; - if (uniformsDescription[i].m_blockIndex == -1) // Uniform is in default block + if (uniformsDescription[i].m_blockIndex == -1) { // Uniform is in default block + qCDebug(Shaders) << "Active Uniform in Default Block " << uniformsDescription[i].m_name; activeUniformsInDefaultBlock.insert(uniformsDescription[i].m_name, uniformsDescription[i]); + } } m_blockIndexToShaderUniforms.insert(-1, activeUniformsInDefaultBlock); } @@ -307,8 +309,10 @@ void RenderShader::initializeAttributes(const QVector &attribut { m_attributes = attributesDescription; m_attributesNames.resize(attributesDescription.size()); - for (int i = 0; i < attributesDescription.size(); i++) + for (int i = 0; i < attributesDescription.size(); i++) { m_attributesNames[i] = attributesDescription[i].m_name; + qCDebug(Shaders) << "Active Attribute " << attributesDescription[i].m_name; + } } void RenderShader::initializeUniformBlocks(const QVector &uniformBlockDescription) @@ -317,6 +321,7 @@ void RenderShader::initializeUniformBlocks(const QVector &un m_uniformBlockNames.resize(uniformBlockDescription.size()); for (int i = 0; i < uniformBlockDescription.size(); ++i) { m_uniformBlockNames[i] = uniformBlockDescription[i].m_name; + qCDebug(Shaders) << "Initializing Uniform Block " << m_uniformBlockNames[i]; // Find all active uniforms for the shader block QVector::const_iterator uniformsIt = m_uniforms.begin(); @@ -328,8 +333,13 @@ void RenderShader::initializeUniformBlocks(const QVector &un QHash activeUniformsInBlock; while (uniformsIt != uniformsEnd && uniformNamesIt != uniformNamesEnd) { - if (uniformsIt->m_blockIndex == uniformBlockDescription[i].m_index) - activeUniformsInBlock.insert(*uniformNamesIt, *uniformsIt); + if (uniformsIt->m_blockIndex == uniformBlockDescription[i].m_index) { + QString uniformName = *uniformNamesIt; + if (!m_uniformBlockNames[i].isEmpty() && !uniformName.startsWith(m_uniformBlockNames[i])) + uniformName = m_uniformBlockNames[i] + QStringLiteral(".") + *uniformNamesIt; + activeUniformsInBlock.insert(uniformName, *uniformsIt); + qCDebug(Shaders) << "Active Uniform Block " << uniformName << " in block " << m_uniformBlockNames[i]; + } ++uniformsIt; ++uniformNamesIt; } -- cgit v1.2.3