Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HeatmapLayer/GPUAggregator: fix WebGL feature checking #3483

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions modules/aggregation-layers/src/heatmap-layer/heatmap-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
scaleToAspectRatio,
getTextureCoordinates
} from './heatmap-layer-utils';
import {Buffer, Transform, getParameter, isWebGL2} from '@luma.gl/core';
import {Buffer, Transform, getParameter, FEATURES, hasFeatures} from '@luma.gl/core';
import {CompositeLayer, AttributeManager, COORDINATE_SYSTEM, log} from '@deck.gl/core';
import TriangleLayer from './triangle-layer';
import {getFloatTexture} from '../utils/resource-utils';
Expand Down Expand Up @@ -55,14 +55,22 @@ const defaultProps = {
threshold: {type: 'number', min: 0, max: 1, value: 0.05}
};

const REQUIRED_FEATURES = [
FEATURES.WEBGL2, // TODO: Remove after trannsform refactor
FEATURES.COLOR_ATTACHMENT_RGBA32F, // weight-map generation
FEATURES.BLEND_EQUATION_MINMAX, // max weight calculation
FEATURES.FLOAT_BLEND, // weight-map generation and max weight calculation
FEATURES.TEXTURE_FLOAT // weight-map as texture
];

export default class HeatmapLayer extends CompositeLayer {
initializeState() {
const {gl} = this.context;
const textureSize = Math.min(SIZE_2K, getParameter(gl, gl.MAX_TEXTURE_SIZE));
this.state = {textureSize, supported: true};
if (!isWebGL2(gl)) {
log.error(`HeatmapLayer ${this.id} is not supported on this browser, requires WebGL2`)();
if (!hasFeatures(gl, REQUIRED_FEATURES)) {
this.setState({supported: false});
log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();
return;
}
this._setupAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ const ARRAY_BUFFER_MAP = {
maxMinData: 'maxMinBuffer'
};

const REQUIRED_FEATURES = [
FEATURES.WEBGL2, // TODO: Remove after trannsform refactor
FEATURES.COLOR_ATTACHMENT_RGBA32F,
FEATURES.BLEND_EQUATION_MINMAX,
FEATURES.FLOAT_BLEND,
FEATURES.TEXTURE_FLOAT
];

export default class GPUGridAggregator {
// Decode and return aggregation data of given pixel.
static getAggregationData({aggregationData, maxData, minData, maxMinData, pixelIndex}) {
Expand Down Expand Up @@ -107,15 +115,7 @@ export default class GPUGridAggregator {
}

static isSupported(gl) {
return (
isWebGL2(gl) &&
hasFeatures(
gl,
FEATURES.BLEND_EQUATION_MINMAX,
FEATURES.COLOR_ATTACHMENT_RGBA32F,
FEATURES.TEXTURE_FLOAT
)
);
return hasFeatures(gl, REQUIRED_FEATURES);
}

// DEBUG ONLY
Expand Down