@flighthq/render-gl 0.3.0-next.1032.e2b99fc → 0.3.0-next.1220.6982c21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract.d.ts +4 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -0
- package/dist/contract.js.map +1 -1
- package/dist/enableGlRenderStateGuards.d.ts +4 -0
- package/dist/enableGlRenderStateGuards.d.ts.map +1 -0
- package/dist/enableGlRenderStateGuards.js +30 -0
- package/dist/enableGlRenderStateGuards.js.map +1 -0
- package/dist/enableGlTextureResolverGuards.d.ts +4 -0
- package/dist/enableGlTextureResolverGuards.d.ts.map +1 -0
- package/dist/enableGlTextureResolverGuards.js +8 -0
- package/dist/enableGlTextureResolverGuards.js.map +1 -0
- package/dist/explainGlTextureResolution.d.ts +3 -0
- package/dist/explainGlTextureResolution.d.ts.map +1 -0
- package/dist/explainGlTextureResolution.js +12 -0
- package/dist/explainGlTextureResolution.js.map +1 -0
- package/dist/glCompressedTexture.js +1 -1
- package/dist/glCompressedTexture.js.map +1 -1
- package/dist/glDraw.d.ts +2 -2
- package/dist/glDraw.d.ts.map +1 -1
- package/dist/glDraw.js +17 -14
- package/dist/glDraw.js.map +1 -1
- package/dist/glExternalTexture.d.ts.map +1 -1
- package/dist/glExternalTexture.js +23 -18
- package/dist/glExternalTexture.js.map +1 -1
- package/dist/glFullscreenPass.js +3 -4
- package/dist/glFullscreenPass.js.map +1 -1
- package/dist/glLinearToSrgbPass.js +3 -3
- package/dist/glLinearToSrgbPass.js.map +1 -1
- package/dist/glPresentRenderTarget.js +3 -3
- package/dist/glPresentRenderTarget.js.map +1 -1
- package/dist/glRenderPass.d.ts.map +1 -1
- package/dist/glRenderPass.js +82 -36
- package/dist/glRenderPass.js.map +1 -1
- package/dist/glRenderState.d.ts +11 -1
- package/dist/glRenderState.d.ts.map +1 -1
- package/dist/glRenderState.js +180 -5
- package/dist/glRenderState.js.map +1 -1
- package/dist/glRenderStateBracket.d.ts.map +1 -1
- package/dist/glRenderStateBracket.js +16 -4
- package/dist/glRenderStateBracket.js.map +1 -1
- package/dist/glRenderTarget.d.ts +10 -1
- package/dist/glRenderTarget.d.ts.map +1 -1
- package/dist/glRenderTarget.js +129 -60
- package/dist/glRenderTarget.js.map +1 -1
- package/dist/glRenderTargetPool.d.ts +4 -1
- package/dist/glRenderTargetPool.d.ts.map +1 -1
- package/dist/glRenderTargetPool.js +32 -23
- package/dist/glRenderTargetPool.js.map +1 -1
- package/dist/glRenderTexture.d.ts +4 -1
- package/dist/glRenderTexture.d.ts.map +1 -1
- package/dist/glRenderTexture.js +75 -17
- package/dist/glRenderTexture.js.map +1 -1
- package/dist/glRenderTexturePool.d.ts +7 -0
- package/dist/glRenderTexturePool.d.ts.map +1 -0
- package/dist/glRenderTexturePool.js +87 -0
- package/dist/glRenderTexturePool.js.map +1 -0
- package/dist/glTestHelper.js +2 -2
- package/dist/glTestHelper.js.map +1 -1
- package/dist/glTextureResolver.d.ts +3 -3
- package/dist/glTextureResolver.d.ts.map +1 -1
- package/dist/glTextureResolver.js +32 -31
- package/dist/glTextureResolver.js.map +1 -1
- package/dist/glTextureUpload.d.ts +2 -2
- package/dist/glTextureUpload.d.ts.map +1 -1
- package/dist/glTextureUpload.js +1 -1
- package/dist/glTextureUpload.js.map +1 -1
- package/dist/glTextureVideoUpload.d.ts +2 -2
- package/dist/glTextureVideoUpload.d.ts.map +1 -1
- package/dist/glTextureVideoUpload.js +3 -3
- package/dist/glTextureVideoUpload.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 +9 -7
- package/src/enableGlRenderStateGuards.test.ts +27 -0
- package/src/enableGlTextureResolverGuards.test.ts +58 -0
- package/src/explainGlTextureResolution.test.ts +32 -0
- package/src/glCompressedTexture.test.ts +2 -2
- package/src/glDraw.test.ts +17 -18
- package/src/glExternalTexture.test.ts +3 -3
- package/src/glFullscreenPass.test.ts +13 -0
- package/src/glLinearToSrgbPass.test.ts +13 -0
- package/src/glPresentRenderTarget.test.ts +15 -1
- package/src/glReadback.test.ts +13 -0
- package/src/glRenderPass.test.ts +63 -0
- package/src/glRenderState.test.ts +135 -0
- package/src/glRenderStateBracket.test.ts +31 -1
- package/src/glRenderTarget.test.ts +186 -3
- package/src/glRenderTargetPool.test.ts +110 -5
- package/src/glRenderTexture.test.ts +71 -11
- package/src/glRenderTexturePool.test.ts +112 -0
- package/src/glTextureResolver.test.ts +73 -51
- package/src/glTextureUpload.test.ts +2 -2
- package/src/glTextureVideoUpload.test.ts +5 -5
package/dist/glRenderTexture.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveRenderTargetDescriptor } from '@flighthq/render/contract';
|
|
1
2
|
import { applyGlSamplerState } from './glDraw';
|
|
2
3
|
import { beginGlRenderPass, endGlRenderPass } from './glRenderPass';
|
|
3
4
|
import { getGlRenderStateRuntime } from './glRenderState';
|
|
@@ -34,7 +35,7 @@ export function destroyGlRenderTexture(state, renderTexture) {
|
|
|
34
35
|
}
|
|
35
36
|
export function explainGlRenderTexture(state, renderTexture) {
|
|
36
37
|
const entry = getEntry(state, renderTexture);
|
|
37
|
-
const descriptor = renderTexture.
|
|
38
|
+
const descriptor = renderTexture.source;
|
|
38
39
|
return {
|
|
39
40
|
height: entry?.target.height ?? descriptor?.height ?? 0,
|
|
40
41
|
status: entry?.status ?? 'unrendered',
|
|
@@ -44,6 +45,20 @@ export function explainGlRenderTexture(state, renderTexture) {
|
|
|
44
45
|
export function getGlRenderTextureColorSpace(state, renderTexture) {
|
|
45
46
|
return getEntry(state, renderTexture)?.target.colorSpace ?? renderTexture.colorSpace;
|
|
46
47
|
}
|
|
48
|
+
// Resolves the hidden target only while the handle owns completed content. This is the backend bridge
|
|
49
|
+
// used by target-to-target effect wrappers; app-level composition keeps using RenderTexture.
|
|
50
|
+
export function getGlRenderTextureTarget(state, renderTexture) {
|
|
51
|
+
const entry = getEntry(state, renderTexture);
|
|
52
|
+
if (entry?.status === 'ready')
|
|
53
|
+
return entry.target;
|
|
54
|
+
notifyGuard(state, renderTexture);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
export function invalidateGlRenderTexture(state, renderTexture, status = 'unrendered') {
|
|
58
|
+
const entry = getEntry(state, renderTexture);
|
|
59
|
+
if (entry !== undefined)
|
|
60
|
+
entry.status = status;
|
|
61
|
+
}
|
|
47
62
|
export function isGlRenderTextureReady(state, renderTexture) {
|
|
48
63
|
const ready = getEntry(state, renderTexture)?.status === 'ready';
|
|
49
64
|
if (!ready)
|
|
@@ -55,34 +70,47 @@ export function isGlRenderTextureReady(state, renderTexture) {
|
|
|
55
70
|
* rendering commands; framebuffer and fixed-function state are restored even when it throws.
|
|
56
71
|
*/
|
|
57
72
|
export function renderIntoGlRenderTexture(state, renderTexture, callback) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
let rendered = false;
|
|
61
|
-
pushGlRenderState(state);
|
|
62
|
-
try {
|
|
63
|
-
beginGlRenderPass(state, entry.target);
|
|
73
|
+
writeGlRenderTextureTarget(state, renderTexture, (target) => {
|
|
74
|
+
pushGlRenderState(state);
|
|
64
75
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
beginGlRenderPass(state, target);
|
|
77
|
+
try {
|
|
78
|
+
callback(state);
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
endGlRenderPass(state);
|
|
82
|
+
}
|
|
67
83
|
}
|
|
68
84
|
finally {
|
|
69
|
-
|
|
85
|
+
popGlRenderState(state);
|
|
70
86
|
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export function setGlRenderTextureGuard(state, guard) {
|
|
90
|
+
getGlRenderStateRuntime(state).glRenderTextureGuard = guard;
|
|
91
|
+
}
|
|
92
|
+
// Gives a backend recipe the hidden destination without opening a pass. The recipe may run several
|
|
93
|
+
// target passes; success atomically publishes the RenderTexture, while failure invalidates it.
|
|
94
|
+
export function writeGlRenderTextureTarget(state, renderTexture, callback) {
|
|
95
|
+
const entry = ensureEntry(state, renderTexture);
|
|
96
|
+
const previousStatus = entry.status;
|
|
97
|
+
entry.status = 'writing';
|
|
98
|
+
let rendered = false;
|
|
99
|
+
try {
|
|
100
|
+
const result = callback(entry.target);
|
|
101
|
+
rendered = true;
|
|
102
|
+
return result;
|
|
71
103
|
}
|
|
72
104
|
finally {
|
|
73
|
-
|
|
74
|
-
entry.status = rendered ? 'ready' : 'unrendered';
|
|
105
|
+
entry.status = rendered ? 'ready' : previousStatus === 'writing' ? 'writing' : 'unrendered';
|
|
75
106
|
if (rendered) {
|
|
76
107
|
renderTexture.colorSpace = entry.target.colorSpace;
|
|
77
108
|
renderTexture.version = (renderTexture.version + 1) >>> 0;
|
|
78
109
|
}
|
|
79
110
|
}
|
|
80
111
|
}
|
|
81
|
-
export function setGlRenderTextureGuard(state, guard) {
|
|
82
|
-
getGlRenderStateRuntime(state).glRenderTextureGuard = guard;
|
|
83
|
-
}
|
|
84
112
|
function ensureEntry(state, renderTexture) {
|
|
85
|
-
const descriptor = renderTexture.
|
|
113
|
+
const descriptor = renderTexture.source;
|
|
86
114
|
const entries = getEntries(state);
|
|
87
115
|
let entry = entries.get(renderTexture);
|
|
88
116
|
if (entry === undefined) {
|
|
@@ -93,10 +121,40 @@ function ensureEntry(state, renderTexture) {
|
|
|
93
121
|
entries.set(renderTexture, entry);
|
|
94
122
|
}
|
|
95
123
|
else {
|
|
96
|
-
|
|
124
|
+
const requested = resolveRenderTargetDescriptor(descriptor);
|
|
125
|
+
if (matchesGlRenderTextureAllocation(entry.target, requested)) {
|
|
126
|
+
resizeGlRenderTarget(state, entry.target, descriptor.width, descriptor.height);
|
|
127
|
+
entry.target.requestedAxes = {
|
|
128
|
+
width: requested.width,
|
|
129
|
+
height: requested.height,
|
|
130
|
+
format: requested.format,
|
|
131
|
+
colorAttachments: requested.colorAttachments,
|
|
132
|
+
colorFormats: [...requested.colorFormats],
|
|
133
|
+
sampleCount: requested.sampleCount,
|
|
134
|
+
depth: requested.depth,
|
|
135
|
+
colorSpace: requested.colorSpace,
|
|
136
|
+
};
|
|
137
|
+
entry.target.clearColors = [...requested.clearColors];
|
|
138
|
+
entry.target.clearDepth = requested.clearDepth;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
destroyGlRenderTarget(state, entry.target);
|
|
142
|
+
entry.target = createGlRenderTarget(state, descriptor);
|
|
143
|
+
entry.status = 'unrendered';
|
|
144
|
+
}
|
|
97
145
|
}
|
|
98
146
|
return entry;
|
|
99
147
|
}
|
|
148
|
+
function matchesGlRenderTextureAllocation(target, descriptor) {
|
|
149
|
+
const requested = target.requestedAxes;
|
|
150
|
+
return (requested.format === descriptor.format &&
|
|
151
|
+
requested.colorAttachments === descriptor.colorAttachments &&
|
|
152
|
+
requested.colorFormats.length === descriptor.colorFormats.length &&
|
|
153
|
+
requested.colorFormats.every((format, index) => format === descriptor.colorFormats[index]) &&
|
|
154
|
+
requested.sampleCount === descriptor.sampleCount &&
|
|
155
|
+
requested.depth === descriptor.depth &&
|
|
156
|
+
requested.colorSpace === descriptor.colorSpace);
|
|
157
|
+
}
|
|
100
158
|
function getEntries(state) {
|
|
101
159
|
return (getGlRenderStateRuntime(state).glRenderTextureCache ??= new WeakMap());
|
|
102
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glRenderTexture.js","sourceRoot":"","sources":["../src/glRenderTexture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"glRenderTexture.js","sourceRoot":"","sources":["../src/glRenderTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAW1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO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M;QAChE,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,KAAK,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC1F,SAAS,CAAC,WAAW,KAAK,UAAU,CAAC,WAAW;QAChD,SAAS,CAAC,KAAK,KAAK,UAAU,CAAC,KAAK;QACpC,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC,UAAU,CAC/C,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAAoB;IACtC,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,oBAAoB,KAAK,IAAI,OAAO,EAAE,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,QAAQ,CAAC,KAAoB,EAAE,aAAsC;IAC5E,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC,oBAAoB,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,WAAW,CAAC,KAAoB,EAAE,aAAsC;IAC/E,uBAAuB,CAAC,KAAK,CAAC,CAAC,oBAAoB,EAAE,CACnD,KAAK,EACL,aAAa,EACb,sBAAsB,CAAC,KAAK,EAAE,aAAa,CAAC,CAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GlRenderState, GlRenderTexturePool, RenderTargetDescriptor, RenderTexture } from '@flighthq/types/contract';
|
|
2
|
+
export declare function acquireGlRenderTexture(state: GlRenderState, pool: GlRenderTexturePool, descriptor: Readonly<RenderTargetDescriptor>): RenderTexture;
|
|
3
|
+
export declare function createGlRenderTexturePool(): GlRenderTexturePool;
|
|
4
|
+
export declare function destroyGlRenderTexturePool(state: GlRenderState, pool: GlRenderTexturePool): void;
|
|
5
|
+
export declare function releaseGlRenderTexture(state: GlRenderState, pool: GlRenderTexturePool, renderTexture: RenderTexture): void;
|
|
6
|
+
export declare function withGlRenderTextures<T>(state: GlRenderState, pool: GlRenderTexturePool, descriptors: ReadonlyArray<Readonly<RenderTargetDescriptor>>, callback: (textures: ReadonlyArray<RenderTexture>) => T): T;
|
|
7
|
+
//# sourceMappingURL=glRenderTexturePool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glRenderTexturePool.d.ts","sourceRoot":"","sources":["../src/glRenderTexturePool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EAEnB,sBAAsB,EACtB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAKlC,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,mBAAmB,EACzB,UAAU,EAAE,QAAQ,CAAC,sBAAsB,CAAC,GAC3C,aAAa,CAQf;AAED,wBAAgB,yBAAyB,IAAI,mBAAmB,CAQ/D;AAID,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAShG;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,mBAAmB,EACzB,aAAa,EAAE,aAAa,GAC3B,IAAI,CAON;AAID,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,mBAAmB,EACzB,WAAW,EAAE,aAAa,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC,EAC5D,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,GACtD,CAAC,CAWH"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createRenderTexture } from '@flighthq/texture/contract';
|
|
2
|
+
import { createGlRenderTargetPool, destroyGlRenderTargetPool } from './glRenderTargetPool';
|
|
3
|
+
import { destroyGlRenderTexture, invalidateGlRenderTexture } from './glRenderTexture';
|
|
4
|
+
export function acquireGlRenderTexture(state, pool, descriptor) {
|
|
5
|
+
assertUsablePool(state, pool);
|
|
6
|
+
const renderTexture = pool.free.pop() ?? createRenderTexture(descriptor);
|
|
7
|
+
applyRenderTargetDescriptor(renderTexture.source, descriptor);
|
|
8
|
+
renderTexture.colorSpace = descriptor.colorSpace ?? 'srgb';
|
|
9
|
+
invalidateGlRenderTexture(state, renderTexture);
|
|
10
|
+
pool.leased.add(renderTexture);
|
|
11
|
+
return renderTexture;
|
|
12
|
+
}
|
|
13
|
+
export function createGlRenderTexturePool() {
|
|
14
|
+
return {
|
|
15
|
+
context: null,
|
|
16
|
+
destroyed: false,
|
|
17
|
+
effectTargets: createGlRenderTargetPool(),
|
|
18
|
+
free: [],
|
|
19
|
+
leased: new Set(),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Destroys free and currently leased handles. A shutdown caller need not recover every outstanding
|
|
23
|
+
// display lease first; after this call the pool cannot be acquired again.
|
|
24
|
+
export function destroyGlRenderTexturePool(state, pool) {
|
|
25
|
+
if (pool.destroyed)
|
|
26
|
+
return;
|
|
27
|
+
assertPoolContext(state, pool);
|
|
28
|
+
const textures = new Set([...pool.free, ...pool.leased]);
|
|
29
|
+
for (const renderTexture of textures)
|
|
30
|
+
destroyGlRenderTexture(state, renderTexture);
|
|
31
|
+
pool.free.length = 0;
|
|
32
|
+
pool.leased.clear();
|
|
33
|
+
destroyGlRenderTargetPool(state, pool.effectTargets);
|
|
34
|
+
pool.destroyed = true;
|
|
35
|
+
}
|
|
36
|
+
export function releaseGlRenderTexture(state, pool, renderTexture) {
|
|
37
|
+
assertUsablePool(state, pool);
|
|
38
|
+
if (!pool.leased.delete(renderTexture)) {
|
|
39
|
+
throw new Error('releaseGlRenderTexture: texture is not leased from this pool');
|
|
40
|
+
}
|
|
41
|
+
invalidateGlRenderTexture(state, renderTexture, 'released');
|
|
42
|
+
pool.free.push(renderTexture);
|
|
43
|
+
}
|
|
44
|
+
// Exception-safe bracket for source/scratch/result sets whose ownership ends together. A result shown
|
|
45
|
+
// by Sprite must instead remain manually leased until that frame's consumer is finished.
|
|
46
|
+
export function withGlRenderTextures(state, pool, descriptors, callback) {
|
|
47
|
+
const textures = [];
|
|
48
|
+
try {
|
|
49
|
+
for (const descriptor of descriptors)
|
|
50
|
+
textures.push(acquireGlRenderTexture(state, pool, descriptor));
|
|
51
|
+
return callback(textures);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
for (let i = textures.length - 1; i >= 0; i--) {
|
|
55
|
+
const texture = textures[i];
|
|
56
|
+
if (pool.leased.has(texture))
|
|
57
|
+
releaseGlRenderTexture(state, pool, texture);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function applyRenderTargetDescriptor(target, descriptor) {
|
|
62
|
+
target.width = descriptor.width;
|
|
63
|
+
target.height = descriptor.height;
|
|
64
|
+
target.format = descriptor.format;
|
|
65
|
+
target.colorAttachments = descriptor.colorAttachments;
|
|
66
|
+
target.colorFormats = descriptor.colorFormats === undefined ? undefined : [...descriptor.colorFormats];
|
|
67
|
+
target.sampleCount = descriptor.sampleCount;
|
|
68
|
+
target.depth = descriptor.depth;
|
|
69
|
+
target.colorSpace = descriptor.colorSpace ?? 'srgb';
|
|
70
|
+
target.clearColors = descriptor.clearColors === undefined ? undefined : [...descriptor.clearColors];
|
|
71
|
+
target.clearDepth = descriptor.clearDepth;
|
|
72
|
+
target.version = (target.version + 1) >>> 0;
|
|
73
|
+
}
|
|
74
|
+
function assertUsablePool(state, pool) {
|
|
75
|
+
if (pool.destroyed)
|
|
76
|
+
throw new Error('GlRenderTexturePool has been destroyed');
|
|
77
|
+
assertPoolContext(state, pool);
|
|
78
|
+
}
|
|
79
|
+
function assertPoolContext(state, pool) {
|
|
80
|
+
if (pool.context === null) {
|
|
81
|
+
pool.context = state.gl;
|
|
82
|
+
}
|
|
83
|
+
else if (pool.context !== state.gl) {
|
|
84
|
+
throw new Error('GlRenderTexturePool cannot cross WebGL contexts');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=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K,CAAC,wCAAwC,CAAC,CAAC;IAC9E,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAoB,EAAE,IAAyB;IACxE,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC;IAC1B,CAAC;SAAM,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;AACH,CAAC"}
|
package/dist/glTestHelper.js
CHANGED
|
@@ -31,8 +31,8 @@ export function createGlState(options) {
|
|
|
31
31
|
flushPendingDraws: null,
|
|
32
32
|
renderTargetViewport: null,
|
|
33
33
|
textureCache: new WeakMap(),
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
textureSourcePremultipliedTextureCache: new WeakMap(),
|
|
35
|
+
textureSourceStraightTextureCache: new WeakMap(),
|
|
36
36
|
shaderLoc,
|
|
37
37
|
defaultBitmapShader: { locations: shaderLoc, program: shaderLoc.program, bind: vi.fn() },
|
|
38
38
|
quadVertexBuffer: {},
|
package/dist/glTestHelper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTestHelper.js","sourceRoot":"","sources":["../src/glTestHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,UAAU,aAAa,CAAC,OAAsE;IAMlG,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;IACnB,MAAM,CAAC,MAAM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AChB,SAAS,EAAE,EAAE;QACb,wBAAwB,EAAE,IAAI;QAC9B,oBAAoB,EAAE,CAAC;QACvB,6BAA6B,EAAE,IAAI;QACnC,2BAA2B,EAAE,IAAI,YAAY,CAAC,EAAE,GAAG,GAAG,CAAC;QACvD,sBAAsB,EAAE,IAAI;QAC5B,sBAAsB,EAAE,IAAI;QAC5B,4BAA4B,EAAE,KAAK;QACnC,wBAAwB,EAAE,IAAI;KACS,CAAC,CAAC;IAC3C,KAAK,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC;IAElC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC1C,CAAC;AAED,6EAA6E;AAC7E,uEAAuE;AACvE,mFAAmF;AACnF,MAAM,UAAU,MAAM;IACpB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAA2B,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,OAAO,EAAE,EAAkB;QAC3B,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,EAA0B;QACrC,QAAQ,EAAE,EAA0B;QACpC,aAAa,EAAE,EAA0B;QACzC,YAAY,EAAE,EAA0B;QACxC,oBAAoB,EAAE,EAA0B;QAChD,UAAU,EAAE,EAA0B;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { GlRenderState, GlTextureResolver,
|
|
1
|
+
import type { GlRenderState, GlTextureResolver, TextureSourceKind, TextureLike } from '@flighthq/types/contract';
|
|
2
2
|
export declare function registerGlBitmapTextureResolver(state: GlRenderState): void;
|
|
3
3
|
export declare function registerGlCompressedImageTextureResolver(state: GlRenderState): void;
|
|
4
4
|
export declare function registerGlImageTextureResolver(state: GlRenderState): void;
|
|
5
5
|
export declare function registerGlRenderTextureResolver(state: GlRenderState): void;
|
|
6
|
-
export declare function registerGlTextureResolver(state: GlRenderState,
|
|
7
|
-
export declare function
|
|
6
|
+
export declare function registerGlTextureResolver(state: GlRenderState, sourceKind: TextureSourceKind, resolver: GlTextureResolver | null): void;
|
|
7
|
+
export declare function registerStandardGlTextureResolvers(state: GlRenderState): void;
|
|
8
8
|
export declare function resolveGlTexture(state: GlRenderState, texture: Readonly<TextureLike>, premultiply?: boolean): WebGLTexture | null;
|
|
9
9
|
//# sourceMappingURL=glTextureResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTextureResolver.d.ts","sourceRoot":"","sources":["../src/glTextureResolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"glTextureResolver.d.ts","sourceRoot":"","sources":["../src/glTextureResolver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,aAAa,EACb,iBAAiB,EAGjB,iBAAiB,EACjB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAalC,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAE1E;AAED,wBAAgB,wCAAwC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAEnF;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAEzE;AAGD,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAE1E;AAID,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,iBAAiB,EAC7B,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GACjC,IAAI,CAKN;AAED,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAI7E;AAOD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC9B,WAAW,UAAQ,GAClB,YAAY,GAAG,IAAI,CAYrB"}
|
|
@@ -1,68 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { emitSignal } from '@flighthq/signals/contract';
|
|
2
|
+
import { getTextureSource, getTextureSourceKind } from '@flighthq/texture/contract';
|
|
3
|
+
import { BitmapTextureSourceKind, CompressedImageTextureSourceKind, ImageTextureSourceKind, RenderRegistry, RenderTargetTextureSourceKind, } from '@flighthq/types/contract';
|
|
4
|
+
import { bindGlBitmapTexture, bindGlCompressedImageTexture, bindGlImageResourceTexture } from './glDraw';
|
|
4
5
|
import { getGlRenderStateRuntime } from './glRenderState';
|
|
5
6
|
import { bindGlRenderTexture } from './glRenderTexture';
|
|
6
7
|
export function registerGlBitmapTextureResolver(state) {
|
|
7
|
-
registerGlTextureResolver(state,
|
|
8
|
+
registerGlTextureResolver(state, BitmapTextureSourceKind, resolveGlBitmapTexture);
|
|
8
9
|
}
|
|
9
10
|
export function registerGlCompressedImageTextureResolver(state) {
|
|
10
|
-
registerGlTextureResolver(state,
|
|
11
|
+
registerGlTextureResolver(state, CompressedImageTextureSourceKind, resolveGlCompressedImageTexture);
|
|
11
12
|
}
|
|
12
13
|
export function registerGlImageTextureResolver(state) {
|
|
13
|
-
registerGlTextureResolver(state,
|
|
14
|
+
registerGlTextureResolver(state, ImageTextureSourceKind, resolveGlImageTexture);
|
|
14
15
|
}
|
|
15
16
|
// Installs the render-target realization.
|
|
16
17
|
export function registerGlRenderTextureResolver(state) {
|
|
17
|
-
registerGlTextureResolver(state,
|
|
18
|
+
registerGlTextureResolver(state, RenderTargetTextureSourceKind, resolveGlRenderTexture);
|
|
18
19
|
}
|
|
19
|
-
// Registers or replaces one declared
|
|
20
|
+
// Registers or replaces one declared source-kind resolver on this render state. Map.set is
|
|
20
21
|
// last-write-wins; passing null removes the key. No registration ordering or matcher scan exists.
|
|
21
|
-
export function registerGlTextureResolver(state,
|
|
22
|
+
export function registerGlTextureResolver(state, sourceKind, resolver) {
|
|
22
23
|
const runtime = getGlRenderStateRuntime(state);
|
|
23
24
|
const registry = (runtime.glTextureResolverRegistry ??= new Map());
|
|
24
25
|
if (resolver === null)
|
|
25
|
-
registry.delete(
|
|
26
|
+
registry.delete(sourceKind);
|
|
26
27
|
else
|
|
27
|
-
registry.set(
|
|
28
|
+
registry.set(sourceKind, resolver);
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
export function registerStandardGlTextureResolvers(state) {
|
|
31
|
+
registerGlBitmapTextureResolver(state);
|
|
32
|
+
registerGlImageTextureResolver(state);
|
|
33
|
+
registerGlRenderTextureResolver(state);
|
|
32
34
|
}
|
|
33
|
-
// Resolves through one keyed lookup using the
|
|
35
|
+
// Resolves through one keyed lookup using the source's declared kind. Resolution is deliberately not
|
|
34
36
|
// pure: each built-in resolver leaves its result bound to TEXTURE_2D on the active texture unit because
|
|
35
37
|
// GL upload and sampler application require that binding. Callers must not reorder this call across
|
|
36
|
-
// activeTexture/bind operations as though it only returned a handle. The CPU
|
|
37
|
-
// GPU-origin target owns its own. An unbound or undeclared
|
|
38
|
+
// activeTexture/bind operations as though it only returned a handle. The CPU source owns its kind; a
|
|
39
|
+
// GPU-origin target owns its own. An unbound or undeclared source is the null sentinel.
|
|
38
40
|
export function resolveGlTexture(state, texture, premultiply = false) {
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
+
const sourceKind = getTextureSourceKind(texture);
|
|
42
|
+
if (sourceKind === null)
|
|
41
43
|
return null;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
+
const runtime = getGlRenderStateRuntime(state);
|
|
45
|
+
const resolver = runtime.glTextureResolverRegistry?.get(sourceKind);
|
|
46
|
+
if (resolver === undefined) {
|
|
47
|
+
if (runtime.registrySignals !== null) {
|
|
48
|
+
emitSignal(runtime.registrySignals.onRegistryMiss, RenderRegistry.TextureResolver, sourceKind);
|
|
49
|
+
}
|
|
44
50
|
return null;
|
|
45
|
-
|
|
51
|
+
}
|
|
52
|
+
return resolver(state, texture, premultiply);
|
|
46
53
|
}
|
|
47
54
|
function resolveGlBitmapTexture(state, texture, premultiply) {
|
|
48
|
-
const bitmap = texture
|
|
55
|
+
const bitmap = getTextureSource(texture);
|
|
49
56
|
return bitmap === null ? null : bindGlBitmapTexture(state, bitmap, texture.sampler, null, premultiply);
|
|
50
57
|
}
|
|
51
58
|
function resolveGlCompressedImageTexture(state, texture) {
|
|
52
|
-
const image = texture
|
|
59
|
+
const image = getTextureSource(texture);
|
|
53
60
|
return image === null ? null : bindGlCompressedImageTexture(state, image, texture.sampler);
|
|
54
61
|
}
|
|
55
62
|
function resolveGlImageTexture(state, texture, premultiply) {
|
|
56
|
-
const image = texture
|
|
63
|
+
const image = getTextureSource(texture);
|
|
57
64
|
return image === null ? null : bindGlImageResourceTexture(state, image, texture.sampler, null, premultiply);
|
|
58
65
|
}
|
|
59
66
|
function resolveGlRenderTexture(state, texture) {
|
|
60
67
|
return bindGlRenderTexture(state, texture);
|
|
61
68
|
}
|
|
62
|
-
function resolveGlVideoTexture(state, texture) {
|
|
63
|
-
const source = texture.storage.image?.source;
|
|
64
|
-
if (source == null || source.readyState < 2 || source.videoWidth <= 0 || source.videoHeight <= 0)
|
|
65
|
-
return null;
|
|
66
|
-
return bindGlVideoTexture(state, texture);
|
|
67
|
-
}
|
|
68
69
|
//# sourceMappingURL=glTextureResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTextureResolver.js","sourceRoot":"","sources":["../src/glTextureResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"glTextureResolver.js","sourceRoot":"","sources":["../src/glTextureResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAWpF,OAAO,EACL,uBAAuB,EACvB,gCAAgC,EAChC,sBAAsB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,CAAC,IAAI,CAAC,CAAC,CAAC,4BAA4B,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AAC7F,CAAC;AAED,SAAS,qBAAqB,CAC5B,KAAoB,EACpB,OAA8B,EAC9B,WAAoB;IAEpB,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAA2B,CAAC;IAClE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC9G,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAoB,EAAE,OAA8B;IAClF,OAAO,mBAAmB,CAAC,KAAK,EAAE,OAAkC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Image } from '@flighthq/types/contract';
|
|
2
2
|
export declare function uploadGlTextureData(gl: WebGL2RenderingContext, target: number, width: number, height: number, data: Readonly<Uint8ClampedArray<ArrayBuffer>>): void;
|
|
3
3
|
export declare function uploadGlTextureElement(gl: WebGL2RenderingContext, target: number, source: TexImageSource): void;
|
|
4
|
-
export declare function uploadGlTextureImageResource(gl: WebGL2RenderingContext, target: number, image: Readonly<
|
|
4
|
+
export declare function uploadGlTextureImageResource(gl: WebGL2RenderingContext, target: number, image: Readonly<Image>): void;
|
|
5
5
|
//# sourceMappingURL=glTextureUpload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTextureUpload.d.ts","sourceRoot":"","sources":["../src/glTextureUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"glTextureUpload.d.ts","sourceRoot":"","sources":["../src/glTextureUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAWtD,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,sBAAsB,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,GAC7C,IAAI,CAYN;AAID,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAE/G;AAGD,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAErH"}
|
package/dist/glTextureUpload.js
CHANGED
|
@@ -14,7 +14,7 @@ export function uploadGlTextureData(gl, target, width, height, data) {
|
|
|
14
14
|
export function uploadGlTextureElement(gl, target, source) {
|
|
15
15
|
gl.texImage2D(target, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
|
16
16
|
}
|
|
17
|
-
// Uploads a host-backed
|
|
17
|
+
// Uploads a host-backed Image through the decoded-element fast path.
|
|
18
18
|
export function uploadGlTextureImageResource(gl, target, image) {
|
|
19
19
|
uploadGlTextureElement(gl, target, image.source);
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTextureUpload.js","sourceRoot":"","sources":["../src/glTextureUpload.ts"],"names":[],"mappings":"AAEA,uGAAuG;AACvG,yGAAyG;AACzG,wGAAwG;AACxG,0GAA0G;AAC1G,4EAA4E;AAE5E,wGAAwG;AACxG,2GAA2G;AAC3G,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CACjC,EAA0B,EAC1B,MAAc,EACd,KAAa,EACb,MAAc,EACd,IAA8C;IAE9C,EAAE,CAAC,UAAU,CACX,MAAM,EACN,CAAC,EACD,EAAE,CAAC,IAAI,EACP,KAAK,EACL,MAAM,EACN,CAA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"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function uploadGlTextureVideoFrame(gl: WebGL2RenderingContext, image: Readonly<
|
|
1
|
+
import type { Image } from '@flighthq/types/contract';
|
|
2
|
+
export declare function uploadGlTextureVideoFrame(gl: WebGL2RenderingContext, image: Readonly<Image>, uploadedVersion: number): number;
|
|
3
3
|
//# sourceMappingURL=glTextureVideoUpload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTextureVideoUpload.d.ts","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"glTextureVideoUpload.d.ts","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AActD,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,sBAAsB,EAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EACtB,eAAe,EAAE,MAAM,GACtB,MAAM,CAUR"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { uploadGlTextureElement } from './glTextureUpload';
|
|
2
|
-
// The per-frame video-to-GPU upload path. An
|
|
2
|
+
// The per-frame video-to-GPU upload path. An Image's borrowed HTMLVideoElement decodes new pixels
|
|
3
3
|
// continuously, so a driver re-uploads the currently-bound GL texture whenever the element's frame
|
|
4
4
|
// advances — but not on frames where nothing changed (a paused or stalled stream), which would waste a
|
|
5
|
-
// full-frame DMA. `uploadedVersion` is the
|
|
6
|
-
//
|
|
5
|
+
// full-frame DMA. `uploadedVersion` is the source revision the caller last uploaded; this compares it to the
|
|
6
|
+
// source's `version` and re-uploads through the element fast-path only on a change, returning the
|
|
7
7
|
// id now on the GPU so the caller stores it for the next frame.
|
|
8
8
|
//
|
|
9
9
|
// The caller owns creating, binding, and setting sampler/pixel-store state on the texture; this writes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTextureVideoUpload.js","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,
|
|
1
|
+
{"version":3,"file":"glTextureVideoUpload.js","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,kGAAkG;AAClG,mGAAmG;AACnG,uGAAuG;AACvG,6GAA6G;AAC7G,kGAAkG;AAClG,gEAAgE;AAChE,EAAE;AACF,uGAAuG;AACvG,oGAAoG;AACpG,uGAAuG;AACvG,MAAM,UAAU,yBAAyB,CACvC,EAA0B,EAC1B,KAAsB,EACtB,eAAuB;IAEvB,IAAI,KAAK,CAAC,OAAO,KAAK,eAAe;QAAE,OAAO,eAAe,CAAC;IAC9D,MAAM,OAAO,GAAG,KAAK,CAAC,MAAiC,CAAC;IACxD,qGAAqG;IACrG,+FAA+F;IAC/F,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,UAAU,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,IAAI,OAAO,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC;QACtG,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,sBAAsB,CAAC,EAAE,EAAE,EAAE,CAAC,UAAU,EAAE,OAAoC,CAAC,CAAC;IAChF,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, createGlCanvasElement, createExternalGlTexture, createGlRenderState, createGlRenderTarget, destroyGlRenderTexture, disposeExternalGlTexture, enableGlRenderTextureGuards, enableGlBlendModeSupport, endGlRenderPass, explainGlRenderTexture, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver,
|
|
1
|
+
export { acquireGlRenderTexture, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, copyGlRenderStateRegistrations, createGlCanvasElement, createExternalGlTexture, createGlOffscreenRenderState, createGlRenderState, createGlRenderTexturePool, createGlRenderTarget, destroyGlRenderTexture, destroyGlRenderTexturePool, destroyGlRenderState, disposeExternalGlTexture, enableGlRenderTextureGuards, enableGlRenderStateGuards, enableGlTextureResolverGuards, enableGlBlendModeSupport, endGlRenderPass, explainGlRenderTarget, explainGlRenderTexture, explainGlTextureResolution, isGlRenderTargetFormatSupported, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver, registerStandardGlTextureResolvers, registerGlTextureResolver, renderGlBackground, renderIntoGlRenderTexture, releaseGlRenderTexture, resolveGlRenderTargetAxes, resolveGlTexture, uploadGlCompressedTextureContainer, withGlRenderTextures, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,kCAAkC,EAClC,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, createGlCanvasElement, createExternalGlTexture, createGlRenderState, createGlRenderTarget, destroyGlRenderTexture, disposeExternalGlTexture, enableGlRenderTextureGuards, enableGlBlendModeSupport, endGlRenderPass, explainGlRenderTexture, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver,
|
|
1
|
+
export { acquireGlRenderTexture, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, copyGlRenderStateRegistrations, createGlCanvasElement, createExternalGlTexture, createGlOffscreenRenderState, createGlRenderState, createGlRenderTexturePool, createGlRenderTarget, destroyGlRenderTexture, destroyGlRenderTexturePool, destroyGlRenderState, disposeExternalGlTexture, enableGlRenderTextureGuards, enableGlRenderStateGuards, enableGlTextureResolverGuards, enableGlBlendModeSupport, endGlRenderPass, explainGlRenderTarget, explainGlRenderTexture, explainGlTextureResolution, isGlRenderTargetFormatSupported, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver, registerStandardGlTextureResolvers, registerGlTextureResolver, renderGlBackground, renderIntoGlRenderTexture, releaseGlRenderTexture, resolveGlRenderTargetAxes, resolveGlTexture, uploadGlCompressedTextureContainer, withGlRenderTextures, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,kCAAkC,EAClC,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/render-gl",
|
|
3
|
-
"version": "0.3.0-next.
|
|
3
|
+
"version": "0.3.0-next.1220.6982c21",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -36,12 +36,14 @@
|
|
|
36
36
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flighthq/
|
|
40
|
-
"@flighthq/
|
|
41
|
-
"@flighthq/
|
|
42
|
-
"@flighthq/
|
|
43
|
-
"@flighthq/
|
|
44
|
-
"@flighthq/
|
|
39
|
+
"@flighthq/entity": "0.3.0-next.1220.6982c21",
|
|
40
|
+
"@flighthq/log": "0.3.0-next.1220.6982c21",
|
|
41
|
+
"@flighthq/scene2d": "0.3.0-next.1220.6982c21",
|
|
42
|
+
"@flighthq/geometry": "0.3.0-next.1220.6982c21",
|
|
43
|
+
"@flighthq/render": "0.3.0-next.1220.6982c21",
|
|
44
|
+
"@flighthq/signals": "0.3.0-next.1220.6982c21",
|
|
45
|
+
"@flighthq/texture": "0.3.0-next.1220.6982c21",
|
|
46
|
+
"@flighthq/types": "0.3.0-next.1220.6982c21"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
49
|
"typescript": "^5.3.0"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { areGlRenderStateGuardsEnabled, enableGlRenderStateGuards } from './enableGlRenderStateGuards';
|
|
2
|
+
import { createGlRenderState } from './glRenderState';
|
|
3
|
+
import { makeGL } from './glTestHelper';
|
|
4
|
+
|
|
5
|
+
function createState() {
|
|
6
|
+
const canvas = document.createElement('canvas');
|
|
7
|
+
canvas.getContext = vi.fn().mockReturnValue(makeGL()) as typeof canvas.getContext;
|
|
8
|
+
return createGlRenderState(canvas);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('areGlRenderStateGuardsEnabled', () => {
|
|
12
|
+
it('reports whether the state-local multiple-root guard is installed', () => {
|
|
13
|
+
const state = createState();
|
|
14
|
+
expect(areGlRenderStateGuardsEnabled(state)).toBe(false);
|
|
15
|
+
enableGlRenderStateGuards(state);
|
|
16
|
+
expect(areGlRenderStateGuardsEnabled(state)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('enableGlRenderStateGuards', () => {
|
|
21
|
+
it('installs the state-local multiple-root guard idempotently', () => {
|
|
22
|
+
const state = createState();
|
|
23
|
+
enableGlRenderStateGuards(state);
|
|
24
|
+
enableGlRenderStateGuards(state);
|
|
25
|
+
expect(areGlRenderStateGuardsEnabled(state)).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
});
|