Compare commits

...

12 Commits

Author SHA1 Message Date
benji
eda300c870 default to no multithreading for emscripten 2026-02-15 19:11:20 -05:00
dependabot[bot]
fc0cada1eb build(deps): bump the submodules group with 2 updates (#11)
* build(deps): bump the submodules group with 2 updates

Bumps the submodules group with 2 updates: [bgfx](https://github.com/bkaradzic/bgfx) and [bx](https://github.com/bkaradzic/bx).
2026-02-02 20:46:15 -05:00
Branimir Karadžić
fbe794fa4c Update dependabot.yml (#12) 2026-02-02 03:34:56 +00:00
Branimir Karadžić
12dcf5f74c Update dependabot.yml 2026-02-02 03:31:44 +00:00
Branimir Karadžić
5a19118dec Update dependabot.yml 2026-02-02 03:31:11 +00:00
Sage Martin
6a35cc27ed CMP0175 fixes (#9) 2026-01-23 23:45:07 -05:00
Sandy
4ae9b3209b Add new code owner @jsm174 (#8) 2026-01-20 11:22:45 -05:00
Jason Millard
cbd0e09dd9 deps: bump bgfx, bimg, and bx 2026-01-20 09:32:00 -05:00
Jason Millard
f104e89b0e deps: bump bgfx, and bx, add support for compiling tint 2026-01-10 21:38:17 -05:00
Jason Millard
54fc2e6d5a deps: bump bgfx and bx 2026-01-08 16:19:51 -05:00
leia uwu
8301c805b5 fix shader paths on README 2025-12-11 23:56:14 -05:00
alemuntoni
b5e37cd0db bump submodules and add new sources to spirv-opt.cmake 2025-12-04 08:23:11 -05:00
13 changed files with 160 additions and 28 deletions

1
.github/CODEOWNERS vendored
View File

@@ -1 +1,2 @@
* @bwrsandman
* @jsm174

View File

@@ -45,7 +45,7 @@ cmake_dependent_option(
)
cmake_dependent_option(BGFX_WITH_WAYLAND "Use Wayland backend." ON "CMAKE_SYSTEM_NAME STREQUAL Linux" OFF)
option(BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON)
option(BGFX_CONFIG_MULTITHREADED "Build bgfx with multithreaded configuration" ON)
cmake_dependent_option(BGFX_CONFIG_MULTITHREADED "Build bgfx with multithreaded configuration" ON "NOT CMAKE_SYSTEM_NAME STREQUAL Emscripten" OFF)
option(BGFX_CONFIG_RENDERER_WEBGPU "Enable the webgpu renderer" OFF)
option(BGFX_CONFIG_DEBUG_ANNOTATION "Enable gfx debug annotations (default: on in debug)" OFF)

View File

@@ -99,7 +99,7 @@ bgfx_compile_shaders(
```
This defines a shaderc command to generate binaries or headers for a number of `TYPE` shaders with `SHADERS` files and `VARYING_DEF` file in the `OUTPUT_DIR` directory. There will be one generated shader for each supported rendering API on this current platform according to the `BGFX_EMBEDDED_SHADER` macro in `bgfx/embedded_shader.h` for headers and in the directory expected by `load_shader` in `bgfx_utils.h`.
The generated headers will have names in the format of `${RENDERING_API}/${SHADERS}.bin[.h]` where `RENDERING_API` can be `glsl`, `essl`, `spv`, `dx11` and `mtl` depending on the availability of the platform.
The generated headers will have names in the format of `${RENDERING_API}/${SHADERS}.bin[.h]` where `RENDERING_API` can be `glsl`, `essl`, `spirv`, `dx11` and `metal` depending on the availability of the platform.
Adding these `SHADERS` as source files to a target will run `shaderc` at build time and they will rebuild if either the contents of the `SHADERS` or the `VARYING_DEF` change.
@@ -128,17 +128,17 @@ target_include_directories(myLib ${CMAKE_BINARY_DIR}/include/generated/shaders)
// main.cpp
#include <glsl/vs.sc.bin.h>
#include <essl/vs.sc.bin.h>
#include <spv/vs.sc.bin.h>
#include <spirv/vs.sc.bin.h>
#include <glsl/fs.sc.bin.h>
#include <essl/fs.sc.bin.h>
#include <spv/fs.sc.bin.h>
#include <spirv/fs.sc.bin.h>
#if defined(_WIN32)
#include <dx11/vs.sc.bin.h>
#include <dx11/fs.sc.bin.h>
#endif // defined(_WIN32)
#if __APPLE__
#include <mtl/vs.sc.bin.h>
#include <mtl/fs.sc.bin.h>
#include <metal/vs.sc.bin.h>
#include <metal/fs.sc.bin.h>
#endif // __APPLE__
const bgfx::EmbeddedShader k_vs = BGFX_EMBEDDED_SHADER(vs);

2
bgfx

Submodule bgfx updated: ee2072d02f...011ede6b42

2
bimg

Submodule bimg updated: bf10ffbb3d...a0204c79f9

2
bx

Submodule bx updated: 1dc8c48270...36ad6131f4

View File

@@ -55,9 +55,10 @@ set_target_properties(glslang PROPERTIES FOLDER "bgfx")
target_include_directories(
glslang
PUBLIC ${GLSLANG} #
${GLSLANG}/glslang/Public #
PRIVATE ${GLSLANG}/.. #
${SPIRV_TOOLS}/include #
${SPIRV_TOOLS}/source #
PUBLIC ${GLSLANG}
${GLSLANG}/glslang/Public
${GLSLANG}/glslang/Include
PRIVATE ${GLSLANG}/..
${SPIRV_TOOLS}/include
${SPIRV_TOOLS}/source
)

View File

@@ -84,6 +84,7 @@ file(
${SPIRV_TOOLS}/source/util/hex_float.h
${SPIRV_TOOLS}/source/util/parse_number.cpp
${SPIRV_TOOLS}/source/util/parse_number.h
${SPIRV_TOOLS}/source/util/status.h
${SPIRV_TOOLS}/source/util/string_utils.cpp
${SPIRV_TOOLS}/source/util/string_utils.h
${SPIRV_TOOLS}/source/util/timer.h
@@ -113,6 +114,7 @@ file(
${SPIRV_TOOLS}/source/val/validate_extensions.cpp
${SPIRV_TOOLS}/source/val/validate_function.cpp
${SPIRV_TOOLS}/source/val/validate_graph.cpp
${SPIRV_TOOLS}/source/val/validate_group.cpp
${SPIRV_TOOLS}/source/val/validate_id.cpp
${SPIRV_TOOLS}/source/val/validate_image.cpp
${SPIRV_TOOLS}/source/val/validate_instruction.cpp
@@ -120,6 +122,7 @@ file(
${SPIRV_TOOLS}/source/val/validate_invalid_type.cpp
${SPIRV_TOOLS}/source/val/validate_layout.cpp
${SPIRV_TOOLS}/source/val/validate_literals.cpp
${SPIRV_TOOLS}/source/val/validate_logical_pointers.cpp
${SPIRV_TOOLS}/source/val/validate_logicals.cpp
${SPIRV_TOOLS}/source/val/validate_memory.cpp
${SPIRV_TOOLS}/source/val/validate_memory_semantics.cpp

98
cmake/bgfx/3rdparty/tint.cmake vendored Normal file
View File

@@ -0,0 +1,98 @@
# bgfx.cmake - bgfx building in cmake
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
#
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
if(TARGET tint)
return()
endif()
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
set(TINT_DIR ${BGFX_DIR}/3rdparty/dawn)
set(SPIRV_HEADERS ${BGFX_DIR}/3rdparty/spirv-headers)
set(SPIRV_TOOLS ${BGFX_DIR}/3rdparty/spirv-tools)
file(
GLOB_RECURSE
TINT_SOURCES
${TINT_DIR}/src/tint/utils/*.cc
${TINT_DIR}/src/tint/utils/*.h
${TINT_DIR}/src/tint/lang/core/*.cc
${TINT_DIR}/src/tint/lang/core/*.h
${TINT_DIR}/src/tint/lang/null/*.cc
${TINT_DIR}/src/tint/lang/null/*.h
${TINT_DIR}/src/tint/lang/spirv/*.cc
${TINT_DIR}/src/tint/lang/spirv/*.h
${TINT_DIR}/src/tint/lang/wgsl/*.cc
${TINT_DIR}/src/tint/lang/wgsl/*.h
${TINT_DIR}/src/tint/api/*.cc
${TINT_DIR}/src/tint/api/*.h
)
add_library(tint STATIC ${TINT_SOURCES})
set_target_properties(tint PROPERTIES FOLDER "bgfx")
target_include_directories(
tint
PUBLIC ${TINT_DIR}
${TINT_DIR}/src/tint
PRIVATE ${TINT_DIR}/third_party/protobuf/src
${TINT_DIR}/third_party/abseil-cpp
${SPIRV_TOOLS}
${SPIRV_TOOLS}/include
${SPIRV_TOOLS}/include/generated
${SPIRV_HEADERS}/include
)
target_compile_definitions(
tint
PRIVATE TINT_BUILD_GLSL_WRITER=0
TINT_BUILD_HLSL_WRITER=0
TINT_BUILD_MSL_WRITER=0
TINT_BUILD_NULL_WRITER=0
TINT_BUILD_SPV_READER=1
TINT_BUILD_SPV_WRITER=0
TINT_BUILD_WGSL_READER=0
TINT_BUILD_WGSL_WRITER=1
TINT_ENABLE_IR_VALIDATION=0
)
if(WIN32)
target_compile_definitions(
tint
PRIVATE TINT_BUILD_IS_LINUX=0
TINT_BUILD_IS_MAC=0
TINT_BUILD_IS_WIN=1
)
elseif(APPLE)
target_compile_definitions(
tint
PRIVATE TINT_BUILD_IS_LINUX=0
TINT_BUILD_IS_MAC=1
TINT_BUILD_IS_WIN=0
)
else()
target_compile_definitions(
tint
PRIVATE TINT_BUILD_IS_LINUX=1
TINT_BUILD_IS_MAC=0
TINT_BUILD_IS_WIN=0
)
endif()
if(MSVC)
target_compile_options(
tint
PRIVATE "/Zc:preprocessor"
)
endif()

View File

@@ -26,6 +26,7 @@ if(BGFX_BUILD_TOOLS_SHADER)
include(3rdparty/glsl-optimizer.cmake)
include(3rdparty/fcpp.cmake)
include(3rdparty/webgpu.cmake)
include(3rdparty/tint.cmake)
include(shaderc.cmake)
endif()

View File

@@ -31,6 +31,8 @@ function(add_bgfx_shader FILE FOLDER)
set(COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src)
set(OUTPUTS "")
set(OUTPUTS_PRETTY "")
set(OUTPUT_FILES "")
set(COMMANDS "")
if(WIN32)
# dx11
@@ -85,11 +87,15 @@ function(add_bgfx_shader FILE FOLDER)
set(SPIRV_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/spirv/${FILENAME}.bin)
_bgfx_shaderc_parse(SPIRV ${COMMON} LINUX PROFILE spirv OUTPUT ${SPIRV_OUTPUT})
list(APPEND OUTPUTS "SPIRV")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}SPIRV")
set(OUTPUT_FILES "")
set(COMMANDS "")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}SPIRV, ")
endif()
# wgsl
set(WGSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/wgsl/${FILENAME}.bin)
_bgfx_shaderc_parse(WGSL ${COMMON} LINUX PROFILE wgsl OUTPUT ${WGSL_OUTPUT})
list(APPEND OUTPUTS "WGSL")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}WGSL")
foreach(OUT ${OUTPUTS})
list(APPEND OUTPUT_FILES ${${OUT}_OUTPUT})
list(APPEND COMMANDS COMMAND "bgfx::shaderc" ${${OUT}})
@@ -163,38 +169,44 @@ function(add_example ARG_NAME)
# on iOS we need to build a bundle so have to copy the data rather than symlink
# and on windows we can't create symlinks
add_custom_command(
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E copy_directory ${BGFX_DIR}/examples/runtime/
TARGET example-${ARG_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${BGFX_DIR}/examples/runtime/
$<TARGET_FILE_DIR:example-${ARG_NAME}>
)
else()
# For everything else symlink some folders into our output directory
add_custom_command(
TARGET example-${ARG_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/font
$<TARGET_FILE_DIR:example-${ARG_NAME}>/font
)
add_custom_command(
TARGET example-${ARG_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/images
$<TARGET_FILE_DIR:example-${ARG_NAME}>/images
)
add_custom_command(
TARGET example-${ARG_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/meshes
$<TARGET_FILE_DIR:example-${ARG_NAME}>/meshes
)
add_custom_command(
TARGET example-${ARG_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/shaders
$<TARGET_FILE_DIR:example-${ARG_NAME}>/shaders
)
add_custom_command(
TARGET example-${ARG_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/text
$<TARGET_FILE_DIR:example-${ARG_NAME}>/text
)
add_custom_command(
TARGET example-${ARG_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/textures
$<TARGET_FILE_DIR:example-${ARG_NAME}>/textures
)

View File

@@ -19,16 +19,6 @@ file(
add_executable(shaderc ${SHADERC_SOURCES})
target_link_libraries(
shaderc
PRIVATE bx
bgfx-vertexlayout
fcpp
glslang
glsl-optimizer
spirv-opt
spirv-cross
)
target_link_libraries(
shaderc
PRIVATE bx
@@ -40,7 +30,28 @@ target_link_libraries(
spirv-opt
spirv-cross
webgpu
tint
)
target_include_directories(
shaderc
PRIVATE ${BGFX_DIR}/3rdparty/dawn
${BGFX_DIR}/3rdparty/dawn/src
)
if(UNIX
AND NOT APPLE
AND NOT EMSCRIPTEN
AND NOT ANDROID
)
target_include_directories(
shaderc
PRIVATE ${BGFX_DIR}/3rdparty/directx-headers/include/directx
${BGFX_DIR}/3rdparty/directx-headers/include
${BGFX_DIR}/3rdparty/directx-headers/include/wsl/stubs
)
endif()
if(BGFX_AMALGAMATED)
target_link_libraries(shaderc PRIVATE bgfx-shader)
endif()

View File

@@ -60,6 +60,11 @@ endforeach()
add_library(bx STATIC ${BX_SOURCES})
if(MSVC)
target_compile_options(bx PRIVATE /EHs-c-)
target_compile_definitions(bx PRIVATE _HAS_EXCEPTIONS=0)
endif()
# Put in a "bgfx" folder in Visual Studio
set_target_properties(bx PROPERTIES FOLDER "bgfx")