@flighthq/scene2d-wgpu 0.5.1-next.920.da8f530 → 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.
Files changed (194) hide show
  1. package/README.md +2 -2
  2. package/dist/.tsbuildinfo.contract +1 -0
  3. package/dist/.tsbuildinfo.runtime +1 -0
  4. package/dist/contract.d.ts +32 -34
  5. package/dist/contract.d.ts.map +1 -1
  6. package/dist/contract.js +32 -34
  7. package/dist/contract.js.map +1 -1
  8. package/dist/contract.scene2d-wgpu-types.d.ts +6 -0
  9. package/dist/contract.scene2d-wgpu-types.d.ts.map +1 -0
  10. package/dist/contract.scene2d-wgpu-types.js +2 -0
  11. package/dist/contract.scene2d-wgpu-types.js.map +1 -0
  12. package/dist/enableWgpuColorAdjustmentGuards.d.ts +3 -2
  13. package/dist/enableWgpuColorAdjustmentGuards.d.ts.map +1 -1
  14. package/dist/enableWgpuColorAdjustmentGuards.js +23 -14
  15. package/dist/enableWgpuColorAdjustmentGuards.js.map +1 -1
  16. package/dist/enableWgpuStrokePathTessellation.d.ts +1 -1
  17. package/dist/enableWgpuStrokePathTessellation.d.ts.map +1 -1
  18. package/dist/enableWgpuStrokePathTessellation.js +1 -6
  19. package/dist/enableWgpuStrokePathTessellation.js.map +1 -1
  20. package/dist/index.d.ts +23 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +23 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/scene2DWgpuPipeline.d.ts +13 -0
  25. package/dist/scene2DWgpuPipeline.d.ts.map +1 -0
  26. package/dist/scene2DWgpuPipeline.js +59 -0
  27. package/dist/scene2DWgpuPipeline.js.map +1 -0
  28. package/dist/types/WgpuColorAdjustmentMaterialFeature.d.ts +2 -0
  29. package/dist/types/WgpuColorAdjustmentMaterialFeature.d.ts.map +1 -0
  30. package/dist/types/WgpuColorAdjustmentMaterialFeature.js +2 -0
  31. package/dist/types/WgpuColorAdjustmentMaterialFeature.js.map +1 -0
  32. package/dist/types/WgpuRenderStats.d.ts +12 -0
  33. package/dist/types/WgpuRenderStats.d.ts.map +1 -0
  34. package/dist/types/WgpuRenderStats.js +2 -0
  35. package/dist/types/WgpuRenderStats.js.map +1 -0
  36. package/dist/types/WgpuRichTextOverlay.d.ts +4 -0
  37. package/dist/types/WgpuRichTextOverlay.d.ts.map +1 -0
  38. package/dist/types/WgpuRichTextOverlay.js +2 -0
  39. package/dist/types/WgpuRichTextOverlay.js.map +1 -0
  40. package/dist/types/WgpuShapeMesh.d.ts +2 -0
  41. package/dist/types/WgpuShapeMesh.d.ts.map +1 -0
  42. package/dist/types/WgpuShapeMesh.js +2 -0
  43. package/dist/types/WgpuShapeMesh.js.map +1 -0
  44. package/dist/types/WgpuShapeRendererData.d.ts +17 -0
  45. package/dist/types/WgpuShapeRendererData.d.ts.map +1 -0
  46. package/dist/types/WgpuShapeRendererData.js +2 -0
  47. package/dist/types/WgpuShapeRendererData.js.map +1 -0
  48. package/dist/wgpuBitmapText.d.ts +2 -2
  49. package/dist/wgpuBitmapText.d.ts.map +1 -1
  50. package/dist/wgpuBitmapText.js +20 -19
  51. package/dist/wgpuBitmapText.js.map +1 -1
  52. package/dist/wgpuCache.d.ts +9 -6
  53. package/dist/wgpuCache.d.ts.map +1 -1
  54. package/dist/wgpuCache.js +17 -18
  55. package/dist/wgpuCache.js.map +1 -1
  56. package/dist/wgpuClip.d.ts +1 -1
  57. package/dist/wgpuClip.d.ts.map +1 -1
  58. package/dist/wgpuClip.js +2 -2
  59. package/dist/wgpuClip.js.map +1 -1
  60. package/dist/wgpuClipContours.d.ts +3 -1
  61. package/dist/wgpuClipContours.d.ts.map +1 -1
  62. package/dist/wgpuClipContours.js +7 -8
  63. package/dist/wgpuClipContours.js.map +1 -1
  64. package/dist/wgpuClipRectangle.d.ts +2 -1
  65. package/dist/wgpuClipRectangle.d.ts.map +1 -1
  66. package/dist/wgpuClipRectangle.js +4 -5
  67. package/dist/wgpuClipRectangle.js.map +1 -1
  68. package/dist/wgpuColorAdjustmentMaterialFeature.d.ts +1 -1
  69. package/dist/wgpuColorAdjustmentMaterialFeature.d.ts.map +1 -1
  70. package/dist/wgpuColorAdjustmentMaterialFeature.js +9 -13
  71. package/dist/wgpuColorAdjustmentMaterialFeature.js.map +1 -1
  72. package/dist/wgpuMeshShapeRenderer.d.ts +3 -2
  73. package/dist/wgpuMeshShapeRenderer.d.ts.map +1 -1
  74. package/dist/wgpuMeshShapeRenderer.js +9 -8
  75. package/dist/wgpuMeshShapeRenderer.js.map +1 -1
  76. package/dist/wgpuNode2D.d.ts +6 -3
  77. package/dist/wgpuNode2D.d.ts.map +1 -1
  78. package/dist/wgpuNode2D.js +20 -4
  79. package/dist/wgpuNode2D.js.map +1 -1
  80. package/dist/wgpuParticleEmitter2D.d.ts +4 -2
  81. package/dist/wgpuParticleEmitter2D.d.ts.map +1 -1
  82. package/dist/wgpuParticleEmitter2D.js +26 -14
  83. package/dist/wgpuParticleEmitter2D.js.map +1 -1
  84. package/dist/wgpuQuadBatch.d.ts +3 -3
  85. package/dist/wgpuQuadBatch.d.ts.map +1 -1
  86. package/dist/wgpuQuadBatch.js +29 -25
  87. package/dist/wgpuQuadBatch.js.map +1 -1
  88. package/dist/wgpuQuadBatchWriter.d.ts +11 -5
  89. package/dist/wgpuQuadBatchWriter.d.ts.map +1 -1
  90. package/dist/wgpuQuadBatchWriter.js +45 -19
  91. package/dist/wgpuQuadBatchWriter.js.map +1 -1
  92. package/dist/wgpuRasterShapeRenderer.d.ts +3 -2
  93. package/dist/wgpuRasterShapeRenderer.d.ts.map +1 -1
  94. package/dist/wgpuRasterShapeRenderer.js +49 -35
  95. package/dist/wgpuRasterShapeRenderer.js.map +1 -1
  96. package/dist/wgpuRenderStats.d.ts +2 -1
  97. package/dist/wgpuRenderStats.d.ts.map +1 -1
  98. package/dist/wgpuRenderStats.js.map +1 -1
  99. package/dist/wgpuRendererData.d.ts +2 -1
  100. package/dist/wgpuRendererData.d.ts.map +1 -1
  101. package/dist/wgpuRendererData.js +1 -1
  102. package/dist/wgpuRendererData.js.map +1 -1
  103. package/dist/wgpuRichText.d.ts +6 -3
  104. package/dist/wgpuRichText.d.ts.map +1 -1
  105. package/dist/wgpuRichText.js +67 -34
  106. package/dist/wgpuRichText.js.map +1 -1
  107. package/dist/wgpuScale9Mapper.d.ts +2 -1
  108. package/dist/wgpuScale9Mapper.d.ts.map +1 -1
  109. package/dist/wgpuScale9Mapper.js.map +1 -1
  110. package/dist/wgpuScale9Shape.d.ts +10 -5
  111. package/dist/wgpuScale9Shape.d.ts.map +1 -1
  112. package/dist/wgpuScale9Shape.js +54 -28
  113. package/dist/wgpuScale9Shape.js.map +1 -1
  114. package/dist/wgpuScale9Sprite.d.ts +3 -2
  115. package/dist/wgpuScale9Sprite.d.ts.map +1 -1
  116. package/dist/wgpuScale9Sprite.js +30 -36
  117. package/dist/wgpuScale9Sprite.js.map +1 -1
  118. package/dist/wgpuShape.d.ts +4 -3
  119. package/dist/wgpuShape.d.ts.map +1 -1
  120. package/dist/wgpuShape.js +7 -7
  121. package/dist/wgpuShape.js.map +1 -1
  122. package/dist/wgpuShapeData.d.ts +8 -3
  123. package/dist/wgpuShapeData.d.ts.map +1 -1
  124. package/dist/wgpuShapeData.js +12 -9
  125. package/dist/wgpuShapeData.js.map +1 -1
  126. package/dist/wgpuShapeMesh.d.ts +4 -2
  127. package/dist/wgpuShapeMesh.d.ts.map +1 -1
  128. package/dist/wgpuShapeMesh.js +9 -8
  129. package/dist/wgpuShapeMesh.js.map +1 -1
  130. package/dist/wgpuShapeRasterizer.d.ts +2 -1
  131. package/dist/wgpuShapeRasterizer.d.ts.map +1 -1
  132. package/dist/wgpuShapeRasterizer.js +3 -8
  133. package/dist/wgpuShapeRasterizer.js.map +1 -1
  134. package/dist/wgpuSprite.d.ts +3 -2
  135. package/dist/wgpuSprite.d.ts.map +1 -1
  136. package/dist/wgpuSprite.js +17 -32
  137. package/dist/wgpuSprite.js.map +1 -1
  138. package/dist/wgpuStandardMaterial.d.ts +2 -2
  139. package/dist/wgpuStandardMaterial.d.ts.map +1 -1
  140. package/dist/wgpuStandardMaterial.js +5 -5
  141. package/dist/wgpuStandardMaterial.js.map +1 -1
  142. package/dist/wgpuTextInput.d.ts +2 -1
  143. package/dist/wgpuTextInput.d.ts.map +1 -1
  144. package/dist/wgpuTextInput.js +6 -7
  145. package/dist/wgpuTextInput.js.map +1 -1
  146. package/dist/wgpuTextLabel.d.ts +3 -2
  147. package/dist/wgpuTextLabel.d.ts.map +1 -1
  148. package/dist/wgpuTextLabel.js +68 -48
  149. package/dist/wgpuTextLabel.js.map +1 -1
  150. package/dist/wgpuTilemap.d.ts +2 -2
  151. package/dist/wgpuTilemap.d.ts.map +1 -1
  152. package/dist/wgpuTilemap.js +20 -19
  153. package/dist/wgpuTilemap.js.map +1 -1
  154. package/dist/wgpuVelocity.d.ts +10 -7
  155. package/dist/wgpuVelocity.d.ts.map +1 -1
  156. package/dist/wgpuVelocity.js +95 -90
  157. package/dist/wgpuVelocity.js.map +1 -1
  158. package/package.json +31 -24
  159. package/src/contract.test.ts +13 -0
  160. package/src/enableWgpuColorAdjustmentGuards.test.ts +50 -28
  161. package/src/enableWgpuStrokePathTessellation.test.ts +4 -9
  162. package/src/scene2DWgpuPipeline.test.ts +53 -0
  163. package/src/wgpuBitmapText.test.ts +10 -10
  164. package/src/wgpuCache.test.ts +130 -168
  165. package/src/wgpuClip.test.ts +1 -1
  166. package/src/wgpuClipContours.test.ts +13 -6
  167. package/src/wgpuClipRectangle.test.ts +8 -8
  168. package/src/wgpuColorAdjustmentMaterialFeature.test.ts +20 -19
  169. package/src/wgpuMeshShapeRenderer.test.ts +51 -52
  170. package/src/wgpuNode2D.test.ts +14 -14
  171. package/src/wgpuParticleEmitter2D.test.ts +99 -38
  172. package/src/wgpuQuadBatch.test.ts +126 -32
  173. package/src/wgpuQuadBatchWriter.test.ts +108 -34
  174. package/src/wgpuRasterShapeRenderer.test.ts +95 -57
  175. package/src/wgpuRenderStats.test.ts +1 -1
  176. package/src/wgpuRendererData.test.ts +2 -2
  177. package/src/wgpuRichText.test.ts +109 -58
  178. package/src/wgpuScale9Mapper.test.ts +1 -1
  179. package/src/wgpuScale9Shape.test.ts +103 -62
  180. package/src/wgpuScale9Sprite.test.ts +38 -41
  181. package/src/wgpuShape.test.ts +111 -76
  182. package/src/wgpuShapeData.test.ts +96 -53
  183. package/src/wgpuShapeMesh.test.ts +39 -25
  184. package/src/wgpuShapeRasterizer.test.ts +11 -7
  185. package/src/wgpuSprite.test.ts +67 -24
  186. package/src/wgpuStandardMaterial.test.ts +9 -13
  187. package/src/wgpuTextInput.test.ts +9 -6
  188. package/src/wgpuTextLabel.test.ts +145 -88
  189. package/src/wgpuTilemap.test.ts +11 -11
  190. package/src/wgpuVelocity.test.ts +86 -86
  191. package/dist/scene2dWgpuPipeline.d.ts +0 -3
  192. package/dist/scene2dWgpuPipeline.d.ts.map +0 -1
  193. package/dist/scene2dWgpuPipeline.js +0 -40
  194. package/dist/scene2dWgpuPipeline.js.map +0 -1
