Skip to content

Commit 276beb8

Browse files
Fix coverage demo launch on Windows: prepend DLL directory to PATH
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>
1 parent 2a6b086 commit 276beb8

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

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

100644100755
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,14 @@ def main(argv=None):
184184
binary_cmd = [str(binary), f"--mode={mode}",
185185
f"--output-dir={output_dir}", *demo_args]
186186
print(f"[1/3] running demo: {' '.join(str(a) for a in binary_cmd)}")
187-
result = subprocess.run(binary_cmd)
187+
# On Windows the runtime DLLs (slang.dll etc.) live in
188+
# <build-root>/<config>/bin/, not next to the demo exe. Prepend that
189+
# directory to PATH so the loader finds them (otherwise STATUS_DLL_NOT_FOUND).
190+
demo_env = os.environ.copy()
191+
if platform.system() == "Windows" and len(binary.parents) >= 4:
192+
dll_dir = binary.parents[3] / binary.parent.name / "bin"
193+
demo_env["PATH"] = str(dll_dir) + os.pathsep + demo_env.get("PATH", "")
194+
result = subprocess.run(binary_cmd, env=demo_env)
188195
if result.returncode != 0:
189196
sys.exit(f"error: demo exited with code {result.returncode}")
190197

examples/shader-coverage-image-pipeline/run_coverage.py

100644100755
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,14 @@ def main(argv=None):
193193
binary_cmd = [str(binary), f"--mode={mode}",
194194
f"--output-dir={output_dir}", *demo_args]
195195
print(f"[1/2] running demo: {' '.join(str(a) for a in binary_cmd)}")
196-
result = subprocess.run(binary_cmd)
196+
# On Windows the runtime DLLs (slang.dll etc.) live in
197+
# <build-root>/<config>/bin/, not next to the demo exe. Prepend that
198+
# directory to PATH so the loader finds them (otherwise STATUS_DLL_NOT_FOUND).
199+
demo_env = os.environ.copy()
200+
if platform.system() == "Windows" and len(binary.parents) >= 4:
201+
dll_dir = binary.parents[3] / binary.parent.name / "bin"
202+
demo_env["PATH"] = str(dll_dir) + os.pathsep + demo_env.get("PATH", "")
203+
result = subprocess.run(binary_cmd, env=demo_env)
197204
if result.returncode != 0:
198205
sys.exit(f"error: demo exited with code {result.returncode}")
199206

0 commit comments

Comments
 (0)