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 #7690 -- hillshade layers leak GPU memory.
  • Loading branch information
ChrisLoer committed Dec 12, 2018
1 parent 9cf6a0c commit 83a9b53
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 @@ -80,6 +80,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 @@ -88,7 +89,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 83a9b53

Please sign in to comment.