跳到主要内容
quality-tiers · 代码
查看代码目录
Graphics Learning Lab Quality Tier / Source

Observe · Change · Recompute · Explain

先分离请求与生效,再讨论优化

Read-only · exact teaching model

质量档位不是开关列表,而是带有设备约束和可回退路径的策略。

这一课怎么学

  1. 观察
  2. 预测
  3. 改一个量
  4. 看证据
  5. 再读代码
01 / REQUEST

Separate requested quality from effective quality

A fallback is explainable only when the original request is kept for comparison.

// Quality Tier & Fallback Lab — executable teaching model
const requested = { maps, ssr, reflections, fog, particles, resolution };
const effective = fallback(requested, { tier, memoryGb, bandwidthMb });
fallbackReasons.push("SSR disabled for low tier");
02 / BUDGET

Visual quality spends three budgets

GPU time, memory and bandwidth can disagree; measure all three.

const gpuMs = pixels * (materialCost + screenSpaceCost) * samples;
const memoryMb = textureMb + frameMb + shadowMb + screenSpaceMb;
const bandwidthMb = pixels * (textureAndFrame + screenSpace) * sampleFactor;

risk = gpuMs > targetMs || memoryMb > deviceMemoryGb * 1024 ? "high" : "low";
03 / RISK

The fallback is part of the product

Risk and report identity make a quality decision testable.

risk = gpuMs > targetMs || memoryMb > deviceMemoryGb * 1024 ? "high" : "low";
reportId = stableHash({ effective, gpuMs, memoryMb, bandwidthMb });