Compare commits

...

28 Commits

Author SHA1 Message Date
574dd75c69 fix(build): 修复shaderc编译参数中的语法错误
移除多余的WERROR参数并修正条件表达式语法
2026-04-27 10:21:20 +08:00
Jason Millard
98d6c112a4 deps: bump bgfx and bimg 2026-04-19 13:55:21 -04:00
Jason Millard
75700d672a deps: bump bgfx 2026-04-15 11:10:05 -04:00
Jason Millard
c3fa3b0e36 deps: bump bgfx and bx 2026-04-13 20:00:39 -04:00
Jason Millard
668550dc7c deps: bump bgfx to latest 2026-03-24 20:19:22 -04:00
Jason Millard
8cc59b3a23 deps: bump bgfx and bimg to latest, add missing examples 2026-03-24 07:44:31 -04:00
Jason Millard
884c624619 deps: bump bgfx to latest 2026-03-22 11:31:49 -04:00
Jason Millard
9ba6a8ae0f deps: bump bgfx to latest 2026-03-21 14:44:33 -04:00
Jason Millard
830133102d ci: bump some github actions to latest 2026-03-20 22:43:48 -04:00
Jason Millard
4a9973b9e3 misc: add support for compiling metal-cpp 2026-03-20 22:43:48 -04:00
Jason Millard
78c265c3c9 deps: bump bgfx, bimg, and bx 2026-03-20 22:43:48 -04:00
Alex Threlfo
10a9ed2220 update shaderc target profiles
- dx10 is deprecated
- dx11 -> dxbc
- use appropriate gl target based on shader type
- add wgsl
- add dxil (dx12)

dxil is a bit of an odd one as bgfx dynamically loads the compiler
runtime from the shaderc binary path, so i've added some extra
configuration to copy the appropriate vendored binaries over to the
build output/install directories.
2026-03-19 22:53:34 -04:00
Alex Threlfo
26dbcda964 fix all renderers defaulting to disabled
caused by bkaradzic/bgfx.cmake#22

overriding *any* renderer config defines causes bgfx to disable
automatic config derivation for *all* renderers - this meant that force
disabling WebGPU was also implicitly disabling all other renderers by
default. not sure what the best option is here (outside of explicitly
setting all renderers in the build system) but removing this for now to
restore expected per-platform defaults.
2026-03-17 13:16:56 -04:00
Alex Threlfo
4f736eedd5 add shader defines to bgfx_compile_shaders()
fixes bkaradzic/bgfx.cmake#19
2026-03-13 08:35:48 -04:00
Alex Threlfo
ceacf584eb disable webgpu renderer at runtime if it is not configured
the logic here was a bit backwards in that webgpu was forced at runtime
if we were building it - bgfx will figure out what renderers are
supported by the current target itself, but it *should* be removed as an
option if we aren't linking to it.
2026-03-13 08:35:22 -04:00
Alex Threlfo
7addeb2643 fix renderer_webgpu.cpp being compiled as plain c++ in xcode 2026-03-09 22:11:28 -04:00
Jason Millard
6e2138a920 add validate_dot_product.cpp and validate_pipe.cpp for spirv-opt 2026-03-01 11:06:11 -05:00
dependabot[bot]
af6a3b1f2f 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).


Updates `bgfx` from `651c203` to `0b1c1ec`
- [Commits](651c203116...0b1c1ecaca)

