Open tareksander opened 1 day ago
This is a good suggestion and is what we've been considering to add. Currently there is already the slang-reflection-test code (that is compiled as a library) that does exactly this, and you can change the code slightly to compile that dll as an exe instead. But it would be useful to package them up directly in slangc.
If no one is working on it I can try implementing it. Shouldn't be that hard with the reflection API already in place.
That will be fantastic. We appreciate your contribution! You can get started by taking a look at \tools\slang-reflection-test\slang-reflection-test-main.cpp
, which should already have all the logic we want: reads the refection data, and print them out as json string.
So basically:
Right?
Yes, that should be it.
How can I run the tests to ensure I don't break anything?
You can run slang-test
from repository root directory without any parameters:
slang-test
To speed things up you can run tests in parallel with:
slang-test -use-test-server -server-count 12
To run tests with specific name:
slang-test tests/compute/simple.slang
To run test using a specific API:
slang-test -api d3d12
slang-test -api all-wgpu # run tests using all apis but wgpu.
I like to recommend checking out our contribution guide. https://github.com/shader-slang/slang/blob/master/CONTRIBUTION.md
As far as I understand the documentation, layout and binding information (unless manually specified) is chosen by the language, and the only way know what was chosen is to use the reflection API. With something like a separate json output file that includes the descriptor set and binding for globals and the type layout, slangc could be used standalone for compilation.