@flighthq/render-gl 0.5.1-next.3302.76ece6b → 0.5.1-next.4304.322dc96
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/enableGlRenderStateGuards.d.ts +2 -1
- package/dist/enableGlRenderStateGuards.d.ts.map +1 -1
- package/dist/enableGlRenderStateGuards.js +13 -3
- package/dist/enableGlRenderStateGuards.js.map +1 -1
- package/dist/enableGlRenderTextureGuards.d.ts +2 -1
- package/dist/enableGlRenderTextureGuards.d.ts.map +1 -1
- package/dist/enableGlRenderTextureGuards.js +10 -3
- package/dist/enableGlRenderTextureGuards.js.map +1 -1
- package/dist/enableGlTextureResolverGuards.d.ts +2 -1
- package/dist/enableGlTextureResolverGuards.d.ts.map +1 -1
- package/dist/enableGlTextureResolverGuards.js +2 -2
- package/dist/enableGlTextureResolverGuards.js.map +1 -1
- package/dist/glRenderView.d.ts +3 -2
- package/dist/glRenderView.d.ts.map +1 -1
- package/dist/glRenderView.js.map +1 -1
- package/package.json +12 -12
- package/src/enableGlRenderStateGuards.test.ts +16 -10
- package/src/enableGlRenderTextureGuards.test.ts +3 -3
- package/src/enableGlTextureResolverGuards.test.ts +29 -9
- package/src/glQuadMaterialRegistry.test.ts +3 -3
- package/src/glRenderState.test.ts +30 -8
- package/src/glRenderTexture.test.ts +26 -6
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/render-gl`. The `@fl
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/render-gl@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/render-gl@0.5.1-next.4304.322dc96](https://github.com/flighthq/flight/tree/322dc963fc5a404a31bc0cc612e906de504ea024/packages/render-gl)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/322dc963fc5a404a31bc0cc612e906de504ea024/LICENSE.md)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
1
2
|
import type { GlRenderState } from '@flighthq/types/contract';
|
|
2
3
|
export declare function areGlRenderStateGuardsEnabled(state: GlRenderState): boolean;
|
|
3
|
-
export declare function enableGlRenderStateGuards(state: GlRenderState): void;
|
|
4
|
+
export declare function enableGlRenderStateGuards(state: GlRenderState, logState: LogState | null): void;
|
|
4
5
|
//# sourceMappingURL=enableGlRenderStateGuards.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableGlRenderStateGuards.d.ts","sourceRoot":"","sources":["../src/enableGlRenderStateGuards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enableGlRenderStateGuards.d.ts","sourceRoot":"","sources":["../src/enableGlRenderStateGuards.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,0BAA0B,CAAC;AAKpF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAG3E;AAKD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAO/F"}
|
|
@@ -9,7 +9,8 @@ export function areGlRenderStateGuardsEnabled(state) {
|
|
|
9
9
|
// Installs the GL pipeline-policy guard. A render state derives proxy transforms relative to one root;
|
|
10
10
|
// preparing another root on that state can reuse stale relative transforms. Give each independently
|
|
11
11
|
// rendered root its own createGlRenderState(gl, pipeline) state.
|
|
12
|
-
export function enableGlRenderStateGuards(state) {
|
|
12
|
+
export function enableGlRenderStateGuards(state, logState) {
|
|
13
|
+
_guardLogStates.set(state, logState);
|
|
13
14
|
const runtime = getRenderStateRuntime(state);
|
|
14
15
|
if (runtime.registries.renderRootGuard !== warnOnSecondRenderRoot) {
|
|
15
16
|
runtime.registries.renderRootGuard = warnOnSecondRenderRoot;
|
|
@@ -29,7 +30,11 @@ function warnOnForeignGlBinding(state, expectedProgram) {
|
|
|
29
30
|
const actual = state.gl.getParameter(state.gl.CURRENT_PROGRAM);
|
|
30
31
|
if (actual === expectedProgram)
|
|
31
32
|
return;
|
|
32
|
-
|
|
33
|
+
const logState = _guardLogStates.get(state) ?? null;
|
|
34
|
+
if (logState === null)
|
|
35
|
+
return;
|
|
36
|
+
// The render guards take no clock, so the warning is stamped at time zero.
|
|
37
|
+
logOnce(logState, 0, 'render-gl:foreign-gl-binding', LogLevel.Warn, {
|
|
33
38
|
message: 'useGlProgram: the GL program actually bound is not the one render-gl cached, so a guest renderer ' +
|
|
34
39
|
'wrote GL state without restoring it. Call invalidateGlRenderStateCache(state) before returning ' +
|
|
35
40
|
'control to render-gl, or the next draw skips a bind it needs and GL rejects a later uniform.',
|
|
@@ -45,7 +50,10 @@ function warnOnSecondRenderRoot(state, root) {
|
|
|
45
50
|
}
|
|
46
51
|
if (previous === root)
|
|
47
52
|
return;
|
|
48
|
-
|
|
53
|
+
const logState = _guardLogStates.get(glState) ?? null;
|
|
54
|
+
if (logState === null)
|
|
55
|
+
return;
|
|
56
|
+
logOnce(logState, 0, 'render-gl:multiple-roots-one-state', LogLevel.Warn, {
|
|
49
57
|
firstRoot: previous,
|
|
50
58
|
message: 'prepareScene2DRender: one GlRenderState was used for multiple roots — create a dedicated state with createGlRenderState(gl, pipeline)',
|
|
51
59
|
root,
|
|
@@ -53,4 +61,6 @@ function warnOnSecondRenderRoot(state, root) {
|
|
|
53
61
|
}, 'render-gl');
|
|
54
62
|
}
|
|
55
63
|
const _firstRoots = new WeakMap();
|
|
64
|
+
// The caller-owned log state each render state's guards report to; null installs them silently.
|
|
65
|
+
const _guardLogStates = new WeakMap();
|
|
56
66
|
//# sourceMappingURL=enableGlRenderStateGuards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableGlRenderStateGuards.js","sourceRoot":"","sources":["../src/enableGlRenderStateGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"enableGlRenderStateGuards.js","sourceRoot":"","sources":["../src/enableGlRenderStateGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,UAAU,6BAA6B,CAAC,KAAoB;IAChE,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC;IACtE,OAAO,KAAK,KAAK,sBAAsB,CAAC;AAC1C,CAAC;AAED,uGAAuG;AACvG,oGAAoG;AACpG,iEAAiE;AACjE,MAAM,UAAU,yBAAyB,CAAC,KAAoB,EAAE,QAAyB;IACvF,eAAe,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC7C,IAAI,OAAO,CAAC,UAAU,CAAC,eAAe,KAAK,sBAAsB,EAAE,CAAC;QAClE,OAAO,CAAC,UAAU,CAAC,eAAe,GAAG,sBAAsB,CAAC;IAC9D,CAAC;IACD,uBAAuB,CAAC,KAAK,CAAC,CAAC,iBAAiB,GAAG,sBAAsB,CAAC;AAC5E,CAAC;AAED,oGAAoG;AACpG,qGAAqG;AACrG,wGAAwG;AACxG,mFAAmF;AACnF,EAAE;AACF,oGAAoG;AACpG,qGAAqG;AACrG,uGAAuG;AACvG,uDAAuD;AAC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e,GAAG,IAAI,OAAO,EAAkC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
1
2
|
import type { GlRenderState } from '@flighthq/types/contract';
|
|
2
3
|
export declare function areGlRenderTextureGuardsEnabled(state: GlRenderState): boolean;
|
|
3
|
-
export declare function enableGlRenderTextureGuards(state: GlRenderState): void;
|
|
4
|
+
export declare function enableGlRenderTextureGuards(state: GlRenderState, logState: LogState | null): void;
|
|
4
5
|
//# sourceMappingURL=enableGlRenderTextureGuards.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableGlRenderTextureGuards.d.ts","sourceRoot":"","sources":["../src/enableGlRenderTextureGuards.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,aAAa,EAA6C,MAAM,0BAA0B,CAAC;AAKpH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAM7E;AAID,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"enableGlRenderTextureGuards.d.ts","sourceRoot":"","sources":["../src/enableGlRenderTextureGuards.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAa,aAAa,EAA6C,MAAM,0BAA0B,CAAC;AAKpH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAM7E;AAID,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAIjG"}
|
|
@@ -10,7 +10,8 @@ export function areGlRenderTextureGuardsEnabled(state) {
|
|
|
10
10
|
}
|
|
11
11
|
// Installs diagnostics for the two silent sentinel cases: sampling before the first completed
|
|
12
12
|
// renderInto, and sampling the same attachment while it is bound for writing.
|
|
13
|
-
export function enableGlRenderTextureGuards(state) {
|
|
13
|
+
export function enableGlRenderTextureGuards(state, logState) {
|
|
14
|
+
_guardLogStates.set(state, logState);
|
|
14
15
|
setGlRenderTextureGuard(state, warnGlRenderTextureUnavailable);
|
|
15
16
|
_guardedContexts.add(state.gl);
|
|
16
17
|
}
|
|
@@ -18,9 +19,13 @@ function setGlRenderTextureGuardProbe(state, onEnabled) {
|
|
|
18
19
|
if (_guardedContexts.has(state.gl))
|
|
19
20
|
onEnabled();
|
|
20
21
|
}
|
|
21
|
-
function warnGlRenderTextureUnavailable(
|
|
22
|
+
function warnGlRenderTextureUnavailable(state, renderTexture, explanation) {
|
|
23
|
+
const logState = _guardLogStates.get(state) ?? null;
|
|
24
|
+
if (logState === null)
|
|
25
|
+
return;
|
|
22
26
|
const writing = explanation.status === 'writing';
|
|
23
|
-
|
|
27
|
+
// The render guards take no clock, so the warning is stamped at time zero.
|
|
28
|
+
logOnce(logState, 0, `render-gl:render-texture-${explanation.status}`, LogLevel.Warn, {
|
|
24
29
|
height: explanation.height,
|
|
25
30
|
message: writing
|
|
26
31
|
? 'bindGlRenderTexture: the render Texture is still bound for writing; sampling it would be a read-after-write feedback hazard.'
|
|
@@ -31,4 +36,6 @@ function warnGlRenderTextureUnavailable(_state, renderTexture, explanation) {
|
|
|
31
36
|
}, 'render-gl');
|
|
32
37
|
}
|
|
33
38
|
const _guardedContexts = new WeakSet();
|
|
39
|
+
// The caller-owned log state each render state's guard reports to; null installs it silently.
|
|
40
|
+
const _guardLogStates = new WeakMap();
|
|
34
41
|
//# sourceMappingURL=enableGlRenderTextureGuards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableGlRenderTextureGuards.js","sourceRoot":"","sources":["../src/enableGlRenderTextureGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"enableGlRenderTextureGuards.js","sourceRoot":"","sources":["../src/enableGlRenderTextureGu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d,CAAC,CAAC,8HAA8H;YAChI,CAAC,CAAC,wHAAwH;QAC5H,aAAa;QACb,MAAM,EAAE,WAAW,CAAC,MAAM;QAC1B,KAAK,EAAE,WAAW,CAAC,KAAK;KACzB,EACD,WAAW,CACZ,CAAC;AACJ,CAAC;AAED,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAAa,CAAC;AAClD,8FAA8F;AAC9F,MAAM,eAAe,GAAG,IAAI,OAAO,EAAkC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
1
2
|
import type { GlRenderState } from '@flighthq/types/contract';
|
|
2
3
|
export declare function areGlTextureResolverGuardsEnabled(state: GlRenderState): boolean;
|
|
3
|
-
export declare function enableGlTextureResolverGuards(state: GlRenderState): void;
|
|
4
|
+
export declare function enableGlTextureResolverGuards(state: GlRenderState, logState: LogState | null): void;
|
|
4
5
|
//# sourceMappingURL=enableGlTextureResolverGuards.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableGlTextureResolverGuards.d.ts","sourceRoot":"","sources":["../src/enableGlTextureResolverGuards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enableGlTextureResolverGuards.d.ts","sourceRoot":"","sources":["../src/enableGlTextureResolverGuards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAE/E;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAEnG"}
|
|
@@ -2,7 +2,7 @@ import { areRenderRegistriesGuardsEnabled, enableRenderRegistriesGuards } from '
|
|
|
2
2
|
export function areGlTextureResolverGuardsEnabled(state) {
|
|
3
3
|
return areRenderRegistriesGuardsEnabled(state);
|
|
4
4
|
}
|
|
5
|
-
export function enableGlTextureResolverGuards(state) {
|
|
6
|
-
enableRenderRegistriesGuards(state);
|
|
5
|
+
export function enableGlTextureResolverGuards(state, logState) {
|
|
6
|
+
enableRenderRegistriesGuards(state, logState);
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=enableGlTextureResolverGuards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableGlTextureResolverGuards.js","sourceRoot":"","sources":["../src/enableGlTextureResolverGuards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enableGlTextureResolverGuards.js","sourceRoot":"","sources":["../src/enableGlTextureResolverGuards.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gCAAgC,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAG3G,MAAM,UAAU,iCAAiC,CAAC,KAAoB;IACpE,OAAO,gCAAgC,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,KAAoB,EAAE,QAAyB;IAC3F,4BAA4B,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/glRenderView.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { RenderViewTargetOptions } from '@flighthq/render/contract';
|
|
2
|
+
import type { GlContext, GlRenderStateOptions, GlRenderViewResources } from '@flighthq/types/contract';
|
|
3
|
+
export declare function createGlRenderViewResources(context: GlContext, width: number, height: number, devicePixelRatio: number, options?: Readonly<GlRenderStateOptions>, target?: Readonly<RenderViewTargetOptions>): GlRenderViewResources;
|
|
3
4
|
export declare function destroyGlRenderViewResources(resources: Readonly<GlRenderViewResources>): void;
|
|
4
5
|
export declare function resizeGlRenderViewResources(resources: Readonly<GlRenderViewResources>, width: number, height: number): void;
|
|
5
6
|
//# sourceMappingURL=glRenderView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glRenderView.d.ts","sourceRoot":"","sources":["../src/glRenderView.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"glRenderView.d.ts","sourceRoot":"","sources":["../src/glRenderView.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAgBvG,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,QAAQ,CAAC,oBAAoB,CAAM,EAC5C,MAAM,GAAE,QAAQ,CAAC,uBAAuB,CAAM,GAC7C,qBAAqB,CAMvB;AAID,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAG7F;AAKD,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,QAAQ,CAAC,qBAAqB,CAAC,EAC1C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,IAAI,CAMN"}
|
package/dist/glRenderView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glRenderView.js","sourceRoot":"","sources":["../src/glRenderView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"glRenderView.js","sourceRoot":"","sources":["../src/glRenderView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,cAAc,EAA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AAK,CAAC,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrD,IAAI,SAAS,CAAC,YAAY,CAAC,KAAK,KAAK,YAAY,IAAI,SAAS,CAAC,YAAY,CAAC,MAAM,KAAK,aAAa;QAAE,OAAO;IAC7G,4BAA4B,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACpD,2BAA2B,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAC5F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/render-gl",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.4304.322dc96",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/color": "0.5.1-next.
|
|
42
|
-
"@flighthq/entity": "0.5.1-next.
|
|
43
|
-
"@flighthq/geometry": "0.5.1-next.
|
|
44
|
-
"@flighthq/log": "0.5.1-next.
|
|
45
|
-
"@flighthq/node": "0.5.1-next.
|
|
46
|
-
"@flighthq/registry": "0.5.1-next.
|
|
47
|
-
"@flighthq/render": "0.5.1-next.
|
|
48
|
-
"@flighthq/scene2d": "0.5.1-next.
|
|
49
|
-
"@flighthq/signals": "0.5.1-next.
|
|
50
|
-
"@flighthq/texture": "0.5.1-next.
|
|
51
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/color": "0.5.1-next.4304.322dc96",
|
|
42
|
+
"@flighthq/entity": "0.5.1-next.4304.322dc96",
|
|
43
|
+
"@flighthq/geometry": "0.5.1-next.4304.322dc96",
|
|
44
|
+
"@flighthq/log": "0.5.1-next.4304.322dc96",
|
|
45
|
+
"@flighthq/node": "0.5.1-next.4304.322dc96",
|
|
46
|
+
"@flighthq/registry": "0.5.1-next.4304.322dc96",
|
|
47
|
+
"@flighthq/render": "0.5.1-next.4304.322dc96",
|
|
48
|
+
"@flighthq/scene2d": "0.5.1-next.4304.322dc96",
|
|
49
|
+
"@flighthq/signals": "0.5.1-next.4304.322dc96",
|
|
50
|
+
"@flighthq/texture": "0.5.1-next.4304.322dc96",
|
|
51
|
+
"@flighthq/types": "0.5.1-next.4304.322dc96"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"typescript": "^5.3.0"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createLogState, setLogSink } from '@flighthq/log/contract';
|
|
2
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
2
3
|
import { getRenderStateRuntime } from '@flighthq/render/contract';
|
|
3
4
|
import type { LogEntry } from '@flighthq/types/contract';
|
|
4
5
|
|
|
@@ -7,19 +8,24 @@ import { useGlProgram } from './glDraw.ts';
|
|
|
7
8
|
import { createGlRenderState, getGlRenderStateRuntime } from './glRenderState.ts';
|
|
8
9
|
import { makeGL } from './glTestHelper.ts';
|
|
9
10
|
|
|
11
|
+
// Each test logs into a fresh caller-owned state, so logOnce keys never leak between tests.
|
|
12
|
+
let logState: LogState;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
logState = createLogState();
|
|
16
|
+
});
|
|
17
|
+
|
|
10
18
|
function createState() {
|
|
11
19
|
const canvas = document.createElement('canvas');
|
|
12
20
|
canvas.getContext = vi.fn().mockReturnValue(makeGL()) as typeof canvas.getContext;
|
|
13
21
|
return createGlRenderState(makeGL());
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
beforeEach(() => clearLogOnceKeys());
|
|
17
|
-
|
|
18
24
|
describe('areGlRenderStateGuardsEnabled', () => {
|
|
19
25
|
it('reports whether the state-local multiple-root guard is installed', () => {
|
|
20
26
|
const state = createState();
|
|
21
27
|
expect(areGlRenderStateGuardsEnabled(state)).toBe(false);
|
|
22
|
-
enableGlRenderStateGuards(state);
|
|
28
|
+
enableGlRenderStateGuards(state, logState);
|
|
23
29
|
expect(areGlRenderStateGuardsEnabled(state)).toBe(true);
|
|
24
30
|
});
|
|
25
31
|
});
|
|
@@ -27,23 +33,23 @@ describe('areGlRenderStateGuardsEnabled', () => {
|
|
|
27
33
|
describe('enableGlRenderStateGuards', () => {
|
|
28
34
|
it('installs the state-local multiple-root guard idempotently', () => {
|
|
29
35
|
const state = createState();
|
|
30
|
-
enableGlRenderStateGuards(state);
|
|
36
|
+
enableGlRenderStateGuards(state, logState);
|
|
31
37
|
const guard = getRenderStateRuntime(state).registries.renderRootGuard;
|
|
32
38
|
expect(guard).not.toBeNull();
|
|
33
|
-
enableGlRenderStateGuards(state);
|
|
39
|
+
enableGlRenderStateGuards(state, logState);
|
|
34
40
|
expect(areGlRenderStateGuardsEnabled(state)).toBe(true);
|
|
35
41
|
expect(getRenderStateRuntime(state).registries.renderRootGuard).toBe(guard);
|
|
36
42
|
});
|
|
37
43
|
});
|
|
38
44
|
|
|
39
45
|
describe('foreign GL binding guard', () => {
|
|
40
|
-
afterEach(() => setLogSink(null));
|
|
46
|
+
afterEach(() => setLogSink(logState, null));
|
|
41
47
|
|
|
42
48
|
function messages(entries: LogEntry[]): string {
|
|
43
49
|
return entries.map((e) => String((e.data as { message?: unknown } | undefined)?.message ?? '')).join('\n');
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
// Both directions live in ONE test on purpose: logOnce suppresses a key for the
|
|
52
|
+
// Both directions live in ONE test on purpose: logOnce suppresses a key for the life of its log state, so a
|
|
47
53
|
// separate silence test would pass whether or not the guard checks anything, once the warn test has
|
|
48
54
|
// consumed the key. Silence is asserted FIRST, while the key is still unconsumed.
|
|
49
55
|
//
|
|
@@ -53,9 +59,9 @@ describe('foreign GL binding guard', () => {
|
|
|
53
59
|
// uniform call in render-gl rather than on the renderer that changed the binding.
|
|
54
60
|
it('warns only when the bound program differs from the one render-gl cached', () => {
|
|
55
61
|
const entries: LogEntry[] = [];
|
|
56
|
-
setLogSink((entry) => entries.push(entry));
|
|
62
|
+
setLogSink(logState, (entry) => entries.push(entry));
|
|
57
63
|
const state = createState();
|
|
58
|
-
enableGlRenderStateGuards(state);
|
|
64
|
+
enableGlRenderStateGuards(state, logState);
|
|
59
65
|
const runtime = getGlRenderStateRuntime(state);
|
|
60
66
|
const cached = {} as WebGLProgram;
|
|
61
67
|
|
|
@@ -6,7 +6,7 @@ describe('areGlRenderTextureGuardsEnabled', () => {
|
|
|
6
6
|
const { state } = createGlState();
|
|
7
7
|
expect(areGlRenderTextureGuardsEnabled(state)).toBe(false);
|
|
8
8
|
|
|
9
|
-
enableGlRenderTextureGuards(state);
|
|
9
|
+
enableGlRenderTextureGuards(state, null);
|
|
10
10
|
|
|
11
11
|
expect(areGlRenderTextureGuardsEnabled(state)).toBe(true);
|
|
12
12
|
});
|
|
@@ -15,8 +15,8 @@ describe('areGlRenderTextureGuardsEnabled', () => {
|
|
|
15
15
|
describe('enableGlRenderTextureGuards', () => {
|
|
16
16
|
it('is idempotent', () => {
|
|
17
17
|
const { state } = createGlState();
|
|
18
|
-
enableGlRenderTextureGuards(state);
|
|
19
|
-
enableGlRenderTextureGuards(state);
|
|
18
|
+
enableGlRenderTextureGuards(state, null);
|
|
19
|
+
enableGlRenderTextureGuards(state, null);
|
|
20
20
|
expect(areGlRenderTextureGuardsEnabled(state)).toBe(true);
|
|
21
21
|
});
|
|
22
22
|
});
|
|
@@ -1,17 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
addLogSink,
|
|
3
|
+
createLogState,
|
|
4
|
+
createMemoryLogSink,
|
|
5
|
+
getMemoryLogSinkEntries,
|
|
6
|
+
removeLogSink,
|
|
7
|
+
} from '@flighthq/log/contract';
|
|
8
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
2
9
|
import { createTexture } from '@flighthq/texture/contract';
|
|
3
|
-
import type { ImageResource } from '@flighthq/types/contract';
|
|
10
|
+
import type { ImageResource, LogEntry, MemoryLogSink } from '@flighthq/types/contract';
|
|
4
11
|
|
|
5
12
|
import { areGlTextureResolverGuardsEnabled, enableGlTextureResolverGuards } from './enableGlTextureResolverGuards.ts';
|
|
6
13
|
import { createGlState } from './glTestHelper.ts';
|
|
7
14
|
import { registerGlTextureResolver, resolveGlTexture } from './glTextureResolver.ts';
|
|
8
15
|
|
|
16
|
+
// Each test logs into a fresh caller-owned state, so logOnce keys never leak between tests.
|
|
17
|
+
let logState: LogState;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
logState = createLogState();
|
|
21
|
+
});
|
|
22
|
+
|
|
9
23
|
describe('areGlTextureResolverGuardsEnabled', () => {
|
|
10
24
|
it('reports whether diagnostics were installed for the state', () => {
|
|
11
25
|
const { state } = createGlState();
|
|
12
26
|
expect(areGlTextureResolverGuardsEnabled(state)).toBe(false);
|
|
13
27
|
|
|
14
|
-
enableGlTextureResolverGuards(state);
|
|
28
|
+
enableGlTextureResolverGuards(state, logState);
|
|
15
29
|
expect(areGlTextureResolverGuardsEnabled(state)).toBe(true);
|
|
16
30
|
});
|
|
17
31
|
});
|
|
@@ -19,8 +33,8 @@ describe('areGlTextureResolverGuardsEnabled', () => {
|
|
|
19
33
|
describe('enableGlTextureResolverGuards', () => {
|
|
20
34
|
it('is idempotent', () => {
|
|
21
35
|
const { state } = createGlState();
|
|
22
|
-
enableGlTextureResolverGuards(state);
|
|
23
|
-
enableGlTextureResolverGuards(state);
|
|
36
|
+
enableGlTextureResolverGuards(state, logState);
|
|
37
|
+
enableGlTextureResolverGuards(state, logState);
|
|
24
38
|
expect(areGlTextureResolverGuardsEnabled(state)).toBe(true);
|
|
25
39
|
});
|
|
26
40
|
|
|
@@ -29,15 +43,15 @@ describe('enableGlTextureResolverGuards', () => {
|
|
|
29
43
|
const missing = textureWithKind('acme.missing.gl');
|
|
30
44
|
const registered = textureWithKind('acme.registered.gl');
|
|
31
45
|
const sink = createMemoryLogSink(4);
|
|
32
|
-
addLogSink(sink.sink);
|
|
33
|
-
enableGlTextureResolverGuards(state);
|
|
46
|
+
addLogSink(logState, sink.sink);
|
|
47
|
+
enableGlTextureResolverGuards(state, logState);
|
|
34
48
|
registerGlTextureResolver(state, 'acme.registered.gl', () => null);
|
|
35
49
|
try {
|
|
36
50
|
expect(resolveGlTexture(state, missing)).toBeNull();
|
|
37
51
|
expect(resolveGlTexture(state, missing)).toBeNull();
|
|
38
52
|
expect(resolveGlTexture(state, registered)).toBeNull();
|
|
39
53
|
|
|
40
|
-
const entries =
|
|
54
|
+
const entries = readMemoryLogEntries(sink);
|
|
41
55
|
expect(entries).toHaveLength(1);
|
|
42
56
|
expect(entries[0]?.data).toMatchObject({
|
|
43
57
|
kind: 'acme.missing.gl',
|
|
@@ -45,7 +59,7 @@ describe('enableGlTextureResolverGuards', () => {
|
|
|
45
59
|
'resolveGlTexture: texture source kind has no registered resolver — rebuild the GlRenderRegistries with the required resolver and create the render state from that registry',
|
|
46
60
|
});
|
|
47
61
|
} finally {
|
|
48
|
-
removeLogSink(sink.sink);
|
|
62
|
+
removeLogSink(logState, sink.sink);
|
|
49
63
|
}
|
|
50
64
|
});
|
|
51
65
|
});
|
|
@@ -56,3 +70,9 @@ function textureWithKind(kind: string) {
|
|
|
56
70
|
source: { kind } as ImageResource,
|
|
57
71
|
});
|
|
58
72
|
}
|
|
73
|
+
|
|
74
|
+
function readMemoryLogEntries(handle: Readonly<MemoryLogSink>): LogEntry[] {
|
|
75
|
+
const entries: LogEntry[] = [];
|
|
76
|
+
getMemoryLogSinkEntries(entries, handle);
|
|
77
|
+
return entries;
|
|
78
|
+
}
|
|
@@ -69,7 +69,7 @@ describe('resolveGlQuadMaterialRenderer', () => {
|
|
|
69
69
|
|
|
70
70
|
it('reports the missing kind, so an unresolved material is not an invisible node with clean logs', () => {
|
|
71
71
|
const { state } = createGlState();
|
|
72
|
-
enableRenderRegistriesGuards(state);
|
|
72
|
+
enableRenderRegistriesGuards(state, null);
|
|
73
73
|
|
|
74
74
|
resolveGlQuadMaterialRenderer(state, makeMaterial(TestKind));
|
|
75
75
|
resolveGlQuadMaterialRenderer(state, null);
|
|
@@ -85,7 +85,7 @@ describe('resolveGlQuadMaterialRenderer', () => {
|
|
|
85
85
|
|
|
86
86
|
it('reports a kind that StandardMaterialKind silently stood in for', () => {
|
|
87
87
|
const { state } = createGlState();
|
|
88
|
-
enableRenderRegistriesGuards(state);
|
|
88
|
+
enableRenderRegistriesGuards(state, null);
|
|
89
89
|
registerGlQuadMaterialRenderer(state, StandardMaterialKind, testRenderer);
|
|
90
90
|
|
|
91
91
|
// Substituting a different shading family draws something, but not what was asked for, so it is
|
|
@@ -99,7 +99,7 @@ describe('resolveGlQuadMaterialRenderer', () => {
|
|
|
99
99
|
|
|
100
100
|
it('records nothing once the kind resolves', () => {
|
|
101
101
|
const { state } = createGlState();
|
|
102
|
-
enableRenderRegistriesGuards(state);
|
|
102
|
+
enableRenderRegistriesGuards(state, null);
|
|
103
103
|
registerGlQuadMaterialRenderer(state, TestKind, testRenderer);
|
|
104
104
|
|
|
105
105
|
resolveGlQuadMaterialRenderer(state, makeMaterial(TestKind));
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
addLogSink,
|
|
4
|
+
createLogState,
|
|
5
|
+
createMemoryLogSink,
|
|
6
|
+
getMemoryLogSinkEntries,
|
|
7
|
+
removeLogSink,
|
|
8
|
+
} from '@flighthq/log/contract';
|
|
9
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
3
10
|
import { withKindMapEntry } from '@flighthq/registry/contract';
|
|
4
11
|
import {
|
|
5
12
|
enableColorAdjustmentGuards,
|
|
@@ -11,11 +18,13 @@ import {
|
|
|
11
18
|
} from '@flighthq/render/contract';
|
|
12
19
|
import { createDisplayObject } from '@flighthq/scene2d/contract';
|
|
13
20
|
import type {
|
|
21
|
+
EffectPaddingResolver,
|
|
14
22
|
GlBitmapShader,
|
|
15
23
|
GlColorAdjustmentMaterialFeature,
|
|
16
24
|
GlColorAdjustmentMaterialFeatureGuard,
|
|
17
25
|
GlRenderStateOptions,
|
|
18
|
-
|
|
26
|
+
LogEntry,
|
|
27
|
+
MemoryLogSink,
|
|
19
28
|
RenderState,
|
|
20
29
|
} from '@flighthq/types/contract';
|
|
21
30
|
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
@@ -43,6 +52,13 @@ import { ensureDefaultGlBitmapShader } from './glShader.ts';
|
|
|
43
52
|
import { makeGL } from './glTestHelper.ts';
|
|
44
53
|
import { registerGlTextureResolver } from './glTextureResolver.ts';
|
|
45
54
|
|
|
55
|
+
// Each test logs into a fresh caller-owned state, so logOnce keys never leak between tests.
|
|
56
|
+
let logState: LogState;
|
|
57
|
+
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
logState = createLogState();
|
|
60
|
+
});
|
|
61
|
+
|
|
46
62
|
function makeContext() {
|
|
47
63
|
return { gl: makeGL() };
|
|
48
64
|
}
|
|
@@ -280,8 +296,8 @@ describe('createGlRenderState (context sharing)', () => {
|
|
|
280
296
|
registerGlQuadMaterialRenderer(screen, 'acme.Material', materialRenderer);
|
|
281
297
|
registerGlTextureResolver(screen, 'acme.Texture', textureResolver);
|
|
282
298
|
enableColorAdjustments(screen);
|
|
283
|
-
enableColorAdjustmentGuards(screen);
|
|
284
|
-
enableGlRenderStateGuards(screen);
|
|
299
|
+
enableColorAdjustmentGuards(screen, logState);
|
|
300
|
+
enableGlRenderStateGuards(screen, logState);
|
|
285
301
|
getGlRenderStateRuntime(screen).registries.effects = withKindMapEntry(
|
|
286
302
|
getGlRenderStateRuntime(screen).registries.effects,
|
|
287
303
|
'acme.Effect',
|
|
@@ -540,16 +556,16 @@ describe('enableGlRenderStateGuards', () => {
|
|
|
540
556
|
const { gl } = makeContext();
|
|
541
557
|
const state = createTestGlRenderState(gl);
|
|
542
558
|
const sink = createMemoryLogSink(4);
|
|
543
|
-
addLogSink(sink.sink);
|
|
544
|
-
enableGlRenderStateGuards(state);
|
|
559
|
+
addLogSink(logState, sink.sink);
|
|
560
|
+
enableGlRenderStateGuards(state, logState);
|
|
545
561
|
try {
|
|
546
562
|
prepareScene2DRender(state, createDisplayObject());
|
|
547
563
|
prepareScene2DRender(state, createDisplayObject());
|
|
548
|
-
const entries =
|
|
564
|
+
const entries = readMemoryLogEntries(sink);
|
|
549
565
|
expect(entries).toHaveLength(1);
|
|
550
566
|
expect((entries[0].data as { message: string }).message).toContain('createGlRenderState');
|
|
551
567
|
} finally {
|
|
552
|
-
removeLogSink(sink.sink);
|
|
568
|
+
removeLogSink(logState, sink.sink);
|
|
553
569
|
}
|
|
554
570
|
});
|
|
555
571
|
});
|
|
@@ -743,3 +759,9 @@ describe('registerGlRenderStateTeardown', () => {
|
|
|
743
759
|
expect(teardown).toHaveBeenCalledWith(state);
|
|
744
760
|
});
|
|
745
761
|
});
|
|
762
|
+
|
|
763
|
+
function readMemoryLogEntries(handle: Readonly<MemoryLogSink>): LogEntry[] {
|
|
764
|
+
const entries: LogEntry[] = [];
|
|
765
|
+
getMemoryLogSinkEntries(entries, handle);
|
|
766
|
+
return entries;
|
|
767
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
addLogSink,
|
|
3
|
+
createLogState,
|
|
4
|
+
createMemoryLogSink,
|
|
5
|
+
getMemoryLogSinkEntries,
|
|
6
|
+
removeLogSink,
|
|
7
|
+
} from '@flighthq/log/contract';
|
|
8
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
9
|
+
import type { LogEntry, MemoryLogSink, RenderTargetClear, RenderTexture } from '@flighthq/types/contract';
|
|
3
10
|
import { RenderTargetTextureSourceKind } from '@flighthq/types/contract';
|
|
4
11
|
|
|
5
12
|
import { enableGlRenderTextureGuards } from './enableGlRenderTextureGuards.ts';
|
|
@@ -19,6 +26,13 @@ import {
|
|
|
19
26
|
} from './glRenderTexture.ts';
|
|
20
27
|
import { createGlState } from './glTestHelper.ts';
|
|
21
28
|
|
|
29
|
+
// Each test logs into a fresh caller-owned state, so logOnce keys never leak between tests.
|
|
30
|
+
let logState: LogState;
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
logState = createLogState();
|
|
34
|
+
});
|
|
35
|
+
|
|
22
36
|
describe('bindGlRenderTexture', () => {
|
|
23
37
|
it('binds the existing target texture without uploading pixels', () => {
|
|
24
38
|
const { state, gl } = createRenderTextureState();
|
|
@@ -72,8 +86,8 @@ describe('enableGlRenderTextureGuards', () => {
|
|
|
72
86
|
const unrendered = createRenderTexture({ height: 8, width: 8 });
|
|
73
87
|
const writing = createRenderTexture({ height: 8, width: 8 });
|
|
74
88
|
const sink = createMemoryLogSink(8);
|
|
75
|
-
addLogSink(sink.sink);
|
|
76
|
-
enableGlRenderTextureGuards(state);
|
|
89
|
+
addLogSink(logState, sink.sink);
|
|
90
|
+
enableGlRenderTextureGuards(state, logState);
|
|
77
91
|
try {
|
|
78
92
|
bindGlRenderTexture(state, unrendered);
|
|
79
93
|
renderIntoGlRenderTexture(
|
|
@@ -85,11 +99,11 @@ describe('enableGlRenderTextureGuards', () => {
|
|
|
85
99
|
TRANSPARENT_CLEAR,
|
|
86
100
|
);
|
|
87
101
|
|
|
88
|
-
const entries =
|
|
102
|
+
const entries = readMemoryLogEntries(sink);
|
|
89
103
|
expect(entries).toHaveLength(2);
|
|
90
104
|
expect(entries.map((entry) => (entry.data as { status: string }).status)).toEqual(['unrendered', 'writing']);
|
|
91
105
|
} finally {
|
|
92
|
-
removeLogSink(sink.sink);
|
|
106
|
+
removeLogSink(logState, sink.sink);
|
|
93
107
|
}
|
|
94
108
|
});
|
|
95
109
|
});
|
|
@@ -351,3 +365,9 @@ function createRenderTexture(options: { depth?: boolean; height: number; width:
|
|
|
351
365
|
}
|
|
352
366
|
|
|
353
367
|
const TRANSPARENT_CLEAR: Readonly<RenderTargetClear> = { color: [0, 0, 0, 0], depth: 1.0, stencil: 0 };
|
|
368
|
+
|
|
369
|
+
function readMemoryLogEntries(handle: Readonly<MemoryLogSink>): LogEntry[] {
|
|
370
|
+
const entries: LogEntry[] = [];
|
|
371
|
+
getMemoryLogSinkEntries(entries, handle);
|
|
372
|
+
return entries;
|
|
373
|
+
}
|