Compare commits

...

42 Commits

Author SHA1 Message Date
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
Jason Millard
052d997930 deps: bump bgfx, bimg, and bx. Update to use C++ 20. (#1) 2025-11-15 16:44:21 +00:00
Matt Tytel
a952acef35 Make sure mm files aren't globbed on non-apple computers 2025-10-29 21:44:41 -04:00
Jason Millard
dddc79f2ee Add missing validate_graph.cpp to fix dependabot builds 2025-10-22 17:49:15 -04:00
dependabot[bot]
fbf0903e50 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 `7a70927` to `b0e9cbd`
- [Commits](7a70927d2a...b0e9cbd110)

Updates `bx` from `eda3839` to `59d9249`
- [Commits](eda38395dd...59d9249854)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-version: b0e9cbd11041a602067ef00b22a281a922f8e1b2
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-version: 59d9249854f1f588dc9e7a79549fe954bcd8a5e7
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-22 17:49:15 -04:00
dependabot[bot]
5f3f4f2972 build(deps): bump the submodules group with 3 updates
Bumps the submodules group with 3 updates: [bgfx](https://github.com/bkaradzic/bgfx), [bx](https://github.com/bkaradzic/bx) and [bimg](https://github.com/bkaradzic/bimg).


Updates `bgfx` from `23baae9` to `7a70927`
- [Commits](23baae9e00...7a70927d2a)

Updates `bx` from `d858859` to `eda3839`
- [Commits](d858859d17...eda38395dd)

Updates `bimg` from `3af74f3` to `a1a2ae3`
- [Commits](3af74f3fe1...a1a2ae3c12)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-version: 7a70927d2af7ffcc5cef9c9e8f4c821e31fcb099
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-version: eda38395ddfdeba08c46653b93b8d5bb21f2c863
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bimg
  dependency-version: a1a2ae3c129d8c33e765eecd91801bffd985c317
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-10 14:45:34 -04:00
dependabot[bot]
bd755d6c91 build(deps): bump the submodules group with 2 updates
Bumps the submodules group with 2 updates: [bgfx](https://github.com/bkaradzic/bgfx) and [bimg](https://github.com/bkaradzic/bimg).


Updates `bgfx` from `14e0aa5` to `23baae9`
- [Commits](14e0aa5aff...23baae9e00)

Updates `bimg` from `446b9eb` to `3af74f3`
- [Commits](446b9eb111...3af74f3fe1)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-version: 23baae9e0010ee03edd8904fc7e176c76f4f8e2c
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bimg
  dependency-version: 3af74f3fe1a36c1ce17d2443c352eb8dbb3a5bd4
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-03 19:21:05 -04:00
dependabot[bot]
e8a92ffbbe 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 `4109e14` to `14e0aa5`
- [Commits](4109e14b43...14e0aa5aff)

Updates `bx` from `5a20afe` to `d858859`
- [Commits](5a20afef84...d858859d17)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-version: 14e0aa5aff65a12df621fbc9466b42d41d01f013
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-version: d858859d1724fc037129318330f9c5ee5e008a08
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-03 07:10:16 -04:00
alemuntoni
657dd62551 bump submodules and add new sources to spirv-opt.cmake 2025-05-29 14:57:33 -04:00
Jason Millard
36a0d1d8d0 actions: bump actions. fixes upload-artifact@v3 failures 2025-02-27 17:03:45 -05:00
dependabot[bot]
cf79284dad build(deps): bump the submodules group across 1 directory with 3 updates
Bumps the submodules group with 3 updates in the / directory: [bgfx](https://github.com/bkaradzic/bgfx), [bx](https://github.com/bkaradzic/bx) and [bimg](https://github.com/bkaradzic/bimg).


Updates `bgfx` from `7b3e1eb` to `de56398`
- [Commits](7b3e1ebf62...de56398919)

Updates `bx` from `c723ec4` to `01c99dd`
- [Commits](c723ec4054...01c99ddd09)

Updates `bimg` from `b713092` to `c5c7b6e`
- [Commits](b7130927db...c5c7b6e187)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bimg
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-26 19:54:40 -05:00
Jason Millard
06144dcb9b add validate_tensor_layout.cpp to spirv-opt cmake 2025-01-02 11:16:00 -05:00
dependabot[bot]
3b5115516c build(deps): bump the submodules group across 1 directory with 3 updates
Bumps the submodules group with 3 updates in the / directory: [bgfx](https://github.com/bkaradzic/bgfx), [bx](https://github.com/bkaradzic/bx) and [bimg](https://github.com/bkaradzic/bimg).


Updates `bgfx` from `cc789e8` to `7b3e1eb`
- [Commits](cc789e83a6...7b3e1ebf62)

Updates `bx` from `2cebc55` to `c723ec4`
- [Commits](2cebc558eb...c723ec4054)

Updates `bimg` from `0d1c78e` to `b713092`
- [Commits](0d1c78e779...b7130927db)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bimg
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-02 11:16:00 -05:00
Aaron Ishibashi
ef0ed485c5 Fix broken shader platform checks, add checks for iOS, Android, Orbis (#254)
* Fix broken shader platform checks, add checks for iOS, Android, Orbis, remove NaCl

* Fix formatting issue

Co-authored-by: Sandy <1013356+bwrsandman@users.noreply.github.com>

* Update cmake/bgfxToolUtils.cmake formatting

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: Sandy <1013356+bwrsandman@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-17 11:59:45 -05:00
Sandy
2c33050257 ci: Update deprecated upload-artifact 2024-11-13 19:57:16 -05:00
Vincent Lee
b12eb2882a Fix bgfx_compile_shaders section of README.md 2024-11-07 08:10:32 -05:00
Andrew Feng
1139067c7d Improve shader profile extension to be more compatible with bgfx (#247)
* remove profile extension incompatible with those listed under examples/runtime/shaders; fix incorrect parameter names; enforce consistent syntax when appending to CLI.

* remove dx9

* add separate profile extension for paths vs profile extension
2024-11-05 12:41:12 -05:00
Matt Tytel
b135fa3d77 Fixing wayland cmake definitions and linkage. 2024-11-05 10:24:53 -05:00
dependabot[bot]
9af6a48ce0 build(deps): bump the submodules group with 3 updates (#252) 2024-11-05 14:56:44 +00:00
dependabot[bot]
f531516396 build(deps): bump the submodules group across 1 directory with 2 updates
Bumps the submodules group with 2 updates in the / directory: [bgfx](https://github.com/bkaradzic/bgfx) and [bx](https://github.com/bkaradzic/bx).


Updates `bgfx` from `409fbc5` to `7e5bb54`
- [Commits](409fbc5d14...7e5bb54a3e)

Updates `bx` from `3d53a4a` to `296dfb2`
- [Commits](3d53a4abaa...296dfb202b)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-02 14:21:33 -04:00
Boyu
94184872a8 Fix incorrect adding .h in bgfx_compile_shaders (#245) 2024-09-10 19:10:48 -04:00
dependabot[bot]
4ceffda6de build(deps): bump the submodules group across 1 directory with 3 updates
Bumps the submodules group with 3 updates in the / directory: [bgfx](https://github.com/bkaradzic/bgfx), [bx](https://github.com/bkaradzic/bx) and [bimg](https://github.com/bkaradzic/bimg).


Updates `bgfx` from `af12904` to `409fbc5`
- [Commits](af12904d8c...409fbc5d14)

Updates `bx` from `e7ede51` to `3d53a4a`
- [Commits](e7ede513dc...3d53a4abaa)

Updates `bimg` from `2afa64c` to `aaf9125`
- [Commits](2afa64c14c...aaf9125234)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bimg
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-03 10:36:09 -04:00
Sandy
8defeece11 Update compile shaders example 2024-07-20 19:46:27 -04:00
Sandy Carter
5b8c8b9057 Cleanup pssl comment 2024-07-20 19:34:50 -04:00
Sandy Carter
de5f4544ef Change the output path of generated shaders
The paths now for output shaders is the same of the shader file inside of
a directory for the profile.
2024-07-20 19:34:50 -04:00
Sandy Carter
85b9f3cf5f Make bgfx_compile_shaders more generic
Allow compiling as header or as binaries
2024-07-20 19:34:50 -04:00
Sandy
79e4993ca5 Update cmake/bgfx/bgfx.cmake
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-09 09:41:37 -04:00
Sandy Carter
0211a63b99 Add option to use wayland on linux, enabled by default 2024-07-09 09:41:37 -04:00
dependabot[bot]
1156dcc725 build(deps): bump the submodules group with 3 updates
Bumps the submodules group with 3 updates: [bgfx](https://github.com/bkaradzic/bgfx), [bx](https://github.com/bkaradzic/bx) and [bimg](https://github.com/bkaradzic/bimg).


Updates `bgfx` from `d1feabe` to `af12904`
- [Commits](d1feabe319...af12904d8c)

Updates `bx` from `24527ea` to `e7ede51`
- [Commits](24527eabfd...e7ede513dc)

Updates `bimg` from `59f188a` to `2afa64c`
- [Commits](59f188a6ad...2afa64c14c)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bimg
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-09 09:24:15 -04:00
exdal
c2b7416a58 Merge pull request #233 from bwrsandman/preprocessor
bx: Add /Zc:preprocessor
2024-06-16 13:51:25 +03:00
Sandy Carter
c0ce1388cc bx: Add /Zc:preprocessor 2024-06-15 19:34:35 -04:00
dependabot[bot]
19cb98d40b build(deps): bump the submodules group with 3 updates
Bumps the submodules group with 3 updates: [bgfx](https://github.com/bkaradzic/bgfx), [bx](https://github.com/bkaradzic/bx) and [bimg](https://github.com/bkaradzic/bimg).


Updates `bgfx` from `57d8a08` to `00fa5ad`
- [Commits](57d8a0838b...00fa5ad179)

Updates `bx` from `34ba9c7` to `d171a0f`
- [Commits](34ba9c7a5c...d171a0f264)

Updates `bimg` from `e9fa0ce` to `98a40e8`
- [Commits](e9fa0ceff2...98a40e8533)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bimg
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-01 14:36:24 -04:00
Sandy Carter
701d84c222 tools: Add an option to insert search paths for tools 2024-05-19 16:13:58 -04:00
Sandy Carter
5940bb7cf8 tools: Rely on CMAKE_PROGRAM_PATH for finding tools 2024-05-19 11:38:19 -04:00
Sandy Carter
2fcbf437f2 tools: for vcpkg hint, use host install path 2024-05-19 07:31:02 -04:00
Jimmy Lord
d7f59648a8 ew option to allow "example-common" project to not be included in build. (#225)
* Added a new option to allow "example-common" project to not be included in build.

* Set BGFX_BUILD_EXAMPLE_COMMON as a dependent option, it will be set ON if either tools or examples are included in the build, OFF otherwise.

* cmake format

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: Sandy <bwrsandman@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-05-18 20:42:20 -04:00
19 changed files with 301 additions and 126 deletions

1
.github/CODEOWNERS vendored
View File

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

View File

@@ -15,15 +15,15 @@ jobs:
name: Check compatibility with minimum cmake version
runs-on: ubuntu-latest
env:
CMAKE_VERSION: 3.10.2
CMAKE_VERSION: 3.20.0
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libgl1-mesa-dev
sudo apt install -y libgl1-mesa-dev libwayland-dev libwayland-egl-backend-dev
- uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ env.CMAKE_VERSION }}
@@ -57,13 +57,13 @@ jobs:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libgl1-mesa-dev
sudo apt install -y libgl1-mesa-dev libwayland-dev libwayland-egl-backend-dev
if: matrix.os == 'ubuntu-latest'
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
@@ -94,13 +94,13 @@ jobs:
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libgl1-mesa-dev
sudo apt install -y libgl1-mesa-dev libwayland-dev libwayland-egl-backend-dev
if: matrix.os == 'ubuntu-latest'
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.

View File

@@ -12,7 +12,7 @@ jobs:
name: cmake-format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
@@ -21,7 +21,7 @@ jobs:
if: startsWith(github.event_name, 'pull_request')
- name: Format CMake files
id: cmake-format
uses: PuneetMatharu/cmake-format-lint-action@main
uses: PuneetMatharu/cmake-format-lint-action@v1.0.6
with:
args: --config-files .cmake-format.py --check
# Run only if a PR and cmake-format has failed
@@ -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@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
@@ -40,12 +40,12 @@ jobs:
if: startsWith(github.event_name, 'pull_request')
- name: Format CMake files
id: cmake-format
uses: PuneetMatharu/cmake-format-lint-action@v1.0.0
uses: PuneetMatharu/cmake-format-lint-action@v1.0.6
with:
args: --config-files .cmake-format.py --in-place
- run: |
git diff > cmake-format.patch
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
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@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
@@ -51,13 +51,13 @@ jobs:
CMAKE_INSTALL_DIR: ${{ github.workspace }}/install/
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libgl1-mesa-dev
sudo apt install -y libgl1-mesa-dev libwayland-dev libwayland-egl-backend-dev
if: matrix.os == 'ubuntu-latest'
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
- uses: lukka/get-cmake@latest
@@ -80,7 +80,7 @@ jobs:
- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target install --config Release
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: ${{ github.workspace }}/install/
@@ -93,7 +93,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
@@ -102,69 +102,69 @@ 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@v3
- uses: actions/download-artifact@v4
with:
name: windows-latest
path: ${{ github.workspace }}/install/windows/bgfx.cmake
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: ubuntu-latest
path: ${{ github.workspace }}/install/linux/bgfx.cmake
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: macos-latest
path: ${{ github.workspace }}/install/macos/bgfx.cmake
- name: Create Source Zip
uses: thedoctor0/zip-release@0.7.1
uses: thedoctor0/zip-release@0.7.6
with:
type: 'zip'
filename: 'bgfx.cmake.${{ needs.version.outputs.tag }}.zip'
directory: 'src'
path: 'bgfx.cmake'
- name: Create Source Tar
uses: thedoctor0/zip-release@0.7.1
uses: thedoctor0/zip-release@0.7.6
with:
type: 'tar'
filename: 'bgfx.cmake.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'src'
path: 'bgfx.cmake'
- name: Create Windows Zip
uses: thedoctor0/zip-release@0.7.1
uses: thedoctor0/zip-release@0.7.6
with:
type: 'zip'
filename: 'bgfx.cmake.binary.windows.${{ needs.version.outputs.tag }}.zip'
directory: 'install/windows'
path: 'bgfx.cmake'
- name: Create Windows Tar
uses: thedoctor0/zip-release@0.7.1
uses: thedoctor0/zip-release@0.7.6
with:
type: 'tar'
filename: 'bgfx.cmake.binary.windows.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'install/windows'
path: 'bgfx.cmake'
- name: Create Linux Zip
uses: thedoctor0/zip-release@0.7.1
uses: thedoctor0/zip-release@0.7.6
with:
type: 'zip'
filename: 'bgfx.cmake.binary.linux.${{ needs.version.outputs.tag }}.zip'
directory: 'install/linux'
path: 'bgfx.cmake'
- name: Create Linux Tar
uses: thedoctor0/zip-release@0.7.1
uses: thedoctor0/zip-release@0.7.6
with:
type: 'tar'
filename: 'bgfx.cmake.binary.linux.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'install/linux'
path: 'bgfx.cmake'
- name: Create MacOS Zip
uses: thedoctor0/zip-release@0.7.1
uses: thedoctor0/zip-release@0.7.6
with:
type: 'zip'
filename: 'bgfx.cmake.binary.macos.${{ needs.version.outputs.tag }}.zip'
directory: 'install/macos'
path: 'bgfx.cmake'
- name: Create MacOS Tar
uses: thedoctor0/zip-release@0.7.1
uses: thedoctor0/zip-release@0.7.6
with:
type: 'tar'
filename: 'bgfx.cmake.binary.macos.${{ needs.version.outputs.tag }}.tar.gz'

View File

@@ -8,12 +8,12 @@
# 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/>.
cmake_minimum_required(VERSION 3.10.2) # version supported by android studio
cmake_minimum_required(VERSION 3.20) # C++20 support required
project(bgfx)
cmake_policy(SET CMP0054 NEW)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
@@ -22,10 +22,6 @@ if(APPLE AND NOT XCODE)
set(CMAKE_CXX_FLAGS "-ObjC++")
endif()
if(MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
add_compile_options("/Zc:__cplusplus")
endif()
include(CMakeDependentOption)
option(BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF)
@@ -38,11 +34,16 @@ cmake_dependent_option(BGFX_BUILD_TOOLS_GEOMETRY "Build bgfx geometry tools." ON
cmake_dependent_option(BGFX_BUILD_TOOLS_TEXTURE "Build bgfx texture tools." ON BGFX_BUILD_TOOLS OFF)
set(BGFX_TOOLS_PREFIX "" CACHE STRING "Prefix name to add to name of tools (to avoid clashes)")
option(BGFX_BUILD_EXAMPLES "Build bgfx examples." ON)
cmake_dependent_option(
BGFX_BUILD_EXAMPLE_COMMON "Build bgfx example-common project." OFF "NOT BGFX_BUILD_EXAMPLES;NOT BGFX_BUILD_TOOLS"
ON
)
option(BGFX_BUILD_TESTS "Build bgfx tests." OFF)
option(BGFX_INSTALL "Create installation target." ON)
cmake_dependent_option(
BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF "BGFX_INSTALL;BGFX_BUILD_EXAMPLES" OFF
)
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)
option(BGFX_CONFIG_RENDERER_WEBGPU "Enable the webgpu renderer" OFF)

View File

@@ -86,35 +86,38 @@ bgfx_compile_texture(
)
```
### `bgfx_compile_shader_to_header`
### `bgfx_compile_shaders`
Add a build rule for a `*.sc` shader to the generated build system using shaderc.
```cmake
bgfx_compile_shader_to_header(
bgfx_compile_shaders(
TYPE VERTEX|FRAGMENT|COMPUTE
SHADERS filenames
VARYING_DEF filename
OUTPUT_DIR directory
[AS_HEADERS]
)
```
This defines a shaderc command to generate 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`.
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 `${SHADERS}.${RENDERING_API}.bin.h` where `RENDERING_API` can be `glsl`, `essl`, `spv`, `dx9`, `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.
#### Examples: Generating shaders as headers
```cmake
bgfx_compile_shader_to_header(
bgfx_compile_shaders(
TYPE VERTEX
SHADERS vs.sc
VARYING_DEF varying.def.sc
OUTPUT_DIR ${CMAKE_BINARY_DIR}/include/generated/shaders
AS_HEADERS
)
bgfx_compile_shader_to_header(
bgfx_compile_shaders(
TYPE FRAGMENT
SHADERS fs.sc
VARYING_DEF ${CMAKE_SOURCE_DIR}/varying.def.sc
OUTPUT_DIR ${CMAKE_BINARY_DIR}/include/generated/shaders
AS_HEADERS
)
add_library(myLib main.cpp vs.sc fs.sc)
@@ -123,21 +126,19 @@ target_include_directories(myLib ${CMAKE_BINARY_DIR}/include/generated/shaders)
```cpp
// main.cpp
#include <vs.sc.glsl.bin.h>
#include <vs.sc.essl.bin.h>
#include <vs.sc.spv.bin.h>
#include <fs.sc.glsl.bin.h>
#include <fs.sc.essl.bin.h>
#include <fs.sc.spv.bin.h>
#include <glsl/vs.sc.bin.h>
#include <essl/vs.sc.bin.h>
#include <spirv/vs.sc.bin.h>
#include <glsl/fs.sc.bin.h>
#include <essl/fs.sc.bin.h>
#include <spirv/fs.sc.bin.h>
#if defined(_WIN32)
#include <vs.sc.dx9.bin.h>
#include <vs.sc.dx11.bin.h>
#include <fs.sc.dx9.bin.h>
#include <fs.sc.dx11.bin.h>
#include <dx11/vs.sc.bin.h>
#include <dx11/fs.sc.bin.h>
#endif // defined(_WIN32)
#if __APPLE__
#include <vs.sc.mtl.bin.h>
#include <fs.sc.mtl.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: 57d8a0838b...9ca7782405

2
bimg

Submodule bimg updated: e9fa0ceff2...a0204c79f9

2
bx

Submodule bx updated: 34ba9c7a5c...d8d7d13c85

View File

@@ -14,10 +14,7 @@ macro(_bgfx_crosscompile_use_host_tool TOOL_NAME)
find_program(
${TOOL_NAME}_EXECUTABLE
NAMES bgfx-${TOOL_NAME} ${TOOL_NAME}
PATHS /usr/bin #
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-linux/tools/bgfx
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-windows/tools/bgfx
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-osx/tools/bgfx
PATHS @BGFX_ADDITIONAL_TOOL_PATHS@ /usr/bin
)
add_executable(bgfx::${TOOL_NAME} IMPORTED)
set_target_properties(bgfx::${TOOL_NAME} PROPERTIES IMPORTED_LOCATION "${${TOOL_NAME}_EXECUTABLE}")

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

@@ -70,16 +70,21 @@ file(
${SPIRV_TOOLS}/source/spirv_validator_options.h
${SPIRV_TOOLS}/source/table.cpp
${SPIRV_TOOLS}/source/table.h
${SPIRV_TOOLS}/source/table2.cpp
${SPIRV_TOOLS}/source/table2.h
${SPIRV_TOOLS}/source/text.cpp
${SPIRV_TOOLS}/source/text.h
${SPIRV_TOOLS}/source/text_handler.cpp
${SPIRV_TOOLS}/source/text_handler.h
${SPIRV_TOOLS}/source/to_string.cpp
${SPIRV_TOOLS}/source/to_string.h
${SPIRV_TOOLS}/source/util/bit_vector.cpp
${SPIRV_TOOLS}/source/util/bit_vector.h
${SPIRV_TOOLS}/source/util/bitutils.h
${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
@@ -108,12 +113,15 @@ file(
${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_id.cpp
${SPIRV_TOOLS}/source/val/validate_image.cpp
${SPIRV_TOOLS}/source/val/validate_instruction.cpp
${SPIRV_TOOLS}/source/val/validate_interfaces.cpp
${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
@@ -127,6 +135,8 @@ file(
${SPIRV_TOOLS}/source/val/validate_ray_tracing_reorder.cpp
${SPIRV_TOOLS}/source/val/validate_scopes.cpp
${SPIRV_TOOLS}/source/val/validate_small_type_uses.cpp
${SPIRV_TOOLS}/source/val/validate_tensor.cpp
${SPIRV_TOOLS}/source/val/validate_tensor_layout.cpp
${SPIRV_TOOLS}/source/val/validate_type.cpp
${SPIRV_TOOLS}/source/val/validation_state.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

@@ -19,22 +19,25 @@ if(NOT IS_DIRECTORY ${BGFX_DIR})
return()
endif()
if(NOT APPLE)
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.cpp)
else()
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.mm)
endif()
# Grab the bgfx source files
file(
GLOB
BGFX_SOURCES
${BGFX_DIR}/src/*.cpp
${BGFX_DIR}/src/*.mm
${BGFX_DIR}/src/*.h
${BGFX_DIR}/include/bgfx/*.h
${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()
if(BGFX_AMALGAMATED)
set(BGFX_NOBUILD ${BGFX_SOURCES})
list(REMOVE_ITEM BGFX_NOBUILD ${BGFX_AMALGAMATED_SOURCE})
@@ -43,8 +46,7 @@ if(BGFX_AMALGAMATED)
endforeach()
else()
# Do not build using amalgamated sources
set_source_files_properties(${BGFX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON)
set_source_files_properties(${BGFX_DIR}/src/amalgamated.mm PROPERTIES HEADER_FILE_ONLY ON)
set_source_files_properties(${BGFX_AMALGAMATED_SOURCE} PROPERTIES HEADER_FILE_ONLY ON)
endif()
# Create the bgfx target
@@ -85,6 +87,11 @@ if(NOT ${BGFX_CONFIG_DEFAULT_MAX_ENCODERS} STREQUAL "")
)
endif()
if(BGFX_WITH_WAYLAND)
target_compile_definitions(bgfx PRIVATE "WL_EGL_PLATFORM=1")
target_link_libraries(bgfx PRIVATE wayland-egl)
endif()
set(BGFX_CONFIG_OPTIONS "")
list(
APPEND

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}})
@@ -136,14 +142,19 @@ function(add_example ARG_NAME)
target_link_libraries(
example-${ARG_NAME} PUBLIC bgfx bx bimg bimg_decode ${DEAR_IMGUI_LIBRARIES} ${MESHOPTIMIZER_LIBRARIES}
)
if(BGFX_WITH_WAYLAND)
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_WAYLAND=1)
endif()
if(BGFX_WITH_GLFW)
find_package(glfw3 REQUIRED)
target_link_libraries(example-${ARG_NAME} PUBLIC glfw)
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_GLFW)
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_GLFW=1)
elseif(BGFX_WITH_SDL)
find_package(SDL2 REQUIRED)
target_link_libraries(example-${ARG_NAME} PUBLIC ${SDL2_LIBRARIES})
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL)
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL=1)
elseif(UNIX AND NOT APPLE AND NOT ANDROID)
target_link_libraries(example-${ARG_NAME} PUBLIC X11)
endif()
@@ -158,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
)
@@ -263,17 +280,19 @@ if(BGFX_CUSTOM_TARGETS)
endif()
# Add common library for examples
add_example(
common
COMMON
DIRECTORIES
${BGFX_DIR}/examples/common/debugdraw
${BGFX_DIR}/examples/common/entry
${BGFX_DIR}/examples/common/font
${BGFX_DIR}/examples/common/imgui
${BGFX_DIR}/examples/common/nanovg
${BGFX_DIR}/examples/common/ps
)
if(BGFX_BUILD_EXAMPLE_COMMON)
add_example(
common
COMMON
DIRECTORIES
${BGFX_DIR}/examples/common/debugdraw
${BGFX_DIR}/examples/common/entry
${BGFX_DIR}/examples/common/font
${BGFX_DIR}/examples/common/imgui
${BGFX_DIR}/examples/common/nanovg
${BGFX_DIR}/examples/common/ps
)
endif()
# Only add examples if set, otherwise we still need exmaples common for tools
if(BGFX_BUILD_EXAMPLES)

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,6 +30,13 @@ target_link_libraries(
spirv-opt
spirv-cross
webgpu
tint
)
target_include_directories(
shaderc
PRIVATE ${BGFX_DIR}/3rdparty/dawn
${BGFX_DIR}/3rdparty/dawn/src
)
if(BGFX_AMALGAMATED)
target_link_libraries(shaderc PRIVATE bgfx-shader)

View File

@@ -215,7 +215,7 @@ if(TARGET bgfx::texturec)
add_custom_command(
OUTPUT ${ARG_OUTPUT} #
COMMAND bgfx::texturec ${CLI} #
MAIN_DEPENDENCY ${ARG_INPUT} #
MAIN_DEPENDENCY ${ARG_FILE} #
)
endfunction()
endif()
@@ -279,12 +279,12 @@ if(TARGET bgfx::geometryc)
# --packnormal
if(ARG_PACKNORMAL)
list(APPEND CLI "--packnormal ${ARG_PACKNORMAL}")
list(APPEND CLI "--packnormal" "${ARG_PACKNORMAL}")
endif()
# --packuv
if(ARG_PACKUV)
list(APPEND CLI "--packuv" ${ARG_PACKUV})
list(APPEND CLI "--packuv" "${ARG_PACKUV}")
endif()
# --tangent
@@ -352,7 +352,7 @@ if(TARGET bgfx::geometryc)
add_custom_command(
OUTPUT ${ARG_OUTPUT} #
COMMAND bgfx::geometryc ${CLI} #
MAIN_DEPENDENCY ${ARG_INPUT} #
MAIN_DEPENDENCY ${ARG_FILE} #
)
endfunction()
endif()
@@ -364,7 +364,7 @@ if(TARGET bgfx::shaderc)
# FILE filename
# OUTPUT filename
# FRAGMENT|VERTEX|COMPUTE
# ANDROID|ASM_JS|IOS|LINUX|NACL|OSX|WINDOWS
# ANDROID|ASM_JS|IOS|LINUX|OSX|WINDOWS|ORBIS
# PROFILE profile
# [O 0|1|2|3]
# [VARYINGDEF filename]
@@ -382,7 +382,7 @@ if(TARGET bgfx::shaderc)
function(_bgfx_shaderc_parse ARG_OUT)
cmake_parse_arguments(
ARG
"DEPENDS;ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS;PREPROCESS;RAW;FRAGMENT;VERTEX;COMPUTE;VERBOSE;DEBUG;DISASM;WERROR"
"DEPENDS;ANDROID;ASM_JS;IOS;LINUX;OSX;WINDOWS;ORBIS;PREPROCESS;RAW;FRAGMENT;VERTEX;COMPUTE;VERBOSE;DEBUG;DISASM;WERROR"
"FILE;OUTPUT;VARYINGDEF;BIN2C;PROFILE;O"
"INCLUDES;DEFINES"
${ARGN}
@@ -423,7 +423,7 @@ if(TARGET bgfx::shaderc)
# --platform
set(PLATFORM "")
set(PLATFORMS "ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS")
set(PLATFORMS "ANDROID;ASM_JS;IOS;LINUX;OSX;WINDOWS;ORBIS")
foreach(P ${PLATFORMS})
if(ARG_${P})
if(PLATFORM)
@@ -436,20 +436,20 @@ if(TARGET bgfx::shaderc)
if(PLATFORM STREQUAL "")
message(SEND_ERROR "Call to _bgfx_shaderc_parse() must have a platform flag: ${PLATFORMS}")
return()
elseif(PLATFORM STREQUAL ANDROID)
elseif(PLATFORM STREQUAL "ANDROID")
list(APPEND CLI "--platform" "android")
elseif(PLATFORM STREQUAL ASM_JS)
elseif(PLATFORM STREQUAL "ASM_JS")
list(APPEND CLI "--platform" "asm.js")
elseif(PLATFORM STREQUAL IOS)
elseif(PLATFORM STREQUAL "IOS")
list(APPEND CLI "--platform" "ios")
elseif(PLATFORM STREQUAL NACL)
list(APPEND CLI "--platform" "nacl")
elseif(PLATFORM STREQUAL OSX)
elseif(PLATFORM STREQUAL "OSX")
list(APPEND CLI "--platform" "osx")
elseif(PLATFORM STREQUAL UNIX)
elseif(PLATFORM STREQUAL "LINUX")
list(APPEND CLI "--platform" "linux")
elseif(PLATFORM STREQUAL WINDOWS)
elseif(PLATFORM STREQUAL "WINDOWS")
list(APPEND CLI "--platform" "windows")
elseif(PLATFORM STREQUAL "ORBIS")
list(APPEND CLI "--platform" "orbis")
endif()
# --preprocess
@@ -539,35 +539,49 @@ if(TARGET bgfx::shaderc)
set(${ARG_OUT} ${CLI} PARENT_SCOPE)
endfunction()
# extensions consistent with those listed under bgfx/runtime/shaders
function(_bgfx_get_profile_path_ext PROFILE PROFILE_PATH_EXT)
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})
set(${PROFILE_PATH_EXT} ${PROFILE} PARENT_SCOPE)
endfunction()
# extensions consistent with embedded_shader.h
function(_bgfx_get_profile_ext PROFILE PROFILE_EXT)
string(REPLACE 300_es essl PROFILE ${PROFILE})
string(REPLACE 120 glsl PROFILE ${PROFILE})
string(REPLACE spirv spv PROFILE ${PROFILE})
string(REPLACE metal mtl PROFILE ${PROFILE})
string(REPLACE s_3_0 dx9 PROFILE ${PROFILE})
string(REPLACE s_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE s_5_0 dx11 PROFILE ${PROFILE})
set(${PROFILE_EXT} ${PROFILE} PARENT_SCOPE)
endfunction()
# bgfx_compile_shader_to_header(
# bgfx_compile_shaders(
# TYPE VERTEX|FRAGMENT|COMPUTE
# SHADERS filenames
# VARYING_DEF filename
# OUTPUT_DIR directory
# OUT_FILES_VAR variable name
# INCLUDE_DIRS directories
# [AS_HEADERS]
# )
#
function(bgfx_compile_shader_to_header)
set(options "")
function(bgfx_compile_shaders)
set(options AS_HEADERS)
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR OUT_FILES_VAR)
set(multiValueArgs SHADERS INCLUDE_DIRS)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
set(PROFILES 120 300_es spirv) # pssl
if(UNIX AND NOT APPLE)
set(PROFILES 120 300_es spirv)
if(IOS)
set(PLATFORM IOS)
list(APPEND PROFILES metal)
elseif(ANDROID)
set(PLATFORM ANDROID)
elseif(UNIX AND NOT APPLE)
set(PLATFORM LINUX)
elseif(EMSCRIPTEN)
set(PLATFORM ASM_JS)
@@ -583,7 +597,12 @@ if(TARGET bgfx::shaderc)
set(PLATFORM WINDOWS)
list(APPEND PROFILES s_4_0)
list(APPEND PROFILES s_5_0)
elseif(ORBIS) # ORBIS should be defined by a PS4 CMake toolchain
set(PLATFORM ORBIS)
list(APPEND PROFILES pssl)
else()
# pssl for Agc and Gnm renderers
# nvn for Nvn renderer
message(error "shaderc: Unsupported platform")
endif()
@@ -597,15 +616,25 @@ if(TARGET bgfx::shaderc)
# Build output targets and their commands
set(OUTPUTS "")
set(COMMANDS "")
set(MKDIR_COMMANDS "")
foreach(PROFILE ${PROFILES})
_bgfx_get_profile_path_ext(${PROFILE} PROFILE_PATH_EXT)
_bgfx_get_profile_ext(${PROFILE} PROFILE_EXT)
set(OUTPUT ${ARGS_OUTPUT_DIR}/${SHADER_FILE_BASENAME}.${PROFILE_EXT}.bin.h)
if(ARGS_AS_HEADERS)
set(HEADER_PREFIX .h)
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})
endif()
_bgfx_shaderc_parse(
CLI #
${BIN2C_PART} #
${ARGS_TYPE} ${PLATFORM_I} WERROR "$<$<CONFIG:debug>:DEBUG>$<$<CONFIG:relwithdebinfo>:DEBUG>"
FILE ${SHADER_FILE_ABSOLUTE}
OUTPUT ${OUTPUT}
@@ -613,16 +642,24 @@ if(TARGET bgfx::shaderc)
O "$<$<CONFIG:debug>:0>$<$<CONFIG:release>:3>$<$<CONFIG:relwithdebinfo>:3>$<$<CONFIG:minsizerel>:3>"
VARYINGDEF ${ARGS_VARYING_DEF}
INCLUDES ${BGFX_SHADER_INCLUDE_PATH} ${ARGS_INCLUDE_DIRS}
BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}
)
list(APPEND OUTPUTS ${OUTPUT})
list(APPEND ALL_OUTPUTS ${OUTPUT})
list(
APPEND
MKDIR_COMMANDS
COMMAND
${CMAKE_COMMAND}
-E
make_directory
${ARGS_OUTPUT_DIR}/${PROFILE_PATH_EXT}
)
list(APPEND COMMANDS COMMAND bgfx::shaderc ${CLI})
endforeach()
add_custom_command(
OUTPUT ${OUTPUTS}
COMMAND ${CMAKE_COMMAND} -E make_directory ${ARGS_OUTPUT_DIR} ${COMMANDS}
COMMAND ${MKDIR_COMMANDS} ${COMMANDS}
MAIN_DEPENDENCY ${SHADER_FILE_ABSOLUTE}
DEPENDS ${ARGS_VARYING_DEF}
)

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")
@@ -92,7 +97,7 @@ target_compile_definitions(bx PUBLIC "__STDC_CONSTANT_MACROS")
target_compile_features(bx PUBLIC cxx_std_14)
# (note: see bx\scripts\toolchain.lua for equivalent compiler flag)
target_compile_options(bx PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>)
target_compile_options(bx PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus /Zc:preprocessor>)
# Link against psapi on Windows
if(WIN32)