Skip to content

Commit c5509f3

Browse files
authored
Making the docs more clear (#78)
* making the docs more clear * add doc for alternatively using build.mk * add reasoning for not including binary files in the repo * adding required installation steps * spirv-tool build instructions * add spirv-tool build file names
1 parent 9f5ae56 commit c5509f3

File tree

1 file changed

+88
-17
lines changed

1 file changed

+88
-17
lines changed

README.md

+88-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,103 @@
1-
# Development instructions
1+
# Development Instructions
22

33
## Setup
44

5-
### Development environment shell
5+
Clone the [Slang Playground](https://github.com/shader-slang/slang-playground):
66

7-
On Windows, set up the environment as follows:
7+
```bash
8+
git clone https://github.com/shader-slang/slang-playground.git
9+
```
810

9-
set TRY_SLANG_SOURCE_DIRECTORY_PATH=%userprofile%\source\try-slang
10-
set TRY_SLANG_TARGET_DIRECTORY_PATH=%userprofile%\target\try-slang
11+
### Prerequisites
1112

12-
In the following, it is also assumed that GNU Make, Python and gzip are in PATH.
13-
Follow the setup instructions in `docs/building.md` for building `slang-wasm` in the Slang repository.
14-
(E.g. setup shell for CMake and Emscripten, and setup the `build.em` output directory.)
13+
Ensure the following tools are installed and properly configured on your system:
14+
- **CMake** (Version 3.25 or greater is preferred, if you're on a lower version please see [build with older cmake](https://github.com/shader-slang/slang/blob/master/docs/building.md#building-with-an-older-cmake))
15+
- A **C++ compiler** with C++17 support (GCC, Clang, or MSVC)
16+
- A **CMake-compatible build backend** (e.g., Ninja or Visual Studio)
17+
- **Python 3** (Required for building and running the server)
18+
- **gzip** (For compressing `.wasm` files)
1519

16-
### Server
20+
To install the above tools on linux, run:
21+
```bash
22+
sudo apt update
23+
sudo apt install build-essential cmake ninja-build python3 python3-pip gzip
24+
```
1725

18-
The Wasm loader needs a running web server in the build target directory, in order to load .wasm files.
26+
We need to build `slang-wasm` because we need `slang-wasm.js` and `slang-wasm.wasm` files.
27+
The reason they're not included in this repo is that they are big binary files, and the result of building top of tree slang, so making this part of the CI build process makes the most sense.
1928

20-
**NOTE: ** You do not need a shell with the full development environment set up, you just need Python and the `TRY_SLANG_TARGET_DIRECTORY_PATH` environment variable.
29+
### Building `slang-wasm`
2130

22-
To start the server, run something like:
31+
1. Clone the [Slang repository](https://github.com/shader-slang/slang) and fetch its submodules:
32+
```bash
33+
git clone https://github.com/shader-slang/slang --recursive
2334

24-
$ cd $TRY_SLANG_TARGET_DIRECTORY_PATH && python -m http.server 8000
35+
cd slang
36+
```
2537

26-
## Iterate
38+
2. Follow the instructions in the [WebAssembly build section](https://github.com/shader-slang/slang/blob/master/docs/building.md#webassembly-build) of the Slang documentation to:
39+
- Set up the [Emscripten SDK](https://github.com/emscripten-core/emsdk) by installing and activating it.
40+
- Build the WebAssembly target (`slang-wasm.js` and `slang-wasm.wasm`) using the documented cross-compilation steps.
2741

28-
To iterate on the website, make changes and build the `website_runtime` target, from a development environment shell:
42+
3. Once the build completes, locate `slang-wasm.js` and `slang-wasm.wasm` in the `build.em/Release/bin` directory
43+
44+
4. Copy `slang-wasm.js` and `slang-wasm.wasm` to the **root of the playground directory**.
2945

30-
$ make -f $TRY_SLANG_SOURCE_DIRECTORY_PATH/build.md website_runtime
46+
5. Compress the `slang-wasm.wasm` file using gzip:
47+
```bash
48+
gzip -k slang-wasm.wasm
49+
```
3150

32-
Now load or reload `localhost:8000` in your browser to see the results.
51+
### Building `spirv-tool`
52+
53+
To enable SPIR-V disassembly in the playground (alongside the SPIR-V binary compilation supported by `slang-wasm.js`), you need to build the WebAssembly version of `spirv-tool`. This is necessary because `slang-wasm.js` does not include the SPIR-V disassembler.
54+
55+
1. Refer to the build process outlined in the CI configuration:
56+
- [GitHub Workflow](https://github.com/shader-slang/slang-playground/blob/main/.github/workflows/jekyll-gh-pages.yml#L43)
57+
- [Build Script](https://github.com/shader-slang/slang-playground/blob/main/spirv-tool-wasm-build.sh)
58+
59+
2. Use the provided [`spirv-tool-wasm-build.sh`](https://github.com/shader-slang/slang-playground/blob/main/spirv-tool-wasm-build.sh) script to compile the WebAssembly build of `spirv-tool`.
60+
61+
3. Once built, place the resulting files (`spirv-tools.wasm` and `spirv-tools.js`) in the **root of the playground directory** alongside `slang-wasm.js` and `slang-wasm.wasm`.
62+
63+
By completing this step, the playground will support SPIR-V disassembly features.
64+
65+
### Starting the Server
66+
67+
1. Navigate to the root of your playground directory (where `slang-wasm.js` and `slang-wasm.wasm.gz` are located).
68+
```bash
69+
cd slang-playground
70+
```
71+
72+
2. Start a Python web server to host the files:
73+
```bash
74+
python -m http.server 8000
75+
```
76+
77+
3. Open `http://localhost:8000` in your browser to verify the server is running and the files are accessible. You should see the application loading the `.wasm` and `.js` files correctly.
78+
79+
If any issues arise, ensure the `.wasm` file is properly compressed (`slang-wasm.wasm.gz`) and located in the correct directory.
80+
81+
This process of: build -> run, should work alone.
82+
83+
## Iterating on Development Using build.mk
84+
85+
Alternatively you can build using the `build.mk` file.
86+
87+
Set up the environment as follows:
88+
89+
```bash
90+
## The output directory where to output target (non-source) files
91+
export TRY_SLANG_TARGET_DIRECTORY_PATH="path-to-slang-target-directory"
92+
## Path to the hello-emscripten source tree
93+
export TRY_SLANG_SOURCE_DIRECTORY_PATH="path-to-slang-source-directory"
94+
## Slang source directory
95+
export TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH="path-to-slang-directory"
96+
```
97+
98+
1. Make the necessary changes to your source code.
99+
2. Build the updated runtime by running:
100+
```bash
101+
make -f ./build.mk website_runtime
102+
```
103+
3. Refresh `http://localhost:8000` in your browser to view the changes.

0 commit comments

Comments
 (0)