ugly-game 0.14.4 → 0.14.5
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/assets/ktx2.js +26 -3
- package/package.json +9 -10
package/dist/assets/ktx2.js
CHANGED
|
@@ -51,6 +51,26 @@ export function requiredFeatureFor(target) {
|
|
|
51
51
|
: 'texture-compression-etc2',
|
|
52
52
|
];
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Every block-compressed target here — ASTC-4x4, BC7, ETC2 — uses a 4x4 block, which is also why
|
|
56
|
+
* `bytesPerRow` below is a `/4` everywhere.
|
|
57
|
+
*/
|
|
58
|
+
const BLOCK = 4;
|
|
59
|
+
/**
|
|
60
|
+
* The copy extent to hand `writeTexture` for one mip level.
|
|
61
|
+
*
|
|
62
|
+
* WebGPU requires a compressed copy to be a whole number of BLOCKS, and the tail of any mip chain is
|
|
63
|
+
* not: a 128² texture ends 4, 2, 1. Passing the logical 2 and 1 makes Chrome REJECT the write with
|
|
64
|
+
* "copySize.width (2) is not a multiple of compressed texture format block width (4)" — a console
|
|
65
|
+
* warning, not an exception, so the two smallest levels of every texture silently never uploaded and
|
|
66
|
+
* anything far enough away to sample them read undefined memory. Measured 1072 of these warnings on
|
|
67
|
+
* a single all-mine-sky world load, across every species albedo and all 120 atlas layers.
|
|
68
|
+
*
|
|
69
|
+
* Rounding UP is correct rather than a fudge: a mip's PHYSICAL subresource is already padded to a
|
|
70
|
+
* full block, and the transcoder hands back exactly that padded block, so 4x4 is the real size of
|
|
71
|
+
* the data and of the destination.
|
|
72
|
+
*/
|
|
73
|
+
const copyExtent = (n, compressed) => compressed ? Math.ceil(n / BLOCK) * BLOCK : n;
|
|
54
74
|
/** Transcode a cooked ETC1S KTX2 to a GPU-compressed texture (full mip chain) on `device`.
|
|
55
75
|
* `basisMod` is an initialized Basis module (from loadBasisModule() or the harness's global). */
|
|
56
76
|
export function transcodeKtx2(device, basisMod, ktx2Bytes) {
|
|
@@ -96,7 +116,10 @@ export function transcodeKtx2(device, basisMod, ktx2Bytes) {
|
|
|
96
116
|
// writeTexture wants a plain ArrayBuffer view (COI/SAB-safe): copy off the transcoder heap.
|
|
97
117
|
const src = new Uint8Array(m.bytes.byteLength);
|
|
98
118
|
src.set(m.bytes);
|
|
99
|
-
device.queue.writeTexture({ texture, mipLevel: mip }, src, { offset: 0, bytesPerRow, rowsPerImage }, {
|
|
119
|
+
device.queue.writeTexture({ texture, mipLevel: mip }, src, { offset: 0, bytesPerRow, rowsPerImage }, {
|
|
120
|
+
width: copyExtent(m.w, target.compressed),
|
|
121
|
+
height: copyExtent(m.h, target.compressed),
|
|
122
|
+
});
|
|
100
123
|
}
|
|
101
124
|
return {
|
|
102
125
|
texture,
|
|
@@ -156,8 +179,8 @@ export function transcodeKtx2Array(device, basisMod, ktx2Bytes) {
|
|
|
156
179
|
const src = new Uint8Array(dst.byteLength);
|
|
157
180
|
src.set(dst);
|
|
158
181
|
device.queue.writeTexture({ texture, mipLevel: mip, origin: { x: 0, y: 0, z: layer } }, src, { offset: 0, bytesPerRow, rowsPerImage }, {
|
|
159
|
-
width: info.origWidth,
|
|
160
|
-
height: info.origHeight,
|
|
182
|
+
width: copyExtent(info.origWidth, target.compressed),
|
|
183
|
+
height: copyExtent(info.origHeight, target.compressed),
|
|
161
184
|
depthOrArrayLayers: 1,
|
|
162
185
|
});
|
|
163
186
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugly-game",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -15,14 +15,6 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"preinstall": "npx only-allow pnpm",
|
|
20
|
-
"build": "tsc -p tsconfig.json && mkdir -p dist/assets/basis && cp src/assets/basis/basis_transcoder.js src/assets/basis/basis_transcoder.bin dist/assets/basis/",
|
|
21
|
-
"lint": "ugly-app lint",
|
|
22
|
-
"lint:fix": "ugly-app lint --fix",
|
|
23
|
-
"pretty": "prettier --write .",
|
|
24
|
-
"prepublishOnly": "pnpm run pretty && ugly-app lint && tsc -p tsconfig.json && mkdir -p dist/assets/basis && cp src/assets/basis/basis_transcoder.js src/assets/basis/basis_transcoder.bin dist/assets/basis/"
|
|
25
|
-
},
|
|
26
18
|
"dependencies": {
|
|
27
19
|
"meshoptimizer": "^1.2.0"
|
|
28
20
|
},
|
|
@@ -35,5 +27,12 @@
|
|
|
35
27
|
"@webgpu/types": "^0.1.40",
|
|
36
28
|
"prettier": "^3.9.5",
|
|
37
29
|
"ugly-app": "^0.1.841"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"preinstall": "npx only-allow pnpm",
|
|
33
|
+
"build": "tsc -p tsconfig.json && mkdir -p dist/assets/basis && cp src/assets/basis/basis_transcoder.js src/assets/basis/basis_transcoder.bin dist/assets/basis/",
|
|
34
|
+
"lint": "ugly-app lint",
|
|
35
|
+
"lint:fix": "ugly-app lint --fix",
|
|
36
|
+
"pretty": "prettier --write ."
|
|
38
37
|
}
|
|
39
|
-
}
|
|
38
|
+
}
|