updated build configuration
This commit is contained in:
parent
c98c00bfb9
commit
88d9b65028
@ -2,12 +2,12 @@
|
||||
"Debug": {
|
||||
"build": [
|
||||
{
|
||||
"args": "",
|
||||
"command": "scripts/compile_shaders.sh",
|
||||
"args": "-C resources/shaders",
|
||||
"command": "make",
|
||||
"working_dir": ""
|
||||
},
|
||||
{
|
||||
"args": "clean-run -g",
|
||||
"args": "build -g",
|
||||
"command": "c3c",
|
||||
"working_dir": ""
|
||||
}
|
||||
@ -15,8 +15,8 @@
|
||||
"build_types": [],
|
||||
"clean": [
|
||||
{
|
||||
"args": "",
|
||||
"command": "rm build/ugui",
|
||||
"args": "clean",
|
||||
"command": "c3c",
|
||||
"working_dir": ""
|
||||
}
|
||||
],
|
||||
|
33
resources/shaders/Makefile
Normal file
33
resources/shaders/Makefile
Normal file
@ -0,0 +1,33 @@
|
||||
SOURCE_DIR := ./source
|
||||
COMPILED_DIR := ./compiled
|
||||
|
||||
SOURCE_FILES := $(wildcard $(SOURCE_DIR)/*.glsl)
|
||||
|
||||
COMPILED_FILES := $(patsubst $(SOURCE_DIR)/%.glsl,$(COMPILED_DIR)/%.spv,$(SOURCE_FILES))
|
||||
|
||||
all: $(COMPILED_FILES)
|
||||
@echo "Compiling shaders from $(SOURCE_DIR) -> $(COMPILED_DIR)"
|
||||
|
||||
$(COMPILED_DIR)/%.spv: $(SOURCE_DIR)/%.glsl
|
||||
@mkdir -p $(COMPILED_DIR)
|
||||
@stage=$$(basename $< .glsl | cut -d. -f2); \
|
||||
if [ "$$stage" = "frag" ] || [ "$$stage" = "vert" ]; then \
|
||||
echo "$$stage $(notdir $<) > $(notdir $@)"; \
|
||||
glslc -O0 -g -fshader-stage=$$stage $< -o $@; \
|
||||
else \
|
||||
echo "Skipping $<: unsupported stage $$stage"; \
|
||||
fi
|
||||
|
||||
$(COMPILED_DIR):
|
||||
mkdir -p $(COMPILED_DIR)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(COMPILED_DIR)
|
||||
|
||||
.PHONY: tree
|
||||
tree:
|
||||
tree $(COMPILED_DIR)
|
||||
|
||||
.PHONY: compile_all
|
||||
compile_all: clean all tree
|
@ -1,41 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
source_directory="./resources/shaders/source"
|
||||
compiled_directory="./resources/shaders/compiled"
|
||||
#vulkan_version="1.0"
|
||||
|
||||
mkdir -p "$compiled_directory"
|
||||
rm -f "$compiled_directory"/*
|
||||
|
||||
echo "Compiling from $source_directory -> $compiled_directory"
|
||||
|
||||
for file in "$source_directory"/*; do
|
||||
[ -f "$file" ] || continue # Skip non-files
|
||||
filename=$(basename "$file")
|
||||
|
||||
# Extract filename parts using POSIX parameter expansion
|
||||
shader_language="${filename##*.}"
|
||||
stage_part="${filename%.*}" # Remove extension
|
||||
base_name="${stage_part%.*}" # Remove stage
|
||||
stage="${stage_part#"$base_name"}"
|
||||
stage="${stage#.}" # Remove leading dot
|
||||
|
||||
# Skip if not in base.stage.glsl format
|
||||
[ "$shader_language" = "glsl" ] && [ -n "$base_name" ] && [ -n "$stage" ] || continue
|
||||
|
||||
# Handle HLSL rejection
|
||||
if [ "$shader_language" != "glsl" ]; then
|
||||
echo "Error: Only GLSL shaders are supported" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Compile based on shader stage
|
||||
case "$stage" in
|
||||
frag|vert)
|
||||
echo "$stage $filename > $base_name.$stage.spv"
|
||||
glslc -O0 -g -fshader-stage="$stage" "$file" -o "$compiled_directory/$base_name.$stage.spv"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
tree "$compiled_directory"
|
Loading…
Reference in New Issue
Block a user