mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:23:53 +00:00
fixes LightBufferBinding messages (#3223)
This PR aims to solve `uniform block LightBufferBinding has no binding` messages @glassmancody has reportedly encountered since PR #3110 due to an apparent bug in OSG. While we do have to add a workaround here that adds a bit of clunkiness, #3216 should allow us to clean up these interactions a bit in the future.
This commit is contained in:
parent
3f48d67d8e
commit
2e031f195b
3 changed files with 13 additions and 2 deletions
|
@ -152,7 +152,7 @@ namespace MWRender
|
||||||
mStateset->setAttribute(new osg::VertexAttribDivisor(6, 1));
|
mStateset->setAttribute(new osg::VertexAttribDivisor(6, 1));
|
||||||
mStateset->setAttribute(new osg::VertexAttribDivisor(7, 1));
|
mStateset->setAttribute(new osg::VertexAttribDivisor(7, 1));
|
||||||
|
|
||||||
mProgramTemplate = mSceneManager->getShaderManager().getProgramTemplate() ? static_cast<osg::Program*>(mSceneManager->getShaderManager().getProgramTemplate()->clone(osg::CopyOp::SHALLOW_COPY)) : new osg::Program;
|
mProgramTemplate = mSceneManager->getShaderManager().getProgramTemplate() ? Shader::ShaderManager::cloneProgram(mSceneManager->getShaderManager().getProgramTemplate()) : osg::ref_ptr<osg::Program>(new osg::Program);
|
||||||
mProgramTemplate->addBindAttribLocation("aOffset", 6);
|
mProgramTemplate->addBindAttribLocation("aOffset", 6);
|
||||||
mProgramTemplate->addBindAttribLocation("aRotation", 7);
|
mProgramTemplate->addBindAttribLocation("aRotation", 7);
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,7 +345,7 @@ namespace Shader
|
||||||
if (found == mPrograms.end())
|
if (found == mPrograms.end())
|
||||||
{
|
{
|
||||||
if (!programTemplate) programTemplate = mProgramTemplate;
|
if (!programTemplate) programTemplate = mProgramTemplate;
|
||||||
osg::ref_ptr<osg::Program> program = programTemplate ? static_cast<osg::Program*>(programTemplate->clone(osg::CopyOp::SHALLOW_COPY)) : new osg::Program;
|
osg::ref_ptr<osg::Program> program = programTemplate ? cloneProgram(programTemplate) : osg::ref_ptr<osg::Program>(new osg::Program);
|
||||||
program->addShader(vertexShader);
|
program->addShader(vertexShader);
|
||||||
program->addShader(fragmentShader);
|
program->addShader(fragmentShader);
|
||||||
found = mPrograms.insert(std::make_pair(std::make_pair(vertexShader, fragmentShader), program)).first;
|
found = mPrograms.insert(std::make_pair(std::make_pair(vertexShader, fragmentShader), program)).first;
|
||||||
|
@ -353,6 +353,14 @@ namespace Shader
|
||||||
return found->second;
|
return found->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Program> ShaderManager::cloneProgram(const osg::Program* src)
|
||||||
|
{
|
||||||
|
osg::ref_ptr<osg::Program> program = static_cast<osg::Program*>(src->clone(osg::CopyOp::SHALLOW_COPY));
|
||||||
|
for (auto [name, idx] : src->getUniformBlockBindingList())
|
||||||
|
program->addBindUniformBlock(name, idx);
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
ShaderManager::DefineMap ShaderManager::getGlobalDefines()
|
ShaderManager::DefineMap ShaderManager::getGlobalDefines()
|
||||||
{
|
{
|
||||||
return DefineMap(mGlobalDefines);
|
return DefineMap(mGlobalDefines);
|
||||||
|
|
|
@ -38,6 +38,9 @@ namespace Shader
|
||||||
const osg::Program* getProgramTemplate() const { return mProgramTemplate; }
|
const osg::Program* getProgramTemplate() const { return mProgramTemplate; }
|
||||||
void setProgramTemplate(const osg::Program* program) { mProgramTemplate = program; }
|
void setProgramTemplate(const osg::Program* program) { mProgramTemplate = program; }
|
||||||
|
|
||||||
|
/// Clone an osg::Program including bindUniformBlocks that osg::Program::clone does not copy for some reason.
|
||||||
|
static osg::ref_ptr<osg::Program> cloneProgram(const osg::Program*);
|
||||||
|
|
||||||
/// Get (a copy of) the DefineMap used to construct all shaders
|
/// Get (a copy of) the DefineMap used to construct all shaders
|
||||||
DefineMap getGlobalDefines();
|
DefineMap getGlobalDefines();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue