microsoft / microsoft/DirectXShaderCompiler

`dxr.exe` doesn't support macro definitions via its CLI

Open
#5,423 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug rewriter
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description
It would be extremely useful if the Rewriter (dxr.exe) supported the -D command-line parameter similar to dxc.exe. After all, it's similar to the preprocessor.

In the absence of this functionality, I had to generate source files with #ifdefs in order to rewrite the same source with different macros.

What's worse, dxr.exe accepts -D arguments without errors or warnings and rewrites the source ignoring the macros, which may take some experimentation to realize.

Steps to Reproduce

  • Compile this trivial shader with -D float4=0: https://godbolt.org/z/5q5WKvq6e The compilation fails, which proves that the macro was expanded.
  • Now, rewrite the same shader with dxr.exe -D float4=0 -E PSMain. The file is rewritten verbatim, which proves that the macro wasn't expanded.

Environment

  • DXC version: 1.7.2212
  • Host Operating System: Win 10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the dxr.exe command-line handling and compare how dxc.exe processes -D arguments. Reproduce the shader example with and without -D float4=0 and inspect the rewrite path for PSMain. Done means dxr.exe applies macro definitions during rewriting and no longer silently ignores them.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.