Skip to content

Fix shader-coverage demo launch on Windows#11625

Merged
jvepsalainen-nv merged 1 commit into
shader-slang:masterfrom
jvepsalainen-nv:fix/coverage-demo-dll-search-and-ascii-output
Jun 16, 2026
Merged

Fix shader-coverage demo launch on Windows#11625
jvepsalainen-nv merged 1 commit into
shader-slang:masterfrom
jvepsalainen-nv:fix/coverage-demo-dll-search-and-ascii-output

Conversation

@jvepsalainen-nv

@jvepsalainen-nv jvepsalainen-nv commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Motivation

run_coverage.py in both shader-coverage demos fails on Windows because
the demo .exe lives in build/examples/<target>/<config>/ but the
Slang runtime DLLs (slang.dll, etc.) live in build/<config>/bin/.
The Windows loader only searches the exe's own directory, so the process
aborts immediately with STATUS_DLL_NOT_FOUND (0xC0000135).

Changes

Prepend the runtime DLL directory to the child process PATH before
launching the demo binary. The directory is derived from the already-known
binary path and handles both CMake generator layouts:

_WIN_CONFIGS = {"Release", "Debug", "RelWithDebInfo"}
demo_env = os.environ.copy()
if platform.system() == "Windows" and len(binary.parents) >= 4:
    config = (binary.parent.name if binary.parent.name in _WIN_CONFIGS
              else binary.parents[2].name)
    dll_dir = binary.parents[3] / config / "bin"
    demo_env["PATH"] = str(dll_dir) + os.pathsep + demo_env.get("PATH", "")
result = subprocess.run(binary_cmd, env=demo_env)
  • Multi-config (Ninja Multi-Config / Visual Studio): exe at
    <build>/examples/<target>/<config>/<exe> — config = binary.parent.name.
  • Single-config (plain Ninja / Makefiles): exe at
    <build>/<config>/examples/<target>/<exe> — config = binary.parents[2].name.
  • In both cases binary.parents[3] is the build root and the DLL directory
    is <build-root>/<config>/bin/.
  • No change on POSIX — rpath handles DLL resolution there.

Both examples/shader-coverage-bvh-traversal/run_coverage.py and
examples/shader-coverage-image-pipeline/run_coverage.py receive the
same fix.

@jvepsalainen-nv jvepsalainen-nv requested a review from a team as a code owner June 16, 2026 09:17
@jvepsalainen-nv jvepsalainen-nv requested review from bmillsNV and removed request for a team June 16, 2026 09:17
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Both run_coverage.py scripts in the shader coverage examples now construct an explicit subprocess environment from os.environ.copy(). On Windows, each script derives a runtime DLL directory from the demo binary path, prepends it to PATH, and passes that environment to subprocess.run(). This ensures the subprocess can locate required runtime DLLs at execution time.

Changes

Windows DLL PATH fix in coverage scripts

Layer / File(s) Summary
Windows DLL PATH handling in bvh-traversal
examples/shader-coverage-bvh-traversal/run_coverage.py
Subprocess invocation now uses demo_env copied from os.environ, with a Windows-specific DLL directory derived from the demo binary's path prepended to PATH before subprocess.run() is called.
Windows DLL PATH handling in image-pipeline
examples/shader-coverage-image-pipeline/run_coverage.py
Same Windows DLL path pattern applied to the image-pipeline script. subprocess.run() now receives env=demo_env containing the modified PATH with the runtime DLL directory prepended.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly explains the Windows DLL search path issue, provides detailed change rationale, and documents the implementation approach with specific code examples.
Title check ✅ Passed The title clearly and specifically identifies the main change: fixing shader-coverage demo launch on Windows by addressing a DLL search path issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jvepsalainen-nv jvepsalainen-nv self-assigned this Jun 16, 2026
@jvepsalainen-nv jvepsalainen-nv added the pr: non-breaking PRs without breaking changes label Jun 16, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d996c92d-b15a-47af-a534-dacec386394d

📥 Commits

Reviewing files that changed from the base of the PR and between d620d71 and e48a801.

📒 Files selected for processing (3)
  • examples/shader-coverage-bvh-traversal/run_coverage.py
  • examples/shader-coverage-image-pipeline/run_coverage.py
  • tools/coverage-html/slang-coverage-html.py

Comment thread examples/shader-coverage-bvh-traversal/run_coverage.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
examples/shader-coverage-bvh-traversal/run_coverage.py (1)

97-99: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

The Windows preset-layout gap is shared by both wrappers. Both files claim generalized binaryDir support, but binary discovery remains rooted to slang_root/build, so non-default Windows preset layouts can still fail before PATH augmentation.

  • examples/shader-coverage-bvh-traversal/run_coverage.py#L97-L99: either broaden _candidate_paths() / discovery to include preset binaryDir variants (e.g., build/windows-vs2022-dev/...) or narrow the doc claim to current support.
  • examples/shader-coverage-image-pipeline/run_coverage.py#L97-L99: apply the same discovery fix (or same doc narrowing) to keep behavior and docs consistent between wrappers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 38989f37-af28-49e1-a805-9694f07c2e59

📥 Commits

Reviewing files that changed from the base of the PR and between e48a801 and 00738a0.

📒 Files selected for processing (2)
  • examples/shader-coverage-bvh-traversal/run_coverage.py
  • examples/shader-coverage-image-pipeline/run_coverage.py

github-actions[bot]

This comment was marked as outdated.

@jvepsalainen-nv jvepsalainen-nv force-pushed the fix/coverage-demo-dll-search-and-ascii-output branch 5 times, most recently from 31a2ac7 to 276beb8 Compare June 16, 2026 10:13

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8b0c9776-152d-43dd-bfbf-abc215f02296

📥 Commits

