yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Jay KwakEnhance SPIRV-Headers update instructions796ea80a0

master
3.8 KiB118 linesraw

Updating external spirv

There are three directories under external that are related to SPIR-V:

  • external/spirv-headers
  • external/spirv-tools
  • external/spirv-tools-generated

In order to use the latest or custom SPIR-V, they need to be updated.

Update SPIRV-Tools

On the Slang repo, you need to update to use the latest commit of SPIRV-Tools and SPIRV-Headers.

  1. Create a branch for the update.

    # This doc will use "update_spirv" as a branch name,
    # but you can use a different name.
    git checkout -b update_spirv
    
  2. Synchronize and update submodules.

    git submodule sync
    git submodule update --init --recursive
    
  3. Update the SPIRV-Tools submodule to the latest version.

    git -C external/spirv-tools fetch
    git -C external/spirv-tools checkout origin/main
    

Build spirv-tools

A directory, external/spirv-tools/generated, holds a set of files generated from spirv-tools directory. You need to build spirv-tools in order to generate them.

cd external
cd spirv-tools
python3.exe utils\git-sync-deps # this step may require you to register your ssh public key to gitlab.khronos.org
cmake.exe . -B build
cmake.exe --build build --config Release

# Go back to repository root
cd ../..

Update SPIRV-Tools

  1. Update the SPIRV-Headers submodule to what SPIRV-Tools uses
    git -C external/spirv-headers fetch
    git -C external/spirv-tools/external/spirv-headers log -1 --oneline
    git -C external/spirv-headers checkout [commit hash from the previous command]
    
    Alternatively you can get the hash value of spirv-headers with the following command,
    grep spirv_headers_revision external/spirv-tools/DEPS
    

Note that the update of SPIRV-Headers should be done after running python3.exe utils\git-sync-deps, because the python script will update external/spirv-tools/external/spirv-headers to whichever commit the current SPIRV-Tools depends on.

Copy the generated files from spirv-tools/build/ to spirv-tools-generated/

Copy the generated header files from external/spirv-tools/build/ to external/spirv-tools-generated/.

rm external/spirv-tools-generated/*.h
rm external/spirv-tools-generated/*.inc
cp external/spirv-tools/build/*.h external/spirv-tools-generated/
cp external/spirv-tools/build/*.inc external/spirv-tools-generated/

Build Slang and run slang-test

After SPIRV submodules are updated, you need to build and test.

# Make sure to clean up data generated from the previous SPIRV
rm -fr build

There are many ways to build Slang executables. Refer to the document for more detail. For a quick reference, you can build with the following commands,

cmake.exe --preset vs2022
cmake.exe --build --preset release

After building Slang executables, run slang-test to see all tests are passing.

set SLANG_RUN_SPIRV_VALIDATION=1
build\Release\bin\slang-test.exe -use-test-server -server-count 8

It is often the case that some of tests fail, because of the changes on SPIRV-Header. You need to properly resolve them before proceed.

Commit and create a Pull Request

After testing is done, you need to stage and commit the updated submodule references and any generated files. Note that when you want to use new commit IDs of the submodules, you have to stage with git-add command for the directory of the submodule itself.

git add external/spirv-headers
git add external/spirv-tools
git add external/spirv-tools-generated

# Add any other changes needed to resolve test failures

git commit -m "Update SPIRV-Tools and SPIRV-Headers to latest versions"
git push origin update_spirv # Use your own branch name as needed

Once all changes are pushed to GitHub, you can create a Pull Request on the main Slang repository.

1# Updating external spirv
2
3There are three directories under `external` that are related to SPIR-V:
4- external/spirv-headers
5- external/spirv-tools
6- external/spirv-tools-generated
7
8In order to use the latest or custom SPIR-V, they need to be updated.
9
10
11## Update SPIRV-Tools
12
13On the Slang repo, you need to update to use the latest commit of SPIRV-Tools and SPIRV-Headers.
14
151. Create a branch for the update.
16   ```
17   # This doc will use "update_spirv" as a branch name,
18   # but you can use a different name.
19   git checkout -b update_spirv
20   ```
21
221. Synchronize and update submodules.
23   ```
24   git submodule sync
25   git submodule update --init --recursive
26   ```
27
281. Update the SPIRV-Tools submodule to the latest version.
29   ```
30   git -C external/spirv-tools fetch
31   git -C external/spirv-tools checkout origin/main
32   ```
33
34## Build spirv-tools
35
36A directory, `external/spirv-tools/generated`, holds a set of files generated from spirv-tools directory.
37You need to build spirv-tools in order to generate them.
38
39```
40cd external
41cd spirv-tools
42python3.exe utils\git-sync-deps # this step may require you to register your ssh public key to gitlab.khronos.org
43cmake.exe . -B build
44cmake.exe --build build --config Release
45
46# Go back to repository root
47cd ../..
48```
49
50## Update SPIRV-Tools
51
521. Update the SPIRV-Headers submodule to what SPIRV-Tools uses
53   ```
54   git -C external/spirv-headers fetch
55   git -C external/spirv-tools/external/spirv-headers log -1 --oneline
56   git -C external/spirv-headers checkout [commit hash from the previous command]
57   ```
58   Alternatively you can get the hash value of spirv-headers with the following command,
59   ```
60   grep spirv_headers_revision external/spirv-tools/DEPS
61   ```
62
63Note that the update of SPIRV-Headers should be done after running `python3.exe utils\git-sync-deps`, because the python script will update `external/spirv-tools/external/spirv-headers` to whichever commit the current SPIRV-Tools depends on.
64
65
66## Copy the generated files from `spirv-tools/build/` to `spirv-tools-generated/`
67
68Copy the generated header files from `external/spirv-tools/build/` to `external/spirv-tools-generated/`.
69```
70rm external/spirv-tools-generated/*.h
71rm external/spirv-tools-generated/*.inc
72cp external/spirv-tools/build/*.h external/spirv-tools-generated/
73cp external/spirv-tools/build/*.inc external/spirv-tools-generated/
74```
75
76
77## Build Slang and run slang-test
78
79After SPIRV submodules are updated, you need to build and test.
80```
81# Make sure to clean up data generated from the previous SPIRV
82rm -fr build
83```
84
85There are many ways to build Slang executables. Refer to the [document](https://github.com/shader-slang/slang/blob/master/docs/building.md) for more detail.
86For a quick reference, you can build with the following commands,
87```
88cmake.exe --preset vs2022
89cmake.exe --build --preset release
90```
91
92After building Slang executables, run `slang-test` to see all tests are passing.
93```
94set SLANG_RUN_SPIRV_VALIDATION=1
95build\Release\bin\slang-test.exe -use-test-server -server-count 8
96```
97
98It is often the case that some of tests fail, because of the changes on SPIRV-Header.
99You need to properly resolve them before proceed.
100
101
102## Commit and create a Pull Request
103
104After testing is done, you need to stage and commit the updated submodule references and any generated files.
105Note that when you want to use new commit IDs of the submodules, you have to stage with git-add command for the directory of the submodule itself.
106
107```
108git add external/spirv-headers
109git add external/spirv-tools
110git add external/spirv-tools-generated
111
112# Add any other changes needed to resolve test failures
113
114git commit -m "Update SPIRV-Tools and SPIRV-Headers to latest versions"
115git push origin update_spirv # Use your own branch name as needed
116```
117
118Once all changes are pushed to GitHub, you can create a Pull Request on the main Slang repository.