Skip to content

Commit

Permalink
Minimal changes to update pssl support.
Browse files Browse the repository at this point in the history
- Fix a line in bgfx_shader.sh (tested locally).
- Update the shader embedding macro to match the other macros.
- Update embedded shader generating make rules to output the same style for PSSL as the other rules (but empty arrays).

Some of the changes are not well tested as I'm having trouble (re-)generating all shaders in my dev environment.
  • Loading branch information
kalmard0 committed Sep 30, 2024
1 parent f8b2061 commit 56e1974
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion include/bgfx/embedded_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#if BGFX_PLATFORM_SUPPORTS_PSSL
# undef BGFX_EMBEDDED_SHADER_PSSL
# define BGFX_EMBEDDED_SHADER_PSSL(_renderer, _name) \
{ _renderer, BGFX_EMBEDDED_SHADER_CONCATENATE(_name, _pssl), BGFX_EMBEDDED_SHADER_COUNTOF(BGFX_EMBEDDED_SHADER_CONCATENATE(_name, _pssl_size) ) },
{ _renderer, BGFX_EMBEDDED_SHADER_CONCATENATE(_name, _pssl), BGFX_EMBEDDED_SHADER_COUNTOF(BGFX_EMBEDDED_SHADER_CONCATENATE(_name, _pssl) ) },
#endif // BGFX_PLATFORM_SUPPORTS_PSSL

#if BGFX_PLATFORM_SUPPORTS_ESSL
Expand Down
9 changes: 3 additions & 6 deletions scripts/shader-embeded.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ vs_%.bin.h : vs_%.sc
-@cat "$(SHADER_TMP)" >> $(@)
-$(SILENT) $(SHADERC) $(VS_FLAGS) --platform ios -p metal -O 3 -f $(<) -o "$(SHADER_TMP)" --bin2c $(basename $(<))_mtl
-@cat "$(SHADER_TMP)" >> $(@)
-@printf "extern const uint8_t* $(basename $(<))_pssl;\n" | tr -d '\015' >> $(@)
-@printf "extern const uint32_t $(basename $(<))_pssl_size;\n" | tr -d '\015' >> $(@)
-@printf "static const uint8_t $(basename $(<))_pssl[0] = {};\n" | tr -d '\015' >> $(@)

fs_%.bin.h : fs_%.sc
@echo [$(<)]
Expand All @@ -49,8 +48,7 @@ fs_%.bin.h : fs_%.sc
-@cat "$(SHADER_TMP)" >> $(@)
-$(SILENT) $(SHADERC) $(FS_FLAGS) --platform ios -p metal -O 3 -f $(<) -o "$(SHADER_TMP)" --bin2c $(basename $(<))_mtl
-@cat "$(SHADER_TMP)" >> $(@)
-@printf "extern const uint8_t* $(basename $(<))_pssl;\n" | tr -d '\015' >> $(@)
-@printf "extern const uint32_t $(basename $(<))_pssl_size;\n" | tr -d '\015' >> $(@)
-@printf "static const uint8_t $(basename $(<))_pssl[0] = {};\n" | tr -d '\015' >> $(@)

cs_%.bin.h : cs_%.sc
@echo [$(<)]
Expand All @@ -62,8 +60,7 @@ cs_%.bin.h : cs_%.sc
-@cat "$(SHADER_TMP)" >> $(@)
-$(SILENT) $(SHADERC) $(CS_FLAGS) --platform windows -p s_5_0 -O 1 -f $(<) -o "$(SHADER_TMP)" --bin2c $(basename $(<))_dx11
-@cat "$(SHADER_TMP)" >> $(@)
-@printf "extern const uint8_t* $(basename $(<))_pssl;\n" | tr -d '\015' >> $(@)
-@printf "extern const uint32_t $(basename $(<))_pssl_size;\n" | tr -d '\015' >> $(@)
-@printf "static const uint8_t $(basename $(<))_pssl[0] = {};\n" | tr -d '\015' >> $(@)

.PHONY: all
all: $(BIN)
Expand Down
2 changes: 1 addition & 1 deletion src/bgfx_shader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

// To be able to patch the uav registers on the DXBC SPDB Chunk (D3D11 renderer) the whitespaces around
// '_type[_reg]' are necessary. This only affects shaders with debug info (i.e., those that have the SPDB Chunk).
# if BGFX_SHADER_LANGUAGE_HLSL > 400 || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL
# if BGFX_SHADER_LANGUAGE_HLSL > 400 || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL
# define REGISTER(_type, _reg) register( _type[_reg] )
# else
# define REGISTER(_type, _reg) register(_type ## _reg)
Expand Down
3 changes: 1 addition & 2 deletions src/fs_clear6.bin.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,4 @@ static const uint8_t fs_clear6_mtl[982] =
0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, // return out;.}
0x0a, 0x0a, 0x00, 0x00, 0x70, 0x00, // ....p.
};
extern const uint8_t* fs_clear6_pssl;
extern const uint32_t fs_clear6_pssl_size;
static const uint8_t fs_clear6_pssl[0] = {};
3 changes: 1 addition & 2 deletions src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ define shader-embedded
-@cat "$(SHADER_TMP)" >> $(@)
-$(SILENT) $(SHADERC) --type $(1) --platform ios -p metal -O 3 -f $(<) -o "$(SHADER_TMP)" --bin2c $(basename $(<))_mtl
-@cat "$(SHADER_TMP)" >> $(@)
-@printf "extern const uint8_t* $(basename $(<))_pssl;\n" | tr -d '\015' >> $(@)
-@printf "extern const uint32_t $(basename $(<))_pssl_size;\n" | tr -d '\015' >> $(@)
-@printf "static const uint8_t $(basename $(<))_pssl[0] = {};\n" | tr -d '\015' >> $(@)
endef

vs_debugfont.bin.h : vs_debugfont.sc
Expand Down
3 changes: 1 addition & 2 deletions src/vs_debugfont.bin.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,5 +275,4 @@ static const uint8_t vs_debugfont_mtl[1035] =
0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // return out;.}...
0x04, 0x05, 0x00, 0x06, 0x00, 0x01, 0x00, 0x10, 0x00, 0x40, 0x00, // .........@.
};
extern const uint8_t* vs_debugfont_pssl;
extern const uint32_t vs_debugfont_pssl_size;
static const uint8_t vs_debugfont_pssl[0] = {};

0 comments on commit 56e1974

Please sign in to comment.