[core] re-bind uniform locations after re-linking program

- On some gl implementations the uniform locations are shifted after linking the program a second time, resulting in errors when using any uniform. On some implementations they are actually doubled. Re-binding the uniforms after selectively binding the vertex attributes prevents this.
This commit is contained in:
Ivo van Dongen
2018-04-03 15:59:35 +03:00
committed by Ivo van Dongen
parent 553efa38e3
commit 4a0e025134

View File

@@ -36,8 +36,13 @@ public:
context.createShader(ShaderType::Fragment, fragmentSource))), context.createShader(ShaderType::Fragment, fragmentSource))),
uniformsState((context.linkProgram(program), Uniforms::bindLocations(program))), uniformsState((context.linkProgram(program), Uniforms::bindLocations(program))),
attributeLocations(Attributes::bindLocations(program)) { attributeLocations(Attributes::bindLocations(program)) {
// Re-link program after manually binding only active attributes in Attributes::bindLocations // Re-link program after manually binding only active attributes in Attributes::bindLocations
context.linkProgram(program); context.linkProgram(program);
// We have to re-initialize the uniforms state from the bindings as the uniform locations
// get shifted on some implementations
uniformsState = Uniforms::bindLocations(program);
} }
template <class BinaryProgram> template <class BinaryProgram>