Updates `bx` from `36ad613` to `fa641d8`
- [Commits](36ad6131f4...fa641d8581)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-version: 0b1c1ecaca917acc093f755bf8468711a5b24aee
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-version: fa641d8581f7f6f696a37abe4b80558aca161440
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-01 11:06:11 -05:00
Jason Millard
f40f4ca580 deps: bump bgfx and bimg (#14) 2026-02-20 17:34:31 -05:00
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
18 changed files with 218 additions and 79 deletions

1
.github/CODEOWNERS vendored
View File

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

View File

@@ -17,7 +17,7 @@ jobs:
env:
CMAKE_VERSION: 3.20.0
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install Linux dependencies
@@ -57,7 +57,7 @@ jobs:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install Linux dependencies
@@ -94,7 +94,7 @@ jobs:
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install Linux dependencies

View File

@@ -12,7 +12,7 @@ jobs:
name: cmake-format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
@@ -31,7 +31,7 @@ jobs:
needs: cmake-format-check
if: always() && startsWith(github.event_name, 'pull_request') && needs.cmake-format-check.result == 'failure'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
@@ -45,7 +45,7 @@ jobs:
args: --config-files .cmake-format.py --in-place
- run: |
git diff > cmake-format.patch
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: formatting-fix-${{github.sha}}
path: cmake-format.patch

View File

@@ -18,7 +18,7 @@ jobs:
sha: ${{ steps.version.outputs.sha }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
@@ -51,7 +51,7 @@ jobs:
CMAKE_INSTALL_DIR: ${{ github.workspace }}/install/
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install Linux dependencies
@@ -80,7 +80,7 @@ jobs:
- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target install --config Release
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}
path: ${{ github.workspace }}/install/
@@ -93,7 +93,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
@@ -102,15 +102,15 @@ jobs:
find src/bgfx.cmake -name ".git*" -exec rm -rf {} +
find src/bgfx.cmake -name ".editorconfig" -delete
rm src/bgfx.cmake/.cmake-format.py
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v8
with:
name: windows-latest
path: ${{ github.workspace }}/install/windows/bgfx.cmake
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v8
with:
name: ubuntu-latest
path: ${{ github.workspace }}/install/linux/bgfx.cmake
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v8
with:
name: macos-latest
path: ${{ github.workspace }}/install/macos/bgfx.cmake

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)

2
bgfx

Submodule bgfx updated: d9d99f51ad...4481b9b46b

2
bimg

Submodule bimg updated: bf10ffbb3d...2317bb623a

2
bx

Submodule bx updated: 01cf049f97...c6131ec676

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

