@flighthq/render-gl 0.5.1-next.1069.554a2ac → 0.5.1-next.1201.9b49dee
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 +2 -2
- package/dist/contract.d.ts +1 -3
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +1 -3
- package/dist/contract.js.map +1 -1
- package/dist/enableGlRenderStateGuards.js +2 -2
- package/dist/enableGlRenderStateGuards.js.map +1 -1
- package/dist/glCubeRenderTarget.d.ts +5 -5
- package/dist/glCubeRenderTarget.d.ts.map +1 -1
- package/dist/glCubeRenderTarget.js +16 -13
- package/dist/glCubeRenderTarget.js.map +1 -1
- package/dist/glFullscreenPass.d.ts +4 -3
- package/dist/glFullscreenPass.d.ts.map +1 -1
- package/dist/glFullscreenPass.js +152 -23
- package/dist/glFullscreenPass.js.map +1 -1
- package/dist/glLinearToSrgbPass.d.ts +2 -2
- package/dist/glLinearToSrgbPass.d.ts.map +1 -1
- package/dist/glLinearToSrgbPass.js.map +1 -1
- package/dist/glPresentRenderTarget.d.ts +2 -2
- package/dist/glPresentRenderTarget.d.ts.map +1 -1
- package/dist/glPresentRenderTarget.js.map +1 -1
- package/dist/glReadback.d.ts +2 -2
- package/dist/glReadback.d.ts.map +1 -1
- package/dist/glReadback.js +1 -1
- package/dist/glReadback.js.map +1 -1
- package/dist/glRenderPass.d.ts +6 -3
- package/dist/glRenderPass.d.ts.map +1 -1
- package/dist/glRenderPass.js +105 -86
- package/dist/glRenderPass.js.map +1 -1
- package/dist/glRenderState.d.ts +1 -2
- package/dist/glRenderState.d.ts.map +1 -1
- package/dist/glRenderState.js +53 -46
- package/dist/glRenderState.js.map +1 -1
- package/dist/glRenderTarget.d.ts +17 -16
- package/dist/glRenderTarget.d.ts.map +1 -1
- package/dist/glRenderTarget.js +38 -26
- package/dist/glRenderTarget.js.map +1 -1
- package/dist/glRenderTargetPool.d.ts +9 -9
- package/dist/glRenderTargetPool.d.ts.map +1 -1
- package/dist/glRenderTargetPool.js +10 -12
- package/dist/glRenderTargetPool.js.map +1 -1
- package/dist/glRenderTexture.d.ts +2 -2
- package/dist/glRenderTexture.d.ts.map +1 -1
- package/dist/glRenderTexture.js +11 -13
- package/dist/glRenderTexture.js.map +1 -1
- package/dist/glRenderTexturePool.js +3 -5
- package/dist/glRenderTexturePool.js.map +1 -1
- package/dist/glSkinPaletteTexture.js +8 -2
- package/dist/glSkinPaletteTexture.js.map +1 -1
- package/dist/glTestHelper.d.ts +0 -1
- package/dist/glTestHelper.d.ts.map +1 -1
- package/dist/glTestHelper.js +0 -1
- package/dist/glTestHelper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/enableGlRenderStateGuards.test.ts +2 -4
- package/src/glContext.test.ts +3 -52
- package/src/glCubeRenderTarget.test.ts +10 -8
- package/src/glDraw.test.ts +4 -16
- package/src/glFullscreenPass.test.ts +145 -41
- package/src/glLinearToSrgbPass.test.ts +8 -5
- package/src/glPresentRenderTarget.test.ts +3 -5
- package/src/glReadback.test.ts +3 -3
- package/src/glRenderPass.test.ts +228 -55
- package/src/glRenderState.test.ts +106 -165
- package/src/glRenderTarget.test.ts +134 -99
- package/src/glRenderTargetPool.test.ts +69 -76
- package/src/glRenderTexture.test.ts +58 -31
- package/src/glSkinPaletteTexture.test.ts +9 -0
- package/src/glTextureResolver.test.ts +5 -1
- package/dist/glBackground.d.ts +0 -3
- package/dist/glBackground.d.ts.map +0 -1
- package/dist/glBackground.js +0 -19
- package/dist/glBackground.js.map +0 -1
- package/dist/glContext.d.ts +0 -3
- package/dist/glContext.d.ts.map +0 -1
- package/dist/glContext.js +0 -16
- package/dist/glContext.js.map +0 -1
- package/src/glBackground.test.ts +0 -68
|
@@ -32,7 +32,6 @@ import { registerGlMaterialRenderer } from './glMaterialRegistry';
|
|
|
32
32
|
import { createEmptyGlRegistries, createGlPipeline } from './glPipeline';
|
|
33
33
|
import {
|
|
34
34
|
createGlContextState,
|
|
35
|
-
createGlOffscreenRenderState,
|
|
36
35
|
createGlRenderState,
|
|
37
36
|
createGlRenderStateRuntime,
|
|
38
37
|
destroyGlRenderState,
|
|
@@ -63,7 +62,7 @@ function expectEntitySlot(slot: object & { readonly [EntityRuntimeKey]?: unknown
|
|
|
63
62
|
const testPipeline = createGlPipeline(createEmptyGlRegistries());
|
|
64
63
|
|
|
65
64
|
function createTestGlRenderState(gl: WebGL2RenderingContext, options: GlRenderOptions = {}) {
|
|
66
|
-
return createGlRenderState(
|
|
65
|
+
return createGlRenderState(gl, testPipeline, options);
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
function getPaddingResolver(state: RenderState, kind: string): RenderEffectPaddingResolver | null {
|
|
@@ -89,9 +88,8 @@ describe('createGlContextState', () => {
|
|
|
89
88
|
|
|
90
89
|
it('returns a state that shares the context tier across derived render states', () => {
|
|
91
90
|
const { gl } = makeContext();
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
const stateB = createGlRenderState(contextState, testPipeline);
|
|
91
|
+
const stateA = createGlRenderState(gl, testPipeline);
|
|
92
|
+
const stateB = createGlRenderState(gl, testPipeline);
|
|
95
93
|
const runtimeA = getGlRenderStateRuntime(stateA);
|
|
96
94
|
const runtimeB = getGlRenderStateRuntime(stateB);
|
|
97
95
|
|
|
@@ -125,11 +123,10 @@ describe('createGlContextState (Entity backing)', () => {
|
|
|
125
123
|
expect(runtimeA.textureCache).not.toBe(runtimeB.textureCache);
|
|
126
124
|
});
|
|
127
125
|
|
|
128
|
-
it('shares the context tier between two render states built from the same
|
|
126
|
+
it('shares the context tier between two render states built from the same GL handle', () => {
|
|
129
127
|
const gl = makeGL();
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const renderB = createGlRenderState(contextState, testPipeline);
|
|
128
|
+
const renderA = createGlRenderState(gl, testPipeline);
|
|
129
|
+
const renderB = createGlRenderState(gl, testPipeline);
|
|
133
130
|
|
|
134
131
|
const runtimeA = getGlRenderStateRuntime(renderA);
|
|
135
132
|
const runtimeB = getGlRenderStateRuntime(renderB);
|
|
@@ -141,7 +138,89 @@ describe('createGlContextState (Entity backing)', () => {
|
|
|
141
138
|
});
|
|
142
139
|
});
|
|
143
140
|
|
|
144
|
-
describe('
|
|
141
|
+
describe('createGlRenderState', () => {
|
|
142
|
+
it('stores the GL context on the returned state', () => {
|
|
143
|
+
const { gl } = makeContext();
|
|
144
|
+
const state = createTestGlRenderState(gl);
|
|
145
|
+
expect(state.gl).toBe(gl);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('initializes runtime currentBlendSignature to null', () => {
|
|
149
|
+
const { gl } = makeContext();
|
|
150
|
+
const state = createTestGlRenderState(gl);
|
|
151
|
+
expect(getGlRenderStateRuntime(state).context.currentBlendSignature).toBeNull();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('initializes runtime currentShader to null', () => {
|
|
155
|
+
const { gl } = makeContext();
|
|
156
|
+
const state = createTestGlRenderState(gl);
|
|
157
|
+
expect(getGlRenderStateRuntime(state).context.currentShader).toBeNull();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('initializes runtime currentTextureRealization to null', () => {
|
|
161
|
+
const { gl } = makeContext();
|
|
162
|
+
const state = createTestGlRenderState(gl);
|
|
163
|
+
expect(getGlRenderStateRuntime(state).context.currentTextureRealization).toBeNull();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('enables blending during initialization', () => {
|
|
167
|
+
const { gl } = makeContext();
|
|
168
|
+
createTestGlRenderState(gl);
|
|
169
|
+
expect(gl.enable).toHaveBeenCalledWith((gl as unknown as { BLEND: number }).BLEND);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('disables depth testing during initialization', () => {
|
|
173
|
+
const { gl } = makeContext();
|
|
174
|
+
createTestGlRenderState(gl);
|
|
175
|
+
expect(gl.disable).toHaveBeenCalledWith((gl as unknown as { DEPTH_TEST: number }).DEPTH_TEST);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('sets the default premultiplied-alpha blend function', () => {
|
|
179
|
+
const { gl } = makeContext();
|
|
180
|
+
createTestGlRenderState(gl);
|
|
181
|
+
const g = gl as unknown as { ONE: number; ONE_MINUS_SRC_ALPHA: number };
|
|
182
|
+
expect(gl.blendFunc).toHaveBeenCalledWith(g.ONE, g.ONE_MINUS_SRC_ALPHA);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('uses the provided pixelRatio option', () => {
|
|
186
|
+
const { gl } = makeContext();
|
|
187
|
+
const state = createTestGlRenderState(gl, { pixelRatio: 2 });
|
|
188
|
+
expect(state.pixelRatio).toBe(2);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('uses imageSmoothingEnabled before the legacy allowSmoothing alias', () => {
|
|
192
|
+
const { gl } = makeContext();
|
|
193
|
+
const state = createTestGlRenderState(gl, { allowSmoothing: false, imageSmoothingEnabled: true });
|
|
194
|
+
expect(state.allowSmoothing).toBe(true);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('defaults roundPixels to false', () => {
|
|
198
|
+
const { gl } = makeContext();
|
|
199
|
+
const state = createTestGlRenderState(gl);
|
|
200
|
+
expect(state.roundPixels).toBe(false);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('applies the roundPixels option', () => {
|
|
204
|
+
const { gl } = makeContext();
|
|
205
|
+
const state = createTestGlRenderState(gl, { roundPixels: true });
|
|
206
|
+
expect(state.roundPixels).toBe(true);
|
|
207
|
+
});
|
|
208
|
+
it('shares the context tier when two states are built from the same GL handle', () => {
|
|
209
|
+
const { gl } = makeContext();
|
|
210
|
+
const stateA = createGlRenderState(gl, testPipeline);
|
|
211
|
+
const stateB = createGlRenderState(gl, testPipeline);
|
|
212
|
+
const runtimeA = getGlRenderStateRuntime(stateA);
|
|
213
|
+
const runtimeB = getGlRenderStateRuntime(stateB);
|
|
214
|
+
|
|
215
|
+
runtimeA.context.currentBlendSignature = { dst: 1, equation: 2, src: 3 };
|
|
216
|
+
expect(runtimeB.context.currentBlendSignature).toEqual({ dst: 1, equation: 2, src: 3 });
|
|
217
|
+
|
|
218
|
+
runtimeB.context.currentBlendSignature = { dst: 4, equation: 5, src: 6 };
|
|
219
|
+
expect(runtimeA.context.currentBlendSignature).toEqual({ dst: 4, equation: 5, src: 6 });
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe('createGlRenderState (context sharing)', () => {
|
|
145
224
|
it('shares context resources and persistent registration snapshots through independent aggregates', () => {
|
|
146
225
|
const { gl } = makeContext();
|
|
147
226
|
const screen = createTestGlRenderState(gl);
|
|
@@ -186,7 +265,7 @@ describe('createGlOffscreenRenderState', () => {
|
|
|
186
265
|
|
|
187
266
|
const screenRuntime = getGlRenderStateRuntime(screen);
|
|
188
267
|
const offscreenPipeline = createGlPipeline(screenRuntime.registries);
|
|
189
|
-
const offscreen =
|
|
268
|
+
const offscreen = createGlRenderState(screen.gl, offscreenPipeline);
|
|
190
269
|
const offscreenRuntime = getGlRenderStateRuntime(offscreen);
|
|
191
270
|
|
|
192
271
|
expect(offscreen.gl).toBe(screen.gl);
|
|
@@ -267,7 +346,7 @@ describe('createGlOffscreenRenderState', () => {
|
|
|
267
346
|
it('does not observe registrations added after pipeline construction', () => {
|
|
268
347
|
const { gl } = makeContext();
|
|
269
348
|
const screen = createTestGlRenderState(gl);
|
|
270
|
-
let offscreen =
|
|
349
|
+
let offscreen = createGlRenderState(screen.gl, screen.pipeline);
|
|
271
350
|
const renderer = { createData: () => null, submit: vi.fn() };
|
|
272
351
|
const paddingResolver = vi.fn(() => ({ bottom: 2, left: 2, right: 2, top: 2 }));
|
|
273
352
|
const resolver = vi.fn(() => null);
|
|
@@ -282,10 +361,7 @@ describe('createGlOffscreenRenderState', () => {
|
|
|
282
361
|
expect(getPaddingResolver(offscreen, 'acme.LateEffect')).toBeNull();
|
|
283
362
|
|
|
284
363
|
destroyGlRenderState(offscreen);
|
|
285
|
-
offscreen =
|
|
286
|
-
screen.contextState,
|
|
287
|
-
createGlPipeline(getGlRenderStateRuntime(screen).registries),
|
|
288
|
-
);
|
|
364
|
+
offscreen = createGlRenderState(screen.gl, createGlPipeline(getGlRenderStateRuntime(screen).registries));
|
|
289
365
|
expect(getRegistryTableEntry(getRenderStateRuntime(offscreen).registries.renderers, 'acme.LateNode')).toBe(
|
|
290
366
|
renderer,
|
|
291
367
|
);
|
|
@@ -305,10 +381,7 @@ describe('createGlOffscreenRenderState', () => {
|
|
|
305
381
|
destroyData,
|
|
306
382
|
submit: vi.fn(),
|
|
307
383
|
});
|
|
308
|
-
const offscreen =
|
|
309
|
-
screen.contextState,
|
|
310
|
-
createGlPipeline(getGlRenderStateRuntime(screen).registries),
|
|
311
|
-
);
|
|
384
|
+
const offscreen = createGlRenderState(screen.gl, createGlPipeline(getGlRenderStateRuntime(screen).registries));
|
|
312
385
|
prepareScene2DRender(offscreen, root);
|
|
313
386
|
|
|
314
387
|
expect(getRenderStateRuntime(offscreen).renderProxyMap).not.toBe(getRenderStateRuntime(screen).renderProxyMap);
|
|
@@ -321,131 +394,6 @@ describe('createGlOffscreenRenderState', () => {
|
|
|
321
394
|
});
|
|
322
395
|
});
|
|
323
396
|
|
|
324
|
-
describe('createGlRenderState', () => {
|
|
325
|
-
it('stores the GL context on the returned state', () => {
|
|
326
|
-
const { gl } = makeContext();
|
|
327
|
-
const state = createTestGlRenderState(gl);
|
|
328
|
-
expect(state.gl).toBe(gl);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it('initializes runtime currentBlendSignature to null', () => {
|
|
332
|
-
const { gl } = makeContext();
|
|
333
|
-
const state = createTestGlRenderState(gl);
|
|
334
|
-
expect(getGlRenderStateRuntime(state).context.currentBlendSignature).toBeNull();
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
it('initializes runtime currentShader to null', () => {
|
|
338
|
-
const { gl } = makeContext();
|
|
339
|
-
const state = createTestGlRenderState(gl);
|
|
340
|
-
expect(getGlRenderStateRuntime(state).context.currentShader).toBeNull();
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it('initializes runtime currentTextureRealization to null', () => {
|
|
344
|
-
const { gl } = makeContext();
|
|
345
|
-
const state = createTestGlRenderState(gl);
|
|
346
|
-
expect(getGlRenderStateRuntime(state).context.currentTextureRealization).toBeNull();
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
it('enables blending during initialization', () => {
|
|
350
|
-
const { gl } = makeContext();
|
|
351
|
-
createTestGlRenderState(gl);
|
|
352
|
-
expect(gl.enable).toHaveBeenCalledWith((gl as unknown as { BLEND: number }).BLEND);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it('disables depth testing during initialization', () => {
|
|
356
|
-
const { gl } = makeContext();
|
|
357
|
-
createTestGlRenderState(gl);
|
|
358
|
-
expect(gl.disable).toHaveBeenCalledWith((gl as unknown as { DEPTH_TEST: number }).DEPTH_TEST);
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it('sets the default premultiplied-alpha blend function', () => {
|
|
362
|
-
const { gl } = makeContext();
|
|
363
|
-
createTestGlRenderState(gl);
|
|
364
|
-
const g = gl as unknown as { ONE: number; ONE_MINUS_SRC_ALPHA: number };
|
|
365
|
-
expect(gl.blendFunc).toHaveBeenCalledWith(g.ONE, g.ONE_MINUS_SRC_ALPHA);
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
it('applies the backgroundColor option', () => {
|
|
369
|
-
const { gl } = makeContext();
|
|
370
|
-
const state = createTestGlRenderState(gl, { backgroundColor: 0xff0000ff });
|
|
371
|
-
expect(state.backgroundColor).toBe(0xff0000ff);
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
it('uses the provided pixelRatio option', () => {
|
|
375
|
-
const { gl } = makeContext();
|
|
376
|
-
const state = createTestGlRenderState(gl, { pixelRatio: 2 });
|
|
377
|
-
expect(state.pixelRatio).toBe(2);
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
it('uses imageSmoothingEnabled before the legacy allowSmoothing alias', () => {
|
|
381
|
-
const { gl } = makeContext();
|
|
382
|
-
const state = createTestGlRenderState(gl, { allowSmoothing: false, imageSmoothingEnabled: true });
|
|
383
|
-
expect(state.allowSmoothing).toBe(true);
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
it('defaults roundPixels to false', () => {
|
|
387
|
-
const { gl } = makeContext();
|
|
388
|
-
const state = createTestGlRenderState(gl);
|
|
389
|
-
expect(state.roundPixels).toBe(false);
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
it('applies the roundPixels option', () => {
|
|
393
|
-
const { gl } = makeContext();
|
|
394
|
-
const state = createTestGlRenderState(gl, { roundPixels: true });
|
|
395
|
-
expect(state.roundPixels).toBe(true);
|
|
396
|
-
});
|
|
397
|
-
it('shares the context tier when two states are built from the same GlContextState', () => {
|
|
398
|
-
const { gl } = makeContext();
|
|
399
|
-
const contextState = createGlContextState(gl);
|
|
400
|
-
const stateA = createGlRenderState(contextState, testPipeline);
|
|
401
|
-
const stateB = createGlRenderState(contextState, testPipeline);
|
|
402
|
-
const runtimeA = getGlRenderStateRuntime(stateA);
|
|
403
|
-
const runtimeB = getGlRenderStateRuntime(stateB);
|
|
404
|
-
|
|
405
|
-
runtimeA.context.currentBlendSignature = { dst: 1, equation: 2, src: 3 };
|
|
406
|
-
expect(runtimeB.context.currentBlendSignature).toEqual({ dst: 1, equation: 2, src: 3 });
|
|
407
|
-
|
|
408
|
-
runtimeB.context.currentBlendSignature = { dst: 4, equation: 5, src: 6 };
|
|
409
|
-
expect(runtimeA.context.currentBlendSignature).toEqual({ dst: 4, equation: 5, src: 6 });
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
it('keeps separate context tiers when two states are built from the same raw GL', () => {
|
|
413
|
-
const { gl } = makeContext();
|
|
414
|
-
const stateA = createTestGlRenderState(gl);
|
|
415
|
-
const stateB = createTestGlRenderState(gl);
|
|
416
|
-
const runtimeA = getGlRenderStateRuntime(stateA);
|
|
417
|
-
const runtimeB = getGlRenderStateRuntime(stateB);
|
|
418
|
-
|
|
419
|
-
runtimeA.context.currentBlendSignature = { dst: 1, equation: 2, src: 3 };
|
|
420
|
-
expect(runtimeB.context.currentBlendSignature).toBeNull();
|
|
421
|
-
});
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
describe('createGlRenderState with an explicit context state', () => {
|
|
425
|
-
it('shares context-owned binding state between render states using one owner', () => {
|
|
426
|
-
const { gl } = makeContext();
|
|
427
|
-
const contextState = createGlContextState(gl);
|
|
428
|
-
const first = createGlRenderState(contextState, testPipeline);
|
|
429
|
-
const second = createGlRenderState(contextState, testPipeline);
|
|
430
|
-
|
|
431
|
-
getGlRenderStateRuntime(first).context.currentBlendSignature = { dst: 1, equation: 2, src: 3 };
|
|
432
|
-
expect(getGlRenderStateRuntime(second).context.currentBlendSignature).toEqual({ dst: 1, equation: 2, src: 3 });
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
it('builds a render state whose context tier is shared with siblings from the same context state', () => {
|
|
436
|
-
const { gl } = makeContext();
|
|
437
|
-
const contextState = createGlContextState(gl);
|
|
438
|
-
const stateA = createGlRenderState(contextState, testPipeline);
|
|
439
|
-
const stateB = createGlRenderState(contextState, testPipeline);
|
|
440
|
-
expect(stateA.gl).toBe(gl);
|
|
441
|
-
expect(stateB.gl).toBe(gl);
|
|
442
|
-
const runtimeA = getGlRenderStateRuntime(stateA);
|
|
443
|
-
const runtimeB = getGlRenderStateRuntime(stateB);
|
|
444
|
-
runtimeA.context.currentBlendSignature = { dst: 7, equation: 8, src: 9 };
|
|
445
|
-
expect(runtimeB.context.currentBlendSignature).toEqual({ dst: 7, equation: 8, src: 9 });
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
|
|
449
397
|
describe('createGlRenderStateRuntime', () => {
|
|
450
398
|
it('returns a runtime with the base binding slot and empty named registration tables', () => {
|
|
451
399
|
const contextState = createGlContextState(makeGL());
|
|
@@ -537,9 +485,8 @@ describe('createGlRenderStateRuntime', () => {
|
|
|
537
485
|
describe('destroyGlRenderState', () => {
|
|
538
486
|
it('runs registered context teardown once after the final shared owner is destroyed', () => {
|
|
539
487
|
const { gl } = makeContext();
|
|
540
|
-
const
|
|
541
|
-
const
|
|
542
|
-
const second = createGlRenderState(contextState, testPipeline);
|
|
488
|
+
const first = createGlRenderState(gl, testPipeline);
|
|
489
|
+
const second = createGlRenderState(gl, testPipeline);
|
|
543
490
|
const teardown = vi.fn();
|
|
544
491
|
const runtime = getGlRenderStateRuntime(first);
|
|
545
492
|
runtime.context.teardowns.push(teardown);
|
|
@@ -596,11 +543,10 @@ describe('destroyGlRenderState', () => {
|
|
|
596
543
|
|
|
597
544
|
it('invokes registered teardown callbacks when the last reference is destroyed', () => {
|
|
598
545
|
const { gl } = makeContext();
|
|
599
|
-
const
|
|
600
|
-
const
|
|
601
|
-
const stateB = createGlRenderState(contextState, testPipeline);
|
|
546
|
+
const stateA = createGlRenderState(gl, testPipeline);
|
|
547
|
+
const stateB = createGlRenderState(gl, testPipeline);
|
|
602
548
|
const teardown = vi.fn();
|
|
603
|
-
registerGlContextTeardown(contextState, teardown);
|
|
549
|
+
registerGlContextTeardown(stateA.contextState, teardown);
|
|
604
550
|
|
|
605
551
|
destroyGlRenderState(stateA);
|
|
606
552
|
expect(teardown).not.toHaveBeenCalled();
|
|
@@ -612,11 +558,10 @@ describe('destroyGlRenderState', () => {
|
|
|
612
558
|
|
|
613
559
|
it('does not invoke teardowns when references remain', () => {
|
|
614
560
|
const { gl } = makeContext();
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
createGlRenderState(contextState, testPipeline);
|
|
561
|
+
const stateA = createGlRenderState(gl, testPipeline);
|
|
562
|
+
createGlRenderState(gl, testPipeline);
|
|
618
563
|
const teardown = vi.fn();
|
|
619
|
-
registerGlContextTeardown(contextState, teardown);
|
|
564
|
+
registerGlContextTeardown(stateA.contextState, teardown);
|
|
620
565
|
|
|
621
566
|
destroyGlRenderState(stateA);
|
|
622
567
|
expect(teardown).not.toHaveBeenCalled();
|
|
@@ -635,7 +580,7 @@ describe('enableGlRenderStateGuards', () => {
|
|
|
635
580
|
prepareScene2DRender(state, createDisplayObject());
|
|
636
581
|
const entries = getMemoryLogSinkEntries(sink);
|
|
637
582
|
expect(entries).toHaveLength(1);
|
|
638
|
-
expect((entries[0].data as { message: string }).message).toContain('
|
|
583
|
+
expect((entries[0].data as { message: string }).message).toContain('createGlRenderState');
|
|
639
584
|
} finally {
|
|
640
585
|
removeLogSink(sink.sink);
|
|
641
586
|
}
|
|
@@ -765,7 +710,7 @@ describe('pipeline-backed GL registrations', () => {
|
|
|
765
710
|
it('requires a rebuilt pipeline to carry late registrations into a new state', () => {
|
|
766
711
|
const { gl } = makeContext();
|
|
767
712
|
const screen = createTestGlRenderState(gl);
|
|
768
|
-
let offscreen =
|
|
713
|
+
let offscreen = createGlRenderState(screen.gl, screen.pipeline);
|
|
769
714
|
const materialRenderer = { instanceFloatCount: 0, bind: vi.fn() } as never;
|
|
770
715
|
const offscreenMaterialRenderer = { instanceFloatCount: 0, bind: vi.fn() } as never;
|
|
771
716
|
const decoder = vi.fn(() => new Uint8ClampedArray(4));
|
|
@@ -786,10 +731,7 @@ describe('pipeline-backed GL registrations', () => {
|
|
|
786
731
|
expect(getGlRenderStateRuntime(offscreen).registries.compressedTextureDecoder.entry).toBeNull();
|
|
787
732
|
expect(getGlRenderStateRuntime(offscreen).registries.compressedTextureUpload.entry).toBeNull();
|
|
788
733
|
destroyGlRenderState(offscreen);
|
|
789
|
-
offscreen =
|
|
790
|
-
screen.contextState,
|
|
791
|
-
createGlPipeline(getGlRenderStateRuntime(screen).registries),
|
|
792
|
-
);
|
|
734
|
+
offscreen = createGlRenderState(screen.gl, createGlPipeline(getGlRenderStateRuntime(screen).registries));
|
|
793
735
|
expect(isBlendModeSupported(offscreen, 'acme.LateBlend')).toBe(true);
|
|
794
736
|
expect(
|
|
795
737
|
getRegistryTableEntry(getGlRenderStateRuntime(offscreen).registries.materialRenderers, 'acme.LateMaterial'),
|
|
@@ -841,10 +783,9 @@ describe('pipeline-backed GL registrations', () => {
|
|
|
841
783
|
describe('registerGlContextTeardown', () => {
|
|
842
784
|
it('pushes a callback that fires on context teardown', () => {
|
|
843
785
|
const { gl } = makeContext();
|
|
844
|
-
const
|
|
845
|
-
const state = createGlRenderState(contextState, testPipeline);
|
|
786
|
+
const state = createGlRenderState(gl, testPipeline);
|
|
846
787
|
const teardown = vi.fn();
|
|
847
|
-
registerGlContextTeardown(contextState, teardown);
|
|
788
|
+
registerGlContextTeardown(state.contextState, teardown);
|
|
848
789
|
destroyGlRenderState(state);
|
|
849
790
|
expect(teardown).toHaveBeenCalledOnce();
|
|
850
791
|
expect(teardown).toHaveBeenCalledWith(gl);
|