here2share

WebGPU Full System Check

Nov 12th, 2026
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 50.18 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>WebGPU Full System Check</title>
  6. <style>
  7.   body { background:#111; color:#eee; font-family:monospace; margin:16px; }
  8.   h1 { font-size:18px; margin:0 0 4px 0; }
  9.   p { color:#aaa; font-size:13px; max-width:900px; }
  10.   button { font-family:monospace; font-size:14px; padding:6px 12px; margin:4px 8px 12px 0; cursor:pointer; }
  11.   #summary { font-size:15px; font-weight:bold; margin:10px 0; }
  12.   #report { white-space:pre-wrap; word-break:break-word; background:#000; padding:12px; border:1px solid #333; }
  13.   #c { width:640px; height:640px; max-width:100%; border:1px solid #333; display:block; margin-top:12px; background:#0d0f14; }
  14.   .pass { color:#7f7; }
  15.   .fail { color:#f77; }
  16. </style>
  17. </head>
  18. <body>
  19. <h1>WebGPU Full System Check</h1>
  20. <p>Open this file in Chrome (headed). It runs every check on its own and prints one copyable report: environment, each adapter type, adapter info / features / limits, device, WGSL compile (good and broken shader), a compute shader with exact expected values, a live canvas demo (a rotating silver teapot above a reflective checkered floor), and an offscreen render with pixel readback verified against the spiral math. In headless Chrome the adapter steps are expected to come back null &mdash; that is the headless result, not a page error.</p>
  21. <button id="copyBtn">Copy report</button>
  22. <button id="dlBtn">Download report (.txt)</button>
  23. <button id="rerunBtn">Run again</button>
  24. <div id="summary">Running&hellip;</div>
  25. <pre id="report"></pre>
  26. <canvas id="c" width="1280" height="1280"></canvas>
  27. <script>
  28. const reportEl = document.getElementById("report");
  29. const summaryEl = document.getElementById("summary");
  30. const lines = [];
  31. let passCount = 0;
  32. let failCount = 0;
  33. function add(m) { lines.push(m); reportEl.textContent = lines.join("\n"); }
  34. function section(t) { add(""); add("== " + t + " =="); }
  35. function check(name, ok, detail) {
  36.   if (ok) { passCount++; add("PASS  " + name + (detail ? "  " + detail : "")); }
  37.   else { failCount++; add("FAIL  " + name + (detail ? "  " + detail : "")); }
  38. }
  39. function info(m) { add("      " + m); }
  40. function ms(t0) { return (performance.now() - t0).toFixed(1) + " ms"; }
  41.  
  42. function mat4Multiply(a, b) {
  43.   const o = new Float32Array(16);
  44.   for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) {
  45.    let s = 0;
  46.    for (let k = 0; k < 4; k++) s += a[k * 4 + r] * b[c * 4 + k];
  47.    o[c * 4 + r] = s;
  48.  }
  49.  return o;
  50. }
  51. function mat4Perspective(fovy, aspect, near, far) {
  52.  const f = 1 / Math.tan(fovy / 2);
  53.  const o = new Float32Array(16);
  54.  o[0] = f / aspect; o[5] = f; o[10] = far / (near - far); o[11] = -1; o[14] = near * far / (near - far);
  55.  return o;
  56. }
  57. function mat4LookAt(eye, target, up) {
  58.  let zx = eye[0] - target[0], zy = eye[1] - target[1], zz = eye[2] - target[2];
  59.  let l = Math.hypot(zx, zy, zz); zx /= l; zy /= l; zz /= l;
  60.  let xx = up[1] * zz - up[2] * zy, xy = up[2] * zx - up[0] * zz, xz = up[0] * zy - up[1] * zx;
  61.  l = Math.hypot(xx, xy, xz); xx /= l; xy /= l; xz /= l;
  62.  const yx = zy * xz - zz * xy, yy = zz * xx - zx * xz, yz = zx * xy - zy * xx;
  63.  const o = new Float32Array(16);
  64.  o[0] = xx; o[1] = yx; o[2] = zx;
  65.  o[4] = xy; o[5] = yy; o[6] = zy;
  66.  o[8] = xz; o[9] = yz; o[10] = zz;
  67.  o[12] = -(xx * eye[0] + xy * eye[1] + xz * eye[2]);
  68.  o[13] = -(yx * eye[0] + yy * eye[1] + yz * eye[2]);
  69.  o[14] = -(zx * eye[0] + zy * eye[1] + zz * eye[2]);
  70.  o[15] = 1;
  71.  return o;
  72. }
  73. function mat4Translate(x, y, z) {
  74.  const o = new Float32Array(16);
  75.  o[0] = 1; o[5] = 1; o[10] = 1; o[15] = 1; o[12] = x; o[13] = y; o[14] = z;
  76.  return o;
  77. }
  78. function mat4RotY(a) {
  79.  const c = Math.cos(a), s = Math.sin(a);
  80.  const o = new Float32Array(16);
  81.  o[0] = c; o[2] = -s; o[5] = 1; o[8] = s; o[10] = c; o[15] = 1;
  82.  return o;
  83. }
  84. function mat4Scale(x, y, z) {
  85.  const o = new Float32Array(16);
  86.  o[0] = x; o[5] = y; o[10] = z; o[15] = 1;
  87.  return o;
  88. }
  89. function mat4Point(m, p) {
  90.  const x = p[0], y = p[1], z = p[2];
  91.  const w = m[3] * x + m[7] * y + m[11] * z + m[15];
  92.  return [
  93.    (m[0] * x + m[4] * y + m[8] * z + m[12]) / w,
  94.    (m[1] * x + m[5] * y + m[9] * z + m[13]) / w,
  95.    (m[2] * x + m[6] * y + m[10] * z + m[14]) / w
  96.  ];
  97. }
  98.  
  99. const TEAPOT_CP = [
  100.  1.4, 0, 2.4, 1.4, -0.784, 2.4, 0.784, -1.4, 2.4, 0, -1.4, 2.4, 1.3375, 0, 2.53125, 1.3375, -0.749, 2.53125,
  101.  0.749, -1.3375, 2.53125, 0, -1.3375, 2.53125, 1.4375, 0, 2.53125, 1.4375, -0.805, 2.53125, 0.805, -1.4375, 2.53125, 0, -1.4375, 2.53125,
  102.  1.5, 0, 2.4, 1.5, -0.84, 2.4, 0.84, -1.5, 2.4, 0, -1.5, 2.4, -0.784, -1.4, 2.4, -1.4, -0.784, 2.4,
  103.  -1.4, 0, 2.4, -0.749, -1.3375, 2.53125, -1.3375, -0.749, 2.53125, -1.3375, 0, 2.53125, -0.805, -1.4375, 2.53125, -1.4375, -0.805, 2.53125,
  104.  -1.4375, 0, 2.53125, -0.84, -1.5, 2.4, -1.5, -0.84, 2.4, -1.5, 0, 2.4, -1.4, 0.784, 2.4, -0.784, 1.4, 2.4,
  105.  0, 1.4, 2.4, -1.3375, 0.749, 2.53125, -0.749, 1.3375, 2.53125, 0, 1.3375, 2.53125, -1.4375, 0.805, 2.53125, -0.805, 1.4375, 2.53125,
  106.  0, 1.4375, 2.53125, -1.5, 0.84, 2.4, -0.84, 1.5, 2.4, 0, 1.5, 2.4, 0.784, 1.4, 2.4, 1.4, 0.784, 2.4,
  107.  0.749, 1.3375, 2.53125, 1.3375, 0.749, 2.53125, 0.805, 1.4375, 2.53125, 1.4375, 0.805, 2.53125, 0.84, 1.5, 2.4, 1.5, 0.84, 2.4,
  108.  1.75, 0, 1.875, 1.75, -0.98, 1.875, 0.98, -1.75, 1.875, 0, -1.75, 1.875, 2, 0, 1.35, 2, -1.12, 1.35,
  109.  1.12, -2, 1.35, 0, -2, 1.35, 2, 0, 0.9, 2, -1.12, 0.9, 1.12, -2, 0.9, 0, -2, 0.9,
  110.  -0.98, -1.75, 1.875, -1.75, -0.98, 1.875, -1.75, 0, 1.875, -1.12, -2, 1.35, -2, -1.12, 1.35, -2, 0, 1.35,
  111.  -1.12, -2, 0.9, -2, -1.12, 0.9, -2, 0, 0.9, -1.75, 0.98, 1.875, -0.98, 1.75, 1.875, 0, 1.75, 1.875,
  112.  -2, 1.12, 1.35, -1.12, 2, 1.35, 0, 2, 1.35, -2, 1.12, 0.9, -1.12, 2, 0.9, 0, 2, 0.9,
  113.  0.98, 1.75, 1.875, 1.75, 0.98, 1.875, 1.12, 2, 1.35, 2, 1.12, 1.35, 1.12, 2, 0.9, 2, 1.12, 0.9,
  114.  2, 0, 0.45, 2, -1.12, 0.45, 1.12, -2, 0.45, 0, -2, 0.45, 1.5, 0, 0.225, 1.5, -0.84, 0.225,
  115.  0.84, -1.5, 0.225, 0, -1.5, 0.225, 1.5, 0, 0.15, 1.5, -0.84, 0.15, 0.84, -1.5, 0.15, 0, -1.5, 0.15,
  116.  -1.12, -2, 0.45, -2, -1.12, 0.45, -2, 0, 0.45, -0.84, -1.5, 0.225, -1.5, -0.84, 0.225, -1.5, 0, 0.225,
  117.  -0.84, -1.5, 0.15, -1.5, -0.84, 0.15, -1.5, 0, 0.15, -2, 1.12, 0.45, -1.12, 2, 0.45, 0, 2, 0.45,
  118.  -1.5, 0.84, 0.225, -0.84, 1.5, 0.225, 0, 1.5, 0.225, -1.5, 0.84, 0.15, -0.84, 1.5, 0.15, 0, 1.5, 0.15,
  119.  1.12, 2, 0.45, 2, 1.12, 0.45, 0.84, 1.5, 0.225, 1.5, 0.84, 0.225, 0.84, 1.5, 0.15, 1.5, 0.84, 0.15,
  120.  -1.6, 0, 2.025, -1.6, -0.3, 2.025, -1.5, -0.3, 2.25, -1.5, 0, 2.25, -2.3, 0, 2.025, -2.3, -0.3, 2.025,
  121.  -2.5, -0.3, 2.25, -2.5, 0, 2.25, -2.7, 0, 2.025, -2.7, -0.3, 2.025, -3, -0.3, 2.25, -3, 0, 2.25,
  122.  -2.7, 0, 1.8, -2.7, -0.3, 1.8, -3, -0.3, 1.8, -3, 0, 1.8, -1.5, 0.3, 2.25, -1.6, 0.3, 2.025,
  123.  -2.5, 0.3, 2.25, -2.3, 0.3, 2.025, -3, 0.3, 2.25, -2.7, 0.3, 2.025, -3, 0.3, 1.8, -2.7, 0.3, 1.8,
  124.  -2.7, 0, 1.575, -2.7, -0.3, 1.575, -3, -0.3, 1.35, -3, 0, 1.35, -2.5, 0, 1.125, -2.5, -0.3, 1.125,
  125.  -2.65, -0.3, 0.9375, -2.65, 0, 0.9375, -2, -0.3, 0.9, -1.9, -0.3, 0.6, -1.9, 0, 0.6, -3, 0.3, 1.35,
  126.  -2.7, 0.3, 1.575, -2.65, 0.3, 0.9375, -2.5, 0.3, 1.125, -1.9, 0.3, 0.6, -2, 0.3, 0.9, 1.7, 0, 1.425,
  127.  1.7, -0.66, 1.425, 1.7, -0.66, 0.6, 1.7, 0, 0.6, 2.6, 0, 1.425, 2.6, -0.66, 1.425, 3.1, -0.66, 0.825,
  128.  3.1, 0, 0.825, 2.3, 0, 2.1, 2.3, -0.25, 2.1, 2.4, -0.25, 2.025, 2.4, 0, 2.025, 2.7, 0, 2.4,
  129.  2.7, -0.25, 2.4, 3.3, -0.25, 2.4, 3.3, 0, 2.4, 1.7, 0.66, 0.6, 1.7, 0.66, 1.425, 3.1, 0.66, 0.825,
  130.  2.6, 0.66, 1.425, 2.4, 0.25, 2.025, 2.3, 0.25, 2.1, 3.3, 0.25, 2.4, 2.7, 0.25, 2.4, 2.8, 0, 2.475,
  131.  2.8, -0.25, 2.475, 3.525, -0.25, 2.49375, 3.525, 0, 2.49375, 2.9, 0, 2.475, 2.9, -0.15, 2.475, 3.45, -0.15, 2.5125,
  132.  3.45, 0, 2.5125, 2.8, 0, 2.4, 2.8, -0.15, 2.4, 3.2, -0.15, 2.4, 3.2, 0, 2.4, 3.525, 0.25, 2.49375,
  133.  2.8, 0.25, 2.475, 3.45, 0.15, 2.5125, 2.9, 0.15, 2.475, 3.2, 0.15, 2.4, 2.8, 0.15, 2.4, 0, 0, 3.15,
  134.  0, -0.002, 3.15, 0.002, 0, 3.15, 0.8, 0, 3.15, 0.8, -0.45, 3.15, 0.45, -0.8, 3.15, 0, -0.8, 3.15,
  135.  0, 0, 2.85, 0.2, 0, 2.7, 0.2, -0.112, 2.7, 0.112, -0.2, 2.7, 0, -0.2, 2.7, -0.002, 0, 3.15,
  136.  -0.45, -0.8, 3.15, -0.8, -0.45, 3.15, -0.8, 0, 3.15, -0.112, -0.2, 2.7, -0.2, -0.112, 2.7, -0.2, 0, 2.7,
  137.  0, 0.002, 3.15, -0.8, 0.45, 3.15, -0.45, 0.8, 3.15, 0, 0.8, 3.15, -0.2, 0.112, 2.7, -0.112, 0.2, 2.7,
  138.  0, 0.2, 2.7, 0.45, 0.8, 3.15, 0.8, 0.45, 3.15, 0.112, 0.2, 2.7, 0.2, 0.112, 2.7, 0.4, 0, 2.55,
  139.  0.4, -0.224, 2.55, 0.224, -0.4, 2.55, 0, -0.4, 2.55, 1.3, 0, 2.55, 1.3, -0.728, 2.55, 0.728, -1.3, 2.55,
  140.  0, -1.3, 2.55, 1.3, 0, 2.4, 1.3, -0.728, 2.4, 0.728, -1.3, 2.4, 0, -1.3, 2.4, -0.224, -0.4, 2.55,
  141.  -0.4, -0.224, 2.55, -0.4, 0, 2.55, -0.728, -1.3, 2.55, -1.3, -0.728, 2.55, -1.3, 0, 2.55, -0.728, -1.3, 2.4,
  142.  -1.3, -0.728, 2.4, -1.3, 0, 2.4, -0.4, 0.224, 2.55, -0.224, 0.4, 2.55, 0, 0.4, 2.55, -1.3, 0.728, 2.55,
  143.  -0.728, 1.3, 2.55, 0, 1.3, 2.55, -1.3, 0.728, 2.4, -0.728, 1.3, 2.4, 0, 1.3, 2.4, 0.224, 0.4, 2.55,
  144.  0.4, 0.224, 2.55, 0.728, 1.3, 2.55, 1.3, 0.728, 2.55, 0.728, 1.3, 2.4, 1.3, 0.728, 2.4, 0, 0, 0,
  145.  1.5, 0, 0.15, 1.5, 0.84, 0.15, 0.84, 1.5, 0.15, 0, 1.5, 0.15, 1.5, 0, 0.075, 1.5, 0.84, 0.075,
  146.  0.84, 1.5, 0.075, 0, 1.5, 0.075, 1.425, 0, 0, 1.425, 0.798, 0, 0.798, 1.425, 0, 0, 1.425, 0,
  147.  -0.84, 1.5, 0.15, -1.5, 0.84, 0.15, -1.5, 0, 0.15, -0.84, 1.5, 0.075, -1.5, 0.84, 0.075, -1.5, 0, 0.075,
  148.  -0.798, 1.425, 0, -1.425, 0.798, 0, -1.425, 0, 0, -1.5, -0.84, 0.15, -0.84, -1.5, 0.15, 0, -1.5, 0.15,
  149.  -1.5, -0.84, 0.075, -0.84, -1.5, 0.075, 0, -1.5, 0.075, -1.425, -0.798, 0, -0.798, -1.425, 0, 0, -1.425, 0,
  150.  0.84, -1.5, 0.15, 1.5, -0.84, 0.15, 0.84, -1.5, 0.075, 1.5, -0.84, 0.075, 0.798, -1.425, 0, 1.425, -0.798, 0
  151. ];
  152. const TEAPOT_PATCHES = [
  153.  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  154.  3, 16, 17, 18, 7, 19, 20, 21, 11, 22, 23, 24, 15, 25, 26, 27,
  155.  18, 28, 29, 30, 21, 31, 32, 33, 24, 34, 35, 36, 27, 37, 38, 39,
  156.  30, 40, 41, 0, 33, 42, 43, 4, 36, 44, 45, 8, 39, 46, 47, 12,
  157.  12, 13, 14, 15, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
  158.  15, 25, 26, 27, 51, 60, 61, 62, 55, 63, 64, 65, 59, 66, 67, 68,
  159.  27, 37, 38, 39, 62, 69, 70, 71, 65, 72, 73, 74, 68, 75, 76, 77,
  160.  39, 46, 47, 12, 71, 78, 79, 48, 74, 80, 81, 52, 77, 82, 83, 56,
  161.  56, 57, 58, 59, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
  162.  59, 66, 67, 68, 87, 96, 97, 98, 91, 99, 100, 101, 95, 102, 103, 104,
  163.  68, 75, 76, 77, 98, 105, 106, 107, 101, 108, 109, 110, 104, 111, 112, 113,
  164.  77, 82, 83, 56, 107, 114, 115, 84, 110, 116, 117, 88, 113, 118, 119, 92,
  165.  120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
  166.  123, 136, 137, 120, 127, 138, 139, 124, 131, 140, 141, 128, 135, 142, 143, 132,
  167.  132, 133, 134, 135, 144, 145, 146, 147, 148, 149, 150, 151, 68, 152, 153, 154,
  168.  135, 142, 143, 132, 147, 155, 156, 144, 151, 157, 158, 148, 154, 159, 160, 68,
  169.  161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
  170.  164, 177, 178, 161, 168, 179, 180, 165, 172, 181, 182, 169, 176, 183, 184, 173,
  171.  173, 174, 175, 176, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
  172.  176, 183, 184, 173, 188, 197, 198, 185, 192, 199, 200, 189, 196, 201, 202, 193,
  173.  203, 203, 203, 203, 206, 207, 208, 209, 210, 210, 210, 210, 211, 212, 213, 214,
  174.  203, 203, 203, 203, 209, 216, 217, 218, 210, 210, 210, 210, 214, 219, 220, 221,
  175.  203, 203, 203, 203, 218, 223, 224, 225, 210, 210, 210, 210, 221, 226, 227, 228,
  176.  203, 203, 203, 203, 225, 229, 230, 206, 210, 210, 210, 210, 228, 231, 232, 211,
  177.  211, 212, 213, 214, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
  178.  214, 219, 220, 221, 236, 245, 246, 247, 240, 248, 249, 250, 244, 251, 252, 253,
  179.  221, 226, 227, 228, 247, 254, 255, 256, 250, 257, 258, 259, 253, 260, 261, 262,
  180.  228, 231, 232, 211, 256, 263, 264, 233, 259, 265, 266, 237, 262, 267, 268, 241,
  181.  269, 269, 269, 269, 278, 279, 280, 281, 274, 275, 276, 277, 270, 271, 272, 273,
  182.  269, 269, 269, 269, 281, 288, 289, 290, 277, 285, 286, 287, 273, 282, 283, 284,
  183.  269, 269, 269, 269, 290, 297, 298, 299, 287, 294, 295, 296, 284, 291, 292, 293,
  184.  269, 269, 269, 269, 299, 304, 305, 278, 296, 302, 303, 274, 293, 300, 301, 270,
  185. ];
  186. function buildTeapot() {
  187.  const divs = 16;
  188.  const pos = [];
  189.  const idx = [];
  190.  const weld = new Map();
  191.  function bern(t) { const u = 1 - t; return [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t]; }
  192.  function vert(p) {
  193.    const key = Math.round(p[0] * 10000) + "," + Math.round(p[1] * 10000) + "," + Math.round(p[2] * 10000);
  194.    let id = weld.get(key);
  195.    if (id === undefined) { id = pos.length / 3; weld.set(key, id); pos.push(p[0], p[1], p[2]); }
  196.    return id;
  197.  }
  198.  for (let pn = 0; pn < 32; pn++) {
  199.    const cp = [];
  200.    for (let i = 0; i < 16; i++) { const o = TEAPOT_PATCHES[pn * 16 + i] * 3; cp.push([TEAPOT_CP[o], TEAPOT_CP[o + 1], TEAPOT_CP[o + 2]]); }
  201.    const grid = [];
  202.    for (let j = 0; j <= divs; j++) {
  203.      const bv = bern(j / divs);
  204.      const row = [];
  205.      for (let i = 0; i <= divs; i++) {
  206.        const bu = bern(i / divs);
  207.        let x = 0, y = 0, z = 0;
  208.        for (let r = 0; r < 4; r++) for (let c = 0; c < 4; c++) {
  209.          const w = bu[c] * bv[r];
  210.          const p = cp[r * 4 + c];
  211.          x += w * p[0]; y += w * p[1]; z += w * p[2];
  212.        }
  213.        row.push(vert([x, y, z]));
  214.      }
  215.      grid.push(row);
  216.    }
  217.    for (let j = 0; j < divs; j++) for (let i = 0; i < divs; i++) {
  218.      const a = grid[j][i], b = grid[j + 1][i], c = grid[j + 1][i + 1], d = grid[j][i + 1];
  219.      idx.push(a, c, b, a, d, c);
  220.    }
  221.  }
  222.  let mnx = 1e9, mxx = -1e9, mny = 1e9, mxy = -1e9, mnz = 1e9;
  223.  for (let i = 0; i < pos.length; i += 3) {
  224.    if (pos[i] < mnx) mnx = pos[i];
  225.    if (pos[i] > mxx) mxx = pos[i];
  226.     if (pos[i + 1] < mny) mny = pos[i + 1];
  227.    if (pos[i + 1] > mxy) mxy = pos[i + 1];
  228.     if (pos[i + 2] < mnz) mnz = pos[i + 2];
  229.  }
  230.  const s = 3.7 / (mxx - mnx);
  231.  const cx = (mnx + mxx) / 2, cy = (mny + mxy) / 2;
  232.  for (let i = 0; i < pos.length; i += 3) {
  233.    const x = pos[i], y = pos[i + 1], z = pos[i + 2];
  234.    pos[i] = (x - cx) * s;
  235.    pos[i + 1] = (z - mnz) * s + 0.5;
  236.    pos[i + 2] = -(y - cy) * s;
  237.  }
  238.  const normals = new Float32Array(pos.length);
  239.  for (let i = 0; i < idx.length; i += 3) {
  240.    const a = idx[i] * 3, b = idx[i + 1] * 3, c = idx[i + 2] * 3;
  241.    const ux = pos[b] - pos[a], uy = pos[b + 1] - pos[a + 1], uz = pos[b + 2] - pos[a + 2];
  242.    const vx = pos[c] - pos[a], vy = pos[c + 1] - pos[a + 1], vz = pos[c + 2] - pos[a + 2];
  243.    const nx = uy * vz - uz * vy, ny = uz * vx - ux * vz, nz = ux * vy - uy * vx;
  244.    normals[a] += nx; normals[a + 1] += ny; normals[a + 2] += nz;
  245.    normals[b] += nx; normals[b + 1] += ny; normals[b + 2] += nz;
  246.    normals[c] += nx; normals[c + 1] += ny; normals[c + 2] += nz;
  247.  }
  248.  for (let i = 0; i < normals.length; i += 3) {
  249.    const l = Math.hypot(normals[i], normals[i + 1], normals[i + 2]);
  250.    if (l < 1e-9) { normals[i] = 0; normals[i + 1] = 1; normals[i + 2] = 0; }
  251.    else { normals[i] /= l; normals[i + 1] /= l; normals[i + 2] /= l; }
  252.  }
  253.  return { positions: new Float32Array(pos), normals, indices: new Uint32Array(idx) };
  254. }
  255.  
  256. const _hf32 = new Float32Array(1);
  257. const _hu32 = new Uint32Array(_hf32.buffer);
  258. function floatToHalf(v) {
  259.  _hf32[0] = v;
  260.  const x = _hu32[0];
  261.  let bits = (x >> 16) & 0x8000;
  262.   let m = (x >> 12) & 0x07ff;
  263.   const e = (x >> 23) & 0xff;
  264.   if (e < 103) return bits;
  265.  if (e > 142) { bits |= 0x7c00; return bits; }
  266.   if (e < 113) {
  267.    m |= 0x0800;
  268.    bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  269.     return bits;
  270.   }
  271.   bits |= ((e - 112) << 10) | (m >> 1);
  272.   bits += m & 1;
  273.   return bits;
  274. }
  275. function envColor(dx, dy, dz) {
  276.   const dl = Math.hypot(dx, dy, dz) || 1;
  277.   dx /= dl; dy /= dl; dz /= dl;
  278.   let r, g, b;
  279.   if (dy >= 0) {
  280.     const t = Math.pow(dy, 0.6);
  281.     r = 0.34 + (0.05 - 0.34) * t;
  282.     g = 0.37 + (0.07 - 0.37) * t;
  283.     b = 0.41 + (0.11 - 0.41) * t;
  284.   } else {
  285.     const t = Math.min(-dy * 2.2, 1);
  286.     r = 0.34 + (0.03 - 0.34) * t;
  287.     g = 0.37 + (0.028 - 0.37) * t;
  288.     b = 0.41 + (0.025 - 0.41) * t;
  289.   }
  290.   const horizon = Math.exp(-Math.abs(dy - 0.02) * 9);
  291.   r += 0.1 * horizon; g += 0.105 * horizon; b += 0.11 * horizon;
  292.   const lobes = [
  293.     [0.5, 0.72, 0.62, 6, 2.6, 1.0, 0.98, 0.94],
  294.     [0.15, 0.5, 0.85, 45, 7.0, 0.95, 0.98, 1.0],
  295.     [0.62, 0.8, 0.45, 300, 16.0, 1.0, 1.0, 1.0],
  296.     [-0.7, 0.35, -0.55, 14, 1.6, 1.0, 0.82, 0.6],
  297.     [-0.25, 0.6, -0.75, 90, 5.0, 0.75, 0.85, 1.0],
  298.     [0.85, 0.12, -0.4, 24, 1.1, 0.9, 0.93, 1.0],
  299.     [-0.9, -0.05, 0.3, 30, 0.5, 1.0, 0.95, 0.88]
  300.   ];
  301.   for (const L of lobes) {
  302.     const ll = Math.hypot(L[0], L[1], L[2]);
  303.     const d = Math.max((dx * L[0] + dy * L[1] + dz * L[2]) / ll, 0);
  304.     const s = Math.pow(d, L[3]) * L[4];
  305.     r += s * L[5]; g += s * L[6]; b += s * L[7];
  306.   }
  307.   return [r, g, b];
  308. }
  309. function buildEnvData() {
  310.   let w = 256, h = 128;
  311.   let cur = new Float32Array(w * h * 3);
  312.   for (let y = 0; y < h; y++) {
  313.    const v = (y + 0.5) / h;
  314.    const phi = v * Math.PI;
  315.    const sp = Math.sin(phi), dy = Math.cos(phi);
  316.    for (let x = 0; x < w; x++) {
  317.      const u = (x + 0.5) / w;
  318.      const theta = (u - 0.5) * Math.PI * 2;
  319.      const c = envColor(sp * Math.cos(theta), dy, sp * Math.sin(theta));
  320.      const o = (y * w + x) * 3;
  321.      cur[o] = c[0]; cur[o + 1] = c[1]; cur[o + 2] = c[2];
  322.    }
  323.  }
  324.  const levels = [];
  325.  while (true) {
  326.    const data = new Uint16Array(w * h * 4);
  327.    for (let i = 0; i < w * h; i++) {
  328.      data[i * 4] = floatToHalf(cur[i * 3]);
  329.      data[i * 4 + 1] = floatToHalf(cur[i * 3 + 1]);
  330.      data[i * 4 + 2] = floatToHalf(cur[i * 3 + 2]);
  331.      data[i * 4 + 3] = floatToHalf(1);
  332.    }
  333.    levels.push({ w, h, data });
  334.    if (w <= 16) break;
  335.    const nw = w / 2, nh = h / 2;
  336.    const nxt = new Float32Array(nw * nh * 3);
  337.    for (let y = 0; y < nh; y++) {
  338.      for (let x = 0; x < nw; x++) {
  339.        let sr = 0, sg = 0, sb = 0;
  340.        for (let oy = 0; oy < 2; oy++) {
  341.          for (let ox = 0; ox < 2; ox++) {
  342.            const sx = (x * 2 + ox) % w, sy = Math.min(y * 2 + oy, h - 1);
  343.            const o = (sy * w + sx) * 3;
  344.            sr += cur[o]; sg += cur[o + 1]; sb += cur[o + 2];
  345.          }
  346.        }
  347.        const o = (y * nw + x) * 3;
  348.        nxt[o] = sr / 4; nxt[o + 1] = sg / 4; nxt[o + 2] = sb / 4;
  349.      }
  350.    }
  351.    cur = nxt; w = nw; h = nh;
  352.  }
  353.  return levels;
  354. }
  355.  
  356. const PALETTE = [
  357.  [255,0,0],[255,64,0],[255,128,0],[255,192,0],[255,255,0],[192,255,0],
  358.  [128,255,0],[0,255,0],[0,255,128],[0,255,192],[0,255,255],[0,192,255],
  359.  [0,128,255],[0,64,255],[64,0,255],[128,0,255],[192,0,255],[255,0,255],[255,0,128]
  360. ];
  361.  
  362. const SPIRAL = `
  363. const palette = array<vec3f, 19>(
  364.     vec3f(255.0, 0.0, 0.0), vec3f(255.0, 64.0, 0.0), vec3f(255.0, 128.0, 0.0),
  365.     vec3f(255.0, 192.0, 0.0), vec3f(255.0, 255.0, 0.0), vec3f(192.0, 255.0, 0.0),
  366.     vec3f(128.0, 255.0, 0.0), vec3f(0.0, 255.0, 0.0), vec3f(0.0, 255.0, 128.0),
  367.     vec3f(0.0, 255.0, 192.0), vec3f(0.0, 255.0, 255.0), vec3f(0.0, 192.0, 255.0),
  368.     vec3f(0.0, 128.0, 255.0), vec3f(0.0, 64.0, 255.0), vec3f(64.0, 0.0, 255.0),
  369.     vec3f(128.0, 0.0, 255.0), vec3f(192.0, 0.0, 255.0), vec3f(255.0, 0.0, 255.0),
  370.     vec3f(255.0, 0.0, 128.0)
  371. );
  372. @vertex fn vs_main(@builtin(vertex_index) idx : u32) -> @builtin(position) vec4f {
  373.     var pos = array<vec2f, 3>(vec2f(-1.0, -1.0), vec2f(3.0, -1.0), vec2f(-1.0, 3.0));
  374.     return vec4f(pos[idx], 0.0, 1.0);
  375. }
  376. @fragment fn fs_main(@builtin(position) coord: vec4f) -> @location(0) vec4f {
  377.     let cx = 640.0;
  378.     let cy = 640.0;
  379.     let dx = coord.x - cx;
  380.     let dy = coord.y - cy;
  381.     let r = sqrt(dx*dx + dy*dy);
  382.     if (r > 1000.0 || r < 1.0) { return vec4f(0.0, 0.0, 0.0, 0.0); }
  383.    let angle_deg = 2000.0 - (2.0 * r);
  384.    let angle_rad = angle_deg * 3.1415926535 / 180.0;
  385.    var local_angle = atan2(dy, dx);
  386.    if (local_angle < 0.0) { local_angle += 2.0 * 3.1415926535; }
  387.    var source_angle = (local_angle - angle_rad) % (2.0 * 3.1415926535);
  388.    if (source_angle < 0.0) { source_angle += 2.0 * 3.1415926535; }
  389.    let idx = i32(floor(source_angle / ((2.0 * 3.1415926535) / 19.0))) % 19;
  390.    return vec4f(palette[idx] / 255.0, 1.0);
  391. }
  392. `;
  393.  
  394. const COMPUTE = `
  395. @group(0) @binding(0) var<storage, read> a : array<f32, 8>;
  396. @group(0) @binding(1) var<storage, read> b : array<f32, 8>;
  397. @group(0) @binding(2) var<storage, read_write> outBuf : array<f32, 8>;
  398. @compute @workgroup_size(8) fn main(@builtin(global_invocation_id) id : vec3<u32>) {
  399.     outBuf[id.x] = a[id.x] * a[id.x] + b[id.x];
  400. }
  401. `;
  402.  
  403. const TEAPOT = `
  404. struct U { mvp: mat4x4f, model: mat4x4f, camPos: vec4f, lightDir: vec4f };
  405. @group(0) @binding(0) var<uniform> u: U;
  406. @group(0) @binding(1) var envTex: texture_2d<f32>;
  407. @group(0) @binding(2) var envSamp: sampler;
  408. struct VOut { @builtin(position) pos: vec4f, @location(0) world: vec3f, @location(1) normal: vec3f };
  409. @vertex fn vs_main(@location(0) p: vec3f, @location(1) n: vec3f) -> VOut {
  410.     var o: VOut;
  411.     let w = u.model * vec4f(p, 1.0);
  412.     o.world = w.xyz;
  413.     o.normal = (u.model * vec4f(n, 0.0)).xyz;
  414.     o.pos = u.mvp * vec4f(p, 1.0);
  415.     return o;
  416. }
  417. fn envUV(d: vec3f) -> vec2f {
  418.     return vec2f(atan2(d.z, d.x) / 6.2831853 + 0.5, acos(clamp(d.y, -1.0, 1.0)) / 3.14159265);
  419. }
  420. fn hash3(p: vec3f) -> f32 {
  421.     let q = fract(p * 0.3183099 + vec3f(0.11, 0.17, 0.23));
  422.     return fract(q.x * q.y * q.z * (q.x + q.y + q.z) * 17.0);
  423. }
  424. fn vnoise(p: vec3f) -> f32 {
  425.     let i = floor(p);
  426.     let f = fract(p);
  427.     let s = f * f * (3.0 - 2.0 * f);
  428.     return mix(
  429.         mix(mix(hash3(i), hash3(i + vec3f(1.0, 0.0, 0.0)), s.x),
  430.             mix(hash3(i + vec3f(0.0, 1.0, 0.0)), hash3(i + vec3f(1.0, 1.0, 0.0)), s.x), s.y),
  431.         mix(mix(hash3(i + vec3f(0.0, 0.0, 1.0)), hash3(i + vec3f(1.0, 0.0, 1.0)), s.x),
  432.             mix(hash3(i + vec3f(0.0, 1.0, 1.0)), hash3(i + vec3f(1.0, 1.0, 1.0)), s.x), s.y), s.z);
  433. }
  434. fn ggxD(noh: f32, rough: f32) -> f32 {
  435.     let a = rough * rough;
  436.     let a2 = a * a;
  437.     let d = noh * noh * (a2 - 1.0) + 1.0;
  438.     return a2 / (3.14159265 * d * d);
  439. }
  440. fn ggxG1(x: f32, rough: f32) -> f32 {
  441.     let k = (rough + 1.0) * (rough + 1.0) / 8.0;
  442.     return x / (x * (1.0 - k) + k);
  443. }
  444. fn fresnel(f0: vec3f, voh: f32) -> vec3f {
  445.     return f0 + (vec3f(1.0) - f0) * pow(1.0 - voh, 5.0);
  446. }
  447. fn specDirect(n: vec3f, v: vec3f, l: vec3f, rough: f32, f0: vec3f) -> vec3f {
  448.     let nol = max(dot(n, l), 0.0);
  449.     if (nol <= 0.0) { return vec3f(0.0); }
  450.    let h = normalize(l + v);
  451.    let nov = max(dot(n, v), 0.0);
  452.    let noh = max(dot(n, h), 0.0);
  453.    let voh = max(dot(v, h), 0.0);
  454.    let d = ggxD(noh, rough);
  455.    let g = ggxG1(nov, rough) * ggxG1(nol, rough);
  456.    let f = fresnel(f0, voh);
  457.    return d * g * f / max(4.0 * nov * nol, 0.0001) * nol;
  458. }
  459. fn envBRDF(f0: vec3f, rough: f32, nov: f32) -> vec3f {
  460.     let c0 = vec4f(-1.0, -0.0275, -0.572, 0.022);
  461.     let c1 = vec4f(1.0, 0.0425, 1.04, -0.04);
  462.     let r = rough * c0 + c1;
  463.     let a004 = min(r.x * r.x, exp2(-9.28 * nov)) * r.x + r.y;
  464.     let ab = vec2f(-1.04, 1.04) * a004 + r.zw;
  465.     return f0 * ab.x + ab.y;
  466. }
  467. fn shade(world: vec3f, normal: vec3f) -> vec3f {
  468.     let n = normalize(normal);
  469.     let v = normalize(u.camPos.xyz - world);
  470.     let nov = max(dot(n, v), 0.0);
  471.     let rough = clamp(0.13 + (vnoise(world * 3.0) - 0.5) * 0.09 + (vnoise(world * 18.0) - 0.5) * 0.05, 0.04, 0.3);
  472.     let f0 = vec3f(0.97, 0.96, 0.94);
  473.     let rd = reflect(-v, n);
  474.     let lod = rough * 4.0;
  475.     let env = textureSampleLevel(envTex, envSamp, envUV(rd), lod).rgb;
  476.     var col = env * envBRDF(f0, rough, nov);
  477.     col += specDirect(n, v, normalize(u.lightDir.xyz), rough, f0) * vec3f(3.2, 3.1, 2.95);
  478.     col += specDirect(n, v, normalize(vec3f(-0.6, 0.3, -0.7)), rough, f0) * vec3f(0.8, 0.95, 1.25);
  479.     return col;
  480. }
  481. fn tonemap(c: vec3f) -> vec3f {
  482.     let x = max(c * 1.15, vec3f(0.0));
  483.     let aces = clamp(x * (2.51 * x + 0.03) / (x * (2.43 * x + 0.59) + 0.14), vec3f(0.0), vec3f(1.0));
  484.     return pow(aces, vec3f(0.45454545));
  485. }
  486. @fragment fn fs_main(@builtin(front_facing) ff: bool, @location(0) world: vec3f, @location(1) normal: vec3f) -> @location(0) vec4f {
  487.     return vec4f(tonemap(shade(world, select(-normal, normal, ff))), 1.0);
  488. }
  489. @fragment fn fs_refl(@builtin(front_facing) ff: bool, @location(0) world: vec3f, @location(1) normal: vec3f) -> @location(0) vec4f {
  490.     return vec4f(clamp(shade(world, select(-normal, normal, ff)), vec3f(0.0), vec3f(1.0)), 1.0);
  491. }
  492. `;
  493.  
  494. const FLOOR = `
  495. struct U { mvp: mat4x4f, camPos: vec4f, size: vec4f };
  496. @group(0) @binding(0) var<uniform> u: U;
  497. @group(0) @binding(1) var reflTex: texture_2d<f32>;
  498. @group(0) @binding(2) var reflSamp: sampler;
  499. struct VOut { @builtin(position) pos: vec4f, @location(0) world: vec3f };
  500. @vertex fn vs_main(@location(0) p: vec3f) -> VOut {
  501.     var o: VOut;
  502.     o.world = p;
  503.     o.pos = u.mvp * vec4f(p, 1.0);
  504.     return o;
  505. }
  506. fn tonemap(c: vec3f) -> vec3f {
  507.     let x = max(c * 1.15, vec3f(0.0));
  508.     let aces = clamp(x * (2.51 * x + 0.03) / (x * (2.43 * x + 0.59) + 0.14), vec3f(0.0), vec3f(1.0));
  509.     return pow(aces, vec3f(0.45454545));
  510. }
  511. @fragment fn fs_main(@builtin(position) fp: vec4f, @location(0) world: vec3f) -> @location(0) vec4f {
  512.     let ix = i32(floor(world.x));
  513.     let iz = i32(floor(world.z));
  514.     let odd = (abs(ix) % 2 == 1) != (abs(iz) % 2 == 1);
  515.     let th = fract(sin(dot(vec2f(f32(ix), f32(iz)), vec2f(127.1, 311.7))) * 43758.5453);
  516.     var albedo = select(vec3f(0.018, 0.018, 0.02), vec3f(0.62, 0.62, 0.64), odd);
  517.     albedo *= 0.92 + 0.16 * th;
  518.     let fx = fract(world.x);
  519.     let fz = fract(world.z);
  520.     let gd = min(min(fx, 1.0 - fx), min(fz, 1.0 - fz));
  521.     let grout = smoothstep(0.0, 0.035, gd);
  522.     albedo *= mix(0.35, 1.0, grout);
  523.     var col = albedo * 1.05;
  524.     let d2 = dot(world.xz, world.xz);
  525.     col *= 1.0 - 0.38 * exp(-d2 / 1.5);
  526.     let uv = clamp(fp.xy / u.size.xy, vec2f(0.0), vec2f(1.0));
  527.     let refl = textureSample(reflTex, reflSamp, uv);
  528.     let v = normalize(u.camPos.xyz - world);
  529.     var f = clamp(0.9 - v.y * 0.6, 0.25, 0.8);
  530.     f *= exp(-length(world.xz) * 0.1);
  531.     f *= mix(0.45, 1.0, grout) * (0.7 + 0.55 * th);
  532.     col = mix(col, refl.rgb, clamp(f, 0.0, 1.0) * refl.a);
  533.     let l = normalize(vec3f(0.5, 0.85, 0.35));
  534.     let hv = normalize(l + v);
  535.     col += vec3f(pow(max(hv.y, 0.0), 140.0)) * 0.3 * grout;
  536.     let edge = smoothstep(5.4, 6.0, max(abs(world.x), abs(world.z)));
  537.     col = mix(col, vec3f(0.012, 0.014, 0.018), edge);
  538.     return vec4f(tonemap(col), 1.0);
  539. }
  540. `;
  541.  
  542. const BACKGROUND = `
  543. struct U { right: vec4f, up: vec4f, fwd: vec4f, params: vec4f };
  544. @group(0) @binding(0) var<uniform> u: U;
  545. @group(0) @binding(1) var envTex: texture_2d<f32>;
  546. @group(0) @binding(2) var envSamp: sampler;
  547. struct VOut { @builtin(position) pos: vec4f, @location(0) ndc: vec2f };
  548. @vertex fn vs_main(@builtin(vertex_index) idx: u32) -> VOut {
  549.     var pts = array<vec2f, 3>(vec2f(-1.0, -1.0), vec2f(3.0, -1.0), vec2f(-1.0, 3.0));
  550.     var o: VOut;
  551.     o.ndc = pts[idx];
  552.     o.pos = vec4f(pts[idx], 1.0, 1.0);
  553.     return o;
  554. }
  555. fn tonemap(c: vec3f) -> vec3f {
  556.     let x = max(c * 1.15, vec3f(0.0));
  557.     let aces = clamp(x * (2.51 * x + 0.03) / (x * (2.43 * x + 0.59) + 0.14), vec3f(0.0), vec3f(1.0));
  558.     return pow(aces, vec3f(0.45454545));
  559. }
  560. @fragment fn fs_main(@location(0) ndc: vec2f) -> @location(0) vec4f {
  561.     let ray = normalize(u.fwd.xyz + ndc.x * u.params.x * u.right.xyz + ndc.y * u.params.x * u.up.xyz);
  562.     let uv = vec2f(atan2(ray.z, ray.x) / 6.2831853 + 0.5, acos(clamp(ray.y, -1.0, 1.0)) / 3.14159265);
  563.     let env = textureSampleLevel(envTex, envSamp, uv, 1.0).rgb;
  564.     return vec4f(tonemap(env), 1.0);
  565. }
  566. `;
  567.  
  568. let demoGen = 0;
  569.  
  570. function expectedPixel(x, y) {
  571.   const dx = x + 0.5 - 640;
  572.   const dy = y + 0.5 - 640;
  573.   const r = Math.sqrt(dx * dx + dy * dy);
  574.   if (r > 1000 || r < 1) return [0, 0, 0, 0];
  575.  const angleRad = (2000 - 2 * r) * Math.PI / 180;
  576.  let local = Math.atan2(dy, dx);
  577.  if (local < 0) local += 2 * Math.PI;
  578.  let src = (local - angleRad) % (2 * Math.PI);
  579.  if (src < 0) src += 2 * Math.PI;
  580.  const idx = Math.floor(src / ((2 * Math.PI) / 19)) % 19;
  581.  return [PALETTE[idx][0], PALETTE[idx][1], PALETTE[idx][2], 255];
  582. }
  583.  
  584. async function describeAdapter(label, adapter) {
  585.  const t0 = performance.now();
  586.  if (!adapter) { check(label + " adapter", false, "null in " + ms(t0)); return null; }
  587.  check(label + " adapter", true, "returned in " + ms(t0));
  588.  const inf = adapter.info || {};
  589.  info("vendor=" + (inf.vendor || "?") + " architecture=" + (inf.architecture || "?") +
  590.       " device=" + (inf.device || "?") + " description=" + (inf.description || "?"));
  591.  info("isFallbackAdapter=" + adapter.isFallbackAdapter);
  592.  const feats = [...adapter.features].sort();
  593.  info("features (" + feats.length + "): " + (feats.join(", ") || "none"));
  594.  const lim = adapter.limits || {};
  595.  const keys = Object.keys(lim).sort();
  596.  info("limits (" + keys.length + "):");
  597.  for (const k of keys) info("  " + k + "=" + lim[k]);
  598.  return adapter;
  599. }
  600.  
  601. async function main() {
  602.  lines.length = 0;
  603.  passCount = 0;
  604.  failCount = 0;
  605.  reportEl.textContent = "";
  606.  summaryEl.textContent = "Running\u2026";
  607.  const started = new Date();
  608.  add("WebGPU Full System Check");
  609.  add("run at " + started.toISOString() + "  local " + started.toString());
  610.  
  611.  section("1  Environment");
  612.  check("secure context", !!window.isSecureContext, "isSecureContext=" + window.isSecureContext + " protocol=" + location.protocol + " host=" + (location.host || "(file)"));
  613.  info("userAgent=" + navigator.userAgent);
  614.  info("platform=" + (navigator.platform || "?") + " hardwareConcurrency=" + navigator.hardwareConcurrency + " deviceMemory=" + (navigator.deviceMemory || "?") + "GB");
  615.  check("navigator.gpu present", !!navigator.gpu, "navigator.gpu=" + !!navigator.gpu);
  616.  if (navigator.gpu && navigator.gpu.wgslLanguageFeatures) {
  617.    info("wgslLanguageFeatures: " + [...navigator.gpu.wgslLanguageFeatures].sort().join(", "));
  618.  }
  619.  if (!navigator.gpu) {
  620.    add("STOP: no navigator.gpu, nothing further can run.");
  621.    finish();
  622.    return;
  623.  }
  624.  
  625.  section("2  Adapter requests (each tried separately)");
  626.  let t0 = performance.now();
  627.  let defAdapter = null;
  628.  try { defAdapter = await navigator.gpu.requestAdapter(); } catch (e) { info("default threw: " + e.message); }
  629.  await describeAdapter("default", defAdapter);
  630.  let hpAdapter = null;
  631.  try { hpAdapter = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" }); } catch (e) { info("high-performance threw: " + e.message); }
  632.  await describeAdapter("high-performance", hpAdapter);
  633.  let lpAdapter = null;
  634.  try { lpAdapter = await navigator.gpu.requestAdapter({ powerPreference: "low-power" }); } catch (e) { info("low-power threw: " + e.message); }
  635.  await describeAdapter("low-power", lpAdapter);
  636.  let fbAdapter = null;
  637.  try { fbAdapter = await navigator.gpu.requestAdapter({ forceFallbackAdapter: true }); } catch (e) { info("fallback threw: " + e.message); }
  638.  await describeAdapter("fallback (forceFallbackAdapter)", fbAdapter);
  639.  info("adapter requests total: " + ms(t0));
  640.  
  641.  const adapter = defAdapter || hpAdapter || lpAdapter || fbAdapter;
  642.  if (!adapter) {
  643.    add("STOP: every adapter request returned null. WebGPU cannot run in this browser/launch mode.");
  644.    add("If this was headless Chrome, that matches the known headless result: headed Chrome on the same machine returned an adapter.");
  645.    finish();
  646.    return;
  647.  }
  648.  const which = defAdapter ? "default" : hpAdapter ? "high-performance" : lpAdapter ? "low-power" : "fallback";
  649.  info("using adapter: " + which);
  650.  
  651.  section("3  Device");
  652.  let device = null;
  653.  t0 = performance.now();
  654.  try {
  655.    device = await adapter.requestDevice();
  656.    check("requestDevice", !!device, "in " + ms(t0));
  657.  } catch (e) {
  658.    check("requestDevice", false, e.message);
  659.    finish();
  660.    return;
  661.  }
  662.  info("device.features (" + device.features.size + "): " + [...device.features].sort().join(", "));
  663.  const dlim = device.limits || {};
  664.  const dkeys = Object.keys(dlim).sort();
  665.  info("device.limits (" + dkeys.length + "):");
  666.  for (const k of dkeys) info("  " + k + "=" + dlim[k]);
  667.  if (device.label !== undefined) info("device.label=" + JSON.stringify(device.label));
  668.  device.addEventListener("uncapturederror", (e) => { add("UNCAPTURED DEVICE ERROR: " + e.error.message); });
  669.  
  670.   section("4  WGSL compile");
  671.   const module = device.createShaderModule({ code: SPIRAL });
  672.   t0 = performance.now();
  673.   const ci = await module.getCompilationInfo();
  674.   const errors = ci.messages.filter((m) => m.type === "error");
  675.   const warnings = ci.messages.filter((m) => m.type === "warning");
  676.   check("spiral WGSL compiles", errors.length === 0, errors.length + " errors, " + warnings.length + " warnings, in " + ms(t0));
  677.   for (const m of ci.messages) info("[" + m.type + "] L" + m.lineNum + ":" + m.linePos + " " + m.message);
  678.   if (ci.messages.length === 0) info("compilation clean");
  679.   const badModule = device.createShaderModule({ code: "@fragment fn broken( {" });
  680.   const badInfo = await badModule.getCompilationInfo();
  681.   const badErrors = badInfo.messages.filter((m) => m.type === "error");
  682.   check("broken WGSL is caught", badErrors.length > 0, badErrors.length + " error(s) reported; first: " + (badErrors[0] ? badErrors[0].message : "none"));
  683.  
  684.   section("5  Compute shader (exact values)");
  685.   const aVals = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8]);
  686.   const bVals = new Float32Array([10, 20, 30, 40, 50, 60, 70, 80]);
  687.   const expected = [11, 24, 39, 56, 75, 96, 119, 144];
  688.   let computeOk = false;
  689.   let computeDetail = "";
  690.   try {
  691.     t0 = performance.now();
  692.     const compModule = device.createShaderModule({ code: COMPUTE });
  693.     const compPipeline = device.createComputePipeline({ layout: "auto", compute: { module: compModule, entryPoint: "main" } });
  694.     function storageBuf(vals) {
  695.       const buf = device.createBuffer({ size: vals.byteLength, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST });
  696.       device.queue.writeBuffer(buf, 0, vals);
  697.       return buf;
  698.     }
  699.     const aBuf = storageBuf(aVals);
  700.     const bBuf = storageBuf(bVals);
  701.     const outBuf = device.createBuffer({ size: 32, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC });
  702.     const readBuf = device.createBuffer({ size: 32, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST });
  703.     const bindGroup = device.createBindGroup({
  704.       layout: compPipeline.getBindGroupLayout(0),
  705.       entries: [
  706.         { binding: 0, resource: { buffer: aBuf } },
  707.         { binding: 1, resource: { buffer: bBuf } },
  708.         { binding: 2, resource: { buffer: outBuf } }
  709.       ]
  710.     });
  711.     device.pushErrorScope("validation");
  712.     const enc = device.createCommandEncoder();
  713.     const pass = enc.beginComputePass();
  714.     pass.setPipeline(compPipeline);
  715.     pass.setBindGroup(0, bindGroup);
  716.     pass.dispatchWorkgroups(1);
  717.     pass.end();
  718.     enc.copyBufferToBuffer(outBuf, 0, readBuf, 0, 32);
  719.     device.queue.submit([enc.finish()]);
  720.     const compErr = await device.popErrorScope();
  721.     if (compErr) throw new Error("validation: " + compErr.message);
  722.     await readBuf.mapAsync(GPUMapMode.READ);
  723.     const got = Array.from(new Float32Array(readBuf.getMappedRange()));
  724.     readBuf.unmap();
  725.     computeOk = got.length === 8 && got.every((v, i) => v === expected[i]);
  726.     computeDetail = "got [" + got.join(", ") + "] expected [" + expected.join(", ") + "] in " + ms(t0);
  727.   } catch (e) {
  728.     computeDetail = e.message;
  729.   }
  730.   check("compute a*a+b", computeOk, computeDetail);
  731.  
  732.   section("6  Canvas demo (rotating silver teapot, visible below)");
  733.   let canvasOk = false;
  734.   let canvasDetail = "";
  735.   try {
  736.     t0 = performance.now();
  737.     const gen = ++demoGen;
  738.     const canvas = document.getElementById("c");
  739.     const ctx = canvas.getContext("webgpu");
  740.     const format = navigator.gpu.getPreferredCanvasFormat();
  741.     info("preferred canvas format: " + format);
  742.     const potModule = device.createShaderModule({ code: TEAPOT });
  743.     const potCI = await potModule.getCompilationInfo();
  744.     const potErrs = potCI.messages.filter((m) => m.type === "error");
  745.     info("teapot WGSL: " + potErrs.length + " errors, " + potCI.messages.length + " messages");
  746.     if (potErrs.length) throw new Error("teapot WGSL: " + potErrs[0].message);
  747.     const floorModule = device.createShaderModule({ code: FLOOR });
  748.     const floorCI = await floorModule.getCompilationInfo();
  749.     const floorErrs = floorCI.messages.filter((m) => m.type === "error");
  750.     info("floor WGSL: " + floorErrs.length + " errors, " + floorCI.messages.length + " messages");
  751.     if (floorErrs.length) throw new Error("floor WGSL: " + floorErrs[0].message);
  752.     const bgModule = device.createShaderModule({ code: BACKGROUND });
  753.     const bgCI = await bgModule.getCompilationInfo();
  754.     const bgErrs = bgCI.messages.filter((m) => m.type === "error");
  755.     info("background WGSL: " + bgErrs.length + " errors, " + bgCI.messages.length + " messages");
  756.     if (bgErrs.length) throw new Error("background WGSL: " + bgErrs[0].message);
  757.     const envLevels = buildEnvData();
  758.     const envTex = device.createTexture({ size: [envLevels[0].w, envLevels[0].h, 1], mipLevelCount: envLevels.length, format: "rgba16float", usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST });
  759.     for (let i = 0; i < envLevels.length; i++) {
  760.      const L = envLevels[i];
  761.      device.queue.writeTexture({ texture: envTex, mipLevel: i }, L.data, { bytesPerRow: L.w * 8, rowsPerImage: L.h }, [L.w, L.h, 1]);
  762.    }
  763.    info("environment: procedural HDR studio equirect " + envLevels[0].w + "x" + envLevels[0].h + " rgba16float, " + envLevels.length + " mip levels (roughness blur)");
  764.    const envSampler = device.createSampler({ addressModeU: "repeat", addressModeV: "clamp-to-edge", magFilter: "linear", minFilter: "linear", mipmapFilter: "linear" });
  765.    const mesh = buildTeapot();
  766.    info("teapot mesh: " + (mesh.positions.length / 3) + " vertices, " + (mesh.indices.length / 3) + " triangles (Utah teapot: 32 bicubic Bezier patches, 306 control points, Crow 1987 data, welded and tessellated in code)");
  767.    const vCount = mesh.positions.length / 3;
  768.    const vData = new Float32Array(vCount * 6);
  769.    for (let i = 0; i < vCount; i++) {
  770.      vData.set(mesh.positions.subarray(i * 3, i * 3 + 3), i * 6);
  771.      vData.set(mesh.normals.subarray(i * 3, i * 3 + 3), i * 6 + 3);
  772.    }
  773.    const vBuf = device.createBuffer({ size: vData.byteLength, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST });
  774.    device.queue.writeBuffer(vBuf, 0, vData);
  775.    const iBuf = device.createBuffer({ size: mesh.indices.byteLength, usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST });
  776.    device.queue.writeBuffer(iBuf, 0, mesh.indices);
  777.    const potLayout = {
  778.      arrayStride: 24,
  779.      attributes: [
  780.        { shaderLocation: 0, offset: 0, format: "float32x3" },
  781.        { shaderLocation: 1, offset: 12, format: "float32x3" }
  782.      ]
  783.    };
  784.    function potPipe(targetFormat, cull, fragEntry) {
  785.      return device.createRenderPipeline({
  786.        layout: "auto",
  787.        vertex: { module: potModule, entryPoint: "vs_main", buffers: [potLayout] },
  788.        fragment: { module: potModule, entryPoint: fragEntry, targets: [{ format: targetFormat }] },
  789.        primitive: { topology: "triangle-list", cullMode: cull },
  790.        depthStencil: { format: "depth24plus", depthWriteEnabled: true, depthCompare: "less" }
  791.      });
  792.    }
  793.    const potPipeCanvas = potPipe(format, "none", "fs_main");
  794.    const potPipeRefl = potPipe("rgba8unorm", "none", "fs_refl");
  795.    const floorVerts = new Float32Array([-6, 0, -6, 6, 0, -6, -6, 0, 6, 6, 0, 6]);
  796.    const floorIdx = new Uint32Array([0, 2, 1, 1, 2, 3]);
  797.    const floorVBuf = device.createBuffer({ size: floorVerts.byteLength, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST });
  798.    device.queue.writeBuffer(floorVBuf, 0, floorVerts);
  799.    const floorIBuf = device.createBuffer({ size: floorIdx.byteLength, usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST });
  800.    device.queue.writeBuffer(floorIBuf, 0, floorIdx);
  801.    const floorPipe = device.createRenderPipeline({
  802.      layout: "auto",
  803.      vertex: { module: floorModule, entryPoint: "vs_main", buffers: [{ arrayStride: 12, attributes: [{ shaderLocation: 0, offset: 0, format: "float32x3" }] }] },
  804.      fragment: { module: floorModule, entryPoint: "fs_main", targets: [{ format }] },
  805.      primitive: { topology: "triangle-list", cullMode: "none" },
  806.      depthStencil: { format: "depth24plus", depthWriteEnabled: false, depthCompare: "less" }
  807.    });
  808.    const bgPipe = device.createRenderPipeline({
  809.      layout: "auto",
  810.      vertex: { module: bgModule, entryPoint: "vs_main" },
  811.      fragment: { module: bgModule, entryPoint: "fs_main", targets: [{ format }] },
  812.      primitive: { topology: "triangle-list", cullMode: "none" },
  813.      depthStencil: { format: "depth24plus", depthWriteEnabled: false, depthCompare: "always" }
  814.    });
  815.    const bgUni = device.createBuffer({ size: 80, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST });
  816.    const bgBind = device.createBindGroup({
  817.      layout: bgPipe.getBindGroupLayout(0),
  818.      entries: [
  819.        { binding: 0, resource: { buffer: bgUni } },
  820.        { binding: 1, resource: envTex.createView() },
  821.        { binding: 2, resource: envSampler }
  822.      ]
  823.    });
  824.    ctx.configure({ device, format, alphaMode: "premultiplied" });
  825.    const eye = [4.4, 3.2, 5.6];
  826.    const view = mat4LookAt(eye, [0, 1.15, 0], [0, 1, 0]);
  827.    const proj = mat4Perspective(0.75, 1, 0.1, 100);
  828.    const vp = mat4Multiply(proj, view);
  829.    function uniBuf(bytes) { return device.createBuffer({ size: bytes, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }); }
  830.    const potUni = uniBuf(160);
  831.    const potUniRefl = uniBuf(160);
  832.    const floorUni = uniBuf(96);
  833.    function writePot(buf, model) {
  834.      const d = new Float32Array(40);
  835.      d.set(mat4Multiply(vp, model), 0);
  836.      d.set(model, 16);
  837.      d.set([eye[0], eye[1], eye[2], 0], 32);
  838.      d.set([0.5, 0.85, 0.35, 0], 36);
  839.      device.queue.writeBuffer(buf, 0, d);
  840.    }
  841.    function writeFloor() {
  842.      const d = new Float32Array(24);
  843.      d.set(vp, 0);
  844.      d.set([eye[0], eye[1], eye[2], 0], 16);
  845.      d.set([1280, 1280, 0, 0], 20);
  846.      device.queue.writeBuffer(floorUni, 0, d);
  847.    }
  848.    writeFloor();
  849.    {
  850.      let fx = -eye[0], fy = 1.15 - eye[1], fz = -eye[2];
  851.      let l = Math.hypot(fx, fy, fz); fx /= l; fy /= l; fz /= l;
  852.      let rx = -fz, ry = 0, rz = fx;
  853.      l = Math.hypot(rx, ry, rz); rx /= l; ry /= l; rz /= l;
  854.      const ux = ry * fz - rz * fy, uy = rz * fx - rx * fz, uz = rx * fy - ry * fx;
  855.      const d = new Float32Array(20);
  856.      d.set([rx, ry, rz, 0], 0);
  857.      d.set([ux, uy, uz, 0], 4);
  858.      d.set([fx, fy, fz, 0], 8);
  859.      d.set([Math.tan(0.375), 1, 0, 0], 12);
  860.      device.queue.writeBuffer(bgUni, 0, d);
  861.    }
  862.    const reflTex = device.createTexture({ size: [640, 640, 1], format: "rgba8unorm", usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING });
  863.    const reflDepth = device.createTexture({ size: [640, 640, 1], format: "depth24plus", usage: GPUTextureUsage.RENDER_ATTACHMENT });
  864.    const canvasDepth = device.createTexture({ size: [1280, 1280, 1], format: "depth24plus", usage: GPUTextureUsage.RENDER_ATTACHMENT });
  865.    const potBind = device.createBindGroup({
  866.      layout: potPipeCanvas.getBindGroupLayout(0),
  867.      entries: [
  868.        { binding: 0, resource: { buffer: potUni } },
  869.        { binding: 1, resource: envTex.createView() },
  870.        { binding: 2, resource: envSampler }
  871.      ]
  872.    });
  873.    const potBindRefl = device.createBindGroup({
  874.      layout: potPipeRefl.getBindGroupLayout(0),
  875.      entries: [
  876.        { binding: 0, resource: { buffer: potUniRefl } },
  877.        { binding: 1, resource: envTex.createView() },
  878.        { binding: 2, resource: envSampler }
  879.      ]
  880.    });
  881.    const sampler = device.createSampler({ magFilter: "linear", minFilter: "linear" });
  882.    const floorBind = device.createBindGroup({
  883.      layout: floorPipe.getBindGroupLayout(0),
  884.      entries: [
  885.        { binding: 0, resource: { buffer: floorUni } },
  886.        { binding: 1, resource: reflTex.createView() },
  887.        { binding: 2, resource: sampler }
  888.      ]
  889.    });
  890.    function drawFrame(now, validate) {
  891.      const ang = now * 0.0007;
  892.      const bob = Math.sin(now * 0.0011) * 0.06;
  893.      const model = mat4Multiply(mat4Translate(0, bob, 0), mat4RotY(ang));
  894.      const modelRefl = mat4Multiply(mat4Scale(1, -1, 1), model);
  895.      writePot(potUni, model);
  896.      writePot(potUniRefl, modelRefl);
  897.      if (validate) device.pushErrorScope("validation");
  898.      const enc = device.createCommandEncoder();
  899.      const rp = enc.beginRenderPass({
  900.        colorAttachments: [{ view: reflTex.createView(), clearValue: { r: 0, g: 0, b: 0, a: 0 }, loadOp: "clear", storeOp: "store" }],
  901.        depthStencilAttachment: { view: reflDepth.createView(), depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
  902.      });
  903.      rp.setPipeline(potPipeRefl);
  904.      rp.setBindGroup(0, potBindRefl);
  905.      rp.setVertexBuffer(0, vBuf);
  906.      rp.setIndexBuffer(iBuf, "uint32");
  907.      rp.drawIndexed(mesh.indices.length);
  908.      rp.end();
  909.      const cp = enc.beginRenderPass({
  910.        colorAttachments: [{ view: ctx.getCurrentTexture().createView(), clearValue: { r: 0.05, g: 0.06, b: 0.08, a: 1 }, loadOp: "clear", storeOp: "store" }],
  911.        depthStencilAttachment: { view: canvasDepth.createView(), depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
  912.      });
  913.      cp.setPipeline(bgPipe);
  914.      cp.setBindGroup(0, bgBind);
  915.      cp.draw(3);
  916.      cp.setPipeline(floorPipe);
  917.      cp.setBindGroup(0, floorBind);
  918.      cp.setVertexBuffer(0, floorVBuf);
  919.      cp.setIndexBuffer(floorIBuf, "uint32");
  920.      cp.drawIndexed(6);
  921.      cp.setPipeline(potPipeCanvas);
  922.      cp.setBindGroup(0, potBind);
  923.      cp.setVertexBuffer(0, vBuf);
  924.      cp.setIndexBuffer(iBuf, "uint32");
  925.      cp.drawIndexed(mesh.indices.length);
  926.      cp.end();
  927.      device.queue.submit([enc.finish()]);
  928.      if (validate) return device.popErrorScope();
  929.      return null;
  930.    }
  931.    const firstErr = await drawFrame(0, true);
  932.    if (firstErr) throw new Error("validation: " + firstErr.message);
  933.    await device.queue.onSubmittedWorkDone();
  934.    canvasOk = true;
  935.    canvasDetail = "teapot first frame complete in " + ms(t0) + "; rotating live (GGX PBR silver, procedural HDR studio environment, ACES, mirrored reflection on checkered floor)";
  936.    const loop = (now) => {
  937.       if (gen !== demoGen) return;
  938.       try { drawFrame(now, false); } catch (e) { return; }
  939.       requestAnimationFrame(loop);
  940.     };
  941.     requestAnimationFrame(loop);
  942.   } catch (e) {
  943.     canvasDetail = e.message;
  944.   }
  945.   check("canvas demo (silver teapot)", canvasOk, canvasDetail);
  946.  
  947.   section("7  Offscreen render + pixel readback");
  948.   let readOk = false;
  949.   let readDetail = "";
  950.   try {
  951.     t0 = performance.now();
  952.     const tex = device.createTexture({
  953.       size: [1280, 1280, 1],
  954.       format: "rgba8unorm",
  955.       usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
  956.     });
  957.     const pipe = device.createRenderPipeline({
  958.       layout: "auto",
  959.       vertex: { module, entryPoint: "vs_main" },
  960.       fragment: { module, entryPoint: "fs_main", targets: [{ format: "rgba8unorm" }] },
  961.       primitive: { topology: "triangle-list" }
  962.     });
  963.     const bytesPerRow = 1280 * 4;
  964.     const readBuf = device.createBuffer({ size: bytesPerRow * 1280, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST });
  965.     device.pushErrorScope("validation");
  966.     const enc = device.createCommandEncoder();
  967.     const pass = enc.beginRenderPass({
  968.       colorAttachments: [{ view: tex.createView(), clearValue: { r: 0, g: 0, b: 0, a: 0 }, loadOp: "clear", storeOp: "store" }]
  969.     });
  970.     pass.setPipeline(pipe);
  971.     pass.draw(3);
  972.     pass.end();
  973.     enc.copyTextureToBuffer({ texture: tex }, { buffer: readBuf, bytesPerRow }, [1280, 1280, 1]);
  974.     device.queue.submit([enc.finish()]);
  975.     const err = await device.popErrorScope();
  976.     if (err) throw new Error("validation: " + err.message);
  977.     await device.queue.onSubmittedWorkDone();
  978.     await readBuf.mapAsync(GPUMapMode.READ);
  979.     const data = new Uint8Array(readBuf.getMappedRange());
  980.     const samples = [[940, 640], [640, 940], [340, 640], [640, 340], [1140, 840], [840, 1140], [640, 640], [100, 100]];
  981.     let bad = 0;
  982.     for (const [x, y] of samples) {
  983.       const o = (y * 1280 + x) * 4;
  984.       const got = [data[o], data[o + 1], data[o + 2], data[o + 3]];
  985.       const exp = expectedPixel(x, y);
  986.       const close = got.every((v, i) => Math.abs(v - exp[i]) <= 2);
  987.      info("pixel (" + x + "," + y + ") got [" + got.join(",") + "] expected [" + exp.join(",") + "] " + (close ? "match" : "MISMATCH"));
  988.      if (!close) bad++;
  989.    }
  990.    const seen = new Set();
  991.    for (let y = 0; y < 1280; y += 16) {
  992.      for (let x = 0; x < 1280; x += 16) {
  993.        const o = (y * 1280 + x) * 4;
  994.        seen.add(data[o] + "," + data[o + 1] + "," + data[o + 2]);
  995.      }
  996.    }
  997.    info("distinct colours in 16px sample grid: " + seen.size + " (spiral palette has 19 + black)");
  998.    readBuf.unmap();
  999.    readOk = bad === 0 && seen.size >= 10;
  1000.     readDetail = bad + " pixel mismatches, " + seen.size + " distinct colours, in " + ms(t0);
  1001.   } catch (e) {
  1002.     readDetail = e.message;
  1003.   }
  1004.   check("offscreen pixels match spiral math", readOk, readDetail);
  1005.  
  1006.   finish();
  1007. }
  1008.  
  1009. function finish() {
  1010.   add("");
  1011.   add("== Summary ==");
  1012.   add("PASS " + passCount + "   FAIL " + failCount);
  1013.   add(failCount === 0 ? "RESULT: WebGPU fully working on this system." : "RESULT: " + failCount + " check(s) failed - see FAIL lines above.");
  1014.   summaryEl.textContent = failCount === 0 ? "PASS " + passCount + " / FAIL 0 - WebGPU fully working" : "PASS " + passCount + " / FAIL " + failCount;
  1015.   summaryEl.className = failCount === 0 ? "pass" : "fail";
  1016. }
  1017.  
  1018. document.getElementById("copyBtn").addEventListener("click", async () => {
  1019.   try { await navigator.clipboard.writeText(reportEl.textContent); summaryEl.textContent += "  (report copied)"; }
  1020.   catch (e) {
  1021.     const sel = window.getSelection();
  1022.     sel.selectAllChildren(reportEl);
  1023.   }
  1024. });
  1025. document.getElementById("dlBtn").addEventListener("click", () => {
  1026.   const blob = new Blob([reportEl.textContent], { type: "text/plain" });
  1027.   const a = document.createElement("a");
  1028.   a.href = URL.createObjectURL(blob);
  1029.   a.download = "webgpu-full-check.txt";
  1030.   a.click();
  1031.   URL.revokeObjectURL(a.href);
  1032. });
  1033. document.getElementById("rerunBtn").addEventListener("click", () => { main().catch((e) => add("ERROR: " + e.message)); });
  1034.  
  1035. main().catch((e) => { add("ERROR: " + (e && e.message)); finish(); });
  1036. </script>
  1037. </body>
  1038. </html>
  1039.  
Advertisement
Add Comment
Please, Sign In to add comment