diff options
author | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2019-05-31 14:22:48 +0300 |
---|---|---|
committer | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2019-06-03 10:41:26 +0300 |
commit | 07e41a592a427988600ed721526a63bf1f5e9814 (patch) | |
tree | 8b60ccea4886fcb6a00fe92b752ca82399361eb1 | |
parent | ff1687d03374de568199dc9aced1794cd6947e3e (diff) |
Move shader feature definition
Move the whole shader feature definition before other backwards
compatibility definitions and remove the special case for NO_FRAG_OUTPUT.
This fixes definition of fragOutput for OpenGL 3.2.
Change-Id: I8daede272fa9ab62ead08ddd06a3436f66e96457
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r-- | src/Runtime/ogl-runtime/src/runtimerender/Qt3DSRenderShaderCache.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/src/Runtime/ogl-runtime/src/runtimerender/Qt3DSRenderShaderCache.cpp b/src/Runtime/ogl-runtime/src/runtimerender/Qt3DSRenderShaderCache.cpp index 1d947459..77d4ee64 100644 --- a/src/Runtime/ogl-runtime/src/runtimerender/Qt3DSRenderShaderCache.cpp +++ b/src/Runtime/ogl-runtime/src/runtimerender/Qt3DSRenderShaderCache.cpp @@ -282,6 +282,10 @@ struct ShaderCache : public IShaderCache if (m_RenderContext.IsAdvancedBlendHwSupportedKHR()) m_InsertStr += "layout(blend_support_all_equations) out;\n"; + + m_InsertStr += "#ifndef NO_FRAG_OUTPUT\n"; + m_InsertStr += "out vec4 fragOutput;\n"; + m_InsertStr += "#endif\n"; } } @@ -367,6 +371,17 @@ struct ShaderCache : public IShaderCache m_InsertStr.append(versionStr.toLatin1().data()); + if (inFeatures.size()) { + for (QT3DSU32 idx = 0, end = inFeatures.size(); idx < end; ++idx) { + SShaderPreprocessorFeature feature(inFeatures[idx]); + m_InsertStr.append("#define "); + m_InsertStr.append(inFeatures[idx].m_Name.c_str()); + m_InsertStr.append(" "); + m_InsertStr.append(feature.m_Enabled ? "1" : "0"); + m_InsertStr.append("\n"); + } + } + if (isGlES) { if (!IQt3DSRenderer::IsGlEs3Context(m_RenderContext.GetRenderContextType())) { if (shaderType == ShaderType::Fragment) { @@ -435,31 +450,7 @@ struct ShaderCache : public IShaderCache m_InsertStr += "#define TESSELLATION_EVALUATION_SHADER 1\n"; } - int fragOutputIndex = int(m_InsertStr.size()); str.insert(0, m_InsertStr); - if (inFeatures.size()) { - eastl::string::size_type insertPos = int(m_InsertStr.size()); - m_InsertStr.clear(); - for (QT3DSU32 idx = 0, end = inFeatures.size(); idx < end; ++idx) { - SShaderPreprocessorFeature feature(inFeatures[idx]); - m_InsertStr.append("#define "); - m_InsertStr.append(inFeatures[idx].m_Name.c_str()); - m_InsertStr.append(" "); - m_InsertStr.append(feature.m_Enabled ? "1" : "0"); - m_InsertStr.append("\n"); - } - str.insert(insertPos, m_InsertStr); - fragOutputIndex = insertPos + int(m_InsertStr.size()); - } - - // Add fragOutput for desktop OpenGL and OpenGL ES 3.x after feature defines - if (!isGlES || IQt3DSRenderer::IsGlEs3Context(m_RenderContext.GetRenderContextType())) { - m_InsertStr.clear(); - m_InsertStr += "#ifndef NO_FRAG_OUTPUT\n"; - m_InsertStr += "out vec4 fragOutput;\n"; - m_InsertStr += "#endif\n"; - str.insert(fragOutputIndex, m_InsertStr); - } } // Compile this program overwriting any existing ones. NVRenderShaderProgram * |