Skip to content

Commit

Permalink
Ensure symbol shader attrib bound at 0 is always valid and used (mapb…
Browse files Browse the repository at this point in the history
…ox#4688)

Manually bind a_data at position 0 for symbolSDF shader. Binding unused/undefined attributes to position 0 causes symbols to not render in Safari.
  • Loading branch information
Lauren Budorick authored and chrisvoll committed May 25, 2017
1 parent 4fffee8 commit 0a3cfa4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,14 @@ class Painter {
assert(gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS), gl.getShaderInfoLog(vertexShader));
gl.attachShader(program, vertexShader);


// For the symbol program, manually ensure the attrib bound to position 0 is always used (either a_data or a_pos_offset would work here).
// This is needed to fix https://github.com/mapbox/mapbox-gl-js/issues/4607 — otherwise a_size can be bound first, causing rendering to fail.
// All remaining attribs will be bound dynamically below.
if (name === 'symbolSDF') {
gl.bindAttribLocation(program, 0, 'a_data');
}

gl.linkProgram(program);
assert(gl.getProgramParameter(program, gl.LINK_STATUS), gl.getProgramInfoLog(program));

Expand Down
2 changes: 2 additions & 0 deletions src/shaders/symbol_sdf.vertex.glsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const float PI = 3.141592653589793;

// NOTE: the a_data attribute in this shader is manually bound (see https://github.com/mapbox/mapbox-gl-js/issues/4607).
// If removing or renaming a_data, revisit the manual binding in painter.js accordingly.
attribute vec4 a_pos_offset;
attribute vec4 a_data;

Expand Down

0 comments on commit 0a3cfa4

Please sign in to comment.