@flighthq/texture-formats 0.3.1-next.975.01aea94 → 0.4.0-edge.1908.751021c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/parseBasis.js
CHANGED
|
@@ -109,8 +109,10 @@ function hasBasisSignature(bytes) {
|
|
|
109
109
|
const basisTotalSlicesOffset = 14;
|
|
110
110
|
const basisTexFormatOffset = 20;
|
|
111
111
|
const basisTexTypeOffset = 23;
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
// Both codebook byte lengths are packed U24 fields. Accounting for those six bytes places
|
|
113
|
+
// m_tables_file_size at 61..64 and m_slice_desc_file_ofs immediately after it, at 65..68.
|
|
114
|
+
const basisSliceDescOffsetField = 65;
|
|
115
|
+
const basisHeaderMinSize = 69; // through m_slice_desc_file_ofs (offset 65, 4 bytes)
|
|
114
116
|
const basisSliceDescSize = 23;
|
|
115
117
|
const basisTextureType2d = 0;
|
|
116
118
|
const basisTextureType2dArray = 1;
|
package/dist/parseBasis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseBasis.js","sourceRoot":"","sources":["../src/parseBasis.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,MAAM,UAAU,0BAA0B,CAAC,KAA2B;IACpE,MAAM,OAAO,GAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC/C,MAAM,SAAS,GAAG,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACrD,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC;AAED,wGAAwG;AACxG,8EAA8E;AAC9E,EAAE;AACF,uGAAuG;AACvG,oGAAoG;AACpG,sGAA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BAAuB,GAAG,CAAC,CAAC;AAClC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AACvC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AACtC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC,MAAM,cAAc,GAAqD;IACvE,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,OAAO;CACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/texture-formats",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-edge.1908.751021c",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/types": "0.
|
|
41
|
+
"@flighthq/types": "0.4.0-edge.1908.751021c"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"typescript": "^5.3.0"
|
|
@@ -23,7 +23,7 @@ describe('explainTextureContainerParse', () => {
|
|
|
23
23
|
reason: 'format-unsupported',
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
const basis = new Uint8Array(
|
|
26
|
+
const basis = new Uint8Array(69);
|
|
27
27
|
basis.set([0x73, 0x42]);
|
|
28
28
|
expect(explainTextureContainerParse(basis)).toEqual({
|
|
29
29
|
container: 'basis',
|
package/src/parseBasis.test.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TextureContainer } from '@flighthq/types/contract';
|
|
1
2
|
import { describe, expect, it } from 'vitest';
|
|
2
3
|
|
|
3
4
|
import { getBasisParseFailureReason, parseBasis } from './parseBasis';
|
|
@@ -18,6 +19,18 @@ interface BasisOptions {
|
|
|
18
19
|
slices: readonly BasisSlice[];
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
interface BasisFixtureExpectation {
|
|
23
|
+
expected: Readonly<TextureContainer>;
|
|
24
|
+
levelIndices: readonly number[];
|
|
25
|
+
path: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface UnsupportedBasisFixtureExpectation {
|
|
29
|
+
path: string;
|
|
30
|
+
reason: 'format-unsupported';
|
|
31
|
+
texFormat: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
const basisHeaderSize = 77;
|
|
22
35
|
const basisSliceDescSize = 23;
|
|
23
36
|
|
|
@@ -40,7 +53,7 @@ function buildBasis(opts: BasisOptions): Uint8Array {
|
|
|
40
53
|
setU24(dv, 17, totalImages); // m_total_images
|
|
41
54
|
bytes[20] = texFormat; // m_tex_format
|
|
42
55
|
bytes[23] = texType; // m_tex_type
|
|
43
|
-
dv.setUint32(
|
|
56
|
+
dv.setUint32(65, sliceTableOffset, true); // m_slice_desc_file_ofs
|
|
44
57
|
let off = sliceTableOffset;
|
|
45
58
|
for (const slice of slices) {
|
|
46
59
|
setU24(dv, off, slice.imageIndex);
|
|
@@ -61,19 +74,37 @@ describe('getBasisParseFailureReason', () => {
|
|
|
61
74
|
});
|
|
62
75
|
|
|
63
76
|
describe('parseBasis', () => {
|
|
77
|
+
it.each(BASIS_FIXTURE_EXPECTATIONS)('matches the exact measured semantics of $path', (fixture) => {
|
|
78
|
+
expect(parseBasis(buildMeasuredBasisFixture(fixture))).toEqual(fixture.expected);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it.each(UNSUPPORTED_BASIS_FIXTURE_EXPECTATIONS)(
|
|
82
|
+
'continues to decline unsupported fixture $path as $reason',
|
|
83
|
+
({ reason, texFormat }) => {
|
|
84
|
+
const bytes = buildBasis({
|
|
85
|
+
slices: [{ fileOfs: 100, fileSize: 8, height: 4, imageIndex: 0, levelIndex: 0, width: 4 }],
|
|
86
|
+
texFormat,
|
|
87
|
+
});
|
|
88
|
+
expect(parseBasis(bytes)).toBeNull();
|
|
89
|
+
expect(getBasisParseFailureReason(bytes)).toBe(reason);
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
|
|
64
93
|
it('parses a single-slice ETC1S image', () => {
|
|
65
94
|
const container = parseBasis(
|
|
66
95
|
buildBasis({ slices: [{ fileOfs: 100, fileSize: 8, height: 4, imageIndex: 0, levelIndex: 0, width: 4 }] }),
|
|
67
96
|
);
|
|
68
|
-
expect(container).
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
97
|
+
expect(container).toEqual({
|
|
98
|
+
depth: 1,
|
|
99
|
+
faces: 1,
|
|
100
|
+
format: 'etc1s',
|
|
101
|
+
height: 4,
|
|
102
|
+
layers: 1,
|
|
103
|
+
levels: [{ byteLength: 8, byteOffset: 100, height: 4, width: 4 }],
|
|
104
|
+
mipLevels: 1,
|
|
105
|
+
supercompression: 'None',
|
|
106
|
+
width: 4,
|
|
107
|
+
});
|
|
77
108
|
});
|
|
78
109
|
|
|
79
110
|
it('reports a mip chain from the slice level indices', () => {
|
|
@@ -173,7 +204,216 @@ describe('parseBasis', () => {
|
|
|
173
204
|
const bytes = buildBasis({
|
|
174
205
|
slices: [{ fileOfs: 100, fileSize: 8, height: 4, imageIndex: 0, levelIndex: 0, width: 4 }],
|
|
175
206
|
});
|
|
176
|
-
new DataView(bytes.buffer).setUint32(
|
|
207
|
+
new DataView(bytes.buffer).setUint32(65, 1_000_000, true); // corrupt m_slice_desc_file_ofs
|
|
177
208
|
expect(parseBasis(bytes)).toBeNull();
|
|
178
209
|
});
|
|
179
210
|
});
|
|
211
|
+
|
|
212
|
+
function buildMeasuredBasisFixture(fixture: Readonly<BasisFixtureExpectation>): Uint8Array {
|
|
213
|
+
return buildBasis({
|
|
214
|
+
slices: fixture.expected.levels.map((level, index) => ({
|
|
215
|
+
fileOfs: level.byteOffset,
|
|
216
|
+
fileSize: level.byteLength,
|
|
217
|
+
height: level.height,
|
|
218
|
+
imageIndex: 0,
|
|
219
|
+
levelIndex: fixture.levelIndices[index]!,
|
|
220
|
+
width: level.width,
|
|
221
|
+
})),
|
|
222
|
+
texFormat: fixture.expected.format === 'uastc' ? 1 : 0,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Fetch: `npm run fixtures -- texture-container-fixtures`.
|
|
227
|
+
// Pinned release 0.1.1 manifest SHA256: 4332d1473b8c47fefd73015d4c7b3ba67edbda3c6faba2c69597f62a47a15744.
|
|
228
|
+
const BASIS_FIXTURE_EXPECTATIONS: readonly BasisFixtureExpectation[] = [
|
|
229
|
+
{
|
|
230
|
+
expected: {
|
|
231
|
+
depth: 1,
|
|
232
|
+
faces: 1,
|
|
233
|
+
format: 'etc1s',
|
|
234
|
+
height: 512,
|
|
235
|
+
layers: 1,
|
|
236
|
+
levels: [
|
|
237
|
+
{ byteLength: 62_601, byteOffset: 45_273, height: 512, width: 768 },
|
|
238
|
+
{ byteLength: 40_817, byteOffset: 107_874, height: 512, width: 768 },
|
|
239
|
+
],
|
|
240
|
+
mipLevels: 1,
|
|
241
|
+
supercompression: 'None',
|
|
242
|
+
width: 768,
|
|
243
|
+
},
|
|
244
|
+
levelIndices: [0, 0],
|
|
245
|
+
path: 'basis/webgl/texture_test/assets/alpha3.basis',
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
expected: {
|
|
249
|
+
depth: 1,
|
|
250
|
+
faces: 1,
|
|
251
|
+
format: 'etc1s',
|
|
252
|
+
height: 512,
|
|
253
|
+
layers: 1,
|
|
254
|
+
levels: [
|
|
255
|
+
{ byteLength: 48_567, byteOffset: 10_417, height: 512, width: 768 },
|
|
256
|
+
{ byteLength: 12_500, byteOffset: 58_984, height: 256, width: 384 },
|
|
257
|
+
{ byteLength: 3_173, byteOffset: 71_484, height: 128, width: 192 },
|
|
258
|
+
{ byteLength: 827, byteOffset: 74_657, height: 64, width: 96 },
|
|
259
|
+
{ byteLength: 217, byteOffset: 75_484, height: 32, width: 48 },
|
|
260
|
+
{ byteLength: 61, byteOffset: 75_701, height: 16, width: 24 },
|
|
261
|
+
{ byteLength: 14, byteOffset: 75_762, height: 8, width: 12 },
|
|
262
|
+
{ byteLength: 7, byteOffset: 75_776, height: 4, width: 6 },
|
|
263
|
+
{ byteLength: 4, byteOffset: 75_783, height: 2, width: 3 },
|
|
264
|
+
{ byteLength: 4, byteOffset: 75_787, height: 1, width: 1 },
|
|
265
|
+
],
|
|
266
|
+
mipLevels: 10,
|
|
267
|
+
supercompression: 'None',
|
|
268
|
+
width: 768,
|
|
269
|
+
},
|
|
270
|
+
levelIndices: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
271
|
+
path: 'basis/webgl/texture_test/assets/kodim01_mipmapped.basis',
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
expected: {
|
|
275
|
+
depth: 1,
|
|
276
|
+
faces: 1,
|
|
277
|
+
format: 'etc1s',
|
|
278
|
+
height: 512,
|
|
279
|
+
layers: 1,
|
|
280
|
+
levels: [{ byteLength: 51_390, byteOffset: 33_914, height: 512, width: 768 }],
|
|
281
|
+
mipLevels: 1,
|
|
282
|
+
supercompression: 'None',
|
|
283
|
+
width: 768,
|
|
284
|
+
},
|
|
285
|
+
levelIndices: [0],
|
|
286
|
+
path: 'basis/webgl/texture_test/assets/kodim03.basis',
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
expected: {
|
|
290
|
+
depth: 1,
|
|
291
|
+
faces: 1,
|
|
292
|
+
format: 'uastc',
|
|
293
|
+
height: 512,
|
|
294
|
+
layers: 1,
|
|
295
|
+
levels: [{ byteLength: 393_216, byteOffset: 100, height: 512, width: 768 }],
|
|
296
|
+
mipLevels: 1,
|
|
297
|
+
supercompression: 'None',
|
|
298
|
+
width: 768,
|
|
299
|
+
},
|
|
300
|
+
levelIndices: [0],
|
|
301
|
+
path: 'basis/webgl/texture_test/assets/kodim03_uastc.basis',
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
expected: {
|
|
305
|
+
depth: 1,
|
|
306
|
+
faces: 1,
|
|
307
|
+
format: 'uastc',
|
|
308
|
+
height: 768,
|
|
309
|
+
layers: 1,
|
|
310
|
+
levels: [{ byteLength: 393_216, byteOffset: 100, height: 768, width: 512 }],
|
|
311
|
+
mipLevels: 1,
|
|
312
|
+
supercompression: 'None',
|
|
313
|
+
width: 512,
|
|
314
|
+
},
|
|
315
|
+
levelIndices: [0],
|
|
316
|
+
path: 'basis/webgl/texture_test/assets/kodim18_uastc.basis',
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
expected: {
|
|
320
|
+
depth: 1,
|
|
321
|
+
faces: 1,
|
|
322
|
+
format: 'etc1s',
|
|
323
|
+
height: 512,
|
|
324
|
+
layers: 1,
|
|
325
|
+
levels: [{ byteLength: 39_560, byteOffset: 12_936, height: 512, width: 768 }],
|
|
326
|
+
mipLevels: 1,
|
|
327
|
+
supercompression: 'None',
|
|
328
|
+
width: 768,
|
|
329
|
+
},
|
|
330
|
+
levelIndices: [0],
|
|
331
|
+
path: 'basis/webgl/texture_test/assets/kodim20.basis',
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
expected: {
|
|
335
|
+
depth: 1,
|
|
336
|
+
faces: 1,
|
|
337
|
+
format: 'etc1s',
|
|
338
|
+
height: 1_024,
|
|
339
|
+
layers: 1,
|
|
340
|
+
levels: [{ byteLength: 52_083, byteOffset: 38_700, height: 1_024, width: 1_024 }],
|
|
341
|
+
mipLevels: 1,
|
|
342
|
+
supercompression: 'None',
|
|
343
|
+
width: 1_024,
|
|
344
|
+
},
|
|
345
|
+
levelIndices: [0],
|
|
346
|
+
path: 'basis/webgl/texture_test/assets/kodim20_1024x1024.basis',
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
expected: {
|
|
350
|
+
depth: 1,
|
|
351
|
+
faces: 1,
|
|
352
|
+
format: 'uastc',
|
|
353
|
+
height: 1_024,
|
|
354
|
+
layers: 1,
|
|
355
|
+
levels: [{ byteLength: 1_048_576, byteOffset: 100, height: 1_024, width: 1_024 }],
|
|
356
|
+
mipLevels: 1,
|
|
357
|
+
supercompression: 'None',
|
|
358
|
+
width: 1_024,
|
|
359
|
+
},
|
|
360
|
+
levelIndices: [0],
|
|
361
|
+
path: 'basis/webgl/texture_test/assets/kodim26_uastc_1024.basis',
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
expected: {
|
|
365
|
+
depth: 1,
|
|
366
|
+
faces: 1,
|
|
367
|
+
format: 'etc1s',
|
|
368
|
+
height: 8,
|
|
369
|
+
layers: 1,
|
|
370
|
+
levels: [
|
|
371
|
+
{ byteLength: 1, byteOffset: 223, height: 8, width: 8 },
|
|
372
|
+
{ byteLength: 2, byteOffset: 224, height: 8, width: 8 },
|
|
373
|
+
],
|
|
374
|
+
mipLevels: 1,
|
|
375
|
+
supercompression: 'None',
|
|
376
|
+
width: 8,
|
|
377
|
+
},
|
|
378
|
+
levelIndices: [0, 0],
|
|
379
|
+
path: 'ktx/basis/alpha_simple.basis',
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
expected: {
|
|
383
|
+
depth: 1,
|
|
384
|
+
faces: 1,
|
|
385
|
+
format: 'etc1s',
|
|
386
|
+
height: 1_024,
|
|
387
|
+
layers: 1,
|
|
388
|
+
levels: [{ byteLength: 64_199, byteOffset: 7_361, height: 1_024, width: 1_024 }],
|
|
389
|
+
mipLevels: 1,
|
|
390
|
+
supercompression: 'None',
|
|
391
|
+
width: 1_024,
|
|
392
|
+
},
|
|
393
|
+
levelIndices: [0],
|
|
394
|
+
path: 'ktx/basis/color_grid.basis',
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
expected: {
|
|
398
|
+
depth: 1,
|
|
399
|
+
faces: 1,
|
|
400
|
+
format: 'etc1s',
|
|
401
|
+
height: 768,
|
|
402
|
+
layers: 1,
|
|
403
|
+
levels: [{ byteLength: 45_303, byteOffset: 10_382, height: 768, width: 512 }],
|
|
404
|
+
mipLevels: 1,
|
|
405
|
+
supercompression: 'None',
|
|
406
|
+
width: 512,
|
|
407
|
+
},
|
|
408
|
+
levelIndices: [0],
|
|
409
|
+
path: 'ktx/basis/kodim17.basis',
|
|
410
|
+
},
|
|
411
|
+
];
|
|
412
|
+
|
|
413
|
+
const UNSUPPORTED_BASIS_FIXTURE_EXPECTATIONS: readonly UnsupportedBasisFixtureExpectation[] = [
|
|
414
|
+
{ path: 'basis/webgl/texture_test/assets/base.basis', reason: 'format-unsupported', texFormat: 6 },
|
|
415
|
+
{ path: 'basis/webgl/texture_test/assets/desk.basis', reason: 'format-unsupported', texFormat: 2 },
|
|
416
|
+
{ path: 'basis/webgl/texture_test/assets/desk_6x6.basis', reason: 'format-unsupported', texFormat: 3 },
|
|
417
|
+
{ path: 'basis/webgl/texture_test/assets/desk_6x6i.basis', reason: 'format-unsupported', texFormat: 4 },
|
|
418
|
+
{ path: 'basis/webgl/texture_test/assets/kodim23_hdr.basis', reason: 'format-unsupported', texFormat: 2 },
|
|
419
|
+
];
|