@plasius/gpu-renderer 0.2.43 → 0.2.45

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/dist/index.js CHANGED
@@ -2205,6 +2205,144 @@ async function createProfessionalAnimatedSceneRenderer(options = {}) {
2205
2205
  };
2206
2206
  }
2207
2207
 
2208
+ // src/feedback-diagnostics.js
2209
+ import {
2210
+ FEEDBACK_GAME_DIAGNOSTICS_CONTRACT_VERSION,
2211
+ feedbackGameDiagnosticSurfaceRegistrations,
2212
+ parseFeedbackGameDiagnostics
2213
+ } from "@plasius/gpu-shared/feedback-diagnostics";
2214
+ var inputKeys = Object.freeze([
2215
+ "featureEnabled",
2216
+ "capabilityGranted",
2217
+ "consentConfirmed",
2218
+ "surfaceId",
2219
+ "renderer",
2220
+ "backend",
2221
+ "viewportWidth",
2222
+ "viewportHeight",
2223
+ "frameRate",
2224
+ "frameTimeMs",
2225
+ "featureIds",
2226
+ "counters",
2227
+ "errorCodes"
2228
+ ]);
2229
+ function bucketFeedbackGameViewport(width, height) {
2230
+ if (typeof width !== "number" || typeof height !== "number" || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
2231
+ return "unknown";
2232
+ }
2233
+ const shorterEdge = Math.min(width, height);
2234
+ const longerEdge = Math.max(width, height);
2235
+ const size = shorterEdge < 600 ? "small" : shorterEdge < 900 || longerEdge < 1440 ? "medium" : "large";
2236
+ const orientation = width > height ? "landscape" : "portrait";
2237
+ return `${size}-${orientation}`;
2238
+ }
2239
+ function bucketFeedbackGameFrameRate(frameRate) {
2240
+ if (typeof frameRate !== "number" || !Number.isFinite(frameRate) || frameRate < 0) {
2241
+ return "unknown";
2242
+ }
2243
+ if (frameRate < 15) {
2244
+ return "under-15";
2245
+ }
2246
+ if (frameRate < 30) {
2247
+ return "15-29";
2248
+ }
2249
+ if (frameRate < 60) {
2250
+ return "30-59";
2251
+ }
2252
+ return "60-plus";
2253
+ }
2254
+ function bucketFeedbackGameFrameTime(frameTimeMs) {
2255
+ if (typeof frameTimeMs !== "number" || !Number.isFinite(frameTimeMs) || frameTimeMs < 0) {
2256
+ return "unknown";
2257
+ }
2258
+ if (frameTimeMs < 17) {
2259
+ return "under-17ms";
2260
+ }
2261
+ if (frameTimeMs < 34) {
2262
+ return "17-33ms";
2263
+ }
2264
+ if (frameTimeMs < 67) {
2265
+ return "34-66ms";
2266
+ }
2267
+ return "over-66ms";
2268
+ }
2269
+ function createFeedbackGameDiagnosticSnapshot(input) {
2270
+ try {
2271
+ return createFeedbackGameDiagnosticSnapshotInternal(input);
2272
+ } catch {
2273
+ throw new TypeError("Invalid privacy-safe renderer diagnostics input.");
2274
+ }
2275
+ }
2276
+ function createFeedbackGameDiagnosticSnapshotInternal(input) {
2277
+ const snapshot = snapshotInputIfEnabled(input);
2278
+ if (snapshot === null) {
2279
+ return null;
2280
+ }
2281
+ const registration = typeof snapshot.surfaceId === "string" && Object.hasOwn(
2282
+ feedbackGameDiagnosticSurfaceRegistrations,
2283
+ snapshot.surfaceId
2284
+ ) ? feedbackGameDiagnosticSurfaceRegistrations[snapshot.surfaceId] : void 0;
2285
+ return parseFeedbackGameDiagnostics({
2286
+ type: "feedback-game-diagnostics",
2287
+ version: FEEDBACK_GAME_DIAGNOSTICS_CONTRACT_VERSION,
2288
+ surfaceId: snapshot.surfaceId,
2289
+ consentConfirmed: true,
2290
+ provenanceContractId: registration?.provenanceContractId,
2291
+ renderer: snapshot.renderer,
2292
+ backend: snapshot.backend,
2293
+ viewportBucket: bucketFeedbackGameViewport(
2294
+ snapshot.viewportWidth,
2295
+ snapshot.viewportHeight
2296
+ ),
2297
+ frameRateBucket: bucketFeedbackGameFrameRate(snapshot.frameRate),
2298
+ frameTimeBucket: bucketFeedbackGameFrameTime(snapshot.frameTimeMs),
2299
+ featureIds: snapshot.featureIds,
2300
+ counters: snapshot.counters,
2301
+ errorCodes: snapshot.errorCodes
2302
+ });
2303
+ }
2304
+ function snapshotInputIfEnabled(input) {
2305
+ assertValid(
2306
+ input !== null && typeof input === "object" && !Array.isArray(input) && (Object.getPrototypeOf(input) === Object.prototype || Object.getPrototypeOf(input) === null)
2307
+ );
2308
+ const gateKeys = [
2309
+ "featureEnabled",
2310
+ "capabilityGranted",
2311
+ "consentConfirmed"
2312
+ ];
2313
+ const snapshot = /* @__PURE__ */ Object.create(null);
2314
+ for (const key of gateKeys) {
2315
+ const descriptor = Object.getOwnPropertyDescriptor(input, key);
2316
+ assertValid(
2317
+ descriptor !== void 0 && descriptor.enumerable === true && Object.hasOwn(descriptor, "value") && typeof descriptor.value === "boolean"
2318
+ );
2319
+ snapshot[key] = descriptor.value;
2320
+ }
2321
+ const { featureEnabled, capabilityGranted, consentConfirmed } = snapshot;
2322
+ if (!featureEnabled || !capabilityGranted || !consentConfirmed) {
2323
+ return null;
2324
+ }
2325
+ const actualKeys = Reflect.ownKeys(input);
2326
+ assertValid(
2327
+ actualKeys.length === inputKeys.length && inputKeys.every((key) => actualKeys.includes(key)) && actualKeys.every(
2328
+ (key) => typeof key === "string" && inputKeys.includes(key)
2329
+ )
2330
+ );
2331
+ for (const key of inputKeys.filter((key2) => !gateKeys.includes(key2))) {
2332
+ const descriptor = Object.getOwnPropertyDescriptor(input, key);
2333
+ assertValid(
2334
+ descriptor !== void 0 && descriptor.enumerable === true && Object.hasOwn(descriptor, "value")
2335
+ );
2336
+ snapshot[key] = descriptor.value;
2337
+ }
2338
+ return Object.freeze(snapshot);
2339
+ }
2340
+ function assertValid(condition) {
2341
+ if (!condition) {
2342
+ throw new TypeError("Invalid privacy-safe renderer diagnostics input.");
2343
+ }
2344
+ }
2345
+
2208
2346
  // src/wavefront-frame-runtime.js
