@flighthq/render-wgpu 0.5.0-next.1944.cd6b6e7 → 0.5.1-edge.638.d4dbd4e

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 (80) hide show
  1. package/README.md +2 -2
  2. package/dist/contract.d.ts +3 -0
  3. package/dist/contract.d.ts.map +1 -1
  4. package/dist/contract.js +3 -0
  5. package/dist/contract.js.map +1 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/wgpuAntialias.d.ts +8 -4
  11. package/dist/wgpuAntialias.d.ts.map +1 -1
  12. package/dist/wgpuAntialias.js +23 -4
  13. package/dist/wgpuAntialias.js.map +1 -1
  14. package/dist/wgpuBackground.d.ts +10 -4
  15. package/dist/wgpuBackground.d.ts.map +1 -1
  16. package/dist/wgpuBackground.js +87 -3
  17. package/dist/wgpuBackground.js.map +1 -1
  18. package/dist/wgpuCompressedTexture.js +9 -9
  19. package/dist/wgpuCompressedTexture.js.map +1 -1
  20. package/dist/wgpuDeviceLoss.d.ts +21 -0
  21. package/dist/wgpuDeviceLoss.d.ts.map +1 -0
  22. package/dist/wgpuDeviceLoss.js +62 -0
  23. package/dist/wgpuDeviceLoss.js.map +1 -0
  24. package/dist/wgpuDraw.d.ts +0 -1
  25. package/dist/wgpuDraw.d.ts.map +1 -1
  26. package/dist/wgpuDraw.js +73 -96
  27. package/dist/wgpuDraw.js.map +1 -1
  28. package/dist/wgpuElement.d.ts +5 -0
  29. package/dist/wgpuElement.d.ts.map +1 -1
  30. package/dist/wgpuElement.js +17 -6
  31. package/dist/wgpuElement.js.map +1 -1
  32. package/dist/wgpuExternalTexture.d.ts.map +1 -1
  33. package/dist/wgpuExternalTexture.js +12 -11
  34. package/dist/wgpuExternalTexture.js.map +1 -1
  35. package/dist/wgpuFullscreenPass.js +1 -1
  36. package/dist/wgpuFullscreenPass.js.map +1 -1
  37. package/dist/wgpuHost.d.ts +7 -0
  38. package/dist/wgpuHost.d.ts.map +1 -0
  39. package/dist/wgpuHost.js +80 -0
  40. package/dist/wgpuHost.js.map +1 -0
  41. package/dist/wgpuMipmap.js +3 -3
  42. package/dist/wgpuMipmap.js.map +1 -1
  43. package/dist/wgpuPipeline.d.ts +5 -0
  44. package/dist/wgpuPipeline.d.ts.map +1 -0
  45. package/dist/wgpuPipeline.js +29 -0
  46. package/dist/wgpuPipeline.js.map +1 -0
  47. package/dist/wgpuRenderState.d.ts +13 -6
  48. package/dist/wgpuRenderState.d.ts.map +1 -1
  49. package/dist/wgpuRenderState.js +220 -271
  50. package/dist/wgpuRenderState.js.map +1 -1
  51. package/dist/wgpuRenderTarget.d.ts.map +1 -1
  52. package/dist/wgpuRenderTarget.js +6 -5
  53. package/dist/wgpuRenderTarget.js.map +1 -1
  54. package/dist/wgpuRenderTexture.js +4 -4
  55. package/dist/wgpuRenderTexture.js.map +1 -1
  56. package/dist/wgpuShader.d.ts.map +1 -1
  57. package/dist/wgpuShader.js +6 -4
  58. package/dist/wgpuShader.js.map +1 -1
  59. package/dist/wgpuSurface.d.ts +5 -5
  60. package/dist/wgpuSurface.d.ts.map +1 -1
  61. package/dist/wgpuSurface.js +2 -2
  62. package/dist/wgpuSurface.js.map +1 -1
  63. package/dist/wgpuTestHelper.d.ts +2 -2
  64. package/dist/wgpuTestHelper.d.ts.map +1 -1
  65. package/dist/wgpuTestHelper.js +6 -2
  66. package/dist/wgpuTestHelper.js.map +1 -1
  67. package/package.json +11 -11
  68. package/src/wgpuAntialias.test.ts +26 -4
  69. package/src/wgpuBackground.test.ts +43 -73
  70. package/src/wgpuDeviceLoss.test.ts +240 -0
  71. package/src/wgpuDraw.test.ts +99 -24
  72. package/src/wgpuElement.test.ts +127 -13
  73. package/src/wgpuHost.test.ts +227 -0
  74. package/src/wgpuMaterialRegistry.test.ts +6 -3
  75. package/src/wgpuMipmap.test.ts +3 -3
  76. package/src/wgpuPipeline.test.ts +52 -0
  77. package/src/wgpuRenderState.test.ts +679 -88
  78. package/src/wgpuRenderTarget.test.ts +12 -8
  79. package/src/wgpuRenderTexture.test.ts +1 -1
  80. package/src/wgpuShader.test.ts +2 -2
