From 56e19741c2cf9e28c02a7f2a20ef912c6c6417c9 Mon Sep 17 00:00:00 2001 From: Daniel Kalmar Date: Mon, 30 Sep 2024 22:32:29 +0200 Subject: [PATCH] Minimal changes to update pssl support. - 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. --- include/bgfx/embedded_shader.h | 2 +- scripts/shader-embeded.mk | 9 +++------ src/bgfx_shader.sh | 2 +- src/fs_clear6.bin.h | 3 +-- src/makefile | 3 +-- src/vs_debugfont.bin.h | 3 +-- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/include/bgfx/embedded_shader.h b/include/bgfx/embedded_shader.h index db80f936df..c12a7f8a9f 100644 --- a/include/bgfx/embedded_shader.h +++ b/include/bgfx/embedded_shader.h @@ -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 diff --git a/scripts/shader-embeded.mk b/scripts/shader-embeded.mk index e058be3ec7..0e7ca3d220 100644 --- a/scripts/shader-embeded.mk +++ b/scripts/shader-embeded.mk @@ -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 [$(<)] @@ -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 [$(<)] @@ -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) diff --git a/src/bgfx_shader.sh b/src/bgfx_shader.sh index 3fe839a6d1..5fb96d9ebb 100644 --- a/src/bgfx_shader.sh +++ b/src/bgfx_shader.sh @@ -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) diff --git a/src/fs_clear6.bin.h b/src/fs_clear6.bin.h index 8f29ba451a..c415e24929 100644 --- a/src/fs_clear6.bin.h +++ b/src/fs_clear6.bin.h @@ -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] = {}; diff --git a/src/makefile b/src/makefile index 8257fcd620..c6dedd310f 100644 --- a/src/makefile +++ b/src/makefile @@ -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 diff --git a/src/vs_debugfont.bin.h b/src/vs_debugfont.bin.h index 08510cd666..1b5c360317 100644 --- a/src/vs_debugfont.bin.h +++ b/src/vs_debugfont.bin.h @@ -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] = {};