Index: ps/trunk/source/graphics/Material.h =================================================================== --- ps/trunk/source/graphics/Material.h +++ ps/trunk/source/graphics/Material.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -46,7 +46,7 @@ // models using this material need to be rendered in a special order // relative to the alpha-blended water plane void SetUsesAlphaBlending(bool flag) { m_AlphaBlending = flag; } - bool UsesAlphaBlending() { return m_AlphaBlending; } + bool UsesAlphaBlending() const { return m_AlphaBlending; } const CTexturePtr& GetDiffuseTexture() const { return m_DiffuseTexture; } Index: ps/trunk/source/graphics/ShaderProgram.h =================================================================== --- ps/trunk/source/graphics/ShaderProgram.h +++ ps/trunk/source/graphics/ShaderProgram.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -112,7 +112,7 @@ * Returns whether this uniform attribute is active in the shader. * If not then there's no point calling Uniform() to set its value. */ - bool Active() { return first != -1 || second != -1; } + bool Active() const { return first != -1 || second != -1; } int first; int second; Index: ps/trunk/source/renderer/HWLightingModelRenderer.cpp =================================================================== --- ps/trunk/source/renderer/HWLightingModelRenderer.cpp +++ ps/trunk/source/renderer/HWLightingModelRenderer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -274,7 +274,7 @@ // Render one model void ShaderModelVertexRenderer::RenderModel(const CShaderProgramPtr& shader, int streamflags, CModel* model, CModelRData* data) { - CModelDefPtr mdldef = model->GetModelDef(); + const CModelDefPtr& mdldef = model->GetModelDef(); ShaderModel* shadermodel = static_cast(data); u8* base = shadermodel->m_Array.Bind(); Index: ps/trunk/source/renderer/InstancingModelRenderer.cpp =================================================================== --- ps/trunk/source/renderer/InstancingModelRenderer.cpp +++ ps/trunk/source/renderer/InstancingModelRenderer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -350,7 +350,7 @@ // Render one model void InstancingModelRenderer::RenderModel(const CShaderProgramPtr& shader, int UNUSED(streamflags), CModel* model, CModelRData* UNUSED(data)) { - CModelDefPtr mdldef = model->GetModelDef(); + const CModelDefPtr& mdldef = model->GetModelDef(); if (m->gpuSkinning) { Index: ps/trunk/source/renderer/ModelRenderer.cpp =================================================================== --- ps/trunk/source/renderer/ModelRenderer.cpp +++ ps/trunk/source/renderer/ModelRenderer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -688,25 +688,19 @@ { const CMaterial::TextureSampler& samp = samplers[s]; - CShaderProgram::Binding bind = texBindings[s]; // check that the handles are current // and reevaluate them if necessary - if (texBindingNames[s] == samp.Name && bind.Active()) + if (texBindingNames[s] != samp.Name || !texBindings[s].Active()) { - bind = texBindings[s]; - } - else - { - bind = shader->GetTextureBinding(samp.Name); - texBindings[s] = bind; + texBindings[s] = shader->GetTextureBinding(samp.Name); texBindingNames[s] = samp.Name; } // same with the actual sampler bindings CTexture* newTex = samp.Sampler.get(); - if (bind.Active() && newTex != currentTexs[s]) + if (texBindings[s].Active() && newTex != currentTexs[s]) { - shader->BindTexture(bind, samp.Sampler->GetHandle()); + shader->BindTexture(texBindings[s], newTex->GetHandle()); currentTexs[s] = newTex; } }