4 Commits
Author SHA1 Message Date
西风逍遥游 31880f0021 feat(examples): gate examples in CI and make repository scripts UTF-8 on every host
`examples/<name>/` was a tested surface in name only. The source-quality job had
no examples check at all, and scripts/smoke_examples.sh accepted any process that
had not printed one of its error markers: a project that died during startup,
exited after a single frame, or crashed without a marker was reported as PASS.
Nothing stopped a malformed or unregistered example from reaching dev, which is
how 14 examples arrived without READMEs and 20 were never registered in the
overview table.

Source side
- scripts/check_examples.py classifies every directory under examples/ as either
  runnable (main.nut plus a config.nut that assigns the engine `config` table) or
  as a reviewed non-runnable sample listed in NON_RUNNABLE_EXAMPLES with a
  reason. Both kinds must own a README.md and appear in examples/README.md.
  Stale exemptions and overview links to missing directories fail as well.
- `make check/examples` and a new source-quality CI step run the gate.
- scripts/tests/test_check_examples.py covers it and pins each failure mode
  against fixtures.

Runtime side
- scripts/smoke_examples.sh now enforces liveness, not just marker absence: every
  runnable example must still be running after MIN_RUN_SECONDS (default 2s; CI
  passes 2s), and a process that dies inside that window fails whatever its exit
  code. A clean self-exit after the window passes with an explicit note instead
  of being silently accepted as a pass.
- The Linux CI step sets MIN_RUN_SECONDS=2 and keeps RUN_SECONDS=6, so the job's
  wall clock is unchanged (13.7 min of its 20 min budget on dev).

