@flighthq/scene2d-wgpu 0.5.1-next.973.788d3d7 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/.tsbuildinfo.contract +1 -0
- package/dist/.tsbuildinfo.runtime +1 -0
- package/dist/contract.d.ts +32 -34
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +32 -34
- package/dist/contract.js.map +1 -1
- package/dist/contract.scene2d-wgpu-types.d.ts +6 -0
- package/dist/contract.scene2d-wgpu-types.d.ts.map +1 -0
- package/dist/contract.scene2d-wgpu-types.js +2 -0
- package/dist/contract.scene2d-wgpu-types.js.map +1 -0
- package/dist/enableWgpuColorAdjustmentGuards.d.ts +3 -2
- package/dist/enableWgpuColorAdjustmentGuards.d.ts.map +1 -1
- package/dist/enableWgpuColorAdjustmentGuards.js +23 -14
- package/dist/enableWgpuColorAdjustmentGuards.js.map +1 -1
- package/dist/enableWgpuStrokePathTessellation.d.ts +1 -1
- package/dist/enableWgpuStrokePathTessellation.d.ts.map +1 -1
- package/dist/enableWgpuStrokePathTessellation.js +1 -6
- package/dist/enableWgpuStrokePathTessellation.js.map +1 -1
- package/dist/index.d.ts +23 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/dist/scene2DWgpuPipeline.d.ts +13 -0
- package/dist/scene2DWgpuPipeline.d.ts.map +1 -0
- package/dist/scene2DWgpuPipeline.js +59 -0
- package/dist/scene2DWgpuPipeline.js.map +1 -0
- package/dist/types/WgpuColorAdjustmentMaterialFeature.d.ts +2 -0
- package/dist/types/WgpuColorAdjustmentMaterialFeature.d.ts.map +1 -0
- package/dist/types/WgpuColorAdjustmentMaterialFeature.js +2 -0
- package/dist/types/WgpuColorAdjustmentMaterialFeature.js.map +1 -0
- package/dist/types/WgpuRenderStats.d.ts +12 -0
- package/dist/types/WgpuRenderStats.d.ts.map +1 -0
- package/dist/types/WgpuRenderStats.js +2 -0
- package/dist/types/WgpuRenderStats.js.map +1 -0
- package/dist/types/WgpuRichTextOverlay.d.ts +4 -0
- package/dist/types/WgpuRichTextOverlay.d.ts.map +1 -0
- package/dist/types/WgpuRichTextOverlay.js +2 -0
- package/dist/types/WgpuRichTextOverlay.js.map +1 -0
- package/dist/types/WgpuShapeMesh.d.ts +2 -0
- package/dist/types/WgpuShapeMesh.d.ts.map +1 -0
- package/dist/types/WgpuShapeMesh.js +2 -0
- package/dist/types/WgpuShapeMesh.js.map +1 -0
- package/dist/types/WgpuShapeRendererData.d.ts +17 -0
- package/dist/types/WgpuShapeRendererData.d.ts.map +1 -0
- package/dist/types/WgpuShapeRendererData.js +2 -0
- package/dist/types/WgpuShapeRendererData.js.map +1 -0
- package/dist/wgpuBitmapText.d.ts +2 -2
- package/dist/wgpuBitmapText.d.ts.map +1 -1
- package/dist/wgpuBitmapText.js +6 -6
- package/dist/wgpuBitmapText.js.map +1 -1
- package/dist/wgpuCache.d.ts +9 -6
- package/dist/wgpuCache.d.ts.map +1 -1
- package/dist/wgpuCache.js +17 -18
- package/dist/wgpuCache.js.map +1 -1
- package/dist/wgpuClip.d.ts +1 -1
- package/dist/wgpuClip.d.ts.map +1 -1
- package/dist/wgpuClip.js +2 -2
- package/dist/wgpuClip.js.map +1 -1
- package/dist/wgpuClipContours.d.ts +3 -1
- package/dist/wgpuClipContours.d.ts.map +1 -1
- package/dist/wgpuClipContours.js +7 -8
- package/dist/wgpuClipContours.js.map +1 -1
- package/dist/wgpuClipRectangle.d.ts +2 -1
- package/dist/wgpuClipRectangle.d.ts.map +1 -1
- package/dist/wgpuClipRectangle.js +4 -5
- package/dist/wgpuClipRectangle.js.map +1 -1
- package/dist/wgpuColorAdjustmentMaterialFeature.d.ts +1 -1
- package/dist/wgpuColorAdjustmentMaterialFeature.d.ts.map +1 -1
- package/dist/wgpuColorAdjustmentMaterialFeature.js +9 -13
- package/dist/wgpuColorAdjustmentMaterialFeature.js.map +1 -1
- package/dist/wgpuMeshShapeRenderer.d.ts +3 -2
- package/dist/wgpuMeshShapeRenderer.d.ts.map +1 -1
- package/dist/wgpuMeshShapeRenderer.js +9 -8
- package/dist/wgpuMeshShapeRenderer.js.map +1 -1
- package/dist/wgpuNode2D.d.ts +6 -3
- package/dist/wgpuNode2D.d.ts.map +1 -1
- package/dist/wgpuNode2D.js +20 -4
- package/dist/wgpuNode2D.js.map +1 -1
- package/dist/wgpuParticleEmitter2D.d.ts +4 -2
- package/dist/wgpuParticleEmitter2D.d.ts.map +1 -1
- package/dist/wgpuParticleEmitter2D.js +8 -8
- package/dist/wgpuParticleEmitter2D.js.map +1 -1
- package/dist/wgpuQuadBatch.d.ts +3 -3
- package/dist/wgpuQuadBatch.d.ts.map +1 -1
- package/dist/wgpuQuadBatch.js +6 -6
- package/dist/wgpuQuadBatch.js.map +1 -1
- package/dist/wgpuQuadBatchWriter.d.ts +9 -5
- package/dist/wgpuQuadBatchWriter.d.ts.map +1 -1
- package/dist/wgpuQuadBatchWriter.js +12 -8
- package/dist/wgpuQuadBatchWriter.js.map +1 -1
- package/dist/wgpuRasterShapeRenderer.d.ts +3 -2
- package/dist/wgpuRasterShapeRenderer.d.ts.map +1 -1
- package/dist/wgpuRasterShapeRenderer.js +41 -22
- package/dist/wgpuRasterShapeRenderer.js.map +1 -1
- package/dist/wgpuRenderStats.d.ts +2 -1
- package/dist/wgpuRenderStats.d.ts.map +1 -1
- package/dist/wgpuRenderStats.js.map +1 -1
- package/dist/wgpuRendererData.d.ts +2 -1
- package/dist/wgpuRendererData.d.ts.map +1 -1
- package/dist/wgpuRendererData.js +1 -1
- package/dist/wgpuRendererData.js.map +1 -1
- package/dist/wgpuRichText.d.ts +6 -3
- package/dist/wgpuRichText.d.ts.map +1 -1
- package/dist/wgpuRichText.js +67 -34
- package/dist/wgpuRichText.js.map +1 -1
- package/dist/wgpuScale9Mapper.d.ts +2 -1
- package/dist/wgpuScale9Mapper.d.ts.map +1 -1
- package/dist/wgpuScale9Mapper.js.map +1 -1
- package/dist/wgpuScale9Shape.d.ts +10 -5
- package/dist/wgpuScale9Shape.d.ts.map +1 -1
- package/dist/wgpuScale9Shape.js +54 -28
- package/dist/wgpuScale9Shape.js.map +1 -1
- package/dist/wgpuScale9Sprite.d.ts +3 -2
- package/dist/wgpuScale9Sprite.d.ts.map +1 -1
- package/dist/wgpuScale9Sprite.js +9 -10
- package/dist/wgpuScale9Sprite.js.map +1 -1
- package/dist/wgpuShape.d.ts +4 -3
- package/dist/wgpuShape.d.ts.map +1 -1
- package/dist/wgpuShape.js +7 -7
- package/dist/wgpuShape.js.map +1 -1
- package/dist/wgpuShapeData.d.ts +8 -3
- package/dist/wgpuShapeData.d.ts.map +1 -1
- package/dist/wgpuShapeData.js +12 -9
- package/dist/wgpuShapeData.js.map +1 -1
- package/dist/wgpuShapeMesh.d.ts +4 -2
- package/dist/wgpuShapeMesh.d.ts.map +1 -1
- package/dist/wgpuShapeMesh.js +9 -8
- package/dist/wgpuShapeMesh.js.map +1 -1
- package/dist/wgpuShapeRasterizer.d.ts +2 -1
- package/dist/wgpuShapeRasterizer.d.ts.map +1 -1
- package/dist/wgpuShapeRasterizer.js +3 -8
- package/dist/wgpuShapeRasterizer.js.map +1 -1
- package/dist/wgpuSprite.d.ts +3 -2
- package/dist/wgpuSprite.d.ts.map +1 -1
- package/dist/wgpuSprite.js +7 -8
- package/dist/wgpuSprite.js.map +1 -1
- package/dist/wgpuStandardMaterial.d.ts +2 -2
- package/dist/wgpuStandardMaterial.d.ts.map +1 -1
- package/dist/wgpuStandardMaterial.js +5 -5
- package/dist/wgpuStandardMaterial.js.map +1 -1
- package/dist/wgpuTextInput.d.ts +2 -1
- package/dist/wgpuTextInput.d.ts.map +1 -1
- package/dist/wgpuTextInput.js +6 -7
- package/dist/wgpuTextInput.js.map +1 -1
- package/dist/wgpuTextLabel.d.ts +3 -2
- package/dist/wgpuTextLabel.d.ts.map +1 -1
- package/dist/wgpuTextLabel.js +67 -35
- package/dist/wgpuTextLabel.js.map +1 -1
- package/dist/wgpuTilemap.d.ts +2 -2
- package/dist/wgpuTilemap.d.ts.map +1 -1
- package/dist/wgpuTilemap.js +6 -6
- package/dist/wgpuTilemap.js.map +1 -1
- package/dist/wgpuVelocity.d.ts +10 -7
- package/dist/wgpuVelocity.d.ts.map +1 -1
- package/dist/wgpuVelocity.js +89 -87
- package/dist/wgpuVelocity.js.map +1 -1
- package/package.json +31 -25
- package/src/contract.test.ts +13 -0
- package/src/enableWgpuColorAdjustmentGuards.test.ts +50 -28
- package/src/enableWgpuStrokePathTessellation.test.ts +4 -9
- package/src/scene2DWgpuPipeline.test.ts +53 -0
- package/src/wgpuBitmapText.test.ts +10 -10
- package/src/wgpuCache.test.ts +130 -168
- package/src/wgpuClip.test.ts +1 -1
- package/src/wgpuClipContours.test.ts +13 -6
- package/src/wgpuClipRectangle.test.ts +8 -8
- package/src/wgpuColorAdjustmentMaterialFeature.test.ts +20 -19
- package/src/wgpuMeshShapeRenderer.test.ts +51 -52
- package/src/wgpuNode2D.test.ts +14 -14
- package/src/wgpuParticleEmitter2D.test.ts +52 -45
- package/src/wgpuQuadBatch.test.ts +62 -60
- package/src/wgpuQuadBatchWriter.test.ts +76 -34
- package/src/wgpuRasterShapeRenderer.test.ts +95 -57
- package/src/wgpuRenderStats.test.ts +1 -1
- package/src/wgpuRendererData.test.ts +2 -2
- package/src/wgpuRichText.test.ts +109 -58
- package/src/wgpuScale9Mapper.test.ts +1 -1
- package/src/wgpuScale9Shape.test.ts +103 -62
- package/src/wgpuScale9Sprite.test.ts +31 -36
- package/src/wgpuShape.test.ts +111 -76
- package/src/wgpuShapeData.test.ts +96 -53
- package/src/wgpuShapeMesh.test.ts +39 -25
- package/src/wgpuShapeRasterizer.test.ts +11 -7
- package/src/wgpuSprite.test.ts +36 -27
- package/src/wgpuStandardMaterial.test.ts +9 -13
- package/src/wgpuTextInput.test.ts +9 -6
- package/src/wgpuTextLabel.test.ts +145 -88
- package/src/wgpuTilemap.test.ts +11 -11
- package/src/wgpuVelocity.test.ts +86 -86
- package/dist/scene2dWgpuPipeline.d.ts +0 -3
- package/dist/scene2dWgpuPipeline.d.ts.map +0 -1
- package/dist/scene2dWgpuPipeline.js +0 -40
- package/dist/scene2dWgpuPipeline.js.map +0 -1
package/src/wgpuCache.test.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
1
2
|
import { createMatrix } from '@flighthq/geometry/contract';
|
|
2
|
-
import { getRegistryTableEntry } from '@flighthq/registry/contract';
|
|
3
3
|
import * as renderWgpu from '@flighthq/render-wgpu/contract';
|
|
4
|
+
import type {
|
|
5
|
+
WgpuBuffer,
|
|
6
|
+
WgpuCanvasContext,
|
|
7
|
+
WgpuCommandEncoder,
|
|
8
|
+
WgpuDevice,
|
|
9
|
+
WgpuQuadMaterialRenderer,
|
|
10
|
+
WgpuRenderState,
|
|
11
|
+
WgpuTexture,
|
|
12
|
+
WgpuTextureFormat,
|
|
13
|
+
WgpuTextureRenderTarget,
|
|
14
|
+
WgpuTextureView,
|
|
15
|
+
} from '@flighthq/render-wgpu/contract';
|
|
4
16
|
import {
|
|
5
17
|
createRenderCache,
|
|
6
18
|
createRenderState,
|
|
@@ -9,65 +21,54 @@ import {
|
|
|
9
21
|
RenderCacheKind,
|
|
10
22
|
useRenderCache,
|
|
11
23
|
} from '@flighthq/render/contract';
|
|
24
|
+
import type { RenderRootGuard } from '@flighthq/render/contract';
|
|
12
25
|
import { createDisplayObject } from '@flighthq/scene2d/contract';
|
|
26
|
+
|
|
13
27
|
import type {
|
|
14
28
|
WgpuColorAdjustmentMaterialFeature,
|
|
15
29
|
WgpuColorAdjustmentMaterialFeatureGuard,
|
|
16
|
-
|
|
17
|
-
WgpuPresentationRenderState,
|
|
18
|
-
WgpuRenderState,
|
|
19
|
-
RenderRootGuard,
|
|
20
|
-
WgpuRenderTarget,
|
|
21
|
-
} from '@flighthq/types/contract';
|
|
22
|
-
import { EntityRuntimeKey, RegistryEntryState } from '@flighthq/types/contract';
|
|
23
|
-
|
|
30
|
+
} from './contract.scene2d-wgpu-types.ts';
|
|
24
31
|
import {
|
|
25
32
|
createWgpuCacheState,
|
|
26
|
-
|
|
33
|
+
wgpuRenderCacheRenderer,
|
|
27
34
|
enableWgpuRenderCache,
|
|
28
35
|
ensureWgpuRenderCacheTarget,
|
|
29
36
|
getWgpuRenderCacheTarget,
|
|
30
37
|
refreshWgpuRenderCache,
|
|
31
38
|
releaseWgpuRenderCache,
|
|
32
|
-
} from './wgpuCache';
|
|
33
|
-
import * as wgpuNode2D from './wgpuNode2D';
|
|
34
|
-
import * as wgpuQuadBatchWriter from './wgpuQuadBatchWriter';
|
|
39
|
+
} from './wgpuCache.ts';
|
|
40
|
+
import * as wgpuNode2D from './wgpuNode2D.ts';
|
|
41
|
+
import * as wgpuQuadBatchWriter from './wgpuQuadBatchWriter.ts';
|
|
35
42
|
|
|
36
43
|
// The GPU render-target lifecycle (@flighthq/render-wgpu) and the two local collaborators
|
|
37
44
|
// ./wgpuQuadBatchWriter and ./wgpuNode2D are stubbed so cache orchestration can be unit-tested without a
|
|
38
|
-
// real GPU pipeline:
|
|
45
|
+
// real GPU pipeline: createWgpuTextureRenderTarget returns a plain descriptor, and the composite, batch-flush
|
|
39
46
|
// and subtree-render calls become spies for the call and ordering assertions below.
|
|
40
47
|
beforeEach(() => {
|
|
41
48
|
vi.spyOn(wgpuQuadBatchWriter, 'flushWgpuQuadBatchWriter').mockImplementation((() => {}) as never);
|
|
42
49
|
|
|
43
50
|
const beginWgpuFrameSpy = vi.spyOn(renderWgpu, 'beginWgpuFrame').mockImplementation(((state: WgpuRenderState) => {
|
|
44
|
-
renderWgpu.getWgpuRenderStateRuntime(state).commandEncoder = {} as
|
|
51
|
+
renderWgpu.getWgpuRenderStateRuntime(state).commandEncoder = {} as WgpuCommandEncoder;
|
|
45
52
|
}) as never);
|
|
46
|
-
const
|
|
47
|
-
state: WgpuRenderState,
|
|
48
|
-
) => {
|
|
53
|
+
const submitWgpuFrameSpy = vi.spyOn(renderWgpu, 'submitWgpuFrame').mockImplementation(((state: WgpuRenderState) => {
|
|
49
54
|
renderWgpu.getWgpuRenderStateRuntime(state).commandEncoder = null;
|
|
50
55
|
}) as never);
|
|
51
56
|
vi.spyOn(renderWgpu, 'beginWgpuRenderPass').mockImplementation((() => {}) as never);
|
|
52
|
-
vi.spyOn(renderWgpu, 'createWgpuOffscreenRenderState').mockImplementation(((
|
|
53
|
-
deviceState: any,
|
|
54
|
-
pipeline: any,
|
|
55
|
-
options: any = {},
|
|
56
|
-
) => {
|
|
57
|
+
vi.spyOn(renderWgpu, 'createWgpuOffscreenRenderState').mockImplementation(((deviceState: any, options: any = {}) => {
|
|
57
58
|
const state = createRenderState({
|
|
58
59
|
allowSmoothing: options.imageSmoothingEnabled ?? true,
|
|
59
60
|
pixelRatio: options.pixelRatio ?? 1,
|
|
60
61
|
roundPixels: options.roundPixels ?? false,
|
|
61
62
|
sceneGraphSyncPolicy: options.sceneGraphSyncPolicy,
|
|
62
63
|
}) as WgpuRenderState;
|
|
64
|
+
const runtime = renderWgpu.createWgpuRenderStateRuntime(deviceState, options);
|
|
63
65
|
Object.assign(state, {
|
|
64
66
|
applyBlendMode: null,
|
|
65
67
|
device: deviceState.device,
|
|
66
68
|
deviceState,
|
|
67
69
|
format: options.format ?? 'bgra8unorm',
|
|
68
|
-
|
|
70
|
+
registries: runtime.registries,
|
|
69
71
|
});
|
|
70
|
-
const runtime = renderWgpu.createWgpuRenderStateRuntime(deviceState, pipeline);
|
|
71
72
|
state[EntityRuntimeKey] = runtime;
|
|
72
73
|
Object.assign(runtime, {
|
|
73
74
|
commandEncoder: null,
|
|
@@ -81,37 +82,36 @@ beforeEach(() => {
|
|
|
81
82
|
retiredBuffers: [],
|
|
82
83
|
retiredTextures: [],
|
|
83
84
|
surfaceAntialiasTexture: null,
|
|
84
|
-
uniformBuffer: { destroy: vi.fn() } as unknown as
|
|
85
|
+
uniformBuffer: { destroy: vi.fn() } as unknown as WgpuBuffer,
|
|
85
86
|
uniformData: new Float32Array(0),
|
|
86
87
|
uniformOffset: 0,
|
|
87
88
|
});
|
|
88
89
|
return state;
|
|
89
90
|
}) as never);
|
|
90
|
-
vi.spyOn(renderWgpu, '
|
|
91
|
-
|
|
92
|
-
((_state: unknown, width: number, height: number): WgpuRenderTarget => ({
|
|
91
|
+
vi.spyOn(renderWgpu, 'createWgpuTextureRenderTarget').mockImplementation(
|
|
92
|
+
((_state: unknown, width: number, height: number): WgpuTextureRenderTarget => ({
|
|
93
93
|
[EntityRuntimeKey]: undefined,
|
|
94
94
|
bindings: new Map(),
|
|
95
|
+
colorAttachments: 1,
|
|
96
|
+
context: null,
|
|
95
97
|
mipLevelCount: 1,
|
|
96
98
|
colorSpace: 'srgb',
|
|
97
|
-
depthStencilTexture: {} as
|
|
98
|
-
depthStencilView: {} as
|
|
99
|
-
texture: {} as
|
|
100
|
-
view: {} as
|
|
99
|
+
depthStencilTexture: {} as WgpuTexture,
|
|
100
|
+
depthStencilView: {} as WgpuTextureView,
|
|
101
|
+
texture: {} as WgpuTexture,
|
|
102
|
+
view: {} as WgpuTextureView,
|
|
101
103
|
format: 'bgra8unorm',
|
|
102
104
|
sampleCount: 1,
|
|
103
|
-
clearColors: [],
|
|
104
|
-
clearDepth: 1,
|
|
105
105
|
width,
|
|
106
106
|
height,
|
|
107
107
|
})) as never,
|
|
108
108
|
);
|
|
109
|
-
vi.spyOn(renderWgpu, '
|
|
110
|
-
vi.spyOn(renderWgpu, '
|
|
109
|
+
vi.spyOn(renderWgpu, 'destroyWgpuTextureRenderTarget').mockImplementation((() => {}) as never);
|
|
110
|
+
vi.spyOn(renderWgpu, 'drawWgpuTextureRenderTargetResult').mockImplementation((() => {}) as never);
|
|
111
111
|
vi.spyOn(renderWgpu, 'endWgpuRenderPass').mockImplementation((() => {}) as never);
|
|
112
|
-
vi.spyOn(renderWgpu, '
|
|
112
|
+
vi.spyOn(renderWgpu, 'resizeWgpuTextureRenderTarget').mockImplementation(((
|
|
113
113
|
_state: unknown,
|
|
114
|
-
target:
|
|
114
|
+
target: WgpuTextureRenderTarget,
|
|
115
115
|
width: number,
|
|
116
116
|
height: number,
|
|
117
117
|
) => {
|
|
@@ -119,7 +119,7 @@ beforeEach(() => {
|
|
|
119
119
|
target.height = height;
|
|
120
120
|
}) as never);
|
|
121
121
|
vi.spyOn(renderWgpu, 'withWgpuFrameBorrow').mockImplementation(((
|
|
122
|
-
owner:
|
|
122
|
+
owner: WgpuRenderState,
|
|
123
123
|
borrower: WgpuRenderState,
|
|
124
124
|
callback: () => unknown,
|
|
125
125
|
) => {
|
|
@@ -132,7 +132,7 @@ beforeEach(() => {
|
|
|
132
132
|
return callback();
|
|
133
133
|
} finally {
|
|
134
134
|
borrowerRuntime.commandEncoder = null;
|
|
135
|
-
if (ownsFrame)
|
|
135
|
+
if (ownsFrame) submitWgpuFrameSpy(owner);
|
|
136
136
|
}
|
|
137
137
|
}) as never);
|
|
138
138
|
vi.spyOn(wgpuNode2D, 'renderWgpuScene2D').mockImplementation((() => {}) as never);
|
|
@@ -140,39 +140,34 @@ beforeEach(() => {
|
|
|
140
140
|
|
|
141
141
|
afterEach(() => vi.restoreAllMocks());
|
|
142
142
|
|
|
143
|
-
function fakeScreen(options = {}):
|
|
144
|
-
const state = createRenderState(options) as unknown as
|
|
145
|
-
const device = {} as
|
|
143
|
+
function fakeScreen(options = {}): WgpuRenderState {
|
|
144
|
+
const state = createRenderState(options) as unknown as WgpuRenderState;
|
|
145
|
+
const device = {} as WgpuDevice;
|
|
146
146
|
const deviceState = renderWgpu.createWgpuDeviceState(device);
|
|
147
|
-
const
|
|
147
|
+
const runtime = renderWgpu.createWgpuRenderStateRuntime(deviceState);
|
|
148
148
|
Object.assign(state, {
|
|
149
|
-
context: {} as
|
|
149
|
+
context: {} as WgpuCanvasContext,
|
|
150
150
|
device,
|
|
151
151
|
deviceState,
|
|
152
|
-
format: 'bgra8unorm' as
|
|
153
|
-
|
|
152
|
+
format: 'bgra8unorm' as WgpuTextureFormat,
|
|
153
|
+
registries: runtime.registries,
|
|
154
154
|
surface: { height: 600, width: 800 },
|
|
155
155
|
});
|
|
156
|
-
state[EntityRuntimeKey] =
|
|
157
|
-
const runtime = renderWgpu.getWgpuRenderStateRuntime(state);
|
|
156
|
+
state[EntityRuntimeKey] = runtime;
|
|
158
157
|
runtime.commandEncoder = null;
|
|
159
158
|
runtime.currentBlendMode = null;
|
|
160
159
|
return state;
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
function createCacheState(screen:
|
|
164
|
-
return createWgpuCacheState(
|
|
165
|
-
screen,
|
|
166
|
-
screen.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
roundPixels: screen.roundPixels,
|
|
173
|
-
sceneGraphSyncPolicy: screen.sceneGraphSyncPolicy,
|
|
174
|
-
},
|
|
175
|
-
);
|
|
162
|
+
function createCacheState(screen: WgpuRenderState): WgpuRenderState {
|
|
163
|
+
return createWgpuCacheState(screen, screen.deviceState, {
|
|
164
|
+
...renderWgpu.getWgpuRenderStateRuntime(screen).registries,
|
|
165
|
+
format: screen.format,
|
|
166
|
+
imageSmoothingEnabled: screen.allowSmoothing,
|
|
167
|
+
pixelRatio: screen.pixelRatio,
|
|
168
|
+
roundPixels: screen.roundPixels,
|
|
169
|
+
sceneGraphSyncPolicy: screen.sceneGraphSyncPolicy,
|
|
170
|
+
});
|
|
176
171
|
}
|
|
177
172
|
|
|
178
173
|
function makeCacheNode(source: unknown): any {
|
|
@@ -184,7 +179,7 @@ describe('createWgpuCacheState', () => {
|
|
|
184
179
|
const screen = fakeScreen();
|
|
185
180
|
const destroyUniformBuffer = vi.fn();
|
|
186
181
|
const screenRuntime = renderWgpu.getWgpuRenderStateRuntime(screen);
|
|
187
|
-
screenRuntime.uniformBuffer = { destroy: destroyUniformBuffer } as unknown as
|
|
182
|
+
screenRuntime.uniformBuffer = { destroy: destroyUniformBuffer } as unknown as WgpuBuffer;
|
|
188
183
|
screenRuntime.quadBatchWriterBufferPool = [];
|
|
189
184
|
|
|
190
185
|
const cacheState = createCacheState(screen);
|
|
@@ -238,37 +233,16 @@ describe('createWgpuCacheState', () => {
|
|
|
238
233
|
const colorAdjustmentFeatureGuard: WgpuColorAdjustmentMaterialFeatureGuard = vi.fn();
|
|
239
234
|
const renderRootGuard: RenderRootGuard = vi.fn();
|
|
240
235
|
const screenRuntime = renderWgpu.getWgpuRenderStateRuntime(screen);
|
|
241
|
-
screenRuntime.registries.colorAdjustments =
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
};
|
|
247
|
-
screenRuntime.registries.colorAdjustmentFeature = {
|
|
248
|
-
entry: { state: RegistryEntryState.Bound, value: colorAdjustmentFeature },
|
|
249
|
-
onMiss: 'Disabled',
|
|
250
|
-
registry: 'WgpuColorAdjustmentFeature',
|
|
251
|
-
shape: 'slot',
|
|
252
|
-
};
|
|
253
|
-
screenRuntime.registries.colorAdjustmentFeatureGuard = {
|
|
254
|
-
entry: { state: RegistryEntryState.Bound, value: colorAdjustmentFeatureGuard },
|
|
255
|
-
onMiss: 'Disabled',
|
|
256
|
-
registry: 'WgpuColorAdjustmentFeatureGuard',
|
|
257
|
-
shape: 'slot',
|
|
258
|
-
};
|
|
259
|
-
screenRuntime.registries.renderRootGuard = {
|
|
260
|
-
entry: { state: RegistryEntryState.Bound, value: renderRootGuard },
|
|
261
|
-
onMiss: 'Disabled',
|
|
262
|
-
registry: 'RenderRootGuard',
|
|
263
|
-
shape: 'slot',
|
|
264
|
-
};
|
|
265
|
-
enableColorAdjustmentGuards(screen);
|
|
236
|
+
screenRuntime.registries.colorAdjustments = resolver;
|
|
237
|
+
screenRuntime.registries.colorAdjustmentFeature = colorAdjustmentFeature;
|
|
238
|
+
screenRuntime.registries.colorAdjustmentFeatureGuard = colorAdjustmentFeatureGuard;
|
|
239
|
+
screenRuntime.registries.renderRootGuard = renderRootGuard;
|
|
240
|
+
enableColorAdjustmentGuards(screen, null);
|
|
266
241
|
enableWgpuRenderCache(screen);
|
|
267
242
|
const cacheState = createCacheState(screen);
|
|
268
|
-
expect(renderWgpu.getWgpuRenderStateRuntime(cacheState).registries.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
});
|
|
243
|
+
expect(renderWgpu.getWgpuRenderStateRuntime(cacheState).registries.nodeRenderers.get(RenderCacheKind)).toEqual(
|
|
244
|
+
wgpuRenderCacheRenderer,
|
|
245
|
+
);
|
|
272
246
|
expect((cacheState as any).device).toBe((screen as any).device);
|
|
273
247
|
expect(renderWgpu.getWgpuRenderStateRuntime(cacheState).renderProxyMap).not.toBe(
|
|
274
248
|
renderWgpu.getWgpuRenderStateRuntime(screen).renderProxyMap,
|
|
@@ -296,29 +270,19 @@ describe('createWgpuCacheState', () => {
|
|
|
296
270
|
expect(cacheRuntime.registries.colorAdjustmentUnsupportedGuard).toBe(sharedUnsupportedGuard);
|
|
297
271
|
expect(getColorAdjustmentUnsupportedGuard(cacheState)).not.toBeNull();
|
|
298
272
|
expect(cacheRuntime.registries.renderRootGuard).toBe(screenRuntime.registries.renderRootGuard);
|
|
299
|
-
expect(
|
|
300
|
-
getRegistryTableEntry(
|
|
301
|
-
cacheRuntime.registries.renderRootGuard!,
|
|
302
|
-
cacheRuntime.registries.renderRootGuard!.registry,
|
|
303
|
-
),
|
|
304
|
-
).toBe(renderRootGuard);
|
|
273
|
+
expect(cacheRuntime.registries.renderRootGuard).toBe(renderRootGuard);
|
|
305
274
|
const sharedRootGuard = cacheRuntime.registries.renderRootGuard;
|
|
306
275
|
screenRuntime.registries.renderRootGuard = undefined;
|
|
307
276
|
expect(screenRuntime.registries.renderRootGuard).toBeUndefined();
|
|
308
277
|
expect(cacheRuntime.registries.renderRootGuard).toBe(sharedRootGuard);
|
|
309
|
-
expect(
|
|
310
|
-
getRegistryTableEntry(
|
|
311
|
-
cacheRuntime.registries.renderRootGuard!,
|
|
312
|
-
cacheRuntime.registries.renderRootGuard!.registry,
|
|
313
|
-
),
|
|
314
|
-
).toBe(renderRootGuard);
|
|
278
|
+
expect(cacheRuntime.registries.renderRootGuard).toBe(renderRootGuard);
|
|
315
279
|
});
|
|
316
280
|
|
|
317
281
|
it('shares persistent registration snapshots through a distinct aggregate and then diverges', () => {
|
|
318
282
|
const screen = fakeScreen();
|
|
319
|
-
const first:
|
|
320
|
-
const replacement:
|
|
321
|
-
renderWgpu.
|
|
283
|
+
const first: WgpuQuadMaterialRenderer = { instanceFloatCount: 0, getShaderModule: vi.fn() };
|
|
284
|
+
const replacement: WgpuQuadMaterialRenderer = { instanceFloatCount: 0, getShaderModule: vi.fn() };
|
|
285
|
+
renderWgpu.registerWgpuQuadMaterialRenderer(screen, 'acme.Material', first);
|
|
322
286
|
|
|
323
287
|
const cacheState = createCacheState(screen);
|
|
324
288
|
const screenRuntime = renderWgpu.getWgpuRenderStateRuntime(screen);
|
|
@@ -327,59 +291,19 @@ describe('createWgpuCacheState', () => {
|
|
|
327
291
|
expect(cacheRuntime.registries.colorAdjustments).toBe(screenRuntime.registries.colorAdjustments);
|
|
328
292
|
expect(cacheRuntime.registries.compressedTextureDecoder).toBe(screenRuntime.registries.compressedTextureDecoder);
|
|
329
293
|
expect(cacheRuntime.registries.compressedTextureUpload).toBe(screenRuntime.registries.compressedTextureUpload);
|
|
330
|
-
expect(cacheRuntime.registries.customMaterialShaders).toBe(screenRuntime.registries.customMaterialShaders);
|
|
331
|
-
expect(cacheRuntime.registries.materialRenderers).toBe(screenRuntime.registries.materialRenderers);
|
|
332
|
-
expect(cacheRuntime.registries.
|
|
333
|
-
expect(cacheRuntime.registries.renderEffects).toBe(screenRuntime.registries.renderEffects);
|
|
294
|
+
expect(cacheRuntime.registries.customMaterialShaders).not.toBe(screenRuntime.registries.customMaterialShaders);
|
|
295
|
+
expect(cacheRuntime.registries.materialRenderers).not.toBe(screenRuntime.registries.materialRenderers);
|
|
296
|
+
expect(cacheRuntime.registries.effects).not.toBe(screenRuntime.registries.effects);
|
|
334
297
|
expect(cacheRuntime.registries.shapeRasterizer).toBe(screenRuntime.registries.shapeRasterizer);
|
|
335
298
|
expect(cacheRuntime.registries.strokeTessellator).toBe(screenRuntime.registries.strokeTessellator);
|
|
336
|
-
expect(cacheRuntime.registries.textureResolvers).toBe(screenRuntime.registries.textureResolvers);
|
|
337
|
-
expect(cacheRuntime.registries.velocityWriters).toBe(screenRuntime.registries.velocityWriters);
|
|
338
|
-
expect(renderWgpu.
|
|
299
|
+
expect(cacheRuntime.registries.textureResolvers).not.toBe(screenRuntime.registries.textureResolvers);
|
|
300
|
+
expect(cacheRuntime.registries.velocityWriters).not.toBe(screenRuntime.registries.velocityWriters);
|
|
301
|
+
expect(renderWgpu.getWgpuQuadMaterialRenderer(cacheState, 'acme.Material')).toBe(first);
|
|
339
302
|
|
|
340
|
-
renderWgpu.
|
|
303
|
+
renderWgpu.registerWgpuQuadMaterialRenderer(screen, 'acme.Material', replacement);
|
|
341
304
|
|
|
342
|
-
expect(renderWgpu.
|
|
343
|
-
expect(renderWgpu.
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
describe('defaultWgpuRenderCacheRenderer', () => {
|
|
348
|
-
it('does nothing when no cache is attached to the source', () => {
|
|
349
|
-
const state = fakeScreen();
|
|
350
|
-
defaultWgpuRenderCacheRenderer.submit(state, makeCacheNode(createDisplayObject()));
|
|
351
|
-
expect(renderWgpu.drawWgpuRenderTargetResult).not.toHaveBeenCalled();
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
it('composites the cache target attached to the source node', () => {
|
|
355
|
-
const state = fakeScreen();
|
|
356
|
-
const obj = createDisplayObject();
|
|
357
|
-
const cache = createRenderCache();
|
|
358
|
-
useRenderCache(state, obj, cache);
|
|
359
|
-
const target = ensureWgpuRenderCacheTarget(state, cache, 16, 16);
|
|
360
|
-
defaultWgpuRenderCacheRenderer.submit(state, makeCacheNode(obj));
|
|
361
|
-
expect(renderWgpu.drawWgpuRenderTargetResult).toHaveBeenCalledWith(
|
|
362
|
-
state,
|
|
363
|
-
expect.anything(),
|
|
364
|
-
target,
|
|
365
|
-
expect.anything(),
|
|
366
|
-
);
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
it('flushes pending batched geometry before the immediate composite', () => {
|
|
370
|
-
const state = fakeScreen();
|
|
371
|
-
const obj = createDisplayObject();
|
|
372
|
-
const cache = createRenderCache();
|
|
373
|
-
useRenderCache(state, obj, cache);
|
|
374
|
-
ensureWgpuRenderCacheTarget(state, cache, 16, 16);
|
|
375
|
-
defaultWgpuRenderCacheRenderer.submit(state, makeCacheNode(obj));
|
|
376
|
-
// The composite draws an immediate quad outside the quad-batch writer; geometry submitted earlier in
|
|
377
|
-
// the walk must be drained first, or the immediate quad interleaves with the un-flushed batch's
|
|
378
|
-
// instance buffer and bind-group state and corrupts it.
|
|
379
|
-
expect(wgpuQuadBatchWriter.flushWgpuQuadBatchWriter).toHaveBeenCalledWith(state);
|
|
380
|
-
expect((wgpuQuadBatchWriter.flushWgpuQuadBatchWriter as any).mock.invocationCallOrder[0]).toBeLessThan(
|
|
381
|
-
(renderWgpu.drawWgpuRenderTargetResult as any).mock.invocationCallOrder[0],
|
|
382
|
-
);
|
|
305
|
+
expect(renderWgpu.getWgpuQuadMaterialRenderer(screen, 'acme.Material')).toBe(replacement);
|
|
306
|
+
expect(renderWgpu.getWgpuQuadMaterialRenderer(cacheState, 'acme.Material')).toBe(first);
|
|
383
307
|
});
|
|
384
308
|
});
|
|
385
309
|
|
|
@@ -387,10 +311,9 @@ describe('enableWgpuRenderCache', () => {
|
|
|
387
311
|
it('registers the renderer for the render cache kind', () => {
|
|
388
312
|
const state = fakeScreen();
|
|
389
313
|
enableWgpuRenderCache(state);
|
|
390
|
-
expect(renderWgpu.getWgpuRenderStateRuntime(state).registries.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
});
|
|
314
|
+
expect(renderWgpu.getWgpuRenderStateRuntime(state).registries.nodeRenderers.get(RenderCacheKind)).toEqual(
|
|
315
|
+
wgpuRenderCacheRenderer,
|
|
316
|
+
);
|
|
394
317
|
});
|
|
395
318
|
});
|
|
396
319
|
|
|
@@ -429,8 +352,8 @@ describe('ensureWgpuRenderCacheTarget', () => {
|
|
|
429
352
|
|
|
430
353
|
renderWgpu.destroyWgpuRenderState(state);
|
|
431
354
|
|
|
432
|
-
expect(renderWgpu.
|
|
433
|
-
expect(renderWgpu.
|
|
355
|
+
expect(renderWgpu.destroyWgpuTextureRenderTarget).toHaveBeenCalledWith(first);
|
|
356
|
+
expect(renderWgpu.destroyWgpuTextureRenderTarget).toHaveBeenCalledWith(second);
|
|
434
357
|
expect(getWgpuRenderCacheTarget(state, firstCache)).toBeNull();
|
|
435
358
|
expect(getWgpuRenderCacheTarget(state, secondCache)).toBeNull();
|
|
436
359
|
});
|
|
@@ -455,20 +378,20 @@ describe('refreshWgpuRenderCache', () => {
|
|
|
455
378
|
const cacheState = createCacheState(screen);
|
|
456
379
|
refreshWgpuRenderCache(screen, cacheState, createRenderCache(), createDisplayObject(), { padding: 5 });
|
|
457
380
|
expect(renderWgpu.beginWgpuFrame).toHaveBeenCalledWith(screen);
|
|
458
|
-
expect(renderWgpu.
|
|
381
|
+
expect(renderWgpu.submitWgpuFrame).toHaveBeenCalledWith(screen);
|
|
459
382
|
expect(renderWgpu.getWgpuRenderStateRuntime(screen).commandEncoder).toBeNull();
|
|
460
383
|
});
|
|
461
384
|
|
|
462
385
|
it('records into an active application frame without submitting it', () => {
|
|
463
386
|
const screen = fakeScreen();
|
|
464
|
-
const encoder = {} as
|
|
387
|
+
const encoder = {} as WgpuCommandEncoder;
|
|
465
388
|
renderWgpu.getWgpuRenderStateRuntime(screen).commandEncoder = encoder;
|
|
466
389
|
const cacheState = createCacheState(screen);
|
|
467
390
|
vi.mocked(renderWgpu.beginWgpuFrame).mockClear();
|
|
468
|
-
vi.mocked(renderWgpu.
|
|
391
|
+
vi.mocked(renderWgpu.submitWgpuFrame).mockClear();
|
|
469
392
|
refreshWgpuRenderCache(screen, cacheState, createRenderCache(), createDisplayObject(), { padding: 5 });
|
|
470
393
|
expect(renderWgpu.beginWgpuFrame).not.toHaveBeenCalled();
|
|
471
|
-
expect(renderWgpu.
|
|
394
|
+
expect(renderWgpu.submitWgpuFrame).not.toHaveBeenCalled();
|
|
472
395
|
expect(renderWgpu.getWgpuRenderStateRuntime(screen).commandEncoder).toBe(encoder);
|
|
473
396
|
});
|
|
474
397
|
|
|
@@ -501,7 +424,46 @@ describe('releaseWgpuRenderCache', () => {
|
|
|
501
424
|
const cache = createRenderCache();
|
|
502
425
|
const target = ensureWgpuRenderCacheTarget(state, cache, 8, 8);
|
|
503
426
|
releaseWgpuRenderCache(state, cache);
|
|
504
|
-
expect(renderWgpu.
|
|
427
|
+
expect(renderWgpu.destroyWgpuTextureRenderTarget).toHaveBeenCalledWith(target);
|
|
505
428
|
expect(getWgpuRenderCacheTarget(state, cache)).toBeNull();
|
|
506
429
|
});
|
|
507
430
|
});
|
|
431
|
+
|
|
432
|
+
describe('wgpuRenderCacheRenderer', () => {
|
|
433
|
+
it('does nothing when no cache is attached to the source', () => {
|
|
434
|
+
const state = fakeScreen();
|
|
435
|
+
wgpuRenderCacheRenderer.submit(state, makeCacheNode(createDisplayObject()));
|
|
436
|
+
expect(renderWgpu.drawWgpuTextureRenderTargetResult).not.toHaveBeenCalled();
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it('composites the cache target attached to the source node', () => {
|
|
440
|
+
const state = fakeScreen();
|
|
441
|
+
const obj = createDisplayObject();
|
|
442
|
+
const cache = createRenderCache();
|
|
443
|
+
useRenderCache(state, obj, cache);
|
|
444
|
+
const target = ensureWgpuRenderCacheTarget(state, cache, 16, 16);
|
|
445
|
+
wgpuRenderCacheRenderer.submit(state, makeCacheNode(obj));
|
|
446
|
+
expect(renderWgpu.drawWgpuTextureRenderTargetResult).toHaveBeenCalledWith(
|
|
447
|
+
state,
|
|
448
|
+
expect.anything(),
|
|
449
|
+
target,
|
|
450
|
+
expect.anything(),
|
|
451
|
+
);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it('flushes pending batched geometry before the immediate composite', () => {
|
|
455
|
+
const state = fakeScreen();
|
|
456
|
+
const obj = createDisplayObject();
|
|
457
|
+
const cache = createRenderCache();
|
|
458
|
+
useRenderCache(state, obj, cache);
|
|
459
|
+
ensureWgpuRenderCacheTarget(state, cache, 16, 16);
|
|
460
|
+
wgpuRenderCacheRenderer.submit(state, makeCacheNode(obj));
|
|
461
|
+
// The composite draws an immediate quad outside the quad-batch writer; geometry submitted earlier in
|
|
462
|
+
// the walk must be drained first, or the immediate quad interleaves with the un-flushed batch's
|
|
463
|
+
// instance buffer and bind-group state and corrupts it.
|
|
464
|
+
expect(wgpuQuadBatchWriter.flushWgpuQuadBatchWriter).toHaveBeenCalledWith(state);
|
|
465
|
+
expect((wgpuQuadBatchWriter.flushWgpuQuadBatchWriter as any).mock.invocationCallOrder[0]).toBeLessThan(
|
|
466
|
+
(renderWgpu.drawWgpuTextureRenderTargetResult as any).mock.invocationCallOrder[0],
|
|
467
|
+
);
|
|
468
|
+
});
|
|
469
|
+
});
|
package/src/wgpuClip.test.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { createMatrix } from '@flighthq/geometry/contract';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
beginWgpuScreenRenderPassForTest,
|
|
4
|
+
createWgpuRenderStateForTest,
|
|
5
|
+
getWgpuRenderStateRuntime,
|
|
6
|
+
installWgpuMock,
|
|
7
|
+
} from '@flighthq/render-wgpu/contract';
|
|
8
|
+
import type { WgpuRenderPassEncoder, WgpuRenderState } from '@flighthq/render-wgpu/contract';
|
|
5
9
|
|
|
6
|
-
import { popWgpuClipContours, pushWgpuClipContours } from './wgpuClipContours';
|
|
10
|
+
import { popWgpuClipContours, pushWgpuClipContours } from './wgpuClipContours.ts';
|
|
7
11
|
|
|
8
12
|
beforeAll(() => {
|
|
9
13
|
installWgpuMock();
|
|
@@ -11,18 +15,21 @@ beforeAll(() => {
|
|
|
11
15
|
|
|
12
16
|
const SQUARE = [[0, 0, 50, 0, 50, 50, 0, 50]];
|
|
13
17
|
|
|
14
|
-
function makePassSpy():
|
|
18
|
+
function makePassSpy(): WgpuRenderPassEncoder {
|
|
15
19
|
return {
|
|
16
20
|
setPipeline: vi.fn(),
|
|
17
21
|
setBindGroup: vi.fn(),
|
|
18
22
|
setVertexBuffer: vi.fn(),
|
|
19
23
|
setStencilReference: vi.fn(),
|
|
20
24
|
draw: vi.fn(),
|
|
21
|
-
} as unknown as
|
|
25
|
+
} as unknown as WgpuRenderPassEncoder;
|
|
22
26
|
}
|
|
23
27
|
|
|
28
|
+
// A real screen pass, with its encoder swapped for a spy: the draw path reads the pass viewport for its
|
|
29
|
+
// projection, so a state with only a fake encoder attached has no coordinate space to draw into.
|
|
24
30
|
async function makeState(): Promise<WgpuRenderState> {
|
|
25
31
|
const state = await createWgpuRenderStateForTest();
|
|
32
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
26
33
|
getWgpuRenderStateRuntime(state).renderPass = makePassSpy();
|
|
27
34
|
return state;
|
|
28
35
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
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
|
|
|
5
|
-
import { popWgpuClipRectangle, pushWgpuClipRectangle } from './wgpuClipRectangle';
|
|
5
|
+
import { popWgpuClipRectangle, pushWgpuClipRectangle } from './wgpuClipRectangle.ts';
|
|
6
6
|
|
|
7
7
|
beforeAll(() => {
|
|
8
8
|
installWgpuMock();
|
|
@@ -11,7 +11,7 @@ beforeAll(() => {
|
|
|
11
11
|
describe('popWgpuClipRectangle', () => {
|
|
12
12
|
it('pops the scissor rect from the stack', async () => {
|
|
13
13
|
const state = await createWgpuRenderStateForTest();
|
|
14
|
-
|
|
14
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
15
15
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
16
16
|
|
|
17
17
|
pushWgpuClipRectangle(state, { x: 0, y: 0, width: 50, height: 50 }, { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 });
|
|
@@ -19,27 +19,27 @@ describe('popWgpuClipRectangle', () => {
|
|
|
19
19
|
|
|
20
20
|
expect(runtime.scissorStack.length).toBe(0);
|
|
21
21
|
expect(runtime.currentScissorRect).toBeNull();
|
|
22
|
-
|
|
22
|
+
submitWgpuFrame(state);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it('is safe to pop from empty stack', async () => {
|
|
26
26
|
const state = await createWgpuRenderStateForTest();
|
|
27
|
-
|
|
27
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
28
28
|
expect(() => popWgpuClipRectangle(state)).not.toThrow();
|
|
29
|
-
|
|
29
|
+
submitWgpuFrame(state);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
describe('pushWgpuClipRectangle', () => {
|
|
34
34
|
it('pushes a scissor rect onto the stack', async () => {
|
|
35
35
|
const state = await createWgpuRenderStateForTest();
|
|
36
|
-
|
|
36
|
+
beginWgpuScreenRenderPassForTest(state);
|
|
37
37
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
38
38
|
|
|
39
39
|
pushWgpuClipRectangle(state, { x: 10, y: 10, width: 100, height: 100 }, { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 });
|
|
40
40
|
|
|
41
41
|
expect(runtime.scissorStack.length).toBe(1);
|
|
42
42
|
expect(runtime.currentScissorRect).not.toBeNull();
|
|
43
|
-
|
|
43
|
+
submitWgpuFrame(state);
|
|
44
44
|
});
|
|
45
45
|
});
|