Reviewing files that changed from the base of the PR and between 8382222 and 276beb8.

📒 Files selected for processing (2)
  • examples/shader-coverage-bvh-traversal/run_coverage.py
  • examples/shader-coverage-image-pipeline/run_coverage.py

Comment thread examples/shader-coverage-bvh-traversal/run_coverage.py

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 🔴 Has issues — 1 bug, 1 question

The PR prepends a derived bin/ directory to the child process PATH so the Windows loader can find slang.dll when launching the shader-coverage demo. The derivation uses positional parents[3] / parent.name arithmetic that is only correct for multi-config CMake layouts; it silently produces a wrong (non-existent) DLL directory for the single-config layout that _candidate_paths itself enumerates. The PR title also advertises an "ASCII console output" change that is not present in the diff.

Changes Overview

Windows DLL search path for demo wrappers (examples/shader-coverage-bvh-traversal/run_coverage.py, examples/shader-coverage-image-pipeline/run_coverage.py)

  • Before: subprocess.run(binary_cmd) — child process inherits parent PATH; on Windows the loader cannot find slang.dll/etc. because they live in build/<config>/bin/ rather than next to the demo .exe, so the demo aborts with STATUS_DLL_NOT_FOUND (0xC0000135).
  • After: when platform.system() == "Windows" and len(binary.parents) >= 4, prepend binary.parents[3] / binary.parent.name / "bin" to a copied PATH and pass it via env= to the single demo subprocess.run. POSIX behavior is unchanged (rpath handles DLL resolution there). File mode also flipped 100644 → 100755 on both scripts (consistent with the existing #!/usr/bin/env python3 shebang).
Findings (2 total)
Severity Location Finding
🔴 Bug examples/shader-coverage-bvh-traversal/run_coverage.py:190, examples/shader-coverage-image-pipeline/run_coverage.py:199 binary.parents[3] / binary.parent.name / "bin" only matches the multi-config layout; for the single-config layout enumerated in _candidate_paths it computes a non-existent directory and the DLL load still fails.
🔵 Question PR title Title advertises an "ASCII console output" fix that is not in the diff — was a commit dropped, or is the title stale?

Comment thread examples/shader-coverage-bvh-traversal/run_coverage.py
Comment thread examples/shader-coverage-image-pipeline/run_coverage.py
@jvepsalainen-nv jvepsalainen-nv force-pushed the fix/coverage-demo-dll-search-and-ascii-output branch from 276beb8 to c275f3f Compare June 16, 2026 10:23
@jvepsalainen-nv jvepsalainen-nv changed the title Fix shader-coverage demo launch on Windows: DLL search path + ASCII console output Fix shader-coverage demo launch on Windows Jun 16, 2026
The demo exe is built into build/examples/<target>/<config>/ but the
Slang runtime DLLs live in build/<config>/bin/. The Windows loader only
searches the exe's own directory, so the process aborts with
STATUS_DLL_NOT_FOUND (0xC0000135).

Derive the DLL directory from the already-located binary path and
prepend it to the child process PATH before launching the demo.
POSIX is unaffected (rpath handles DLL resolution there).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@jvepsalainen-nv jvepsalainen-nv force-pushed the fix/coverage-demo-dll-search-and-ascii-output branch from c275f3f to 99faf9a Compare June 16, 2026 10:33
@jvepsalainen-nv jvepsalainen-nv changed the title Fix shader-coverage demo launch on Windows Fix shader-coverage demo launch on Windows: DLL search path Jun 16, 2026
@jvepsalainen-nv jvepsalainen-nv changed the title Fix shader-coverage demo launch on Windows: DLL search path Fix shader-coverage demo launch on Windows Jun 16, 2026
@jvepsalainen-nv jvepsalainen-nv added this pull request to the merge queue Jun 16, 2026
Merged via the queue into shader-slang:master with commit 890f8be Jun 16, 2026
48 checks passed
jvepsalainen-nv added a commit that referenced this pull request Jun 22, 2026
## Motivation

`run_coverage.py` in both shader-coverage demos fails on Windows because
the demo `.exe` lives in `build/examples/<target>/<config>/` but the
Slang runtime DLLs (`slang.dll`, etc.) live in `build/<config>/bin/`.
The Windows loader only searches the exe's own directory, so the process
aborts immediately with `STATUS_DLL_NOT_FOUND` (0xC0000135).

## Changes

Prepend the runtime DLL directory to the child process `PATH` before
launching the demo binary. The directory is derived from the
already-known
binary path and handles both CMake generator layouts:

```python
_WIN_CONFIGS = {"Release", "Debug", "RelWithDebInfo"}
demo_env = os.environ.copy()
if platform.system() == "Windows" and len(binary.parents) >= 4:
    config = (binary.parent.name if binary.parent.name in _WIN_CONFIGS
              else binary.parents[2].name)
    dll_dir = binary.parents[3] / config / "bin"
    demo_env["PATH"] = str(dll_dir) + os.pathsep + demo_env.get("PATH", "")
result = subprocess.run(binary_cmd, env=demo_env)
```

- **Multi-config** (Ninja Multi-Config / Visual Studio): exe at
`<build>/examples/<target>/<config>/<exe>` — config =
`binary.parent.name`.
- **Single-config** (plain Ninja / Makefiles): exe at
`<build>/<config>/examples/<target>/<exe>` — config =
`binary.parents[2].name`.
- In both cases `binary.parents[3]` is the build root and the DLL
directory
  is `<build-root>/<config>/bin/`.
- No change on POSIX — `rpath` handles DLL resolution there.

Both `examples/shader-coverage-bvh-traversal/run_coverage.py` and
`examples/shader-coverage-image-pipeline/run_coverage.py` receive the
same fix.

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: non-breaking PRs without breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants