diff --git a/.gitattributes b/.gitattributes index dde21f78733..11d91b35b01 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,6 @@ +* -text *.bin binary diff=hex + *.c eol=lf *.cpp eol=lf *.h eol=lf diff --git a/.github/workflows/lwjgl.yml b/.github/workflows/lwjgl.yml new file mode 100644 index 00000000000..9e2d5c65ed0 --- /dev/null +++ b/.github/workflows/lwjgl.yml @@ -0,0 +1,386 @@ +name: LWJGL Build + +on: + workflow_dispatch: + push: + branches: + - master + +env: + AWS_DEFAULT_REGION: us-east-1 + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + S3_PARAMS: --cache-control "public,must-revalidate,proxy-revalidate,max-age=0" + +jobs: + linux: + name: Linux + runs-on: ubuntu-latest + container: + image: centos:7 + strategy: + fail-fast: false + matrix: + ARCH: [x64] + include: + - ARCH: x64 + PACKAGES: mesa-libGL-devel xorg-x11-proto-devel libX11-devel + OUTPUT_DIR: linux64_gcc + env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true + LWJGL_ARCH: ${{matrix.ARCH}} + defaults: + run: + shell: bash + steps: + - name: Upgrade git + run: | + sed -i \ + -e 's/^mirrorlist/#mirrorlist/' \ + -e 's/^#baseurl/baseurl/' \ + -e 's/mirror\.centos\.org/vault.centos.org/' \ + /etc/yum.repos.d/*.repo + yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm + yum -y install git + - uses: actions/checkout@v3 + with: + fetch-depth: 3 + - name: Configure yum + run: | + yum -y install epel-release + yum -y update + - name: Install build dependencies + run: | + yum -y install centos-release-scl + sed -i \ + -e 's/^mirrorlist/#mirrorlist/' \ + -e 's/^#baseurl/baseurl/' \ + -e 's/^# baseurl/baseurl/' \ + -e 's/mirror\.centos\.org/vault.centos.org/' \ + /etc/yum.repos.d/CentOS-SCLo-scl*.repo + yum -y install devtoolset-11-gcc-c++ + yum -y install awscli + - name: Clone bx & bimg + run: | + git clone https://github.com/LWJGL-CI/bx.git ../bx + git clone https://github.com/LWJGL-CI/bimg.git ../bimg + - name: Clone and build GENie + run: | + source scl_source enable devtoolset-11 || true + git clone https://github.com/bkaradzic/GENie.git ../GENie + cd ../GENie + make + - name: Install bgfx dependencies + run: | + yum -y install ${{matrix.PACKAGES}} + - name: Build + run: | #sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so + source scl_source enable devtoolset-11 || true + ../GENie/bin/linux/genie --with-shared-lib --with-tools --gcc=linux-gcc gmake + make -R -C .build/projects/gmake-linux-gcc config=release64 CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0" bgfx-shared-lib + strip .build/linux64_gcc/bin/libbgfx-shared-libRelease.so + - name: Build geometryc + run: | + source scl_source enable devtoolset-11 || true + make -R -C .build/projects/gmake-linux-gcc config=release64 geometryc + - name: Build texturec + run: | + source scl_source enable devtoolset-11 || true + make -R -C .build/projects/gmake-linux-gcc config=release64 texturec + - name: Build texturev + run: | + source scl_source enable devtoolset-11 || true + make -R -C .build/projects/gmake-linux-gcc config=release64 texturev + - name: Build shaderc + run: | + source scl_source enable devtoolset-11 || true + make -R -C .build/projects/gmake-linux-gcc config=release64 shaderc + - name: Upload artifact + run: aws s3 cp .build/${{matrix.OUTPUT_DIR}}/bin/libbgfx-shared-libRelease.so s3://lwjgl-build/nightly/linux/${{matrix.ARCH}}/libbgfx.so ${{env.S3_PARAMS}} + - name: Upload tools + run: | + aws s3 cp .build/linux64_gcc/bin/geometrycRelease s3://lwjgl-build/nightly/linux/x64/bgfx-tools/geometryc ${{env.S3_PARAMS}} + aws s3 cp .build/linux64_gcc/bin/texturecRelease s3://lwjgl-build/nightly/linux/x64/bgfx-tools/texturec ${{env.S3_PARAMS}} + aws s3 cp .build/linux64_gcc/bin/texturevRelease s3://lwjgl-build/nightly/linux/x64/bgfx-tools/texturev ${{env.S3_PARAMS}} + aws s3 cp .build/linux64_gcc/bin/shadercRelease s3://lwjgl-build/nightly/linux/x64/bgfx-tools/shaderc ${{env.S3_PARAMS}} + - name: Upload git revision + run: | + git config --global --add safe.directory $PWD + git log --first-parent --pretty=format:%H HEAD~2..HEAD~1 > libbgfx.so.git + aws s3 cp libbgfx.so.git s3://lwjgl-build/nightly/linux/${{matrix.ARCH}}/ ${{env.S3_PARAMS}} + + linux-cross: + name: Linux Cross + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + ARCH: [arm32, arm64, ppc64le, riscv64] + include: + # ----- + - ARCH: arm32 + CROSS_ARCH: armhf + TRIPLET: arm-linux-gnueabihf + FLAVOR: linux-arm-gcc + # ----- + - ARCH: arm64 + CROSS_ARCH: arm64 + TRIPLET: aarch64-linux-gnu + FLAVOR: linux-arm-gcc + # ----- + - ARCH: ppc64le + CROSS_ARCH: ppc64el + TRIPLET: powerpc64le-linux-gnu + FLAVOR: linux-ppc64le-gcc + # ----- + - ARCH: riscv64 + CROSS_ARCH: riscv64 + TRIPLET: riscv64-linux-gnu + FLAVOR: linux-riscv64-gcc + env: + LWJGL_ARCH: ${{matrix.ARCH}} + MATRIX_FLAVOR: ${{matrix.FLAVOR}} + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 3 + - name: Install dependencies + run: | + DEBIAN_FRONTEND=noninteractive sudo apt-get -yq update + DEBIAN_FRONTEND=noninteractive sudo apt-get -yq install cmake gcc-${{matrix.TRIPLET}} g++-${{matrix.TRIPLET}} libc6-dev-${{matrix.CROSS_ARCH}}-cross + - name: Clone bx & bimg + run: | + git clone https://github.com/LWJGL-CI/bx.git ../bx --depth=1 + git clone https://github.com/LWJGL-CI/bimg.git ../bimg --depth=1 + - name: Clone and build GENie + run: | + git clone https://github.com/bkaradzic/GENie.git ../GENie + cd ../GENie + make + - name: Prepare cross-compilation for ${{matrix.CROSS_ARCH}} + run: | + sudo sed -i 's/deb mirror/deb [arch=amd64,i386] mirror/' /etc/apt/sources.list + sudo grep "mirror+file" /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/ports.list + sudo sed -i 's/amd64,i386/${{matrix.CROSS_ARCH}}/' /etc/apt/sources.list.d/ports.list + sudo sed -i 's#mirror+file:/etc/apt/apt-mirrors.txt#http://ports.ubuntu.com/ubuntu-ports/#' /etc/apt/sources.list.d/ports.list + sudo dpkg --add-architecture ${{matrix.CROSS_ARCH}} + sudo apt-get update || true + - name: Install cross-compilation dependencies + run: sudo apt-get -yq --allow-unauthenticated --no-install-suggests --no-install-recommends install libgl1-mesa-dev:${{matrix.CROSS_ARCH}} x11proto-dev:${{matrix.CROSS_ARCH}} libx11-dev:${{matrix.CROSS_ARCH}} -o Dpkg::Options::="--force-overwrite" + - name: Build bgfx for ${{matrix.CROSS_ARCH}} + run: | + sed -i 's/strip -s/${{matrix.TRIPLET}}-strip/' ../bx/scripts/toolchain.lua + ../GENie/bin/linux/genie --with-shared-lib --gcc=${{matrix.FLAVOR}} gmake + make -R -C .build/projects/gmake-${{matrix.FLAVOR}} config=release CXX="${{matrix.TRIPLET}}-g++" CC="${{matrix.TRIPLET}}-gcc" CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0" bgfx-shared-lib + ${{matrix.TRIPLET}}-strip .build/${MATRIX_FLAVOR//-/_}/bin/libbgfx-shared-libRelease.so + - name: Upload artifact + run: aws s3 cp .build/${MATRIX_FLAVOR//-/_}/bin/libbgfx-shared-libRelease.so s3://lwjgl-build/nightly/linux/${{matrix.ARCH}}/libbgfx.so ${{env.S3_PARAMS}} + - name: Upload git revision + run: | + git config --global --add safe.directory $(pwd) + git log --first-parent --pretty=format:%H HEAD~2..HEAD~1 > libbgfx.so.git + aws s3 cp libbgfx.so.git s3://lwjgl-build/nightly/linux/${{matrix.ARCH}}/ ${{env.S3_PARAMS}} + + freebsd-cross: + name: FreeBSD Cross + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 3 + - name: Clone bx, bimg & GENie + run: | + git clone https://github.com/LWJGL-CI/bx.git ../bx + git clone https://github.com/LWJGL-CI/bimg.git ../bimg + git clone https://github.com/LWJGL-CI/GENie.git ../GENie + - name: Build + uses: cross-platform-actions/action@v0.24.0 + with: + operating_system: freebsd + architecture: x86-64 + version: '13.2' + memory: 4G + shell: bash + run: | + echo ------------------------- + echo Install bgfx dependencies + echo ------------------------- + sudo pkg install -y gmake gcc mesa-devel mesa-libs x11/libX11 libglvnd + echo "" + echo ------------------------- + echo Build GENie + echo ------------------------- + cd ../GENie + gmake + echo "" + echo ------------------------- + echo Build + echo ------------------------- + cd ../bgfx + ../GENie/bin/bsd/genie --with-shared-lib --with-tools --gcc=freebsd gmake + gmake -R -C .build/projects/gmake-freebsd config=release64 CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0" bgfx-shared-lib + strip .build/freebsd/bin/libbgfx-shared-libRelease.so + echo "" + echo ------------------------- + echo Build geometryc + echo ------------------------- + gmake -R -C .build/projects/gmake-freebsd config=release64 geometryc + echo "" + echo ------------------------- + echo Build texturec + echo ------------------------- + gmake -R -C .build/projects/gmake-freebsd config=release64 texturec + echo "" + echo ------------------------- + echo Build texturev + echo ------------------------- + gmake -R -C .build/projects/gmake-freebsd config=release64 texturev + echo "" + echo ------------------------- + echo Build shaderc + echo ------------------------- + gmake -R -C .build/projects/gmake-freebsd config=release64 shaderc + - name: Upload artifact + run: aws s3 cp .build/freebsd/bin/libbgfx-shared-libRelease.so s3://lwjgl-build/nightly/freebsd/x64/libbgfx.so ${{env.S3_PARAMS}} + - name: Upload tools + run: | + aws s3 cp .build/freebsd/bin/geometrycRelease s3://lwjgl-build/nightly/freebsd/x64/bgfx-tools/geometryc ${{env.S3_PARAMS}} + aws s3 cp .build/freebsd/bin/texturecRelease s3://lwjgl-build/nightly/freebsd/x64/bgfx-tools/texturec ${{env.S3_PARAMS}} + aws s3 cp .build/freebsd/bin/texturevRelease s3://lwjgl-build/nightly/freebsd/x64/bgfx-tools/texturev ${{env.S3_PARAMS}} + aws s3 cp .build/freebsd/bin/shadercRelease s3://lwjgl-build/nightly/freebsd/x64/bgfx-tools/shaderc ${{env.S3_PARAMS}} + - name: Upload git revision + run: | + git config --global --add safe.directory $PWD + git log --first-parent --pretty=format:%H HEAD~2..HEAD~1 > libbgfx.so.git + aws s3 cp libbgfx.so.git s3://lwjgl-build/nightly/freebsd/x64/ ${{env.S3_PARAMS}} + + macos: + name: macOS + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + ARCH: [x64, arm64] + include: + - ARCH: x64 + PLATFORM: osx-x64 + GENIE_PARAMS: --with-macos=10.11 + CC: MACOSX_DEPLOYMENT_TARGET=10.11 CFLAGS=-mmacosx-version-min=10.11 LDFLAGS=-mmacosx-version-min=10.11 + GENIE_PARAMS_TOOL: --with-macos=10.15 + CC_TOOL: MACOSX_DEPLOYMENT_TARGET=10.15 CFLAGS=-mmacosx-version-min=10.15 LDFLAGS=-mmacosx-version-min=10.15 + - ARCH: arm64 + PLATFORM: osx-arm64 + GENIE_PARAMS: --with-macos=11.0 + CC: MACOSX_DEPLOYMENT_TARGET=11.0 CFLAGS=-mmacosx-version-min=11.0 LDFLAGS=-mmacosx-version-min=11.0 + GENIE_PARAMS_TOOL: --with-macos=11.0 + CC_TOOL: MACOSX_DEPLOYMENT_TARGET=11.0 CFLAGS=-mmacosx-version-min=11.0 LDFLAGS=-mmacosx-version-min=11.0 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 3 + - name: Clone bx & bimg + run: | + git clone https://github.com/LWJGL-CI/bx.git ../bx + git clone https://github.com/LWJGL-CI/bimg.git ../bimg + - name: Configure bgfx + run: ${{matrix.CC}} ../bx/tools/bin/darwin/genie --with-shared-lib --with-tools ${{matrix.GENIE_PARAMS}} --gcc=${{matrix.PLATFORM}} gmake + - name: Build bgfx + run: | + ${{matrix.CC}} make -C .build/projects/gmake-${{matrix.PLATFORM}} config=release64 CFLAGS="-D BGFX_CONFIG_RENDERER_METAL=1 -D BGFX_CONFIG_RENDERER_OPENGL=1" bgfx-shared-lib + strip -u -r .build/${{matrix.PLATFORM}}/bin/libbgfx-shared-libRelease.dylib + - name: Configure tools + run: ${{matrix.CC_TOOL}} ../bx/tools/bin/darwin/genie --with-shared-lib --with-tools ${{matrix.GENIE_PARAMS_TOOL}} --gcc=${{matrix.PLATFORM}} gmake + - name: Build geometryc + run: ${{matrix.CC_TOOL}} make -C .build/projects/gmake-${{matrix.PLATFORM}} config=release64 geometryc + - name: Build texturec + run: ${{matrix.CC_TOOL}} make -C .build/projects/gmake-${{matrix.PLATFORM}} config=release64 texturec + - name: Build texturev + run: ${{matrix.CC_TOOL}} make -C .build/projects/gmake-${{matrix.PLATFORM}} config=release64 texturev + - name: Build shaderc + run: ${{matrix.CC_TOOL}} make -C .build/projects/gmake-${{matrix.PLATFORM}} config=release64 shaderc + - name: Upload artifacts + run: | + aws s3 cp .build/${{matrix.PLATFORM}}/bin/libbgfx-shared-libRelease.dylib s3://lwjgl-build/nightly/macosx/${{matrix.ARCH}}/libbgfx.dylib ${{env.S3_PARAMS}} + aws s3 cp .build/${{matrix.PLATFORM}}/bin/geometrycRelease s3://lwjgl-build/nightly/macosx/${{matrix.ARCH}}/bgfx-tools/geometryc ${{env.S3_PARAMS}} + aws s3 cp .build/${{matrix.PLATFORM}}/bin/texturecRelease s3://lwjgl-build/nightly/macosx/${{matrix.ARCH}}/bgfx-tools/texturec ${{env.S3_PARAMS}} + aws s3 cp .build/${{matrix.PLATFORM}}/bin/texturevRelease s3://lwjgl-build/nightly/macosx/${{matrix.ARCH}}/bgfx-tools/texturev ${{env.S3_PARAMS}} + aws s3 cp .build/${{matrix.PLATFORM}}/bin/shadercRelease s3://lwjgl-build/nightly/macosx/${{matrix.ARCH}}/bgfx-tools/shaderc ${{env.S3_PARAMS}} + - name: Upload git revision + run: | + git log --first-parent --pretty=format:%H HEAD~2..HEAD~1 > libbgfx.dylib.git + aws s3 cp libbgfx.dylib.git s3://lwjgl-build/nightly/macosx/${{matrix.ARCH}}/ ${{env.S3_PARAMS}} + + windows: + name: Windows + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + ARCH: [x86, x64] + include: + - ARCH: x86 + MSVC_ARCH: amd64_x86 + PLATFORM: x32 + BUILD: Win32 + OUTPUT_DIR: win32_vs2022 + - ARCH: x64 + MSVC_ARCH: amd64 + PLATFORM: x64 + BUILD: x64 + OUTPUT_DIR: win64_vs2022 +# - ARCH: arm64 +# MSVC_ARCH: amd64_arm64 +# PLATFORM: arm64 +# BUILD: arm64 +# OUTPUT_DIR: win64_vs2022 + defaults: + run: + shell: cmd + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 3 + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.MSVC_ARCH }} + - name: Clone bx & bimg + run: | + git clone https://github.com/LWJGL-CI/bx.git ../bx + git clone https://github.com/LWJGL-CI/bimg.git ../bimg + - name: Configure build + run: ..\bx\tools\bin\windows\genie --with-shared-lib --with-tools vs2022 --platform ${{matrix.PLATFORM}} + - name: Switch to ClangCL for x64 build + run: | + (Get-Content .build/projects/vs2022/bgfx-shared-lib.vcxproj) -replace 'v143', 'ClangCL' | Out-File -encoding UTF8 .build/projects/vs2022/bgfx-shared-lib.vcxproj + (Get-Content .build/projects/vs2022/geometryc.vcxproj) -replace 'v143', 'ClangCL' | Out-File -encoding UTF8 .build/projects/vs2022/geometryc.vcxproj + (Get-Content .build/projects/vs2022/texturec.vcxproj) -replace 'v143', 'ClangCL' | Out-File -encoding UTF8 .build/projects/vs2022/texturec.vcxproj + (Get-Content .build/projects/vs2022/texturev.vcxproj) -replace 'v143', 'ClangCL' | Out-File -encoding UTF8 .build/projects/vs2022/texturev.vcxproj + (Get-Content .build/projects/vs2022/shaderc.vcxproj) -replace 'v143', 'ClangCL' | Out-File -encoding UTF8 .build/projects/vs2022/shaderc.vcxproj + shell: pwsh + if: ${{ matrix.ARCH == 'x64' }} + - name: Build bgfx + run: devenv .build\projects\vs2022\bgfx.sln /Project bgfx-shared-lib /Build "Release|${{matrix.BUILD}}" + - name: Build geometryc + run: devenv .build\projects\vs2022\bgfx.sln /Project geometryc /Build "Release|${{matrix.BUILD}}" + - name: Build texturec + run: devenv .build\projects\vs2022\bgfx.sln /Project texturec /Build "Release|${{matrix.BUILD}}" + - name: Build texturev + run: devenv .build\projects\vs2022\bgfx.sln /Project texturev /Build "Release|${{matrix.BUILD}}" + - name: Build shaderc + run: devenv .build\projects\vs2022\bgfx.sln /Project "shaderc (tools\shaderc\shaderc)" /Build "Release|${{matrix.BUILD}}" + - name: Upload artifacts + run: | + aws s3 cp .build/${{matrix.OUTPUT_DIR}}/bin/bgfx-shared-libRelease.dll s3://lwjgl-build/nightly/windows/${{matrix.ARCH}}/bgfx.dll ${{env.S3_PARAMS}} + aws s3 cp .build/${{matrix.OUTPUT_DIR}}/bin/geometrycRelease.exe s3://lwjgl-build/nightly/windows/${{matrix.ARCH}}/bgfx-tools/geometryc.exe ${{env.S3_PARAMS}} + aws s3 cp .build/${{matrix.OUTPUT_DIR}}/bin/texturecRelease.exe s3://lwjgl-build/nightly/windows/${{matrix.ARCH}}/bgfx-tools/texturec.exe ${{env.S3_PARAMS}} + aws s3 cp .build/${{matrix.OUTPUT_DIR}}/bin/texturevRelease.exe s3://lwjgl-build/nightly/windows/${{matrix.ARCH}}/bgfx-tools/texturev.exe ${{env.S3_PARAMS}} + aws s3 cp .build/${{matrix.OUTPUT_DIR}}/bin/shadercRelease.exe s3://lwjgl-build/nightly/windows/${{matrix.ARCH}}/bgfx-tools/shaderc.exe ${{env.S3_PARAMS}} + - name: Upload git revision + run: | + git log --first-parent --pretty=format:%%H HEAD~2..HEAD~1 > bgfx.dll.git + aws s3 cp bgfx.dll.git s3://lwjgl-build/nightly/windows/${{matrix.ARCH}}/ ${{env.S3_PARAMS}} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 1e6d5e1a76b..00000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,211 +0,0 @@ -name: CI - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - -on: - push: - pull_request: - -jobs: - msvc: - strategy: - fail-fast: true - matrix: - include: [ - { config: Debug, platform: Win32, bindir: 'win32_vs2019' }, - { config: Debug, platform: x64, bindir: 'win64_vs2019' }, - { config: Release, platform: Win32, bindir: 'win32_vs2019' }, - { config: Release, platform: x64, bindir: 'win64_vs2019' }, - ] - name: msvc-${{ matrix.config }}-${{ matrix.platform }} - runs-on: windows-2022 - steps: - - name: Checkout bgfx - uses: actions/checkout@v4 - with: - path: bgfx - - name: Checkout bx - uses: actions/checkout@v4 - with: - repository: bkaradzic/bx - path: bx - - name: Checkout bimg - uses: actions/checkout@v4 - with: - repository: bkaradzic/bimg - path: bimg - - name: Prepare - uses: microsoft/setup-msbuild@v1.1 - - name: Build - shell: cmd - run: | - cd bgfx - ..\bx\tools\bin\windows\genie.exe --with-tools --with-combined-examples --with-shared-lib vs2019 - msbuild ".build/projects/vs2019/bgfx.sln" /m /v:minimal /p:Configuration=${{ matrix.config }} /p:Platform=${{ matrix.platform }} - - name: Check - shell: cmd - run: | - cd bgfx - dir /s ".build\${{ matrix.bindir }}\bin" - ".build\${{ matrix.bindir }}\bin\geometryc${{ matrix.config }}.exe" --version - ".build\${{ matrix.bindir }}\bin\shaderc${{ matrix.config }}.exe" --version - ".build\${{ matrix.bindir }}\bin\texturec${{ matrix.config }}.exe" --version - mingw: - strategy: - fail-fast: true - matrix: - include: [ - { msystem: MINGW64, project: 'mingw-gcc', bindir: 'win64_mingw-gcc' }, -# { msystem: CLANG64, project: 'mingw-clang', bindir: 'win64_mingw-clang' }, - ] - name: mingw-${{ matrix.msystem }} - runs-on: windows-2022 - steps: - - name: Checkout bgfx - uses: actions/checkout@v4 - with: - path: bgfx - - name: Checkout bx - uses: actions/checkout@v4 - with: - repository: bkaradzic/bx - path: bx - - name: Checkout bimg - uses: actions/checkout@v4 - with: - repository: bkaradzic/bimg - path: bimg - - name: Prepare - uses: msys2/setup-msys2@v2 - with: - msystem: ${{ matrix.msystem }} - update: true - install: make - pacboy: cc:p - - name: Build - shell: msys2 {0} - run: | - cd bgfx - make ${{ matrix.project }}-release64 -j$(nproc) AR=ar CC=cc CXX=c++ MINGW=$MINGW_PREFIX - - name: Check - shell: cmd - run: | - cd bgfx - dir /s ".build\${{ matrix.bindir }}\bin" - ".build\${{ matrix.bindir }}\bin\geometrycRelease.exe" --version - ".build\${{ matrix.bindir }}\bin\shadercRelease.exe" --version - ".build\${{ matrix.bindir }}\bin\texturecRelease.exe" --version - linux: - strategy: - fail-fast: true - matrix: - include: [ - { config: debug, binsuffix: Debug }, - { config: release, binsuffix: Release }, - ] - name: linux-gcc-${{ matrix.config }}64 - runs-on: ubuntu-24.04 - steps: - - name: Checkout bgfx - uses: actions/checkout@v4 - with: - path: bgfx - - name: Checkout bx - uses: actions/checkout@v4 - with: - repository: bkaradzic/bx - path: bx - - name: Checkout bimg - uses: actions/checkout@v4 - with: - repository: bkaradzic/bimg - path: bimg - - name: Build - run: | - sudo apt install libgl-dev - cd bgfx - make -j$(nproc) linux-gcc-${{ matrix.config }}64 - - name: Check - run: | - cd bgfx - ls -lash ".build/linux64_gcc/bin" - ".build/linux64_gcc/bin/geometryc${{ matrix.binsuffix}}" --version - ".build/linux64_gcc/bin/shaderc${{ matrix.binsuffix}}" --version - ".build/linux64_gcc/bin/texturec${{ matrix.binsuffix}}" --version - osx: - strategy: - fail-fast: true - matrix: - include: [ - { config: debug, binsuffix: Debug }, - { config: release, binsuffix: Release }, - ] - name: osx-x64-${{ matrix.config }} - runs-on: macos-14 - steps: - - name: Checkout bgfx - uses: actions/checkout@v4 - with: - path: bgfx - - name: Checkout bx - uses: actions/checkout@v4 - with: - repository: bkaradzic/bx - path: bx - - name: Checkout bimg - uses: actions/checkout@v4 - with: - repository: bkaradzic/bimg - path: bimg - - name: Build - run: | - cd bgfx - make -j$(sysctl -n hw.physicalcpu) osx-x64-${{ matrix.config }} - - name: Check - run: | - cd bgfx - ls -lash ".build/osx-x64/bin" - ".build/osx-x64/bin/geometryc${{ matrix.binsuffix}}" --version - ".build/osx-x64/bin/shaderc${{ matrix.binsuffix}}" --version - ".build/osx-x64/bin/texturec${{ matrix.binsuffix}}" --version - android: - strategy: - fail-fast: true - matrix: - include: [ - { platform: arm64 }, - ] - name: android-${{ matrix.platform }} - runs-on: ubuntu-24.04 - steps: - - uses: nttld/setup-ndk@v1 - id: setup-ndk - with: - ndk-version: r25b - add-to-path: false - - name: Checkout bgfx - uses: actions/checkout@v4 - with: - path: bgfx - - name: Checkout bx - uses: actions/checkout@v4 - with: - repository: bkaradzic/bx - path: bx - - name: Checkout bimg - uses: actions/checkout@v4 - with: - repository: bkaradzic/bimg - path: bimg - - name: Build - run: | - cd bgfx - make -j$(sysctl -n hw.physicalcpu) android-${{ matrix.platform }} - env: - ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }} - - name: Check - run: | - cd bgfx - ls -lash ".build/android-${{ matrix.platform }}/bin" diff --git a/3rdparty/dear-imgui/imgui_demo.cpp b/3rdparty/dear-imgui/imgui_demo.cpp index 5849e11ef9e..0acba72c0bc 100644 --- a/3rdparty/dear-imgui/imgui_demo.cpp +++ b/3rdparty/dear-imgui/imgui_demo.cpp @@ -7734,6 +7734,9 @@ void ImGui::ShowAboutWindow(bool* p_open) #ifdef __linux__ ImGui::Text("define: __linux__"); #endif +#ifdef __FreeBSD__ + ImGui::Text("define: __FreeBSD__"); +#endif #ifdef __APPLE__ ImGui::Text("define: __APPLE__"); #endif diff --git a/3rdparty/glsl-optimizer/src/mesa/main/compiler.h b/3rdparty/glsl-optimizer/src/mesa/main/compiler.h index ce85e8f1f75..5e926640d34 100644 --- a/3rdparty/glsl-optimizer/src/mesa/main/compiler.h +++ b/3rdparty/glsl-optimizer/src/mesa/main/compiler.h @@ -144,7 +144,7 @@ extern "C" { * For now, only used by some DRI hardware drivers for color/texel packing. */ #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN -#if defined(__linux__) +#if defined(__linux__) || defined(__FreeBSD__) #include #define CPU_TO_LE32( x ) bswap_32( x ) #elif defined(__APPLE__) diff --git a/3rdparty/renderdoc/renderdoc_app.h b/3rdparty/renderdoc/renderdoc_app.h index 402dd3d4a47..8468bfe3c1d 100644 --- a/3rdparty/renderdoc/renderdoc_app.h +++ b/3rdparty/renderdoc/renderdoc_app.h @@ -35,7 +35,7 @@ #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) #define RENDERDOC_CC __cdecl -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) #define RENDERDOC_CC #elif defined(__APPLE__) #define RENDERDOC_CC diff --git a/examples/common/entry/dialog.cpp b/examples/common/entry/dialog.cpp index 244565c230f..075878a9985 100644 --- a/examples/common/entry/dialog.cpp +++ b/examples/common/entry/dialog.cpp @@ -134,7 +134,7 @@ bool openFileSelectionDialog( char tmp[4096]; bx::StaticMemoryBlockWriter writer(tmp, sizeof(tmp) ); -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD bx::write(&writer, &err , "--file-selection%s --title \"%.*s\" --filename \"%s\"" , FileSelectionDialogType::Save == _type ? " --save" : "" diff --git a/examples/common/entry/entry_glfw.cpp b/examples/common/entry/entry_glfw.cpp index 206bc64e53e..52e342f0236 100644 --- a/examples/common/entry/entry_glfw.cpp +++ b/examples/common/entry/entry_glfw.cpp @@ -14,7 +14,7 @@ # error "GLFW 3.4 or later is required" #endif // GLFW_VERSION_* -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD # define GLFW_EXPOSE_NATIVE_WAYLAND # define GLFW_EXPOSE_NATIVE_X11 # define GLFW_EXPOSE_NATIVE_GLX @@ -40,7 +40,7 @@ namespace entry { static void* glfwNativeWindowHandle(GLFWwindow* _window) { -# if BX_PLATFORM_LINUX +# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD if (GLFW_PLATFORM_WAYLAND == glfwGetPlatform() ) { return glfwGetWaylandWindow(_window); @@ -833,7 +833,7 @@ namespace entry void* getNativeDisplayHandle() { -# if BX_PLATFORM_LINUX +# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD if (GLFW_PLATFORM_WAYLAND == glfwGetPlatform() ) { return glfwGetWaylandDisplay(); @@ -847,7 +847,7 @@ namespace entry bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType() { -# if BX_PLATFORM_LINUX +# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD if (GLFW_PLATFORM_WAYLAND == glfwGetPlatform() ) { return bgfx::NativeWindowHandleType::Wayland; diff --git a/examples/common/entry/entry_sdl.cpp b/examples/common/entry/entry_sdl.cpp index 79a2768cf56..81f17170cb9 100644 --- a/examples/common/entry/entry_sdl.cpp +++ b/examples/common/entry/entry_sdl.cpp @@ -7,7 +7,7 @@ #if ENTRY_CONFIG_USE_SDL -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD #elif BX_PLATFORM_WINDOWS # define SDL_MAIN_HANDLED #endif @@ -45,7 +45,7 @@ namespace entry return NULL; } -# if BX_PLATFORM_LINUX +# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD if (wmi.subsystem == SDL_SYSWM_WAYLAND) { return (void*)wmi.info.wl.surface; @@ -1057,7 +1057,7 @@ namespace entry { return NULL; } -# if BX_PLATFORM_LINUX +# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD if (wmi.subsystem == SDL_SYSWM_WAYLAND) return wmi.info.wl.display; else @@ -1075,7 +1075,7 @@ namespace entry { return bgfx::NativeWindowHandleType::Default; } -# if BX_PLATFORM_LINUX +# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD if (wmi.subsystem == SDL_SYSWM_WAYLAND) { return bgfx::NativeWindowHandleType::Wayland; diff --git a/examples/common/entry/entry_x11.cpp b/examples/common/entry/entry_x11.cpp index ff858742ba4..648c77c4133 100644 --- a/examples/common/entry/entry_x11.cpp +++ b/examples/common/entry/entry_x11.cpp @@ -5,7 +5,7 @@ #include "entry_p.h" -#if ENTRY_CONFIG_USE_NATIVE && (BX_PLATFORM_LINUX || BX_PLATFORM_RPI) +#if ENTRY_CONFIG_USE_NATIVE && (BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_RPI) #define XK_MISCELLANY #define XK_LATIN1 diff --git a/examples/common/nanovg/nanovg_bgfx.cpp b/examples/common/nanovg/nanovg_bgfx.cpp index 13593b1bcb8..4485a2dfde2 100644 --- a/examples/common/nanovg/nanovg_bgfx.cpp +++ b/examples/common/nanovg/nanovg_bgfx.cpp @@ -27,12 +27,22 @@ #include "nanovg.h" #include +#include #include #include #include #include +typedef void* (*reallocPROC) (void *ptr, size_t size); +typedef void (*freePROC) (void *ptr); + +static reallocPROC org_lwjgl_realloc; +static freePROC org_lwjgl_free; + +#define NVG_REALLOC(p,sz) org_lwjgl_realloc(p,sz) +#define NVG_FREE(p) org_lwjgl_free(p) + BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4244); // warning C4244: '=' : conversion from '' to '', possible loss of data #include "vs_nanovg_fill.bin.h" @@ -191,7 +201,7 @@ namespace { int old = gl->ctextures; gl->ctextures = (gl->ctextures == 0) ? 2 : gl->ctextures*2; - gl->textures = (struct GLNVGtexture*)bx::realloc(gl->allocator, gl->textures, sizeof(struct GLNVGtexture)*gl->ctextures); + gl->textures = (struct GLNVGtexture*)NVG_REALLOC(gl->textures, sizeof(struct GLNVGtexture)*gl->ctextures); bx::memSet(&gl->textures[old], 0xff, (gl->ctextures-old)*sizeof(struct GLNVGtexture) ); if (gl->textures == NULL) @@ -425,6 +435,29 @@ namespace return c; } + static void nvgTransformIdentity(float* t) + { + t[0] = 1.0f; t[1] = 0.0f; + t[2] = 0.0f; t[3] = 1.0f; + t[4] = 0.0f; t[5] = 0.0f; + } + static int nvgTransformInverse(float* inv, const float* t) + { + double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1]; + if (det > -1e-6 && det < 1e-6) { + nvgTransformIdentity(inv); + return 0; + } + invdet = 1.0 / det; + inv[0] = (float)(t[3] * invdet); + inv[2] = (float)(-t[2] * invdet); + inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet); + inv[1] = (float)(-t[1] * invdet); + inv[3] = (float)(t[0] * invdet); + inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet); + return 1; + } + static int glnvg__convertPaint( struct GLNVGcontext* gl , struct GLNVGfragUniforms* frag @@ -836,7 +869,7 @@ namespace if (gl->ncalls+1 > gl->ccalls) { gl->ccalls = gl->ccalls == 0 ? 32 : gl->ccalls * 2; - gl->calls = (struct GLNVGcall*)bx::realloc(gl->allocator, gl->calls, sizeof(struct GLNVGcall) * gl->ccalls); + gl->calls = (struct GLNVGcall*)NVG_REALLOC(gl->calls, sizeof(struct GLNVGcall) * gl->ccalls); } ret = &gl->calls[gl->ncalls++]; bx::memSet(ret, 0, sizeof(struct GLNVGcall) ); @@ -849,7 +882,7 @@ namespace if (gl->npaths + n > gl->cpaths) { GLNVGpath* paths; int cpaths = glnvg__maxi(gl->npaths + n, 128) + gl->cpaths / 2; // 1.5x Overallocate - paths = (GLNVGpath*)bx::realloc(gl->allocator, gl->paths, sizeof(GLNVGpath) * cpaths); + paths = (GLNVGpath*)NVG_REALLOC(gl->paths, sizeof(GLNVGpath) * cpaths); if (paths == NULL) return -1; gl->paths = paths; gl->cpaths = cpaths; @@ -870,7 +903,7 @@ namespace NVGvertex* verts; int cverts = glnvg__maxi(gl->nverts + n, 4096) + gl->cverts/2; // 1.5x Overallocate cverts = glnvg__mini(cverts, UINT16_MAX); - verts = (NVGvertex*)bx::realloc(gl->allocator, gl->verts, sizeof(NVGvertex) * cverts); + verts = (NVGvertex*)NVG_REALLOC(gl->verts, sizeof(NVGvertex) * cverts); if (verts == NULL) return -1; gl->verts = verts; gl->cverts = cverts; @@ -886,7 +919,7 @@ namespace if (gl->nuniforms+n > gl->cuniforms) { gl->cuniforms = gl->cuniforms == 0 ? glnvg__maxi(n, 32) : gl->cuniforms * 2; - gl->uniforms = (unsigned char*)bx::realloc(gl->allocator, gl->uniforms, gl->cuniforms * structSize); + gl->uniforms = (unsigned char*)NVG_REALLOC(gl->uniforms, gl->cuniforms * structSize); } ret = gl->nuniforms * structSize; gl->nuniforms += n; @@ -1097,17 +1130,39 @@ namespace } } - bx::free(gl->allocator, gl->uniforms); - bx::free(gl->allocator, gl->verts); - bx::free(gl->allocator, gl->paths); - bx::free(gl->allocator, gl->calls); - bx::free(gl->allocator, gl->textures); + NVG_FREE(gl->uniforms); + NVG_FREE(gl->verts); + NVG_FREE(gl->paths); + NVG_FREE(gl->calls); + NVG_FREE(gl->textures); bx::free(gl->allocator, gl); } } // namespace -NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId, bx::AllocatorI* _allocator) +typedef NVGcontext* (*nvgCreateInternalPROC) (NVGparams*); +typedef NVGparams* (*nvgInternalParamsPROC) (NVGcontext*); +typedef void (*nvgDeleteInternalPROC) (NVGcontext*); + +static nvgCreateInternalPROC org_lwjgl_nvgCreateInternal; +static nvgInternalParamsPROC org_lwjgl_nvgInternalParams; +static nvgDeleteInternalPROC org_lwjgl_nvgDeleteInternal; + +BGFX_C_API void org_lwjgl_nanovg_setup( + reallocPROC realloc, + freePROC free, + nvgCreateInternalPROC nvgCreateInternal, + nvgInternalParamsPROC nvgInternalParams, + nvgDeleteInternalPROC nvgDeleteInternal +) { + org_lwjgl_realloc = realloc; + org_lwjgl_free = free; + org_lwjgl_nvgCreateInternal = nvgCreateInternal; + org_lwjgl_nvgInternalParams = nvgInternalParams; + org_lwjgl_nvgDeleteInternal = nvgDeleteInternal; +} + +BGFX_C_API NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId, bx::AllocatorI* _allocator) { if (NULL == _allocator) { @@ -1144,7 +1199,7 @@ NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId, bx::AllocatorI* _al gl->edgeAntiAlias = _edgeaa; gl->viewId = _viewId; - ctx = nvgCreateInternal(¶ms); + ctx = org_lwjgl_nvgCreateInternal(¶ms); if (ctx == NULL) goto error; return ctx; @@ -1153,7 +1208,7 @@ NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId, bx::AllocatorI* _al // 'gl' is freed by nvgDeleteInternal. if (ctx != NULL) { - nvgDeleteInternal(ctx); + org_lwjgl_nvgDeleteInternal(ctx); } return NULL; @@ -1163,28 +1218,28 @@ NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId) { return nvgCreate(_edgeaa, _viewId, NULL); } -void nvgDelete(NVGcontext* _ctx) +BGFX_C_API void nvgDelete(NVGcontext* _ctx) { - nvgDeleteInternal(_ctx); + org_lwjgl_nvgDeleteInternal(_ctx); } -void nvgSetViewId(NVGcontext* _ctx, bgfx::ViewId _viewId) +BGFX_C_API void nvgSetViewId(NVGcontext* _ctx, bgfx::ViewId _viewId) { - struct NVGparams* params = nvgInternalParams(_ctx); + struct NVGparams* params = org_lwjgl_nvgInternalParams(_ctx); struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr; gl->viewId = _viewId; } -uint16_t nvgGetViewId(struct NVGcontext* _ctx) +BGFX_C_API uint16_t nvgGetViewId(struct NVGcontext* _ctx) { - struct NVGparams* params = nvgInternalParams(_ctx); + struct NVGparams* params = org_lwjgl_nvgInternalParams(_ctx); struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr; return gl->viewId; } bgfx::TextureHandle nvglImageHandle(NVGcontext* _ctx, int32_t _image) { - GLNVGcontext* gl = (GLNVGcontext*)nvgInternalParams(_ctx)->userPtr; + GLNVGcontext* gl = (GLNVGcontext*)org_lwjgl_nvgInternalParams(_ctx)->userPtr; GLNVGtexture* tex = glnvg__findTexture(gl, _image); return tex->id; } @@ -1201,7 +1256,7 @@ NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int32_t width, int32_t return framebuffer; } -NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32_t _height, int32_t _imageFlags) +BGFX_C_API NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32_t _height, int32_t _imageFlags) { BX_UNUSED(_imageFlags); BX_ASSERT(_width >= 0 && _width <= bx::max(), "Invalid tex width %d (max: %u)", _width, bx::max()); @@ -1224,7 +1279,7 @@ NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32 return NULL; } - struct NVGparams* params = nvgInternalParams(_ctx); + struct NVGparams* params = org_lwjgl_nvgInternalParams(_ctx); struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr; struct GLNVGtexture* tex = glnvg__allocTexture(gl); @@ -1248,62 +1303,7 @@ NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32 return framebuffer; } -NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int32_t imageFlags, bgfx::ViewId viewId) -{ - NVGLUframebuffer* framebuffer = nvgluCreateFramebuffer(ctx, imageFlags); - - if (framebuffer != NULL) - { - nvgluSetViewFramebuffer(viewId, framebuffer); - } - - return framebuffer; -} - -NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _imageFlags) -{ - BX_UNUSED(_imageFlags); - bgfx::TextureHandle textures[] = - { - bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::RGBA8, BGFX_TEXTURE_RT), - bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::D24S8, BGFX_TEXTURE_RT | BGFX_TEXTURE_RT_WRITE_ONLY) - }; - bgfx::FrameBufferHandle fbh = bgfx::createFrameBuffer( - BX_COUNTOF(textures) - , textures - , true - ); - - if (!bgfx::isValid(fbh) ) - { - return NULL; - } - - struct NVGparams* params = nvgInternalParams(_ctx); - struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr; - struct GLNVGtexture* tex = glnvg__allocTexture(gl); - - if (NULL == tex) - { - bgfx::destroy(fbh); - return NULL; - } - - tex->width = 0; - tex->height = 0; - tex->type = NVG_TEXTURE_RGBA; - tex->flags = _imageFlags | NVG_IMAGE_PREMULTIPLIED; - tex->id = bgfx::getTexture(fbh); - - NVGLUframebuffer* framebuffer = BX_NEW(gl->allocator, NVGLUframebuffer); - framebuffer->ctx = _ctx; - framebuffer->image = tex->id.idx; - framebuffer->handle = fbh; - - return framebuffer; -} - -void nvgluBindFramebuffer(NVGLUframebuffer* _framebuffer) +BGFX_C_API void nvgluBindFramebuffer(NVGLUframebuffer* _framebuffer) { static NVGcontext* s_prevCtx = NULL; static bgfx::ViewId s_prevViewId; @@ -1319,7 +1319,7 @@ void nvgluBindFramebuffer(NVGLUframebuffer* _framebuffer) } } -void nvgluDeleteFramebuffer(NVGLUframebuffer* _framebuffer) +BGFX_C_API void nvgluDeleteFramebuffer(NVGLUframebuffer* _framebuffer) { if (_framebuffer == NULL) { @@ -1331,25 +1331,25 @@ void nvgluDeleteFramebuffer(NVGLUframebuffer* _framebuffer) bgfx::destroy(_framebuffer->handle); } - struct NVGparams* params = nvgInternalParams(_framebuffer->ctx); + struct NVGparams* params = org_lwjgl_nvgInternalParams(_framebuffer->ctx); struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr; glnvg__deleteTexture(gl, _framebuffer->image); bx::deleteObject(gl->allocator, _framebuffer); } -void nvgluSetViewFramebuffer(bgfx::ViewId _viewId, NVGLUframebuffer* _framebuffer) +BGFX_C_API void nvgluSetViewFramebuffer(bgfx::ViewId _viewId, NVGLUframebuffer* _framebuffer) { _framebuffer->viewId = _viewId; bgfx::setViewFrameBuffer(_viewId, _framebuffer->handle); bgfx::setViewMode(_viewId, bgfx::ViewMode::Sequential); } -int nvgCreateBgfxTexture(struct NVGcontext *_ctx, - bgfx::TextureHandle _id, - int _width, - int _height, - int _flags) { - struct NVGparams *params = nvgInternalParams(_ctx); +BGFX_C_API int nvgCreateBgfxTexture(struct NVGcontext *_ctx, + bgfx::TextureHandle _id, + int _width, + int _height, + int _flags) { + struct NVGparams *params = org_lwjgl_nvgInternalParams(_ctx); struct GLNVGcontext *gl = (struct GLNVGcontext *)params->userPtr; struct GLNVGtexture *tex = glnvg__allocTexture(gl); tex->id = _id; diff --git a/examples/common/nanovg/nanovg_bgfx.h b/examples/common/nanovg/nanovg_bgfx.h index 32512c1233b..8710c1dc346 100644 --- a/examples/common/nanovg/nanovg_bgfx.h +++ b/examples/common/nanovg/nanovg_bgfx.h @@ -7,6 +7,7 @@ #define NANOVG_BGFX_H_HEADER_GUARD #include +#include namespace bx { struct AllocatorI; } @@ -26,19 +27,19 @@ enum NVGimageFlagsGL { }; /// -NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId, bx::AllocatorI* _allocator); +BGFX_C_API NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId, bx::AllocatorI* _allocator); /// NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId); /// -void nvgDelete(NVGcontext* _ctx); +BGFX_C_API void nvgDelete(NVGcontext* _ctx); /// -void nvgSetViewId(NVGcontext* _ctx, bgfx::ViewId _viewId); +BGFX_C_API void nvgSetViewId(NVGcontext* _ctx, bgfx::ViewId _viewId); /// -uint16_t nvgGetViewId(struct NVGcontext* _ctx); +BGFX_C_API uint16_t nvgGetViewId(struct NVGcontext* _ctx); // Helper functions to create bgfx framebuffer to render to. // Example: @@ -64,22 +65,19 @@ uint16_t nvgGetViewId(struct NVGcontext* _ctx); NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32_t _height, int32_t _imageFlags, bgfx::ViewId _viewId); /// -NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32_t _height, int32_t _imageFlags); +BGFX_C_API NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32_t _height, int32_t _imageFlags); /// -NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _imageFlags, bgfx::ViewId _viewId); +BGFX_C_API void nvgluBindFramebuffer(NVGLUframebuffer* _framebuffer); /// -NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _imageFlags); +BGFX_C_API void nvgluDeleteFramebuffer(NVGLUframebuffer* _framebuffer); /// -void nvgluBindFramebuffer(NVGLUframebuffer* _framebuffer); +BGFX_C_API void nvgluSetViewFramebuffer(bgfx::ViewId _viewId, NVGLUframebuffer* _framebuffer); /// -void nvgluDeleteFramebuffer(NVGLUframebuffer* _framebuffer); - -/// -void nvgluSetViewFramebuffer(bgfx::ViewId _viewId, NVGLUframebuffer* _framebuffer); +BGFX_C_API int nvgCreateBgfxTexture(NVGcontext * _ctx, bgfx::TextureHandle _id, int _width, int _height, int _flags); /// int nvgCreateBgfxTexture(struct NVGcontext *_ctx, bgfx::TextureHandle _id, int _width, int _height, int _flags); diff --git a/include/bgfx/embedded_shader.h b/include/bgfx/embedded_shader.h index db80f936dfa..c6966478a48 100644 --- a/include/bgfx/embedded_shader.h +++ b/include/bgfx/embedded_shader.h @@ -19,6 +19,7 @@ #define BGFX_PLATFORM_SUPPORTS_DXBC (0 \ || BX_PLATFORM_LINUX \ + || BX_PLATFORM_BSD \ || BX_PLATFORM_WINDOWS \ || BX_PLATFORM_WINRT \ || BX_PLATFORM_XBOXONE \ @@ -32,6 +33,7 @@ || BX_PLATFORM_EMSCRIPTEN \ || BX_PLATFORM_IOS \ || BX_PLATFORM_LINUX \ + || BX_PLATFORM_BSD \ || BX_PLATFORM_OSX \ || BX_PLATFORM_RPI \ || BX_PLATFORM_VISIONOS \ @@ -39,6 +41,7 @@ ) #define BGFX_PLATFORM_SUPPORTS_GLSL (0 \ || BX_PLATFORM_LINUX \ + || BX_PLATFORM_BSD \ || BX_PLATFORM_OSX \ || BX_PLATFORM_WINDOWS \ ) @@ -54,6 +57,7 @@ || BX_PLATFORM_ANDROID \ || BX_PLATFORM_EMSCRIPTEN \ || BX_PLATFORM_LINUX \ + || BX_PLATFORM_BSD \ || BX_PLATFORM_WINDOWS \ || BX_PLATFORM_OSX \ || BX_PLATFORM_NX \ diff --git a/makefile b/makefile index fbf3b6a8844..dd2d70fa8e4 100644 --- a/makefile +++ b/makefile @@ -4,12 +4,16 @@ # UNAME := $(shell uname) -ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin)) +ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin FreeBSD GNU/kFreeBSD)) ifeq ($(UNAME),$(filter $(UNAME),Darwin)) OS=darwin else +ifeq ($(UNAME),$(filter $(UNAME),FreeBSD GNU/kFreeBSD)) +OS=bsd +else OS=linux endif +endif help: @echo Available targets: @@ -45,6 +49,7 @@ projgen: ## Generate project files for all configurations. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=osx-arm64 gmake $(GENIE) --with-tools --with-combined-examples --with-shared-lib --xcode=osx xcode9 $(GENIE) --with-tools --with-combined-examples --with-shared-lib --xcode=ios xcode9 + $(GENIE) --with-combined-examples --with-shared-lib --gcc=freebsd gmake $(GENIE) --with-combined-examples --with-shared-lib --gcc=android-arm gmake $(GENIE) --with-combined-examples --with-shared-lib --gcc=android-arm64 gmake $(GENIE) --with-combined-examples --with-shared-lib --gcc=android-x86 gmake @@ -113,6 +118,18 @@ linux-clang-release64: .build/projects/gmake-linux-clang ## Build - Linux Clang $(MAKE) -R -C .build/projects/gmake-linux-clang config=release64 linux-clang: linux-clang-debug64 linux-clang-release64 ## Build - Linux Clang x86/x64 Debug and Release +.build/projects/gmake-freebsd: + $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=freebsd gmake +freebsd-debug32: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Debug + $(MAKE) -R -C .build/projects/gmake-freebsd config=debug32 +freebsd-release32: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Release + $(MAKE) -R -C .build/projects/gmake-freebsd config=release32 +freebsd-debug64: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Debug + $(MAKE) -R -C .build/projects/gmake-freebsd config=debug64 +freebsd-release64: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Release + $(MAKE) -R -C .build/projects/gmake-freebsd config=release64 +freebsd: freebsd-debug32 freebsd-release32 freebsd-debug64 freebsd-release64 ## Build - FreeBSD x86/x64 Debug and Release + .build/projects/gmake-mingw-gcc: $(GENIE) --with-tools --with-combined-examples --with-shared-lib --os=windows --gcc=mingw-gcc gmake mingw-gcc-debug32: .build/projects/gmake-mingw-gcc ## Build - MinGW GCC x86 Debug @@ -199,7 +216,7 @@ rpi: rpi-debug rpi-release ## Build - RasberryPi Debug and Release SILENT ?= @ UNAME := $(shell uname) -ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin)) +ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin FreeBSD GNU/kFreeBSD)) ifeq ($(UNAME),$(filter $(UNAME),Darwin)) OS=darwin BUILD_PROJECT_DIR=gmake-osx-arm64 @@ -208,6 +225,14 @@ BUILD_TOOLS_CONFIG=release BUILD_TOOLS_SUFFIX=Release EXE= else +ifeq ($(UNAME),$(filter $(UNAME),FreeBSD GNU/kFreeBSD)) +OS=bsd +BUILD_PROJECT_DIR=gmake-freebsd +BUILD_OUTPUT_DIR=freebsd64_gcc +BUILD_TOOLS_CONFIG=release64 +BUILD_TOOLS_SUFFIX=Release +EXE= +else OS=linux BUILD_PROJECT_DIR=gmake-linux BUILD_OUTPUT_DIR=linux64_gcc @@ -215,6 +240,7 @@ BUILD_TOOLS_CONFIG=release64 BUILD_TOOLS_SUFFIX=Release EXE= endif +endif else OS=windows BUILD_PROJECT_DIR=gmake-mingw-gcc diff --git a/scripts/bgfx.lua b/scripts/bgfx.lua index 6d4e2defbf4..a215004480f 100644 --- a/scripts/bgfx.lua +++ b/scripts/bgfx.lua @@ -59,7 +59,7 @@ function bgfxProjectBase(_kind, _defines) "-shared", } - configuration { "linux-*" } + configuration { "linux-* or freebsd" } buildoptions { "-fPIC", } @@ -138,14 +138,21 @@ function bgfxProjectBase(_kind, _defines) configuration { "osx*" } buildoptions { "-x objective-c++" } -- additional build option for osx + defines { + "BGFX_CONFIG_RENDERER_OPENGL=0", + "BGFX_CONFIG_RENDERER_OPENGLES=0", + } linkoptions { "-framework Cocoa", "-framework IOKit", - "-framework OpenGL", + --"-framework OpenGL", "-framework QuartzCore", "-weak_framework Metal", "-weak_framework MetalKit", } + --removefiles { + --path.join(BGFX_DIR, "src/glcontext**"), + --} configuration { "not NX32", "not NX64" } includedirs { @@ -164,10 +171,14 @@ function bgfxProjectBase(_kind, _defines) path.join(BGFX_DIR, "src/**.cpp"), path.join(BGFX_DIR, "src/**.h"), path.join(BGFX_DIR, "scripts/**.natvis"), + path.join(BGFX_DIR, "examples/common/nanovg/**.cpp"), + path.join(BGFX_DIR, "examples/common/nanovg/**.h"), } removefiles { path.join(BGFX_DIR, "src/**.bin.h"), + path.join(BGFX_DIR, "examples/common/nanovg/nanovg.cpp"), + path.join(BGFX_DIR, "examples/common/nanovg/**.bin.h"), } overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-agc"), { diff --git a/scripts/shaderc.lua b/scripts/shaderc.lua index cc4d7d8ac49..6afb6438082 100644 --- a/scripts/shaderc.lua +++ b/scripts/shaderc.lua @@ -104,7 +104,7 @@ project "spirv-opt" "/wd4706", -- warning C4706: assignment within conditional expression } - configuration { "mingw* or linux* or osx*" } + configuration { "mingw* or linux* or freebsd or osx*" } buildoptions { "-Wno-switch", } @@ -160,7 +160,7 @@ project "spirv-cross" "/wd4715", -- warning C4715: '': not all control paths return a value } - configuration { "mingw* or linux* or osx*" } + configuration { "mingw* or linux* or freebsd or osx*" } buildoptions { "-Wno-type-limits", } @@ -232,7 +232,7 @@ project "glslang" "-Wno-maybe-uninitialized", } - configuration { "mingw* or linux* or osx*" } + configuration { "mingw* or linux* or freebsd or osx*" } buildoptions { "-fno-strict-aliasing", -- glslang has bugs if strict aliasing is used. "-Wno-ignored-qualifiers", @@ -488,7 +488,7 @@ project "glsl-optimizer" "/wd4996", -- warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. } - configuration { "mingw* or linux* or osx*" } + configuration { "mingw* or linux* or freebsd or osx*" } buildoptions { "-fno-strict-aliasing", -- glsl-optimizer has bugs if strict aliasing is used. @@ -613,7 +613,7 @@ project "shaderc" "psapi", } - configuration { "osx* or linux*" } + configuration { "osx* or linux* or freebsd" } links { "pthread", } diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 600cf8429f6..cba1639be8a 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -2723,7 +2723,7 @@ namespace bgfx score += RendererType::Direct3D12 == renderer ? -100 : 0; } } - else if (BX_ENABLED(BX_PLATFORM_LINUX) ) + else if (BX_ENABLED(BX_PLATFORM_LINUX) || BX_ENABLED(BX_PLATFORM_BSD) ) { score += RendererType::Vulkan == renderer ? 50 : 0; score += RendererType::OpenGL == renderer ? 40 : 0; @@ -3468,6 +3468,7 @@ namespace bgfx , callback(NULL) , allocator(NULL) { + bx::memCopy(&this->platformData, &g_platformData, sizeof(PlatformData) ); } void Attachment::init(TextureHandle _handle, Access::Enum _access, uint16_t _layer, uint16_t _numLayers, uint16_t _mip, uint8_t _resolve) diff --git a/src/config.h b/src/config.h index 1f459eac74d..94e4ce40ca2 100644 --- a/src/config.h +++ b/src/config.h @@ -80,6 +80,7 @@ # ifndef BGFX_CONFIG_RENDERER_OPENGL # define BGFX_CONFIG_RENDERER_OPENGL (0 \ || BX_PLATFORM_LINUX \ + || BX_PLATFORM_BSD \ || BX_PLATFORM_WINDOWS \ ? BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION : 0) # endif // BGFX_CONFIG_RENDERER_OPENGL @@ -103,6 +104,7 @@ # define BGFX_CONFIG_RENDERER_VULKAN (0 \ || BX_PLATFORM_ANDROID \ || BX_PLATFORM_LINUX \ + || BX_PLATFORM_BSD \ || BX_PLATFORM_WINDOWS \ || BX_PLATFORM_NX \ || BX_PLATFORM_OSX \ diff --git a/src/debug_renderdoc.cpp b/src/debug_renderdoc.cpp index c04b9537a3f..107a5b78fbf 100644 --- a/src/debug_renderdoc.cpp +++ b/src/debug_renderdoc.cpp @@ -5,7 +5,7 @@ #include "bgfx_p.h" -#if BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX +#if BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX || BX_PLATFORM_BSD # if BX_PLATFORM_WINDOWS # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN diff --git a/src/glcontext_egl.cpp b/src/glcontext_egl.cpp index 273c40b9686..3dbdb676d72 100644 --- a/src/glcontext_egl.cpp +++ b/src/glcontext_egl.cpp @@ -84,7 +84,7 @@ EGL_IMPORT void* eglOpen() { void* handle = bx::dlopen( -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD "libEGL.so.1" #else "libEGL." BX_DL_EXT @@ -569,6 +569,7 @@ WL_EGL_IMPORT { return BX_ENABLED(0 | BX_PLATFORM_LINUX + | BX_PLATFORM_BSD | BX_PLATFORM_WINDOWS | BX_PLATFORM_ANDROID ) @@ -628,10 +629,10 @@ WL_EGL_IMPORT { BX_TRACE("Import:"); -# if BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX +# if BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX || BX_PLATFORM_BSD # if BX_PLATFORM_WINDOWS # define LIBRARY_NAME "libGL.dll" -# elif BX_PLATFORM_LINUX +# elif BX_PLATFORM_LINUX || BX_PLATFORM_BSD # if BGFX_CONFIG_RENDERER_OPENGL # define LIBRARY_NAME "libGL.so.1" # else diff --git a/src/renderer_d3d.h b/src/renderer_d3d.h index 7ec065f83fe..eb35ef4fc5b 100644 --- a/src/renderer_d3d.h +++ b/src/renderer_d3d.h @@ -58,7 +58,7 @@ namespace bgfx { -#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT typedef ::IUnknown IUnknown; #else typedef ::IGraphicsUnknown IUnknown; diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 7d6636ae969..a081af392fc 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -820,7 +820,7 @@ namespace bgfx { namespace d3d11 #if USE_D3D11_DYNAMIC_LIB const char* d3d11DllName = -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD "d3d11.so" #else "d3d11.dll" @@ -1021,7 +1021,7 @@ namespace bgfx { namespace d3d11 HRESULT hr = S_OK; m_swapEffect = -#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_WINDOWS DXGI_SWAP_EFFECT_FLIP_DISCARD #else DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL @@ -1368,7 +1368,7 @@ namespace bgfx { namespace d3d11 if (DXGI_FORMAT_UNKNOWN != fmt) { - if (BX_ENABLED(BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) ) + if (BX_ENABLED(BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) ) { D3D11_FEATURE_DATA_FORMAT_SUPPORT data; data.InFormat = fmt; @@ -1497,7 +1497,7 @@ namespace bgfx { namespace d3d11 if (DXGI_FORMAT_UNKNOWN != fmtSrgb) { - if (BX_ENABLED(BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) ) + if (BX_ENABLED(BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) ) { struct D3D11_FEATURE_DATA_FORMAT_SUPPORT { diff --git a/src/renderer_d3d11.h b/src/renderer_d3d11.h index 75e326e120f..3ce480670e0 100644 --- a/src/renderer_d3d11.h +++ b/src/renderer_d3d11.h @@ -6,7 +6,7 @@ #ifndef BGFX_RENDERER_D3D11_H_HEADER_GUARD #define BGFX_RENDERER_D3D11_H_HEADER_GUARD -#define USE_D3D11_DYNAMIC_LIB (BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS) +#define USE_D3D11_DYNAMIC_LIB (BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_WINDOWS) #if !USE_D3D11_DYNAMIC_LIB # undef BGFX_CONFIG_DEBUG_ANNOTATION @@ -22,7 +22,7 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4005) // warning C4005: '' : macro redefinitio #include #define D3D11_NO_HELPERS -#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_WINDOWS # include #elif BX_PLATFORM_WINRT # define __D3D10_1SHADER_H__ // BK - not used keep quiet! diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index d3d33369bf0..96b48a87f79 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -8,7 +8,7 @@ #if BGFX_CONFIG_RENDERER_DIRECT3D12 # include "renderer_d3d12.h" -#if !BX_PLATFORM_WINDOWS && !BX_PLATFORM_LINUX +#if !BX_PLATFORM_WINDOWS && !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD # include # if BX_PLATFORM_WINRT # include @@ -493,7 +493,7 @@ namespace bgfx { namespace d3d12 static void initHeapProperties(ID3D12Device* _device) { -#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_WINDOWS initHeapProperties(_device, s_heapProperties[HeapProperty::Default ].m_properties); initHeapProperties(_device, s_heapProperties[HeapProperty::Texture ].m_properties); initHeapProperties(_device, s_heapProperties[HeapProperty::Upload ].m_properties); @@ -618,7 +618,7 @@ namespace bgfx { namespace d3d12 static PFN_D3D12_GET_DEBUG_INTERFACE D3D12GetDebugInterface; static PFN_D3D12_SERIALIZE_ROOT_SIGNATURE D3D12SerializeRootSignature; -# if !BX_PLATFORM_LINUX +# if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD typedef HANDLE (WINAPI* PFN_CREATE_EVENT_EX_A)(LPSECURITY_ATTRIBUTES _attrs, LPCSTR _name, DWORD _flags, DWORD _access); static PFN_CREATE_EVENT_EX_A CreateEventExA; # endif // !BX_PLATFORM_LINUX @@ -743,7 +743,7 @@ namespace bgfx { namespace d3d12 #if USE_D3D12_DYNAMIC_LIB -# if !BX_PLATFORM_LINUX +# if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD m_kernel32Dll = bx::dlopen("kernel32.dll"); if (NULL == m_kernel32Dll) { @@ -765,7 +765,7 @@ namespace bgfx { namespace d3d12 { const char* d3d12DllName = -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD "libd3d12.so" #else "d3d12.dll" @@ -804,7 +804,7 @@ namespace bgfx { namespace d3d12 } #endif // USE_D3D12_DYNAMIC_LIB -#if !BX_PLATFORM_LINUX +#if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD if (!m_dxgi.init(g_caps) ) { goto error; @@ -824,7 +824,7 @@ namespace bgfx { namespace d3d12 } else { -#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT if (_init.debug || _init.profile) { @@ -882,7 +882,7 @@ namespace bgfx { namespace d3d12 for (uint32_t ii = 0; ii < BX_COUNTOF(featureLevel) && FAILED(hr); ++ii) { hr = D3D12CreateDevice( -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD NULL #else m_dxgi.m_adapter @@ -934,7 +934,7 @@ namespace bgfx { namespace d3d12 } } -#if !BX_PLATFORM_LINUX +#if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD m_dxgi.update(m_device); #endif // !BX_PLATFORM_LINUX @@ -953,7 +953,7 @@ namespace bgfx { namespace d3d12 } } -#if !BX_PLATFORM_LINUX +#if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD if (BGFX_PCI_ID_NVIDIA != m_dxgi.m_adapterDesc.VendorId) { m_nvapi.shutdown(); @@ -1168,7 +1168,7 @@ namespace bgfx { namespace d3d12 if (NULL != m_scd.nwh) { -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD hr = E_FAIL; #else hr = m_dxgi.createSwapChain( @@ -1539,7 +1539,7 @@ namespace bgfx { namespace d3d12 postReset(); m_batch.create(4<<10); -#if !BX_PLATFORM_LINUX +#if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD m_batch.setIndirectMode(BGFX_PCI_ID_NVIDIA != m_dxgi.m_adapterDesc.VendorId && BGFX_PCI_ID_MICROSOFT != m_dxgi.m_adapterDesc.VendorId); #endif // !BX_PLATFORM_LINUX @@ -1592,7 +1592,7 @@ namespace bgfx { namespace d3d12 case ErrorState::CreatedDXGIFactory: DX_RELEASE(m_device, 0); -#if !BX_PLATFORM_LINUX +#if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD m_dxgi.shutdown(); #endif // !BX_PLATFORM_LINUX [[fallthrough]]; @@ -1682,7 +1682,7 @@ namespace bgfx { namespace d3d12 DX_RELEASE(m_device, 0); m_nvapi.shutdown(); -#if !BX_PLATFORM_LINUX +#if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD m_dxgi.shutdown(); #endif // !BX_PLATFORM_LINUX @@ -1727,7 +1727,7 @@ namespace bgfx { namespace d3d12 { presentFlags |= DXGI_PRESENT_RESTART; } -#if !BX_PLATFORM_LINUX +#if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD else if (m_dxgi.tearingSupported() ) { presentFlags |= DXGI_PRESENT_ALLOW_TEARING; @@ -2527,7 +2527,7 @@ namespace bgfx { namespace d3d12 DX_RELEASE(m_swapChain, 0); HRESULT hr; -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD hr = E_FAIL; #else hr = m_dxgi.createSwapChain( @@ -3564,7 +3564,7 @@ namespace bgfx { namespace d3d12 m_commandList = _alloc ? m_cmd.alloc() : NULL; } -#if !BX_PLATFORM_LINUX +#if !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD Dxgi m_dxgi; #endif // !BX_PLATFORM_LINUX @@ -4052,7 +4052,7 @@ namespace bgfx { namespace d3d12 ID3D12CommandList* commandLists[] = { commandList.m_commandList }; m_commandQueue->ExecuteCommandLists(BX_COUNTOF(commandLists), commandLists); -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD commandList.m_event = NULL; #else commandList.m_event = CreateEventExA(NULL, NULL, 0, EVENT_ALL_ACCESS); @@ -4104,7 +4104,7 @@ namespace bgfx { namespace d3d12 bool CommandQueueD3D12::consume(uint32_t _ms) { CommandList& commandList = m_commandList[m_control.m_read]; -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD BX_UNUSED(commandList, _ms); #else if (WAIT_OBJECT_0 == WaitForSingleObject(commandList.m_event, _ms) ) @@ -7279,7 +7279,7 @@ namespace bgfx { namespace d3d12 , BGFX_REV_NUMBER ); -#if BX_PLATFORM_LINUX +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD const DXGI_ADAPTER_DESC desc = {}; #else const DXGI_ADAPTER_DESC& desc = m_dxgi.m_adapterDesc; diff --git a/src/renderer_d3d12.h b/src/renderer_d3d12.h index 47919b1487e..ecc26e4e546 100644 --- a/src/renderer_d3d12.h +++ b/src/renderer_d3d12.h @@ -6,12 +6,12 @@ #ifndef BGFX_RENDERER_D3D12_H_HEADER_GUARD #define BGFX_RENDERER_D3D12_H_HEADER_GUARD -#define USE_D3D12_DYNAMIC_LIB (BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX) +#define USE_D3D12_DYNAMIC_LIB (BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX || BX_PLATFORM_BSD) #include #include -#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT +#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT # include #else # if !BGFX_CONFIG_DEBUG @@ -47,7 +47,7 @@ extern "C++" { #include "nvapi.h" #include "dxgi.h" -#if BGFX_CONFIG_DEBUG_ANNOTATION && !BX_PLATFORM_LINUX +#if BGFX_CONFIG_DEBUG_ANNOTATION && !BX_PLATFORM_LINUX && !BX_PLATFORM_BSD # if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT typedef struct PIXEventsThreadInfo* (WINAPI* PFN_PIX_GET_THREAD_INFO)(); typedef uint64_t (WINAPI* PFN_PIX_EVENTS_REPLACE_BLOCK)(bool _getEarliestTime); diff --git a/src/renderer_gl.h b/src/renderer_gl.h index c721bd373ec..8d468635b74 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -9,6 +9,7 @@ #define BGFX_USE_EGL ( (BGFX_CONFIG_RENDERER_OPENGL || BGFX_CONFIG_RENDERER_OPENGLES) && (0 \ || BX_PLATFORM_ANDROID \ || BX_PLATFORM_LINUX \ + || BX_PLATFORM_BSD \ || BX_PLATFORM_NX \ || BX_PLATFORM_RPI \ ) ) @@ -23,6 +24,7 @@ #define BGFX_USE_GL_DYNAMIC_LIB (0 \ || BX_PLATFORM_LINUX \ + || BX_PLATFORM_BSD \ || BX_PLATFORM_WINDOWS \ ) @@ -60,7 +62,7 @@ # if BGFX_CONFIG_RENDERER_OPENGL >= 31 # include # else -# if BX_PLATFORM_LINUX +# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD # define GL_PROTOTYPES # define GL_GLEXT_LEGACY # include diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 4b649602969..538df8755d9 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -364,7 +364,7 @@ VK_IMPORT_DEVICE # if BX_PLATFORM_ANDROID KHR_android_surface, -# elif BX_PLATFORM_LINUX +# elif BX_PLATFORM_LINUX || BX_PLATFORM_BSD KHR_wayland_surface, KHR_xlib_surface, KHR_xcb_surface, @@ -402,7 +402,7 @@ VK_IMPORT_DEVICE { "VK_KHR_get_physical_device_properties2", 1, false, false, true, Layer::Count }, # if BX_PLATFORM_ANDROID { VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, 1, false, false, true, Layer::Count }, -# elif BX_PLATFORM_LINUX +# elif BX_PLATFORM_LINUX || BX_PLATFORM_BSD { VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, 1, false, false, true, Layer::Count }, { VK_KHR_XLIB_SURFACE_EXTENSION_NAME, 1, false, false, true, Layer::Count }, { VK_KHR_XCB_SURFACE_EXTENSION_NAME, 1, false, false, true, Layer::Count }, @@ -6955,7 +6955,7 @@ VK_DESTROY BX_WARN(VK_SUCCESS == result, "vkCreateAndroidSurfaceKHR failed %d: %s.", result, getName(result) ); } } -#elif BX_PLATFORM_LINUX +#elif BX_PLATFORM_LINUX || BX_PLATFORM_BSD { if (g_platformData.type == bgfx::NativeWindowHandleType::Wayland && s_extension[Extension::KHR_wayland_surface].m_supported diff --git a/src/renderer_vk.h b/src/renderer_vk.h index c47bd0d73c4..670db77d527 100644 --- a/src/renderer_vk.h +++ b/src/renderer_vk.h @@ -9,7 +9,7 @@ #if BX_PLATFORM_ANDROID # define VK_USE_PLATFORM_ANDROID_KHR # define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_ANDROID -#elif BX_PLATFORM_LINUX +#elif BX_PLATFORM_LINUX || BX_PLATFORM_BSD # define VK_USE_PLATFORM_WAYLAND_KHR # define VK_USE_PLATFORM_XLIB_KHR # define VK_USE_PLATFORM_XCB_KHR diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index 34480f00dc3..55a54b9e7e8 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -1165,6 +1165,7 @@ namespace bgfx preprocessor.setDefaultDefine("BX_PLATFORM_IOS"); preprocessor.setDefaultDefine("BX_PLATFORM_VISIONOS"); preprocessor.setDefaultDefine("BX_PLATFORM_LINUX"); + preprocessor.setDefaultDefine("BX_PLATFORM_BSD"); preprocessor.setDefaultDefine("BX_PLATFORM_OSX"); preprocessor.setDefaultDefine("BX_PLATFORM_PS4"); preprocessor.setDefaultDefine("BX_PLATFORM_WINDOWS"); @@ -1229,6 +1230,18 @@ namespace bgfx preprocessor.setDefine(glslDefine); } } + else if (0 == bx::strCmpI(platform, "bsd") ) + { + preprocessor.setDefine("BX_PLATFORM_BSD=1"); + if (profile->lang == ShadingLang::SpirV) + { + preprocessor.setDefine("BGFX_SHADER_LANGUAGE_SPIRV=1"); + } + else + { + preprocessor.setDefine(glslDefine); + } + } else if ( 0 == bx::strCmpI(platform, "ios") || 0 == bx::strCmpI(platform, "osx") || diff --git a/tools/texturev/texturev.cpp b/tools/texturev/texturev.cpp index 6c759588f02..cf966a7a366 100644 --- a/tools/texturev/texturev.cpp +++ b/tools/texturev/texturev.cpp @@ -1226,7 +1226,7 @@ void associate() } } } -#elif BX_PLATFORM_LINUX +#elif BX_PLATFORM_LINUX || BX_PLATFORM_BSD std::string mimeType;