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

Align pattern vertex array with 4-byte boundary again #12361

Merged
merged 1 commit into from
Nov 8, 2022
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
20 changes: 12 additions & 8 deletions src/data/array_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,20 @@ register(StructArrayLayout4f16, 'StructArrayLayout4f16');

/**
* Implementation of the StructArray layout:
* [0]: Uint16[5]
* [0]: Uint16[4]
* [8]: Float32[1]
*
* @private
*/
class StructArrayLayout5ui10 extends StructArray {
class StructArrayLayout4ui1f12 extends StructArray {
uint8: Uint8Array;
uint16: Uint16Array;
float32: Float32Array;

_refreshViews() {
this.uint8 = new Uint8Array(this.arrayBuffer);
this.uint16 = new Uint16Array(this.arrayBuffer);
this.float32 = new Float32Array(this.arrayBuffer);
}

emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number): number {
Expand All @@ -204,18 +207,19 @@ class StructArrayLayout5ui10 extends StructArray {
}

emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number): number {
const o2 = i * 5;
const o2 = i * 6;
const o4 = i * 3;
this.uint16[o2 + 0] = v0;
this.uint16[o2 + 1] = v1;
this.uint16[o2 + 2] = v2;
this.uint16[o2 + 3] = v3;
this.uint16[o2 + 4] = v4;
this.float32[o4 + 2] = v4;
return i;
}
}

StructArrayLayout5ui10.prototype.bytesPerElement = 10;
register(StructArrayLayout5ui10, 'StructArrayLayout5ui10');
StructArrayLayout4ui1f12.prototype.bytesPerElement = 12;
register(StructArrayLayout4ui1f12, 'StructArrayLayout4ui1f12');

/**
* Implementation of the StructArray layout:
Expand Down Expand Up @@ -1195,7 +1199,7 @@ export {
StructArrayLayout4i8,
StructArrayLayout2i4ub1f12,
StructArrayLayout4f16,
StructArrayLayout5ui10,
StructArrayLayout4ui1f12,
StructArrayLayout4ui8,
StructArrayLayout6i12,
StructArrayLayout4i4ui4i24,
Expand Down Expand Up @@ -1224,7 +1228,7 @@ export {
StructArrayLayout2i4 as HeatmapLayoutArray,
StructArrayLayout2i4ub1f12 as LineLayoutArray,
StructArrayLayout4f16 as LineExtLayoutArray,
StructArrayLayout5ui10 as PatternLayoutArray,
StructArrayLayout4ui1f12 as PatternLayoutArray,
StructArrayLayout4ui8 as DashLayoutArray,
StructArrayLayout6i12 as FillExtrusionExtArray,
StructArrayLayout4i4ui4i24 as SymbolLayoutArray,
Expand Down
2 changes: 1 addition & 1 deletion src/data/bucket/pattern_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {StructArrayLayout} from '../../util/struct_array.js';
const patternAttributes: StructArrayLayout = createLayout([
// [tl.x, tl.y, br.x, br.y]
{name: 'a_pattern', components: 4, type: 'Uint16'},
{name: 'a_pixel_ratio', components: 1, type: 'Uint16'}
{name: 'a_pixel_ratio', components: 1, type: 'Float32'}
]);

export default patternAttributes;