Official Codebase of 3DCodeVerse
Python
a frame rate measured on SwiftShader is the box's, and neither gates nor judges
ziyao17a5ab1f61d6
diff --git a/harness/codeverse/contracts/artifacts.py b/harness/codeverse/contracts/artifacts.pyindex 70a61862..d96ce10a 100644--- a/harness/codeverse/contracts/artifacts.py+++ b/harness/codeverse/contracts/artifacts.py@@ -128,6 +128,13 @@ class RenderView(BaseModel):)+#: A renderer string that means "no hardware did this". Same words as+#: `runtime_js/gpu_launch.cjs` SOFTWARE_RE, which is what decides whether a GPU attempt+#: is trusted; kept here because `fps` is only a fact about the scene when hardware+#: measured it.+SOFTWARE_RENDERERS = ("swiftshader", "llvmpipe", "softpipe", "software", "basic render")++class RenderSet(BaseModel):views: list[RenderView] = Field(default_factory=list)contact_sheet: str | None = Field(default=None, description="one labelled grid image of all views")@@ -137,6 +144,25 @@ class RenderSet(BaseModel):fps: float | None = Noneout_dir: str = Field(default="", description="directory the views (+ views.json/metrics.json) were written to")+ @property+ def software_rendered(self) -> bool:+ """True when these pixels came from a CPU rasteriser.++ Measured on bench/out/scene_baseline (2026-09-05): with the box's eight GPUs at+ ~100 % from other work, the GPU probe's negative verdict is cached for 20 minutes,+ so cells fell back to SwiftShader one at a time and `fps` was measured on a+ DIFFERENT renderer per cell — 11.5 fps on an RTX 6000 Ada for one, 5.1 / 7.1 / 2.0+ on SwiftShader for the next three. A CPU number is not comparable with a GPU one+ and is not a property of the scene, so nothing may gate or judge on it.+ """+ low = self.renderer.lower()+ return any(word in low for word in SOFTWARE_RENDERERS)++ @property+ def hardware_fps(self) -> float | None:+ """`fps` when hardware measured it, else None — the only form worth reporting."""+ return None if (self.fps is None or self.software_rendered) else self.fps+# ===================================================================== judgmentclass JudgeIssue(BaseModel):diff --git a/harness/codeverse/judges/prompt_builder.py b/harness/codeverse/judges/prompt_builder.pyindex 3450e3ba..46cf216c 100644--- a/harness/codeverse/judges/prompt_builder.py+++ b/harness/codeverse/judges/prompt_builder.py@@ -852,8 +852,15 @@ def view_rig_section(renders: RenderSet, montages: list[Montage], *, scene: boolbits.append(RIG_RULES["object"])if renders.console_errors:bits.append(f"PROBE: {len(renders.console_errors)} console error(s) during rendering, first: {_clip(renders.console_errors[0], 200)}")- if renders.fps is not None:- bits.append(f"PROBE: measured {renders.fps:.0f} fps.")+ # Only a hardware measurement is a fact about the scene; a SwiftShader number is the+ # box's, and the judge has no way to know which it was handed. Rather than drop it+ # silently, say what it is, so a genuinely heavy scene is still visible to a reader.+ if renders.hardware_fps is not None:+ bits.append(f"PROBE: measured {renders.hardware_fps:.0f} fps.")+ elif renders.fps is not None:+ bits.append(f"PROBE: {renders.fps:.0f} fps, but on a CPU rasteriser "+ f"({_clip(renders.renderer, 60)}) — NOT a statement about this scene's cost; "+ f"do not raise a performance issue from it.")bits.append("Images in send order:\n" + describe_montages(montages))return "\n".join(bits)diff --git a/harness/codeverse/tracks/scene.py b/harness/codeverse/tracks/scene.pyindex b3da07eb..0dd6ef01 100644--- a/harness/codeverse/tracks/scene.py+++ b/harness/codeverse/tracks/scene.py@@ -132,9 +132,14 @@ class ScenePipeline:findings = [GateFinding(gate="render_console", severity=Severity.ERROR, target=_guess_target(e, ctx.plan), message=e[:300],fix_hint="open the named module, fix the thrown error; run the build/probe tool until no console errors")for e in errs[:MAX_CONSOLE_ERRORS]]- if renders.fps is not None and renders.fps < 20:+ # `hardware_fps`, not `fps`: a number measured on SwiftShader is the box's, and+ # telling the agent to merge geometry because the CPU rasteriser is slow sends it+ # optimising a scene that was never the problem (2026-09-05, three cells of+ # scenes_v1 measured 2-7 fps on SwiftShader while a fourth measured 11.5 on an+ # RTX 6000 — four different renderers, one gate threshold).+ if renders.hardware_fps is not None and renders.hardware_fps < 20:findings.append(GateFinding(gate="render_console", severity=Severity.WARN, target="overall",- message=f"low frame rate {renders.fps:.0f} fps" + perf_detail(renders),+ message=f"low frame rate {renders.hardware_fps:.0f} fps" + perf_detail(renders),fix_hint="the budget is <= 200 draw calls and <= 2 M triangles: merge static geometry ""(BufferGeometryUtils.mergeGeometries) and put anything repeated > 5x in ONE ""InstancedMesh per material — a per-object mesh loop is what costs the frame rate"))diff --git a/harness/tests/scene_gates/test_software_fps.py b/harness/tests/scene_gates/test_software_fps.pynew file mode 100644index 00000000..ee97ba5c--- /dev/null+++ b/harness/tests/scene_gates/test_software_fps.py@@ -0,0 +1,81 @@+"""A frame rate measured on a CPU rasteriser is the box's, not the scene's.++Measured on `bench/out/scene_baseline` (2026-09-05). With the machine's eight GPUs at+~100 % from other work, the GPU probe's negative verdict is cached for 20 minutes, so+cells fell back to SwiftShader one at a time. Across four scored cells `fps` was+measured on TWO DIFFERENT RENDERERS:++ japanese_garden 11.5 fps ANGLE (NVIDIA Corporation, NVIDIA RTX 6000 Ada …)+ rooftop_garden 5.1 fps ANGLE (Google, … SwiftShader driver)+ medieval_market 7.1 fps ANGLE (Google, … SwiftShader driver)+ snowy_hut 2.0 fps ANGLE (Google, … SwiftShader driver) — 4 frames in 2 s++`render_console` raised "low frame rate" below 20 for all of them and the judge was told+"PROBE: measured N fps" as a fact. Two of the four judge issues marked **critical** in+that battery were frame-rate complaints, so the box was being scored as the model.+"""++from __future__ import annotations++import pytest++from codeverse.contracts.artifacts import RenderSet++GPU = "ANGLE (NVIDIA Corporation, NVIDIA RTX 6000 Ada Generation, Vulkan)"+CPU = "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)"++[email protected]("renderer,software", [+ (GPU, False),+ (CPU, True),+ ("Mesa/X.org llvmpipe (LLVM 15.0.7, 256 bits)", True),+ ("ANGLE (Intel, Mesa Intel(R) UHD Graphics)", False),+ ("", False), # unknown: not claimable as software+])+def test_the_renderer_string_decides(renderer: str, software: bool) -> None:+ assert RenderSet(renderer=renderer, fps=9.0).software_rendered is software+++def test_a_cpu_measurement_is_not_offered_as_a_frame_rate() -> None:+ assert RenderSet(renderer=CPU, fps=2.0).hardware_fps is None+ assert RenderSet(renderer=GPU, fps=11.5).hardware_fps == 11.5+ assert RenderSet(renderer=GPU, fps=None).hardware_fps is None+++def test_the_gate_does_not_fire_on_a_cpu_frame_rate() -> None:+ from types import SimpleNamespace++ from codeverse.contracts.artifacts import GateReport+ from codeverse.contracts.plan import BBox, CameraPlan, ScenePlan, ZonePlan+ from codeverse.tracks.scene import ScenePipeline++ bb = BBox(center=(0, 0, 0), extents=(10, 5, 10))+ plan = ScenePlan(title="t", summary="s", setting="meadow", mood="calm", bounds=bb, environment="sunny",+ zones=[ZonePlan(name="Yard", description="d", bbox=bb, contents=[])], assets=[],+ cameras=[CameraPlan(name="overview", position=(1, 1, 1), look_at=(0, 0, 0), fov=50, purpose="p")],+ animation=[], effects=[])+ # frame_gate reads metrics.json from the render dir; with no views there is none,+ # so a report with no findings is the right stand-in and the events sink is a no-op+ ctx = SimpleNamespace(+ plan=plan, ws=None, extra={},+ services=SimpleNamespace(frame_gate=lambda r: GateReport(gate='scene_frames', passed=True, findings=[])),+ events=SimpleNamespace(emit=lambda *a, **k: None),+ )++ def _fps_findings(renders: RenderSet) -> list[str]:+ reports = ScenePipeline().post_render_gates(ctx, 0, renders) # type: ignore[arg-type]+ return [f.message for r in reports for f in r.findings if "frame rate" in f.message]++ assert _fps_findings(RenderSet(renderer=CPU, fps=2.0)) == [], "SwiftShader's 2 fps is the box"+ assert _fps_findings(RenderSet(renderer=GPU, fps=11.5)), "a real GPU measurement still gates"+++def test_the_judge_is_told_a_cpu_number_is_not_the_scene() -> None:+ """Dropping it silently would hide a genuinely heavy scene from a reader, so the+ line stays — labelled, with an instruction not to raise an issue from it."""+ from codeverse.judges.prompt_builder import view_rig_section++ cpu = view_rig_section(RenderSet(renderer=CPU, fps=2.0), [], scene=True)+ gpu = view_rig_section(RenderSet(renderer=GPU, fps=11.5), [], scene=True)+ assert "CPU rasteriser" in cpu and "do not raise a performance issue" in cpu+ assert "measured 12 fps." in gpu and "CPU rasteriser" not in gpu