summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/program.hpp
diff options
context:
space:
mode:
authorAleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com>2019-05-20 16:17:19 +0300
committerGitHub <noreply@github.com>2019-05-20 16:17:19 +0300
commit2a3a1c7bb36410c6037f1d8da46fa68733efbe42 (patch)
treef041b0065195cceefd221663d6a9bac5263d736d /src/mbgl/gl/program.hpp
parent8d91264160b49465cb403de6c6e3f419163b76f7 (diff)
downloadqtlocation-mapboxgl-2a3a1c7bb36410c6037f1d8da46fa68733efbe42.tar.gz
[core] Remove re-linking programs approach (#14482)
Remove re-linking programs as redundant. It costs (cheaper to link once than twice) and (subjective) is not that common GL API usage pattern, although perfectly legal and permitted. Initial idea, behind the removed code, was to enable work on optimization that would reduce number of attrib setup calls in case when VAO is not available (as described in #9433). As such optimization is not implemented, and it is arguable if it makes sense to do it now, we can remove re-linking. Related to closed PRs #9433 and PR #11583. I have [measured the time spent just on relinking](https://gist.github.com/astojilj/29bd5a5c5dc0b2d9f29ecb660da07fbf) using release build on iPhone SE (A9, same as iPhone 6S): - 1st run after reboot or installation Total 37.14ms, average per program:1.86ms - reopening Total: 2.47ms, average per program: 0.12ms This time we save using the patch here.
Diffstat (limited to 'src/mbgl/gl/program.hpp')
-rw-r--r--src/mbgl/gl/program.hpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp
index 3757c442de..8540385e97 100644
--- a/src/mbgl/gl/program.hpp
+++ b/src/mbgl/gl/program.hpp
@@ -49,15 +49,10 @@ public:
const std::initializer_list<const char*>& fragmentSource)
: program(context.createProgram(
context.createShader(ShaderType::Vertex, vertexSource),
- context.createShader(ShaderType::Fragment, fragmentSource))),
- attributeLocations(context, program) {
- // Re-link program after manually binding only active attributes in Attributes::queryLocations
- context.linkProgram(program);
-
- // We have to re-initialize the uniforms state from the bindings as the uniform locations
- // get shifted on some implementations
+ context.createShader(ShaderType::Fragment, fragmentSource),
+ attributeLocations.getFirstAttribName())) {
+ attributeLocations.queryLocations(program);
uniformStates.queryLocations(program);
-
// Texture units are specified via uniforms as well, so we need query their locations
textureStates.queryLocations(program);
}