Windows / GBK
- scripts/utf8_stdio.py re-encodes stdout/stderr as UTF-8 and every scripts/*.py
  program calls it as the first statement of its __main__ block. On a Chinese
  Windows a redirected stream falls back to the ANSI code page (cp936), and
  printing a character that code page cannot encode (arrows, superscripts, bullet
  separators, emoji - all common in this repository) raised UnicodeEncodeError
  and turned a checker into a traceback.
- The mirror image is input: read_text() without encoding= decoded UTF-8
  repository text as cp936 and raised UnicodeDecodeError.
- scripts/tests/test_utf8_stdio.py enforces both conventions for every script and
  test module; text file I/O and child-process decoding now pass encoding="utf-8"
  explicitly.
- Unit-test invocations run with `python3 -X utf8` so the runner's own output
  never follows the host code page.

Violations the new gates found on top of dev, fixed here: 14 examples shipped
without a README (fluid3d, mesh-impact-lab, mesh-modifier-lab, spline-tube-lab on
the earlier dev tip, plus pcg-depth-of-field, pcg-detail-overwrite,
pcg-layer-culling, pcg-location-system, pcg-runtime-orchestration,
pcg-scene-player-culling, pcg-snow-wind, pcg-thunder-strike, pcg-ui-scaler and
pcg-underwater added by #397), 20 were missing from the overview table (those 14
plus archspace-editor, geometry-stroke-lab, interior-mapping, layered-animation,
triplanar-decal, terrain-stamping), and scripts/export_meshret_onnx.py had no
UTF-8 stdio guard.

Verified locally: `python -m ruff check scripts` (All checks passed);
scripts/check_test_manifest.py; scripts/check_quality_metadata.py;
scripts/check_architecture_contracts.py --base HEAD; scripts/check_nodiscard.py;
`make -n check/examples`; scripts/check_examples.py (125 examples: 118 runnable,
7 reviewed non-runnable); and `python -X utf8 -m unittest discover -s scripts/tests
-p "test_*.py"` (155 tests, OK). The runtime half of the contract needs a Linux
headless build, so it is verified by the CI examples smoke step rather than
locally.
2026-09-15 20:20:23 +08:00
西风逍遥游 128fd5c95e feat(graphics): complete classic rendering chain 2026-08-26 22:35:20 +08:00
西风逍遥游 eae8cfbc38 feat(graphics): stage 3 - VirtualGeometry hardware-raster integration
Virtual-geometry assets now render through the main GPU-driven frame instead of
the standalone software-raster experiment:

- Shared VG scene in vulkan::Graphics: pooled positions/triangles/clusters +
  per-cluster asset ids + per-slot visible list / indirect commands / asset
  models + materials. Meshes attach an asset via gpuDrivenVgAttachToMesh;
  GpuMeshRecord.vgAssetId routes them out of the instance chain.
- vg_main_cull.comp runs in the main frame's compute section (frustum + HZB
  against the per-asset model) and emits per-cluster VkDrawIndirectCommand
  (vertexCount = triCount*3, firstInstance = cluster id).
- Hardware raster: mesh3d_gbuffer_vgvis draws clusters with NO vertex input -
  gl_InstanceIndex = cluster, gl_VertexIndex = triangle corner, positions from
  the cluster stream; face normals computed from world edges; writes the same
  visID/visBary attachments (bit31 marks VG clusters).
- resolve_vis.frag decodes VG clusters: asset -> material, interpolates from
  the cluster stream, flat-tint shading via the shared PBR core, writes
  gl_FragDepth so later transparent draws depth-test correctly.
- gpu_emit.comp additionally writes non-indexed VkDrawIndirectCommand per
  bucket (the 20-byte indexed layout's firstInstance sits at offset 16, which
  vkCmdDrawIndirect (16-byte commands) ignores - this was the vis pass showing
  only instance 0). The vis pass now draws from that command stream.
- All per-frame bindless updates (vis samplers 15/16, VG bindings 26-29) moved
  BEFORE the set is bound to the recording command buffer (no UPDATE_AFTER_BIND;
  updating a bound set invalidates the CB - caught by validation).
- drawIndirectCount Vulkan 1.2 feature enabled at device creation; the VG
  count buffer carries VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT.
- RenderControl gains the "visResolve" feature flag (the stage-3 resolve path
  was previously enabled via an unknown flag that setFeature silently dropped).

Verified: GpuDriven.visResolveParity now genuinely exercises the resolve path
(maxDelta = 0.0 vs forward); GpuDriven.vgVisResolve renders a sphere's clusters
through the main frame (9 visible after frustum+HZB, tint-correct center,
frustum-culled to 0 behind the camera); 19 render tests + 3x suite repeat pass;
validation shows no new VUIDs.
2026-08-21 19:04:13 +08:00
西风逍遥游 d82d246465 gpu-driven stage 2: GPU frustum/HZB cull + GPU-written indirect draws
Add the stage-2 compute chain to the main frame:
- ComputePass wrapper + compile script for compute SPIR-V (hzb_build /
  gpu_cull / gpu_emit); bindless set extended with cull UBO, visible flags,
  compacted instances, indirect commands, HZB buffer and GBuffer depth.
- HZB: R32F max-downsampled mip chain per frame slot built from the
  GBuffer depth after the GBuffer pass (buffer-based; offsets header at slot
  start). Same-frame self-occlusion handled by testing the bounding sphere's
  FRONT depth, and near-zero depth (uninitialized/corner garbage) never
  occludes.
- Cull: per-instance Gribb-Hartmann frustum test + HZB occlusion test, flags
  written per instance; emit compacts visible instances per CPU-provided
  bucket layout and fills per-bucket indirect commands with atomic counters.
- Frame wiring: begin3DFrame defers opening the scene color pass when the
  cull chain is live, so the compute section records before the opaque
  draws; RenderSystem3D uploads sorted instances, runs cull+emit, opens the
  pass and draws with GPU-written commands (per-bucket, empty buckets no-op).
  Fallback to stage 1 when compute caps are missing. gpuDriven now forces
  the GBuffer pass (HZB source).
- Known limitation: HZB is built from the same-frame GBuffer, so objects
  already in the GBuffer cannot be occlusion-culled until the GBuffer itself
  is culled (stage 3 vis buffer); the chain is verified with frustum culling
  (2 of 5 instances culled) and pixel parity.

Tests: GpuDriven.opaqueForwardCullParity (5 spheres, 2 outside frustum ->
3 visible / 3 non-empty buckets, pixel parity < 0.03); all 6 GpuDriven
tests pass (integrated GPU; the AMD driver intermittently crashes at
vkCreateImage during init - environmental).
2026-08-21 15:09:39 +08:00