jassub 2.3.3 → 2.4.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 +3 -3
- package/dist/worker/renderers/2d-renderer.d.ts +16 -0
- package/dist/worker/renderers/2d-renderer.js +71 -0
- package/dist/worker/renderers/2d-renderer.js.map +1 -0
- package/dist/worker/renderers/webgl1-renderer.d.ts +38 -0
- package/dist/worker/renderers/webgl1-renderer.js +363 -0
- package/dist/worker/renderers/webgl1-renderer.js.map +1 -0
- package/dist/worker/renderers/webgl2-renderer.d.ts +32 -0
- package/dist/worker/renderers/webgl2-renderer.js +361 -0
- package/dist/worker/renderers/webgl2-renderer.js.map +1 -0
- package/dist/worker/renderers/webgpu-renderer.d.ts +50 -0
- package/dist/worker/renderers/webgpu-renderer.js +404 -0
- package/dist/worker/renderers/webgpu-renderer.js.map +1 -0
- package/dist/worker/util.d.ts +23 -0
- package/dist/worker/util.js +57 -0
- package/dist/worker/util.js.map +1 -1
- package/dist/worker/worker.d.ts +4 -2
- package/dist/worker/worker.js +19 -5
- package/dist/worker/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/worker/renderers/2d-renderer.ts +81 -0
- package/src/worker/renderers/webgl1-renderer.ts +445 -0
- package/src/worker/{webgl-renderer.ts → renderers/webgl2-renderer.ts} +2 -65
- package/src/worker/{webgpu-renderer.ts → renderers/webgpu-renderer.ts} +1 -1
- package/src/worker/util.ts +64 -0
- package/src/worker/worker.ts +17 -5
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
// fallback for browsers that don't support WebGL2
|
|
2
|
+
import { colorMatrixConversionMap, IDENTITY_MATRIX, IS_FIREFOX, SHOULD_REFERENCE_MEMORY } from "../util.js";
|
|
3
|
+
// GLSL ES 3.0 Vertex Shader with Instancing
|
|
4
|
+
const VERTEX_SHADER = /* glsl */ `#version 300 es
|
|
5
|
+
precision mediump float;
|
|
6
|
+
|
|
7
|
+
const vec2 QUAD_POSITIONS[6] = vec2[6](
|
|
8
|
+
vec2(0.0, 0.0),
|
|
9
|
+
vec2(1.0, 0.0),
|
|
10
|
+
vec2(0.0, 1.0),
|
|
11
|
+
vec2(1.0, 0.0),
|
|
12
|
+
vec2(1.0, 1.0),
|
|
13
|
+
vec2(0.0, 1.0)
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
uniform vec2 u_resolution;
|
|
17
|
+
|
|
18
|
+
// Instance attributes
|
|
19
|
+
in vec4 a_destRect; // x, y, w, h
|
|
20
|
+
in vec4 a_color; // r, g, b, a
|
|
21
|
+
in float a_texLayer;
|
|
22
|
+
|
|
23
|
+
flat out vec2 v_destXY;
|
|
24
|
+
flat out vec4 v_color;
|
|
25
|
+
flat out vec2 v_texSize;
|
|
26
|
+
flat out float v_texLayer;
|
|
27
|
+
|
|
28
|
+
void main() {
|
|
29
|
+
vec2 quadPos = QUAD_POSITIONS[gl_VertexID];
|
|
30
|
+
vec2 pixelPos = a_destRect.xy + quadPos * a_destRect.zw;
|
|
31
|
+
vec2 clipPos = (pixelPos / u_resolution) * 2.0 - 1.0;
|
|
32
|
+
clipPos.y = -clipPos.y;
|
|
33
|
+
|
|
34
|
+
gl_Position = vec4(clipPos, 0.0, 1.0);
|
|
35
|
+
v_destXY = a_destRect.xy;
|
|
36
|
+
v_color = a_color;
|
|
37
|
+
v_texSize = a_destRect.zw;
|
|
38
|
+
v_texLayer = a_texLayer;
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
// GLSL ES 3.0 Fragment Shader - use texelFetch for pixel-perfect sampling
|
|
42
|
+
const FRAGMENT_SHADER = /* glsl */ `#version 300 es
|
|
43
|
+
precision mediump float;
|
|
44
|
+
precision mediump sampler2DArray;
|
|
45
|
+
|
|
46
|
+
uniform sampler2DArray u_texArray;
|
|
47
|
+
uniform mat3 u_colorMatrix;
|
|
48
|
+
uniform vec2 u_resolution;
|
|
49
|
+
|
|
50
|
+
flat in vec2 v_destXY;
|
|
51
|
+
flat in vec4 v_color;
|
|
52
|
+
flat in vec2 v_texSize;
|
|
53
|
+
flat in float v_texLayer;
|
|
54
|
+
|
|
55
|
+
out vec4 fragColor;
|
|
56
|
+
|
|
57
|
+
void main() {
|
|
58
|
+
// Flip Y: WebGL's gl_FragCoord.y is 0 at bottom, but destXY.y is from top
|
|
59
|
+
vec2 fragPos = vec2(gl_FragCoord.x, u_resolution.y - gl_FragCoord.y);
|
|
60
|
+
|
|
61
|
+
// Calculate local position within the quad (screen coords)
|
|
62
|
+
vec2 localPos = fragPos - v_destXY;
|
|
63
|
+
|
|
64
|
+
// Convert to integer texel coordinates for texelFetch
|
|
65
|
+
ivec2 texCoord = ivec2(floor(localPos));
|
|
66
|
+
|
|
67
|
+
// Bounds check (prevents out-of-bounds access)
|
|
68
|
+
ivec2 texSizeI = ivec2(v_texSize);
|
|
69
|
+
if (texCoord.x < 0 || texCoord.y < 0 || texCoord.x >= texSizeI.x || texCoord.y >= texSizeI.y) {
|
|
70
|
+
discard;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// texelFetch: integer coords, no interpolation, no precision issues
|
|
74
|
+
float mask = texelFetch(u_texArray, ivec3(texCoord, int(v_texLayer)), 0).r;
|
|
75
|
+
|
|
76
|
+
// Apply color matrix conversion (identity if no conversion needed)
|
|
77
|
+
vec3 correctedColor = u_colorMatrix * v_color.rgb;
|
|
78
|
+
|
|
79
|
+
// libass color alpha: 0 = opaque, 255 = transparent (inverted)
|
|
80
|
+
float colorAlpha = 1.0 - v_color.a;
|
|
81
|
+
|
|
82
|
+
// Final alpha = colorAlpha * mask
|
|
83
|
+
float a = colorAlpha * mask;
|
|
84
|
+
|
|
85
|
+
// Premultiplied alpha output
|
|
86
|
+
fragColor = vec4(correctedColor * a, a);
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
// Texture array configuration
|
|
90
|
+
const TEX_ARRAY_SIZE = 64; // Fixed layer count
|
|
91
|
+
const TEX_INITIAL_SIZE = 256; // Initial width/height
|
|
92
|
+
const MAX_INSTANCES = 256; // Maximum instances per draw call
|
|
93
|
+
export class WebGL2Renderer {
|
|
94
|
+
canvas = null;
|
|
95
|
+
gl = null;
|
|
96
|
+
program = null;
|
|
97
|
+
vao = null;
|
|
98
|
+
// Uniform locations
|
|
99
|
+
u_resolution = null;
|
|
100
|
+
u_texArray = null;
|
|
101
|
+
u_colorMatrix = null;
|
|
102
|
+
// Instance attribute buffers
|
|
103
|
+
instanceDestRectBuffer = null;
|
|
104
|
+
instanceColorBuffer = null;
|
|
105
|
+
instanceTexLayerBuffer = null;
|
|
106
|
+
// Instance data arrays
|
|
107
|
+
instanceDestRectData;
|
|
108
|
+
instanceColorData;
|
|
109
|
+
instanceTexLayerData;
|
|
110
|
+
texArray = null;
|
|
111
|
+
texArrayWidth = 0;
|
|
112
|
+
texArrayHeight = 0;
|
|
113
|
+
colorMatrix = IDENTITY_MATRIX;
|
|
114
|
+
constructor() {
|
|
115
|
+
this.instanceDestRectData = new Float32Array(MAX_INSTANCES * 4);
|
|
116
|
+
this.instanceColorData = new Float32Array(MAX_INSTANCES * 4);
|
|
117
|
+
this.instanceTexLayerData = new Float32Array(MAX_INSTANCES);
|
|
118
|
+
}
|
|
119
|
+
_scheduledResize;
|
|
120
|
+
resizeCanvas(width, height) {
|
|
121
|
+
// WebGL2 doesn't allow 0-sized canvases
|
|
122
|
+
if (width <= 0 || height <= 0)
|
|
123
|
+
return;
|
|
124
|
+
this._scheduledResize = { width, height };
|
|
125
|
+
}
|
|
126
|
+
setCanvas(canvas) {
|
|
127
|
+
this.canvas = canvas;
|
|
128
|
+
this.gl = canvas.getContext('webgl2', {
|
|
129
|
+
alpha: true,
|
|
130
|
+
premultipliedAlpha: true,
|
|
131
|
+
antialias: false,
|
|
132
|
+
depth: false,
|
|
133
|
+
preserveDrawingBuffer: false,
|
|
134
|
+
stencil: false,
|
|
135
|
+
desynchronized: true,
|
|
136
|
+
powerPreference: 'high-performance'
|
|
137
|
+
});
|
|
138
|
+
if (!this.gl) {
|
|
139
|
+
throw new Error('Could not get WebGL2 context');
|
|
140
|
+
}
|
|
141
|
+
// Create shaders
|
|
142
|
+
const vertexShader = this.createShader(this.gl.VERTEX_SHADER, VERTEX_SHADER);
|
|
143
|
+
const fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, FRAGMENT_SHADER);
|
|
144
|
+
if (!vertexShader || !fragmentShader) {
|
|
145
|
+
throw new Error('Failed to create shaders');
|
|
146
|
+
}
|
|
147
|
+
// Create program
|
|
148
|
+
this.program = this.gl.createProgram();
|
|
149
|
+
this.gl.attachShader(this.program, vertexShader);
|
|
150
|
+
this.gl.attachShader(this.program, fragmentShader);
|
|
151
|
+
this.gl.linkProgram(this.program);
|
|
152
|
+
if (!this.gl.getProgramParameter(this.program, this.gl.LINK_STATUS)) {
|
|
153
|
+
const info = this.gl.getProgramInfoLog(this.program);
|
|
154
|
+
throw new Error('Failed to link program: ' + info);
|
|
155
|
+
}
|
|
156
|
+
this.gl.deleteShader(vertexShader);
|
|
157
|
+
this.gl.deleteShader(fragmentShader);
|
|
158
|
+
// Get uniform locations
|
|
159
|
+
this.u_resolution = this.gl.getUniformLocation(this.program, 'u_resolution');
|
|
160
|
+
this.u_texArray = this.gl.getUniformLocation(this.program, 'u_texArray');
|
|
161
|
+
this.u_colorMatrix = this.gl.getUniformLocation(this.program, 'u_colorMatrix');
|
|
162
|
+
// Create instance attribute buffers
|
|
163
|
+
this.instanceDestRectBuffer = this.gl.createBuffer();
|
|
164
|
+
this.instanceColorBuffer = this.gl.createBuffer();
|
|
165
|
+
this.instanceTexLayerBuffer = this.gl.createBuffer();
|
|
166
|
+
// Create a VAO (required for WebGL2)
|
|
167
|
+
this.vao = this.gl.createVertexArray();
|
|
168
|
+
this.gl.bindVertexArray(this.vao);
|
|
169
|
+
// Setup instance attributes
|
|
170
|
+
const destRectLoc = this.gl.getAttribLocation(this.program, 'a_destRect');
|
|
171
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceDestRectBuffer);
|
|
172
|
+
this.gl.enableVertexAttribArray(destRectLoc);
|
|
173
|
+
this.gl.vertexAttribPointer(destRectLoc, 4, this.gl.FLOAT, false, 0, 0);
|
|
174
|
+
this.gl.vertexAttribDivisor(destRectLoc, 1);
|
|
175
|
+
const colorLoc = this.gl.getAttribLocation(this.program, 'a_color');
|
|
176
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceColorBuffer);
|
|
177
|
+
this.gl.enableVertexAttribArray(colorLoc);
|
|
178
|
+
this.gl.vertexAttribPointer(colorLoc, 4, this.gl.FLOAT, false, 0, 0);
|
|
179
|
+
this.gl.vertexAttribDivisor(colorLoc, 1);
|
|
180
|
+
const texLayerLoc = this.gl.getAttribLocation(this.program, 'a_texLayer');
|
|
181
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceTexLayerBuffer);
|
|
182
|
+
this.gl.enableVertexAttribArray(texLayerLoc);
|
|
183
|
+
this.gl.vertexAttribPointer(texLayerLoc, 1, this.gl.FLOAT, false, 0, 0);
|
|
184
|
+
this.gl.vertexAttribDivisor(texLayerLoc, 1);
|
|
185
|
+
// Set up blending for premultiplied alpha
|
|
186
|
+
this.gl.enable(this.gl.BLEND);
|
|
187
|
+
this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
|
|
188
|
+
// Use the program
|
|
189
|
+
this.gl.useProgram(this.program);
|
|
190
|
+
// Set texture unit
|
|
191
|
+
this.gl.uniform1i(this.u_texArray, 0);
|
|
192
|
+
// Set initial color matrix
|
|
193
|
+
this.gl.uniformMatrix3fv(this.u_colorMatrix, false, this.colorMatrix);
|
|
194
|
+
// Set one-time GL state
|
|
195
|
+
this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1);
|
|
196
|
+
this.gl.clearColor(0, 0, 0, 0);
|
|
197
|
+
this.gl.activeTexture(this.gl.TEXTURE0);
|
|
198
|
+
// Create initial texture array
|
|
199
|
+
this.createTexArray(TEX_INITIAL_SIZE, TEX_INITIAL_SIZE);
|
|
200
|
+
}
|
|
201
|
+
createShader(type, source) {
|
|
202
|
+
const shader = this.gl.createShader(type);
|
|
203
|
+
this.gl.shaderSource(shader, source);
|
|
204
|
+
this.gl.compileShader(shader);
|
|
205
|
+
if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
|
|
206
|
+
const info = this.gl.getShaderInfoLog(shader);
|
|
207
|
+
console.log(info);
|
|
208
|
+
this.gl.deleteShader(shader);
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
return shader;
|
|
212
|
+
}
|
|
213
|
+
// Set the color matrix for color space conversion.
|
|
214
|
+
// Pass null or undefined to use identity (no conversion).
|
|
215
|
+
setColorMatrix(subtitleColorSpace, videoColorSpace) {
|
|
216
|
+
this.colorMatrix = (subtitleColorSpace && videoColorSpace && colorMatrixConversionMap[subtitleColorSpace]?.[videoColorSpace]) ?? IDENTITY_MATRIX;
|
|
217
|
+
if (this.gl && this.u_colorMatrix && this.program) {
|
|
218
|
+
this.gl.useProgram(this.program);
|
|
219
|
+
this.gl.uniformMatrix3fv(this.u_colorMatrix, false, this.colorMatrix);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
createTexArray(width, height) {
|
|
223
|
+
if (this.texArray) {
|
|
224
|
+
this.gl.deleteTexture(this.texArray);
|
|
225
|
+
}
|
|
226
|
+
this.texArray = this.gl.createTexture();
|
|
227
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, this.texArray);
|
|
228
|
+
// Allocate storage for texture array
|
|
229
|
+
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 // Firefox cries about uninitialized data, but is slower with zero initialized data...
|
|
230
|
+
);
|
|
231
|
+
// Set texture parameters (no filtering needed for texelFetch, but set anyway)
|
|
232
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST);
|
|
233
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST);
|
|
234
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
|
235
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
|
236
|
+
this.texArrayWidth = width;
|
|
237
|
+
this.texArrayHeight = height;
|
|
238
|
+
}
|
|
239
|
+
render(images, heap) {
|
|
240
|
+
if (!this.gl || !this.program || !this.vao || !this.texArray)
|
|
241
|
+
return;
|
|
242
|
+
// HACK 1 and 2 [see above for explanation]
|
|
243
|
+
if ((self.HEAPU8RAW.buffer !== self.WASMMEMORY.buffer) || SHOULD_REFERENCE_MEMORY) {
|
|
244
|
+
heap = self.HEAPU8RAW = new Uint8Array(self.WASMMEMORY.buffer);
|
|
245
|
+
}
|
|
246
|
+
// we scheduled a resize because changing the canvas size clears it, and we don't want it to flicker
|
|
247
|
+
// so we do it here, right before rendering
|
|
248
|
+
if (this._scheduledResize) {
|
|
249
|
+
const { width, height } = this._scheduledResize;
|
|
250
|
+
this._scheduledResize = undefined;
|
|
251
|
+
this.canvas.width = width;
|
|
252
|
+
this.canvas.height = height;
|
|
253
|
+
// Update viewport and resolution uniform
|
|
254
|
+
this.gl.viewport(0, 0, width, height);
|
|
255
|
+
this.gl.uniform2f(this.u_resolution, width, height);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
// Clear canvas
|
|
259
|
+
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
260
|
+
}
|
|
261
|
+
// Find max dimensions needed and filter valid images
|
|
262
|
+
let maxW = this.texArrayWidth;
|
|
263
|
+
let maxH = this.texArrayHeight;
|
|
264
|
+
const validImages = [];
|
|
265
|
+
for (const img of images) {
|
|
266
|
+
if (img.w <= 0 || img.h <= 0)
|
|
267
|
+
continue;
|
|
268
|
+
validImages.push(img);
|
|
269
|
+
if (img.w > maxW)
|
|
270
|
+
maxW = img.w;
|
|
271
|
+
if (img.h > maxH)
|
|
272
|
+
maxH = img.h;
|
|
273
|
+
}
|
|
274
|
+
if (validImages.length === 0)
|
|
275
|
+
return;
|
|
276
|
+
// Resize texture array if needed
|
|
277
|
+
if (maxW > this.texArrayWidth || maxH > this.texArrayHeight) {
|
|
278
|
+
this.createTexArray(maxW, maxH);
|
|
279
|
+
}
|
|
280
|
+
// Process images in chunks that fit within texture array size
|
|
281
|
+
const batchSize = Math.min(TEX_ARRAY_SIZE, MAX_INSTANCES);
|
|
282
|
+
for (let batchStart = 0; batchStart < validImages.length; batchStart += batchSize) {
|
|
283
|
+
const batchEnd = Math.min(batchStart + batchSize, validImages.length);
|
|
284
|
+
let instanceCount = 0;
|
|
285
|
+
// Upload textures for this batch
|
|
286
|
+
for (let i = batchStart; i < batchEnd; i++) {
|
|
287
|
+
const img = validImages[i];
|
|
288
|
+
const layer = instanceCount;
|
|
289
|
+
// Upload bitmap data to texture array layer
|
|
290
|
+
this.gl.pixelStorei(this.gl.UNPACK_ROW_LENGTH, img.stride);
|
|
291
|
+
if (IS_FIREFOX) {
|
|
292
|
+
// HACK 3 [see above for explanation]
|
|
293
|
+
const sourceView = new Uint8Array(heap.buffer, img.bitmap, img.stride * img.h);
|
|
294
|
+
const bitmapData = new Uint8Array(sourceView);
|
|
295
|
+
this.gl.texSubImage3D(this.gl.TEXTURE_2D_ARRAY, 0, 0, 0, layer, // x, y, z offset
|
|
296
|
+
img.w, img.h, 1, // depth (1 layer)
|
|
297
|
+
this.gl.RED, this.gl.UNSIGNED_BYTE, bitmapData);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
this.gl.texSubImage3D(this.gl.TEXTURE_2D_ARRAY, 0, 0, 0, layer, // x, y, z offset
|
|
301
|
+
img.w, img.h, 1, // depth (1 layer)
|
|
302
|
+
this.gl.RED, this.gl.UNSIGNED_BYTE, heap, img.bitmap);
|
|
303
|
+
}
|
|
304
|
+
// Fill instance data
|
|
305
|
+
const idx = instanceCount * 4;
|
|
306
|
+
this.instanceDestRectData[idx] = img.dst_x;
|
|
307
|
+
this.instanceDestRectData[idx + 1] = img.dst_y;
|
|
308
|
+
this.instanceDestRectData[idx + 2] = img.w;
|
|
309
|
+
this.instanceDestRectData[idx + 3] = img.h;
|
|
310
|
+
this.instanceColorData[idx] = ((img.color >>> 24) & 0xFF) / 255;
|
|
311
|
+
this.instanceColorData[idx + 1] = ((img.color >>> 16) & 0xFF) / 255;
|
|
312
|
+
this.instanceColorData[idx + 2] = ((img.color >>> 8) & 0xFF) / 255;
|
|
313
|
+
this.instanceColorData[idx + 3] = (img.color & 0xFF) / 255;
|
|
314
|
+
this.instanceTexLayerData[instanceCount] = layer;
|
|
315
|
+
instanceCount++;
|
|
316
|
+
}
|
|
317
|
+
this.gl.pixelStorei(this.gl.UNPACK_ROW_LENGTH, 0);
|
|
318
|
+
if (instanceCount === 0)
|
|
319
|
+
continue;
|
|
320
|
+
// Upload instance data to buffers
|
|
321
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceDestRectBuffer);
|
|
322
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, this.instanceDestRectData.subarray(0, instanceCount * 4), this.gl.DYNAMIC_DRAW);
|
|
323
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceColorBuffer);
|
|
324
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, this.instanceColorData.subarray(0, instanceCount * 4), this.gl.DYNAMIC_DRAW);
|
|
325
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceTexLayerBuffer);
|
|
326
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, this.instanceTexLayerData.subarray(0, instanceCount), this.gl.DYNAMIC_DRAW);
|
|
327
|
+
// Single instanced draw call
|
|
328
|
+
this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, instanceCount);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
destroy() {
|
|
332
|
+
if (this.gl) {
|
|
333
|
+
if (this.texArray) {
|
|
334
|
+
this.gl.deleteTexture(this.texArray);
|
|
335
|
+
this.texArray = null;
|
|
336
|
+
}
|
|
337
|
+
if (this.instanceDestRectBuffer) {
|
|
338
|
+
this.gl.deleteBuffer(this.instanceDestRectBuffer);
|
|
339
|
+
this.instanceDestRectBuffer = null;
|
|
340
|
+
}
|
|
341
|
+
if (this.instanceColorBuffer) {
|
|
342
|
+
this.gl.deleteBuffer(this.instanceColorBuffer);
|
|
343
|
+
this.instanceColorBuffer = null;
|
|
344
|
+
}
|
|
345
|
+
if (this.instanceTexLayerBuffer) {
|
|
346
|
+
this.gl.deleteBuffer(this.instanceTexLayerBuffer);
|
|
347
|
+
this.instanceTexLayerBuffer = null;
|
|
348
|
+
}
|
|
349
|
+
if (this.vao) {
|
|
350
|
+
this.gl.deleteVertexArray(this.vao);
|
|
351
|
+
this.vao = null;
|
|
352
|
+
}
|
|
353
|
+
if (this.program) {
|
|
354
|
+
this.gl.deleteProgram(this.program);
|
|
355
|
+
this.program = null;
|
|
356
|
+
}
|
|
357
|
+
this.gl = null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
//# sourceMappingURL=webgl2-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl2-renderer.js","sourceRoot":"","sources":["../../../src/worker/renderers/webgl2-renderer.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,UAAU,EAAE,uBAAuB,EAAiB,MAAM,YAAY,CAAA;AAQ1H,4CAA4C;AAC5C,MAAM,aAAa,GAAG,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoC/B,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mBAAmB,EAAE,CAAC;gBAC7B,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;gBAC9C,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAA;YACjC,CAAC;YAED,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;gBAChC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;gBACjD,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAA;YACpC,CAAC;YAED,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACnC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;YACjB,CAAC;YAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBACnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACrB,CAAC;YAED,IAAI,CAAC,EAAE,GAAG,IAAI,CAAA;QAChB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ASSImage } from '../util.ts';
|
|
2
|
+
export declare const colorMatrixConversionMap: {
|
|
3
|
+
readonly BT601: {
|
|
4
|
+
readonly BT709: Float32Array<ArrayBuffer>;
|
|
5
|
+
readonly BT601: Float32Array<ArrayBuffer>;
|
|
6
|
+
};
|
|
7
|
+
readonly BT709: {
|
|
8
|
+
readonly BT601: Float32Array<ArrayBuffer>;
|
|
9
|
+
readonly BT709: Float32Array<ArrayBuffer>;
|
|
10
|
+
};
|
|
11
|
+
readonly FCC: {
|
|
12
|
+
readonly BT709: Float32Array<ArrayBuffer>;
|
|
13
|
+
readonly BT601: Float32Array<ArrayBuffer>;
|
|
14
|
+
};
|
|
15
|
+
readonly SMPTE240M: {
|
|
16
|
+
readonly BT709: Float32Array<ArrayBuffer>;
|
|
17
|
+
readonly BT601: Float32Array<ArrayBuffer>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type ColorSpace = keyof typeof colorMatrixConversionMap;
|
|
21
|
+
interface TextureInfo {
|
|
22
|
+
texture: GPUTexture;
|
|
23
|
+
view: GPUTextureView;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}
|
|
27
|
+
export declare class WebGPURenderer {
|
|
28
|
+
device: GPUDevice | null;
|
|
29
|
+
context: GPUCanvasContext | null;
|
|
30
|
+
pipeline: GPURenderPipeline | null;
|
|
31
|
+
bindGroupLayout: GPUBindGroupLayout | null;
|
|
32
|
+
uniformBuffer: GPUBuffer | null;
|
|
33
|
+
colorMatrixBuffer: GPUBuffer | null;
|
|
34
|
+
imageDataBuffers: GPUBuffer[];
|
|
35
|
+
textures: TextureInfo[];
|
|
36
|
+
pendingDestroyTextures: GPUTexture[];
|
|
37
|
+
format: GPUTextureFormat;
|
|
38
|
+
constructor(device: GPUDevice);
|
|
39
|
+
setCanvas(canvas: OffscreenCanvas, width: number, height: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Set the color matrix for color space conversion.
|
|
42
|
+
* Pass null or undefined to use identity (no conversion).
|
|
43
|
+
* Matrix should be a pre-padded Float32Array with 12 values (3 columns × 4 floats each).
|
|
44
|
+
*/
|
|
45
|
+
setColorMatrix(subtitleColorSpace?: 'BT601' | 'BT709' | 'SMPTE240M' | 'FCC', videoColorSpace?: 'BT601' | 'BT709'): void;
|
|
46
|
+
createTextureInfo(width: number, height: number): TextureInfo;
|
|
47
|
+
render(images: ASSImage[], heap: Uint8Array): void;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
}
|
|
50
|
+
export {};
|