@@ -1,40 +1,41 @@
1
1
  import { computeRgbaCssString } from '@flighthq/color/contract';
2
2
  import { invalidateImageResource } from '@flighthq/image/contract';
3
3
  import { getNodeLocalContentRevision } from '@flighthq/node/contract';
4
- import { bindWgpuImageResourceTexture, resolveWgpuMaterialRenderer } from '@flighthq/render-wgpu/contract';
4
+ import { bindWgpuImageResourceTexture, resolveWgpuQuadMaterialRenderer } from '@flighthq/render-wgpu/contract';
5
5
  import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu/contract';
6
- import { createRaster2DSurface, destroyRaster2DSurface } from '@flighthq/render/contract';
7
- import { computeTextFormatFontString } from '@flighthq/text/contract';
8
- import { getTextLabelRuntime } from '@flighthq/text/contract';
9
- import { computeTextLayout, createTextFormatRange, getTextLayoutResult } from '@flighthq/textlayout/contract';
10
- import { BatchFormat } from '@flighthq/types/contract';
11
- import { QUAD_BATCH_INSTANCE_FLOATS, ensureWgpuQuadBatchResources, packWgpuQuadBatchMaterialInstance, prepareWgpuQuadBatchWrite, recordWgpuQuadBatchColorScaleBias, } from './wgpuQuadBatchWriter';
12
- import { createWgpuRendererData, getWgpuRendererData } from './wgpuRendererData';
6
+ import { createCanvasHostSurface, destroyCanvasHostSurface, BatchFormat } from '@flighthq/render/contract';
7
+ import { computeTextFormatFontString, getTextLabelRuntime, getTextLayoutResult } from '@flighthq/text/contract';
8
+ import { createTextFormatRange } from '@flighthq/textformat/contract';
9
+ import { computeTextLayout } from '@flighthq/textlayout/contract';
10
+ import { QUAD_BATCH_INSTANCE_FLOATS, ensureWgpuQuadBatchResources, packWgpuQuadBatchMaterialInstance, prepareWgpuQuadBatchWrite, recordWgpuQuadBatchColorScaleBias, writeWgpuQuadBatchInstance, } from './wgpuQuadBatchWriter.js';
11
+ import { createWgpuRendererData, getWgpuRendererData } from './wgpuRendererData.js';
13
12
  function createWgpuTextLabelData(_state, _source) {
14
13
  return createWgpuRendererData({
15
- surface: null,
14
+ allocH: 0,
15
+ allocW: 0,
16
+ image: null,
16
17
  lastContentId: -1,
17
18
  lastPixelRatio: 0,
18
- logW: 0,
19
19
  logH: 0,
20
+ logW: 0,
21
+ surface: null,
20
22
  });
21
23
  }
