@flighthq/render-wgpu 0.5.1-next.3308.79ae053 → 0.5.1-next.4305.c5b7dc0

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 CHANGED
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/render-wgpu`. The `@
13
13
  This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
14
14
 
15
15
  - [Flight project](https://github.com/flighthq/flight)
16
- - [Source for @flighthq/render-wgpu@0.5.1-next.3308.79ae053](https://github.com/flighthq/flight/tree/79ae05332d95f01cdbd3492cf912bbd3b8f9658a/packages/render-wgpu)
17
- - [License](https://github.com/flighthq/flight/blob/79ae05332d95f01cdbd3492cf912bbd3b8f9658a/LICENSE.md)
16
+ - [Source for @flighthq/render-wgpu@0.5.1-next.4305.c5b7dc0](https://github.com/flighthq/flight/tree/c5b7dc0276d23e5772eb5aa05cdff1a91777141f/packages/render-wgpu)
17
+ - [License](https://github.com/flighthq/flight/blob/c5b7dc0276d23e5772eb5aa05cdff1a91777141f/LICENSE.md)
@@ -1,4 +1,5 @@
1
+ import type { LogState } from '@flighthq/log/contract';
1
2
  import type { WgpuRenderState } from '@flighthq/types/contract';
2
3
  export declare function areWgpuTextureResolverGuardsEnabled(state: WgpuRenderState): boolean;
3
- export declare function enableWgpuTextureResolverGuards(state: WgpuRenderState): void;
4
+ export declare function enableWgpuTextureResolverGuards(state: WgpuRenderState, logState: LogState | null): void;
4
5
  //# sourceMappingURL=enableWgpuTextureResolverGuards.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enableWgpuTextureResolverGuards.d.ts","sourceRoot":"","sources":["../src/enableWgpuTextureResolverGuards.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAKhE,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEnF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAI5E"}
1
+ {"version":3,"file":"enableWgpuTextureResolverGuards.d.ts","sourceRoot":"","sources":["../src/enableWgpuTextureResolverGuards.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAKhE,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEnF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAIvG"}
@@ -5,13 +5,16 @@ import { getWgpuRenderStateRuntime } from "./wgpuRenderState.js";
5
5
  export function areWgpuTextureResolverGuardsEnabled(state) {
6
6
  return areRenderRegistriesGuardsEnabled(state);
7
7
  }
8
- export function enableWgpuTextureResolverGuards(state) {
9
- enableRenderRegistriesGuards(state);
8
+ export function enableWgpuTextureResolverGuards(state, logState) {
9
+ enableRenderRegistriesGuards(state, logState);
10
10
  const runtime = getWgpuRenderStateRuntime(state);
11
- runtime.mipmapDegradedGuard = warnOnMipmapDegradation;
11
+ runtime.mipmapDegradedGuard = (degradedState) => warnOnMipmapDegradation(logState, degradedState);
12
12
  }
13
- function warnOnMipmapDegradation(state) {
14
- logOnce('render-wgpu:mipmap-degraded', LogLevel.Warn, {
13
+ function warnOnMipmapDegradation(logState, state) {
14
+ if (logState === null)
15
+ return;
16
+ // The render guards take no clock, so the warning is stamped at time zero.
17
+ logOnce(logState, 0, 'render-wgpu:mipmap-degraded', LogLevel.Warn, {
15
18
  message: 'bindWgpuBitmapTexture: mipmaps requested but no WGPU mipmap generator registered — texture allocated with a single mip level (bilinear fallback). Call registerWgpuMipmapGeneration(state) to enable trilinear/anisotropic sampling.',
16
19
  state,
17
20
  }, 'render-wgpu');
@@ -1 +1 @@
1
- {"version":3,"file":"enableWgpuTextureResolverGuards.js","sourceRoot":"","sources":["../src/enableWgpuTextureResolverGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gCAAgC,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAE3G,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,UAAU,mCAAmC,CAAC,KAAsB;IACxE,OAAO,gCAAgC,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAAsB;IACpE,4BAA4B,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,OAAO,CAAC,mBAAmB,GAAG,uBAAuB,CAAC;AACxD,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAsB;IACrD,OAAO,CACL,6BAA6B,EAC7B,QAAQ,CAAC,IAAI,EACb;QACE,OAAO,EACL,sOAAsO;QACxO,KAAK;KACN,EACD,aAAa,CACd,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"enableWgpuTextureResolverGuards.js","sourceRoot":"","sources":["../src/enableWgpuTextureResolverGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,gCAAgC,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAE3G,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,UAAU,mCAAmC,CAAC,KAAsB;IACxE,OAAO,gCAAgC,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAAsB,EAAE,QAAyB;IAC/F,4BAA4B,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,OAAO,CAAC,mBAAmB,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,uBAAuB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AACpG,CAAC;AAED,SAAS,uBAAuB,CAAC,QAAyB,EAAE,KAAsB;IAChF,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO;IAC9B,2EAA2E;IAC3E,OAAO,CACL,QAAQ,EACR,CAAC,EACD,6BAA6B,EAC7B,QAAQ,CAAC,IAAI,EACb;QACE,OAAO,EACL,sOAAsO;QACxO,KAAK;KACN,EACD,aAAa,CACd,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/render-wgpu",
3
- "version": "0.5.1-next.3308.79ae053",
3
+ "version": "0.5.1-next.4305.c5b7dc0",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,16 +38,16 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/color": "0.5.1-next.3308.79ae053",
42
- "@flighthq/entity": "0.5.1-next.3308.79ae053",
43
- "@flighthq/geometry": "0.5.1-next.3308.79ae053",
44
- "@flighthq/log": "0.5.1-next.3308.79ae053",
45
- "@flighthq/render": "0.5.1-next.3308.79ae053",
46
- "@flighthq/registry": "0.5.1-next.3308.79ae053",
47
- "@flighthq/signals": "0.5.1-next.3308.79ae053",
48
- "@flighthq/bitmap": "0.5.1-next.3308.79ae053",
49
- "@flighthq/texture": "0.5.1-next.3308.79ae053",
50
- "@flighthq/types": "0.5.1-next.3308.79ae053"
41
+ "@flighthq/color": "0.5.1-next.4305.c5b7dc0",
42
+ "@flighthq/entity": "0.5.1-next.4305.c5b7dc0",
43
+ "@flighthq/geometry": "0.5.1-next.4305.c5b7dc0",
44
+ "@flighthq/log": "0.5.1-next.4305.c5b7dc0",
45
+ "@flighthq/render": "0.5.1-next.4305.c5b7dc0",
46
+ "@flighthq/registry": "0.5.1-next.4305.c5b7dc0",
47
+ "@flighthq/signals": "0.5.1-next.4305.c5b7dc0",
48
+ "@flighthq/bitmap": "0.5.1-next.4305.c5b7dc0",
49
+ "@flighthq/texture": "0.5.1-next.4305.c5b7dc0",
50
+ "@flighthq/types": "0.5.1-next.4305.c5b7dc0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@webgpu/types": "^0.1.70"
@@ -1,6 +1,13 @@
1
- import { addLogSink, createMemoryLogSink, getMemoryLogSinkEntries, removeLogSink } from '@flighthq/log/contract';
1
+ import {
2
+ addLogSink,
3
+ createLogState,
4
+ createMemoryLogSink,
5
+ getMemoryLogSinkEntries,
6
+ removeLogSink,
7
+ } from '@flighthq/log/contract';
8
+ import type { LogState } from '@flighthq/log/contract';
2
9
  import { createTexture } from '@flighthq/texture/contract';
3
- import type { ImageResource } from '@flighthq/types/contract';
10
+ import type { ImageResource, LogEntry, MemoryLogSink } from '@flighthq/types/contract';
4
11
 
5
12
  import {
6
13
  areWgpuTextureResolverGuardsEnabled,
@@ -11,6 +18,13 @@ import { getWgpuRenderStateRuntime } from './wgpuRenderState.ts';
11
18
  import { createWgpuRenderStateForTest, installWgpuMock } from './wgpuTestHelper.ts';
12
19
  import { registerWgpuTextureResolver, resolveWgpuTexture } from './wgpuTextureResolver.ts';
13
20
 
21
+ // Each test logs into a fresh caller-owned state, so logOnce keys never leak between tests.
22
+ let logState: LogState;
23
+
24
+ beforeEach(() => {
25
+ logState = createLogState();
26
+ });
27
+
14
28
  beforeAll(() => {
15
29
  installWgpuMock();
16
30
  });
@@ -20,7 +34,7 @@ describe('areWgpuTextureResolverGuardsEnabled', () => {
20
34
  const state = await createWgpuRenderStateForTest();
21
35
  expect(areWgpuTextureResolverGuardsEnabled(state)).toBe(false);
22
36
 
23
- enableWgpuTextureResolverGuards(state);
37
+ enableWgpuTextureResolverGuards(state, logState);
24
38
  expect(areWgpuTextureResolverGuardsEnabled(state)).toBe(true);
25
39
  });
26
40
  });
@@ -28,8 +42,8 @@ describe('areWgpuTextureResolverGuardsEnabled', () => {
28
42
  describe('enableWgpuTextureResolverGuards', () => {
29
43
  it('is idempotent', async () => {
30
44
  const state = await createWgpuRenderStateForTest();
31
- enableWgpuTextureResolverGuards(state);
32
- enableWgpuTextureResolverGuards(state);
45
+ enableWgpuTextureResolverGuards(state, logState);
46
+ enableWgpuTextureResolverGuards(state, logState);
33
47
  expect(areWgpuTextureResolverGuardsEnabled(state)).toBe(true);
34
48
  });
35
49
 
@@ -38,15 +52,15 @@ describe('enableWgpuTextureResolverGuards', () => {
38
52
  const missing = textureWithKind('acme.missing.wgpu');
39
53
  const registered = textureWithKind('acme.registered.wgpu');
40
54
  const sink = createMemoryLogSink(4);
41
- addLogSink(sink.sink);
42
- enableWgpuTextureResolverGuards(state);
55
+ addLogSink(logState, sink.sink);
56
+ enableWgpuTextureResolverGuards(state, logState);
43
57
  registerWgpuTextureResolver(state, 'acme.registered.wgpu', () => null);
44
58
  try {
45
59
  expect(resolveWgpuTexture(state, missing)).toBeNull();
46
60
  expect(resolveWgpuTexture(state, missing)).toBeNull();
47
61
  expect(resolveWgpuTexture(state, registered)).toBeNull();
48
62
 
49
- const entries = getMemoryLogSinkEntries(sink);
63
+ const entries = readMemoryLogEntries(sink);
50
64
  expect(entries).toHaveLength(1);
51
65
  expect(entries[0]?.data).toMatchObject({
52
66
  kind: 'acme.missing.wgpu',
@@ -54,35 +68,35 @@ describe('enableWgpuTextureResolverGuards', () => {
54
68
  'resolveWgpuTexture: texture source kind has no registered resolver — call registerWgpuTextureResolver(state, sourceKind, resolver)',
55
69
  });
56
70
  } finally {
57
- removeLogSink(sink.sink);
71
+ removeLogSink(logState, sink.sink);
58
72
  }
59
73
  });
60
74
 
61
75
  it('installs the mipmap-degraded guard on the runtime', async () => {
62
76
  const state = await createWgpuRenderStateForTest();
63
77
  expect(getWgpuRenderStateRuntime(state).mipmapDegradedGuard).toBeNull();
64
- enableWgpuTextureResolverGuards(state);
78
+ enableWgpuTextureResolverGuards(state, logState);
65
79
  expect(getWgpuRenderStateRuntime(state).mipmapDegradedGuard).not.toBeNull();
66
80
  });
67
81
 
68
82
  it('logs a warning when mipmaps are requested without a registered generator', async () => {
69
83
  const state = await createWgpuRenderStateForTest();
70
84
  const sink = createMemoryLogSink(4);
71
- addLogSink(sink.sink);
72
- enableWgpuTextureResolverGuards(state);
85
+ addLogSink(logState, sink.sink);
86
+ enableWgpuTextureResolverGuards(state, logState);
73
87
  try {
74
88
  const canvas = document.createElement('canvas');
75
89
  canvas.width = 8;
76
90
  canvas.height = 8;
77
91
  bindWgpuTexture(state, canvas, true);
78
92
 
79
- const entries = getMemoryLogSinkEntries(sink);
93
+ const entries = readMemoryLogEntries(sink);
80
94
  expect(entries).toHaveLength(1);
81
95
  expect(entries[0]?.data).toMatchObject({
82
96
  message: expect.stringContaining('no WGPU mipmap generator registered'),
83
97
  });
84
98
  } finally {
85
- removeLogSink(sink.sink);
99
+ removeLogSink(logState, sink.sink);
86
100
  }
87
101
  });
88
102
  });
@@ -93,3 +107,9 @@ function textureWithKind(kind: string) {
93
107
  source: { kind } as ImageResource,
94
108
  });
95
109
  }
110
+
111
+ function readMemoryLogEntries(handle: Readonly<MemoryLogSink>): LogEntry[] {
112
+ const entries: LogEntry[] = [];
113
+ getMemoryLogSinkEntries(entries, handle);
114
+ return entries;
115
+ }
@@ -219,7 +219,7 @@ describe('observeWgpuDeviceLoss', () => {
219
219
  const deviceRuntime = {
220
220
  device,
221
221
  lost: null,
222
- signals: { onDeviceLost: createSignal<(info: GPUDeviceLostInfo) => void>() },
222
+ signals: { onDeviceLost: createSignal<GPUDeviceLostInfo>() },
223
223
  } as unknown as WgpuDeviceRuntime;
224
224
  let emissions = 0;
225
225
  connectSignal(deviceRuntime.signals!.onDeviceLost, () => {
@@ -1,6 +1,19 @@
1
- import { addLogSink, createMemoryLogSink, getMemoryLogSinkEntries, removeLogSink } from '@flighthq/log/contract';
1
+ import {
2
+ addLogSink,
3
+ createLogState,
4
+ createMemoryLogSink,
5
+ getMemoryLogSinkEntries,
6
+ removeLogSink,
7
+ } from '@flighthq/log/contract';
8
+ import type { LogState } from '@flighthq/log/contract';
2
9
  import { enableRenderRegistriesGuards, explainRenderRegistriesMisses } from '@flighthq/render/contract';
3
- import type { Material, WgpuQuadMaterialRenderer, WgpuRenderState } from '@flighthq/types/contract';
10
+ import type {
11
+ LogEntry,
12
+ Material,
13
+ MemoryLogSink,
14
+ WgpuQuadMaterialRenderer,
15
+ WgpuRenderState,
16
+ } from '@flighthq/types/contract';
4
17
  import { StandardMaterialKind, EntityRuntimeKey, RenderRegistryTable } from '@flighthq/types/contract';
5
18
 
6
19
  import {
@@ -10,6 +23,13 @@ import {
10
23
  } from './wgpuQuadMaterialRegistry.ts';
11
24
  import { createWgpuDeviceState, createWgpuRenderStateRuntime, getWgpuRenderStateRuntime } from './wgpuRenderState.ts';
12
25
 
26
+ // Each test logs into a fresh caller-owned state, so logOnce keys never leak between tests.
27
+ let logState: LogState;
28
+
29
+ beforeEach(() => {
30
+ logState = createLogState();
31
+ });
32
+
13
33
  const TestKind = 'TestMaterial';
14
34
  const testRenderer: WgpuQuadMaterialRenderer = {
15
35
  instanceFloatCount: 0,
@@ -80,9 +100,9 @@ describe('resolveWgpuQuadMaterialRenderer', () => {
80
100
 
81
101
  it('reports the missing kind against the wgpu registrar, not the gl one', () => {
82
102
  const state = makeState();
83
- enableRenderRegistriesGuards(state);
103
+ enableRenderRegistriesGuards(state, logState);
84
104
  const sink = createMemoryLogSink(4);
85
- addLogSink(sink.sink);
105
+ addLogSink(logState, sink.sink);
86
106
 
87
107
  try {
88
108
  resolveWgpuQuadMaterialRenderer(state, makeMaterial(TestKind));
@@ -90,14 +110,20 @@ describe('resolveWgpuQuadMaterialRenderer', () => {
90
110
  expect(explainRenderRegistriesMisses(state).misses).toEqual([
91
111
  { kind: TestKind, registry: RenderRegistryTable.MaterialRenderer },
92
112
  ]);
93
- expect(getMemoryLogSinkEntries(sink)[0]?.data).toMatchObject({
113
+ expect(readMemoryLogEntries(sink)[0]?.data).toMatchObject({
94
114
  kind: TestKind,
95
115
  message:
96
116
  'resolveWgpuQuadMaterialRenderer: material kind has no registered renderer, so nodes using it do not draw — call registerWgpuQuadMaterialRenderer(state, kind, renderer)',
97
117
  registry: RenderRegistryTable.MaterialRenderer,
98
118
  });
99
119
  } finally {
100
- removeLogSink(sink.sink);
120
+ removeLogSink(logState, sink.sink);
101
121
  }
102
122
  });
103
123
  });
124
+
125
+ function readMemoryLogEntries(handle: Readonly<MemoryLogSink>): LogEntry[] {
126
+ const entries: LogEntry[] = [];
127
+ getMemoryLogSinkEntries(entries, handle);
128
+ return entries;
129
+ }
@@ -251,7 +251,7 @@ describe('createWgpuOffscreenRenderState', () => {
251
251
  registerWgpuQuadMaterialRenderer(screen, 'acme.Material', materialRenderer);
252
252
  registerWgpuTextureResolver(screen, 'acme.Texture', textureResolver);
253
253
  enableColorAdjustments(screen);
254
- enableColorAdjustmentGuards(screen);
254
+ enableColorAdjustmentGuards(screen, null);
255
255
  registerPaddingResolver(screen, 'acme.Effect', paddingResolver);
256
256
  getWgpuRenderStateRuntime(screen).registries.colorAdjustmentFeature = colorAdjustmentFeature;
257
257
  getWgpuRenderStateRuntime(screen).registries.colorAdjustmentFeatureGuard = colorAdjustmentFeatureGuard;