2209
2347
  function createGpuParallelismCounters() {
2210
2348
  return {
@@ -5050,7 +5188,13 @@ function clampTileSizeForDevice(config, device) {
5050
5188
  }
5051
5189
  const maxPixelsByRay = Math.floor(limit / RAY_RECORD_BYTES);
5052
5190
  const maxPixelsByHit = Math.floor(limit / HIT_RECORD_BYTES);
5053
- const maxPixels = Math.max(256, Math.min(maxPixelsByRay, maxPixelsByHit));
5191
+ const maxPixelsByPathVertex = Math.floor(
5192
+ limit / ((config.maxDepth + 1) * PATH_VERTEX_RECORD_BYTES)
5193
+ );
5194
+ const maxPixels = Math.max(
5195
+ 256,
5196
+ Math.min(maxPixelsByRay, maxPixelsByHit, maxPixelsByPathVertex)
5197
+ );
5054
5198
  if (config.tilePixelCapacity <= maxPixels) {
5055
5199
  return config.tileSize;
5056
5200
  }
@@ -11358,7 +11502,11 @@ async function createWavefrontPathTracingComputeRenderer(options = {}) {
11358
11502
  canvas,
11359
11503
  width: config.width,
11360
11504
  height: config.height,
11361
- tileSize: safeTileSize
11505
+ tileSize: safeTileSize,
11506
+ tilePixelCapacity: Math.min(
11507
+ config.tilePixelCapacity,
11508
+ safeTileSize * safeTileSize
11509
+ )
11362
11510
  });
11363
11511
  }
11364
11512
  config = Object.freeze({
@@ -13175,8 +13323,12 @@ export {
13175
13323
  applyMediumTransmittance,
13176
13324
  beerLambertTransmittance,
13177
13325
  bindRendererToXrManager,
13326
+ bucketFeedbackGameFrameRate,
13327
+ bucketFeedbackGameFrameTime,
13328
+ bucketFeedbackGameViewport,
13178
13329
  createAnimatedSceneRenderer,
13179
13330
  createDefaultWavefrontSceneObjects,
13331
+ createFeedbackGameDiagnosticSnapshot,
13180
13332
  createGpuRenderer,
13181
13333
  createMediumStack,
13182
13334
  createProfessionalAnimatedSceneRenderer,