mirror of
https://github.com/bkaradzic/bgfx.cmake.git
synced 2026-02-17 21:12:35 +01:00
Compare commits
26 Commits
v1.128.878
...
v1.136.911
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ae9b3209b | ||
|
|
cbd0e09dd9 | ||
|
|
f104e89b0e | ||
|
|
54fc2e6d5a | ||
|
|
8301c805b5 | ||
|
|
b5e37cd0db | ||
|
|
052d997930 | ||
|
|
a952acef35 | ||
|
|
dddc79f2ee | ||
|
|
fbf0903e50 | ||
|
|
5f3f4f2972 | ||
|
|
bd755d6c91 | ||
|
|
e8a92ffbbe | ||
|
|
657dd62551 | ||
|
|
36a0d1d8d0 | ||
|
|
cf79284dad | ||
|
|
06144dcb9b | ||
|
|
3b5115516c | ||
|
|
ef0ed485c5 | ||
|
|
2c33050257 | ||
|
|
b12eb2882a | ||
|
|
1139067c7d | ||
|
|
b135fa3d77 | ||
|
|
9af6a48ce0 | ||
|
|
f531516396 | ||
|
|
94184872a8 |
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -1 +1,2 @@
|
||||
* @bwrsandman
|
||||
* @jsm174
|
||||
|
||||
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
@@ -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.
|
||||
|
||||
10
.github/workflows/format.yml
vendored
10
.github/workflows/format.yml
vendored
@@ -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
|
||||
|
||||
32
.github/workflows/release.yml
vendored
32
.github/workflows/release.yml
vendored
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -43,7 +43,7 @@ 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)
|
||||
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)
|
||||
|
||||
18
README.md
18
README.md
@@ -94,12 +94,12 @@ bgfx_compile_shaders(
|
||||
SHADERS filenames
|
||||
VARYING_DEF filename
|
||||
OUTPUT_DIR directory
|
||||
[AS_HEADER]
|
||||
[AS_HEADERS]
|
||||
)
|
||||
```
|
||||
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.
|
||||
|
||||
@@ -110,14 +110,14 @@ bgfx_compile_shaders(
|
||||
SHADERS vs.sc
|
||||
VARYING_DEF varying.def.sc
|
||||
OUTPUT_DIR ${CMAKE_BINARY_DIR}/include/generated/shaders
|
||||
AS_HEADER
|
||||
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_HEADER
|
||||
AS_HEADERS
|
||||
)
|
||||
|
||||
add_library(myLib main.cpp vs.sc fs.sc)
|
||||
@@ -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
2
bgfx
Submodule bgfx updated: 409fbc5d14...9ca7782405
2
bimg
2
bimg
Submodule bimg updated: aaf9125234...a0204c79f9
2
bx
2
bx
Submodule bx updated: 3d53a4abaa...d8d7d13c85
11
cmake/bgfx/3rdparty/glslang.cmake
vendored
11
cmake/bgfx/3rdparty/glslang.cmake
vendored
@@ -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
|
||||
)
|
||||
|
||||
10
cmake/bgfx/3rdparty/spirv-opt.cmake
vendored
10
cmake/bgfx/3rdparty/spirv-opt.cmake
vendored
@@ -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
98
cmake/bgfx/3rdparty/tint.cmake
vendored
Normal 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()
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -87,6 +89,7 @@ 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 "")
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,15 +539,23 @@ 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()
|
||||
|
||||
@@ -568,7 +576,12 @@ if(TARGET bgfx::shaderc)
|
||||
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
||||
|
||||
set(PROFILES 120 300_es spirv)
|
||||
if(UNIX AND NOT APPLE)
|
||||
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)
|
||||
@@ -584,6 +597,9 @@ 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
|
||||
@@ -602,8 +618,12 @@ if(TARGET bgfx::shaderc)
|
||||
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}/${PROFILE_EXT}/${SHADER_FILE_BASENAME}.bin$<$<BOOL:ARGS_AS_HEADERS>:.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)
|
||||
@@ -632,7 +652,7 @@ if(TARGET bgfx::shaderc)
|
||||
${CMAKE_COMMAND}
|
||||
-E
|
||||
make_directory
|
||||
${ARGS_OUTPUT_DIR}/${PROFILE_EXT}
|
||||
${ARGS_OUTPUT_DIR}/${PROFILE_PATH_EXT}
|
||||
)
|
||||
list(APPEND COMMANDS COMMAND bgfx::shaderc ${CLI})
|
||||
endforeach()
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user