Skip to content

Commit 1154cd8

Browse files
jdolanCopilot
andcommitted
Use pattern rules in Makefile.am; stage encoded in file extension
Replace 20 explicit per-shader rules with 6 pattern rules keyed on .vert/.frag/.comp extension. Also use $(addprefix) on the shadercross phony target so it resolves correctly in out-of-tree builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9f932d5 commit 1154cd8

1 file changed

Lines changed: 10 additions & 29 deletions

File tree

Examples/Shaders/Makefile.am

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,59 +27,40 @@ SPIRV_BLOBS = \
2727
HelloCompute.vert.spv \
2828
HelloCompute.frag.spv
2929

30-
DXIL_BLOBS =
31-
32-
EXTRA_DIST = $(HLSL_SOURCES) $(MSL_BLOBS) $(SPIRV_BLOBS) $(DXIL_BLOBS)
30+
EXTRA_DIST = $(HLSL_SOURCES) $(MSL_BLOBS) $(SPIRV_BLOBS)
3331

3432
# For out-of-tree builds, symlink the pre-built blobs into the build directory
3533
# so SDL Resource resolution (SDL_GetBasePath() + "Shaders") finds them.
3634
all-local:
3735
@if [ "x$(srcdir)" != "x$(builddir)" ]; then \
38-
for f in $(MSL_BLOBS) $(SPIRV_BLOBS) $(DXIL_BLOBS); do \
36+
for f in $(MSL_BLOBS) $(SPIRV_BLOBS); do \
3937
test -e "$(builddir)/$$f" || \
4038
$(LN_S) "$(abs_srcdir)/$$f" "$(builddir)/$$f"; \
4139
done; \
4240
fi
4341

4442
# -------------------------------------------------------------------------
4543
# shadercross — regenerate all blobs from HLSL source.
46-
# Requires shadercross (from SDL_shadercross) for HLSL→SPIR-V and HLSL→MSL.
44+
# Requires shadercross (from SDL_shadercross).
4745
# -------------------------------------------------------------------------
4846

4947
.PHONY: shadercross
50-
shadercross: $(MSL_BLOBS) $(SPIRV_BLOBS)
48+
shadercross: $(addprefix $(srcdir)/,$(MSL_BLOBS) $(SPIRV_BLOBS))
5149

52-
# Hello — vertex
53-
$(srcdir)/Hello.vert.spv: $(srcdir)/Hello.vert.hlsl
50+
$(srcdir)/%.vert.spv: $(srcdir)/%.vert.hlsl
5451
$(SHADERCROSS) $< -s HLSL -d SPIRV -t vertex -e vs_main -o $@
5552

56-
$(srcdir)/Hello.vert.msl: $(srcdir)/Hello.vert.hlsl
53+
$(srcdir)/%.vert.msl: $(srcdir)/%.vert.hlsl
5754
$(SHADERCROSS) $< -s HLSL -d MSL -t vertex -e vs_main -o $@
5855

59-
# Hello — fragment
60-
$(srcdir)/Hello.frag.spv: $(srcdir)/Hello.frag.hlsl
56+
$(srcdir)/%.frag.spv: $(srcdir)/%.frag.hlsl
6157
$(SHADERCROSS) $< -s HLSL -d SPIRV -t fragment -e fs_main -o $@
6258

63-
$(srcdir)/Hello.frag.msl: $(srcdir)/Hello.frag.hlsl
59+
$(srcdir)/%.frag.msl: $(srcdir)/%.frag.hlsl
6460
$(SHADERCROSS) $< -s HLSL -d MSL -t fragment -e fs_main -o $@
6561

66-
# HelloCompute — compute
67-
$(srcdir)/HelloCompute.comp.spv: $(srcdir)/HelloCompute.comp.hlsl
62+
$(srcdir)/%.comp.spv: $(srcdir)/%.comp.hlsl
6863
$(SHADERCROSS) $< -s HLSL -d SPIRV -t compute -e cs_main -o $@
6964

70-
$(srcdir)/HelloCompute.comp.msl: $(srcdir)/HelloCompute.comp.hlsl
65+
$(srcdir)/%.comp.msl: $(srcdir)/%.comp.hlsl
7166
$(SHADERCROSS) $< -s HLSL -d MSL -t compute -e cs_main -o $@
72-
73-
# HelloCompute — vertex
74-
$(srcdir)/HelloCompute.vert.spv: $(srcdir)/HelloCompute.vert.hlsl
75-
$(SHADERCROSS) $< -s HLSL -d SPIRV -t vertex -e vs_main -o $@
76-
77-
$(srcdir)/HelloCompute.vert.msl: $(srcdir)/HelloCompute.vert.hlsl
78-
$(SHADERCROSS) $< -s HLSL -d MSL -t vertex -e vs_main -o $@
79-
80-
# HelloCompute — fragment
81-
$(srcdir)/HelloCompute.frag.spv: $(srcdir)/HelloCompute.frag.hlsl
82-
$(SHADERCROSS) $< -s HLSL -d SPIRV -t fragment -e fs_main -o $@
83-
84-
$(srcdir)/HelloCompute.frag.msl: $(srcdir)/HelloCompute.frag.hlsl
85-
$(SHADERCROSS) $< -s HLSL -d MSL -t fragment -e fs_main -o $@

0 commit comments

Comments
 (0)