@@ -110,10 +110,12 @@ file(
${SPIRV_TOOLS}/source/val/validate_debug.cpp
${SPIRV_TOOLS}/source/val/validate_decorations.cpp
${SPIRV_TOOLS}/source/val/validate_derivatives.cpp
${SPIRV_TOOLS}/source/val/validate_dot_product.cpp
${SPIRV_TOOLS}/source/val/validate_execution_limitations.cpp
${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
@@ -129,6 +131,7 @@ file(
${SPIRV_TOOLS}/source/val/validate_misc.cpp
${SPIRV_TOOLS}/source/val/validate_mode_setting.cpp
${SPIRV_TOOLS}/source/val/validate_non_uniform.cpp
${SPIRV_TOOLS}/source/val/validate_pipe.cpp
${SPIRV_TOOLS}/source/val/validate_primitives.cpp
${SPIRV_TOOLS}/source/val/validate_ray_query.cpp
${SPIRV_TOOLS}/source/val/validate_ray_tracing.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

@@ -29,14 +29,7 @@ file(
${BGFX_DIR}/include/bgfx/c99/*.h
)
if(APPLE)
file(GLOB BGFX_OBJC_SOURCES ${BGFX_DIR}/src/*.mm)
list(APPEND BGFX_SOURCES ${BGFX_OBJC_SOURCES})
list(REMOVE_ITEM BGFX_SOURCES ${BGFX_DIR}/src/amalgamated.cpp)
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.mm)
else()
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.cpp)
endif()
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.cpp)
if(BGFX_AMALGAMATED)
set(BGFX_NOBUILD ${BGFX_SOURCES})
@@ -59,7 +52,6 @@ endif()
if(BGFX_CONFIG_RENDERER_WEBGPU)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/webgpu.cmake)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_WEBGPU=1)
if(EMSCRIPTEN)
target_link_options(bgfx PRIVATE "-s USE_WEBGPU=1")
else()
@@ -192,13 +184,6 @@ if(UNIX
target_link_libraries(bgfx PUBLIC ${X11_LIBRARIES} ${OPENGL_LIBRARIES})
endif()
# Exclude mm files if not on OS X
if(NOT APPLE)
set_source_files_properties(${BGFX_DIR}/src/glcontext_eagl.mm PROPERTIES HEADER_FILE_ONLY ON)
set_source_files_properties(${BGFX_DIR}/src/glcontext_nsgl.mm PROPERTIES HEADER_FILE_ONLY ON)
set_source_files_properties(${BGFX_DIR}/src/renderer_mtl.mm PROPERTIES HEADER_FILE_ONLY ON)
endif()
# Exclude glx context on non-unix
if(NOT UNIX OR APPLE)
set_source_files_properties(${BGFX_DIR}/src/glcontext_glx.cpp PROPERTIES HEADER_FILE_ONLY ON)
@@ -207,10 +192,14 @@ endif()
# Put in a "bgfx" folder in Visual Studio
set_target_properties(bgfx PROPERTIES FOLDER "bgfx")
# in Xcode we need to specify this file as objective-c++ (instead of renaming to .mm)
# in Xcode we need to specify these files as objective-c++ (instead of renaming to .mm)
if(XCODE)
set_source_files_properties(
${BGFX_DIR}/src/renderer_vk.cpp PROPERTIES LANGUAGE OBJCXX XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp
${BGFX_DIR}/src/renderer_vk.cpp
${BGFX_DIR}/src/renderer_webgpu.cpp
PROPERTIES
LANGUAGE OBJCXX
XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp
)
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
)
@@ -334,6 +346,10 @@ if(BGFX_BUILD_EXAMPLES)
45-bokeh
46-fsr
47-pixelformats
48-drawindirect
49-hextile
50-headless
51-gpufont
)
foreach(EXAMPLE ${BGFX_EXAMPLES})

View File

@@ -1,3 +1 @@
#include "@BGFX_DIR@/src/shader.cpp"
#include "@BGFX_DIR@/src/shader_dxbc.cpp"
#include "@BGFX_DIR@/src/shader_spirv.cpp"

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,32 @@ target_link_libraries(
spirv-opt
spirv-cross
webgpu
tint
)
target_include_directories(
shaderc
PRIVATE ${BGFX_DIR}/3rdparty/dawn
${BGFX_DIR}/3rdparty/dawn/src
)
set(DXCOMPILER_RUNTIME)
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
)
set(DXCOMPILER_RUNTIME ${BGFX_DIR}/tools/bin/linux/libdxcompiler.so)
elseif(WIN32)
set(DXCOMPILER_RUNTIME ${BGFX_DIR}/tools/bin/windows/dxcompiler.dll)
endif()
if(BGFX_AMALGAMATED)
target_link_libraries(shaderc PRIVATE bgfx-shader)
endif()
@@ -66,3 +81,15 @@ endif()
if(BGFX_INSTALL)
install(TARGETS shaderc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
# DXIL compiler will be dynamically loaded at runtime - no need
# to link, just install the needed binaries alongside shaderc.exe
if(DXCOMPILER_RUNTIME)
add_custom_command(
TARGET shaderc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DXCOMPILER_RUNTIME} $<TARGET_FILE_DIR:shaderc>
)
if(BGFX_INSTALL)
install(FILES ${DXCOMPILER_RUNTIME} DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
endif()

View File

@@ -459,16 +459,10 @@ if(TARGET bgfx::shaderc)
# --define
if(ARG_DEFINES)
list(APPEND CLI "--defines")
set(DEFINES "")
foreach(DEFINE ${ARG_DEFINES})
if(NOT "${DEFINES}" STREQUAL "")
set(DEFINES "${DEFINES}\\\\;${DEFINE}")
else()
set(DEFINES "${DEFINE}")
endif()
endforeach()
list(APPEND CLI "${DEFINES}")
# Add extra escapes or CMake will expand in the final CLI
string(REPLACE ";" "\\\\\\;" DEFINES "${ARG_DEFINES}")
# Also need to quote escape for Unix shells
list(APPEND CLI "--define" "\"${DEFINES}\"")
endif()
# --raw
@@ -541,21 +535,25 @@ if(TARGET bgfx::shaderc)
# extensions consistent with those listed under bgfx/runtime/shaders
function(_bgfx_get_profile_path_ext PROFILE PROFILE_PATH_EXT)
string(REPLACE 100_es essl PROFILE ${PROFILE})
string(REPLACE 300_es essl PROFILE ${PROFILE})
string(REPLACE 120 glsl PROFILE ${PROFILE})
string(REPLACE s_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE s_5_0 dx11 PROFILE ${PROFILE})
string(REPLACE 430 glsl PROFILE ${PROFILE})
string(REPLACE s_5_0 dxbc PROFILE ${PROFILE})
string(REPLACE s_6_0 dxil PROFILE ${PROFILE})
set(${PROFILE_PATH_EXT} ${PROFILE} PARENT_SCOPE)
endfunction()
# extensions consistent with embedded_shader.h
function(_bgfx_get_profile_ext PROFILE PROFILE_EXT)
string(REPLACE 100_es essl PROFILE ${PROFILE})
string(REPLACE 300_es essl PROFILE ${PROFILE})
string(REPLACE 120 glsl PROFILE ${PROFILE})
string(REPLACE 430 glsl PROFILE ${PROFILE})
string(REPLACE spirv spv PROFILE ${PROFILE})
string(REPLACE metal mtl PROFILE ${PROFILE})
string(REPLACE s_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE s_5_0 dx11 PROFILE ${PROFILE})
string(REPLACE s_5_0 dxbc PROFILE ${PROFILE})
string(REPLACE s_6_0 dxil PROFILE ${PROFILE})
set(${PROFILE_EXT} ${PROFILE} PARENT_SCOPE)
endfunction()
@@ -566,16 +564,25 @@ if(TARGET bgfx::shaderc)
# OUTPUT_DIR directory
# OUT_FILES_VAR variable name
# INCLUDE_DIRS directories
# DEFINES defines
# [AS_HEADERS]
# )
#
function(bgfx_compile_shaders)
set(options AS_HEADERS)
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR OUT_FILES_VAR)
set(multiValueArgs SHADERS INCLUDE_DIRS)
set(multiValueArgs SHADERS INCLUDE_DIRS DEFINES)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
set(PROFILES 120 300_es spirv)
set(PROFILES spirv)
if(ARGS_TYPE STREQUAL "COMPUTE")
list(APPEND PROFILES 430 300_es)
else()
list(APPEND PROFILES 120 100_es)
endif()
if(BGFX_CONFIG_RENDERER_WEBGPU)
list(APPEND PROFILES wgsl)
endif()
if(IOS)
set(PLATFORM IOS)
list(APPEND PROFILES metal)
@@ -595,8 +602,8 @@ if(TARGET bgfx::shaderc)
OR CYGWIN
)
set(PLATFORM WINDOWS)
list(APPEND PROFILES s_4_0)
list(APPEND PROFILES s_5_0)
list(APPEND PROFILES s_6_0)
elseif(ORBIS) # ORBIS should be defined by a PS4 CMake toolchain
set(PLATFORM ORBIS)
list(APPEND PROFILES pssl)
@@ -625,9 +632,6 @@ if(TARGET bgfx::shaderc)
endif()
set(OUTPUT ${ARGS_OUTPUT_DIR}/${PROFILE_PATH_EXT}/${SHADER_FILE_BASENAME}.bin${HEADER_PREFIX})
set(PLATFORM_I ${PLATFORM})
if(PROFILE STREQUAL "spirv")
set(PLATFORM_I LINUX)
endif()
set(BIN2C_PART "")
if(ARGS_AS_HEADERS)
set(BIN2C_PART BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT})
@@ -635,13 +639,14 @@ if(TARGET bgfx::shaderc)
_bgfx_shaderc_parse(
CLI #
${BIN2C_PART} #
${ARGS_TYPE} ${PLATFORM_I} WERROR "$<$<CONFIG:debug>:DEBUG>$<$<CONFIG:relwithdebinfo>:DEBUG>"
${ARGS_TYPE} ${PLATFORM_I} "$<$<CONFIG:Debug,RelWithDebInfo>:DEBUG>"
FILE ${SHADER_FILE_ABSOLUTE}
OUTPUT ${OUTPUT}
PROFILE ${PROFILE}
O "$<$<CONFIG:debug>:0>$<$<CONFIG:release>:3>$<$<CONFIG:relwithdebinfo>:3>$<$<CONFIG:minsizerel>:3>"
O "$<IF:$<CONFIG:Debug>,0,3>"
VARYINGDEF ${ARGS_VARYING_DEF}
INCLUDES ${BGFX_SHADER_INCLUDE_PATH} ${ARGS_INCLUDE_DIRS}
DEFINES ${ARGS_DEFINES}
)
list(APPEND OUTPUTS ${OUTPUT})
list(APPEND ALL_OUTPUTS ${OUTPUT})

View File

@@ -19,5 +19,5 @@ if(NOT MINIZ_LIBRARIES)
MINIZ_SOURCES #
${BIMG_DIR}/3rdparty/tinyexr/deps/miniz/miniz.* #
)
set(MINIZ_INCLUDE_DIR ${BIMG_DIR}/3rdparty/tinyexr/deps/miniz)
set(MINIZ_INCLUDE_DIR ${BIMG_DIR}/3rdparty/tinyexr/deps)
endif()