jassub 2.0.20 → 2.2.0
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/README.md +31 -11
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/wasm/jassub-worker-modern.wasm +0 -0
- package/dist/wasm/jassub-worker.js +1 -1
- package/dist/wasm/jassub-worker.js.map +1 -1
- package/dist/wasm/jassub-worker.wasm +0 -0
- package/dist/wasm/types.d.ts +1 -5
- package/dist/worker/webgl-renderer.d.ts +45 -0
- package/dist/worker/webgl-renderer.js +328 -0
- package/dist/worker/webgl-renderer.js.map +1 -0
- package/dist/worker/webgpu-renderer.d.ts +4 -5
- package/dist/worker/webgpu-renderer.js +87 -99
- package/dist/worker/webgpu-renderer.js.map +1 -1
- package/dist/worker/worker.d.ts +3 -3
- package/dist/worker/worker.js +16 -8
- package/dist/worker/worker.js.map +1 -1
- package/package.json +3 -2
- package/src/debug.ts +1 -1
- package/src/wasm/types.d.ts +1 -5
- package/src/worker/webgl-renderer.ts +412 -0
- package/src/worker/webgpu-renderer.ts +89 -103
- package/src/worker/worker.ts +19 -8
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// @ts-expect-error new experimental API
|
|
2
|
+
const SUPPORTS_GROWTH = !!WebAssembly.Memory.prototype.toResizableBuffer;
|
|
3
|
+
const IDENTITY_MATRIX = new Float32Array([
|
|
4
|
+
1, 0, 0,
|
|
5
|
+
0, 1, 0,
|
|
6
|
+
0, 0, 1
|
|
7
|
+
]);
|
|
8
|
+
// Color matrix conversion map - mat3x3 for WebGL2
|
|
9
|
+
// Each matrix converts FROM the key color space TO the nested key color space
|
|
10
|
+
export const colorMatrixConversionMap = {
|
|
11
|
+
BT601: {
|
|
12
|
+
BT709: new Float32Array([
|
|
13
|
+
1.0863, 0.0965, -0.01411,
|
|
14
|
+
-0.0723, 0.8451, -0.0277,
|
|
15
|
+
-0.0141, 0.0584, 1.0418
|
|
16
|
+
]),
|
|
17
|
+
BT601: IDENTITY_MATRIX
|
|
18
|
+
},
|
|
19
|
+
BT709: {
|
|
20
|
+
BT601: new Float32Array([
|
|
21
|
+
0.9137, 0.0784, 0.0079,
|
|
22
|
+
-0.1049, 1.1722, -0.0671,
|
|
23
|
+
0.0096, 0.0322, 0.9582
|
|
24
|
+
]),
|
|
25
|
+
BT709: IDENTITY_MATRIX
|
|
26
|
+
},
|
|
27
|
+
FCC: {
|
|
28
|
+
BT709: new Float32Array([
|
|
29
|
+
1.0873, -0.0736, -0.0137,
|
|
30
|
+
0.0974, 0.8494, 0.0531,
|
|
31
|
+
-0.0127, -0.0251, 1.0378
|
|
32
|
+
]),
|
|
33
|
+
BT601: new Float32Array([
|
|
34
|
+
1.001, -0.0008, -0.0002,
|
|
35
|
+
0.0009, 1.005, -0.006,
|
|
36
|
+
0.0013, 0.0027, 0.996
|
|
37
|
+
])
|
|
38
|
+
},
|
|
39
|
+
SMPTE240M: {
|
|
40
|
+
BT709: new Float32Array([
|
|
41
|
+
0.9993, 0.0006, 0.0001,
|
|
42
|
+
-0.0004, 0.9812, 0.0192,
|
|
43
|
+
-0.0034, -0.0114, 1.0148
|
|
44
|
+
]),
|
|
45
|
+
BT601: new Float32Array([
|
|
46
|
+
0.913, 0.0774, 0.0096,
|
|
47
|
+
-0.1051, 1.1508, -0.0456,
|
|
48
|
+
0.0063, 0.0207, 0.973
|
|
49
|
+
])
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
// GLSL ES 3.0 Vertex Shader
|
|
53
|
+
const VERTEX_SHADER = /* glsl */ `#version 300 es
|
|
54
|
+
precision highp float;
|
|
55
|
+
|
|
56
|
+
const vec2 QUAD_POSITIONS[6] = vec2[6](
|
|
57
|
+
vec2(0.0, 0.0),
|
|
58
|
+
vec2(1.0, 0.0),
|
|
59
|
+
vec2(0.0, 1.0),
|
|
60
|
+
vec2(1.0, 0.0),
|
|
61
|
+
vec2(1.0, 1.0),
|
|
62
|
+
vec2(0.0, 1.0)
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
uniform vec2 u_resolution;
|
|
66
|
+
uniform vec4 u_destRect; // x, y, w, h
|
|
67
|
+
uniform vec4 u_color; // r, g, b, a
|
|
68
|
+
uniform float u_texLayer;
|
|
69
|
+
|
|
70
|
+
flat out vec2 v_destXY;
|
|
71
|
+
flat out vec4 v_color;
|
|
72
|
+
flat out vec2 v_texSize;
|
|
73
|
+
flat out float v_texLayer;
|
|
74
|
+
|
|
75
|
+
void main() {
|
|
76
|
+
vec2 quadPos = QUAD_POSITIONS[gl_VertexID];
|
|
77
|
+
vec2 pixelPos = u_destRect.xy + quadPos * u_destRect.zw;
|
|
78
|
+
vec2 clipPos = (pixelPos / u_resolution) * 2.0 - 1.0;
|
|
79
|
+
clipPos.y = -clipPos.y;
|
|
80
|
+
|
|
81
|
+
gl_Position = vec4(clipPos, 0.0, 1.0);
|
|
82
|
+
v_destXY = u_destRect.xy;
|
|
83
|
+
v_color = u_color;
|
|
84
|
+
v_texSize = u_destRect.zw;
|
|
85
|
+
v_texLayer = u_texLayer;
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
// GLSL ES 3.0 Fragment Shader - use texelFetch for pixel-perfect sampling
|
|
89
|
+
const FRAGMENT_SHADER = /* glsl */ `#version 300 es
|
|
90
|
+
precision highp float;
|
|
91
|
+
precision highp sampler2DArray;
|
|
92
|
+
|
|
93
|
+
uniform sampler2DArray u_texArray;
|
|
94
|
+
uniform mat3 u_colorMatrix;
|
|
95
|
+
uniform vec2 u_resolution;
|
|
96
|
+
|
|
97
|
+
flat in vec2 v_destXY;
|
|
98
|
+
flat in vec4 v_color;
|
|
99
|
+
flat in vec2 v_texSize;
|
|
100
|
+
flat in float v_texLayer;
|
|
101
|
+
|
|
102
|
+
out vec4 fragColor;
|
|
103
|
+
|
|
104
|
+
void main() {
|
|
105
|
+
// Flip Y: WebGL's gl_FragCoord.y is 0 at bottom, but destXY.y is from top
|
|
106
|
+
vec2 fragPos = vec2(gl_FragCoord.x, u_resolution.y - gl_FragCoord.y);
|
|
107
|
+
|
|
108
|
+
// Calculate local position within the quad (screen coords)
|
|
109
|
+
vec2 localPos = fragPos - v_destXY;
|
|
110
|
+
|
|
111
|
+
// Convert to integer texel coordinates for texelFetch
|
|
112
|
+
ivec2 texCoord = ivec2(floor(localPos));
|
|
113
|
+
|
|
114
|
+
// Bounds check (prevents out-of-bounds access)
|
|
115
|
+
ivec2 texSizeI = ivec2(v_texSize);
|
|
116
|
+
if (texCoord.x < 0 || texCoord.y < 0 || texCoord.x >= texSizeI.x || texCoord.y >= texSizeI.y) {
|
|
117
|
+
fragColor = vec4(0.0);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// texelFetch: integer coords, no interpolation, no precision issues
|
|
122
|
+
float mask = texelFetch(u_texArray, ivec3(texCoord, int(v_texLayer)), 0).r;
|
|
123
|
+
|
|
124
|
+
// Apply color matrix conversion (identity if no conversion needed)
|
|
125
|
+
vec3 correctedColor = u_colorMatrix * v_color.rgb;
|
|
126
|
+
|
|
127
|
+
// libass color alpha: 0 = opaque, 255 = transparent (inverted)
|
|
128
|
+
float colorAlpha = 1.0 - v_color.a;
|
|
129
|
+
|
|
130
|
+
// Final alpha = colorAlpha * mask
|
|
131
|
+
float a = colorAlpha * mask;
|
|
132
|
+
|
|
133
|
+
// Premultiplied alpha output
|
|
134
|
+
fragColor = vec4(correctedColor * a, a);
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
// Texture array configuration
|
|
138
|
+
const TEX_ARRAY_SIZE = 64; // Fixed layer count
|
|
139
|
+
const TEX_INITIAL_SIZE = 256; // Initial width/height
|
|
140
|
+
export class WebGL2Renderer {
|
|
141
|
+
gl = null;
|
|
142
|
+
program = null;
|
|
143
|
+
vao = null;
|
|
144
|
+
// Uniform locations
|
|
145
|
+
u_resolution = null;
|
|
146
|
+
u_destRect = null;
|
|
147
|
+
u_color = null;
|
|
148
|
+
u_texArray = null;
|
|
149
|
+
u_colorMatrix = null;
|
|
150
|
+
u_texLayer = null;
|
|
151
|
+
// Single texture array instead of individual textures
|
|
152
|
+
texArray = null;
|
|
153
|
+
texArrayWidth = 0;
|
|
154
|
+
texArrayHeight = 0;
|
|
155
|
+
colorMatrix = IDENTITY_MATRIX;
|
|
156
|
+
setCanvas(canvas, width, height) {
|
|
157
|
+
// WebGL2 doesn't allow 0-sized canvases
|
|
158
|
+
if (width <= 0 || height <= 0)
|
|
159
|
+
return;
|
|
160
|
+
canvas.width = width;
|
|
161
|
+
canvas.height = height;
|
|
162
|
+
if (!this.gl) {
|
|
163
|
+
// Get canvas context
|
|
164
|
+
// Note: preserveDrawingBuffer is false (default) - the browser handles
|
|
165
|
+
// buffer swaps for OffscreenCanvas, avoiding flicker
|
|
166
|
+
this.gl = canvas.getContext('webgl2', {
|
|
167
|
+
alpha: true,
|
|
168
|
+
premultipliedAlpha: true,
|
|
169
|
+
antialias: false,
|
|
170
|
+
depth: false,
|
|
171
|
+
stencil: false,
|
|
172
|
+
desynchronized: true
|
|
173
|
+
});
|
|
174
|
+
if (!this.gl) {
|
|
175
|
+
throw new Error('Could not get WebGL2 context');
|
|
176
|
+
}
|
|
177
|
+
// Create shaders
|
|
178
|
+
const vertexShader = this.createShader(this.gl.VERTEX_SHADER, VERTEX_SHADER);
|
|
179
|
+
const fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, FRAGMENT_SHADER);
|
|
180
|
+
if (!vertexShader || !fragmentShader) {
|
|
181
|
+
throw new Error('Failed to create shaders');
|
|
182
|
+
}
|
|
183
|
+
// Create program
|
|
184
|
+
this.program = this.gl.createProgram();
|
|
185
|
+
this.gl.attachShader(this.program, vertexShader);
|
|
186
|
+
this.gl.attachShader(this.program, fragmentShader);
|
|
187
|
+
this.gl.linkProgram(this.program);
|
|
188
|
+
if (!this.gl.getProgramParameter(this.program, this.gl.LINK_STATUS)) {
|
|
189
|
+
const info = this.gl.getProgramInfoLog(this.program);
|
|
190
|
+
throw new Error('Failed to link program: ' + info);
|
|
191
|
+
}
|
|
192
|
+
this.gl.deleteShader(vertexShader);
|
|
193
|
+
this.gl.deleteShader(fragmentShader);
|
|
194
|
+
// Get uniform locations
|
|
195
|
+
this.u_resolution = this.gl.getUniformLocation(this.program, 'u_resolution');
|
|
196
|
+
this.u_destRect = this.gl.getUniformLocation(this.program, 'u_destRect');
|
|
197
|
+
this.u_color = this.gl.getUniformLocation(this.program, 'u_color');
|
|
198
|
+
this.u_texArray = this.gl.getUniformLocation(this.program, 'u_texArray');
|
|
199
|
+
this.u_colorMatrix = this.gl.getUniformLocation(this.program, 'u_colorMatrix');
|
|
200
|
+
this.u_texLayer = this.gl.getUniformLocation(this.program, 'u_texLayer');
|
|
201
|
+
// Create a VAO (required for WebGL2)
|
|
202
|
+
this.vao = this.gl.createVertexArray();
|
|
203
|
+
this.gl.bindVertexArray(this.vao);
|
|
204
|
+
// Set up blending for premultiplied alpha
|
|
205
|
+
this.gl.enable(this.gl.BLEND);
|
|
206
|
+
this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
|
|
207
|
+
// Use the program
|
|
208
|
+
this.gl.useProgram(this.program);
|
|
209
|
+
// Set texture unit
|
|
210
|
+
this.gl.uniform1i(this.u_texArray, 0);
|
|
211
|
+
// Set initial color matrix
|
|
212
|
+
this.gl.uniformMatrix3fv(this.u_colorMatrix, false, this.colorMatrix);
|
|
213
|
+
// Set one-time GL state
|
|
214
|
+
this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1);
|
|
215
|
+
this.gl.clearColor(0, 0, 0, 0);
|
|
216
|
+
this.gl.activeTexture(this.gl.TEXTURE0);
|
|
217
|
+
// Create initial texture array
|
|
218
|
+
this.createTexArray(TEX_INITIAL_SIZE, TEX_INITIAL_SIZE);
|
|
219
|
+
}
|
|
220
|
+
// Update viewport and resolution uniform
|
|
221
|
+
this.gl.viewport(0, 0, width, height);
|
|
222
|
+
this.gl.uniform2f(this.u_resolution, width, height);
|
|
223
|
+
}
|
|
224
|
+
createShader(type, source) {
|
|
225
|
+
const shader = this.gl.createShader(type);
|
|
226
|
+
this.gl.shaderSource(shader, source);
|
|
227
|
+
this.gl.compileShader(shader);
|
|
228
|
+
if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
|
|
229
|
+
const info = this.gl.getShaderInfoLog(shader);
|
|
230
|
+
console.log(info);
|
|
231
|
+
this.gl.deleteShader(shader);
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
return shader;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Set the color matrix for color space conversion.
|
|
238
|
+
* Pass null or undefined to use identity (no conversion).
|
|
239
|
+
*/
|
|
240
|
+
setColorMatrix(subtitleColorSpace, videoColorSpace) {
|
|
241
|
+
this.colorMatrix = (subtitleColorSpace && videoColorSpace && colorMatrixConversionMap[subtitleColorSpace]?.[videoColorSpace]) ?? IDENTITY_MATRIX;
|
|
242
|
+
if (this.gl && this.u_colorMatrix && this.program) {
|
|
243
|
+
this.gl.useProgram(this.program);
|
|
244
|
+
this.gl.uniformMatrix3fv(this.u_colorMatrix, false, this.colorMatrix);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
createTexArray(width, height) {
|
|
248
|
+
if (this.texArray) {
|
|
249
|
+
this.gl.deleteTexture(this.texArray);
|
|
250
|
+
}
|
|
251
|
+
this.texArray = this.gl.createTexture();
|
|
252
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, this.texArray);
|
|
253
|
+
// Allocate storage for texture array
|
|
254
|
+
this.gl.texImage3D(this.gl.TEXTURE_2D_ARRAY, 0, this.gl.R8, width, height, TEX_ARRAY_SIZE, 0, this.gl.RED, this.gl.UNSIGNED_BYTE, null);
|
|
255
|
+
// Set texture parameters (no filtering needed for texelFetch, but set anyway)
|
|
256
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST);
|
|
257
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST);
|
|
258
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
|
259
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
|
260
|
+
this.texArrayWidth = width;
|
|
261
|
+
this.texArrayHeight = height;
|
|
262
|
+
}
|
|
263
|
+
render(images, heap) {
|
|
264
|
+
if (!this.gl || !this.program || !this.vao || !this.texArray)
|
|
265
|
+
return;
|
|
266
|
+
// Hack: work around shared memory issues, webGL doesnt support shared memory, so there are race conditions when growing memory
|
|
267
|
+
if ((self.HEAPU8RAW.buffer !== self.WASMMEMORY.buffer) || SUPPORTS_GROWTH) {
|
|
268
|
+
heap = self.HEAPU8RAW = new Uint8Array(self.WASMMEMORY.buffer);
|
|
269
|
+
}
|
|
270
|
+
// Clear canvas
|
|
271
|
+
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
272
|
+
// Find max dimensions needed
|
|
273
|
+
let maxW = this.texArrayWidth;
|
|
274
|
+
let maxH = this.texArrayHeight;
|
|
275
|
+
for (const img of images) {
|
|
276
|
+
if (img.w > maxW)
|
|
277
|
+
maxW = img.w;
|
|
278
|
+
if (img.h > maxH)
|
|
279
|
+
maxH = img.h;
|
|
280
|
+
}
|
|
281
|
+
// Resize texture array if needed
|
|
282
|
+
if (maxW > this.texArrayWidth || maxH > this.texArrayHeight) {
|
|
283
|
+
this.createTexArray(maxW, maxH);
|
|
284
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, this.texArray);
|
|
285
|
+
}
|
|
286
|
+
// Render each image
|
|
287
|
+
for (let i = 0, texLayer = 0; i < images.length; i++) {
|
|
288
|
+
const img = images[i];
|
|
289
|
+
// Skip images with invalid dimensions
|
|
290
|
+
if (img.w <= 0 || img.h <= 0)
|
|
291
|
+
continue;
|
|
292
|
+
// Use modulo to cycle through layers if we have more images than layers
|
|
293
|
+
const layer = texLayer % TEX_ARRAY_SIZE;
|
|
294
|
+
texLayer++;
|
|
295
|
+
// Upload bitmap data to texture array layer
|
|
296
|
+
this.gl.pixelStorei(this.gl.UNPACK_ROW_LENGTH, img.stride);
|
|
297
|
+
this.gl.texSubImage3D(this.gl.TEXTURE_2D_ARRAY, 0, 0, 0, layer, // x, y, z offset
|
|
298
|
+
img.w, img.h, 1, // depth (1 layer)
|
|
299
|
+
this.gl.RED, this.gl.UNSIGNED_BYTE, heap, img.bitmap);
|
|
300
|
+
this.gl.pixelStorei(this.gl.UNPACK_ROW_LENGTH, 0);
|
|
301
|
+
// Set uniforms
|
|
302
|
+
this.gl.uniform4f(this.u_destRect, img.dst_x, img.dst_y, img.w, img.h);
|
|
303
|
+
this.gl.uniform1f(this.u_texLayer, layer);
|
|
304
|
+
// color (RGBA from 0xRRGGBBAA)
|
|
305
|
+
this.gl.uniform4f(this.u_color, ((img.color >>> 24) & 0xFF) / 255, ((img.color >>> 16) & 0xFF) / 255, ((img.color >>> 8) & 0xFF) / 255, (img.color & 0xFF) / 255);
|
|
306
|
+
// 6 vertices for quad
|
|
307
|
+
this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
destroy() {
|
|
311
|
+
if (this.gl) {
|
|
312
|
+
if (this.texArray) {
|
|
313
|
+
this.gl.deleteTexture(this.texArray);
|
|
314
|
+
this.texArray = null;
|
|
315
|
+
}
|
|
316
|
+
if (this.vao) {
|
|
317
|
+
this.gl.deleteVertexArray(this.vao);
|
|
318
|
+
this.vao = null;
|
|
319
|
+
}
|
|
320
|
+
if (this.program) {
|
|
321
|
+
this.gl.deleteProgram(this.program);
|
|
322
|
+
this.program = null;
|
|
323
|
+
}
|
|
324
|
+
this.gl = null;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=webgl-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-renderer.js","sourceRoot":"","sources":["../../src/worker/webgl-renderer.ts"],"names":[],"mappings":"AAQA,wCAAwC;AACxC,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAA;AAExE,MAAM,eAAe,GAAG,IAAI,YAAY,CAAC;IACvC,CAAC,EAAE,CAAC,EAAE,CAAC;IACP,CAAC,EAAE,CAAC,EAAE,CAAC;IACP,CAAC,EAAE,CAAC,EAAE,CAAC;CACR,CAAC,CAAA;AAEF,kDAAkD;AAClD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,KAAK,EAAE;QACL,KAAK,EAAE,IAAI,YAAY,CAAC;YACtB,MAAM,EAAE,MAAM,EAAE,CAAC,OAAO;YACxB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM;YACxB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM;SACxB,CAAC;QACF,KAAK,EAAE,eAAe;KACvB;IACD,KAAK,EAAE;QACL,KAAK,EAAE,IAAI,YAAY,CAAC;YACtB,MAAM,EAAE,MAAM,EAAE,MAAM;YACtB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM;YACxB,MAAM,EAAE,MAAM,EAAE,MAAM;SACvB,CAAC;QACF,KAAK,EAAE,eAAe;KACvB;IACD,GAAG,EAAE;QACH,KAAK,EAAE,IAAI,YAAY,CAAC;YACtB,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM;YACxB,MAAM,EAAE,MAAM,EAAE,MAAM;YACtB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM;SACzB,CAAC;QACF,KAAK,EAAE,IAAI,YAAY,CAAC;YACtB,KAAK,EAAE,CAAC,MAAM,EAAE,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 export declare class WebGPURenderer {
|
|
|
35
35
|
textures: TextureInfo[];
|
|
36
36
|
pendingDestroyTextures: GPUTexture[];
|
|
37
37
|
format: GPUTextureFormat;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
setCanvas(canvas: OffscreenCanvas, width: number, height: number): Promise<void>;
|
|
38
|
+
constructor(device: GPUDevice);
|
|
39
|
+
setCanvas(canvas: OffscreenCanvas, width: number, height: number): void;
|
|
41
40
|
/**
|
|
42
41
|
* Set the color matrix for color space conversion.
|
|
43
42
|
* Pass null or undefined to use identity (no conversion).
|
|
44
43
|
* Matrix should be a pre-padded Float32Array with 12 values (3 columns × 4 floats each).
|
|
45
44
|
*/
|
|
46
|
-
setColorMatrix(
|
|
47
|
-
|
|
45
|
+
setColorMatrix(subtitleColorSpace?: 'BT601' | 'BT709' | 'SMPTE240M' | 'FCC', videoColorSpace?: 'BT601' | 'BT709'): void;
|
|
46
|
+
createTextureInfo(width: number, height: number): TextureInfo;
|
|
48
47
|
render(images: ASSImage[], heap: Uint8Array): void;
|
|
49
48
|
destroy(): void;
|
|
50
49
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// WARN:
|
|
2
|
+
// This has been deprecated as WebGL is simply faster
|
|
3
|
+
// Know how to optimise this to beat WebGL? submit a PR!
|
|
1
4
|
const IDENTITY_MATRIX = new Float32Array([
|
|
2
5
|
1, 0, 0, 0,
|
|
3
6
|
0, 1, 0, 0,
|
|
@@ -157,106 +160,91 @@ export class WebGPURenderer {
|
|
|
157
160
|
pendingDestroyTextures = [];
|
|
158
161
|
// eslint-disable-next-line no-undef
|
|
159
162
|
format = 'bgra8unorm';
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.colorMatrixBuffer = this.device.createBuffer({
|
|
190
|
-
size: 48, // 3 x vec4f (each column is vec3f padded to 16 bytes)
|
|
191
|
-
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
192
|
-
});
|
|
193
|
-
// Initialize with identity matrix
|
|
194
|
-
this.device.queue.writeBuffer(this.colorMatrixBuffer, 0, IDENTITY_MATRIX);
|
|
195
|
-
// Create bind group layout (no sampler needed - using textureLoad for pixel-perfect sampling)
|
|
196
|
-
this.bindGroupLayout = this.device.createBindGroupLayout({
|
|
197
|
-
entries: [
|
|
198
|
-
{
|
|
199
|
-
binding: 0,
|
|
200
|
-
visibility: GPUShaderStage.VERTEX,
|
|
201
|
-
buffer: { type: 'uniform' }
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
binding: 1,
|
|
205
|
-
visibility: GPUShaderStage.VERTEX,
|
|
206
|
-
buffer: { type: 'read-only-storage' }
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
binding: 3,
|
|
210
|
-
visibility: GPUShaderStage.FRAGMENT,
|
|
211
|
-
texture: { sampleType: 'unfilterable-float' } // textureLoad requires unfilterable
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
binding: 4,
|
|
215
|
-
visibility: GPUShaderStage.FRAGMENT,
|
|
216
|
-
buffer: { type: 'uniform' }
|
|
217
|
-
}
|
|
218
|
-
]
|
|
219
|
-
});
|
|
220
|
-
// Create pipeline layout
|
|
221
|
-
const pipelineLayout = this.device.createPipelineLayout({
|
|
222
|
-
bindGroupLayouts: [this.bindGroupLayout]
|
|
223
|
-
});
|
|
224
|
-
// Create render pipeline
|
|
225
|
-
this.pipeline = this.device.createRenderPipeline({
|
|
226
|
-
layout: pipelineLayout,
|
|
227
|
-
vertex: {
|
|
228
|
-
module: vertexModule,
|
|
229
|
-
entryPoint: 'vertexMain'
|
|
163
|
+
constructor(device) {
|
|
164
|
+
this.device = device;
|
|
165
|
+
this.format = navigator.gpu.getPreferredCanvasFormat();
|
|
166
|
+
// Create shader modules
|
|
167
|
+
const vertexModule = this.device.createShaderModule({
|
|
168
|
+
code: VERTEX_SHADER
|
|
169
|
+
});
|
|
170
|
+
const fragmentModule = this.device.createShaderModule({
|
|
171
|
+
code: FRAGMENT_SHADER
|
|
172
|
+
});
|
|
173
|
+
// Create uniform buffer
|
|
174
|
+
this.uniformBuffer = this.device.createBuffer({
|
|
175
|
+
size: 16, // vec2f resolution + padding
|
|
176
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
177
|
+
});
|
|
178
|
+
// Create color matrix buffer (mat3x3f requires 48 bytes: 3 vec3f padded to vec4f each)
|
|
179
|
+
this.colorMatrixBuffer = this.device.createBuffer({
|
|
180
|
+
size: 48, // 3 x vec4f (each column is vec3f padded to 16 bytes)
|
|
181
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
182
|
+
});
|
|
183
|
+
// Initialize with identity matrix
|
|
184
|
+
this.device.queue.writeBuffer(this.colorMatrixBuffer, 0, IDENTITY_MATRIX);
|
|
185
|
+
// Create bind group layout (no sampler needed - using textureLoad for pixel-perfect sampling)
|
|
186
|
+
this.bindGroupLayout = this.device.createBindGroupLayout({
|
|
187
|
+
entries: [
|
|
188
|
+
{
|
|
189
|
+
binding: 0,
|
|
190
|
+
visibility: GPUShaderStage.VERTEX,
|
|
191
|
+
buffer: { type: 'uniform' }
|
|
230
192
|
},
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
{
|
|
236
|
-
format: this.format,
|
|
237
|
-
blend: {
|
|
238
|
-
color: {
|
|
239
|
-
srcFactor: 'one',
|
|
240
|
-
dstFactor: 'one-minus-src-alpha',
|
|
241
|
-
operation: 'add'
|
|
242
|
-
},
|
|
243
|
-
alpha: {
|
|
244
|
-
srcFactor: 'one',
|
|
245
|
-
dstFactor: 'one-minus-src-alpha',
|
|
246
|
-
operation: 'add'
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
]
|
|
193
|
+
{
|
|
194
|
+
binding: 1,
|
|
195
|
+
visibility: GPUShaderStage.VERTEX,
|
|
196
|
+
buffer: { type: 'read-only-storage' }
|
|
251
197
|
},
|
|
252
|
-
|
|
253
|
-
|
|
198
|
+
{
|
|
199
|
+
binding: 3,
|
|
200
|
+
visibility: GPUShaderStage.FRAGMENT,
|
|
201
|
+
texture: { sampleType: 'unfilterable-float' } // textureLoad requires unfilterable
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
binding: 4,
|
|
205
|
+
visibility: GPUShaderStage.FRAGMENT,
|
|
206
|
+
buffer: { type: 'uniform' }
|
|
254
207
|
}
|
|
255
|
-
|
|
256
|
-
})
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
// Create pipeline layout
|
|
211
|
+
const pipelineLayout = this.device.createPipelineLayout({
|
|
212
|
+
bindGroupLayouts: [this.bindGroupLayout]
|
|
213
|
+
});
|
|
214
|
+
// Create render pipeline
|
|
215
|
+
this.pipeline = this.device.createRenderPipeline({
|
|
216
|
+
layout: pipelineLayout,
|
|
217
|
+
vertex: {
|
|
218
|
+
module: vertexModule,
|
|
219
|
+
entryPoint: 'vertexMain'
|
|
220
|
+
},
|
|
221
|
+
fragment: {
|
|
222
|
+
module: fragmentModule,
|
|
223
|
+
entryPoint: 'fragmentMain',
|
|
224
|
+
targets: [
|
|
225
|
+
{
|
|
226
|
+
format: this.format,
|
|
227
|
+
blend: {
|
|
228
|
+
color: {
|
|
229
|
+
srcFactor: 'one',
|
|
230
|
+
dstFactor: 'one-minus-src-alpha',
|
|
231
|
+
operation: 'add'
|
|
232
|
+
},
|
|
233
|
+
alpha: {
|
|
234
|
+
srcFactor: 'one',
|
|
235
|
+
dstFactor: 'one-minus-src-alpha',
|
|
236
|
+
operation: 'add'
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
primitive: {
|
|
243
|
+
topology: 'triangle-list'
|
|
244
|
+
}
|
|
245
|
+
});
|
|
257
246
|
}
|
|
258
|
-
|
|
259
|
-
await this._ready;
|
|
247
|
+
setCanvas(canvas, width, height) {
|
|
260
248
|
if (!this.device)
|
|
261
249
|
return;
|
|
262
250
|
// WebGPU doesn't allow 0-sized textures/swapchains
|
|
@@ -284,11 +272,11 @@ export class WebGPURenderer {
|
|
|
284
272
|
* Pass null or undefined to use identity (no conversion).
|
|
285
273
|
* Matrix should be a pre-padded Float32Array with 12 values (3 columns × 4 floats each).
|
|
286
274
|
*/
|
|
287
|
-
|
|
288
|
-
await this._ready;
|
|
275
|
+
setColorMatrix(subtitleColorSpace, videoColorSpace) {
|
|
289
276
|
if (!this.device)
|
|
290
277
|
return;
|
|
291
|
-
|
|
278
|
+
const colorMatrix = (subtitleColorSpace && videoColorSpace && colorMatrixConversionMap[subtitleColorSpace]?.[videoColorSpace]) ?? IDENTITY_MATRIX;
|
|
279
|
+
this.device.queue.writeBuffer(this.colorMatrixBuffer, 0, colorMatrix);
|
|
292
280
|
}
|
|
293
281
|
createTextureInfo(width, height) {
|
|
294
282
|
const texture = this.device.createTexture({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-renderer.js","sourceRoot":"","sources":["../../src/worker/webgpu-renderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgpu-renderer.js","sourceRoot":"","sources":["../../src/worker/webgpu-renderer.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,qDAAqD;AACrD,wDAAwD;AAIxD,MAAM,eAAe,GAAG,IAAI,YAAY,CAAC;IACvC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAC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ACF"}
|
package/dist/worker/worker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { finalizer } from 'abslink';
|
|
2
|
-
import {
|
|
2
|
+
import { WebGL2Renderer } from './webgl-renderer';
|
|
3
3
|
import type { ASSEvent, ASSStyle } from '../jassub';
|
|
4
4
|
import type { JASSUB } from '../wasm/types.js';
|
|
5
5
|
interface opts {
|
|
@@ -22,7 +22,7 @@ export declare class ASSRenderer {
|
|
|
22
22
|
_subtitleColorSpace?: 'BT601' | 'BT709' | 'SMPTE240M' | 'FCC' | null;
|
|
23
23
|
_videoColorSpace?: 'BT709' | 'BT601';
|
|
24
24
|
_malloc: (size: number) => number;
|
|
25
|
-
_gpurender:
|
|
25
|
+
_gpurender: WebGL2Renderer;
|
|
26
26
|
debug: boolean;
|
|
27
27
|
useLocalFonts: boolean;
|
|
28
28
|
_availableFonts: Record<string, Uint8Array | string>;
|
|
@@ -53,7 +53,7 @@ export declare class ASSRenderer {
|
|
|
53
53
|
_allocFont(uint8: Uint8Array): void;
|
|
54
54
|
_processAvailableFonts(content: string): void;
|
|
55
55
|
_canvas(width: number, height: number, videoWidth: number, videoHeight: number): void;
|
|
56
|
-
[finalizer](): void
|
|
56
|
+
[finalizer](): Promise<void>;
|
|
57
57
|
_draw(time: number, force?: boolean): void;
|
|
58
58
|
_setColorSpace(videoColorSpace: 'RGB' | 'BT709' | 'BT601'): void;
|
|
59
59
|
}
|