@@ -2,6 +2,7 @@ import { createMatrix } from '@flighthq/geometry/contract';
2
2
  import type { WgpuRenderTarget } from '@flighthq/types/contract';
3
3
 
4
4
  import { renderWgpuBackground, submitWgpuRenderPass } from './wgpuBackground';
5
+ import { resolveWgpuSmoothingBindGroup } from './wgpuDraw';
5
6
  import { getWgpuRenderStateRuntime } from './wgpuRenderState';
6
7
  import {
7
8
  getWgpuRenderTargetSupersampleScale,
@@ -49,12 +50,12 @@ describe('beginWgpuRenderPass', () => {
49
50
  });
50
51
 
51
52
  describe('createWgpuRenderTarget', () => {
52
- it('returns a target with texture, view, bind group, and depth-stencil', async () => {
53
+ it('returns a target with texture, view, binding cache, and depth-stencil', async () => {
53
54
  const state = await createWgpuRenderStateForTest();
54
55
  const target = createWgpuRenderTarget(state, 256, 256);
55
56
  expect(target.texture).toBeDefined();
56
57
  expect(target.view).toBeDefined();
57
- expect(target.bindGroup).toBeDefined();
58
+ expect(target.bindings).toBeDefined();
58
59
  expect(target.depthStencilTexture).toBeDefined();
59
60
  expect(target.width).toBe(256);
60
61
  expect(target.height).toBe(256);
@@ -200,24 +201,27 @@ describe('resizeWgpuRenderTarget', () => {
200
201
  const target = createWgpuRenderTarget(state, 64, 64);
201
202
  const texture = target.texture;
202
203
  const depthStencilTexture = target.depthStencilTexture;
203
- const bindGroup = target.bindGroup;
204
+ const sampler = getWgpuRenderStateRuntime(state).context.linearSampler;
205
+ const bindGroup = resolveWgpuSmoothingBindGroup(state, target, true);
204
206
 
205
207
  resizeWgpuRenderTarget(state, target, 64, 64);
206
208
 
207
209
  expect(target.texture).toBe(texture);
208
210
  expect(target.depthStencilTexture).toBe(depthStencilTexture);
209
- expect(target.bindGroup).toBe(bindGroup);
211
+ // The view survived, so its cached bindings must survive with it.
212
+ expect(target.bindings.get(sampler)).toBe(bindGroup);
210
213
  });
211
214
 
212
- it('updates width, height, and bind group', async () => {
215
+ it('updates width, height, and drops bindings that referenced the old view', async () => {
213
216
  const state = await createWgpuRenderStateForTest();
214
217
  const target = createWgpuRenderTarget(state, 64, 64);
215
- const previousBindGroup = target.bindGroup;
218
+ const previousBindGroup = resolveWgpuSmoothingBindGroup(state, target, true);
216
219
  resizeWgpuRenderTarget(state, target, 200, 150);
217
220
  expect(target.width).toBe(200);
218
221
  expect(target.height).toBe(150);
219
- expect(target.bindGroup).toBeDefined();
220
- expect(target.bindGroup).not.toBe(previousBindGroup);
222
+ // Reallocation replaces the view, so every binding over the old one is dropped and rebuilt.
223
+ expect(target.bindings.size).toBe(0);
224
+ expect(resolveWgpuSmoothingBindGroup(state, target, true)).not.toBe(previousBindGroup);
221
225
  });
222
226
 
223
227
  it('reallocates when the effective sample count changes', async () => {
@@ -61,7 +61,7 @@ describe('destroyWgpuRenderTexture', () => {
61
61
  const renderTexture = texture();
62
62
  renderWgpuBackground(state);
63
63
  renderIntoWgpuRenderTexture(state, renderTexture, () => {});
64
- const entry = getWgpuRenderStateRuntime(state).wgpuRenderTextureCache!.get(renderTexture)!;
64
+ const entry = getWgpuRenderStateRuntime(state).context.wgpuRenderTextureCache!.get(renderTexture)!;
65
65
  const destroy = vi.spyOn(entry.target.texture, 'destroy');
66
66
 
67
67
  destroyWgpuRenderTexture(state, renderTexture);
@@ -34,8 +34,8 @@ describe('createWgpuPipelineLayout', () => {
34
34
  const runtime = getWgpuRenderStateRuntime(state);
35
35
  const layout = createWgpuPipelineLayout(
36
36
  state.device,
37
- runtime.uniformBindGroupLayout,
38
- runtime.textureBindGroupLayout,
37
+ runtime.context.uniformBindGroupLayout,
38
+ runtime.context.textureBindGroupLayout,
39
39
  );
40
40
  expect(layout).toBeDefined();
41
41
  });