Nabla icon indicating copy to clipboard operation
Nabla copied to clipboard

HLSL preprocessor cannot handle comments on the same line as a preprocessor directive

Open Fletterio opened this issue 1 year ago • 0 comments

Describe the bug

If you try to put a comment on the same line as a preprocessor directive, preprocessing will fail

Steps to Reproduce

In my case I hit this when trying to write a file that can be #included from both host code and device code. For example, code like the following:

#ifndef __HLSL_VERSION // CPP
// Host code...
#else // HLSL
// Device code...
#endif // End device code

will fail to preprocess because of the comments on the same line as the directives. Remove those comments, and it preprocesses fine

Also, I'm hitting this catch(...): https://github.com/Devsh-Graphics-Programming/Nabla/blob/e8f4dca1724b907826f2b9ca1f238ad114716218/src/nbl/asset/utils/CHLSLCompiler.cpp#L358

Meaning that Wave can't even provide a reason for why it's failing to preprocess.

I would guess that currently when it encounters a preprocess directive it does not know to recognize // as the start of a comment, which makes it try to parse the whole line as a directive and fails to do so.

Environment

  • OS: Windows 11
  • CPU: Ryzen 5 5700
  • Compiler: MSVC
  • branch: main
  • commit hash: e8f4dca1724b907826f2b9ca1f238ad114716218

Fletterio avatar Nov 22 '24 19:11 Fletterio