yum-slop/modular_slang

write individual HLSL modules/libraries in slang

git clone https://git.yummers.dev/yum-slop/modular_slang

yumupdate readmef299253

v1.0.0
1.1 KiB39 linesraw

modular slang

the idea here is just to make something like slangc.exe, but which treats entrypoints like regular functions.

basics and gotchas

  • all functions marked public are exported as entrypoints.
  • we use a custom build of slang which lets entrypoints use regular arguments instead of cbuffers / structs.
  • it should "just work" for simple math kernels

usage

  • import unitypackage
  • right click .slang file, select 'Translate to HLSL'
  • import the generated .hlsl in your shader

build instructions

git clone https://github.com/shader-slang/slang
cd slang
git checkout 8f499fbe9baf68ef880da2ffe4812fbed1e5c1fa
patch -p1 <../slang.patch
git submodule update --init --recursive -j 32
# wait, the previous command takes a while
mkdir build
cd build
# run this part in powershell, from ./slang/build
cmake.exe ..
cmake.exe --build . -j 32 --config Release
# the previous command will take a long fucking time
# switch back to top level of repo
cd ../..
# do this in wsl2 or powershell. Showing wsl2/bash syntax.
powershell.exe ./build.ps1 && ./dist/modular_slang.exe ./demo.slang
1## modular slang
2
3the idea here is just to make something like slangc.exe, but which treats
4entrypoints like regular functions.
5
6basics and gotchas
7
8- all functions marked `public` are exported as entrypoints.
9- we use a custom build of slang which lets entrypoints use regular arguments
10  instead of cbuffers / structs.
11- it should "just work" for simple math kernels
12
13usage
14
15- import unitypackage
16- right click .slang file, select 'Translate to HLSL'
17- import the generated .hlsl in your shader
18
19build instructions
20
21```bash
22git clone https://github.com/shader-slang/slang
23cd slang
24git checkout 8f499fbe9baf68ef880da2ffe4812fbed1e5c1fa
25patch -p1 <../slang.patch
26git submodule update --init --recursive -j 32
27# wait, the previous command takes a while
28mkdir build
29cd build
30# run this part in powershell, from ./slang/build
31cmake.exe ..
32cmake.exe --build . -j 32 --config Release
33# the previous command will take a long fucking time
34# switch back to top level of repo
35cd ../..
36# do this in wsl2 or powershell. Showing wsl2/bash syntax.
37powershell.exe ./build.ps1 && ./dist/modular_slang.exe ./demo.slang
38```
39