Skip to content

Commit 867555f

Browse files
committed
Stabilize RTX rendering checks across GPUs
1 parent 5cad87b commit 867555f

7 files changed

Lines changed: 59 additions & 5 deletions

File tree

source/_isaaclab_testing/test/rendering/golden_image.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
from isaaclab.utils.images import make_camera_output_grid, normalize_camera_output_for_display
2222

23+
RTX_COLOR_PIXEL_L2_THRESHOLD = 20.0
24+
2325

2426
@dataclass(frozen=True)
2527
class ImageComparison:

source/_isaaclab_testing/test/rendering/rendering_runner.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from typing import Any
1313

1414
import torch
15-
from golden_image import camera_output_image, compare_to_golden
15+
from golden_image import RTX_COLOR_PIXEL_L2_THRESHOLD, camera_output_image, compare_to_golden
1616
from rendering_cases import KIT_RENDERING_CASES, RenderCase
1717
from rendering_runtime import SEMANTIC_COLORS, build_rendering_scene
1818
from rendering_scene_cfgs import make_rendering_scene_spec
@@ -31,6 +31,7 @@
3131
RenderBufferKind.MOTION_VECTORS,
3232
}
3333
_ALPHA_ONLY_AOVS = {RenderBufferKind.INSTANCE_SEGMENTATION, RenderBufferKind.INSTANCE_ID_SEGMENTATION_FAST}
34+
_RTX_COLOR_AOVS = {RenderBufferKind.RGB, RenderBufferKind.ALBEDO}
3435

3536

