Compare commits

...

64 Commits

Author SHA1 Message Date
dependabot[bot]
ac2c644f44 build(deps): bump bgfx from 66de825 to 5f435ea
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `66de825` to `5f435ea`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](66de825e6f...5f435ea56b)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-03 21:09:33 -05:00
dependabot[bot]
4ea31fd36f build(deps): bump bimg from 85109d7 to 1af9054
Bumps [bimg](https://github.com/bkaradzic/bimg) from `85109d7` to `1af9054`.
- [Release notes](https://github.com/bkaradzic/bimg/releases)
- [Commits](85109d7cdb...1af90543ca)

---
updated-dependencies:
- dependency-name: bimg
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-03 21:09:18 -05:00
Sandy Carter
4ea7d23eb2 3rdparty: prefix bgfx- to lib names to avoid conflicts 2023-01-03 21:09:01 -05:00
Sandy
03ae29e5bd Update README.md 2022-12-03 13:59:33 -05:00
Sandy Carter
cfc015871f Properly export when making shared library
Fixes using a dll in windows
2022-12-03 13:59:15 -05:00
Sandy Carter
54aaa9103d Add BGFX_CONFIG_DEBUG_ANNOTATION option
Disable for WindowsStore (UWP)
2022-12-03 13:59:05 -05:00
Sandy
2d7b0296f6 Use commit count for tag
In the case where the cmake package has been updated but bgfx submodules
haven't it is more informative to have the commit count than the sha.
2022-12-03 13:58:25 -05:00
dependabot[bot]
a59e0a63ae build(deps): bump bx from 20efa22 to aed1086
Bumps [bx](https://github.com/bkaradzic/bx) from `20efa22` to `aed1086`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](20efa22f18...aed1086c48)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-02 17:35:52 -05:00
dependabot[bot]
671c819e85 build(deps): bump bgfx from 6a03a1e to 66de825
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `6a03a1e` to `66de825`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](6a03a1ec5e...66de825e6f)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-02 17:35:46 -05:00
dependabot[bot]
c825dcf256 build(deps): bump bimg from 225dad7 to 85109d7
Bumps [bimg](https://github.com/bkaradzic/bimg) from `225dad7` to `85109d7`.
- [Release notes](https://github.com/bkaradzic/bimg/releases)
- [Commits](225dad7441...85109d7cdb)

---
updated-dependencies:
- dependency-name: bimg
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-02 17:35:38 -05:00
loanselot
916f26e1b6 Merge pull request #160 from Hyreos/patch-1
Prevent the script from trying to install tools that have been disabled
2022-11-28 16:18:22 +03:00
Hyreos
4e42ae2ae0 Prevent the script from trying to install tools that have been disabled
This commit fixes the issue of install failing if you disable any of the tools due to missing targets.
2022-11-20 17:23:21 -03:00
Johannes Schäufele
52feec47f5 bgfx: Add bgfx limits config options 2022-11-04 17:30:48 -04:00
loanselot
cf77d7c6d7 Merge pull request #159 from bkaradzic/dependabot/submodules/bgfx-6a03a1e
build(deps): bump bgfx from `f6a1289` to `6a03a1e`
2022-11-02 00:48:54 +03:00
loanselot
33dde1a115 Merge pull request #158 from bkaradzic/dependabot/submodules/bimg-225dad7
build(deps): bump bimg from `1955d8f` to `225dad7`
2022-11-02 00:48:44 +03:00
dependabot[bot]
3e7f1fe200 build(deps): bump bgfx from f6a1289 to 6a03a1e
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `f6a1289` to `6a03a1e`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](f6a1289dbc...6a03a1ec5e)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-01 16:03:17 +00:00
dependabot[bot]
866599edb0 build(deps): bump bimg from 1955d8f to 225dad7
Bumps [bimg](https://github.com/bkaradzic/bimg) from `1955d8f` to `225dad7`.
- [Release notes](https://github.com/bkaradzic/bimg/releases)
- [Commits](1955d8f99a...225dad7441)

---
updated-dependencies:
- dependency-name: bimg
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-01 16:03:13 +00:00
loanselot
089b388ac0 Merge pull request #156 from bkaradzic/temp
Update Submodules
2022-10-28 23:00:25 +03:00
e-erdal
9d3bc4f326 Update bgfx submodule 2022-10-28 22:21:19 +03:00
e-erdal
9ee85d3c1b Fix directx-headers 2022-10-28 21:48:50 +03:00
e-erdal
74a8e4dc72 ordering matters 2022-10-28 21:35:02 +03:00
e-erdal
99f17108ca Add linux compat for bx 2022-10-28 21:25:03 +03:00
e-erdal
862912e7e9 Fix WSL Include 2022-10-28 21:18:47 +03:00
e-erdal
72ea9b6f29 Add other DX Headers 2022-10-28 21:00:43 +03:00
e-erdal
6e23a39de6 Update submodules 2022-10-28 20:36:16 +03:00
loanselot
74e4a3fad9 Merge pull request #151 from SamHellawell/master
Allow to specify which tools to compile
2022-10-28 20:08:06 +03:00
Samuel Hellawell
5c54e5f299 Allow to specify which tools to compile
Signed-off-by: Samuel Hellawell <sshellawell@gmail.com>
2022-09-23 04:36:01 +01:00
Sandy Carter
06b995080d update submodules to dbafa14, 90ac47d, 8e94c8c 2022-08-26 10:29:01 -04:00
Sandy Carter
f5dc53db85 Find shaderc when cross-compiling 2022-08-24 11:56:03 -04:00
Sandy Carter
2051444e25 Install bgfxToolUtils even if not building tools
Fixes corner case of cross compiling with tools from host platform
2022-08-24 11:56:03 -04:00
Sandy Carter
5ba5a38762 add new 47-pixelformats example 2022-08-23 07:20:31 -04:00
Sandy Carter
e4e935c7ae ToolUtils: Add helper to compile shader to header 2022-08-22 08:57:50 -04:00
Sandy Carter
01c90714e1 export cmake function for shaderc_compiling
Remove unused add_shader and shaderc
Example usage:
```
shaderc_parse(
  CLI
  ${ARGS_TYPE} ${PLATFORM_I} WERROR
  "$<$<CONFIG:debug>:DEBUG>$<$<CONFIG:relwithdebinfo>:DEBUG>"
  FILE ${SHADER_FILE_ABSOLUTE}
  OUTPUT ${OUTPUT}
  PROFILE ${PROFILE}
  O "$<$<CONFIG:debug>:0>$<$<CONFIG:release>:3>$<$<CONFIG:relwithdebinfo>:3>$<$<CONFIG:minsizerel>:3>"
  VARYINGDEF ${ARGS_VARYING_DEF}
  INCLUDES ${BGFX_SHADER_INCLUDE_PATH}
  BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}
)
```
2022-08-22 08:57:50 -04:00
Sandy Carter
6ecce2449d emscripten: Set examples as htmls 2022-08-22 08:57:15 -04:00
Sandy Carter
c717984be0 emscripten: specify webgl2
Fix `undefined symbol emscripten_webgl2_get_proc_address` linker error
2022-08-22 08:57:15 -04:00
Sandy
955d692550 Dependabot unblock (#144)
* build(deps): bump bx from `aa5090b` to `13ae212`

Bumps [bx](https://github.com/bkaradzic/bx) from `aa5090b` to `13ae212`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](aa5090bbd8...13ae21207d)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump bgfx from `db44d56` to `8461f34`

Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `db44d56` to `8461f34`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](db44d5675f...8461f3406e)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-19 08:56:45 -07:00
Sandy Carter
12b75cc0ad config: Add option to turn on debug output on release 2022-08-07 08:33:26 -04:00
loanselot
65dde3874d Merge pull request #137 from pr0g/master
update bx to require c++14 and add compiler flag for bx when using MSVC
2022-07-19 00:42:56 +03:00
Tom Hulton-Harrop
f6a9fb1687 update from upstream - update bgfx submodule 2022-07-17 22:39:38 +01:00
Tom Hulton-Harrop
f1eed47138 Merge remote-tracking branch 'upstream/master' 2022-07-17 22:38:36 +01:00
loanselot
9ac6e08121 Merge pull request #138 from bkaradzic/dependabot/submodules/bx-aa5090b
build(deps): bump bx from `6332fb0` to `aa5090b`
2022-07-17 18:16:53 +03:00
loanselot
6c75503da4 Merge pull request #139 from bkaradzic/dependabot/submodules/bgfx-b38389f
build(deps): bump bgfx from `9204a53` to `b38389f`
2022-07-17 18:16:45 +03:00
dependabot[bot]
3dcf049202 build(deps): bump bgfx from 9204a53 to b38389f
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `9204a53` to `b38389f`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](9204a536dd...b38389f04e)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-01 16:03:21 +00:00
dependabot[bot]
3ec2a51aef build(deps): bump bx from 6332fb0 to aa5090b
Bumps [bx](https://github.com/bkaradzic/bx) from `6332fb0` to `aa5090b`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](6332fb0305...aa5090bbd8)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-01 16:03:20 +00:00
e-erdal
26a0f1e54d update bx to require c++14 and add compiler flag for bx when using MSVC 2022-06-26 17:22:23 +01:00
e-erdal
896ab5478c Add __cplusplus for MSVC 2022-06-24 11:42:25 +03:00
loanselot
23a1dc204a Merge pull request #135 from bkaradzic/dependabot/submodules/bx-6332fb0
build(deps): bump bx from `8832707` to `6332fb0`
2022-06-24 11:36:57 +03:00
loanselot
5fa58aad11 Merge pull request #136 from bkaradzic/dependabot/submodules/bgfx-9204a53
build(deps): bump bgfx from `379fc70` to `9204a53`
2022-06-24 11:36:49 +03:00
dependabot[bot]
8dafd0d9e4 build(deps): bump bgfx from 379fc70 to 9204a53
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `379fc70` to `9204a53`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](379fc707ff...9204a536dd)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-01 16:03:24 +00:00
dependabot[bot]
3bac602264 build(deps): bump bx from 8832707 to 6332fb0
Bumps [bx](https://github.com/bkaradzic/bx) from `8832707` to `6332fb0`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](88327070b9...6332fb0305)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-01 16:03:20 +00:00
loanselot
1b2b921bde Merge pull request #134 from bkaradzic/dependabot/submodules/bgfx-379fc70
build(deps): bump bgfx from `5ae2271` to `379fc70`
2022-05-04 12:26:41 +03:00
loanselot
374dcbba70 Merge pull request #133 from bkaradzic/dependabot/submodules/bx-8832707
build(deps): bump bx from `ad018d4` to `8832707`
2022-05-04 12:26:26 +03:00
dependabot[bot]
95af1cc54d build(deps): bump bgfx from 5ae2271 to 379fc70
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `5ae2271` to `379fc70`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](5ae2271667...379fc707ff)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-01 16:01:28 +00:00
dependabot[bot]
e85f8c0f3c build(deps): bump bx from ad018d4 to 8832707
Bumps [bx](https://github.com/bkaradzic/bx) from `ad018d4` to `8832707`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](ad018d47c6...88327070b9)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-01 16:01:26 +00:00
loanselot
9ecbe9ee51 Merge pull request #131 from bkaradzic/dependabot/submodules/bgfx-5ae2271
Bump bgfx from `ae7aeba` to `5ae2271`
2022-04-12 02:24:53 +03:00
Sandy Carter
d725e78f86 bgfx: Add BGFX_MULTITHREADED option 2022-04-10 22:30:07 -04:00
dependabot[bot]
93de01a1af Bump bgfx from ae7aeba to 5ae2271
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `ae7aeba` to `5ae2271`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](ae7aeba72c...5ae2271667)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-01 16:02:10 +00:00
Sandy Carter
dd2017c332 examples: Don't build on android by default 2022-03-30 17:09:46 -04:00
Sandy Carter
ead887f59b bx: Link with android log library 2022-03-30 17:09:46 -04:00
Sandy Carter
f184835827 glsl-optimizer: set libraries as STATIC explicitly 2022-03-30 17:09:31 -04:00
Tom Hulton-Harrop
a7ac0aa3ae add additional space around parens 2022-03-21 20:52:06 -04:00
Tom Hulton-Harrop
163661a07e update to have bgfx.cmake work with emscripten 2022-03-21 20:52:06 -04:00
loanselot
99b9c1e852 Merge pull request #126 from bkaradzic/dependabot/submodules/bx-ad018d4
Bump bx from `c969169` to `ad018d4`
2022-03-08 13:51:21 +03:00
dependabot[bot]
819719a4f9 Bump bx from c969169 to ad018d4
Bumps [bx](https://github.com/bkaradzic/bx) from `c969169` to `ad018d4`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](c969169fc1...ad018d47c6)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-01 16:02:16 +00:00
34 changed files with 564 additions and 454 deletions

View File

@@ -25,11 +25,11 @@ jobs:
- id: version
run: |
API_VERSION=$(grep -Eo "BGFX_API_VERSION UINT32_C\([0-9]+\)" bgfx/include/bgfx/defines.h | grep -Eo "[0-9]+" | tail -1)
REVISION=$(cd bgfx && git rev-list HEAD --count)
BGFX_REVISION=$(cd bgfx && git rev-list HEAD --count)
BGFX_CMAKE_REVISION=$(git rev-list HEAD --count)
SHA=$(cd bgfx && git rev-parse HEAD)
SHA7="${GITHUB_SHA::7}"
TAG="v1.${API_VERSION}.${REVISION}-${SHA7}"
echo "::set-output name=revision::${REVISION}"
TAG="v1.${API_VERSION}.${BGFX_REVISION}-${BGFX_CMAKE_REVISION}"
echo "::set-output name=revision::${BGFX_REVISION}"
echo "::set-output name=sha::${SHA}"
echo "::set-output name=tag::${TAG}"

View File

@@ -21,19 +21,43 @@ if( APPLE AND NOT XCODE )
set( CMAKE_CXX_FLAGS "-ObjC++" )
endif()
option( BGFX_BUILD_TOOLS "Build bgfx tools." ON )
option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON )
option( BGFX_INSTALL "Create installation target." ON )
option( BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF )
option( BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON )
option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF )
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
option( BGFX_CONFIG_RENDERER_WEBGPU "Enables the webgpu renderer" OFF )
if (MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
add_compile_options("/Zc:__cplusplus")
endif()
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
option( BX_CONFIG_DEBUG "Log debug messages (default: on in debug)" OFF )
option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF )
option( BGFX_BUILD_TOOLS "Build bgfx tools." ON )
option( BGFX_BUILD_TOOLS_SHADER "Build bgfx shader tools." ON )
option( BGFX_BUILD_TOOLS_GEOMETRY "Build bgfx geometry tools." ON )
option( BGFX_BUILD_TOOLS_TEXTURE "Build bgfx texture tools." ON )
option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON )
option( BGFX_INSTALL "Create installation target." ON )
option( BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." 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 )
option( BGFX_CONFIG_DEBUG_ANNOTATION "Enable gfx debug annotations (default: on in debug)" OFF )
set( BGFX_OPENGL_VERSION "" CACHE STRING "Specify minimum opengl version" )
set( BGFX_OPENGLES_VERSION "" CACHE STRING "Specify minimum OpenGL ES version" )
set( BGFX_LIBRARY_TYPE "STATIC" CACHE STRING "Linking type for library" )
set( BGFX_CONFIG_DEFAULT_MAX_ENCODERS "" CACHE STRING "Specify default maximum encoder count (multithreaded only)" )
set( BGFX_CONFIG_MAX_DRAW_CALLS "" CACHE STRING "Specify maximum draw calls" )
set( BGFX_CONFIG_MAX_VIEWS "" CACHE STRING "Specify maximum view count (should be a power of two)" )
set( BGFX_CONFIG_MAX_FRAME_BUFFERS "" CACHE STRING "Specify maximum frame buffers" )
set( BGFX_CONFIG_MAX_VERTEX_LAYOUTS "" CACHE STRING "Specify maximum vertex layouts" )
set( BGFX_CONFIG_MAX_VERTEX_BUFFERS "" CACHE STRING "Specify maximum vertex buffer count" )
set( BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS "" CACHE STRING "Specify maximum dynamic vertex buffer count" )
set( BGFX_CONFIG_MAX_INDEX_BUFFERS "" CACHE STRING "Specify maximum index buffer count" )
set( BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS "" CACHE STRING "Specify maximum dynamic index buffer count" )
set( BGFX_CONFIG_MAX_TEXTURES "" CACHE STRING "Specify maximum texture count" )
set( BGFX_CONFIG_MAX_TEXTURE_SAMPLERS "" CACHE STRING "Specify maximum texture samplers" )
set( BGFX_CONFIG_MAX_SHADERS "" CACHE STRING "Specify shader count" )
set( BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM "" CACHE STRING "Specify maximum program count as 2^(program bits)" )
set_property( CACHE BGFX_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED )
if( BGFX_LIBRARY_TYPE MATCHES "SHARED" )
@@ -125,7 +149,7 @@ if( BGFX_INSTALL )
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
if( NOT BGFX_LIBRARY_TYPE MATCHES "SHARED" )
install( TARGETS bimg bx astc-codec astc edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr
install( TARGETS bimg bx astc-encoder edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
@@ -154,22 +178,30 @@ if( BGFX_INSTALL )
)
# install tools
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake
DESTINATION "${config_install_dir}")
if( BGFX_BUILD_TOOLS )
install( TARGETS shaderc
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS geometryc
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS geometryv
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS texturec
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS texturev
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
if (BGFX_BUILD_TOOLS_SHADER)
install( TARGETS shaderc
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
endif()
if (BGFX_BUILD_TOOLS_GEOMETRY)
install( TARGETS geometryc
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS geometryv
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
endif()
if (BGFX_BUILD_TOOLS_TEXTURE)
install( TARGETS texturec
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS texturev
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
endif()
endif()
# install examples

View File

@@ -1,37 +1,38 @@
bgfx.cmake
===================
==========
[![Build Status](https://github.com/bkaradzic/bgfx.cmake/workflows/Release/badge.svg)](https://github.com/bkaradzic/bgfx.cmake/workflows/Release/badge.svg)
**NOTE: This port only made to be used as C++ library, some features (such as bindings, examples) might not work! Please use original repo with GENie instead.**
**NOTE: This port only made to be used as C++ library, some features (such as bindings) might not work! For those features, please use original repo with GENie instead.**
This repo contains a bunch of cmake files that can be used to build bgfx with CMake.
This repo contains cmake configuration files that can be used to build bgfx with CMake.
Building
-------------
---
```bash
git clone https://github.com/bkaradzic/bgfx.cmake.git
cd bgfx.cmake
git submodule init
git submodule update
mkdir build
cd build
cmake ..
cmake -S. -Bcmake-build # $CMakeOptions
cmake --build cmake-build
```
If downloading via zip (instead of using git submodules) manually download bx, bimg and bgfx and copy them into the root directory, or locate them via `BX_DIR`, `BIMG_DIR` and `BGFX_DIR` CMake variables.
How To Use
-------------
This project is setup to be included a few different ways. To include bgfx source code in your project simply use add_subdirectory to include this project. To build bgfx binaries build the `INSTALL` target (or `make install`). The installed files will be in the directory specified by `CMAKE_INSTALL_PREFIX` which I recommend you set to `./install` so it will export to your build directory. Note you may want to build install on both `Release` and `Debug` configurations.
----------
This project is setup to be included a few different ways. To include bgfx source code in your project simply use add_subdirectory to include this project. To build bgfx binaries build the `INSTALL` target (or `make install`). The installed files will be in the directory specified by `CMAKE_INSTALL_PREFIX` which we recommend you set to `./install` so it will export to your build directory. Note you may want to build install on both `Release` and `Debug` configurations.
Features
-------------
--------
* No outside dependencies besides bx, bimg, bgfx, and CMake.
* Tested on Visual Studio 2015, Xcode, gcc 5.4, clang 3.8.
* Tested on
* Windows, OSX, Linux, Android, UWP, Emscripten (experimental)
* VSCode, Visual Studio, Xcode, gcc, clang.
* Compiles bgfx, tools & examples.
* Detects shader modifications and automatically rebuilds them for all examples.
Does this work with latest bx/bgfx/bimg?
-------------
----------------------------------------
Probably! This project needs to be updated if a dependency is added or the bgfx build system changes. The bgfx repository is very active but these types of changes are rare. New examples have to be added manually as well, but not doing so will merely result in that example not showing up and won't break anything else. If pulling latest causes issues, be sure to manually reconfigure CMake as the glob patterns may need to be refreshed (the use of glob patterns in CMake is generally discouraged but in this project it helps to ensure upwards compatibilty with newer bgfx updates).

2
bgfx

Submodule bgfx updated: ae7aeba72c...5f435ea56b

2
bimg

Submodule bimg updated: 663f724186...1af90543ca

2
bx

Submodule bx updated: c969169fc1...aed1086c48

View File

@@ -8,21 +8,23 @@
# 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 astc-codec )
if( TARGET astc-encoder )
return()
endif()
file(
GLOB
ASTC_CODEC_SOURCES
${BIMG_DIR}/3rdparty/astc-codec/src/decoder/*.cc
${BIMG_DIR}/3rdparty/astc-codec/src/decoder/*.h
ASTC_ENCODER_SOURCES
${BIMG_DIR}/3rdparty/astc-encoder/source/*.cpp
${BIMG_DIR}/3rdparty/astc-encoder/include/*.h
)
add_library( astc-codec STATIC ${ASTC_CODEC_SOURCES} )
target_include_directories( astc-codec
add_library( astc-encoder STATIC ${ASTC_ENCODER_SOURCES} )
target_include_directories( astc-encoder
PUBLIC
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-codec>
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-codec/include> )
set_target_properties( astc-codec PROPERTIES FOLDER "bgfx/3rdparty" )
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder>
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder/include> )
set_target_properties( astc-encoder
PROPERTIES
FOLDER "bgfx/3rdparty" )

View File

@@ -1,19 +0,0 @@
# 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 astc )
return()
endif()
file( GLOB ASTC_SOURCES ${BIMG_DIR}/3rdparty/astc/*.cpp ${BIMG_DIR}/3rdparty/astc/*.h )
add_library( astc STATIC ${ASTC_SOURCES} )
target_include_directories( astc PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( astc PROPERTIES FOLDER "bgfx/3rdparty" )

View File

@@ -18,4 +18,7 @@ add_library( dear-imgui STATIC EXCLUDE_FROM_ALL ${dear_IMGUI_SOURCES} )
target_compile_definitions( dear-imgui PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS" )
target_include_directories( dear-imgui PUBLIC ${BGFX_DIR}/3rdparty )
target_link_libraries( dear-imgui PUBLIC bx )
set_target_properties( dear-imgui PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( dear-imgui
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB EDTAA3_SOURCES ${BIMG_DIR}/3rdparty/edtaa3/*.cpp ${BIMG_DIR}/3rdparty
add_library( edtaa3 STATIC ${EDTAA3_SOURCES} )
target_include_directories( edtaa3 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( edtaa3 PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( edtaa3
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB ETC1_SOURCES ${BIMG_DIR}/3rdparty/etc1/*.cpp ${BIMG_DIR}/3rdparty/etc
add_library( etc1 STATIC ${ETC1_SOURCES} )
target_include_directories( etc1 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( etc1 PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( etc1
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,5 +16,8 @@ file( GLOB ETC2_SOURCES ${BIMG_DIR}/3rdparty/etc2/*.cpp ${BIMG_DIR}/3rdparty/etc
add_library( etc2 STATIC ${ETC2_SOURCES} )
target_include_directories( etc2 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( etc2 PROPERTIES FOLDER "bgfx/3rdparty" )
target_link_libraries( etc2 PUBLIC bx )
target_link_libraries( etc2 PUBLIC bx )
set_target_properties( etc2
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -28,5 +28,8 @@ if( MSVC )
set_target_properties( fcpp PROPERTIES COMPILE_FLAGS "/W0" )
endif()
set_target_properties( fcpp PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( fcpp
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
set_source_files_properties( ${BGFX_DIR}/3rdparty/fcpp/usecpp.c PROPERTIES HEADER_FILE_ONLY ON )

View File

@@ -27,7 +27,8 @@ string(REPLACE "-fsanitize=undefined" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
# glcpp
file( GLOB GLCPP_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/glcpp/*.c ${BGFX_DIR}/3rdparty/glsl-optimizer/src/util/*.c )
add_library( glcpp ${GLCPP_SOURCES} )
# Library must be static because hash_table_ctor referenced in function glcpp_parser_create
add_library( glcpp STATIC ${GLCPP_SOURCES} )
target_include_directories( glcpp PUBLIC ${GLSL-OPTIMIZER_INCLUDES} )
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options( glcpp PRIVATE "-fno-strict-aliasing")
@@ -39,7 +40,8 @@ set_target_properties( glcpp PROPERTIES FOLDER "bgfx/3rdparty" )
# mesa
file( GLOB MESA_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa/program/*.c ${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa/main/*.c )
add_library( mesa ${MESA_SOURCES} )
# Library must be static because mesa/program/prog_hash_table.c uses _mesa_error_no_memory which is in glsl/standalone_scaffolding.cpp of glsl-optimizer
add_library( mesa STATIC ${MESA_SOURCES} )
target_include_directories( mesa PUBLIC ${GLSL-OPTIMIZER_INCLUDES} )
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options( mesa PRIVATE "-fno-strict-aliasing")
@@ -53,7 +55,7 @@ set_target_properties( mesa PROPERTIES FOLDER "bgfx/3rdparty" )
file( GLOB GLSL-OPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.cpp ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.c )
file( GLOB GLSL-OPTIMIZER_SOURCES_REMOVE ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/main.cpp ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/builtin_stubs.cpp )
list( REMOVE_ITEM GLSL-OPTIMIZER_SOURCES ${GLSL-OPTIMIZER_SOURCES_REMOVE} )
add_library( glsl-optimizer ${GLSL-OPTIMIZER_SOURCES} )
add_library( glsl-optimizer STATIC ${GLSL-OPTIMIZER_SOURCES} )
target_link_libraries( glsl-optimizer glcpp mesa )
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options( glsl-optimizer
@@ -82,4 +84,7 @@ elseif(APPLE)
-Wno-deprecated-register
)
endif()
set_target_properties( glsl-optimizer PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( glsl-optimizer
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -40,7 +40,10 @@ target_include_directories( glslang PUBLIC
${BGFX_DIR}/3rdparty
)
set_target_properties( glslang PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( glslang
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
if( MSVC )
target_compile_options( glslang PRIVATE
@@ -95,4 +98,4 @@ endif()
target_compile_definitions( glslang PRIVATE
ENABLE_OPT=1
ENABLE_HLSL=1
)
)

View File

@@ -16,4 +16,7 @@ file( GLOB IQA_SOURCES ${BIMG_DIR}/3rdparty/iqa/source/*.c ${BIMG_DIR}/3rdparty/
add_library( iqa STATIC ${IQA_SOURCES} )
target_include_directories( iqa PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/iqa/include> )
set_target_properties( iqa PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( iqa
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB SQUISH_SOURCES ${BIMG_DIR}/3rdparty/libsquish/*.cpp ${BIMG_DIR}/3rdpa
add_library( squish STATIC ${SQUISH_SOURCES} )
target_include_directories( squish PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( squish PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( squish
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB MESHOPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.cpp ${
add_library( meshoptimizer STATIC ${MESHOPTIMIZER_SOURCES} )
target_include_directories( meshoptimizer PUBLIC ${BGFX_DIR}/3rdparty )
set_target_properties( meshoptimizer PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( meshoptimizer
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -32,5 +32,8 @@ target_include_directories( nvtt
PUBLIC
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/nvtt> )
set_target_properties( nvtt PROPERTIES FOLDER "bgfx/3rdparty" )
target_link_libraries( nvtt PUBLIC bx )
target_link_libraries( nvtt PUBLIC bx )
set_target_properties( nvtt
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB PVRTC_SOURCES ${BIMG_DIR}/3rdparty/pvrtc/*.cpp ${BIMG_DIR}/3rdparty/p
add_library( pvrtc STATIC ${PVRTC_SOURCES} )
target_include_directories( pvrtc PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( pvrtc PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( pvrtc
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -35,4 +35,7 @@ if( MSVC )
)
endif()
set_target_properties( spirv-cross PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( spirv-cross
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -55,4 +55,7 @@ else()
endif()
endif()
set_target_properties( spirv-tools PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( spirv-tools
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -6,4 +6,7 @@ file( GLOB_RECURSE TINYEXR_SOURCES ${BIMG_DIR}/3rdparty/tinyexr/*.c ${BIMG_DIR}/
add_library( tinyexr STATIC ${TINYEXR_SOURCES} )
target_include_directories( tinyexr PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/tinyexr/deps/miniz> )
set_target_properties( tinyexr PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( tinyexr
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -28,4 +28,7 @@ target_include_directories( webgpu
$<BUILD_INTERFACE:${BGFX_DIR}/3rdparty/webgpu/include>
)
# set_target_properties( webgpu PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( webgpu
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -1,4 +1,25 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
check_required_components("@PROJECT_NAME@")
get_target_property(BGFX_INCLUDE_PATH bgfx::bgfx INTERFACE_INCLUDE_DIRECTORIES)
list(GET BGFX_INCLUDE_PATH 0 BGFX_INCLUDE_PATH_1) # bgfx::bgfx exports include directory twice?
set(BGFX_SHADER_INCLUDE_PATH ${BGFX_INCLUDE_PATH_1}/bgfx)
# If cross compiling, we need a host-compatible version of shaderc to compile shaders
if (@CMAKE_CROSSCOMPILING@ AND NOT TARGET bgfx::shaderc)
find_program(
shaderc_EXECUTABLE REQUIRED
NAMES bgfx-shaderc shaderc
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
)
add_executable(bgfx::shaderc IMPORTED)
set_target_properties(
bgfx::shaderc PROPERTIES IMPORTED_LOCATION "${shaderc_EXECUTABLE}"
)
endif ()
include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake")
check_required_components("@PROJECT_NAME@")

View File

@@ -44,6 +44,7 @@ if(BGFX_LIBRARY_TYPE STREQUAL STATIC)
add_library( bgfx STATIC ${BGFX_SOURCES} )
else()
add_library( bgfx SHARED ${BGFX_SOURCES} )
target_compile_definitions( bgfx PUBLIC BGFX_SHARED_LIB_BUILD=1 )
endif()
if(BGFX_CONFIG_RENDERER_WEBGPU)
@@ -56,6 +57,10 @@ if(BGFX_CONFIG_RENDERER_WEBGPU)
endif()
endif()
if(EMSCRIPTEN)
target_link_options(bgfx PUBLIC "-sMAX_WEBGL_VERSION=2")
endif()
if( NOT ${BGFX_OPENGL_VERSION} STREQUAL "" )
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION=${BGFX_OPENGL_VERSION} )
endif()
@@ -64,19 +69,64 @@ if( NOT ${BGFX_OPENGLES_VERSION} STREQUAL "" )
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION=${BGFX_OPENGLES_VERSION} )
endif()
if( NOT ${BGFX_CONFIG_DEFAULT_MAX_ENCODERS} STREQUAL "" )
target_compile_definitions( bgfx
PUBLIC
"BGFX_CONFIG_DEFAULT_MAX_ENCODERS=$<IF:$<BOOL:${BGFX_CONFIG_MULTITHREADED}>,${BGFX_CONFIG_DEFAULT_MAX_ENCODERS},1>" )
endif()
set(BGFX_CONFIG_OPTIONS "")
list(APPEND BGFX_CONFIG_OPTIONS
"BGFX_CONFIG_MAX_DRAW_CALLS"
"BGFX_CONFIG_MAX_VIEWS"
"BGFX_CONFIG_MAX_FRAME_BUFFERS"
"BGFX_CONFIG_MAX_VERTEX_LAYOUTS"
"BGFX_CONFIG_MAX_VERTEX_BUFFERS"
"BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS"
"BGFX_CONFIG_MAX_INDEX_BUFFERS"
"BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS"
"BGFX_CONFIG_MAX_TEXTURES"
"BGFX_CONFIG_MAX_TEXTURE_SAMPLERS"
"BGFX_CONFIG_MAX_SHADERS"
"BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM"
)
foreach(BGFX_CONFIG_OPTION IN LISTS BGFX_CONFIG_OPTIONS)
if( NOT ${${BGFX_CONFIG_OPTION}} STREQUAL "" )
target_compile_definitions( bgfx PUBLIC "${BGFX_CONFIG_OPTION}=${${BGFX_CONFIG_OPTION}}" )
endif()
endforeach()
# Special Visual Studio Flags
if( MSVC )
target_compile_definitions( bgfx PRIVATE "_CRT_SECURE_NO_WARNINGS" )
endif()
# Add debug config required in bx headers since bx is private
target_compile_definitions(bgfx PUBLIC "BX_CONFIG_DEBUG=$<CONFIG:Debug>")
target_compile_definitions(bgfx
PUBLIC
"BX_CONFIG_DEBUG=$<OR:$<CONFIG:Debug>,$<BOOL:${BX_CONFIG_DEBUG}>>"
"BGFX_CONFIG_DEBUG_ANNOTATION=$<AND:$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},WindowsStore>>,$<OR:$<CONFIG:Debug>,$<BOOL:${BGFX_CONFIG_DEBUG_ANNOTATION}>>>"
"BGFX_CONFIG_MULTITHREADED=$<BOOL:${BGFX_CONFIG_MULTITHREADED}>"
)
# directx-headers
set (DIRECTX_HEADERS)
if (UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID) # Only Linux
set (DIRECTX_HEADERS
${BGFX_DIR}/3rdparty/directx-headers/include/directx
${BGFX_DIR}/3rdparty/directx-headers/include
${BGFX_DIR}/3rdparty/directx-headers/include/wsl/stubs )
elseif (WIN32) # Only Windows
set (DIRECTX_HEADERS
${BGFX_DIR}/3rdparty/directx-headers/include/directx
${BGFX_DIR}/3rdparty/directx-headers/include )
endif()
# Includes
target_include_directories( bgfx
PRIVATE
${DIRECTX_HEADERS}
${BGFX_DIR}/3rdparty
${BGFX_DIR}/3rdparty/dxsdk/include
${BGFX_DIR}/3rdparty/khronos
PUBLIC
$<BUILD_INTERFACE:${BGFX_DIR}/include>

277
cmake/bgfxToolUtils.cmake Normal file
View File

@@ -0,0 +1,277 @@
# shaderc_parse(
# FILE filename
# OUTPUT filename
# FRAGMENT|VERTEX|COMPUTE
# ANDROID|ASM_JS|IOS|LINUX|NACL|OSX|WINDOWS
# [PROFILE profile]
# [O 0|1|2|3]
# [VARYINGDEF filename]
# [BIN2C filename]
# [INCLUDES include;include]
# [DEFINES include;include]
# [DEPENDS]
# [PREPROCESS]
# [RAW]
# [VERBOSE]
# [DEBUG]
# [DISASM]
# [WERROR]
# )
function( 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" "FILE;OUTPUT;VARYINGDEF;BIN2C;PROFILE;O" "INCLUDES;DEFINES" ${ARGN} )
set( CLI "" )
# -f
if( ARG_FILE )
list( APPEND CLI "-f" "${ARG_FILE}" )
endif()
# -i
if( ARG_INCLUDES )
foreach( INCLUDE ${ARG_INCLUDES} )
list( APPEND CLI "-i" )
list( APPEND CLI "${INCLUDE}" )
endforeach()
endif()
# -o
if( ARG_OUTPUT )
list( APPEND CLI "-o" "${ARG_OUTPUT}" )
endif()
# --bin2c
if( ARG_BIN2C )
list( APPEND CLI "--bin2c" "${ARG_BIN2C}" )
endif()
# --depends
if( ARG_DEPENDS )
list( APPEND CLI "--depends" )
endif()
# --platform
set( PLATFORM "" )
set( PLATFORMS "ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS" )
foreach( P ${PLATFORMS} )
if( ARG_${P} )
if( PLATFORM )
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${PLATFORM} and ${P}." )
return()
endif()
set( PLATFORM "${P}" )
endif()
endforeach()
if( "${PLATFORM}" STREQUAL "" )
message( SEND_ERROR "Call to shaderc_parse() must have a platform flag: ${PLATFORMS}" )
return()
elseif( "${PLATFORM}" STREQUAL "ANDROID" )
list( APPEND CLI "--platform" "android" )
elseif( "${PLATFORM}" STREQUAL "ASM_JS" )
list( APPEND CLI "--platform" "asm.js" )
elseif( "${PLATFORM}" STREQUAL "IOS" )
list( APPEND CLI "--platform" "ios" )
elseif( "${PLATFORM}" STREQUAL "LINUX" )
list( APPEND CLI "--platform" "linux" )
elseif( "${PLATFORM}" STREQUAL "NACL" )
list( APPEND CLI "--platform" "nacl" )
elseif( "${PLATFORM}" STREQUAL "OSX" )
list( APPEND CLI "--platform" "osx" )
elseif( "${PLATFORM}" STREQUAL "WINDOWS" )
list( APPEND CLI "--platform" "windows" )
endif()
# --preprocess
if( ARG_PREPROCESS )
list( APPEND CLI "--preprocess" )
endif()
# --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}" )
endif()
# --raw
if( ARG_RAW )
list( APPEND CLI "--raw" )
endif()
# --type
set( TYPE "" )
set( TYPES "FRAGMENT;VERTEX;COMPUTE" )
foreach( T ${TYPES} )
if( ARG_${T} )
if( TYPE )
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${TYPE} and ${T}." )
return()
endif()
set( TYPE "${T}" )
endif()
endforeach()
if( "${TYPE}" STREQUAL "" )
message( SEND_ERROR "Call to shaderc_parse() must have a type flag: ${TYPES}" )
return()
elseif( "${TYPE}" STREQUAL "FRAGMENT" )
list( APPEND CLI "--type" "fragment" )
elseif( "${TYPE}" STREQUAL "VERTEX" )
list( APPEND CLI "--type" "vertex" )
elseif( "${TYPE}" STREQUAL "COMPUTE" )
list( APPEND CLI "--type" "compute" )
endif()
# --varyingdef
if( ARG_VARYINGDEF )
list( APPEND CLI "--varyingdef" "${ARG_VARYINGDEF}" )
endif()
# --verbose
if( ARG_VERBOSE )
list( APPEND CLI "--verbose" )
endif()
# --debug
if( ARG_DEBUG )
list( APPEND CLI "--debug" )
endif()
# --disasm
if( ARG_DISASM )
list( APPEND CLI "--disasm" )
endif()
# --profile
if( ARG_PROFILE )
list( APPEND CLI "--profile" "${ARG_PROFILE}" )
endif()
# -O
if( ARG_O )
list( APPEND CLI "-O" "${ARG_O}" )
endif()
# --Werror
if( ARG_WERROR )
list( APPEND CLI "--Werror" )
endif()
set( ${ARG_OUT} ${CLI} PARENT_SCOPE )
endfunction()
function (_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 vs_3_0 dx9 PROFILE ${PROFILE})
string(REPLACE vs_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE vs_5_0 dx11 PROFILE ${PROFILE})
string(REPLACE ps_3_0 dx9 PROFILE ${PROFILE})
string(REPLACE ps_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE ps_5_0 dx11 PROFILE ${PROFILE})
string(REPLACE cs_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE cs_5_0 dx11 PROFILE ${PROFILE})
set(${PROFILE_EXT}
${PROFILE}
PARENT_SCOPE
)
endfunction ()
# compile_shader_to_header(
# TYPE VERTEX|FRAGMENT|COMPUTE
# SHADERS filenames
# VARYING_DEF filename
# OUTPUT_DIR directory
#)
#
function (compile_shader_to_header)
set(options "")
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR)
set(multiValueArgs SHADERS)
cmake_parse_arguments(
ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}"
)
set(PROFILES 120 300_es spirv) # pssl
if (UNIX AND NOT APPLE)
set(PLATFORM LINUX)
elseif (EMSCRIPTEN)
set(PLATFORM ASM_JS)
elseif (APPLE)
set(PLATFORM OSX)
list(APPEND PROFILES metal)
elseif (
WIN32
OR MINGW
OR MSYS
OR CYGWIN
)
set(PLATFORM WINDOWS)
if (ARGS_TYPE STREQUAL "VERTEX")
list(APPEND PROFILES vs_3_0)
list(APPEND PROFILES vs_4_0)
list(APPEND PROFILES vs_5_0)
elseif (ARGS_TYPE STREQUAL "FRAGMENT")
list(APPEND PROFILES ps_3_0)
list(APPEND PROFILES ps_4_0)
list(APPEND PROFILES ps_5_0)
elseif (ARGS_TYPE STREQUAL "COMPUTE")
list(APPEND PROFILES cs_4_0)
list(APPEND PROFILES cs_5_0)
else ()
message(error "shaderc: Unsupported type")
endif ()
else ()
message(error "shaderc: Unsupported platform")
endif ()
foreach (SHADER_FILE ${ARGS_SHADERS})
source_group("Shaders" FILES "${SHADER}")
get_filename_component(SHADER_FILE_BASENAME ${SHADER_FILE} NAME)
get_filename_component(SHADER_FILE_NAME_WE ${SHADER_FILE} NAME_WE)
get_filename_component(SHADER_FILE_ABSOLUTE ${SHADER_FILE} ABSOLUTE)
# Build output targets and their commands
set(OUTPUTS "")
set(COMMANDS "")
foreach (PROFILE ${PROFILES})
_get_profile_ext(${PROFILE} PROFILE_EXT)
set(OUTPUT
${ARGS_OUTPUT_DIR}/${SHADER_FILE_BASENAME}.${PROFILE_EXT}.bin.h
)
set(PLATFORM_I ${PLATFORM})
if (PROFILE STREQUAL "spirv")
set(PLATFORM_I LINUX)
endif ()
shaderc_parse(
CLI #
${ARGS_TYPE} ${PLATFORM_I} WERROR
"$<$<CONFIG:debug>:DEBUG>$<$<CONFIG:relwithdebinfo>:DEBUG>"
FILE ${SHADER_FILE_ABSOLUTE}
OUTPUT ${OUTPUT}
PROFILE ${PROFILE}
O "$<$<CONFIG:debug>:0>$<$<CONFIG:release>:3>$<$<CONFIG:relwithdebinfo>:3>$<$<CONFIG:minsizerel>:3>"
VARYINGDEF ${ARGS_VARYING_DEF}
INCLUDES ${BGFX_SHADER_INCLUDE_PATH}
BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}
)
list(APPEND OUTPUTS ${OUTPUT})
list(APPEND COMMANDS COMMAND bgfx::shaderc ${CLI})
endforeach ()
add_custom_command(
OUTPUT ${OUTPUTS}
COMMAND ${CMAKE_COMMAND} -E make_directory ${ARGS_OUTPUT_DIR} ${COMMANDS}
MAIN_DEPENDENCY ${SHADER_FILE_ABSOLUTE}
DEPENDS ${ARGS_VARYING_DEF}
)
endforeach ()
endfunction ()

View File

@@ -9,8 +9,7 @@
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
# Third party libs
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc-codec.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc-encoder.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/edtaa3.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc1.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc2.cmake )
@@ -39,7 +38,7 @@ target_include_directories( bimg
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# bimg dependencies
target_link_libraries( bimg PUBLIC bx PRIVATE astc-codec astc edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr )
target_link_libraries( bimg PUBLIC bx PRIVATE astc-encoder edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr )
# Put in a "bgfx" folder in Visual Studio
set_target_properties( bimg PROPERTIES FOLDER "bgfx" )

View File

@@ -30,6 +30,10 @@ endif()
# Create the bx target
add_library( bx STATIC ${BX_SOURCES} )
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> )
# Link against psapi on Windows
if( WIN32 )
target_link_libraries( bx PUBLIC psapi )
@@ -55,11 +59,16 @@ elseif( WIN32 )
PUBLIC
$<BUILD_INTERFACE:${BX_DIR}/include/compat/msvc>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/msvc> )
elseif( APPLE )
elseif( APPLE ) # APPLE is technically UNIX... ORDERING MATTERS!
target_include_directories( bx
PUBLIC
$<BUILD_INTERFACE:${BX_DIR}/include/compat/osx>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/osx> )
$<BUILD_INTERFACE:${BX_DIR}/include/compat/osx>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/osx> )
elseif ( UNIX )
target_include_directories( bx
PUBLIC
$<BUILD_INTERFACE:${BX_DIR}/include/compat/linux>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/linux> )
endif()
# All configurations
@@ -67,20 +76,25 @@ target_compile_definitions( bx PUBLIC "__STDC_LIMIT_MACROS" )
target_compile_definitions( bx PUBLIC "__STDC_FORMAT_MACROS" )
target_compile_definitions( bx PUBLIC "__STDC_CONSTANT_MACROS" )
target_compile_definitions(bx PUBLIC "BX_CONFIG_DEBUG=$<CONFIG:Debug>")
target_compile_definitions(bx PUBLIC "BX_CONFIG_DEBUG=$<IF:$<CONFIG:Debug>,1,$<BOOL:${BX_CONFIG_DEBUG}>>")
# Additional dependencies on Unix
if( UNIX AND NOT APPLE AND NOT ANDROID )
if (ANDROID)
# For __android_log_write
find_library( LOG_LIBRARY log )
mark_as_advanced( LOG_LIBRARY )
target_link_libraries( bx PUBLIC ${LOG_LIBRARY} )
elseif( APPLE )
find_library( FOUNDATION_LIBRARY Foundation)
mark_as_advanced( FOUNDATION_LIBRARY )
target_link_libraries( bx PUBLIC ${FOUNDATION_LIBRARY} )
elseif( UNIX )
# Threads
find_package( Threads )
target_link_libraries( bx ${CMAKE_THREAD_LIBS_INIT} dl )
# Real time (for clock_gettime)
target_link_libraries( bx rt )
elseif(APPLE)
find_library( FOUNDATION_LIBRARY Foundation)
mark_as_advanced( FOUNDATION_LIBRARY )
target_link_libraries( bx PUBLIC ${FOUNDATION_LIBRARY} )
endif()
# Put in a "bgfx" folder in Visual Studio

View File

@@ -14,6 +14,7 @@ include( ${CMAKE_CURRENT_LIST_DIR}/util/ConfigureDebugging.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/dear-imgui.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/meshoptimizer.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake )
function( add_bgfx_shader FILE FOLDER )
get_filename_component( FILENAME "${FILE}" NAME_WE )
@@ -171,7 +172,7 @@ function( add_example ARG_NAME )
target_compile_definitions( example-${ARG_NAME} PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS" "-DENTRY_CONFIG_IMPLEMENT_MAIN=1" )
# Configure shaders
if( NOT ARG_COMMON AND NOT IOS AND NOT EMSCRIPTEN)
if( NOT ARG_COMMON AND NOT IOS AND NOT EMSCRIPTEN AND NOT ANDROID)
foreach( SHADER ${SHADERS} )
add_bgfx_shader( ${SHADER} ${ARG_NAME} )
endforeach()
@@ -179,10 +180,12 @@ function( add_example ARG_NAME )
endif()
if (NOT ARG_COMMON AND EMSCRIPTEN)
target_link_libraries(example-${ARG_NAME}
"-s PRECISE_F32=1"
"-s TOTAL_MEMORY=268435456"
"--memory-init-file 1")
set_target_properties(example-${ARG_NAME}
PROPERTIES
LINK_FLAGS
"-s PRECISE_F32=1 -s TOTAL_MEMORY=268435456 -s ENVIRONMENT=web --memory-init-file 1 --emrun"
SUFFIX ".html"
)
endif()
# Directory name
@@ -275,6 +278,7 @@ if( BGFX_BUILD_EXAMPLES )
44-sss
45-bokeh
46-fsr
47-pixelformats
)
foreach( EXAMPLE ${BGFX_EXAMPLES} )

View File

@@ -13,8 +13,16 @@ if( BGFX_CUSTOM_TARGETS )
set_target_properties( tools PROPERTIES FOLDER "bgfx/tools" )
endif()
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryc.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryv.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/shaderc.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturec.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturev.cmake )
if( BGFX_BUILD_TOOLS_SHADER )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/shaderc.cmake )
endif()
if( BGFX_BUILD_TOOLS_GEOMETRY )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryc.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryv.cmake )
endif()
if( BGFX_BUILD_TOOLS_TEXTURE )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturec.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturev.cmake )
endif()

View File

@@ -11,6 +11,9 @@
add_executable( geometryv ${BGFX_DIR}/tools/geometryv/geometryv.cpp )
set_target_properties( geometryv PROPERTIES FOLDER "bgfx/tools" )
target_link_libraries( geometryv example-common )
if(EMSCRIPTEN)
target_link_options( geometryv PRIVATE -sMAX_WEBGL_VERSION=2 )
endif()
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools geometryv )
endif()

View File

@@ -32,338 +32,3 @@ elseif (IOS)
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
endif()
function( add_shader ARG_FILE )
# Parse arguments
cmake_parse_arguments( ARG "FRAGMENT;VERTEX;COMPUTE" "OUTPUT;GLSL_VERSION;DX9_MODEL;DX11_MODEL" "PLATFORMS" ${ARGN} )
# Get filename
get_filename_component( FILENAME "${ARG_FILE}" NAME_WE )
# Determine if fragment or vertex or compute
if( ARG_FRAGMENT AND ARG_VERTEX AND ARG_COMPUTE )
message( SEND_ERROR "add_shader cannot be called with all FRAGMENT and VERTEX and COMPUTE." )
return()
elseif( ARG_FRAGMENT AND ARG_VERTEX )
message( SEND_ERROR "add_shader cannot be called with both FRAGMENT and VERTEX." )
return()
elseif( ARG_FRAGMENT AND ARG_COMPUTE )
message( SEND_ERROR "add_shader cannot be called with both FRAGMENT and COMPUTE." )
return()
elseif( ARG_VERTEX AND ARG_COMPUTE )
message( SEND_ERROR "add_shader cannot be called with both VERTEX and COMPUTE." )
return()
endif()
if( ARG_FRAGMENT )
set( TYPE "FRAGMENT" )
set( D3D_PREFIX "ps" )
elseif( ARG_VERTEX )
set( TYPE "VERTEX" )
set( D3D_PREFIX "vs" )
elseif( ARG_COMPUTE )
set( TYPE "COMPUTE" )
set( D3D_PREFIX "cs" )
else()
message( SEND_ERROR "add_shader must be called with either FRAGMENT or VERTEX or COMPUTE." )
return()
endif()
# Determine compatible platforms
if( ARG_PLATFORMS )
set( PLATFORMS ${ARG_PLATFORMS} )
else()
if( MSVC )
set( PLATFORMS dx9 dx11 glsl essl asm.js spirv )
elseif( APPLE )
set( PLATFORMS metal glsl essl asm.js spirv )
else()
set( PLATFORMS glsl essl asm.js spirv )
endif()
endif()
# Build options
set( BASE_OPTIONS
FILE ${ARG_FILE}
${TYPE}
INCLUDES ${BGFX_DIR}/src
)
# Parse profiles
set( DX9_PROFILE PROFILE ${D3D_PREFIX}_3_0 )
if( ARG_DX9_MODEL )
set( DX9_PROFILE PROFILE ${D3D_PREFIX}_${ARG_DX9_MODEL} )
endif()
set( DX11_PROFILE PROFILE ${D3D_PREFIX}_5_0 )
if( ARG_DX11_MODEL )
set( DX11_PROFILE PROFILE ${D3D_PREFIX}_${ARG_DX11_MODEL} )
endif()
set( GLSL_PROFILE PROFILE 120 )
if( ARG_COMPUTE )
set( GLSL_PROFILE PROFILE 430 )
endif()
if( ARG_GLSL_VERSION )
set( GLSL_PROFILE PROFILE ${ARG_GLSL_VERSION} )
endif()
set( SPIRV_PROFILE PROFILE spirv )
# Add commands
set( OUTPUTS "" )
set( COMMANDS "" )
foreach( PLATFORM ${PLATFORMS} )
set( OPTIONS ${BASE_OPTIONS} )
set( OUTPUT "${ARG_OUTPUT}/${PLATFORM}/${FILENAME}.bin" )
get_filename_component( OUTPUT "${OUTPUT}" ABSOLUTE )
if( "${PLATFORM}" STREQUAL "dx9" )
list( APPEND OPTIONS
WINDOWS
${DX9_PROFILE}
OUTPUT ${OUTPUT}
)
elseif( "${PLATFORM}" STREQUAL "dx11" )
list( APPEND OPTIONS
WINDOWS
${DX11_PROFILE}
OUTPUT ${OUTPUT}
)
elseif( "${PLATFORM}" STREQUAL "metal" )
list( APPEND OPTIONS
OSX
PROFILE metal
OUTPUT ${OUTPUT}
)
elseif( "${PLATFORM}" STREQUAL "glsl" )
list( APPEND OPTIONS
LINUX
${GLSL_PROFILE}
OUTPUT ${OUTPUT}
)
elseif( "${PLATFORM}" STREQUAL "essl" )
list( APPEND OPTIONS
ANDROID
OUTPUT ${OUTPUT}
)
elseif( "${PLATFORM}" STREQUAL "asm.js" )
list( APPEND OPTIONS
ASM_JS
OUTPUT ${OUTPUT}
)
elseif( "${PLATFORM}" STREQUAL "spirv" )
list( APPEND OPTIONS
LINUX
${SPIRV_PROFILE}
OUTPUT ${OUTPUT}
)
else()
message( SEND_ERROR "add_shader given bad platform: ${PLATFORM}" )
return()
endif()
list( APPEND OUTPUTS ${OUTPUT} )
shaderc_parse( CMD ${OPTIONS} )
list( APPEND COMMANDS COMMAND "${CMAKE_COMMAND}" -E make_directory "${ARG_OUTPUT}/${PLATFORM}" )
list( APPEND COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${CMD} )
endforeach()
# Add command
add_custom_command(
MAIN_DEPENDENCY
${ARG_FILE}
OUTPUT
${OUTPUTS}
${COMMANDS}
COMMENT "Compiling shader ${ARG_FILE}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
# Add to custom filter
source_group( "Shader Files" FILES ${ARG_FILE} )
endfunction()
# shaderc( FILE file OUTPUT file ... )
# See shaderc_parse() below for inputs
function( shaderc )
cmake_parse_arguments( ARG "" "FILE;OUTPUT;LABEL" "" ${ARGN} )
set( LABEL "" )
if( ARG_LABEL )
set( LABEL " (${ARG_LABEL})" )
endif()
shaderc_parse( CLI FILE ${ARG_FILE} OUTPUT ${ARG_OUTPUT} ${ARG_UNPARSED_ARGUMENTS} )
get_filename_component( OUTDIR "${ARG_OUTPUT}" ABSOLUTE )
get_filename_component( OUTDIR "${OUTDIR}" DIRECTORY )
add_custom_command( OUTPUT ${ARG_OUTPUT}
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUTDIR}"
COMMAND "$<TARGET_FILE:shaderc>" ${CLI}
MAIN_DEPENDENCY ${ARG_FILE}
COMMENT "Compiling shader ${ARG_FILE}${LABEL}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
endfunction()
# shaderc_parse(
# FILE filename
# OUTPUT filename
# FRAGMENT|VERTEX|COMPUTE
# ANDROID|ASM_JS|IOS|LINUX|NACL|OSX|WINDOWS
# [PROFILE profile]
# [O 0|1|2|3]
# [VARYINGDEF filename]
# [BIN2C filename]
# [INCLUDES include;include]
# [DEFINES include;include]
# [DEPENDS]
# [PREPROCESS]
# [RAW]
# [VERBOSE]
# [DEBUG]
# [DISASM]
# [WERROR]
# )
function( 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" "FILE;OUTPUT;VARYINGDEF;BIN2C;PROFILE;O" "INCLUDES;DEFINES" ${ARGN} )
set( CLI "" )
# -f
if( ARG_FILE )
list( APPEND CLI "-f" "${ARG_FILE}" )
endif()
# -i
if( ARG_INCLUDES )
foreach( INCLUDE ${ARG_INCLUDES} )
list( APPEND CLI "-i" )
list( APPEND CLI "${INCLUDE}" )
endforeach()
endif()
# -o
if( ARG_OUTPUT )
list( APPEND CLI "-o" "${ARG_OUTPUT}" )
endif()
# --bin2c
if( ARG_BIN2C )
list( APPEND CLI "--bin2c" "${ARG_BIN2C}" )
endif()
# --depends
if( ARG_DEPENDS )
list( APPEND CLI "--depends" )
endif()
# --platform
set( PLATFORM "" )
set( PLATFORMS "ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS" )
foreach( P ${PLATFORMS} )
if( ARG_${P} )
if( PLATFORM )
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${PLATFORM} and ${P}." )
return()
endif()
set( PLATFORM "${P}" )
endif()
endforeach()
if( "${PLATFORM}" STREQUAL "" )
message( SEND_ERROR "Call to shaderc_parse() must have a platform flag: ${PLATFORMS}" )
return()
elseif( "${PLATFORM}" STREQUAL "ANDROID" )
list( APPEND CLI "--platform" "android" )
elseif( "${PLATFORM}" STREQUAL "ASM_JS" )
list( APPEND CLI "--platform" "asm.js" )
elseif( "${PLATFORM}" STREQUAL "IOS" )
list( APPEND CLI "--platform" "ios" )
elseif( "${PLATFORM}" STREQUAL "LINUX" )
list( APPEND CLI "--platform" "linux" )
elseif( "${PLATFORM}" STREQUAL "NACL" )
list( APPEND CLI "--platform" "nacl" )
elseif( "${PLATFORM}" STREQUAL "OSX" )
list( APPEND CLI "--platform" "osx" )
elseif( "${PLATFORM}" STREQUAL "WINDOWS" )
list( APPEND CLI "--platform" "windows" )
endif()
# --preprocess
if( ARG_PREPROCESS )
list( APPEND CLI "--preprocess" )
endif()
# --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}" )
endif()
# --raw
if( ARG_RAW )
list( APPEND CLI "--raw" )
endif()
# --type
set( TYPE "" )
set( TYPES "FRAGMENT;VERTEX;COMPUTE" )
foreach( T ${TYPES} )
if( ARG_${T} )
if( TYPE )
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${TYPE} and ${T}." )
return()
endif()
set( TYPE "${T}" )
endif()
endforeach()
if( "${TYPE}" STREQUAL "" )
message( SEND_ERROR "Call to shaderc_parse() must have a type flag: ${TYPES}" )
return()
elseif( "${TYPE}" STREQUAL "FRAGMENT" )
list( APPEND CLI "--type" "fragment" )
elseif( "${TYPE}" STREQUAL "VERTEX" )
list( APPEND CLI "--type" "vertex" )
elseif( "${TYPE}" STREQUAL "COMPUTE" )
list( APPEND CLI "--type" "compute" )
endif()
# --varyingdef
if( ARG_VARYINGDEF )
list( APPEND CLI "--varyingdef" "${ARG_VARYINGDEF}" )
endif()
# --verbose
if( ARG_VERBOSE )
list( APPEND CLI "--verbose" )
endif()
# --debug
if( ARG_DEBUG )
list( APPEND CLI "--debug" )
endif()
# --disasm
if( ARG_DISASM )
list( APPEND CLI "--disasm" )
endif()
# --profile
if( ARG_PROFILE )
list( APPEND CLI "--profile" "${ARG_PROFILE}" )
endif()
# -O
if( ARG_O )
list( APPEND CLI "-O" "${ARG_O}" )
endif()
# --Werror
if( ARG_WERROR )
list( APPEND CLI "--Werror" )
endif()
set( ${ARG_OUT} ${CLI} PARENT_SCOPE )
endfunction()

View File

@@ -13,6 +13,9 @@ include( CMakeParseArguments )
add_executable( texturev ${BGFX_DIR}/tools/texturev/texturev.cpp )
set_target_properties( texturev PROPERTIES FOLDER "bgfx/tools" )
target_link_libraries( texturev example-common )
if (EMSCRIPTEN)
target_link_options( texturev PRIVATE -sMAX_WEBGL_VERSION=2 )
endif()
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools texturev )
endif()
@@ -20,4 +23,4 @@ endif()
if (IOS)
set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER texturev)
endif()
endif()