Skip to content

Commit

Permalink
Cache hillshade textures based on texture size, not tile size.
Browse files Browse the repository at this point in the history
Fixes mapbox#7690 -- hillshade layers leak GPU memory.
  • Loading branch information
ChrisLoer authored and pirxpilot committed Jun 18, 2019
1 parent a67e6cf commit dce6e76
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/render/draw_hillshade.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function prepareHillshade(painter, tile, layer, sourceMaxZoom, depthMode, stenci
// base 2 - 0000 0000, 0000 0001, 0000 0110, 1110 1100
if (tile.dem && tile.dem.data) {
const tileSize = tile.dem.dim;
const textureStride = tile.dem.stride;

const pixelData = tile.dem.getPixels();
context.activeTexture.set(gl.TEXTURE1);
Expand All @@ -83,7 +84,7 @@ function prepareHillshade(painter, tile, layer, sourceMaxZoom, depthMode, stenci
// tiles will appear blank, because as you can see above the alpha value for these textures
// is always 0
context.pixelStoreUnpackPremultiplyAlpha.set(false);
tile.demTexture = tile.demTexture || painter.getTileTexture(tile.tileSize);
tile.demTexture = tile.demTexture || painter.getTileTexture(textureStride);
if (tile.demTexture) {
const demTexture = tile.demTexture;
demTexture.update(pixelData, { premultiply: false });
Expand Down

0 comments on commit dce6e76

Please sign in to comment.