Skip to content

Commit f820994

Browse files
committed
Update documentation for building shaders
1 parent ac405fb commit f820994

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

resources/shaders/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
This directory contains postprocessed versions of the shaders in the top-level
22
`shaders/` directory, for convenience. Don't modify the shaders here; instead
3-
modify the corresponding shaders in `shaders/` and rerun `make` in that
4-
directory.
5-
6-
You will need `glslangValidator` and `spirv-cross` installed to execute the
7-
Makefile. On macOS, you can get these with `brew install glslang spirv-cross`.
3+
modify the corresponding shaders in `shaders/` and rebuild them according to
4+
`shaders/README.md`.

shaders/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ OUT=\
5858

5959
GLSL_3_VERSION=330
6060
GLSL_4_VERSION=430
61+
62+
GLSLANG?=glslangValidator
6163
GLSLANGFLAGS=--auto-map-locations -I.
6264
GLSLANGFLAGS_METAL=$(GLSLANGFLAGS) -DPF_ORIGIN_UPPER_LEFT=1
6365

@@ -81,13 +83,13 @@ clean:
8183
rm -f $(OUT)
8284

8385
build/metal/%.spv: %.glsl $(INCLUDES)
84-
mkdir -p $(dir $@) && glslangValidator $(GLSLANGFLAGS_METAL) -G$(GLSL_VERSION) -S $(GLSL_SHADER_TYPE$(suffix $(basename $(notdir $<)))) -o $@ $<
86+
mkdir -p $(dir $@) && $(GLSLANG) $(GLSLANGFLAGS_METAL) -G$(GLSL_VERSION) -S $(GLSL_SHADER_TYPE$(suffix $(basename $(notdir $<)))) -o $@ $<
8587

8688
$(TARGET_DIR)/gl3/%.glsl: %.glsl $(INCLUDES)
87-
mkdir -p $(dir $@) && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( glslangValidator $(GLSLANGFLAGS) -S $(GLSL_SHADER_TYPE$(suffix $(basename $(notdir $<)))) -E $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 )
89+
mkdir -p $(dir $@) && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( $(GLSLANG) $(GLSLANGFLAGS) -S $(GLSL_SHADER_TYPE$(suffix $(basename $(notdir $<)))) -E $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 )
8890

8991
$(TARGET_DIR)/gl4/%.glsl: %.glsl $(INCLUDES)
90-
mkdir -p $(dir $@) && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( glslangValidator $(GLSLANGFLAGS) -S $(GLSL_SHADER_TYPE$(suffix $(basename $(notdir $<)))) -E $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 )
92+
mkdir -p $(dir $@) && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( $(GLSLANG) $(GLSLANGFLAGS) -S $(GLSL_SHADER_TYPE$(suffix $(basename $(notdir $<)))) -E $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 )
9193

9294
$(TARGET_DIR)/metal/%.metal: build/metal/%.spv
9395
mkdir -p $(dir $@) && echo $(HEADER) > $@ && ( $(SPIRVCROSS) $(SPIRVCROSSFLAGS) $< >> $@ ) || ( rm $@ && exit 1 )

shaders/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Building the shaders
2+
3+
You will need `glslangValidator` and `spirv-cross` installed to execute the
4+
Makefile from this directory. You can speed up the build by parallelizing the
5+
build: `make -j`.
6+
7+
## macOS
8+
9+
You can use [Homebrew](https://brew.sh/) to install the dependencies:
10+
11+
```sh
12+
brew install glslang spirv-cross
13+
```
14+
15+
## Windows
16+
17+
`glslangValidator` and `spirv-cross` are available by installing the
18+
[Vulkan SDK](https://vulkan.lunarg.com/sdk/home). You'll also need some commands
19+
like `make`, `rm`, etc. These are available on the
20+
[Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
21+
shell. You'll need to set these environment variables for `make` to succeed:
22+
23+
```sh
24+
export GLSLANG=glslangValidator.exe
25+
export SPIRVCROSS=spirv-cross.exe
26+
```

0 commit comments

Comments
 (0)