Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ binaries/data/config/default.cfg @@ -156,9 +156,6 @@ materialmgr.PARALLAX_VHQ_DIST.max = 0 ;;;;;;;;;;;;;;;;;;;;;;;; -; Replace alpha-blending with alpha-testing, for performance experiments -forcealphatest = false - ; Color of the sky (in "r g b" format) skycolor = "0 0 0" Index: binaries/data/mods/public/shaders/effects/model_transparent.xml =================================================================== --- binaries/data/mods/public/shaders/effects/model_transparent.xml +++ binaries/data/mods/public/shaders/effects/model_transparent.xml @@ -39,26 +39,6 @@ - - - - - - - - - - - - - - - - - - - - Index: source/graphics/MaterialManager.cpp =================================================================== --- source/graphics/MaterialManager.cpp +++ source/graphics/MaterialManager.cpp @@ -79,7 +79,6 @@ #undef EL CPreprocessorWrapper preprocessor; - preprocessor.AddDefine("CFG_FORCE_ALPHATEST", g_RenderingOptions.GetForceAlphaTest() ? "1" : "0"); CMaterial material; material.AddStaticUniform("qualityLevel", CVector4D(qualityLevel, 0, 0, 0)); Index: source/graphics/ShaderManager.cpp =================================================================== --- source/graphics/ShaderManager.cpp +++ source/graphics/ShaderManager.cpp @@ -385,7 +385,6 @@ // Define all the elements and attributes used in the XML file #define EL(x) int el_##x = XeroFile.GetElementID(#x) #define AT(x) int at_##x = XeroFile.GetAttributeID(#x) - EL(alpha); EL(blend); EL(define); EL(depth); @@ -395,7 +394,6 @@ AT(context); AT(dst); AT(func); - AT(ref); AT(shader); AT(shaders); AT(src); @@ -429,6 +427,7 @@ { XMBAttributeList Attrs = Child.GetAttributes(); + // TODO: require should be an attribute of the tech and not its child. if (Child.GetNodeName() == el_require) { if (Attrs.GetNamedItem(at_shaders) == "arb") @@ -472,7 +471,6 @@ }); CShaderDefines techDefines = baseDefines; - XERO_ITER_EL(usableTechs[0].first, Child) { if (Child.GetNodeName() == el_define) @@ -483,7 +481,15 @@ { tech->SetSortByDistance(true); } - else if (Child.GetNodeName() == el_pass) + } + // We don't want to have a shader context depending on the order of define and + // pass tags. + // TODO: we might want to implement that in a proper way via splitting passes + // and tags in different groups in XML. + std::vector techPasses; + XERO_ITER_EL(usableTechs[0].first, Child) + { + if (Child.GetNodeName() == el_pass) { CShaderDefines passDefines = techDefines; @@ -495,12 +501,6 @@ { passDefines.Add(CStrIntern(Element.GetAttributes().GetNamedItem(at_name)), CStrIntern(Element.GetAttributes().GetNamedItem(at_value))); } - else if (Element.GetNodeName() == el_alpha) - { - GLenum func = ParseComparisonFunc(Element.GetAttributes().GetNamedItem(at_func)); - float ref = Element.GetAttributes().GetNamedItem(at_ref).ToFloat(); - pass.AlphaFunc(func, ref); - } else if (Element.GetNodeName() == el_blend) { GLenum src = ParseBlendFunc(Element.GetAttributes().GetNamedItem(at_src)); @@ -520,9 +520,11 @@ // Load the shader program after we've read all the possibly-relevant s pass.SetShader(LoadProgram(Child.GetAttributes().GetNamedItem(at_shader).c_str(), passDefines)); - tech->AddPass(pass); + techPasses.emplace_back(std::move(pass)); } } + + tech->SetPasses(std::move(techPasses)); return true; } Index: source/graphics/ShaderTechnique.h =================================================================== --- source/graphics/ShaderTechnique.h +++ source/graphics/ShaderTechnique.h @@ -39,7 +39,6 @@ void SetShader(const CShaderProgramPtr& shader) { m_Shader = shader; } // Add various bits of GL state to the pass: - void AlphaFunc(GLenum func, GLclampf ref); void BlendFunc(GLenum src, GLenum dst); void ColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a); void DepthMask(GLboolean mask); @@ -60,24 +59,20 @@ private: CShaderProgramPtr m_Shader; - bool m_HasAlpha; - GLenum m_AlphaFunc; - GLclampf m_AlphaRef; - - bool m_HasBlend; + bool m_HasBlend = false; GLenum m_BlendSrc; GLenum m_BlendDst; - bool m_HasColorMask; + bool m_HasColorMask = false; GLboolean m_ColorMaskR; GLboolean m_ColorMaskG; GLboolean m_ColorMaskB; GLboolean m_ColorMaskA; - bool m_HasDepthMask; + bool m_HasDepthMask = false; GLboolean m_DepthMask; - bool m_HasDepthFunc; + bool m_HasDepthFunc = false; GLenum m_DepthFunc; }; @@ -89,7 +84,7 @@ { public: CShaderTechnique(); - void AddPass(const CShaderPass& pass); + void SetPasses(std::vector&& passes); int GetNumPasses() const; @@ -108,7 +103,7 @@ private: std::vector m_Passes; - bool m_SortByDistance; + bool m_SortByDistance = false; }; #endif // INCLUDED_SHADERTECHNIQUE Index: source/graphics/ShaderTechnique.cpp =================================================================== --- source/graphics/ShaderTechnique.cpp +++ source/graphics/ShaderTechnique.cpp @@ -21,22 +21,12 @@ #include "graphics/ShaderProgram.h" -CShaderPass::CShaderPass() : - m_HasAlpha(false), m_HasBlend(false), m_HasColorMask(false), m_HasDepthMask(false), m_HasDepthFunc(false) -{ -} +CShaderPass::CShaderPass() = default; void CShaderPass::Bind() { m_Shader->Bind(); -#if !CONFIG2_GLES - if (m_HasAlpha) - { - glEnable(GL_ALPHA_TEST); - glAlphaFunc(m_AlphaFunc, m_AlphaRef); - } -#endif // TODO: maybe emit some warning if GLSL shaders try to use alpha test; // the test should be done inside the shader itself @@ -60,11 +50,6 @@ { m_Shader->Unbind(); -#if !CONFIG2_GLES - if (m_HasAlpha) - glDisable(GL_ALPHA_TEST); -#endif - if (m_HasBlend) glDisable(GL_BLEND); @@ -78,13 +63,6 @@ glDepthFunc(GL_LEQUAL); } -void CShaderPass::AlphaFunc(GLenum func, GLclampf ref) -{ - m_HasAlpha = true; - m_AlphaFunc = func; - m_AlphaRef = ref; -} - void CShaderPass::BlendFunc(GLenum src, GLenum dst) { m_HasBlend = true; @@ -114,14 +92,11 @@ } -CShaderTechnique::CShaderTechnique() - : m_SortByDistance(false) -{ -} +CShaderTechnique::CShaderTechnique() = default; -void CShaderTechnique::AddPass(const CShaderPass& pass) +void CShaderTechnique::SetPasses(std::vector&& passes) { - m_Passes.push_back(pass); + m_Passes = std::move(passes); } int CShaderTechnique::GetNumPasses() const Index: source/renderer/RenderingOptions.h =================================================================== --- source/renderer/RenderingOptions.h +++ source/renderer/RenderingOptions.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -113,7 +113,6 @@ OPTION(ShadowAlphaFix, bool); OPTION(ARBProgramShadow, bool); OPTION(Particles, bool); - OPTION(ForceAlphaTest, bool); OPTION(GPUSkinning, bool); OPTION(Silhouettes, bool); OPTION(SmoothLOS, bool); Index: source/renderer/RenderingOptions.cpp =================================================================== --- source/renderer/RenderingOptions.cpp +++ source/renderer/RenderingOptions.cpp @@ -123,7 +123,6 @@ m_Particles = false; m_Silhouettes = false; m_Fog = false; - m_ForceAlphaTest = false; m_GPUSkinning = false; m_SmoothLOS = false; m_PostProc = false; @@ -212,7 +211,6 @@ }); m_ConfigHooks->Setup("silhouettes", m_Silhouettes); - m_ConfigHooks->Setup("forcealphatest", m_ForceAlphaTest); m_ConfigHooks->Setup("gpuskinning", [this]() { bool enabled; CFG_GET_VAL("gpuskinning", enabled);