0

I'm trying to implement material shaders with a common entry file main.hlsl. It needs to include different files with implementation of shading function to handle different material types. I want to achieve this by using a macro to control the include file path. A simple example looks like this:

#define INCLUDE_FILE "include.hlsl"

#include INCLUDE_FILE

It works correctly and now I want one step further: generate the INCLUDE_FILE macro with dxc commandline argument. But simply adding -DINCLUDE_FILE=""include.hlsl"" didn't work.

I've tried the following approaches:

  1. compile with dxc -E Main -T ps_6_0 -DINCLUDE_FILE="\"include.hlsl\"" .\main.hlsl
  2. compile with dxc -E Main -T ps_6_0 -DINCLUDE_FILE='"include.hlsl"' .\main.hlsl

I got the following error with the command above:

// for the first command
.\main.hlsl:5:10: error: expected "FILENAME" or <FILENAME>
#include INCLUDE_FILE
         ^
<built-in>:67:22: note: expanded from here
#define INCLUDE_FILE \include.hlsl\\
                     ^

// for the second command
.\main.hlsl:5:10: error: expected "FILENAME" or <FILENAME>
#include INCLUDE_FILE
         ^
<built-in>:66:22: note: expanded from here
#define INCLUDE_FILE include.hlsl
                     ^

It seems that they are translated to #define INCLUDE_FILE include.hlsl and #define INCLUDE_FILE \include.hlsl\\ respectively.

I want to know how to pass quotes in command line argument, or is there any equivalent way to implement this feature?


My dxc version is: dxcompiler.dll: 1.7 - 1.6.0.3576 (9395376ef)

  • Update: I managed to avoid passing quotes as compiler arguments by using `<>` with additional `-I` instead. This seems to be an ugly fix. – Martin Z He Feb 24 '23 at 08:28
  • The error suggests a typo (I**M**CLUDE_FILE), other than that I believe the command with \" should work. – BubLblckZ Feb 27 '23 at 14:04
  • Sorry for the mistake, but that does not change the fact that neither of the commands works. I've corrected and updated the full output for commands. The question is, as shown previously following the output, neither of them are translated to `"include.hlsl"`. @BubLblckZ – Martin Z He Mar 05 '23 at 08:14

0 Answers0