22
- // Remove the GPU cache entry while its Image key is still valid, then return the raster allocation to
23
- // the provider that created it. A node that never rasterized owns neither resource.
24
24
  function destroyWgpuTextLabelData(state, data) {
25
25
  const runtime = getWgpuRenderStateRuntime(state);
26
26
  const textLabelData = getWgpuRendererData(data);
27
27
  if (textLabelData === null)
28
28
  return;
29
- const { surface } = textLabelData;
30
- if (surface === null)
31
- return;
32
- const entry = runtime.context.textureSourcePremultipliedTextureCache.get(surface.image);
33
- if (entry !== undefined) {
34
- entry.texture.destroy();
35
- runtime.context.textureSourcePremultipliedTextureCache.delete(surface.image);
29
+ const { image, surface } = textLabelData;
30
+ if (image !== null) {
31
+ const entry = runtime.context.textureSourcePremultipliedTextureCache.get(image);
32
+ if (entry !== undefined) {
33
+ entry.texture.destroy();
34
+ runtime.context.textureSourcePremultipliedTextureCache.delete(image);
35
+ }
36
36
  }
37
- destroyRaster2DSurface(surface);
37
+ if (surface !== null)
38
+ destroyCanvasHostSurface(surface);
38
39
  }
39
40
  export function drawWgpuTextLabel(state, renderProxy) {
40
41
  const runtime = getWgpuRenderStateRuntime(state);
@@ -47,15 +48,15 @@ export function drawWgpuTextLabel(state, renderProxy) {
47
48
  if (renderProxy.rendererData === null)
48
49
  return;
49
50
  const material = renderProxy.material;
50
- const materialRenderer = resolveWgpuMaterialRenderer(state, material);
51
+ const materialRenderer = resolveWgpuQuadMaterialRenderer(state, material);
51
52
  if (materialRenderer === null)
52
53
  return;
53
- if (state.raster2DSurfaceProvider === null)
54
+ if (state.canvasHost === null || state.imageHost === null)
54
55
  return;
55
56
  const textData = getWgpuRendererData(renderProxy.rendererData);
56
57
  if (textData === null)
57
58
  return;
58
- const surface = acquireWgpuTextLabelRasterSurface(state.raster2DSurfaceProvider, textData);
59
+ let surface = textData.surface ?? _ensureWgpuTextLabelSurface(state, textData, 1, 1);
59
60
  if (surface === null)
60
61
  return;
61
62
  const maxTexDim = state.device.limits.maxTextureDimension2D;
@@ -98,8 +99,9 @@ export function drawWgpuTextLabel(state, renderProxy) {
98
99
  return;
99
100
  const pw = Math.ceil(w * pixelRatio);
100
101
  const ph = Math.ceil(h * pixelRatio);
101
- surface.width = pw;
102
- surface.height = ph;
102
+ surface = _ensureWgpuTextLabelSurface(state, textData, pw, ph);
103
+ if (surface === null)
104
+ return;
103
105
  const ctx = surface.context;
104
106
  ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
105
107
  ctx.clearRect(0, 0, w, h);
@@ -111,51 +113,69 @@ export function drawWgpuTextLabel(state, renderProxy) {
111
113
  const slice = text.substring(group.startIndex, group.endIndex);
112
114
  ctx.fillText(slice, group.offsetX, group.offsetY + group.ascent * 0.815);
113
115
  }
114
- // Bump the resource version so the batch's version-aware cache re-uploads (recreating the GPU texture,
115
- // which covers a physical-size change too).
116
- invalidateImageResource(surface.image);
116
+ if (textData.image !== null)
117
+ invalidateImageResource(textData.image);
117
118
  textData.logW = w;
118
119
  textData.logH = h;
119
120
  }
120
121
  if (textData.logW <= 0 || textData.logH <= 0)
121
122
  return;
122
123
  ensureWgpuQuadBatchResources(state);
123
- const textureEntry = bindWgpuImageResourceTexture(state, surface.image, false, true);
124
+ if (textData.image === null)
125
+ return;
126
+ const textureEntry = bindWgpuImageResourceTexture(state, textData.image, false, true);
124
127
  if (textureEntry === null)
125
128
  return;
126
129
  const startInstance = prepareWgpuQuadBatchWrite(state, textureEntry, null, renderProxy.blendMode, material, materialRenderer, 1);
127
130
  const base = startInstance * QUAD_BATCH_INSTANCE_FLOATS;
128
131
  const d = runtime.quadBatchWriterInstanceData;
129
132
  const t = renderProxy.transform2D;
130
- d[base] = t.a;
131
- d[base + 1] = t.b;
132
- d[base + 2] = t.c;
133
- d[base + 3] = t.d;
134
- d[base + 4] = t.tx;
135
- d[base + 5] = t.ty;
136
- d[base + 6] = textData.logW;
137
- d[base + 7] = textData.logH;
138
- d[base + 8] = 0;
139
- d[base + 9] = 0;
140
- d[base + 10] = 1;
141
- d[base + 11] = 1;
142
- d[base + 12] = renderProxy.alpha;
133
+ writeWgpuQuadBatchInstance(d, base, t, textData.logW, textData.logH, 0, 0, 1, 1, renderProxy.alpha);
143
134
  packWgpuQuadBatchMaterialInstance(state, renderProxy.materialData, startInstance);
144
135
  recordWgpuQuadBatchColorScaleBias(state, renderProxy.colorMatrix ?? renderProxy.colorScaleBias, startInstance);
145
136
  runtime.quadBatchWriterCount++;
146
137
  }
147
- export const defaultWgpuTextLabelRenderer = {
138
+ export const wgpuTextLabelRenderer = {
148
139
  format: BatchFormat.Quad,
149
140
  createData: createWgpuTextLabelData,
150
141
  destroyData: destroyWgpuTextLabelData,
151
142
  submit: drawWgpuTextLabel,
152
143
  };
153
- function acquireWgpuTextLabelRasterSurface(provider, data) {
154
- if (data.surface !== null)
144
+ function _ensureWgpuTextLabelSurface(state, data, pw, ph) {
145
+ if (data.surface !== null && data.allocW === pw && data.allocH === ph)
155
146
  return data.surface;
156
- const surface = createRaster2DSurface(provider, 1, 1);
157
- if (surface !== null)
158
- data.surface = surface;
147
+ if (data.surface !== null) {
148
+ if (data.image !== null) {
149
+ const cache = getWgpuRenderStateRuntime(state).context.textureSourcePremultipliedTextureCache;
150
+ const entry = cache.get(data.image);
151
+ if (entry !== undefined) {
152
+ entry.texture.destroy();
153
+ cache.delete(data.image);
154
+ }
155
+ }
156
+ destroyCanvasHostSurface(data.surface);
157
+ }
158
+ const canvasHost = state.canvasHost;
159
+ const imageHost = state.imageHost;
160
+ if (canvasHost === null || imageHost === null) {
161
+ data.surface = null;
162
+ data.image = null;
163
+ data.allocW = 0;
164
+ data.allocH = 0;
165
+ return null;
166
+ }
167
+ const surface = createCanvasHostSurface(canvasHost, pw, ph);
168
+ if (surface === null) {
169
+ data.surface = null;
170
+ data.image = null;
171
+ data.allocW = 0;
172
+ data.allocH = 0;
173
+ return null;
174
+ }
175
+ data.surface = surface;
176
+ data.image = imageHost.createImageFromSurface?.(surface) ?? null;
177
+ data.allocW = pw;
178
+ data.allocH = ph;
159
179
  return surface;
160
180
  }
161
181
  //# sourceMappingURL=wgpuTextLabel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wgpuTextLabel.js","sourceRoot":"","sources":["../src/wgpuTextLabel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC3G,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,2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AAE,EAAE,CAAC,CAAC;IAC5D,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,sBAAsB,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IACjE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACjB,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,3 +1,3 @@
1
- import type { SpriteRenderer } from '@flighthq/types/contract';
2
- export declare const defaultWgpuTilemapRenderer: SpriteRenderer;
1
+ import type { SpriteRenderer } from '@flighthq/render/contract';
2
+ export declare const wgpuTilemapRenderer: SpriteRenderer;
3
3
  //# sourceMappingURL=wgpuTilemap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wgpuTilemap.d.ts","sourceRoot":"","sources":["../src/wgpuTilemap.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,cAAc,EAIf,MAAM,0BAA0B,CAAC;AAsGlC,eAAO,MAAM,0BAA0B,EAAE,cAIxC,CAAC"}
1
+ {"version":3,"file":"wgpuTilemap.d.ts","sourceRoot":"","sources":["../src/wgpuTilemap.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAsHhE,eAAO,MAAM,mBAAmB,EAAE,cAIjC,CAAC"}
@@ -1,10 +1,10 @@
1
- import { resolveWgpuMaterialRenderer, resolveWgpuTexture } from '@flighthq/render-wgpu/contract';
1
+ import { resolveWgpuQuadMaterialRenderer, resolveWgpuTexture } from '@flighthq/render-wgpu/contract';
2
2
  import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu/contract';
3
- import { SCENE2D_WORKING_COLOR_SPACE } from '@flighthq/render/contract';
3
+ import { SCENE2D_WORKING_COLOR_SPACE, BatchFormat } from '@flighthq/render/contract';
4
4
  import { noopRendererData } from '@flighthq/render/contract';
5
5
  import { getTextureHeight, getTextureWidth, hasTextureSource } from '@flighthq/texture/contract';
6
- import { BatchFormat } from '@flighthq/types/contract';
7
- import { packWgpuQuadBatchMaterialInstance, prepareWgpuQuadBatchWrite, recordWgpuQuadBatchColorScaleBias, QUAD_BATCH_INSTANCE_FLOATS, } from './wgpuQuadBatchWriter';
6
+ import { TextureAtlasRotation } from '@flighthq/textureatlas/contract';
7
+ import { packWgpuQuadBatchMaterialInstance, prepareWgpuQuadBatchWrite, recordWgpuQuadBatchColorScaleBias, writeWgpuQuadBatchAffineInstance, QUAD_BATCH_INSTANCE_FLOATS, } from './wgpuQuadBatchWriter.js';
8
8
  // Each tile writes the 13 base instance floats; any material packs its own per-instance data.
9
9
  const INSTANCE_STRIDE_FLOATS = QUAD_BATCH_INSTANCE_FLOATS;
10
10
  function submitWgpuTilemap(state, tilemapNode) {
@@ -18,7 +18,7 @@ function submitWgpuTilemap(state, tilemapNode) {
18
18
  if (columns === 0 || rows === 0)
19
19
  return;
20
20
  const material = tilemapNode.material;
21
- const materialRenderer = resolveWgpuMaterialRenderer(state, material);
21
+ const materialRenderer = resolveWgpuQuadMaterialRenderer(state, material);
22
22
  if (materialRenderer === null)
23
23
  return;
24
24
  const texture = atlas.texture;
@@ -52,19 +52,19 @@ function submitWgpuTilemap(state, tilemapNode) {
52
52
  continue;
53
53
  const dx = col * tileWidth;
54
54
  const dy = row * tileHeight;
55
- instanceData[writeBase] = pa;
56
- instanceData[writeBase + 1] = pb;
57
- instanceData[writeBase + 2] = pc;
58
- instanceData[writeBase + 3] = pd;
59
- instanceData[writeBase + 4] = pa * dx + pc * dy + ptx;
60
- instanceData[writeBase + 5] = pb * dx + pd * dy + pty;
61
- instanceData[writeBase + 6] = tileWidth;
62
- instanceData[writeBase + 7] = tileHeight;
63
- instanceData[writeBase + 8] = region.x * iw;
64
- instanceData[writeBase + 9] = region.y * ih;
65
- instanceData[writeBase + 10] = (region.x + region.width) * iw;
66
- instanceData[writeBase + 11] = (region.y + region.height) * ih;
67
- instanceData[writeBase + 12] = alpha;
55
+ tileTransform.a = pa;
56
+ tileTransform.b = pb;
57
+ tileTransform.c = pc;
58
+ tileTransform.d = pd;
59
+ tileTransform.tx = pa * dx + pc * dy + ptx;
60
+ tileTransform.ty = pb * dx + pd * dy + pty;
61
+ const u0 = region.x * iw;
62
+ const v0 = region.y * ih;
63
+ const u1 = (region.x + region.width) * iw;
64
+ const v1 = (region.y + region.height) * ih;
65
+ const rotated = region.rotation !== TextureAtlasRotation.None;
66
+ const counterclockwise = region.rotation === TextureAtlasRotation.Counterclockwise90;
67
+ writeWgpuQuadBatchAffineInstance(instanceData, writeBase, tileTransform, tileWidth, tileHeight, rotated ? (counterclockwise ? u0 : u1) : u0, rotated && counterclockwise ? v1 : v0, rotated ? 0 : u1 - u0, rotated ? (counterclockwise ? v0 - v1 : v1 - v0) : 0, rotated ? (counterclockwise ? u1 - u0 : u0 - u1) : 0, rotated ? 0 : v1 - v0, alpha);
68
68
  packWgpuQuadBatchMaterialInstance(state, nodeMaterialData, startInstance + drawCount);
69
69
  // Per-tile tint overrides the node-level tint (null → the node's, itself possibly null → untinted).
70
70
  const colorScaleBias = perTileColorScaleBias?.[row * columns + col] ??
@@ -77,9 +77,10 @@ function submitWgpuTilemap(state, tilemapNode) {
77
77
  }
78
78
  runtime.quadBatchWriterCount += drawCount;
79
79
  }
80
- export const defaultWgpuTilemapRenderer = {
80
+ export const wgpuTilemapRenderer = {
81
81
  format: BatchFormat.Quad,
82
82
  createData: noopRendererData,
83
83
  submit: submitWgpuTilemap,
84
84
  };
85
+ const tileTransform = { a: 1, b: 0, c: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,GACjB,qBAAqB,EAAE,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,CAInC;gBACT,eAAe;gBACf,kBAAkB,CAAC;YACrB,iCAAiC,CAAC,KAAK,EAAE,cAAc,EAAE,aAAa,GAAG,SAAS,CAAC,CAAC;YACpF,SAAS,IAAI,sBAAsB,CAAC;YACpC,SAAS,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,CAAC,oBAAoB,IAAI,SAAS,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAmB;IACjD,MAAM,EAAE,WAAW,CAAC,IAAI;IACxB,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,iBAAiB;CAC1B,CAAC;AAEF,MAAM,aAAa,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC"}
@@ -1,9 +1,9 @@
1
- import type { Kind, Transform2DNode, VelocityField, WgpuRenderState, WgpuRenderTarget, WgpuVelocityContext, WgpuVelocityWriter } from '@flighthq/types/contract';
1
+ import type { Kind } from '@flighthq/entity/contract';
2
+ import type { Transform2DNode } from '@flighthq/node/contract';
3
+ import type { WgpuRenderState, WgpuTextureRenderTarget, WgpuVelocityContext, WgpuVelocityWriter } from '@flighthq/render-wgpu/contract';
4
+ import type { VelocityField } from '@flighthq/velocity/contract';
2
5
  /** Allocates an rgba16float render target sized to hold a signed, sub-pixel screen-space velocity buffer. */
3
- export declare function createWgpuVelocityTarget(state: WgpuRenderState, width: number, height: number): WgpuRenderTarget;
4
- export declare const defaultWgpuNode2DVelocityWriter: WgpuVelocityWriter;
5
- export declare const defaultWgpuParticleEmitter2DVelocityWriter: WgpuVelocityWriter;
6
- export declare const defaultWgpuQuadBatchVelocityWriter: WgpuVelocityWriter;
6
+ export declare function createWgpuVelocityTarget(state: WgpuRenderState, width: number, height: number): WgpuTextureRenderTarget;
7
7
  /**
8
8
  * Draws one velocity quad: a device-pixel rect (x, y, width, height) filled with (velocityX, velocityY) in
9
9
  * node units (scaled by pixelRatio here). The velocity pass must be active — renderWgpuVelocity sets it
@@ -17,7 +17,10 @@ export declare function registerWgpuVelocityWriter(state: WgpuRenderState, kind:
17
17
  * Walks `root`'s subtree and writes every moving renderable's velocity into `target`, dispatching the
18
18
  * registered WgpuVelocityWriter for each node's kind. Nodes whose kind has no writer are skipped; the
19
19
  * cleared (0,0,0,0) background means zero velocity. Runs inside the frame's command encoder (open one with
20
- * renderWgpuBackground first), as its own render pass; ends any pass currently open and leaves none open.
20
+ * a pass or beginWgpuFrame first), as its own render pass; the caller's pass is suspended and resumed.
21
21
  */
22
- export declare function renderWgpuVelocity<Traits extends object>(state: WgpuRenderState, root: Readonly<Transform2DNode<Traits>>, field: VelocityField, target: Readonly<WgpuRenderTarget>): void;
22
+ export declare function renderWgpuVelocity<Fields extends object>(state: WgpuRenderState, root: Readonly<Transform2DNode<Fields>>, field: VelocityField, target: Readonly<WgpuTextureRenderTarget>): void;
23
+ export declare const wgpuNode2DVelocityWriter: WgpuVelocityWriter;
24
+ export declare const wgpuParticleEmitter2DVelocityWriter: WgpuVelocityWriter;
25
+ export declare const wgpuQuadBatchVelocityWriter: WgpuVelocityWriter;
23
26
  //# sourceMappingURL=wgpuVelocity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wgpuVelocity.d.ts","sourceRoot":"","sources":["../src/wgpuVelocity.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,IAAI,EAKJ,eAAe,EAEf,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAgBlC,6GAA6G;AAC7G,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB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gB,wBAAwB,CACtC,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,uBAAuB,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAClC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,IAAI,CAuBN;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,GAAG,kBAAkB,GAAG,IAAI,CAGnG;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAM/G;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,SAAS,MAAM,EACtD,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,EACvC,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,GACxC,IAAI,CAkCN;AAID,eAAO,MAAM,wBAAwB,EAAE,kBAOtC,CAAC;AAWF,eAAO,MAAM,mCAAmC,EAAE,kBA8DjD,CAAC;AAUF,eAAO,MAAM,2BAA2B,EAAE,kBAqFzC,CAAC"}
@@ -1,7 +1,7 @@
1
+ import { EntityRuntimeKey } from '@flighthq/entity/contract';
1
2
  import { ensureNodeWorldBoundsRectangle, ensureNodeWorldMatrix, getNodeChildAt, getNodeChildCount, getNodeWorldBoundsRectangle, getNodeWorldMatrix, } from '@flighthq/node/contract';
2
- import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu/contract';
3
- import { createWgpuRenderTarget } from '@flighthq/render-wgpu/contract';
4
- import { EntityRuntimeKey, RegistryEntryState } from '@flighthq/types/contract';
3
+ import { WgpuBufferUsage, WgpuShaderStage, createWgpuTextureRenderTarget, getWgpuActiveRenderPass, getWgpuRenderStateRuntime, resumeWgpuRenderPass, suspendWgpuRenderPass, } from '@flighthq/render-wgpu/contract';
4
+ import { TextureAtlasRotation } from '@flighthq/textureatlas/contract';
5
5
  import { getVelocity } from '@flighthq/velocity/contract';
6
6
  // Wgpu velocity-buffer production, the mirror of scene2d-gl's webglVelocity. Velocity is tied to the
7
7
  // draw, so production is per-kind: the velocity pass walks the scene and dispatches a registered
@@ -16,11 +16,89 @@ import { getVelocity } from '@flighthq/velocity/contract';
16
16
  // top-left origin, y-down; drawWgpuVelocityQuad maps a rect into clip space, flipping y.
17
17
  /** Allocates an rgba16float render target sized to hold a signed, sub-pixel screen-space velocity buffer. */
18
18
  export function createWgpuVelocityTarget(state, width, height) {
19
- return createWgpuRenderTarget(state, width, height, 'rgba16float');
19
+ return createWgpuTextureRenderTarget(state, width, height, 'rgba16float');
20
+ }
21
+ /**
22
+ * Draws one velocity quad: a device-pixel rect (x, y, width, height) filled with (velocityX, velocityY) in
23
+ * node units (scaled by pixelRatio here). The velocity pass must be active — renderWgpuVelocity sets it
24
+ * up before dispatching writers; outside a velocity pass this is a no-op. Each draw consumes one uniform
25
+ * ring slot (clipRect + velocity) addressed by dynamic offset, mirroring the filter-pass ring.
26
+ */
27
+ export function drawWgpuVelocityQuad(ctx, x, y, width, height, velocityX, velocityY) {
28
+ const active = _activeVelocityPasses.get(ctx.state);
29
+ if (active === undefined)
30
+ return;
31
+ const pipeline = active.pipeline;
32
+ const clipX0 = (x / ctx.width) * 2 - 1;
33
+ const clipY0 = 1 - (y / ctx.height) * 2;
34
+ const clipWidth = (width / ctx.width) * 2;
35
+ const clipHeight = -((height / ctx.height) * 2);
36
+ const slot = pipeline.cursor;
37
+ pipeline.cursor = (slot + UNIFORM_STRIDE) % (UNIFORM_SLOTS * UNIFORM_STRIDE);
38
+ const scratch = pipeline.scratch;
39
+ scratch[0] = clipX0;
40
+ scratch[1] = clipY0;
41
+ scratch[2] = clipWidth;
42
+ scratch[3] = clipHeight;
43
+ scratch[4] = velocityX * ctx.pixelRatio;
44
+ scratch[5] = velocityY * ctx.pixelRatio;
45
+ ctx.state.device.queue.writeBuffer(pipeline.uniformBuffer, slot, scratch.buffer, 0, UNIFORM_BYTES);
46
+ active.pass.setBindGroup(0, pipeline.bindGroup, [slot]);
47
+ active.pass.draw(6);
48
+ }
49
+ export function getWgpuVelocityWriter(state, kind) {
50
+ const entry = getWgpuRenderStateRuntime(state).registries.velocityWriters.get(kind);
51
+ return entry ?? null;
52
+ }
53
+ export function registerWgpuVelocityWriter(state, kind, writer) {
54
+ const runtime = getWgpuRenderStateRuntime(state);
55
+ const table = runtime.registries.velocityWriters;
56
+ const entries = new Map(table);
57
+ entries.set(kind, writer);
58
+ runtime.registries.velocityWriters = entries;
59
+ }
60
+ /**
61
+ * Walks `root`'s subtree and writes every moving renderable's velocity into `target`, dispatching the
62
+ * registered WgpuVelocityWriter for each node's kind. Nodes whose kind has no writer are skipped; the
63
+ * cleared (0,0,0,0) background means zero velocity. Runs inside the frame's command encoder (open one with
64
+ * a pass or beginWgpuFrame first), as its own render pass; the caller's pass is suspended and resumed.
65
+ */
66
+ export function renderWgpuVelocity(state, root, field, target) {
67
+ const runtime = getWgpuRenderStateRuntime(state);
68
+ if (runtime.commandEncoder === null) {
69
+ throw new Error('No active command encoder — open a frame with beginWgpuRenderPass before renderWgpuVelocity.');
70
+ }
71
+ // The velocity buffer is written in its own pass over its own target, so the caller's pass steps aside
72
+ // for the duration and is resumed with its pixels intact.
73
+ const suspended = getWgpuActiveRenderPass(state);
74
+ if (suspended !== null)
75
+ suspendWgpuRenderPass(suspended);
76
+ const pipeline = ensureWgpuVelocityPipeline(state);
77
+ pipeline.cursor = 0;
78
+ const pass = runtime.commandEncoder.beginRenderPass({
79
+ colorAttachments: [
80
+ { view: target.view, loadOp: 'clear', storeOp: 'store', clearValue: { r: 0, g: 0, b: 0, a: 0 } },
81
+ ],
82
+ });
83
+ pass.setViewport(0, 0, target.width, target.height, 0, 1);
84
+ pass.setPipeline(pipeline.pipeline);
85
+ _activeVelocityPasses.set(state, { pass, pipeline });
86
+ const ctx = {
87
+ state,
88
+ field,
89
+ width: target.width,
90
+ height: target.height,
91
+ pixelRatio: state.pixelRatio,
92
+ };
93
+ visitWgpuVelocity(ctx, root);
94
+ pass.end();
95
+ _activeVelocityPasses.delete(state);
96
+ if (suspended !== null)
97
+ resumeWgpuRenderPass(suspended);
20
98
  }
21
99
  // The default writer for plain display-object nodes: cover the node's world bounds with its velocity.
22
100
  // Batched/instanced kinds (QuadBatch, particles) register a writer that emits per-instance velocity.
23
- export const defaultWgpuNode2DVelocityWriter = (ctx, node) => {
101
+ export const wgpuNode2DVelocityWriter = (ctx, node) => {
24
102
  getVelocity(ctx.field, node, _scratchVelocity);
25
103
  if (_scratchVelocity.x === 0 && _scratchVelocity.y === 0)
26
104
  return;
@@ -37,8 +115,8 @@ export const defaultWgpuNode2DVelocityWriter = (ctx, node) => {
37
115
  // mapped by the emitter world transform (skipped when worldSpace puts particles in world space already).
38
116
  // Velocity stays in node units; drawWgpuVelocityQuad applies pixelRatio (matching the other writers).
39
117
  // Skips particles with zero velocity and emitters without a populated velocities array. Mirrors
40
- // defaultGlParticleEmitter2DVelocityWriter.
41
- export const defaultWgpuParticleEmitter2DVelocityWriter = (ctx, node) => {
118
+ // glParticleEmitter2DVelocityWriter.
119
+ export const wgpuParticleEmitter2DVelocityWriter = (ctx, node) => {
42
120
  const emitter = node;
43
121
  const { atlas, ids, particleCount, transforms, velocities, worldSpace } = emitter.data;
44
122
  if (atlas === null || particleCount === 0 || velocities.length < particleCount * 2)
@@ -70,8 +148,9 @@ export const defaultWgpuParticleEmitter2DVelocityWriter = (ctx, node) => {
70
148
  if (id < 0 || id >= numRegions)
71
149
  continue;
72
150
  const region = regions[id];
73
- const rw = region.width;
74
- const rh = region.height;
151
+ const rotated = region.rotation !== TextureAtlasRotation.None;
152
+ const rw = rotated ? region.height : region.width;
153
+ const rh = rotated ? region.width : region.height;
75
154
  if (rw <= 0 || rh <= 0)
76
155
  continue;
77
156
  const tt = i * 4;
@@ -111,8 +190,8 @@ export const defaultWgpuParticleEmitter2DVelocityWriter = (ctx, node) => {
111
190
  // batch renderer composes it (batch world transform ∘ per-instance local transform, then axis-aligned
112
191
  // bounds). Velocity stays in node units; drawWgpuVelocityQuad applies pixelRatio. Fallback: when no
113
192
  // per-instance array is present, cover the batch's world bounds with one coarse field velocity, like the
114
- // Node2D writer. Identical math to defaultGlQuadBatchVelocityWriter.
115
- export const defaultWgpuQuadBatchVelocityWriter = (ctx, node) => {
193
+ // Node2D writer. Identical math to glQuadBatchVelocityWriter.
194
+ export const wgpuQuadBatchVelocityWriter = (ctx, node) => {
116
195
  const batch = node;
117
196
  const data = batch.data;
118
197
  const runtime = node[EntityRuntimeKey];
@@ -139,8 +218,9 @@ export const defaultWgpuQuadBatchVelocityWriter = (ctx, node) => {
139
218
  if (id < 0 || id >= numRegions)
140
219
  continue;
141
220
  const region = regions[id];
142
- const w = region.width;
143
- const h = region.height;
221
+ const rotated = region.rotation !== TextureAtlasRotation.None;
222
+ const w = rotated ? region.height : region.width;
223
+ const h = rotated ? region.width : region.height;
144
224
  if (w <= 0 || h <= 0)
145
225
  continue;
146
226
  let wa;
@@ -198,81 +278,6 @@ export const defaultWgpuQuadBatchVelocityWriter = (ctx, node) => {
198
278
  const bounds = getNodeWorldBoundsRectangle(spatial);
199
279
  drawWgpuVelocityQuad(ctx, bounds.x, bounds.y, bounds.width, bounds.height, _scratchVelocity.x, _scratchVelocity.y);
200
280
  };
201
- /**
202
- * Draws one velocity quad: a device-pixel rect (x, y, width, height) filled with (velocityX, velocityY) in
203
- * node units (scaled by pixelRatio here). The velocity pass must be active — renderWgpuVelocity sets it
204
- * up before dispatching writers; outside a velocity pass this is a no-op. Each draw consumes one uniform
205
- * ring slot (clipRect + velocity) addressed by dynamic offset, mirroring the filter-pass ring.
206
- */
207
- export function drawWgpuVelocityQuad(ctx, x, y, width, height, velocityX, velocityY) {
208
- const active = _activeVelocityPasses.get(ctx.state);
209
- if (active === undefined)
210
- return;
211
- const pipeline = active.pipeline;
212
- const clipX0 = (x / ctx.width) * 2 - 1;
213
- const clipY0 = 1 - (y / ctx.height) * 2;
214
- const clipWidth = (width / ctx.width) * 2;
215
- const clipHeight = -((height / ctx.height) * 2);
216
- const slot = pipeline.cursor;
217
- pipeline.cursor = (slot + UNIFORM_STRIDE) % (UNIFORM_SLOTS * UNIFORM_STRIDE);
218
- const scratch = pipeline.scratch;
219
- scratch[0] = clipX0;
220
- scratch[1] = clipY0;
221
- scratch[2] = clipWidth;
222
- scratch[3] = clipHeight;
223
- scratch[4] = velocityX * ctx.pixelRatio;
224
- scratch[5] = velocityY * ctx.pixelRatio;
225
- ctx.state.device.queue.writeBuffer(pipeline.uniformBuffer, slot, scratch.buffer, 0, UNIFORM_BYTES);
226
- active.pass.setBindGroup(0, pipeline.bindGroup, [slot]);
227
- active.pass.draw(6);
228
- }
229
- export function getWgpuVelocityWriter(state, kind) {
230
- const entry = getWgpuRenderStateRuntime(state).registries.velocityWriters.entries.get(kind);
231
- return entry?.state === RegistryEntryState.Bound ? entry.value : null;
232
- }
233
- export function registerWgpuVelocityWriter(state, kind, writer) {
234
- const runtime = getWgpuRenderStateRuntime(state);
235
- const table = runtime.registries.velocityWriters;
236
- const entries = new Map(table.entries);
237
- entries.set(kind, { state: RegistryEntryState.Bound, value: writer });
238
- runtime.registries.velocityWriters = { ...table, entries };
239
- }
240
- /**
241
- * Walks `root`'s subtree and writes every moving renderable's velocity into `target`, dispatching the
242
- * registered WgpuVelocityWriter for each node's kind. Nodes whose kind has no writer are skipped; the
243
- * cleared (0,0,0,0) background means zero velocity. Runs inside the frame's command encoder (open one with
244
- * renderWgpuBackground first), as its own render pass; ends any pass currently open and leaves none open.
245
- */
246
- export function renderWgpuVelocity(state, root, field, target) {
247
- const runtime = getWgpuRenderStateRuntime(state);
248
- if (runtime.commandEncoder === null) {
249
- throw new Error('No active command encoder — call renderWgpuBackground before renderWgpuVelocity.');
250
- }
251
- if (runtime.renderPass !== null) {
252
- runtime.renderPass.end();
253
- runtime.renderPass = null;
254
- }
255
- const pipeline = ensureWgpuVelocityPipeline(state);
256
- pipeline.cursor = 0;
257
- const pass = runtime.commandEncoder.beginRenderPass({
258
- colorAttachments: [
259
- { view: target.view, loadOp: 'clear', storeOp: 'store', clearValue: { r: 0, g: 0, b: 0, a: 0 } },
260
- ],
261
- });
262
- pass.setViewport(0, 0, target.width, target.height, 0, 1);
263
- pass.setPipeline(pipeline.pipeline);
264
- _activeVelocityPasses.set(state, { pass, pipeline });
265
- const ctx = {
266
- state,
267
- field,
268
- width: target.width,
269
- height: target.height,
270
- pixelRatio: state.pixelRatio,
271
- };
272
- visitWgpuVelocity(ctx, root);
273
- pass.end();
274
- _activeVelocityPasses.delete(state);
275
- }
276
281
  function ensureWgpuVelocityPipeline(state) {
277
282
  const existing = _velocityPipelines.get(state);
278
283
  if (existing !== undefined)
@@ -283,7 +288,7 @@ function ensureWgpuVelocityPipeline(state) {
283
288
  entries: [
284
289
  {
285
290
  binding: 0,
286
- visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
291
+ visibility: WgpuShaderStage.VERTEX | WgpuShaderStage.FRAGMENT,
287
292
  buffer: { type: 'uniform', hasDynamicOffset: true },
288
293
  },
289
294
  ],
@@ -298,7 +303,7 @@ function ensureWgpuVelocityPipeline(state) {
298
303
  });
299
304
  const uniformBuffer = device.createBuffer({
300
305
  size: UNIFORM_SLOTS * UNIFORM_STRIDE,
301
- usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
306
+ usage: WgpuBufferUsage.UNIFORM | WgpuBufferUsage.COPY_DST,
302
307
  });
303
308
  const bindGroup = device.createBindGroup({
304
309
  layout: bindGroupLayout,