DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Provide callback for custom include handler

Open QuantumDeveloper opened this issue 2 years ago • 4 comments

I am using C# bindings for DXC and I faced with an issue using default include handler. While is tandard case its working fine, its completely failing wheh using from Source Generators. There is no way I could make it work and the only variant was to preprocess sources and manually include sources in shader file. So, I wish to have simple way to make custom include handler like it was done in ShaderC project by Google (https://github.com/google/shaderc).

Do you have plans for this improvement?

QuantumDeveloper avatar Aug 22 '22 13:08 QuantumDeveloper

Hi @QuantumDeveloper!

I'm a bit confused by your message. I don't know what you mean by "from Source Generators". Regardless, there is a way to provide a custom include handler using C++ at any rate as can be seen in a test example here: https://github.com/microsoft/DirectXShaderCompiler/blob/940df03ceb03eac0c58bf953f8280cf1ada97ac8/tools/clang/unittests/HLSL/CompilerTest.cpp#L64

Can you elaborate on the problem you encountered? Did you use this mechanism?

pow2clk avatar Aug 22 '22 19:08 pow2clk

Hi @pow2clk As I mention in my first post, I am using C# bindings to DXC and I simply cannot do like this, because C# has some limitations working with structs (no inheritance in C#) and especially COM objects.

QuantumDeveloper avatar Aug 22 '22 19:08 QuantumDeveloper

Thanks @QuantumDeveloper,

I suspected this might be related to the use of C#, but I'm not very familiar with that language. I wanted to make sure we were on the same page and now we are.

We'll consider this feature request

pow2clk avatar Aug 22 '22 19:08 pow2clk

@pow2clk Just wish to have more cross-platform (cross-language) and user-friendly way of creating custom include handlers. Hope you`ll approve this feature request.

QuantumDeveloper avatar Aug 22 '22 20:08 QuantumDeveloper

We are not going to make any significant alterations to the DXC library interface. We do have a task to implement a C API for the Clang-based HLSL compiler (see: llvm-project/#63631).

llvm-beanz avatar Jul 25 '23 21:07 llvm-beanz