Skip to content

Commit 2faf0ab

Browse files
authored
Fix pattern attributes vertex layout (#9482)
* Fix vertex layout attribute offset when used with DDS The vertex layout offset for patternAttributes is overriden to be 0, this is incorrect as each component of this layout require a specific offset to be set to appropriately bind the buffers when calling vertexAttribPointer * Fix flow * Cleanup unused param * Add render tests for data driven styling coverage * EOL
1 parent 8131815 commit 2faf0ab

File tree

5 files changed

+105
-14
lines changed

5 files changed

+105
-14
lines changed

src/data/bucket/pattern_attributes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// @flow
22
import {createLayout} from '../../util/struct_array';
33

4-
export default createLayout([
4+
const patternAttributes = createLayout([
55
// [tl.x, tl.y, br.x, br.y]
66
{name: 'a_pattern_from', components: 4, type: 'Uint16'},
77
{name: 'a_pattern_to', components: 4, type: 'Uint16'},
88
{name: 'a_pixel_ratio_from', components: 1, type: 'Uint8'},
99
{name: 'a_pixel_ratio_to', components: 1, type: 'Uint8'},
1010
]);
11+
12+
export default patternAttributes;

src/data/program_configuration.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {register} from '../util/web_worker_transfer';
77
import {PossiblyEvaluatedPropertyValue} from '../style/properties';
88
import {StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray} from './array_types';
99
import {clamp} from '../util/util';
10-
10+
import patternAttributes from './bucket/pattern_attributes';
1111
import EvaluationParameters from '../style/evaluation_parameters';
1212
import FeaturePositionMap from './feature_position_map';
1313
import {
@@ -312,20 +312,13 @@ class CrossFadedCompositeBinder implements AttributeBinder {
312312
zoomOutPaintVertexBuffer: ?VertexBuffer;
313313
paintVertexAttributes: Array<StructArrayMember>;
314314

315-
constructor(expression: CompositeExpression, names: Array<string>, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: Class<StructArray>, layerId: string) {
315+
constructor(expression: CompositeExpression, type: string, useIntegerZoom: boolean, zoom: number, PaintVertexArray: Class<StructArray>, layerId: string) {
316316
this.expression = expression;
317317
this.type = type;
318318
this.useIntegerZoom = useIntegerZoom;
319319
this.zoom = zoom;
320320
this.layerId = layerId;
321321

322-
this.paintVertexAttributes = names.map((name) => ({
323-
name: `a_${name}`,
324-
type: 'Uint16',
325-
components: 4,
326-
offset: 0
327-
}));
328-
329322
this.zoomInPaintVertexArray = new PaintVertexArray();
330323
this.zoomOutPaintVertexArray = new PaintVertexArray();
331324
}
@@ -371,8 +364,8 @@ class CrossFadedCompositeBinder implements AttributeBinder {
371364

372365
upload(context: Context) {
373366
if (this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer) {
374-
this.zoomInPaintVertexBuffer = context.createVertexBuffer(this.zoomInPaintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);
375-
this.zoomOutPaintVertexBuffer = context.createVertexBuffer(this.zoomOutPaintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);
367+
this.zoomInPaintVertexBuffer = context.createVertexBuffer(this.zoomInPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);
368+
this.zoomOutPaintVertexBuffer = context.createVertexBuffer(this.zoomOutPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);
376369
}
377370
}
378371

@@ -438,7 +431,7 @@ export default class ProgramConfiguration {
438431
} else if (expression.kind === 'source' || isCrossFaded) {
439432
const StructArrayLayout = layoutType(property, type, 'source');
440433
this.binders[property] = isCrossFaded ?
441-
new CrossFadedCompositeBinder(expression, names, type, useIntegerZoom, zoom, StructArrayLayout, layer.id) :
434+
new CrossFadedCompositeBinder(expression, type, useIntegerZoom, zoom, StructArrayLayout, layer.id) :
442435
new SourceExpressionBinder(expression, names, type, StructArrayLayout);
443436
keys.push(`/a_${property}`);
444437

src/render/draw_fill_extrusion.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ function drawExtrusionTiles(painter, source, layer, coords, depthMode, stencilMo
6868
tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
6969
programConfiguration.updatePaintBuffers(crossfade);
7070
}
71-
7271
const constantPattern = patternProperty.constantOr(null);
7372
if (constantPattern && tile.imageAtlas) {
7473
const atlas = tile.imageAtlas;
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"height": 256,
6+
"width": 256,
7+
"pixelRatio": 1,
8+
"operations": [
9+
[
10+
"wait"
11+
],
12+
[
13+
"addImage",
14+
"pattern",
15+
"./image/marker.png",
16+
{
17+
"pixelRatio": 2
18+
}
19+
],
20+
[
21+
"wait"
22+
],
23+
[
24+
"addSource",
25+
"geojson",
26+
{
27+
"type": "geojson",
28+
"data": {
29+
"type": "FeatureCollection",
30+
"features": [
31+
{
32+
"type": "Feature",
33+
"properties": {
34+
"height": 10
35+
},
36+
"geometry": {
37+
"type": "Polygon",
38+
"coordinates": [
39+
[
40+
[
41+
-0.0001,
42+
-0.0001
43+
],
44+
[
45+
-0.0001,
46+
0.0001
47+
],
48+
[
49+
0.0001,
50+
0.0001
51+
],
52+
[
53+
0.0001,
54+
-0.0001
55+
],
56+
[
57+
-0.0001,
58+
-0.0001
59+
]
60+
]
61+
]
62+
}
63+
}
64+
]
65+
}
66+
}
67+
],
68+
[
69+
"wait"
70+
],
71+
[
72+
"addLayer",
73+
{
74+
"id": "extrusion",
75+
"type": "fill-extrusion",
76+
"source": "geojson",
77+
"paint": {
78+
"fill-extrusion-pattern": {
79+
"property": "height",
80+
"type": "interval",
81+
"stops": [[0, "pattern"]]
82+
},
83+
"fill-extrusion-height": 10
84+
}
85+
}
86+
],
87+
[
88+
"wait"
89+
]
90+
]
91+
}
92+
},
93+
"pitch": 60,
94+
"zoom": 19,
95+
"sources": {},
96+
"layers": []
97+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy