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

Pattern attributes 4-bytes alignment #9681

Merged
merged 3 commits into from
May 14, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/generate-struct-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ function createStructArrayLayoutType({members, size, alignment}) {

const key = `${members.map(m => `${m.components}${typeAbbreviations[m.type]}`).join('')}${size}`;
const className = `StructArrayLayout${key}`;
// Layout alignment to 4 bytes boundaries can be an issue on some set of graphics cards. Particularly AMD.
if (size % 4 !== 0) { console.warn(`Warning: The layout ${className} is not aligned to 4-bytes boundaries.`); }
if (!layoutCache[key]) {
layoutCache[key] = {
className,
Expand Down
20 changes: 9 additions & 11 deletions src/data/array_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,11 @@ register('StructArrayLayout2i4ub8', StructArrayLayout2i4ub8);

/**
* Implementation of the StructArray layout:
* [0]: Uint16[8]
* [16]: Uint8[2]
* [0]: Uint16[10]
*
* @private
*/
class StructArrayLayout8ui2ub18 extends StructArray {
class StructArrayLayout10ui20 extends StructArray {
uint8: Uint8Array;
uint16: Uint16Array;

Expand All @@ -170,8 +169,7 @@ class StructArrayLayout8ui2ub18 extends StructArray {
}

emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number) {
const o2 = i * 9;
const o1 = i * 18;
const o2 = i * 10;
this.uint16[o2 + 0] = v0;
this.uint16[o2 + 1] = v1;
this.uint16[o2 + 2] = v2;
Expand All @@ -180,14 +178,14 @@ class StructArrayLayout8ui2ub18 extends StructArray {
this.uint16[o2 + 5] = v5;
this.uint16[o2 + 6] = v6;
this.uint16[o2 + 7] = v7;
this.uint8[o1 + 16] = v8;
this.uint8[o1 + 17] = v9;
this.uint16[o2 + 8] = v8;
this.uint16[o2 + 9] = v9;
return i;
}
}

StructArrayLayout8ui2ub18.prototype.bytesPerElement = 18;
register('StructArrayLayout8ui2ub18', StructArrayLayout8ui2ub18);
StructArrayLayout10ui20.prototype.bytesPerElement = 20;
register('StructArrayLayout10ui20', StructArrayLayout10ui20);

/**
* Implementation of the StructArray layout:
Expand Down Expand Up @@ -1097,7 +1095,7 @@ export {
StructArrayLayout4i8,
StructArrayLayout2i4i12,
StructArrayLayout2i4ub8,
StructArrayLayout8ui2ub18,
StructArrayLayout10ui20,
StructArrayLayout4i4ui4i24,
StructArrayLayout3f12,
StructArrayLayout1ul4,
Expand All @@ -1122,7 +1120,7 @@ export {
StructArrayLayout2i4i12 as FillExtrusionLayoutArray,
StructArrayLayout2i4 as HeatmapLayoutArray,
StructArrayLayout2i4ub8 as LineLayoutArray,
StructArrayLayout8ui2ub18 as PatternLayoutArray,
StructArrayLayout10ui20 as PatternLayoutArray,
StructArrayLayout4i4ui4i24 as SymbolLayoutArray,
StructArrayLayout3f12 as SymbolDynamicLayoutArray,
StructArrayLayout1ul4 as SymbolOpacityArray,
Expand Down
4 changes: 2 additions & 2 deletions src/data/bucket/pattern_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const patternAttributes = createLayout([
// [tl.x, tl.y, br.x, br.y]
{name: 'a_pattern_from', components: 4, type: 'Uint16'},
{name: 'a_pattern_to', components: 4, type: 'Uint16'},
{name: 'a_pixel_ratio_from', components: 1, type: 'Uint8'},
{name: 'a_pixel_ratio_to', components: 1, type: 'Uint8'},
{name: 'a_pixel_ratio_from', components: 1, type: 'Uint16'},
{name: 'a_pixel_ratio_to', components: 1, type: 'Uint16'},
]);

export default patternAttributes;
3 changes: 2 additions & 1 deletion test/ignores.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"render-tests/tile-mode/streets-v11": "skip - mapbox-gl-js does not support tile-mode",
"render-tests/within/paint-line": "https://github.com/mapbox/mapbox-gl-js/issues/7023",
"render-tests/icon-text-fit/text-variable-anchor-tile-map-mode": "skip - mapbox-gl-js does not support tile-mode",
"render-tests/text-variable-anchor/all-anchors-labels-priority-tile-map-mode": "skip - mapbox-gl-js does not support tile-mode"
"render-tests/text-variable-anchor/all-anchors-labels-priority-tile-map-mode": "skip - mapbox-gl-js does not support tile-mode",
"render-tests/fill-extrusion-pattern/1.5x-on-1x-add-image": "skip - non-deterministic on AMD graphics cards"
}