3637
def run_rendering_case(
@@ -97,6 +98,9 @@ def run_rendering_case(
9798
artifact_dir=_ARTIFACT_DIR,
9899
max_diff_pct=image_max_diff_pct,
99100
min_ssim=None if aov in _NO_SSIM else min_ssim,
101+
pixel_l2_threshold=(
102+
RTX_COLOR_PIXEL_L2_THRESHOLD if case.renderer == "isaac_rtx" and aov in _RTX_COLOR_AOVS else 10.0
103+
),
100104
# OVRTX's numeric semantic IDs vary by USD reader; metadata validates their labels separately.
101105
alpha_only=aov in _ALPHA_ONLY_AOVS
102106
or (case.renderer == "ovrtx" and aov == RenderBufferKind.SEMANTIC_SEGMENTATION),

source/_isaaclab_testing/test/rendering/rendering_runtime.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ def build_rendering_scene(
157157
with build_simulation_context(sim_cfg=sim_cfg) as sim:
158158
if renderer is not None:
159159
sim.set_setting("/isaaclab/render/rtx_sensors", True)
160-
# Golden captures must not race background texture streaming.
161-
sim.set_setting("/rtx-transient/resourcemanager/enableTextureStreaming", False)
160+
if renderer == "ovrtx":
161+
# OVRTX has no Kit USD-context streaming wait; golden captures must not race texture uploads.
162+
sim.set_setting("/rtx-transient/resourcemanager/enableTextureStreaming", False)
162163
runtime = RenderingScene(
163164
sim,
164165
InteractiveScene(scene_cfg),

source/_isaaclab_testing/test/rendering/rendering_scene_cfgs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ def make_rendering_scene_spec(scene: str, physics: str) -> RenderingSceneSpec:
574574
camera_eye=(-5.0, 0.0, 2.0),
575575
camera_target=(0.0, 0.0, 2.0),
576576
expected_instances={f"/World/envs/env_{env_id}/Robot": "cartpole" for env_id in range(4)},
577+
# Isaac RTX color differs across GPU families while the reset pose remains structurally identical.
578+
image_tolerance_overrides={("isaac_rtx", RenderBufferKind.RGB): (8.0, 0.95)},
577579
)
578580
if scene in {"franka_soft", "franka_cloth"}:
579581
if physics != "newton":

source/_isaaclab_testing/test/rendering/test_golden_image.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import pytest
1212
import torch
13-
from golden_image import compare_to_golden
13+
from golden_image import RTX_COLOR_PIXEL_L2_THRESHOLD, compare_to_golden
1414
from PIL import Image
1515
from rendering_runner import _validate_segmentation
1616

@@ -59,6 +59,36 @@ def test_difference_fails_and_writes_artifacts(tmp_path: Path, monkeypatch: pyte
5959
assert comparison.golden_path is not None and comparison.golden_path.exists()
6060

6161

62+
def test_rtx_color_threshold_ignores_small_shifts_but_not_large_deltas(
63+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
64+
) -> None:
65+
monkeypatch.delenv("ISAACLAB_UPDATE_GOLDENS", raising=False)
66+
golden = tmp_path / "golden.png"
67+
_image((0, 0, 0)).save(golden)
68+
69+
small_shift = compare_to_golden(
70+
_image((15, 0, 0)),
71+
golden,
72+
label="small-shift",
73+
artifact_dir=tmp_path / "artifacts",
74+
max_diff_pct=0.0,
75+
min_ssim=None,
76+
pixel_l2_threshold=RTX_COLOR_PIXEL_L2_THRESHOLD,
77+
)
78+
large_delta = compare_to_golden(
79+
_image((30, 0, 0)),
80+
golden,
81+
label="large-delta",
82+
artifact_dir=tmp_path / "artifacts",
83+
max_diff_pct=0.0,
84+
min_ssim=None,
85+
pixel_l2_threshold=RTX_COLOR_PIXEL_L2_THRESHOLD,
86+
)
87+
88+
assert small_shift.passed and small_shift.diff_pct == 0.0
89+
assert not large_delta.passed and large_delta.diff_pct == 100.0
90+
91+
6292
def test_missing_baseline_is_bootstrapped_but_fails(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
6393
monkeypatch.delenv("ISAACLAB_UPDATE_GOLDENS", raising=False)
6494
golden = tmp_path / "missing.png"

source/_isaaclab_testing/test/rendering/test_rendering_architecture.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,19 @@ def test_reset_and_teardown_policies_keep_their_owners() -> None:
291291
build = next(
292292
node for node in runtime_tree.body if isinstance(node, ast.FunctionDef) and node.name == "build_rendering_scene"
293293
)
294+
texture_setting = "/rtx-transient/resourcemanager/enableTextureStreaming"
295+
texture_calls = [
296+
node
297+
for node in ast.walk(build)
298+
if isinstance(node, ast.Call)
299+
and ast.unparse(node.func) == "sim.set_setting"
300+
and node.args
301+
and ast.literal_eval(node.args[0]) == texture_setting
302+
]
303+
ovrtx_branch = next(
304+
node for node in ast.walk(build) if isinstance(node, ast.If) and ast.unparse(node.test) == "renderer == 'ovrtx'"
305+
)
306+
assert len(texture_calls) == 1 and texture_calls[0] in ast.walk(ovrtx_branch)
294307
assert any(
295308
ast.unparse(node) == "runtime.scene.close()"
296309
for try_node in ast.walk(build)

source/_isaaclab_testing/test/rendering/visualizer_runner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import numpy as np
1414
import torch
15-
from golden_image import camera_output_image, compare_to_golden, frame_image
15+
from golden_image import RTX_COLOR_PIXEL_L2_THRESHOLD, camera_output_image, compare_to_golden, frame_image
1616
from isaaclab_visualizers.kit import KitVisualizerCfg
1717
from isaaclab_visualizers.newton import NewtonGLVisualizerCfg
1818
from PIL import Image
@@ -80,6 +80,8 @@ def run_visualizer_case(physics: str, kind: str, tiled: bool, request: Any) -> N
8080
artifact_dir=_ARTIFACT_DIR,
8181
max_diff_pct=8.0 if kind == "kit" and tiled else 5.0 if kind == "kit" else 0.75,
8282
min_ssim=0.97 if kind == "kit" else 0.99,
83+
# Kit RTX has small cross-GPU color shifts; SSIM and the spatial budget still gate structure.
84+
pixel_l2_threshold=RTX_COLOR_PIXEL_L2_THRESHOLD if kind == "kit" else 10.0,
8385
)
8486
comparison.record(request)
8587

0 commit comments

Comments
 (0)