Update documentation for building shaders

This commit is contained in:
Michael Tang 2020-09-12 13:49:28 -07:00
parent ac405fb988
commit f8209946e3
3 changed files with 33 additions and 8 deletions

View File

@ -1,7 +1,4 @@
This directory contains postprocessed versions of the shaders in the top-level This directory contains postprocessed versions of the shaders in the top-level
`shaders/` directory, for convenience. Don't modify the shaders here; instead `shaders/` directory, for convenience. Don't modify the shaders here; instead
modify the corresponding shaders in `shaders/` and rerun `make` in that modify the corresponding shaders in `shaders/` and rebuild them according to
directory. `shaders/README.md`.
You will need `glslangValidator` and `spirv-cross` installed to execute the
Makefile. On macOS, you can get these with `brew install glslang spirv-cross`.

View File

@ -58,6 +58,8 @@ OUT=\
GLSL_3_VERSION=330 GLSL_3_VERSION=330
GLSL_4_VERSION=430 GLSL_4_VERSION=430
GLSLANG?=glslangValidator
GLSLANGFLAGS=--auto-map-locations -I. GLSLANGFLAGS=--auto-map-locations -I.
GLSLANGFLAGS_METAL=$(GLSLANGFLAGS) -DPF_ORIGIN_UPPER_LEFT=1 GLSLANGFLAGS_METAL=$(GLSLANGFLAGS) -DPF_ORIGIN_UPPER_LEFT=1
@ -81,13 +83,13 @@ clean:
rm -f $(OUT) rm -f $(OUT)
build/metal/%.spv: %.glsl $(INCLUDES) build/metal/%.spv: %.glsl $(INCLUDES)
mkdir -p $(dir $@) && glslangValidator $(GLSLANGFLAGS_METAL) -G$(GLSL_VERSION) -S $(GLSL_SHADER_TYPE$(suffix $(basename $(notdir $<)))) -o $@ $< mkdir -p $(dir $@) && $(GLSLANG) $(GLSLANGFLAGS_METAL) -G$(GLSL_VERSION) -S $(GLSL_SHADER_TYPE$(suffix $(basename $(notdir $<)))) -o $@ $<
$(TARGET_DIR)/gl3/%.glsl: %.glsl $(INCLUDES) $(TARGET_DIR)/gl3/%.glsl: %.glsl $(INCLUDES)
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 ) 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 )
$(TARGET_DIR)/gl4/%.glsl: %.glsl $(INCLUDES) $(TARGET_DIR)/gl4/%.glsl: %.glsl $(INCLUDES)
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 ) 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 )
$(TARGET_DIR)/metal/%.metal: build/metal/%.spv $(TARGET_DIR)/metal/%.metal: build/metal/%.spv
mkdir -p $(dir $@) && echo $(HEADER) > $@ && ( $(SPIRVCROSS) $(SPIRVCROSSFLAGS) $< >> $@ ) || ( rm $@ && exit 1 ) mkdir -p $(dir $@) && echo $(HEADER) > $@ && ( $(SPIRVCROSS) $(SPIRVCROSSFLAGS) $< >> $@ ) || ( rm $@ && exit 1 )

26
shaders/README.md Normal file
View File

@ -0,0 +1,26 @@
# Building the shaders
You will need `glslangValidator` and `spirv-cross` installed to execute the
Makefile from this directory. You can speed up the build by parallelizing the
build: `make -j`.
## macOS
You can use [Homebrew](https://brew.sh/) to install the dependencies:
```sh
brew install glslang spirv-cross
```
## Windows
`glslangValidator` and `spirv-cross` are available by installing the
[Vulkan SDK](https://vulkan.lunarg.com/sdk/home). You'll also need some commands
like `make`, `rm`, etc. These are available on the
[Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
shell. You'll need to set these environment variables for `make` to succeed:
```sh
export GLSLANG=glslangValidator.exe
export SPIRVCROSS=spirv-cross.exe
```