@flighthq/scene2d-wgpu 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/wgpuCache.d.ts +4 -4
- package/dist/wgpuCache.d.ts.map +1 -1
- package/dist/wgpuCache.js +11 -11
- package/dist/wgpuCache.js.map +1 -1
- package/dist/wgpuClipContours.d.ts.map +1 -1
- package/dist/wgpuClipContours.js +3 -4
- package/dist/wgpuClipContours.js.map +1 -1
- package/dist/wgpuClipRectangle.js +3 -4
- package/dist/wgpuClipRectangle.js.map +1 -1
- package/dist/wgpuNode2D.d.ts +2 -2
- package/dist/wgpuNode2D.d.ts.map +1 -1
- package/dist/wgpuNode2D.js +4 -1
- package/dist/wgpuNode2D.js.map +1 -1
- package/dist/wgpuParticleEmitter2D.js +3 -3
- package/dist/wgpuParticleEmitter2D.js.map +1 -1
- package/dist/wgpuQuadBatchWriter.js +3 -3
- package/dist/wgpuQuadBatchWriter.js.map +1 -1
- package/dist/wgpuShapeMesh.js +2 -3
- package/dist/wgpuShapeMesh.js.map +1 -1
- package/dist/wgpuVelocity.d.ts +4 -4
- package/dist/wgpuVelocity.d.ts.map +1 -1
- package/dist/wgpuVelocity.js +11 -9
- package/dist/wgpuVelocity.js.map +1 -1
- package/package.json +20 -20
- package/src/wgpuBitmapText.test.ts +3 -3
- package/src/wgpuCache.test.ts +25 -28
- package/src/wgpuClipContours.test.ts +9 -2
- package/src/wgpuClipRectangle.test.ts +7 -7
- package/src/wgpuColorAdjustmentMaterialFeature.test.ts +3 -3
- package/src/wgpuMeshShapeRenderer.test.ts +11 -7
- package/src/wgpuNode2D.test.ts +6 -6
- package/src/wgpuParticleEmitter2D.test.ts +21 -7
- package/src/wgpuQuadBatch.test.ts +10 -10
- package/src/wgpuQuadBatchWriter.test.ts +19 -19
- package/src/wgpuRasterShapeRenderer.test.ts +26 -8
- package/src/wgpuRichText.test.ts +30 -12
- package/src/wgpuScale9Shape.test.ts +24 -9
- package/src/wgpuScale9Sprite.test.ts +7 -7
- package/src/wgpuShape.test.ts +30 -16
- package/src/wgpuShapeData.test.ts +15 -1
- package/src/wgpuShapeMesh.test.ts +9 -2
- package/src/wgpuSprite.test.ts +13 -13
- package/src/wgpuTextInput.test.ts +3 -3
- package/src/wgpuTextLabel.test.ts +28 -14
- package/src/wgpuTilemap.test.ts +3 -3
- package/src/wgpuVelocity.test.ts +5 -5
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createQuadBatch, reserveQuadBatch } from '@flighthq/quadbatch/contract';
|
|
2
2
|
import {
|
|
3
|
+
beginWgpuScreenRenderPassForTest,
|
|
3
4
|
getWgpuRenderStateRuntime,
|
|
4
5
|
registerWgpuRenderTextureResolver,
|
|
5
6
|
renderIntoWgpuRenderTexture,
|
|
6
|
-
|
|
7
|
-
submitWgpuRenderPass,
|
|
7
|
+
submitWgpuFrame,
|
|
8
8
|
} from '@flighthq/render-wgpu/contract';
|
|
9
9
|
import { createWgpuRenderStateForTest, installWgpuMock } from '@flighthq/render-wgpu/contract';
|
|
10
10
|
import { getOrCreateRenderProxy2D, getRenderProxy2D, prepareScene2DRender } from '@flighthq/render/contract';
|
|
@@ -33,7 +33,7 @@ describe('defaultWgpuQuadBatchRenderer', () => {
|
|
|
33
33
|
describe('defaultWgpuQuadBatchRenderer.submit', () => {
|
|
34
34
|
it('does not throw when atlas is null', async () => {
|
|
35
35
|
const state = await createWgpuRenderStateForTest();
|
|
36
|
-
|
|
36
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
37
37
|
|
|
38
38
|
const batch = createQuadBatch();
|
|
39
39
|
prepareScene2DRender(state, batch);
|
|
@@ -43,16 +43,16 @@ describe('defaultWgpuQuadBatchRenderer.submit', () => {
|
|
|
43
43
|
defaultWgpuQuadBatchRenderer.submit(state, renderProxy);
|
|
44
44
|
flushWgpuQuadBatchWriter(state as any);
|
|
45
45
|
}).not.toThrow();
|
|
46
|
-
|
|
46
|
+
submitWgpuFrame(state);
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it('packs a rotated region with upright geometry and affine UV axes', async () => {
|
|
50
50
|
const state = await createWgpuRenderStateForTest();
|
|
51
|
-
|
|
51
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
52
52
|
registerWgpuRenderTextureResolver(state);
|
|
53
53
|
registerWgpuStandardMaterial(state);
|
|
54
54
|
const texture = createRenderTexture({ height: 64, width: 64 });
|
|
55
|
-
renderIntoWgpuRenderTexture(state, texture, () => {});
|
|
55
|
+
renderIntoWgpuRenderTexture(state, texture, () => {}, { color: [0, 0, 0, 0], depth: 1.0, stencil: 0 });
|
|
56
56
|
const batch = createQuadBatch({
|
|
57
57
|
data: {
|
|
58
58
|
atlas: createTextureAtlas({
|
|
@@ -86,16 +86,16 @@ describe('defaultWgpuQuadBatchRenderer.submit', () => {
|
|
|
86
86
|
expect(data[9]).toBeCloseTo(40 / 64);
|
|
87
87
|
expect(data[10]).toBeCloseTo(-20 / 64);
|
|
88
88
|
expect(data[11]).toBeCloseTo(0);
|
|
89
|
-
|
|
89
|
+
submitWgpuFrame(state);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it('packs libGDX counterclockwise regions with the opposite affine UV axes', async () => {
|
|
93
93
|
const state = await createWgpuRenderStateForTest();
|
|
94
|
-
|
|
94
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
95
95
|
registerWgpuRenderTextureResolver(state);
|
|
96
96
|
registerWgpuStandardMaterial(state);
|
|
97
97
|
const texture = createRenderTexture({ height: 64, width: 64 });
|
|
98
|
-
renderIntoWgpuRenderTexture(state, texture, () => {});
|
|
98
|
+
renderIntoWgpuRenderTexture(state, texture, () => {}, { color: [0, 0, 0, 0], depth: 1.0, stencil: 0 });
|
|
99
99
|
const batch = createQuadBatch({
|
|
100
100
|
data: {
|
|
101
101
|
atlas: createTextureAtlas({
|
|
@@ -125,7 +125,7 @@ describe('defaultWgpuQuadBatchRenderer.submit', () => {
|
|
|
125
125
|
expect(data[7]).toBeCloseTo(40 / 64);
|
|
126
126
|
expect(data[9]).toBeCloseTo(-40 / 64);
|
|
127
127
|
expect(data[10]).toBeCloseTo(20 / 64);
|
|
128
|
-
|
|
128
|
+
submitWgpuFrame(state);
|
|
129
129
|
});
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { beginWgpuScreenRenderPassForTest, submitWgpuFrame } from '@flighthq/render-wgpu/contract';
|
|
2
2
|
import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu/contract';
|
|
3
3
|
import { createWgpuRenderStateForTest, installWgpuMock } from '@flighthq/render-wgpu/contract';
|
|
4
4
|
import type { ColorScaleBias, Material, WgpuTextureEntry } from '@flighthq/types/contract';
|
|
@@ -85,14 +85,14 @@ describe('ensureWgpuQuadBatchResources', () => {
|
|
|
85
85
|
describe('flushWgpuQuadBatchWriter', () => {
|
|
86
86
|
it('does nothing when batch count is zero', async () => {
|
|
87
87
|
const state = await createWgpuRenderStateForTest();
|
|
88
|
-
|
|
88
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
89
89
|
expect(() => flushWgpuQuadBatchWriter(state)).not.toThrow();
|
|
90
|
-
|
|
90
|
+
submitWgpuFrame(state);
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
it('resets state after flush', async () => {
|
|
94
94
|
const state = await createWgpuRenderStateForTest();
|
|
95
|
-
|
|
95
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
96
96
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
97
97
|
const tex = makeTexture();
|
|
98
98
|
|
|
@@ -104,7 +104,7 @@ describe('flushWgpuQuadBatchWriter', () => {
|
|
|
104
104
|
expect(runtime.quadBatchWriterTexture).toBeNull();
|
|
105
105
|
expect(runtime.quadBatchWriterBlendMode).toBeNull();
|
|
106
106
|
expect(runtime.quadBatchWriterMaterial).toBeNull();
|
|
107
|
-
|
|
107
|
+
submitWgpuFrame(state);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
it('records the flush in render stats, from the LIVE draw path', async () => {
|
|
@@ -112,7 +112,7 @@ describe('flushWgpuQuadBatchWriter', () => {
|
|
|
112
112
|
// production path could reach here recording nothing at all and every test still pass. This drives
|
|
113
113
|
// the real flush and asserts the counters moved.
|
|
114
114
|
const state = await createWgpuRenderStateForTest();
|
|
115
|
-
|
|
115
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
116
116
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
117
117
|
resetWgpuRenderStats(state);
|
|
118
118
|
|
|
@@ -126,25 +126,25 @@ describe('flushWgpuQuadBatchWriter', () => {
|
|
|
126
126
|
// The instance count is the batch size, not one per flush — a caller reading this to size buffers
|
|
127
127
|
// needs the quads, not the draws.
|
|
128
128
|
expect(stats.instanceCount).toBe(3);
|
|
129
|
-
|
|
129
|
+
submitWgpuFrame(state);
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
it('records nothing when the flush issues no draw', async () => {
|
|
133
133
|
// An empty writer returns early without drawing. Counting that would report batches the GPU never
|
|
134
134
|
// saw, which is worse than not counting at all: it makes a frame look busier than it was.
|
|
135
135
|
const state = await createWgpuRenderStateForTest();
|
|
136
|
-
|
|
136
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
137
137
|
resetWgpuRenderStats(state);
|
|
138
138
|
flushWgpuQuadBatchWriter(state);
|
|
139
139
|
expect(getWgpuRenderStats(state).batchFlushCount).toBe(0);
|
|
140
|
-
|
|
140
|
+
submitWgpuFrame(state);
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
it('claims a distinct buffer per flush so deferred draws never share one', async () => {
|
|
144
144
|
// The canvas pass is submitted once at end of frame; if successive flushes reused one instance
|
|
145
145
|
// buffer, every draw would read the last flush's data and the batch would collapse to one spot.
|
|
146
146
|
const state = await createWgpuRenderStateForTest();
|
|
147
|
-
|
|
147
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
148
148
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
149
149
|
const tex1 = makeTexture();
|
|
150
150
|
const tex2 = makeTexture();
|
|
@@ -162,7 +162,7 @@ describe('flushWgpuQuadBatchWriter', () => {
|
|
|
162
162
|
expect(runtime.quadBatchWriterBufferPool[0].instanceBuffer).not.toBe(
|
|
163
163
|
runtime.quadBatchWriterBufferPool[1].instanceBuffer,
|
|
164
164
|
);
|
|
165
|
-
|
|
165
|
+
submitWgpuFrame(state);
|
|
166
166
|
});
|
|
167
167
|
});
|
|
168
168
|
|
|
@@ -231,7 +231,7 @@ describe('prepareWgpuQuadBatchWrite', () => {
|
|
|
231
231
|
|
|
232
232
|
it('flushes when texture changes', async () => {
|
|
233
233
|
const state = await createWgpuRenderStateForTest();
|
|
234
|
-
|
|
234
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
235
235
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
236
236
|
const tex1 = makeTexture();
|
|
237
237
|
const tex2 = makeTexture();
|
|
@@ -242,12 +242,12 @@ describe('prepareWgpuQuadBatchWrite', () => {
|
|
|
242
242
|
|
|
243
243
|
expect(runtime.quadBatchWriterTexture).toBe(tex2);
|
|
244
244
|
expect(runtime.quadBatchWriterCount).toBe(0);
|
|
245
|
-
|
|
245
|
+
submitWgpuFrame(state);
|
|
246
246
|
});
|
|
247
247
|
|
|
248
248
|
it('flushes when material changes', async () => {
|
|
249
249
|
const state = await createWgpuRenderStateForTest();
|
|
250
|
-
|
|
250
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
251
251
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
252
252
|
const tex = makeTexture();
|
|
253
253
|
const materialA = makeMaterial();
|
|
@@ -259,7 +259,7 @@ describe('prepareWgpuQuadBatchWrite', () => {
|
|
|
259
259
|
|
|
260
260
|
expect(runtime.quadBatchWriterMaterial).toBe(materialB);
|
|
261
261
|
expect(runtime.quadBatchWriterCount).toBe(0);
|
|
262
|
-
|
|
262
|
+
submitWgpuFrame(state);
|
|
263
263
|
});
|
|
264
264
|
});
|
|
265
265
|
|
|
@@ -289,21 +289,21 @@ describe('recordWgpuQuadBatchColorScaleBias', () => {
|
|
|
289
289
|
it('an untinted batch on flush uses the lean material module (no fold)', async () => {
|
|
290
290
|
const state = await createWgpuRenderStateForTest();
|
|
291
291
|
registerWgpuColorAdjustmentMaterialFeature(state);
|
|
292
|
-
|
|
292
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
293
293
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
294
294
|
const tex = makeTexture();
|
|
295
295
|
prepareWgpuQuadBatchWrite(state, tex, null, null, null, standardWgpuMaterialRenderer, 1);
|
|
296
296
|
recordWgpuQuadBatchColorScaleBias(state, null, 0);
|
|
297
297
|
runtime.quadBatchWriterCount = 1;
|
|
298
298
|
expect(() => flushWgpuQuadBatchWriter(state)).not.toThrow();
|
|
299
|
-
|
|
299
|
+
submitWgpuFrame(state);
|
|
300
300
|
});
|
|
301
301
|
});
|
|
302
302
|
|
|
303
303
|
describe('resetWgpuQuadBatchWriterBufferPool', () => {
|
|
304
304
|
it('rewinds the pool cursor so slots are reclaimed next frame', async () => {
|
|
305
305
|
const state = await createWgpuRenderStateForTest();
|
|
306
|
-
|
|
306
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
307
307
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
308
308
|
const tex = makeTexture();
|
|
309
309
|
|
|
@@ -314,7 +314,7 @@ describe('resetWgpuQuadBatchWriterBufferPool', () => {
|
|
|
314
314
|
|
|
315
315
|
resetWgpuQuadBatchWriterBufferPool(state);
|
|
316
316
|
expect(runtime.quadBatchWriterBufferCursor).toBe(0);
|
|
317
|
-
|
|
317
|
+
submitWgpuFrame(state);
|
|
318
318
|
});
|
|
319
319
|
});
|
|
320
320
|
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createImageResource,
|
|
3
|
+
registerTestImageDimensionResolver,
|
|
4
|
+
unregisterTestImageDimensionResolver,
|
|
5
|
+
} from '@flighthq/image/contract';
|
|
2
6
|
import * as flightNode from '@flighthq/node/contract';
|
|
3
|
-
import {
|
|
4
|
-
|
|
7
|
+
import {
|
|
8
|
+
beginWgpuScreenRenderPassForTest,
|
|
9
|
+
createWgpuRenderStateForTest,
|
|
10
|
+
getWgpuRenderStateRuntime,
|
|
11
|
+
installWgpuMock,
|
|
12
|
+
} from '@flighthq/render-wgpu/contract';
|
|
5
13
|
import { enableRenderRegistryGuards, explainRenderRegistryMisses } from '@flighthq/render/contract';
|
|
6
14
|
import { appendShapeBeginFill, appendShapeEndFill, appendShapeRectangle, createShape } from '@flighthq/shape/contract';
|
|
7
15
|
import type { RenderProxy2D } from '@flighthq/types/contract';
|
|
@@ -11,6 +19,16 @@ import { defaultWgpuRasterShapeRenderer, drawWgpuRasterShape } from './wgpuRaste
|
|
|
11
19
|
import { registerWgpuShapeRasterizer } from './wgpuShapeRasterizer';
|
|
12
20
|
import { registerWgpuStandardMaterial } from './wgpuStandardMaterial';
|
|
13
21
|
|
|
22
|
+
// A test that wraps a host handle supplies the host: the resource measures through the registered
|
|
23
|
+
// resolver, and clearing after each test keeps this file from covering for another's missing one.
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
registerTestImageDimensionResolver();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
unregisterTestImageDimensionResolver();
|
|
30
|
+
});
|
|
31
|
+
|
|
14
32
|
beforeAll(() => installWgpuMock());
|
|
15
33
|
|
|
16
34
|
beforeEach(() => {
|
|
@@ -128,7 +146,7 @@ describe('drawWgpuRasterShape', () => {
|
|
|
128
146
|
it('rasterizes a fill the mesh path could have tessellated, which is what pinning this strategy means', async () => {
|
|
129
147
|
const state = await createWgpuRenderStateForTest();
|
|
130
148
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider();
|
|
131
|
-
|
|
149
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
132
150
|
registerWgpuStandardMaterial(state);
|
|
133
151
|
const pass = makeMeshPassSpy();
|
|
134
152
|
getWgpuRenderStateRuntime(state).renderPass = pass;
|
|
@@ -145,7 +163,7 @@ describe('drawWgpuRasterShape', () => {
|
|
|
145
163
|
it('replays the whole command stream, not the subset a mesh path could not express', async () => {
|
|
146
164
|
const state = await createWgpuRenderStateForTest();
|
|
147
165
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider();
|
|
148
|
-
|
|
166
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
149
167
|
registerWgpuStandardMaterial(state);
|
|
150
168
|
getWgpuRenderStateRuntime(state).renderPass = makeMeshPassSpy();
|
|
151
169
|
const shape = solidShape();
|
|
@@ -162,7 +180,7 @@ describe('drawWgpuRasterShape', () => {
|
|
|
162
180
|
it('reports a ShapeRasterizer miss when no rasterizer is registered', async () => {
|
|
163
181
|
const state = await createWgpuRenderStateForTest();
|
|
164
182
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider();
|
|
165
|
-
|
|
183
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
166
184
|
getWgpuRenderStateRuntime(state).renderPass = makeMeshPassSpy();
|
|
167
185
|
enableRenderRegistryGuards(state);
|
|
168
186
|
|
|
@@ -176,7 +194,7 @@ describe('drawWgpuRasterShape', () => {
|
|
|
176
194
|
|
|
177
195
|
it('preserves expected surface absence without rasterizing or writing a batch', async () => {
|
|
178
196
|
const state = await createWgpuRenderStateForTest();
|
|
179
|
-
|
|
197
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
180
198
|
registerWgpuStandardMaterial(state);
|
|
181
199
|
getWgpuRenderStateRuntime(state).renderPass = makeMeshPassSpy();
|
|
182
200
|
const rasterizer = vi.fn();
|
|
@@ -191,7 +209,7 @@ describe('drawWgpuRasterShape', () => {
|
|
|
191
209
|
it('does nothing without a render pass, for an empty command list, or with absent renderer data', async () => {
|
|
192
210
|
const state = await createWgpuRenderStateForTest();
|
|
193
211
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider();
|
|
194
|
-
|
|
212
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
195
213
|
registerWgpuStandardMaterial(state);
|
|
196
214
|
const rasterizer = vi.fn();
|
|
197
215
|
registerWgpuShapeRasterizer(state, rasterizer);
|
package/src/wgpuRichText.test.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createImageResource,
|
|
3
|
+
registerTestImageDimensionResolver,
|
|
4
|
+
unregisterTestImageDimensionResolver,
|
|
5
|
+
} from '@flighthq/image/contract';
|
|
6
|
+
import {
|
|
7
|
+
beginWgpuScreenRenderPassForTest,
|
|
8
|
+
getWgpuRenderStateRuntime,
|
|
9
|
+
submitWgpuFrame,
|
|
10
|
+
} from '@flighthq/render-wgpu/contract';
|
|
3
11
|
import { createWgpuRenderStateForTest, installWgpuMock } from '@flighthq/render-wgpu/contract';
|
|
4
12
|
import { getOrCreateRenderProxy2D, prepareScene2DRender } from '@flighthq/render/contract';
|
|
5
13
|
import { createRichText } from '@flighthq/text/contract';
|
|
@@ -17,6 +25,16 @@ import {
|
|
|
17
25
|
registerWgpuTextInputOverlay,
|
|
18
26
|
} from './wgpuRichText';
|
|
19
27
|
|
|
28
|
+
// A test that wraps a host handle supplies the host: the resource measures through the registered
|
|
29
|
+
// resolver, and clearing after each test keeps this file from covering for another's missing one.
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
registerTestImageDimensionResolver();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
unregisterTestImageDimensionResolver();
|
|
36
|
+
});
|
|
37
|
+
|
|
20
38
|
beforeAll(() => {
|
|
21
39
|
installWgpuMock();
|
|
22
40
|
});
|
|
@@ -73,7 +91,7 @@ describe('destroyWgpuRichTextData', () => {
|
|
|
73
91
|
it('removes the GPU cache entry before returning the node surface to its creator', async () => {
|
|
74
92
|
const order: string[] = [];
|
|
75
93
|
const state = await createWgpuRenderStateForTest();
|
|
76
|
-
|
|
94
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
77
95
|
const cache = getWgpuRenderStateRuntime(state).context.textureSourcePremultipliedTextureCache;
|
|
78
96
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider((surface) => {
|
|
79
97
|
order.push('surface');
|
|
@@ -86,7 +104,7 @@ describe('destroyWgpuRichTextData', () => {
|
|
|
86
104
|
drawWgpuRichText(state, proxy);
|
|
87
105
|
const surface = getWgpuRendererData<{ surface: Raster2DSurface }>(proxy.rendererData)!.surface;
|
|
88
106
|
const entry = cache.get(surface.image)!;
|
|
89
|
-
|
|
107
|
+
submitWgpuFrame(state);
|
|
90
108
|
vi.spyOn(entry.texture, 'destroy').mockImplementation(() => {
|
|
91
109
|
order.push('texture');
|
|
92
110
|
});
|
|
@@ -106,7 +124,7 @@ describe('drawWgpuRichText', () => {
|
|
|
106
124
|
it('keeps different text nodes on distinct surfaces and GPU textures in one frame', async () => {
|
|
107
125
|
const state = await createWgpuRenderStateForTest();
|
|
108
126
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider();
|
|
109
|
-
|
|
127
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
110
128
|
const first = createRichText({ data: { height: 40, text: 'first', width: 100 } });
|
|
111
129
|
const second = createRichText({ data: { height: 40, text: 'second', width: 100 } });
|
|
112
130
|
prepareScene2DRender(state, first);
|
|
@@ -133,19 +151,19 @@ describe('drawWgpuRichText', () => {
|
|
|
133
151
|
drawWgpuRichText(state, firstProxy);
|
|
134
152
|
expect(firstOwned.surface).toBe(firstSurface);
|
|
135
153
|
expect(firstOwned.surface!.image).toBe(firstImage);
|
|
136
|
-
|
|
154
|
+
submitWgpuFrame(state);
|
|
137
155
|
});
|
|
138
156
|
|
|
139
157
|
it('does not throw for empty rich text', async () => {
|
|
140
158
|
const state = await createWgpuRenderStateForTest();
|
|
141
|
-
|
|
159
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
142
160
|
|
|
143
161
|
const richText = createRichText();
|
|
144
162
|
prepareScene2DRender(state, richText);
|
|
145
163
|
const renderProxy = getOrCreateRenderProxy2D(state, richText);
|
|
146
164
|
|
|
147
165
|
expect(() => drawWgpuRichText(state, renderProxy)).not.toThrow();
|
|
148
|
-
|
|
166
|
+
submitWgpuFrame(state);
|
|
149
167
|
});
|
|
150
168
|
|
|
151
169
|
it('does not throw when renderPass is null', async () => {
|
|
@@ -161,12 +179,12 @@ describe('drawWgpuRichText', () => {
|
|
|
161
179
|
describe('drawWgpuRichTextWithOverlay', () => {
|
|
162
180
|
it('does not throw for empty rich text', async () => {
|
|
163
181
|
const state = await createWgpuRenderStateForTest();
|
|
164
|
-
|
|
182
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
165
183
|
const richText = createRichText();
|
|
166
184
|
prepareScene2DRender(state, richText);
|
|
167
185
|
const renderProxy = getOrCreateRenderProxy2D(state, richText);
|
|
168
186
|
expect(() => drawWgpuRichTextWithOverlay(state, renderProxy)).not.toThrow();
|
|
169
|
-
|
|
187
|
+
submitWgpuFrame(state);
|
|
170
188
|
});
|
|
171
189
|
});
|
|
172
190
|
|
|
@@ -176,7 +194,7 @@ describe('registerWgpuTextInputOverlay', () => {
|
|
|
176
194
|
registerWgpuTextInputOverlay(overlay);
|
|
177
195
|
const state = await createWgpuRenderStateForTest();
|
|
178
196
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider();
|
|
179
|
-
|
|
197
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
180
198
|
|
|
181
199
|
const plain = createRichText({ data: { height: 40, text: 'x', width: 100 } });
|
|
182
200
|
prepareScene2DRender(state, plain);
|
|
@@ -192,6 +210,6 @@ describe('registerWgpuTextInputOverlay', () => {
|
|
|
192
210
|
editableProxy.rendererData = createWgpuRichTextData(state, editable);
|
|
193
211
|
drawWgpuRichText(state, editableProxy);
|
|
194
212
|
expect(overlay).toHaveBeenCalled();
|
|
195
|
-
|
|
213
|
+
submitWgpuFrame(state);
|
|
196
214
|
});
|
|
197
215
|
});
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { createImageResource, invalidateImageResource } from '@flighthq/image/contract';
|
|
2
1
|
import {
|
|
2
|
+
createImageResource,
|
|
3
|
+
invalidateImageResource,
|
|
4
|
+
registerTestImageDimensionResolver,
|
|
5
|
+
unregisterTestImageDimensionResolver,
|
|
6
|
+
} from '@flighthq/image/contract';
|
|
7
|
+
import {
|
|
8
|
+
beginWgpuScreenRenderPassForTest,
|
|
3
9
|
bindWgpuImageResourceTexture,
|
|
4
10
|
getWgpuRenderStateRuntime,
|
|
5
|
-
|
|
6
|
-
submitWgpuRenderPass,
|
|
11
|
+
submitWgpuFrame,
|
|
7
12
|
} from '@flighthq/render-wgpu/contract';
|
|
8
13
|
import { createWgpuRenderStateForTest, installWgpuMock } from '@flighthq/render-wgpu/contract';
|
|
9
14
|
import { getOrCreateRenderProxy2D, prepareScene2DRender } from '@flighthq/render/contract';
|
|
@@ -21,6 +26,16 @@ import {
|
|
|
21
26
|
getWgpuScale9ShapeData,
|
|
22
27
|
} from './wgpuScale9Shape';
|
|
23
28
|
|
|
29
|
+
// A test that wraps a host handle supplies the host: the resource measures through the registered
|
|
30
|
+
// resolver, and clearing after each test keeps this file from covering for another's missing one.
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
registerTestImageDimensionResolver();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
unregisterTestImageDimensionResolver();
|
|
37
|
+
});
|
|
38
|
+
|
|
24
39
|
const grid = { height: 80, width: 80, x: 10, y: 10 };
|
|
25
40
|
const destroySurface = vi.fn();
|
|
26
41
|
|
|
@@ -171,19 +186,19 @@ describe('drawWgpuScale9Shape', () => {
|
|
|
171
186
|
it('returns early when commands are empty', async () => {
|
|
172
187
|
const state = await createWgpuRenderStateForTest();
|
|
173
188
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider();
|
|
174
|
-
|
|
189
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
175
190
|
const shape = createScale9Shape(grid);
|
|
176
191
|
prepareScene2DRender(state, shape);
|
|
177
192
|
const renderProxy = getOrCreateRenderProxy2D(state, shape);
|
|
178
193
|
|
|
179
194
|
expect(() => drawWgpuScale9Shape(state, renderProxy)).not.toThrow();
|
|
180
|
-
|
|
195
|
+
submitWgpuFrame(state);
|
|
181
196
|
});
|
|
182
197
|
|
|
183
198
|
it('rasterizes and draws a filled shape without throwing', async () => {
|
|
184
199
|
const state = await createWgpuRenderStateForTest();
|
|
185
200
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider();
|
|
186
|
-
|
|
201
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
187
202
|
const shape = createScale9Shape(grid);
|
|
188
203
|
appendShapeBeginFill(shape, 0xff0000ff);
|
|
189
204
|
appendShapeRectangle(shape, 0, 0, 100, 100);
|
|
@@ -191,7 +206,7 @@ describe('drawWgpuScale9Shape', () => {
|
|
|
191
206
|
const renderProxy = getOrCreateRenderProxy2D(state, shape);
|
|
192
207
|
|
|
193
208
|
expect(() => drawWgpuScale9Shape(state, renderProxy)).not.toThrow();
|
|
194
|
-
|
|
209
|
+
submitWgpuFrame(state);
|
|
195
210
|
});
|
|
196
211
|
});
|
|
197
212
|
|
|
@@ -199,13 +214,13 @@ describe('drawWgpuScale9ShapeMask', () => {
|
|
|
199
214
|
it('delegates to the Scale9 draw path', async () => {
|
|
200
215
|
const state = await createWgpuRenderStateForTest();
|
|
201
216
|
state.raster2DSurfaceProvider = createTestRaster2DSurfaceProvider();
|
|
202
|
-
|
|
217
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
203
218
|
const shape = createScale9Shape(grid);
|
|
204
219
|
prepareScene2DRender(state, shape);
|
|
205
220
|
const renderProxy = getOrCreateRenderProxy2D(state, shape);
|
|
206
221
|
|
|
207
222
|
expect(() => drawWgpuScale9ShapeMask(state, renderProxy)).not.toThrow();
|
|
208
|
-
|
|
223
|
+
submitWgpuFrame(state);
|
|
209
224
|
});
|
|
210
225
|
});
|
|
211
226
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
beginWgpuScreenRenderPassForTest,
|
|
2
3
|
createWgpuRenderStateForTest,
|
|
3
4
|
getWgpuPipelineRegistries,
|
|
4
5
|
getWgpuRenderStateRuntime,
|
|
5
6
|
installWgpuMock,
|
|
6
7
|
registerWgpuRenderTextureResolver,
|
|
7
8
|
renderIntoWgpuRenderTexture,
|
|
8
|
-
|
|
9
|
-
submitWgpuRenderPass,
|
|
9
|
+
submitWgpuFrame,
|
|
10
10
|
} from '@flighthq/render-wgpu/contract';
|
|
11
11
|
import { createRenderTexture } from '@flighthq/texture/contract';
|
|
12
12
|
import type {
|
|
@@ -41,7 +41,7 @@ describe('defaultWgpuScale9SpriteRenderer', () => {
|
|
|
41
41
|
describe('drawWgpuScale9Sprite', () => {
|
|
42
42
|
it('emits nine independently positioned quad instances', async () => {
|
|
43
43
|
const state = await createWgpuRenderStateForTest();
|
|
44
|
-
|
|
44
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
45
45
|
registerWgpuRenderTextureResolver(state);
|
|
46
46
|
registerWgpuStandardMaterial(state);
|
|
47
47
|
const texture = createResolvedRenderTexture(state);
|
|
@@ -69,12 +69,12 @@ describe('drawWgpuScale9Sprite', () => {
|
|
|
69
69
|
expect(runtime.quadBatchWriterInstanceData[center + 9]).toBeCloseTo(0);
|
|
70
70
|
expect(runtime.quadBatchWriterInstanceData[center + 10]).toBeCloseTo(0);
|
|
71
71
|
expect(runtime.quadBatchWriterInstanceData[center + 11]).toBeCloseTo(10 / 60);
|
|
72
|
-
|
|
72
|
+
submitWgpuFrame(state);
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
it('indexes parallel instance streams from the post-flush writer count', async () => {
|
|
76
76
|
const state = await createWgpuRenderStateForTest();
|
|
77
|
-
|
|
77
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
78
78
|
registerWgpuRenderTextureResolver(state);
|
|
79
79
|
registerWgpuStandardMaterial(state);
|
|
80
80
|
registerWgpuColorAdjustmentMaterialFeature(state);
|
|
@@ -90,13 +90,13 @@ describe('drawWgpuScale9Sprite', () => {
|
|
|
90
90
|
expect(runtime.quadBatchWriterCount).toBe(9);
|
|
91
91
|
expect(runtime.quadBatchWriterColorScaleBiasMode).toBe(1);
|
|
92
92
|
expect(runtime.quadBatchWriterUniformColorScaleBias).toBe(tint);
|
|
93
|
-
|
|
93
|
+
submitWgpuFrame(state);
|
|
94
94
|
});
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
function createResolvedRenderTexture(state: Parameters<typeof renderIntoWgpuRenderTexture>[0]): Texture2D {
|
|
98
98
|
const texture = createRenderTexture({ height: 60, width: 90 });
|
|
99
|
-
renderIntoWgpuRenderTexture(state, texture, () => {});
|
|
99
|
+
renderIntoWgpuRenderTexture(state, texture, () => {}, { color: [0, 0, 0, 0], depth: 1.0, stencil: 0 });
|
|
100
100
|
return texture;
|
|
101
101
|
}
|
|
102
102
|
|