mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-08 07:28:22 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd228dbcce |
No files matched your search
@@ -5,6 +5,9 @@ on:
|
||||
tags:
|
||||
- 'nightly_*'
|
||||
|
||||
env:
|
||||
QT_VERSION: 5.12.12
|
||||
|
||||
jobs:
|
||||
build_linux:
|
||||
strategy:
|
||||
@@ -18,25 +21,24 @@ jobs:
|
||||
arch: arm64
|
||||
name: Linux
|
||||
runs-on: ${{ matrix.os }}
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-71099c9
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Configure CMake
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: gcc-9
|
||||
ENABLE_QTFRED: OFF
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
run: ninja -k 20 all
|
||||
run: |
|
||||
LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja -k 20 all
|
||||
- name: Run Tests
|
||||
working-directory: ./build
|
||||
env:
|
||||
@@ -49,7 +51,7 @@ jobs:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
run: $GITHUB_WORKSPACE/ci/linux/generate_appimage.sh $GITHUB_WORKSPACE/build/install
|
||||
- name: Upload build result
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-${{ matrix.configuration }}-${{ matrix.arch }}
|
||||
path: ${{ github.workspace }}/build/install/*.AppImage
|
||||
@@ -57,26 +59,23 @@ jobs:
|
||||
name: Build Linux distribution zip
|
||||
needs: build_linux
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x86_64, arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: '0'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Download Release builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-Release-${{ matrix.arch }}
|
||||
path: builds
|
||||
- name: Download FastDebug builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-FastDebug-${{ matrix.arch }}
|
||||
path: builds
|
||||
@@ -102,169 +101,119 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [FastDebug, Release]
|
||||
os: [windows-2025, windows-11-arm]
|
||||
arch: [Win32, x64, ARM64]
|
||||
simd: [SSE2, ""]
|
||||
exclude:
|
||||
- arch: Win32
|
||||
os: windows-11-arm
|
||||
- arch: x64
|
||||
os: windows-11-arm
|
||||
- arch: ARM64
|
||||
os: windows-2025
|
||||
- os: windows-2025
|
||||
simd: ""
|
||||
- os: windows-11-arm
|
||||
simd: SSE2
|
||||
arch: [Win32, x64]
|
||||
simd: [SSE2]
|
||||
name: Windows
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Install v143 ATL/MFC
|
||||
shell: pwsh
|
||||
run: ci/windows/install_v143_atlmfc.ps1
|
||||
# Tree A: static CRT (/MT) for FSO + FRED2 (no Qt dependency needed)
|
||||
- name: Configure CMake (static CRT /MT - FSO + FRED2)
|
||||
# - name: Cache Qt
|
||||
# id: cache-qt-win
|
||||
# uses: actions/cache@v1
|
||||
# with:
|
||||
# path: ${{ github.workspace }}/../Qt
|
||||
# key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
|
||||
# - name: Install Qt (32 bit)
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# if: ${{ matrix.arch == 'Win32' }}
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# arch: win32_msvc2017
|
||||
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
|
||||
# aqtversion: ==0.8
|
||||
# - name: Install Qt (64 bit)
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# if: ${{ matrix.arch == 'x64' }}
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# arch: win64_msvc2017_64
|
||||
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
|
||||
# aqtversion: ==0.8
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/[email protected]
|
||||
with:
|
||||
vulkan-query-version: 1.4.304.1
|
||||
vulkan-components: Vulkan-Headers, Vulkan-Loader
|
||||
vulkan-use-cache: true
|
||||
- name: Configure CMake
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
ARCHITECTURE: ${{ matrix.arch }}
|
||||
SIMD: ${{ matrix.simd }}
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build-mt
|
||||
cd build-mt
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH=ON \
|
||||
-DFSO_USE_VOICEREC=ON -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_TESTS=ON -DFSO_INSTALL_DEBUG_FILES=ON -A "$ARCHITECTURE" \
|
||||
-DFSO_BUILD_QTFRED=OFF -G "Visual Studio 18 2026" -T "v143" \
|
||||
-DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
- name: Compile (static CRT)
|
||||
working-directory: ./build-mt
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
shell: bash
|
||||
run: |
|
||||
cmake --build . --config "$CONFIGURATION" -- /verbosity:minimal
|
||||
cmake --install . --config "$CONFIGURATION"
|
||||
ls -alR "$(pwd)/install"
|
||||
# Tree B: dynamic CRT (/MD) for QtFRED only (matches Qt's prebuilt /MD runtime)
|
||||
# Skipped on Win32: Qt6 has no 32-bit Windows support, so CMake force-disables
|
||||
# FSO_BUILD_QTFRED there and the qtfred target would not exist
|
||||
- name: Configure CMake (dynamic CRT /MD - QtFRED)
|
||||
if: matrix.arch != 'Win32'
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
ARCHITECTURE: ${{ matrix.arch }}
|
||||
SIMD: ${{ matrix.simd }}
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build-md
|
||||
cd build-md
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH=ON \
|
||||
-DFSO_USE_VOICEREC=ON -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_TESTS=OFF -DFSO_INSTALL_DEBUG_FILES=ON -A "$ARCHITECTURE" \
|
||||
-DFSO_BUILD_QTFRED=ON -DFSO_BUILD_FRED2=OFF -DQT_USE_PRECOMPILED=ON \
|
||||
-G "Visual Studio 18 2026" -T "v143" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
- name: Compile (dynamic CRT)
|
||||
if: matrix.arch != 'Win32'
|
||||
working-directory: ./build-md
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
shell: bash
|
||||
run: |
|
||||
cmake --build . --config "$CONFIGURATION" --target qtfred -- /verbosity:minimal
|
||||
cmake --install . --config "$CONFIGURATION" --component qtFRED
|
||||
ls -alR "$(pwd)/install"
|
||||
# Merge both trees into the single install dir the zip job consumes
|
||||
- name: Merge installs
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p build/install
|
||||
# build-md does not exist on Win32 (no QtFRED there)
|
||||
if [ -d build-md/install ]; then
|
||||
cp -r build-md/install/. build/install/
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
if [ "$ARCHITECTURE" = "Win32" ]; then
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH="ON" \
|
||||
-DFSO_USE_VOICEREC="ON" -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_QTFRED=OFF -DFSO_BUILD_TESTS=ON \
|
||||
-DFSO_INSTALL_DEBUG_FILES="ON" -DFSO_BUILD_WITH_VULKAN="OFF" -A "$ARCHITECTURE" \
|
||||
-G "Visual Studio 17 2022" -T "v143" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
else
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH="ON" \
|
||||
-DFSO_USE_VOICEREC="ON" -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_QTFRED=OFF -DFSO_BUILD_TESTS=ON \
|
||||
-DFSO_INSTALL_DEBUG_FILES="ON" -A "$ARCHITECTURE" \
|
||||
-G "Visual Studio 17 2022" -T "v143" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
fi
|
||||
cp -r build-mt/install/. build/install/
|
||||
ls -alR build/install
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
shell: bash
|
||||
run: |
|
||||
cmake --build . --config "$CONFIGURATION" --target INSTALL -- /verbosity:minimal
|
||||
ls -alR "$(pwd)/install"
|
||||
- name: Run Tests
|
||||
working-directory: ./build-mt
|
||||
working-directory: ./build
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
shell: bash
|
||||
run: ./bin/$CONFIGURATION/unittests --gtest_shuffle
|
||||
- name: Set artifact id
|
||||
shell: bash
|
||||
run: |
|
||||
id=
|
||||
if [ -n "${{ matrix.simd }}" ]; then
|
||||
id="${{ matrix.configuration }}-${{ matrix.arch }}-${{ matrix.simd }}"
|
||||
else
|
||||
id="${{ matrix.configuration }}-${{ matrix.arch }}"
|
||||
fi
|
||||
echo "artifact_id=${id}" >> $GITHUB_ENV
|
||||
- name: Upload build result
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-${{ env.artifact_id }}
|
||||
name: windows-${{ matrix.configuration }}-${{ matrix.arch }}-${{ matrix.simd }}
|
||||
path: ${{ github.workspace }}/build/install/*
|
||||
windows_zip:
|
||||
name: Build Windows distribution zip
|
||||
needs: build_windows
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [Win32, x64, ARM64]
|
||||
simd: [SSE2, ""]
|
||||
exclude:
|
||||
- arch: Win32
|
||||
simd: ""
|
||||
- arch: x64
|
||||
simd: ""
|
||||
- arch: ARM64
|
||||
simd: SSE2
|
||||
arch: [Win32, x64]
|
||||
simd: [SSE2]
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: '0'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Set artifact id
|
||||
shell: bash
|
||||
run: |
|
||||
id=
|
||||
if [ -n "${{ matrix.simd }}" ]; then
|
||||
id="${{ matrix.arch }}-${{ matrix.simd }}"
|
||||
else
|
||||
id="${{ matrix.arch }}"
|
||||
fi
|
||||
echo "artifact_id=${id}" >> $GITHUB_ENV
|
||||
- name: Download Release builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-Release-${{ env.artifact_id }}
|
||||
name: windows-Release-${{ matrix.arch }}-${{ matrix.simd }}
|
||||
path: builds
|
||||
- name: Download FastDebug builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-FastDebug-${{ env.artifact_id }}
|
||||
name: windows-FastDebug-${{ matrix.arch }}-${{ matrix.simd }}
|
||||
path: builds
|
||||
- name: Create Distribution package
|
||||
working-directory: ./builds
|
||||
shell: bash
|
||||
env:
|
||||
ID: ${{ env.artifact_id }}
|
||||
ARCH: ${{ matrix.arch }}
|
||||
SIMD: ${{ matrix.simd }}
|
||||
run: $GITHUB_WORKSPACE/ci/linux/create_dist_pack.sh Windows
|
||||
- name: Upload result package
|
||||
working-directory: ./builds
|
||||
@@ -285,14 +234,32 @@ jobs:
|
||||
name: Mac
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
# - name: Cache Qt
|
||||
# id: cache-qt-mac
|
||||
# uses: actions/cache@v1
|
||||
# with:
|
||||
# path: ${{ github.workspace }}/../Qt
|
||||
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
|
||||
# - name: Install Qt
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
|
||||
# setup-python: 'false'
|
||||
# aqtversion: ==1.1.3
|
||||
# py7zrversion: '==0.19.*'
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/[email protected]
|
||||
with:
|
||||
vulkan-query-version: 1.4.304.1
|
||||
vulkan-components: Vulkan-Headers, Vulkan-Loader
|
||||
vulkan-use-cache: true
|
||||
- name: Set up test version
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -305,10 +272,11 @@ jobs:
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
ARCHITECTURE: ${{ matrix.arch }}
|
||||
JOB_CMAKE_OPTIONS: ${{ matrix.cmake_options }}
|
||||
ENABLE_QTFRED: OFF
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
run: ninja all
|
||||
run: LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja all
|
||||
- name: Run Tests
|
||||
working-directory: ./build
|
||||
env:
|
||||
@@ -334,7 +302,7 @@ jobs:
|
||||
# Ref: https://github.com/actions/runner-images/issues/2619
|
||||
run: gtar -cvzf macos-build-${{ matrix.configuration }}-${{ matrix.arch }}.tgz *.app
|
||||
- name: Upload build result
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mac-${{ matrix.configuration }}-${{ matrix.arch }}
|
||||
path: ${{ github.workspace }}/build/bin/macos-build-${{ matrix.configuration }}-${{ matrix.arch }}.tgz
|
||||
@@ -342,27 +310,24 @@ jobs:
|
||||
name: Build Mac distribution zip
|
||||
needs: build_mac
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x86_64, arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: '0'
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Download Release builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: mac-Release-${{ matrix.arch }}
|
||||
path: builds
|
||||
- name: Download FastDebug builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: mac-FastDebug-${{ matrix.arch }}
|
||||
path: builds
|
||||
|
||||
@@ -5,6 +5,9 @@ on:
|
||||
tags:
|
||||
- 'release_*'
|
||||
|
||||
env:
|
||||
QT_VERSION: 5.12.12
|
||||
|
||||
jobs:
|
||||
create_release:
|
||||
name: Create GitHub release
|
||||
@@ -47,27 +50,26 @@ jobs:
|
||||
name: Linux
|
||||
needs: create_release # Don't run this job until create_release is done and successful
|
||||
runs-on: ${{ matrix.os }}
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-71099c9
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
# checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true # `true` to checkout submodules, `recursive` to recursively checkout submodules
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Configure CMake
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: gcc-9
|
||||
ENABLE_QTFRED: OFF
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
run: ninja -k 20 all
|
||||
run: |
|
||||
LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja -k 20 all
|
||||
- name: Run Tests
|
||||
working-directory: ./build
|
||||
env:
|
||||
@@ -80,7 +82,7 @@ jobs:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
run: $GITHUB_WORKSPACE/ci/linux/generate_appimage.sh $GITHUB_WORKSPACE/build/install
|
||||
- name: Upload build result
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
# Upload the url file for use with other runners
|
||||
# upload-artifact.inputs:
|
||||
# if-no-files-found=warn What to do if path fails to find any files.
|
||||
@@ -97,29 +99,26 @@ jobs:
|
||||
name: Build Linux distribution zip
|
||||
needs: build_linux
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x86_64, arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: '0' # value 0 to fetch all history and tags for all branches
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Download Release builds
|
||||
# Grab the release builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-Release-${{ matrix.arch }}
|
||||
path: builds
|
||||
- name: Download FastDebug builds
|
||||
# Grab the debug builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-FastDebug-${{ matrix.arch }}
|
||||
path: builds
|
||||
@@ -136,7 +135,7 @@ jobs:
|
||||
run: $GITHUB_WORKSPACE/ci/linux/create_dist_pack.sh Linux
|
||||
- name: Upload result package
|
||||
# Stash the result to artifact filespace
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.generate_package.outputs.package_name }}
|
||||
path: ${{ steps.generate_package.outputs.package_path }}
|
||||
@@ -152,175 +151,123 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [FastDebug, Release]
|
||||
os: [windows-2025, windows-11-arm]
|
||||
arch: [Win32, x64, ARM64]
|
||||
simd: [SSE2, AVX, ""]
|
||||
exclude:
|
||||
- arch: Win32
|
||||
os: windows-11-arm
|
||||
- arch: x64
|
||||
os: windows-11-arm
|
||||
- arch: ARM64
|
||||
os: windows-2025
|
||||
- os: windows-2025
|
||||
simd: ""
|
||||
- os: windows-11-arm
|
||||
simd: SSE2
|
||||
- os: windows-11-arm
|
||||
simd: AVX
|
||||
arch: [Win32, x64]
|
||||
simd: [SSE2, AVX]
|
||||
needs: create_release
|
||||
name: Windows
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
# Checkout repo
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Install v143 ATL/MFC
|
||||
shell: pwsh
|
||||
run: ci/windows/install_v143_atlmfc.ps1
|
||||
# Tree A: static CRT (/MT) for FSO + FRED2 (no Qt dependency needed)
|
||||
- name: Configure CMake (static CRT /MT - FSO + FRED2)
|
||||
# - name: Cache Qt
|
||||
# # Cache Qt
|
||||
# id: cache-qt-win
|
||||
# uses: actions/cache@v1
|
||||
# with:
|
||||
# path: ${{ github.workspace }}/../Qt
|
||||
# key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
|
||||
# - name: Install Qt (32 bit)
|
||||
# # Install Qt 32bit if matrix.arch == Win32
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# if: ${{ matrix.arch == 'Win32' }}
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# arch: win32_msvc2017
|
||||
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
|
||||
# aqtversion: ==0.8
|
||||
# - name: Install Qt (64 bit)
|
||||
# # Install Qt 64bit if matrix.arch == x64
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# if: ${{ matrix.arch == 'x64' }}
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# arch: win64_msvc2017_64
|
||||
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
|
||||
# aqtversion: ==0.8
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/[email protected]
|
||||
with:
|
||||
vulkan-query-version: 1.4.304.1
|
||||
vulkan-components: Vulkan-Headers, Vulkan-Loader
|
||||
vulkan-use-cache: true
|
||||
- name: Configure CMake
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
ARCHITECTURE: ${{ matrix.arch }}
|
||||
SIMD: ${{ matrix.simd }}
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build-mt
|
||||
cd build-mt
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH=ON \
|
||||
-DFSO_USE_VOICEREC=ON -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_TESTS=ON -DFSO_INSTALL_DEBUG_FILES=ON -A "$ARCHITECTURE" \
|
||||
-DFSO_BUILD_QTFRED=OFF -G "Visual Studio 18 2026" -T "v143" \
|
||||
-DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
- name: Compile (static CRT)
|
||||
working-directory: ./build-mt
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
shell: bash
|
||||
run: |
|
||||
cmake --build . --config "$CONFIGURATION" -- /verbosity:minimal
|
||||
cmake --install . --config "$CONFIGURATION"
|
||||
ls -alR "$(pwd)/install"
|
||||
# Tree B: dynamic CRT (/MD) for QtFRED only (matches Qt's prebuilt /MD runtime)
|
||||
# Skipped on Win32: Qt6 has no 32-bit Windows support, so CMake force-disables
|
||||
# FSO_BUILD_QTFRED there and the qtfred target would not exist
|
||||
- name: Configure CMake (dynamic CRT /MD - QtFRED)
|
||||
if: matrix.arch != 'Win32'
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
ARCHITECTURE: ${{ matrix.arch }}
|
||||
SIMD: ${{ matrix.simd }}
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build-md
|
||||
cd build-md
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH=ON \
|
||||
-DFSO_USE_VOICEREC=ON -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_TESTS=OFF -DFSO_INSTALL_DEBUG_FILES=ON -A "$ARCHITECTURE" \
|
||||
-DFSO_BUILD_QTFRED=ON -DFSO_BUILD_FRED2=OFF -DQT_USE_PRECOMPILED=ON \
|
||||
-G "Visual Studio 18 2026" -T "v143" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
- name: Compile (dynamic CRT)
|
||||
if: matrix.arch != 'Win32'
|
||||
working-directory: ./build-md
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
shell: bash
|
||||
run: |
|
||||
cmake --build . --config "$CONFIGURATION" --target qtfred -- /verbosity:minimal
|
||||
cmake --install . --config "$CONFIGURATION" --component qtFRED
|
||||
ls -alR "$(pwd)/install"
|
||||
# Merge both trees into the single install dir the zip job consumes
|
||||
- name: Merge installs
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p build/install
|
||||
# build-md does not exist on Win32 (no QtFRED there)
|
||||
if [ -d build-md/install ]; then
|
||||
cp -r build-md/install/. build/install/
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
if [ "$ARCHITECTURE" = "Win32" ]; then
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH="ON" \
|
||||
-DFSO_USE_VOICEREC="ON" -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_QTFRED=OFF -DFSO_BUILD_TESTS=ON \
|
||||
-DFSO_INSTALL_DEBUG_FILES="ON" -DFSO_BUILD_WITH_VULKAN="OFF" -A "$ARCHITECTURE" \
|
||||
-G "Visual Studio 17 2022" -T "v143" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
else
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH="ON" \
|
||||
-DFSO_USE_VOICEREC="ON" -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_QTFRED=OFF -DFSO_BUILD_TESTS=ON \
|
||||
-DFSO_INSTALL_DEBUG_FILES="ON" -A "$ARCHITECTURE" \
|
||||
-G "Visual Studio 17 2022" -T "v143" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
fi
|
||||
cp -r build-mt/install/. build/install/
|
||||
ls -alR build/install
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
shell: bash
|
||||
run: |
|
||||
cmake --build . --config "$CONFIGURATION" --target INSTALL -- /verbosity:minimal
|
||||
ls -alR "$(pwd)/install"
|
||||
- name: Run Tests
|
||||
working-directory: ./build-mt
|
||||
working-directory: ./build
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
shell: bash
|
||||
run: ./bin/$CONFIGURATION/unittests --gtest_shuffle
|
||||
- name: Set artifact id
|
||||
shell: bash
|
||||
run: |
|
||||
id=
|
||||
if [ -n "${{ matrix.simd }}" ]; then
|
||||
id="${{ matrix.configuration }}-${{ matrix.arch }}-${{ matrix.simd }}"
|
||||
else
|
||||
id="${{ matrix.configuration }}-${{ matrix.arch }}"
|
||||
fi
|
||||
echo "artifact_id=${id}" >> $GITHUB_ENV
|
||||
- name: Upload build result
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-${{ env.artifact_id }}
|
||||
name: windows-${{ matrix.configuration }}-${{ matrix.arch }}-${{ matrix.simd }}
|
||||
path: ${{ github.workspace }}/build/install/*
|
||||
|
||||
windows_zip:
|
||||
name: Build Windows distribution zip
|
||||
needs: build_windows
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
|
||||
strategy:
|
||||
fail-fast: false # Run the other jobs in the matrix instead of failing them
|
||||
matrix:
|
||||
arch: [Win32, x64, ARM64]
|
||||
simd: [SSE2, AVX, ""]
|
||||
exclude:
|
||||
- arch: Win32
|
||||
simd: ""
|
||||
- arch: x64
|
||||
simd: ""
|
||||
- arch: ARM64
|
||||
simd: SSE2
|
||||
- arch: ARM64
|
||||
simd: AVX
|
||||
arch: [Win32, x64]
|
||||
simd: [SSE2, AVX]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: '0'
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Set artifact id
|
||||
shell: bash
|
||||
run: |
|
||||
id=
|
||||
if [ -n "${{ matrix.simd }}" ]; then
|
||||
id="${{ matrix.arch }}-${{ matrix.simd }}"
|
||||
else
|
||||
id="${{ matrix.arch }}"
|
||||
fi
|
||||
echo "artifact_id=${id}" >> $GITHUB_ENV
|
||||
- name: Download Release builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-Release-${{ env.artifact_id }}
|
||||
name: windows-Release-${{ matrix.arch }}-${{ matrix.simd }}
|
||||
path: builds
|
||||
|
||||
- name: Download FastDebug builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-FastDebug-${{ env.artifact_id }}
|
||||
name: windows-FastDebug-${{ matrix.arch }}-${{ matrix.simd }}
|
||||
path: builds
|
||||
|
||||
- name: Create Distribution package
|
||||
@@ -328,17 +275,18 @@ jobs:
|
||||
working-directory: ./builds
|
||||
shell: bash
|
||||
env:
|
||||
ID: ${{ env.artifact_id }}
|
||||
ARCH: ${{ matrix.arch }}
|
||||
SIMD: ${{ matrix.simd }}
|
||||
run: $GITHUB_WORKSPACE/ci/linux/create_dist_pack.sh Windows
|
||||
|
||||
- name: Upload result package
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.generate_package.outputs.package_name }}
|
||||
path: ${{ steps.generate_package.outputs.package_path }}
|
||||
|
||||
- name: Upload debug package
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.generate_package.outputs.debug_name }}
|
||||
path: ${{ steps.generate_package.outputs.debug_path }}
|
||||
@@ -362,25 +310,43 @@ jobs:
|
||||
needs: create_release
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
# - name: Cache Qt
|
||||
# id: cache-qt-mac
|
||||
# uses: actions/cache@v1
|
||||
# with:
|
||||
# path: ${{ github.workspace }}/../Qt
|
||||
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
|
||||
# - name: Install Qt
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
|
||||
# setup-python: 'false'
|
||||
# aqtversion: ==1.1.3
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/[email protected]
|
||||
with:
|
||||
vulkan-query-version: 1.4.304.1
|
||||
vulkan-components: Vulkan-Headers, Vulkan-Loader
|
||||
vulkan-use-cache: true
|
||||
- name: Configure CMake
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
ARCHITECTURE: ${{ matrix.arch }}
|
||||
JOB_CMAKE_OPTIONS: ${{ matrix.cmake_options }}
|
||||
ENABLE_QTFRED: OFF
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
run: ninja all
|
||||
run: LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja all
|
||||
- name: Run Tests
|
||||
working-directory: ./build
|
||||
env:
|
||||
@@ -406,7 +372,7 @@ jobs:
|
||||
# Ref: https://github.com/actions/runner-images/issues/2619
|
||||
run: gtar -cvzf macos-build-${{ matrix.configuration }}-${{ matrix.arch }}.tgz *.app
|
||||
- name: Upload build result
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mac-${{ matrix.configuration }}-${{ matrix.arch }}
|
||||
path: ${{ github.workspace }}/build/bin/macos-build-${{ matrix.configuration }}-${{ matrix.arch }}.tgz
|
||||
@@ -414,27 +380,24 @@ jobs:
|
||||
name: Build Mac distribution zip
|
||||
needs: build_mac
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x86_64, arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: '0'
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Download Release builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: mac-Release-${{ matrix.arch }}
|
||||
path: builds
|
||||
- name: Download FastDebug builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: mac-FastDebug-${{ matrix.arch }}
|
||||
path: builds
|
||||
@@ -450,7 +413,7 @@ jobs:
|
||||
ARCH: ${{ matrix.arch }}
|
||||
run: $GITHUB_WORKSPACE/ci/linux/create_dist_pack.sh Mac
|
||||
- name: Upload result package
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.generate_package.outputs.package_name }}
|
||||
path: ${{ steps.generate_package.outputs.package_path }}
|
||||
|
||||
+106
-114
@@ -5,28 +5,22 @@ on:
|
||||
branches:
|
||||
- 'test/*'
|
||||
|
||||
env:
|
||||
QT_VERSION: 5.12.12
|
||||
|
||||
jobs:
|
||||
build_linux:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [FastDebug, Release]
|
||||
os: [ubuntu-latest, ubuntu-24.04-arm]
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
arch: x86_64
|
||||
- os: ubuntu-24.04-arm
|
||||
arch: arm64
|
||||
name: Linux
|
||||
runs-on: ${{ matrix.os }}
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-ab87451
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-71099c9
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Set up test version
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -37,12 +31,14 @@ jobs:
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: gcc-9
|
||||
ENABLE_QTFRED: OFF
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
run: ninja -k 20 all
|
||||
run: |
|
||||
LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja -k 20 all
|
||||
- name: Run Tests
|
||||
working-directory: ./build
|
||||
env:
|
||||
@@ -55,46 +51,34 @@ jobs:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
run: $GITHUB_WORKSPACE/ci/linux/generate_appimage.sh $GITHUB_WORKSPACE/build/install
|
||||
- name: Upload build result
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-${{ matrix.configuration }}-${{ matrix.arch }}
|
||||
name: linux-${{ matrix.configuration }}
|
||||
path: ${{ github.workspace }}/build/install/*.AppImage
|
||||
linux_zip:
|
||||
name: Build Linux distribution zip
|
||||
needs: build_linux
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-ab87451
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x86_64, arm64]
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: '0'
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Download Release builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-Release-${{ matrix.arch }}
|
||||
name: linux-Release
|
||||
path: builds
|
||||
- name: Download FastDebug builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-FastDebug-${{ matrix.arch }}
|
||||
name: linux-FastDebug
|
||||
path: builds
|
||||
- name: Fix permissions
|
||||
working-directory: ./builds
|
||||
shell: bash
|
||||
run: chmod 755 *.AppImage
|
||||
- name: Create Distribution package
|
||||
working-directory: ./builds
|
||||
env:
|
||||
ARCH: ${{ matrix.arch }}
|
||||
run: $GITHUB_WORKSPACE/ci/linux/create_dist_pack.sh Linux
|
||||
- name: Upload result package
|
||||
working-directory: ./builds
|
||||
@@ -109,39 +93,51 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [FastDebug, Release]
|
||||
os: [windows-2025, windows-11-arm]
|
||||
arch: [Win32, x64, ARM64]
|
||||
simd: [SSE2, ""]
|
||||
exclude:
|
||||
- arch: Win32
|
||||
os: windows-11-arm
|
||||
- arch: x64
|
||||
os: windows-11-arm
|
||||
- arch: ARM64
|
||||
os: windows-2025
|
||||
- os: windows-2025
|
||||
simd: ""
|
||||
- os: windows-11-arm
|
||||
simd: SSE2
|
||||
arch: [Win32, x64]
|
||||
simd: [SSE2]
|
||||
name: Windows
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Set up test version
|
||||
shell: bash
|
||||
run: |
|
||||
[[ "${{ github.ref }}" =~ ^refs\/heads\/test\/(.*)$ ]]
|
||||
# Override the revision string so that the builds are named correctly
|
||||
echo "set(FSO_VERSION_REVISION_STR ${BASH_REMATCH[1]})" > "version_override.cmake"
|
||||
- name: Install v143 ATL/MFC
|
||||
shell: pwsh
|
||||
run: ci/windows/install_v143_atlmfc.ps1
|
||||
# - name: Cache Qt
|
||||
# id: cache-qt-win
|
||||
# uses: actions/cache@v1
|
||||
# with:
|
||||
# path: ${{ github.workspace }}/../Qt
|
||||
# key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
|
||||
# - name: Install Qt (32 bit)
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# if: ${{ matrix.arch == 'Win32' }}
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# arch: win32_msvc2017
|
||||
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
|
||||
# aqtversion: ==0.8
|
||||
# - name: Install Qt (64 bit)
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# if: ${{ matrix.arch == 'x64' }}
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# arch: win64_msvc2017_64
|
||||
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
|
||||
# aqtversion: ==0.8
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/[email protected]
|
||||
with:
|
||||
vulkan-query-version: 1.4.304.1
|
||||
vulkan-components: Vulkan-Headers, Vulkan-Loader
|
||||
vulkan-use-cache: true
|
||||
- name: Configure CMake
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
@@ -151,11 +147,20 @@ jobs:
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH=ON \
|
||||
-DFSO_USE_VOICEREC=ON -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_TESTS=ON -DFSO_INSTALL_DEBUG_FILES=ON -A "$ARCHITECTURE" \
|
||||
-DQT_USE_PRECOMPILED=ON -G "Visual Studio 18 2026" -T "v143" \
|
||||
-DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
|
||||
if [ "$ARCHITECTURE" = "Win32" ]; then
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH="ON" \
|
||||
-DFSO_USE_VOICEREC="ON" -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_QTFRED=OFF -DFSO_BUILD_TESTS=ON \
|
||||
-DFSO_INSTALL_DEBUG_FILES="ON" -DFSO_BUILD_WITH_VULKAN="OFF" -A "$ARCHITECTURE" \
|
||||
-G "Visual Studio 17 2022" -T "v143" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
else
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH="ON" \
|
||||
-DFSO_USE_VOICEREC="ON" -DFORCED_SIMD_INSTRUCTIONS="$SIMD" \
|
||||
-DFSO_BUILD_QTFRED=OFF -DFSO_BUILD_TESTS=ON \
|
||||
-DFSO_INSTALL_DEBUG_FILES="ON" -A "$ARCHITECTURE" \
|
||||
-G "Visual Studio 17 2022" -T "v143" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
fi
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
env:
|
||||
@@ -171,72 +176,43 @@ jobs:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
shell: bash
|
||||
run: ./bin/$CONFIGURATION/unittests --gtest_shuffle
|
||||
- name: Set artifact id
|
||||
shell: bash
|
||||
run: |
|
||||
id=
|
||||
if [ -n "${{ matrix.simd }}" ]; then
|
||||
id="${{ matrix.configuration }}-${{ matrix.arch }}-${{ matrix.simd }}"
|
||||
else
|
||||
id="${{ matrix.configuration }}-${{ matrix.arch }}"
|
||||
fi
|
||||
echo "artifact_id=${id}" >> $GITHUB_ENV
|
||||
- name: Upload build result
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-${{ env.artifact_id }}
|
||||
name: windows-${{ matrix.configuration }}-${{ matrix.arch }}-${{ matrix.simd }}
|
||||
path: ${{ github.workspace }}/build/install/*
|
||||
windows_zip:
|
||||
name: Build Windows distribution zip
|
||||
needs: build_windows
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [Win32, x64, ARM64]
|
||||
simd: [SSE2, ""]
|
||||
exclude:
|
||||
- arch: Win32
|
||||
simd: ""
|
||||
- arch: x64
|
||||
simd: ""
|
||||
- arch: ARM64
|
||||
simd: SSE2
|
||||
arch: [Win32, x64]
|
||||
simd: [SSE2]
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: '0'
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Set artifact id
|
||||
shell: bash
|
||||
run: |
|
||||
id=
|
||||
if [ -n "${{ matrix.simd }}" ]; then
|
||||
id="${{ matrix.arch }}-${{ matrix.simd }}"
|
||||
else
|
||||
id="${{ matrix.arch }}"
|
||||
fi
|
||||
echo "artifact_id=${id}" >> $GITHUB_ENV
|
||||
- name: Download Release builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-Release-${{ env.artifact_id }}
|
||||
name: windows-Release-${{ matrix.arch }}-${{ matrix.simd }}
|
||||
path: builds
|
||||
- name: Download FastDebug builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-FastDebug-${{ env.artifact_id }}
|
||||
name: windows-FastDebug-${{ matrix.arch }}-${{ matrix.simd }}
|
||||
path: builds
|
||||
- name: Create Distribution package
|
||||
working-directory: ./builds
|
||||
shell: bash
|
||||
env:
|
||||
ID: ${{ env.artifact_id }}
|
||||
ARCH: ${{ matrix.arch }}
|
||||
SIMD: ${{ matrix.simd }}
|
||||
run: $GITHUB_WORKSPACE/ci/linux/create_dist_pack.sh Windows
|
||||
- name: Upload result package
|
||||
working-directory: ./builds
|
||||
@@ -257,14 +233,32 @@ jobs:
|
||||
name: Mac
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
# - name: Cache Qt
|
||||
# id: cache-qt-mac
|
||||
# uses: actions/cache@v1
|
||||
# with:
|
||||
# path: ${{ github.workspace }}/../Qt
|
||||
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
|
||||
# - name: Install Qt
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
|
||||
# setup-python: 'false'
|
||||
# aqtversion: ==1.1.3
|
||||
# py7zrversion: '==0.19.*'
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/[email protected]
|
||||
with:
|
||||
vulkan-query-version: 1.4.304.1
|
||||
vulkan-components: Vulkan-Headers, Vulkan-Loader
|
||||
vulkan-use-cache: true
|
||||
- name: Set up test version
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -276,10 +270,11 @@ jobs:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
ARCHITECTURE: ${{ matrix.arch }}
|
||||
ENABLE_QTFRED: OFF
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
run: ninja all
|
||||
run: LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja all
|
||||
- name: Run Tests
|
||||
working-directory: ./build
|
||||
env:
|
||||
@@ -305,7 +300,7 @@ jobs:
|
||||
# Ref: https://github.com/actions/runner-images/issues/2619
|
||||
run: gtar -cvzf macos-build-${{ matrix.configuration }}-${{ matrix.arch }}.tgz *.app
|
||||
- name: Upload build result
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mac-${{ matrix.configuration }}-${{ matrix.arch }}
|
||||
path: ${{ github.workspace }}/build/bin/macos-build-${{ matrix.configuration }}-${{ matrix.arch }}.tgz
|
||||
@@ -313,27 +308,24 @@ jobs:
|
||||
name: Build Mac distribution zip
|
||||
needs: build_mac
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x86_64, arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v2
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: '0'
|
||||
ref: '${{ github.ref }}'
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Download Release builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: mac-Release-${{ matrix.arch }}
|
||||
path: builds
|
||||
- name: Download FastDebug builds
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: mac-FastDebug-${{ matrix.arch }}
|
||||
path: builds
|
||||
|
||||
@@ -5,13 +5,15 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
QT_VERSION: 5.12.12
|
||||
|
||||
jobs:
|
||||
build_linux:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Debug, Release]
|
||||
compiler: [gcc-9, gcc-13, clang-16]
|
||||
arch: [x86_64]
|
||||
cmake_options: [""]
|
||||
include:
|
||||
# Also include configurations that check if the code compiles without the graphics backends
|
||||
@@ -23,20 +25,18 @@ jobs:
|
||||
cmake_options: -DFSO_BUILD_WITH_OPENGL=OFF -DFSO_BUILD_WITH_VULKAN=OFF
|
||||
name: Linux
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-71099c9
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- name: Install Qt dependencies
|
||||
run: apt-get -yq update && apt-get -yq install libfontconfig1
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2.23
|
||||
uses: hendrikmuhs/ccache-action@v1
|
||||
with:
|
||||
key: ${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.compiler }}-${{ matrix.arch }}
|
||||
max-size: 750MB
|
||||
key: ${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.compiler }}
|
||||
- name: Configure ccache
|
||||
run: |
|
||||
ccache --set-config=sloppiness=pch_defines,time_macros
|
||||
@@ -48,51 +48,11 @@ jobs:
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
JOB_CMAKE_OPTIONS: ${{ matrix.cmake_options }}
|
||||
CCACHE_PATH: /usr/local/bin/ccache
|
||||
ENABLE_QTFRED: ON
|
||||
Qt5_DIR: /qt/${{ env.QT_VERSION }}/gcc_64/lib/cmake/Qt5
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
run: ninja -k 20 all
|
||||
- name: Show CCache statistics
|
||||
run: ccache --show-stats
|
||||
|
||||
|
||||
build_mac:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Debug, Release]
|
||||
compiler: [clang]
|
||||
arch: [x86_64, arm64]
|
||||
cmake_options: [""]
|
||||
name: Mac
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/[email protected]
|
||||
with:
|
||||
key: ${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.arch }}
|
||||
max-size: 750MB
|
||||
- name: Configure ccache
|
||||
run: |
|
||||
ccache --set-config=sloppiness=pch_defines,time_macros
|
||||
ccache -p
|
||||
|
||||
- name: Configure CMake
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
ARCHITECTURE: ${{ matrix.arch }}
|
||||
JOB_CMAKE_OPTIONS: ${{ matrix.cmake_options }}
|
||||
CCACHE_PATH: /usr/local/bin/ccache
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
run: ninja -k 20 all
|
||||
run: LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja -k 20 all
|
||||
- name: Show CCache statistics
|
||||
run: ccache --show-stats
|
||||
@@ -33,7 +33,6 @@ env:
|
||||
NEBULA_PASSWORD: ${{ secrets.NEBULA_PASSWORD }}
|
||||
HLP_API: ${{ secrets.HLP_API }}
|
||||
HLP_KEY: ${{ secrets.HLP_KEY }}
|
||||
FORUM_SECRET: ${{ secrets.FORUM_SECRET }}
|
||||
RELEASE_TAG: ${{ inputs.releaseTag }}
|
||||
|
||||
jobs:
|
||||
@@ -46,13 +45,11 @@ jobs:
|
||||
run: echo "github.event_name= ${{ github.event_name }}"
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
ref: ${{ env.RELEASE_TAG }}
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
|
||||
- name: Install Python dependencies
|
||||
run: pip install -r ci/post/requirements.txt
|
||||
|
||||
@@ -70,7 +67,6 @@ jobs:
|
||||
HLP_API: ${{ secrets.HLP_API }}
|
||||
HLP_KEY: ${{ secrets.HLP_KEY }}
|
||||
RELEASE_TAG: ${{ inputs.releaseTag }}
|
||||
FORUM_SECRET: ${{ secrets.FORUM_SECRET }}
|
||||
run: python ci/post/main.py release
|
||||
|
||||
- name: Post Builds (Manual trigger)
|
||||
|
||||
@@ -2,6 +2,9 @@ name: Check a pull request
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
env:
|
||||
QT_VERSION: 5.12.12
|
||||
|
||||
jobs:
|
||||
build_linux:
|
||||
strategy:
|
||||
@@ -17,26 +20,25 @@ jobs:
|
||||
- configuration: Release
|
||||
compiler: gcc-13
|
||||
cmake_options: -DFSO_BUILD_WITH_OPENGL=OFF -DFSO_BUILD_WITH_VULKAN=OFF
|
||||
# - configuration: Debug
|
||||
# compiler: gcc-13
|
||||
# cmake_options: -DFSO_BUILD_WITH_OPENGL=OFF -DFSO_BUILD_WITH_VULKAN=ON
|
||||
# - configuration: Release
|
||||
# compiler: gcc-13
|
||||
# cmake_options: -DFSO_BUILD_WITH_OPENGL=OFF -DFSO_BUILD_WITH_VULKAN=ON
|
||||
- configuration: Debug
|
||||
compiler: gcc-13
|
||||
cmake_options: -DFSO_BUILD_WITH_OPENGL=OFF -DFSO_BUILD_WITH_VULKAN=ON
|
||||
- configuration: Release
|
||||
compiler: gcc-13
|
||||
cmake_options: -DFSO_BUILD_WITH_OPENGL=OFF -DFSO_BUILD_WITH_VULKAN=ON
|
||||
name: Linux
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-71099c9
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- name: Install Qt dependencies
|
||||
run: apt-get -yq update && apt-get -yq install libfontconfig1
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2.23
|
||||
uses: hendrikmuhs/ccache-action@v1
|
||||
with:
|
||||
key: ${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.compiler }}
|
||||
save: false # Caches are created by a separate job and only restored for PRs
|
||||
@@ -49,10 +51,12 @@ jobs:
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
JOB_CMAKE_OPTIONS: ${{ matrix.cmake_options }}
|
||||
CCACHE_PATH: /usr/local/bin/ccache
|
||||
ENABLE_QTFRED: ON
|
||||
Qt5_DIR: /qt/${{ env.QT_VERSION }}/gcc_64/lib/cmake/Qt5
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
run: ninja -k 20 all
|
||||
run: LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja -k 20 all
|
||||
- name: Run Tests
|
||||
working-directory: ./build
|
||||
env:
|
||||
@@ -78,21 +82,44 @@ jobs:
|
||||
compiler: [MSVC]
|
||||
arch: [Win32, x64]
|
||||
name: Windows
|
||||
runs-on: windows-2025
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Prepare Environment
|
||||
run: choco install ninja
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Install v143 ATL/MFC
|
||||
if: matrix.compiler == 'MSVC'
|
||||
shell: pwsh
|
||||
run: ci/windows/install_v143_atlmfc.ps1
|
||||
# - name: Cache Qt
|
||||
# id: cache-qt-win
|
||||
# uses: actions/cache@v1
|
||||
# with:
|
||||
# path: ${{ github.workspace }}/../Qt
|
||||
# key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
|
||||
# - name: Install Qt (32 bit)
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# if: ${{ matrix.compiler == 'MSVC' && matrix.arch == 'Win32' }}
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# arch: win32_msvc2017
|
||||
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
|
||||
# aqtversion: ==0.8
|
||||
# - name: Install Qt (64 bit)
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# if: ${{ matrix.compiler == 'MSVC' && matrix.arch == 'x64' }}
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# arch: win64_msvc2017_64
|
||||
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
|
||||
# aqtversion: ==0.8
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/[email protected]
|
||||
with:
|
||||
vulkan-query-version: 1.4.304.1
|
||||
vulkan-components: Vulkan-Headers, Vulkan-Loader
|
||||
vulkan-use-cache: true
|
||||
- name: Configure CMake
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
@@ -104,12 +131,23 @@ jobs:
|
||||
cd build
|
||||
|
||||
if [ "$COMPILER" = "MinGW" ]; then
|
||||
cmake -DFSO_USE_SPEECH=OFF -DFSO_FATAL_WARNINGS=ON -DFSO_USE_VOICEREC=OFF -DFSO_BUILD_TESTS=ON \
|
||||
-DFSO_BUILD_FRED2=OFF -DQT_USE_PRECOMPILED=ON -DCMAKE_BUILD_TYPE=$CONFIGURATION -G "Ninja" ..
|
||||
if [ "$ARCHITECTURE" = "Win32" ]; then
|
||||
cmake -DFSO_USE_SPEECH="OFF" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
|
||||
-DFSO_BUILD_FRED2="OFF" -DFSO_BUILD_WITH_VULKAN="OFF" -DCMAKE_BUILD_TYPE=$CONFIGURATION -G "Ninja" ..
|
||||
else
|
||||
cmake -DFSO_USE_SPEECH="OFF" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
|
||||
-DFSO_BUILD_FRED2="OFF" -DCMAKE_BUILD_TYPE=$CONFIGURATION -G "Ninja" ..
|
||||
fi
|
||||
else
|
||||
cmake -DFSO_USE_SPEECH=ON -DFSO_FATAL_WARNINGS=ON -DFSO_USE_VOICEREC=OFF -DFSO_BUILD_TESTS=ON \
|
||||
-DFORCED_SIMD_INSTRUCTIONS=SSE2 -G "Visual Studio 18 2026" -T "v143" -A "$ARCHITECTURE" \
|
||||
-DQT_USE_PRECOMPILED=ON -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
if [ "$ARCHITECTURE" = "Win32" ]; then
|
||||
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
|
||||
-DFORCED_SIMD_INSTRUCTIONS=SSE2 -DFSO_BUILD_FRED2="ON" -DFSO_BUILD_WITH_VULKAN="OFF" -G "Visual Studio 17 2022" \
|
||||
-DFSO_BUILD_QTFRED=OFF -T "v143" -A "$ARCHITECTURE" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
else
|
||||
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
|
||||
-DFORCED_SIMD_INSTRUCTIONS=SSE2 -DFSO_BUILD_FRED2="ON" -G "Visual Studio 17 2022" \
|
||||
-DFSO_BUILD_QTFRED=OFF -T "v143" -A "$ARCHITECTURE" -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
|
||||
fi
|
||||
fi
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
@@ -146,32 +184,48 @@ jobs:
|
||||
name: Mac
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
# - name: Cache Qt
|
||||
# id: cache-qt-mac
|
||||
# uses: actions/cache@v1
|
||||
# with:
|
||||
# path: ${{ github.workspace }}/../Qt
|
||||
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
|
||||
# - name: Install Qt
|
||||
# uses: jurplel/install-qt-action@v2
|
||||
# with:
|
||||
# version: ${{ env.QT_VERSION }}
|
||||
# dir: ${{ github.workspace }}/..
|
||||
# cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
|
||||
# setup-python: 'false'
|
||||
# aqtversion: ==1.1.3
|
||||
# py7zrversion: '==0.19.*'
|
||||
- uses: actions/checkout@v1
|
||||
name: Checkout
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2.23
|
||||
uses: hendrikmuhs/ccache-action@v1
|
||||
with:
|
||||
key: ${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.compiler }}-${{ matrix.arch }}
|
||||
save: false # Caches are created by a separate job and only restored for PRs
|
||||
- name: Configure ccache
|
||||
run: ccache --set-config=sloppiness=pch_defines,time_macros
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/[email protected]
|
||||
with:
|
||||
vulkan-query-version: 1.4.304.1
|
||||
vulkan-components: Vulkan-Headers, Vulkan-Loader
|
||||
vulkan-use-cache: true
|
||||
- name: Configure CMake
|
||||
env:
|
||||
CONFIGURATION: ${{ matrix.configuration }}
|
||||
COMPILER: ${{ matrix.compiler }}
|
||||
ARCHITECTURE: ${{ matrix.arch }}
|
||||
JOB_CMAKE_OPTIONS: ${{ matrix.cmake_options }}
|
||||
CCACHE_PATH: /usr/local/bin/ccache
|
||||
ENABLE_QTFRED: OFF
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
- name: Compile
|
||||
working-directory: ./build
|
||||
run: ninja all
|
||||
run: LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja all
|
||||
- name: Run Tests
|
||||
working-directory: ./build
|
||||
env:
|
||||
@@ -179,24 +233,12 @@ jobs:
|
||||
ARCH: ${{ matrix.arch }}
|
||||
XDG_RUNTIME_DIR: /root
|
||||
run: $GITHUB_WORKSPACE/ci/linux/run_tests.sh
|
||||
- name: Show CCache statistics
|
||||
run: ccache --show-stats
|
||||
- name: Install clang-tidy
|
||||
# macOS runners don't ship clang-tidy; pin to the same version as the Linux
|
||||
# container's clang-tidy-16 for consistent diagnostics. pyyaml is required
|
||||
# too: clang-tidy-diff.py only accepts -export-fixes when it can import yaml.
|
||||
# --break-system-packages is required since the runner's Homebrew Python
|
||||
# is externally managed (PEP 668); the runner is ephemeral so this is safe.
|
||||
if: startsWith(matrix.compiler, 'clang')
|
||||
run: pip3 install --break-system-packages clang-tidy==16.0.4 pyyaml
|
||||
- name: Run Clang Tidy
|
||||
# Clang-tidy reuses the precompiled headers so this only makes sense for the clang compilers
|
||||
if: startsWith(matrix.compiler, 'clang')
|
||||
env:
|
||||
CLANG_TIDY_BINARY: clang-tidy
|
||||
if: startsWith(matrix.compiler, 'clang-')
|
||||
run: $GITHUB_WORKSPACE/ci/linux/clang_tidy.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
|
||||
- name: Process clang-tidy warnings
|
||||
if: startsWith(matrix.compiler, 'clang')
|
||||
if: startsWith(matrix.compiler, 'clang-')
|
||||
uses: asarium/clang-tidy-action@v1
|
||||
with:
|
||||
fixesFile: clang-fixes.yaml
|
||||
@@ -11,6 +11,7 @@ on:
|
||||
- cron: "5 0 * * 5" # Run once per a week on Friday morning (midnight UTC, 4 AM EST), to avoid Coverity's submission limits
|
||||
|
||||
env:
|
||||
QT_VERSION: 5.12.12
|
||||
coverity_email: [email protected]
|
||||
coverity_token: ${{ secrets.COVERITY_TOKEN }}
|
||||
|
||||
@@ -19,7 +20,7 @@ jobs:
|
||||
name: Build FSO With Coverity Wrapper
|
||||
if: github.repository == 'scp-fs2open/fs2open.github.com'
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-ab87451
|
||||
container: ghcr.io/scp-fs2open/linux_build:sha-71099c9
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -28,12 +29,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: recursive # `true` to checkout submodules, `recursive` to recursively checkout submodules
|
||||
- name: Set workspace as safe
|
||||
# This appears to be broken in current actions, so do it manually
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
|
||||
# pipe results of wget to a log file because it's very verbose and rarely fails
|
||||
- name: Install Coverity
|
||||
@@ -51,6 +49,7 @@ jobs:
|
||||
env:
|
||||
CONFIGURATION: Release
|
||||
COMPILER: gcc-9
|
||||
ENABLE_QTFRED: OFF
|
||||
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
|
||||
|
||||
- name: Build FSO with Coverity Wrapper
|
||||
|
||||
@@ -262,8 +262,3 @@ CMakePresets.json
|
||||
!/docker/build
|
||||
CMakeFiles/cmake.check_cache
|
||||
CMakeCache.txt
|
||||
|
||||
# Written by the unittests binary at runtime
|
||||
test/test_data/**/*_settings.ini
|
||||
test/test_data/data/players/presets/asdf.json
|
||||
test/test_data/pilotfile/data/asdf.hdp
|
||||
@@ -1,3 +1,6 @@
|
||||
[submodule "cmake/external/rpavlik-cmake-modules"]
|
||||
path = cmake/external/rpavlik-cmake-modules
|
||||
url = https://github.com/rpavlik/cmake-modules.git
|
||||
[submodule "lib/libRocket"]
|
||||
path = lib/libRocket
|
||||
url = https://github.com/scp-fs2open/libRocket.git
|
||||
+25
-44
@@ -29,57 +29,33 @@ ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
|
||||
SET(TARGET_COPY_FILES "" CACHE INTERNAL "" FORCE)
|
||||
SET(TARGET_COPY_DIRS "" CACHE INTERNAL "" FORCE)
|
||||
|
||||
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
|
||||
# Override standard CMake configurations
|
||||
set(FSO_BUILD_TYPES Debug Release FastDebug)
|
||||
|
||||
if(is_multi_config)
|
||||
set(CMAKE_CONFIGURATION_TYPES "${FSO_BUILD_TYPES}" CACHE STRING "Configuration types" FORCE)
|
||||
elseif(NOT CMAKE_BUILD_TYPE)
|
||||
### Define options and editable variables in the section below:
|
||||
# This is only needed for single configuration generators so don't annoy others
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build configuration used." FORCE)
|
||||
message(WARNING "CMAKE_BUILD_TYPE was not specified, defaulting to Release configuration.")
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${FSO_BUILD_TYPES}")
|
||||
endif()
|
||||
endif(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
|
||||
|
||||
# Override standard CMake configurations
|
||||
set(CMAKE_CONFIGURATION_TYPES Debug Release FastDebug CACHE STRING "Available configurations" FORCE)
|
||||
|
||||
set(FSO_LANGUAGES C CXX)
|
||||
|
||||
if(APPLE)
|
||||
set(FSO_LANGUAGES ${FSO_LANGUAGES} OBJC OBJCXX)
|
||||
|
||||
# 10.15 for c++17 std::filesystem
|
||||
# NOTE: this must be set *before* the project() call to work properly!!
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "macOS deployment target")
|
||||
|
||||
# fix all targets in scheme (so it's not just qtfred)
|
||||
set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
|
||||
endif()
|
||||
|
||||
PROJECT(FS2_Open LANGUAGES ${FSO_LANGUAGES})
|
||||
|
||||
if (ANDROID)
|
||||
message(STATUS "Building for Android (NDK)")
|
||||
set(FSO_BUILD_INCLUDED_LIBS ON CACHE BOOL "" FORCE)
|
||||
set(USING_PREBUILT_LIBS ON CACHE BOOL "" FORCE)
|
||||
set(SDL3_USE_PRECOMPILED ON CACHE BOOL "" FORCE)
|
||||
set(OPENAL_USE_PRECOMPILED ON CACHE BOOL "" FORCE)
|
||||
set(USING_PREBUILT_VULKAN ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
# Check if the external modules exists
|
||||
IF(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libRocket/Build")
|
||||
IF(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/rpavlik-cmake-modules/launcher-templates")
|
||||
message(FATAL_ERROR "External submodules could not be found. Please make sure you have updated your submodules.")
|
||||
endif()
|
||||
|
||||
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/finder")
|
||||
|
||||
# this must be set before include(toolchain)
|
||||
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(FSO_BUILD_QTFRED OFF CACHE INTERNAL "" FORCE)
|
||||
else()
|
||||
OPTION(FSO_BUILD_QTFRED "Build qtFRED2 binary" ON)
|
||||
endif()
|
||||
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/rpavlik-cmake-modules")
|
||||
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/cotire")
|
||||
|
||||
INCLUDE(globals)
|
||||
INCLUDE(toolchain)
|
||||
@@ -98,7 +74,7 @@ IF(RESET_INSTALL_PREFIX)
|
||||
ENDIF(NOT $ENV{FS2PATH} STREQUAL "")
|
||||
ENDIF(RESET_INSTALL_PREFIX)
|
||||
|
||||
IF(WIN32 OR APPLE OR ANDROID OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
IF(WIN32 OR APPLE OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
OPTION(FSO_USE_SPEECH "Use text-to-speach libraries" ON)
|
||||
ELSE()
|
||||
OPTION(FSO_USE_SPEECH "Use text-to-speach libraries" OFF)
|
||||
@@ -118,8 +94,10 @@ OPTION(FSO_BUILD_TESTS "Build unit tests" OFF)
|
||||
|
||||
OPTION(FSO_DEVELOPMENT_MODE "Generate binaries in development mode, only use if you know what you're doing!" OFF)
|
||||
|
||||
IF(WIN32 OR APPLE OR ANDROID)
|
||||
# On windows, mac and android the default should be to always build the included libraries
|
||||
OPTION(FSO_BUILD_QTFRED "Build qtFRED2 binary" OFF)
|
||||
|
||||
IF(WIN32 OR APPLE)
|
||||
# On windows and mac the default should be to always build the included libraries
|
||||
SET(FSO_BUILD_INCLUDED_LIBS_DEFAULT ON)
|
||||
ELSE()
|
||||
SET(FSO_BUILD_INCLUDED_LIBS_DEFAULT OFF)
|
||||
@@ -139,6 +117,8 @@ SET(FSO_RUN_ARGUMENTS "" CACHE STRING "Additional arguments passed to a generate
|
||||
|
||||
option(FSO_INSTALL_DEBUG_FILES "Install some debug files (currently only PDB files on windows)" OFF)
|
||||
|
||||
option(ENABLE_COTIRE "Enable cotire for faster compilation. Enabled by default." ON)
|
||||
|
||||
option(FSO_RELEASE_LOGGING "Enable logging output for release builds" OFF)
|
||||
|
||||
OPTION(FSO_BUILD_WITH_FFMPEG "Enable the usage of FFmpeg for sound and custscenes" ON)
|
||||
@@ -147,13 +127,13 @@ OPTION(FSO_BUILD_WITH_DISCORD "Build with Discord support" ON)
|
||||
|
||||
OPTION(FSO_BUILD_WITH_OPENGL "Enable compilation of the OpenGL renderer" ON)
|
||||
OPTION(FSO_BUILD_WITH_OPENGL_DEBUG "Enables debug option for OpenGL" OFF)
|
||||
OPTION(FSO_BUILD_WITH_OPENGL_ES "When building OpenGL, use OpenGL ES compatibility layer" OFF)
|
||||
OPTION(FSO_BUILD_WITH_OPENGL_ES "When building OpenGL, use OpenGL ES compatibility layer (External shaders only!)" OFF)
|
||||
|
||||
OPTION(FSO_BUILD_WITH_VULKAN "Enable compilation of the Vulkan renderer" ON)
|
||||
OPTION(FSO_BUILD_WITH_VULKAN "Enable compilation of the Vulkan renderer" OFF)
|
||||
|
||||
if(NOT FSO_BUILD_WITH_OPENGL AND FSO_BUILD_WITH_OPENGL_ES)
|
||||
# Disable GLES if not building with OpenGL
|
||||
set(FSO_BUILD_WITH_OPENGL_ES OFF CACHE BOOL "" FORCE)
|
||||
set(FSO_BUILD_WITH_OPENGL_ES OFF FORCE)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -187,6 +167,7 @@ MARK_AS_ADVANCED(FORCE FSO_USE_LUAJIT)
|
||||
MARK_AS_ADVANCED(FORCE FSO_DEVELOPMENT_MODE)
|
||||
MARK_AS_ADVANCED(FORCE FSO_FATAL_WARNINGS)
|
||||
mark_as_advanced(FORCE FSO_INSTALL_DEBUG_FILES)
|
||||
mark_as_advanced(FORCE ENABLE_COTIRE)
|
||||
mark_as_advanced(FORCE FSO_RELEASE_LOGGING)
|
||||
mark_as_advanced(FORCE FSO_BUILD_WITH_FFMPEG)
|
||||
mark_as_advanced(FORCE FSO_BUILD_WITH_DISCORD)
|
||||
@@ -215,11 +196,11 @@ include(clang-tidy)
|
||||
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT LTO_AVAILABLE)
|
||||
if (FSO_USE_LTO AND LTO_AVAILABLE)
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release" AND FSO_USE_LTO AND LTO_AVAILABLE)
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
||||
message("Enabled LTO for Release builds")
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
|
||||
endif (FSO_USE_LTO AND LTO_AVAILABLE)
|
||||
message("Enabled LTO")
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif (CMAKE_BUILD_TYPE STREQUAL "Release" AND FSO_USE_LTO AND LTO_AVAILABLE)
|
||||
|
||||
# This includes source code for some tools, either used in the build or also for something else
|
||||
ADD_SUBDIRECTORY(tools)
|
||||
|
||||
@@ -18,16 +18,13 @@ fi
|
||||
# branch
|
||||
BASE_COMMIT=$(git merge-base $1 $2)
|
||||
|
||||
# Allow the caller to override the clang-tidy binary and job count, since neither
|
||||
# /usr/bin/clang-tidy-16 nor nproc are available outside the Linux CI container
|
||||
# (e.g. macOS runners install clang-tidy via pip and use sysctl for core count).
|
||||
CLANG_TIDY_BINARY="${CLANG_TIDY_BINARY:-/usr/bin/clang-tidy-16}"
|
||||
NUM_JOBS="${NUM_JOBS:-$( (command -v nproc >/dev/null 2>&1 && nproc) || sysctl -n hw.ncpu )}"
|
||||
|
||||
# Note: Manually passing in the Vulkan flags that are normally provided by cmake (but are not so, here), to ensure
|
||||
# that the source files are checked with the actual configuration used.
|
||||
echo "Running clang-tidy on changed files"
|
||||
git diff -U0 --no-color "$BASE_COMMIT..$2" | \
|
||||
$HERE/clang-tidy-diff.py -path "$(pwd)/build" -p1 \
|
||||
-extra-arg="-DWITH_VULKAN" \
|
||||
-extra-arg="-DVULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1" \
|
||||
-extra-arg="-DVK_NO_PROTOTYPES" \
|
||||
-regex '(code(?!((\/graphics\/shaders\/compiled)|(\/globalincs\/windebug)|(\/def_files\/data)))|freespace2|qtfred|test\/src|build|tools)\/.*\.(cpp|h)' \
|
||||
-clang-tidy-binary "$CLANG_TIDY_BINARY" -j"$NUM_JOBS" -export-fixes "$(pwd)/clang-fixes.yaml"
|
||||
-clang-tidy-binary /usr/bin/clang-tidy-16 -j$(nproc) -export-fixes "$(pwd)/clang-fixes.yaml"
|
||||
@@ -13,32 +13,21 @@ if [ "$COMPILER" = "clang-16" ]; then
|
||||
export CXX=clang++-16
|
||||
fi
|
||||
|
||||
LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH
|
||||
if [ "$RUNNER_OS" = "macOS" ]; then
|
||||
CXXFLAGS="-mtune=generic -pipe -Wno-unknown-pragmas"
|
||||
CFLAGS="-mtune=generic -pipe -Wno-unknown-pragmas"
|
||||
# TODO: Vulkan support is disabled on MacOS due to issues with the test suite not linking correctly
|
||||
PLATFORM_CMAKE_OPTIONS="-DFSO_BUILD_WITH_VULKAN=OFF"
|
||||
export CMAKE_OSX_ARCHITECTURES="$ARCHITECTURE"
|
||||
else
|
||||
PLATFORM_CMAKE_OPTIONS="-DFSO_BUILD_APPIMAGE=ON -DFORCED_SIMD_INSTRUCTIONS=SSE2"
|
||||
|
||||
# Optionally use static libstdc++/libc++ on Linux, but default to off
|
||||
# (Issue #5571 enabled it as a fix for 20.04 compatibility, but we've moved to 22.04)
|
||||
PLATFORM_CMAKE_OPTIONS="$PLATFORM_CMAKE_OPTIONS -DUSE_STATIC_LIBCXX=${USE_STATIC_LIBCXX:-OFF}"
|
||||
PLATFORM_CMAKE_OPTIONS="-DFSO_BUILD_APPIMAGE=ON -DFORCED_SIMD_INSTRUCTIONS=SSE2 -DUSE_STATIC_LIBCXX=ON"
|
||||
fi
|
||||
|
||||
CMAKE_OPTIONS="$JOB_CMAKE_OPTIONS"
|
||||
if [[ "$COMPILER" =~ ^clang.*$ ]]; then
|
||||
# Default to allowing system standard c++ library be used. On Linux, which
|
||||
# typically uses libstdc++ by default, using libc++ causes a conflict with
|
||||
# Qt6 libs. So an error/warning is in place to catch that case when QtFRED
|
||||
# is enabled.
|
||||
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCLANG_USE_LIBCXX=${CLANG_USE_LIBCXX:-OFF}"
|
||||
fi
|
||||
|
||||
if [ ! "$CCACHE_PATH" = "" ] && [ ! -x "$CCACHE_PATH" ]; then
|
||||
# The configured path doesn't exist on this runner (e.g. macOS runners on Apple
|
||||
# Silicon hosts install Homebrew under /opt/homebrew instead of /usr/local),
|
||||
# so fall back to whatever ccache is actually on PATH.
|
||||
CCACHE_PATH="$(command -v ccache || true)"
|
||||
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCLANG_USE_LIBCXX=ON"
|
||||
# force clang to silently allow -static-libstdc++ flag
|
||||
fi
|
||||
|
||||
if [ ! "$CCACHE_PATH" = "" ]; then
|
||||
@@ -46,10 +35,6 @@ if [ ! "$CCACHE_PATH" = "" ]; then
|
||||
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_C_COMPILER_LAUNCHER=$CCACHE_PATH -DCMAKE_CXX_COMPILER_LAUNCHER=$CCACHE_PATH"
|
||||
fi
|
||||
|
||||
if [ -n "${ENABLE_QTFRED:-}" ]; then
|
||||
CMAKE_OPTIONS="$CMAKE_OPTIONS -DFSO_BUILD_QTFRED=${ENABLE_QTFRED}"
|
||||
fi
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
@@ -65,6 +50,6 @@ fi
|
||||
# we have some build rules that do not play nice with parallel invocation and that fixes these issues
|
||||
|
||||
cmake -G Ninja -DFSO_FATAL_WARNINGS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON $CMAKE_OPTIONS $PLATFORM_CMAKE_OPTIONS \
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DCMAKE_BUILD_TYPE=$CONFIGURATION -DQT_USE_PRECOMPILED=ON \
|
||||
-DFFMPEG_USE_PRECOMPILED=ON -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON \
|
||||
-DCMAKE_JOB_POOLS=link=1 -DCMAKE_JOB_POOL_LINK=link ..
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DCMAKE_BUILD_TYPE=$CONFIGURATION \
|
||||
-DFFMPEG_USE_PRECOMPILED=ON -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFSO_BUILD_QTFRED=${ENABLE_QTFRED:-OFF} \
|
||||
-DSHADERS_ENABLE_COMPILATION=ON -DCMAKE_JOB_POOLS=link=1 -DCMAKE_JOB_POOL_LINK=link ..
|
||||
@@ -14,17 +14,17 @@ if [ "$OS" = "Linux" ]; then
|
||||
echo "package_name=$(get_package_name)-builds-Linux-$ARCH.tar.gz" >> $GITHUB_OUTPUT
|
||||
echo "package_mime=$(file -b --mime-type "$(pwd)/$(get_package_name)-builds-Linux-$ARCH.tar.gz")" >> $GITHUB_OUTPUT
|
||||
elif [ "$OS" = "Windows" ]; then
|
||||
7z a -xr'!*.pdb' "$(get_package_name)-builds-$ID.zip" "*"
|
||||
7z a -xr'!*.pdb' "$(get_package_name)-builds-$ARCH-$SIMD.zip" "*"
|
||||
|
||||
echo "package_path=$(pwd)/$(get_package_name)-builds-$ID.zip" >> $GITHUB_OUTPUT
|
||||
echo "package_name=$(get_package_name)-builds-$ID.zip" >> $GITHUB_OUTPUT
|
||||
echo "package_mime=$(file -b --mime-type "$(pwd)/$(get_package_name)-builds-$ID.zip")" >> $GITHUB_OUTPUT
|
||||
echo "package_path=$(pwd)/$(get_package_name)-builds-$ARCH-$SIMD.zip" >> $GITHUB_OUTPUT
|
||||
echo "package_name=$(get_package_name)-builds-$ARCH-$SIMD.zip" >> $GITHUB_OUTPUT
|
||||
echo "package_mime=$(file -b --mime-type "$(pwd)/$(get_package_name)-builds-$ARCH-$SIMD.zip")" >> $GITHUB_OUTPUT
|
||||
|
||||
7z a "$(get_package_name)-debug-$ID.7z" "*.pdb"
|
||||
7z a "$(get_package_name)-debug-$ARCH-$SIMD.7z" "*.pdb"
|
||||
|
||||
echo "debug_path=$(pwd)/$(get_package_name)-debug-$ID.7z" >> $GITHUB_OUTPUT
|
||||
echo "debug_name=$(get_package_name)-debug-$ID.7z" >> $GITHUB_OUTPUT
|
||||
echo "debug_mime=$(file -b --mime-type "$(pwd)/$(get_package_name)-debug-$ID.7z")" >> $GITHUB_OUTPUT
|
||||
echo "debug_path=$(pwd)/$(get_package_name)-debug-$ARCH-$SIMD.7z" >> $GITHUB_OUTPUT
|
||||
echo "debug_name=$(get_package_name)-debug-$ARCH-$SIMD.7z" >> $GITHUB_OUTPUT
|
||||
echo "debug_mime=$(file -b --mime-type "$(pwd)/$(get_package_name)-debug-$ARCH-$SIMD.7z")" >> $GITHUB_OUTPUT
|
||||
elif [ "$OS" = "Mac" ]; then
|
||||
tar -cvzf "$(get_package_name)-builds-Mac-$ARCH.tar.gz" *.app
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/Freespace2 -DCOMPONENT=Unspecified
|
||||
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/Freespace2 -DCOMPONENT=Freespace2 -P cmake_install.cmake
|
||||
|
||||
# We need to be a bit creative for determining the AppImage name since we don't want to hard-code the name
|
||||
FILENAME="$(find $INSTALL_FOLDER/Freespace2/bin -maxdepth 1 -name 'fs2_open_*' -type f -executable -printf "%f\n").AppImage"
|
||||
FILENAME="$(find $INSTALL_FOLDER/Freespace2/bin -name 'fs2_open_*' -type f -printf "%f\n").AppImage"
|
||||
./bin/appimagetool -n "$INSTALL_FOLDER/Freespace2" "$INSTALL_FOLDER/$FILENAME"
|
||||
chmod +x "$INSTALL_FOLDER/$FILENAME"
|
||||
|
||||
@@ -41,7 +41,7 @@ if [ -f qtfred/cmake_install.cmake ]; then
|
||||
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/qtFRED -DCOMPONENT=qtFRED -P cmake_install.cmake
|
||||
|
||||
# We need to be a bit creative for determining the AppImage name since we don't want to hard-code the name
|
||||
FILENAME="$(find $INSTALL_FOLDER/qtFRED/bin -maxdepth 1 -iname 'qtfred_*' -type f -executable -printf "%f\n").AppImage"
|
||||
FILENAME="$(find $INSTALL_FOLDER/qtFRED/bin -iname 'qtfred_*' -type f -printf "%f\n").AppImage"
|
||||
./bin/appimagetool -n "$INSTALL_FOLDER/qtFRED" "$INSTALL_FOLDER/$FILENAME"
|
||||
chmod +x "$INSTALL_FOLDER/$FILENAME"
|
||||
fi
|
||||
|
||||
@@ -5,14 +5,6 @@ HERE=$(dirname "$SCRIPT")
|
||||
|
||||
export LD_LIBRARY_PATH=$(pwd)/bin/lib:$LD_LIBRARY_PATH
|
||||
|
||||
# The unit tests never open a window, but a few of them reach code that brings SDL's video
|
||||
# subsystem up (os_init() and resolution_default(), the latter via gr_init()). Left to itself SDL
|
||||
# probes its real backends and dlopens libX11, which leaks a handful of blocks per init/quit cycle
|
||||
# that SDL_QuitSubSystem() does not reclaim -- those are the "definitely lost" contexts memcheck
|
||||
# fails the Debug legs on. Pinning the dummy driver skips the probing entirely, so the leaks never
|
||||
# happen, and it makes the tests behave the same way whether or not the runner has a display.
|
||||
export SDL_VIDEODRIVER=dummy
|
||||
|
||||
# if on mac and building for architecture that doesn't match host
|
||||
# then unittests will fail so we just need to skip it (for now)
|
||||
if [ "$RUNNER_OS" = "macOS" ] && [ "$ARCH" != "$(uname -m)" ]; then
|
||||
@@ -20,7 +12,7 @@ if [ "$RUNNER_OS" = "macOS" ] && [ "$ARCH" != "$(uname -m)" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$CONFIGURATION" = "Debug" ] && [[ "$RUNNER_OS" != "macOS" ]] ; then
|
||||
if [ "$CONFIGURATION" = "Debug"] && [[ "$RUNNER_OS" != "macOS" ]] ; then
|
||||
valgrind --leak-check=full --error-exitcode=1 --gen-suppressions=all \
|
||||
--suppressions="$HERE/valgrind.supp" ./bin/unittests --gtest_shuffle
|
||||
else
|
||||
|
||||
+47
-23
@@ -8,6 +8,24 @@
|
||||
obj:*
|
||||
obj:*
|
||||
}
|
||||
{
|
||||
Travis memleak
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:malloc
|
||||
fun:_dl_signal_error
|
||||
fun:_dl_open
|
||||
fun:dlopen_doit
|
||||
fun:_dl_catch_error
|
||||
fun:_dlerror_run
|
||||
fun:dlopen@@GLIBC_2.2.5
|
||||
obj:/usr/lib/x86_64-linux-gnu/libmirclient.so.7
|
||||
fun:call_init.part.0
|
||||
fun:call_init
|
||||
fun:_dl_init
|
||||
fun:dl_open_worker
|
||||
fun:_dl_catch_error
|
||||
}
|
||||
{
|
||||
CLang Lua unitialized value error
|
||||
Memcheck:Cond
|
||||
@@ -109,31 +127,37 @@
|
||||
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
|
||||
}
|
||||
{
|
||||
SDL_Init one-time internal allocation via os_init
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:malloc
|
||||
obj:*
|
||||
obj:*
|
||||
obj:*
|
||||
obj:*
|
||||
fun:_Z7os_initPKcS0_S0_
|
||||
fun:_ZN4test13FSTestFixture5SetUpEv
|
||||
}
|
||||
# Kept only as a backstop for running memcheck by hand. run_tests.sh pins SDL_VIDEODRIVER=dummy, so
|
||||
# the X11 backend is never created there; this block also cannot match the prebuilt libSDL3 anymore,
|
||||
# since that library is now stripped and X11_CreateDevice is a static symbol.
|
||||
{
|
||||
SDL3 X11 video backend internal allocations, not freed by SDL_VideoQuit
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite,possible
|
||||
...
|
||||
fun:X11_CreateDevice
|
||||
}
|
||||
{
|
||||
glibc loader bookkeeping and library constructor allocations retained across dlopen
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite,possible
|
||||
...
|
||||
fun:_dl_signal_error
|
||||
fun:_dl_open
|
||||
fun:dlopen_doit
|
||||
fun:_dl_catch_error
|
||||
fun:_dlerror_run
|
||||
fun:dlopen@@GLIBC_2.2.5
|
||||
obj:*
|
||||
obj:*
|
||||
fun:call_init.part.0
|
||||
fun:call_init
|
||||
fun:_dl_init
|
||||
fun:dl_open_worker
|
||||
}
|
||||
{
|
||||
dlopen leak
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:malloc
|
||||
fun:_dl_exception_create
|
||||
fun:_dl_signal_error
|
||||
fun:_dl_map_object
|
||||
fun:dl_open_worker
|
||||
fun:_dl_catch_exception
|
||||
fun:_dl_open
|
||||
fun:dlopen_doit
|
||||
fun:_dl_catch_exception
|
||||
fun:_dl_catch_error
|
||||
fun:_dlerror_run
|
||||
fun:dlopen@@GLIBC_2.2.5
|
||||
}
|
||||
@@ -149,8 +149,6 @@ def get_release_files(tag_name, config) -> Tuple[List[ReleaseFile], Dict[str, So
|
||||
# x64 is the Visual Studio name but for consistency we need Win64
|
||||
if platform == "x64":
|
||||
platform = "Win64"
|
||||
elif platform == "ARM64":
|
||||
platform = "WinARM64"
|
||||
|
||||
binary_files.append(ReleaseFile(name, url, platform, group_match.group(3)))
|
||||
else:
|
||||
@@ -215,8 +213,6 @@ def get_ftp_files(build_type, tag_name, config) -> List[ReleaseFile] :
|
||||
# x64 is the name Visual Studio uses but Win64 works better for us since that gets displayed in the nightly post
|
||||
if "x64" in group_match:
|
||||
group_match = group_match.replace("x64", "Win64")
|
||||
elif "ARM64" in group_match:
|
||||
group_match = group_match.replace("ARM64", "WinARM64")
|
||||
|
||||
# construct the download URL list for all mirrors. The first listed ftp location is taken as the Primary
|
||||
for mirror in config["ftp"]["mirrors"]:
|
||||
@@ -229,4 +225,4 @@ def get_ftp_files(build_type, tag_name, config) -> List[ReleaseFile] :
|
||||
# Form the List[ReleaseFile] list with the download URL links
|
||||
out_data.append(ReleaseFile(file, primary_url, group_match, None, mirrors))
|
||||
|
||||
return out_data
|
||||
return out_data
|
||||
+6
-9
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
import requests
|
||||
@@ -34,14 +33,12 @@ class ForumAPI:
|
||||
print("Post failed! No API or API_KEY given!")
|
||||
return
|
||||
|
||||
resp = requests.post(self.config["hlp"]["api"],
|
||||
headers={"X-HLP-Bot": os.environ["FORUM_SECRET"]},
|
||||
data={
|
||||
"api_key": self.config["hlp"]["key"],
|
||||
"board": str(board),
|
||||
"subject": title,
|
||||
"body": content
|
||||
})
|
||||
resp = requests.post(self.config["hlp"]["api"], data={
|
||||
"api_key": self.config["hlp"]["key"],
|
||||
"board": str(board),
|
||||
"subject": title,
|
||||
"body": content
|
||||
})
|
||||
|
||||
if resp.status_code != 200:
|
||||
print("Post failed! Response: %s" %resp.text)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
# Credentials into hard-light.net for forum post
|
||||
# HLP_API:
|
||||
# HLP_KEY:
|
||||
# FORUM_SECRET:
|
||||
|
||||
# LINUX_RESULT: bool, if the linux builds were successfully uploaded
|
||||
# WINDOWS_RESULT: bool, if the windows builds were successfully uploaded
|
||||
@@ -125,10 +124,6 @@ def get_source_version(date_version: datetime, tag_name: str) -> semantic_versio
|
||||
|
||||
|
||||
def main():
|
||||
if "FORUM_SECRET" not in os.environ or not os.environ["FORUM_SECRET"]:
|
||||
print(" ERROR: FORUM_SECRET environment variable not set")
|
||||
sys.exit(1)
|
||||
|
||||
os.chdir(os.path.dirname(__file__)) # Change working directory to this file's directory
|
||||
|
||||
# Aggregate configuration data in a dictionary
|
||||
|
||||
+2
-6
@@ -15,7 +15,6 @@ WIN32_SSE2_KEY = "Win32-SSE2"
|
||||
WIN64_SSE2_KEY = "Win64-SSE2"
|
||||
WIN32_AVX_KEY = "Win32-AVX"
|
||||
WIN64_AVX_KEY = "Win64-AVX"
|
||||
WINARM64_KEY = "WinARM64"
|
||||
|
||||
metadata = {
|
||||
'type': 'engine',
|
||||
@@ -43,8 +42,7 @@ platforms = {
|
||||
WIN32_SSE2_KEY: 'windows',
|
||||
WIN64_SSE2_KEY: 'windows',
|
||||
WIN32_AVX_KEY: 'windows',
|
||||
WIN64_AVX_KEY: 'windows',
|
||||
WINARM64_KEY: 'windows',
|
||||
WIN64_AVX_KEY: 'windows'
|
||||
}
|
||||
|
||||
envs = {
|
||||
@@ -55,8 +53,7 @@ envs = {
|
||||
WIN32_SSE2_KEY: 'windows',
|
||||
WIN64_SSE2_KEY: 'windows && x86_64',
|
||||
WIN32_AVX_KEY: 'windows && avx',
|
||||
WIN64_AVX_KEY: 'windows && avx && x86_64',
|
||||
WINARM64_KEY: 'windows && arm64'
|
||||
WIN64_AVX_KEY: 'windows && avx && x86_64'
|
||||
}
|
||||
|
||||
subdirs = {
|
||||
@@ -194,7 +191,6 @@ def render_nebula_release(version, stability, files, config):
|
||||
"sse2": "SSE2" in fn or "AVX" in fn, # AVX implies SSE2
|
||||
"avx": "AVX" in fn, # This conveniently also covers the AVX2 case since AVX2 implies AVX
|
||||
"avx2": "AVX2" in fn,
|
||||
"arm64": "arm64" in fn,
|
||||
}
|
||||
|
||||
pkg['executables'].append({
|
||||
|
||||
@@ -22,7 +22,7 @@ Windows: [url=http://scp.fsmods.net/builds/Launcher55g.zip]Launcher 5.5g[/url]
|
||||
OS X: Soulstorm's [url=https://www.hard-light.net/forums/index.php/topic,51391.0.html]OS X Launcher 3.0[/url]
|
||||
Linux: [url=https://www.hard-light.net/forums/index.php/topic,53206.0.html]YAL[/url] or [url=https://www.hard-light.net/wiki/index.php/Fs2_open_on_Linux/Graphics_Settings]by hand[/url] or whatever you can figure out.[/hidden]
|
||||
|
||||
[img]https://scp.indiegames.us/img/windows-icon.png[/img] [color=green][size=12pt]Windows (32/64-bit/ARM64)[/size][/color]
|
||||
[img]https://scp.indiegames.us/img/windows-icon.png[/img] [color=green][size=12pt]Windows (32/64-bit)[/size][/color]
|
||||
[size=8pt]Compiled using GitHub Actions on Windows Server 2019 (10.0.17763), Visual Studio Enterprise 2019[/size]
|
||||
|
||||
[b]64-bit:[/b] ${build(groups["Win64"].mainFile)}
|
||||
@@ -30,8 +30,6 @@ Linux: [url=https://www.hard-light.net/forums/index.php/topic,53206.0.html]YAL[
|
||||
[b]32-bit:[/b] ${build(groups["Win32"].mainFile)}
|
||||
[size=8pt]This one is based on the SSE2 Optimizations from the MSVC Compiler.[/size]
|
||||
|
||||
[b]ARM64:[/b] ${build(groups["WinARM64"].mainFile)}
|
||||
|
||||
[hidden=Alternative builds]
|
||||
|
||||
[b]64-bit AVX:[/b] ${build(groups["Win64"].subFiles["AVX"])}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Mako==1.4.2
|
||||
Mako==1.3.12
|
||||
requests==2.33.0
|
||||
semantic-version==2.8.5
|
||||
@@ -1,34 +0,0 @@
|
||||
# Installs ATL and MFC for the v143 toolset, which the Visual Studio 2026 runner images
|
||||
# only ship for the latest toolset. ATL is needed by SAPI speech (sphelper.h) and MFC by FRED2.
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$msvcVersion = '14.44'
|
||||
$component = 'Microsoft.VisualStudio.Component.VC.14.44.17.14'
|
||||
$suffix = if ($env:RUNNER_ARCH -eq 'ARM64') { '.ARM64' } else { '' }
|
||||
|
||||
$installerDir = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer"
|
||||
$installPath = & "$installerDir\vswhere.exe" -version '[18.0,19.0)' -latest -property installationPath
|
||||
if (-not $installPath) {
|
||||
Write-Error 'Visual Studio 2026 was not found'
|
||||
}
|
||||
|
||||
$arguments = @(
|
||||
'/c', 'vs_installer.exe', 'modify',
|
||||
'--installPath', "`"$installPath`"",
|
||||
'--add', "$component.ATL$suffix",
|
||||
'--add', "$component.MFC$suffix",
|
||||
'--quiet', '--norestart', '--nocache'
|
||||
)
|
||||
$process = Start-Process -FilePath cmd.exe -ArgumentList $arguments -WorkingDirectory $installerDir -Wait -PassThru -NoNewWindow
|
||||
# 3010 = success, reboot required
|
||||
if ($process.ExitCode -notin 0, 3010) {
|
||||
Write-Error "vs_installer exited with code $($process.ExitCode)"
|
||||
}
|
||||
|
||||
# fail here rather than with a confusing compile error if the components didn't install
|
||||
foreach ($header in 'atlbase.h', 'afxwin.h') {
|
||||
if (-not (Test-Path "$installPath\VC\Tools\MSVC\$msvcVersion.*\atlmfc\include\$header")) {
|
||||
Write-Error "$header for MSVC $msvcVersion is missing after install"
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
# - Removes duplicate entries and non-directories from a provided list
|
||||
#
|
||||
# clean_directory_list(<listvar> [<additional list items>...])
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__clean_directory_list)
|
||||
return()
|
||||
endif()
|
||||
set(__clean_directory_list YES)
|
||||
|
||||
function(clean_directory_list _var)
|
||||
# combine variable's current value with additional list items
|
||||
set(_in ${${_var}} ${ARGN})
|
||||
|
||||
if(_in)
|
||||
# Initial list cleaning
|
||||
list(REMOVE_DUPLICATES _in)
|
||||
|
||||
# Grab the absolute path of each actual directory
|
||||
set(_out)
|
||||
foreach(_dir ${_in})
|
||||
if(IS_DIRECTORY "${_dir}")
|
||||
get_filename_component(_dir "${_dir}" ABSOLUTE)
|
||||
file(TO_CMAKE_PATH "${_dir}" _dir)
|
||||
list(APPEND _out "${_dir}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(_out)
|
||||
# Clean up the output list now
|
||||
list(REMOVE_DUPLICATES _out)
|
||||
endif()
|
||||
|
||||
# return _out
|
||||
set(${_var} "${_out}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -1,311 +0,0 @@
|
||||
# - Create launchers to set working directory, env. vars, etc.
|
||||
#
|
||||
# include(CreateLaunchers) - to make these available
|
||||
# guess_runtime_library_dirs(<outputvarname> [<extralibrary> ...])
|
||||
# create_default_target_launcher(<targetname>
|
||||
# [ARGS <args...>]
|
||||
# [FORWARD_ARGS]
|
||||
# [RUNTIME_LIBRARY_DIRS <dir...>]
|
||||
# [WORKING_DIRECTORY <dir>]
|
||||
# [ENVIRONMENT <VAR=value> [<VAR=value>...]])
|
||||
#
|
||||
# create_target_launcher(<targetname>
|
||||
# [ARGS <args...>]
|
||||
# [FORWARD_ARGS]
|
||||
# [RUNTIME_LIBRARY_DIRS <dir...>]
|
||||
# [WORKING_DIRECTORY <dir>]
|
||||
# [ENVIRONMENT <VAR=value> [<VAR=value>...]])
|
||||
#
|
||||
# create_generic_launcher(<launchername>
|
||||
# [RUNTIME_LIBRARY_DIRS <dir...>]
|
||||
# [WORKING_DIRECTORY <dir>]
|
||||
# [ENVIRONMENT <VAR=value> [<VAR=value>...]])
|
||||
# - sets GENERIC_LAUNCHER_COMMAND and GENERIC_LAUNCHER_FAIL_REGULAR_EXPRESSION
|
||||
#
|
||||
# Requires these CMake modules:
|
||||
# ListFilter
|
||||
# ProgramFilesGlob
|
||||
# CleanDirectoryList
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__create_launchers)
|
||||
return()
|
||||
endif()
|
||||
set(__create_launchers YES)
|
||||
|
||||
include(CleanDirectoryList)
|
||||
|
||||
# We must run the following at "include" time, not at function call time,
|
||||
# to find the path to this module rather than the path to a calling list file
|
||||
get_filename_component(_launchermoddir
|
||||
${CMAKE_CURRENT_LIST_FILE}
|
||||
PATH)
|
||||
set(_launchermoddir "${_launchermoddir}/launcher-templates")
|
||||
|
||||
macro(_launcher_system_settings)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(BITS 64)
|
||||
else()
|
||||
set(BITS 32)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
# Find user and system name
|
||||
set(SYSTEM_NAME $ENV{USERDOMAIN})
|
||||
set(USER_NAME $ENV{USERNAME})
|
||||
set(VCPROJ_TYPE vcproj)
|
||||
set(USERFILE_EXTENSION ${SYSTEM_NAME}.${USER_NAME}.user)
|
||||
set(LAUNCHER_LINESEP "
")
|
||||
if(MSVC90)
|
||||
set(USERFILE_VC_VERSION 9.00)
|
||||
elseif(MSVC80)
|
||||
set(USERFILE_VC_VERSION 8.00)
|
||||
elseif(MSVC71)
|
||||
set(USERFILE_VC_VERSION 7.10)
|
||||
elseif(MSVC10 OR (MSVC AND MSVC_VERSION GREATER 1600)) # 2010 or newer
|
||||
set(LAUNCHER_LINESEP "\n")
|
||||
set(USERFILE_VC_VERSION 10.00)
|
||||
set(USERFILE_EXTENSION user)
|
||||
set(VCPROJ_TYPE vcxproj)
|
||||
endif()
|
||||
if(BITS EQUAL 64)
|
||||
set(USERFILE_PLATFORM x64)
|
||||
else()
|
||||
set(USERFILE_PLATFORM Win${BITS})
|
||||
endif()
|
||||
set(_pathdelim ";")
|
||||
set(_suffix "cmd")
|
||||
else()
|
||||
set(_pathdelim ":")
|
||||
set(USERFILE_PLATFORM ${CMAKE_SYSTEM_NAME}${BITS})
|
||||
set(_suffix "sh")
|
||||
find_package(GDB QUIET)
|
||||
if(GDB_FOUND)
|
||||
set(LAUNCHERS_GOT_GDB YES)
|
||||
if(GDB_HAS_RETURN_CHILD_RESULT)
|
||||
set(LAUNCHERS_GDB_ARG --return-child-result)
|
||||
endif()
|
||||
else()
|
||||
set(LAUNCHERS_GOT_GDB)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT USERFILE_REMOTE_MACHINE)
|
||||
site_name(USERFILE_REMOTE_MACHINE)
|
||||
mark_as_advanced(USERFILE_REMOTE_MACHINE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(_launcher_process_args)
|
||||
set(_nowhere)
|
||||
set(_curdest _nowhere)
|
||||
set(_val_args
|
||||
ARGS
|
||||
RUNTIME_LIBRARY_DIRS
|
||||
WORKING_DIRECTORY
|
||||
ENVIRONMENT)
|
||||
set(_bool_args FORWARD_ARGS)
|
||||
foreach(_arg ${_val_args} ${_bool_args})
|
||||
set(${_arg})
|
||||
endforeach()
|
||||
foreach(_element ${ARGN})
|
||||
list(FIND _val_args "${_element}" _val_arg_find)
|
||||
list(FIND _bool_args "${_element}" _bool_arg_find)
|
||||
if("${_val_arg_find}" GREATER "-1")
|
||||
set(_curdest "${_element}")
|
||||
elseif("${_bool_arg_find}" GREATER "-1")
|
||||
set("${_element}" ON)
|
||||
set(_curdest _nowhere)
|
||||
else()
|
||||
list(APPEND ${_curdest} "${_element}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(_nowhere)
|
||||
message(FATAL_ERROR
|
||||
"Syntax error in use of a function in CreateLaunchers!")
|
||||
endif()
|
||||
|
||||
# Turn into a list of native paths
|
||||
set(_runtime_lib_dirs)
|
||||
foreach(_dlldir ${RUNTIME_LIBRARY_DIRS})
|
||||
file(TO_NATIVE_PATH "${_dlldir}" _path)
|
||||
set(_runtime_lib_dirs "${_runtime_lib_dirs}${_path}${_pathdelim}")
|
||||
endforeach()
|
||||
|
||||
if(NOT WORKING_DIRECTORY)
|
||||
set(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
if(FORWARD_ARGS)
|
||||
if(WIN32)
|
||||
set(FWD_ARGS %*)
|
||||
else()
|
||||
set(FWD_ARGS $*)
|
||||
endif()
|
||||
else()
|
||||
set(FWD_ARGS)
|
||||
endif()
|
||||
|
||||
set(USERFILE_WORKING_DIRECTORY "${WORKING_DIRECTORY}")
|
||||
set(USERFILE_COMMAND_ARGUMENTS "${ARGS}")
|
||||
set(LAUNCHERSCRIPT_COMMAND_ARGUMENTS "${ARGS} ${FWD_ARGS}")
|
||||
|
||||
if(WIN32)
|
||||
set(RUNTIME_LIBRARIES_ENVIRONMENT "PATH=${_runtime_lib_dirs};%PATH%")
|
||||
file(READ
|
||||
"${_launchermoddir}/launcher.env.cmd.in"
|
||||
_cmdenv)
|
||||
else()
|
||||
if(APPLE)
|
||||
set(RUNTIME_LIBRARIES_ENVIRONMENT
|
||||
"DYLD_LIBRARY_PATH=${_runtime_lib_dirs}:$DYLD_LIBRARY_PATH")
|
||||
else()
|
||||
set(RUNTIME_LIBRARIES_ENVIRONMENT
|
||||
"LD_LIBRARY_PATH=${_runtime_lib_dirs}:$LD_LIBRARY_PATH")
|
||||
endif()
|
||||
file(READ
|
||||
"${_launchermoddir}/launcher.env.sh.in"
|
||||
_cmdenv)
|
||||
endif()
|
||||
set(USERFILE_ENVIRONMENT "${RUNTIME_LIBRARIES_ENVIRONMENT}")
|
||||
|
||||
set(USERFILE_ENV_COMMANDS)
|
||||
foreach(_arg "${RUNTIME_LIBRARIES_ENVIRONMENT}" ${ENVIRONMENT})
|
||||
string(CONFIGURE
|
||||
"@USERFILE_ENVIRONMENT@@LAUNCHER_LINESEP@@_arg@"
|
||||
USERFILE_ENVIRONMENT
|
||||
@ONLY)
|
||||
string(CONFIGURE
|
||||
"@USERFILE_ENV_COMMANDS@${_cmdenv}"
|
||||
USERFILE_ENV_COMMANDS
|
||||
@ONLY)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
macro(_launcher_produce_vcproj_user)
|
||||
if(MSVC)
|
||||
file(READ
|
||||
"${_launchermoddir}/perconfig.${VCPROJ_TYPE}.user.in"
|
||||
_perconfig)
|
||||
file(TO_NATIVE_PATH "${USERFILE_WORKING_DIRECTORY}" NATIVE_WORKING_DIRECTORY)
|
||||
set(USERFILE_CONFIGSECTIONS)
|
||||
foreach(USERFILE_CONFIGNAME ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(CONFIGURE "${_perconfig}" _temp @ONLY ESCAPE_QUOTES)
|
||||
set(USERFILE_CONFIGSECTIONS "${USERFILE_CONFIGSECTIONS}${_temp}")
|
||||
endforeach()
|
||||
|
||||
|
||||
configure_file("${_launchermoddir}/${VCPROJ_TYPE}.user.in"
|
||||
"${VCPROJNAME}.${VCPROJ_TYPE}.${USERFILE_EXTENSION}"
|
||||
@ONLY)
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
||||
macro(_launcher_configure_executable _src _tmp _target)
|
||||
# get_filename_component(_targetname "${_target}" NAME)
|
||||
get_filename_component(_targetpath "${_target}" PATH)
|
||||
configure_file("${_src}"
|
||||
"${_tmp}"
|
||||
@ONLY)
|
||||
file(COPY "${_tmp}"
|
||||
DESTINATION "${_targetpath}"
|
||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
endmacro()
|
||||
|
||||
macro(_launcher_create_target_launcher)
|
||||
set(TARGET_NAME ${_targetname})
|
||||
|
||||
set(_fn "launch-${_targetname}-generator.${_suffix}")
|
||||
|
||||
configure_file("${_launchermoddir}/targetlauncher.${_suffix}.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_fn}"
|
||||
@ONLY)
|
||||
|
||||
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/launch-${_targetname}-$<CONFIGURATION>.${_suffix}"
|
||||
INPUT "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_fn}")
|
||||
endmacro()
|
||||
|
||||
function(create_default_target_launcher _targetname)
|
||||
_launcher_system_settings()
|
||||
_launcher_process_args(${ARGN})
|
||||
|
||||
set(VCPROJNAME "${CMAKE_BINARY_DIR}/ALL_BUILD")
|
||||
_launcher_produce_vcproj_user()
|
||||
|
||||
_launcher_create_target_launcher()
|
||||
endfunction()
|
||||
|
||||
function(create_target_launcher _targetname)
|
||||
_launcher_system_settings()
|
||||
_launcher_process_args(${ARGN})
|
||||
|
||||
set(VCPROJNAME "${CMAKE_CURRENT_BINARY_DIR}/${_targetname}")
|
||||
_launcher_produce_vcproj_user()
|
||||
|
||||
_launcher_create_target_launcher()
|
||||
endfunction()
|
||||
|
||||
function(create_generic_launcher _launchername)
|
||||
_launcher_system_settings()
|
||||
_launcher_process_args(${ARGN})
|
||||
|
||||
if(NOT IS_ABSOLUTE _launchername)
|
||||
set(_launchername
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${_launchername}.${_suffix}")
|
||||
else()
|
||||
set(_launchername "${_launchername}.${_suffix}")
|
||||
endif()
|
||||
if(WIN32)
|
||||
set(GENERIC_LAUNCHER_COMMAND "${_launchername}" PARENT_SCOPE)
|
||||
set(GENERIC_LAUNCHER_FAIL_REGULAR_EXPRESSION)
|
||||
else()
|
||||
set(GENERIC_LAUNCHER_COMMAND sh "${_launchername}" PARENT_SCOPE)
|
||||
set(GENERIC_LAUNCHER_FAIL_REGULAR_EXPRESSION
|
||||
"Program terminated with signal")
|
||||
endif()
|
||||
|
||||
_launcher_configure_executable("${_launchermoddir}/genericlauncher.${_suffix}.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/genericlauncher.${_suffix}.in"
|
||||
"${_launchername}")
|
||||
endfunction()
|
||||
|
||||
function(guess_runtime_library_dirs _var)
|
||||
# Start off with the link directories of the calling listfile's directory
|
||||
get_directory_property(_libdirs LINK_DIRECTORIES)
|
||||
|
||||
# Add additional libraries passed to the function
|
||||
foreach(_lib ${ARGN})
|
||||
get_filename_component(_libdir "${_lib}" PATH)
|
||||
list(APPEND _libdirs "${_libdir}")
|
||||
endforeach()
|
||||
|
||||
# Now, build a list of potential dll directories
|
||||
set(_dlldirs)
|
||||
foreach(_libdir ${_libdirs})
|
||||
# Add the libdir itself
|
||||
list(APPEND _dlldirs "${_libdir}")
|
||||
|
||||
# Look also in libdir/../bin since the dll might not be with the lib
|
||||
get_filename_component(_libdir "${_libdir}/../bin" ABSOLUTE)
|
||||
list(APPEND _dlldirs "${_libdir}")
|
||||
endforeach()
|
||||
|
||||
# Only keep the valid, unique directories
|
||||
clean_directory_list(_dlldirs)
|
||||
|
||||
# Return _dlldirs
|
||||
set(${_var} "${_dlldirs}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -1,88 +0,0 @@
|
||||
# - Add flags to compile with extra warnings
|
||||
#
|
||||
# enable_extra_compiler_warnings(<targetname>)
|
||||
# globally_enable_extra_compiler_warnings() - to modify CMAKE_CXX_FLAGS, etc
|
||||
# to change for all targets declared after the command, instead of per-command
|
||||
#
|
||||
#
|
||||
# Original Author:
|
||||
# 2010 Ryan Pavlik <[email protected]> <[email protected]>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__enable_extra_compiler_warnings)
|
||||
return()
|
||||
endif()
|
||||
set(__enable_extra_compiler_warnings YES)
|
||||
|
||||
macro(_enable_extra_compiler_warnings_flags)
|
||||
set(_flags)
|
||||
if(MSVC)
|
||||
option(COMPILER_WARNINGS_EXTREME
|
||||
"Use compiler warnings that are probably overkill."
|
||||
off)
|
||||
mark_as_advanced(COMPILER_WARNINGS_EXTREME)
|
||||
set(_flags "/W4")
|
||||
if(COMPILER_WARNINGS_EXTREME)
|
||||
set(_flags "${_flags} /Wall /wd4619 /wd4668 /wd4820 /wd4571 /wd4710")
|
||||
endif()
|
||||
else()
|
||||
include(CheckCXXCompilerFlag)
|
||||
set(_flags)
|
||||
|
||||
check_cxx_compiler_flag(-W SUPPORTS_W_FLAG)
|
||||
if(SUPPORTS_W_FLAG)
|
||||
set(_flags "${_flags} -W")
|
||||
endif()
|
||||
|
||||
check_cxx_compiler_flag(-Wall SUPPORTS_WALL_FLAG)
|
||||
if(SUPPORTS_WALL_FLAG)
|
||||
set(_flags "${_flags} -Wall")
|
||||
endif()
|
||||
|
||||
check_cxx_compiler_flag(-Wextra SUPPORTS_WEXTRA_FLAG)
|
||||
if(SUPPORTS_WEXTRA_FLAG)
|
||||
set(_flags "${_flags} -Wextra")
|
||||
endif()
|
||||
|
||||
if(SUPPORTS_WALL_FLAG)
|
||||
# At least GCC includes -Wmaybe-uninitialized in -Wall, which
|
||||
# unneccesarily whines about boost::optional (by it's nature
|
||||
# it's a "maybe" warning - prone to noisy false-positives)
|
||||
check_cxx_compiler_flag(-Wno-maybe-uninitialized SUPPORTS_WNO_MAYBE_UNINITIALIZED_FLAG)
|
||||
if(SUPPORTS_WNO_MAYBE_UNINITIALIZED_FLAG)
|
||||
set(_flags "${_flags} -Wno-maybe-uninitialized")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(enable_extra_compiler_warnings _target)
|
||||
_enable_extra_compiler_warnings_flags()
|
||||
get_target_property(_origflags ${_target} COMPILE_FLAGS)
|
||||
if(_origflags)
|
||||
set_property(TARGET
|
||||
${_target}
|
||||
PROPERTY
|
||||
COMPILE_FLAGS
|
||||
"${_flags} ${_origflags}")
|
||||
else()
|
||||
set_property(TARGET
|
||||
${_target}
|
||||
PROPERTY
|
||||
COMPILE_FLAGS
|
||||
"${_flags}")
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
function(globally_enable_extra_compiler_warnings)
|
||||
_enable_extra_compiler_warnings_flags()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flags}" PARENT_SCOPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flags}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -1,53 +0,0 @@
|
||||
# - Combine lists of prefixes and suffixes in all combinations
|
||||
#
|
||||
# list_combinations(var PREFIXES listitems... SUFFIXES listitems...) -
|
||||
# where var is the name of your desired output variable and PREFIXES
|
||||
# and SUFFIXES are special arguments that indicate the start of your
|
||||
# list of prefixes or suffixes respectively.
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__list_combinations)
|
||||
return()
|
||||
endif()
|
||||
set(__list_combinations YES)
|
||||
|
||||
function(list_combinations var)
|
||||
# Parse arguments
|
||||
set(_prefixes)
|
||||
set(_suffixes)
|
||||
set(_nowhere)
|
||||
set(_curdest _nowhere)
|
||||
foreach(_element ${ARGN})
|
||||
if("${_element}" STREQUAL "PREFIXES")
|
||||
set(_curdest _prefixes)
|
||||
elseif("${_element}" STREQUAL "SUFFIXES")
|
||||
set(_curdest _suffixes)
|
||||
else()
|
||||
list(APPEND ${_curdest} "${_element}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(_nowhere)
|
||||
message(STATUS "_prefixes ${_prefixes}")
|
||||
message(STATUS "_prefixes ${_suffixes}")
|
||||
message(STATUS "_prefixes ${_nowhere}")
|
||||
message(FATAL_ERROR
|
||||
"Syntax error in use of ${CMAKE_CURRENT_LIST_FILE}")
|
||||
endif()
|
||||
|
||||
foreach(_prefix ${_prefixes})
|
||||
foreach(_suffix ${_suffixes})
|
||||
list(APPEND _out "${_prefix}${_suffix}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
set(${var} "${_out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -1,31 +0,0 @@
|
||||
# - Compile with multiple processes on MSVC
|
||||
#
|
||||
# include(MSVCMultipleProcessCompile)
|
||||
#
|
||||
# Requires these CMake modules:
|
||||
# ListCombinations.cmake
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(MSVC AND NOT "${MSVC_VERSION}" LESS 1400)
|
||||
# Only available in VS 2005 and newer
|
||||
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" _conftypesUC)
|
||||
include(ListCombinations)
|
||||
list_combinations(_varnames
|
||||
PREFIXES
|
||||
CMAKE_C_FLAGS_
|
||||
CMAKE_CXX_FLAGS_
|
||||
SUFFIXES
|
||||
${_conftypesUC})
|
||||
foreach(_var ${_varnames})
|
||||
set(${_var} "${${_var}} /MP")
|
||||
endforeach()
|
||||
endif()
|
||||
+1
Submodule cmake/external/rpavlik-cmake-modules added at 7cef9577d6.
@@ -11,8 +11,6 @@ if (WIN32)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
# it should just work
|
||||
elseif(ANDROID)
|
||||
# connects to a java TTS manager via SDL activity class
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# uses speech-dispatcher with dlopen
|
||||
else()
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
cd @USERFILE_WORKING_DIRECTORY@
|
||||
@USERFILE_ENV_COMMANDS@
|
||||
|
||||
IF NOT [x%1]==[x--debugger] GOTO SkipDebuggingMess
|
||||
|
||||
ECHO Need to ditch the debugger!
|
||||
SHIFT /1
|
||||
%1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
GOTO EOF
|
||||
|
||||
:SkipDebuggingMess
|
||||
%*
|
||||
|
||||
:EOF
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
bindir=$(pwd)
|
||||
cd @USERFILE_WORKING_DIRECTORY@
|
||||
@USERFILE_ENV_COMMANDS@
|
||||
if test "x$1" = "x--debugger"; then
|
||||
shift
|
||||
cmd="$1"
|
||||
shift
|
||||
if test "x@LAUNCHERS_GOT_GDB@" = "xYES"; then
|
||||
echo "r $@" > $bindir/gdbscript
|
||||
echo "bt" >> $bindir/gdbscript
|
||||
@GDB_COMMAND@ -batch -command=$bindir/gdbscript @LAUNCHERS_GDB_ARG@ $cmd
|
||||
else
|
||||
$cmd $@
|
||||
fi
|
||||
else
|
||||
$@
|
||||
fi
|
||||
@@ -1 +0,0 @@
|
||||
set @_arg@
|
||||
@@ -1 +0,0 @@
|
||||
export @_arg@
|
||||
@@ -1,28 +0,0 @@
|
||||
<Configuration
|
||||
Name="@USERFILE_CONFIGNAME@|@USERFILE_PLATFORM@"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="${USERFILE_@USERFILE_CONFIGNAME@_COMMAND}"
|
||||
WorkingDirectory="@USERFILE_WORKING_DIRECTORY@"
|
||||
CommandArguments="@USERFILE_COMMAND_ARGUMENTS@"
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="@USERFILE_REMOTE_MACHINE@"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment="@USERFILE_ENVIRONMENT@"
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
@@ -1,7 +0,0 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='@USERFILE_CONFIGNAME@|@USERFILE_PLATFORM@'">
|
||||
<LocalDebuggerEnvironment>@USERFILE_ENVIRONMENT@</LocalDebuggerEnvironment>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(TargetPath)</LocalDebuggerCommand>
|
||||
<LocalDebuggerCommandArguments>@USERFILE_COMMAND_ARGUMENTS@</LocalDebuggerCommandArguments>
|
||||
<LocalDebuggerWorkingDirectory>@NATIVE_WORKING_DIRECTORY@</LocalDebuggerWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
@@ -1,8 +0,0 @@
|
||||
cd @USERFILE_WORKING_DIRECTORY@
|
||||
@USERFILE_ENV_COMMANDS@
|
||||
if [%1]==[--debugger] (
|
||||
SHIFT
|
||||
)
|
||||
|
||||
"@USERFILE_COMMAND@" @LAUNCHERSCRIPT_COMMAND_ARGUMENTS@
|
||||
pause
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
bindir=$(pwd)
|
||||
cd @USERFILE_WORKING_DIRECTORY@
|
||||
@USERFILE_ENV_COMMANDS@
|
||||
if test "x$1" = "x--debugger"; then
|
||||
shift
|
||||
if test "x@LAUNCHERS_GOT_GDB@" = "xYES"; then
|
||||
echo "r @LAUNCHERSCRIPT_COMMAND_ARGUMENTS@" > $bindir/gdbscript
|
||||
echo "bt" >> $bindir/gdbscript
|
||||
@GDB_COMMAND@ -batch -command=$bindir/gdbscript @LAUNCHERS_GDB_ARG@ @USERFILE_COMMAND@
|
||||
else
|
||||
"@USERFILE_COMMAND@" @LAUNCHERSCRIPT_COMMAND_ARGUMENTS@
|
||||
fi
|
||||
else
|
||||
"@USERFILE_COMMAND@" @LAUNCHERSCRIPT_COMMAND_ARGUMENTS@
|
||||
fi
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="@USERFILE_VC_VERSION@"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
@USERFILE_CONFIGSECTIONS@
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
@USERFILE_CONFIGSECTIONS@
|
||||
</Project>
|
||||
@@ -11,6 +11,9 @@ endif()
|
||||
|
||||
target_link_libraries(platform INTERFACE ${COCOA_LIBRARY})
|
||||
|
||||
# To support C++17 we need to target at least 10.13. maybe 10.14 for some rare features
|
||||
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
|
||||
|
||||
SET(CMAKE_SKIP_RPATH FALSE)
|
||||
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
SET(CMAKE_INSTALL_RPATH @loader_path/../Frameworks/)
|
||||
|
||||
@@ -43,6 +43,7 @@ endif()
|
||||
|
||||
if (USE_STATIC_LIBCXX)
|
||||
set(CXX_BASE_FLAGS "${CXX_BASE_FLAGS} -static-libstdc++ -Qunused-arguments")
|
||||
set(CLANG_USE_LIBCXX ON)
|
||||
endif()
|
||||
|
||||
# For C and C++, the values can be overwritten independently
|
||||
@@ -134,10 +135,8 @@ endif()
|
||||
set(CXX_FLAGS_RELEASE "${CXX_OPT_FLAG_RELEASE} -Wno-unused-variable -Wno-unused-parameter")
|
||||
set(C_FLAGS_RELEASE "${C_OPT_FLAG_RELEASE} -Wno-unused-variable -Wno-unused-parameter")
|
||||
|
||||
# Valgrind (as used by CI) does not understand the DWARF5 debug info that clang
|
||||
# emits by default, so force DWARF4 to keep memcheck able to symbolize the binary.
|
||||
set(CXX_FLAGS_DEBUG "${CXX_OPT_FLAG_DEBUG} -g -gdwarf-4 -Wshadow")
|
||||
set(C_FLAGS_DEBUG "${C_OPT_FLAG_DEBUG} -g -gdwarf-4 -Wshadow")
|
||||
set(CXX_FLAGS_DEBUG "${CXX_OPT_FLAG_DEBUG} -g -Wshadow")
|
||||
set(C_FLAGS_DEBUG "${C_OPT_FLAG_DEBUG} -g -Wshadow")
|
||||
|
||||
# Always use the base flags and add our compiler flags at the back
|
||||
set(CMAKE_CXX_FLAGS "${CXX_BASE_FLAGS} ${COMPILER_FLAGS}")
|
||||
|
||||
@@ -13,13 +13,6 @@ option(MSVC_RELEASE_DEBUGGING "Set options that allow to debug release builds" O
|
||||
MARK_AS_ADVANCED(FORCE MSVC_USE_RUNTIME_DLL)
|
||||
MARK_AS_ADVANCED(FORCE MSVC_RELEASE_DEBUGGING)
|
||||
|
||||
# Qt is only available as DLL-runtime builds, so qtFRED forces the DLL runtime for the whole tree
|
||||
if(MSVC_USE_RUNTIME_DLL OR FSO_BUILD_QTFRED)
|
||||
set(FSO_MSVC_RUNTIME_DLL ON)
|
||||
else()
|
||||
set(FSO_MSVC_RUNTIME_DLL OFF)
|
||||
endif()
|
||||
|
||||
# These are the warnings we disable
|
||||
set(WARNING_FLAGS
|
||||
/wd4100 # unreferenced formal parameters
|
||||
@@ -78,12 +71,12 @@ if (MSVC_RELEASE_DEBUGGING)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# The debug runtime is not redistributable (statically linked or not), so only Debug may use it
|
||||
IF(FSO_MSVC_RUNTIME_DLL)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
# This should be kept in sync with the corresponding IF() in fred2/CMakeLists.txt
|
||||
IF(MSVC_USE_RUNTIME_DLL OR FSO_BUILD_QTFRED)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<NOT:$<CONFIG:Release>>:Debug>DLL")
|
||||
add_compile_definitions(_AFXDLL)
|
||||
ELSE()
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<NOT:$<CONFIG:Release>>:Debug>")
|
||||
ENDIF()
|
||||
|
||||
# Debug
|
||||
|
||||
+10
-7
@@ -3,13 +3,7 @@
|
||||
|
||||
add_library(compiler INTERFACE)
|
||||
|
||||
set(FSO_CONFIG_DEFINITIONS "$<$<CONFIG:Release>:NDEBUG>" "$<$<CONFIG:Debug>:_DEBUG>")
|
||||
if(NOT MSVC)
|
||||
# On MSVC the debug runtime flags (/MTd, /MDd) define _DEBUG themselves, and a FastDebug
|
||||
# build on the release runtime must not have it
|
||||
list(APPEND FSO_CONFIG_DEFINITIONS "$<$<CONFIG:FastDebug>:_DEBUG>")
|
||||
endif()
|
||||
target_compile_definitions(compiler INTERFACE ${FSO_CONFIG_DEFINITIONS})
|
||||
target_compile_definitions(compiler INTERFACE "$<$<CONFIG:Release>:NDEBUG>;$<$<CONFIG:Debug>:_DEBUG>;$<$<CONFIG:FastDebug>:_DEBUG>")
|
||||
|
||||
set(FORCED_NATIVE_SIMD_INSTRUCTIONS ON CACHE BOOL "Override instruction set detection and compile with the maximum possible instructions for the current system.")
|
||||
IF(IS_X86)
|
||||
@@ -80,3 +74,12 @@ set(CMAKE_C_FLAGS_FASTDEBUG "${CMAKE_C_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_FASTDEBUG "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_FASTDEBUG "${CMAKE_STATIC_LINKER_FLAGS_RELEASE}")
|
||||
|
||||
if (MSVC)
|
||||
# Adjust runtime library
|
||||
string(REPLACE "/MD" "/MDd" CMAKE_C_FLAGS_FASTDEBUG "${CMAKE_C_FLAGS_FASTDEBUG}")
|
||||
string(REPLACE "/MT" "/MTd" CMAKE_C_FLAGS_FASTDEBUG "${CMAKE_C_FLAGS_FASTDEBUG}")
|
||||
|
||||
string(REPLACE "/MD" "/MDd" CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_FASTDEBUG}")
|
||||
string(REPLACE "/MT" "/MTd" CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_FASTDEBUG}")
|
||||
endif()
|
||||
+14
-29
@@ -66,37 +66,33 @@ ENDIF(EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${FILE}\")
|
||||
SET(${OUTVAR} "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${NAME} PARENT_SCOPE)
|
||||
ENDFUNCTION(EP_CHECK_FILE_EXISTS)
|
||||
|
||||
# Use rsync if possible for COPY_FILE_TO_TARGET macro in order to preserve
|
||||
# symlinks as copy_if_different follows them which results in multiple copies
|
||||
if(PLATFORM_UNIX AND NOT DEFINED RSYNC_BIN)
|
||||
find_program(RSYNC_BIN rsync)
|
||||
endif()
|
||||
|
||||
MACRO(COPY_FILE_TO_TARGET _target _file)
|
||||
if(RSYNC_BIN)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET ${_target} POST_BUILD
|
||||
COMMAND ${RSYNC_BIN} -rlq "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}"
|
||||
COMMENT "copying '${_file}'..."
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
if (IS_DIRECTORY "${_file}")
|
||||
get_filename_component(_dirName "${_file}" NAME)
|
||||
if (IS_DIRECTORY "${_file}")
|
||||
get_filename_component(_dirName "${_file}" NAME)
|
||||
if (PLATFORM_MAC AND ("${_file}" MATCHES ".framework$"))
|
||||
# This is stupid, but it preserves symlinks, unlike copy_directory_if_different.
|
||||
# Otherwise we end up creating duplicate files in the copied framework.
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET ${_target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/${_dirName}"
|
||||
COMMAND rsync -rlq "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}"
|
||||
COMMENT "copying '${_file}'..."
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET ${_target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/${_dirName}"
|
||||
COMMENT "copying '${_file}'..."
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET ${_target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
|
||||
COMMENT "copying '${_file}'..."
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
endmacro(COPY_FILE_TO_TARGET)
|
||||
|
||||
@@ -241,17 +237,6 @@ function(suppress_file_warnings)
|
||||
endif()
|
||||
endfunction(suppress_file_warnings)
|
||||
|
||||
# Suppress no symbols warnings in static libraries (on Xcode)
|
||||
function(suppress_no_symbol_warnings _target)
|
||||
if(XCODE)
|
||||
get_target_property(target_type ${_target} TYPE)
|
||||
if(target_type STREQUAL "STATIC_LIBRARY")
|
||||
set_property(TARGET ${_target} APPEND PROPERTY
|
||||
STATIC_LIBRARY_OPTIONS "-no_warning_for_no_symbols"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endfunction(suppress_no_symbol_warnings)
|
||||
|
||||
function(list_target_dependencies _target _out_var)
|
||||
set(out_list)
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ if (EXISTS "${PROJECT_SOURCE_DIR}/version_override.cmake")
|
||||
include("${PROJECT_SOURCE_DIR}/version_override.cmake")
|
||||
endif()
|
||||
|
||||
set_if_not_defined(FSO_VERSION_MAJOR 26)
|
||||
set_if_not_defined(FSO_VERSION_MINOR 3)
|
||||
set_if_not_defined(FSO_VERSION_MAJOR 25)
|
||||
set_if_not_defined(FSO_VERSION_MINOR 1)
|
||||
set_if_not_defined(FSO_VERSION_BUILD 0)
|
||||
|
||||
# A numeric revision e.g. the CI build number
|
||||
|
||||
+13
-7
@@ -39,7 +39,7 @@ TARGET_LINK_LIBRARIES(code PUBLIC ${PNG_LIBS})
|
||||
TARGET_LINK_LIBRARIES(code PUBLIC ${JPEG_LIBS})
|
||||
TARGET_LINK_LIBRARIES(code PUBLIC lz4)
|
||||
|
||||
TARGET_LINK_LIBRARIES(code PUBLIC sdl3)
|
||||
TARGET_LINK_LIBRARIES(code PUBLIC sdl2)
|
||||
|
||||
if (FSO_BUILD_WITH_FFMPEG)
|
||||
TARGET_LINK_LIBRARIES(code PUBLIC ffmpeg)
|
||||
@@ -76,6 +76,8 @@ TARGET_LINK_LIBRARIES(code PUBLIC jansson)
|
||||
|
||||
target_link_libraries(code PUBLIC anl)
|
||||
|
||||
target_link_libraries(code PUBLIC hidapi::hidapi)
|
||||
|
||||
target_link_libraries(code PUBLIC imgui)
|
||||
|
||||
IF(FSO_BUILD_WITH_OPENXR)
|
||||
@@ -111,9 +113,16 @@ if (FSO_BUILD_WITH_OPENGL)
|
||||
target_compile_definitions(code PUBLIC WITH_OPENGL)
|
||||
endif()
|
||||
if (FSO_BUILD_WITH_VULKAN)
|
||||
target_compile_definitions(code PUBLIC WITH_VULKAN VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VK_NO_PROTOTYPES)
|
||||
target_include_directories(code PUBLIC Vulkan::Headers)
|
||||
target_link_libraries(code PUBLIC VulkanMemoryAllocator)
|
||||
find_package(Vulkan REQUIRED)
|
||||
if (Vulkan_FOUND)
|
||||
target_compile_definitions(code PUBLIC WITH_VULKAN)
|
||||
target_link_libraries(code PRIVATE Vulkan::Vulkan)
|
||||
|
||||
target_compile_definitions(code PUBLIC WITH_VULKAN VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VK_NO_PROTOTYPES)
|
||||
else()
|
||||
message(WARNING "FSO_BUILD_WITH_VULKAN was set, but the package was unable to be found. Forcing OFF.")
|
||||
set(FSO_BUILD_WITH_VULKAN OFF CACHE BOOL "Enable compilation of the Vulkan renderer" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(shaders.cmake)
|
||||
@@ -130,8 +139,5 @@ set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_COPY_PHASE_STRIP[variant=D
|
||||
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT[variant=Debug] "NO")
|
||||
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN[variant=Debug] "NO")
|
||||
|
||||
# Prevent warnings on files with no symbols on Mac
|
||||
suppress_no_symbol_warnings(code)
|
||||
|
||||
# Prevent GCC warnings in third-party BitOp... see GitHub #4366
|
||||
suppress_file_warnings(scripting/lua/bitop/bit.c)
|
||||
@@ -38,7 +38,7 @@ const TypeDefinition& TypeDefinition::forValueType(ValueType type)
|
||||
case ValueType::String:
|
||||
return s_identifier;
|
||||
default:
|
||||
UNREACHABLE("Invalid value type %d!", static_cast<int>(type));
|
||||
UNREACHABLE("Invalid value type!");
|
||||
return s_integer; // Make compiler happy
|
||||
}
|
||||
}
|
||||
|
||||
+12
-7
@@ -16,11 +16,9 @@
|
||||
#include "ai/ai.h"
|
||||
#include "object/object.h"
|
||||
#include "ship/ship.h"
|
||||
#include "utils/string_utils.h"
|
||||
|
||||
|
||||
// heap-allocated rather than SCP_string, so that the pointers held by ai goals stay valid when the vector grows
|
||||
SCP_vector<SCP_vm_unique_ptr<char>> Goal_target_names;
|
||||
SCP_vector<char *> Goal_target_names;
|
||||
ai_info Ai_info[MAX_AI_INFO];
|
||||
ai_info *Player_ai;
|
||||
|
||||
@@ -59,13 +57,20 @@ const char *ai_get_goal_target_name(const char *name, int *index)
|
||||
Assertion(name != nullptr && index != nullptr, "Arguments cannot be null!");
|
||||
|
||||
for (int i = 0; i < static_cast<int>(Goal_target_names.size()); ++i) {
|
||||
if (!stricmp(name, Goal_target_names[i].get())) {
|
||||
if (!stricmp(name, Goal_target_names[i])) {
|
||||
*index = i;
|
||||
return Goal_target_names[i].get();
|
||||
return Goal_target_names[i];
|
||||
}
|
||||
}
|
||||
|
||||
*index = static_cast<int>(Goal_target_names.size());
|
||||
Goal_target_names.push_back(util::vm_unique_copy(name, false));
|
||||
return Goal_target_names.back().get();
|
||||
Goal_target_names.push_back(vm_strdup(name));
|
||||
return Goal_target_names[*index];
|
||||
}
|
||||
|
||||
void ai_clear_goal_target_names()
|
||||
{
|
||||
for (auto ptr : Goal_target_names)
|
||||
vm_free(ptr);
|
||||
Goal_target_names.clear();
|
||||
}
|
||||
+5
-8
@@ -295,7 +295,6 @@ typedef struct ai_info {
|
||||
vec3d path_create_pos; // Object's position at time of global path creation.
|
||||
matrix path_create_orient; // Object's orientation at time of global path creation.
|
||||
int mp_index; // Model path index. Index in polymodel:model_paths
|
||||
int mp_randomized_vert; // Vertex of the model path that was given a random offset, or -1
|
||||
fix path_next_check_time; // Last time checked to see if would collide with model.
|
||||
int path_goal_dist; // minimum distance to first path point to consider path reached
|
||||
int path_subsystem_next_check; // timestamp to next check if subsystem is still visible
|
||||
@@ -495,8 +494,8 @@ extern int Mission_all_attack; // !0 means all teams attack all teams.
|
||||
extern ai_info Ai_info[];
|
||||
extern ai_info *Player_ai;
|
||||
|
||||
extern SCP_vector<ai_class> Ai_classes;
|
||||
extern SCP_vector<const char*> Ai_class_names;
|
||||
extern ai_class *Ai_classes;
|
||||
extern char** Ai_class_names;
|
||||
|
||||
extern int Num_ai_classes;
|
||||
extern int Ai_firing_enabled;
|
||||
@@ -526,6 +525,7 @@ void ai_object_init(object * obj, int ai_index);
|
||||
void ai_process( object * obj, int ai_index, float frametime );
|
||||
|
||||
const char *ai_get_goal_target_name(const char *name, int *index);
|
||||
void ai_clear_goal_target_names();
|
||||
|
||||
extern void init_ai_system(void);
|
||||
extern void ai_attack_object(object *attacker, object *attacked, int ship_info_index = -1, int class_type = -1);
|
||||
@@ -535,7 +535,6 @@ extern void ai_ignore_wing(object *ignorer, int wingnum);
|
||||
extern void ai_dock_with_object(object *docker, int docker_index, object *dockee, int dockee_index, int dock_type);
|
||||
extern void ai_stay_still(object *still_objp, vec3d *view_pos);
|
||||
extern void ai_do_default_behavior(object *obj);
|
||||
extern void ai_reset_order_state(ai_info *aip);
|
||||
extern void ai_start_waypoints(object *objp, int wl_index, int wp_flags, int start_index, bool force = false);
|
||||
extern void ai_ship_hit(object *objp_ship, object *hit_objp, const vec3d *hit_normal);
|
||||
extern void ai_ship_destroy(int shipnum);
|
||||
@@ -598,9 +597,7 @@ extern int ai_maybe_fire_afterburner(object *objp, ai_info *aip);
|
||||
extern void set_predicted_enemy_pos(vec3d *predicted_enemy_pos, object *pobjp, vec3d *enemy_pos, vec3d *enemy_vel, ai_info *aip);
|
||||
|
||||
extern int is_instructor(object *objp);
|
||||
extern int find_enemy(int objnum, float range, int max_attackers, bool for_pursuit, int ship_info_index = -1, int class_type = -1);
|
||||
extern bool ai_targets_for_pursuit(const ai_info *aip);
|
||||
extern bool ai_declines_pursuit(const object *attacker_objp, const object *target_objp);
|
||||
extern int find_enemy(int objnum, float range, int max_attackers, int ship_info_index = -1, int class_type = -1);
|
||||
|
||||
float ai_get_weapon_speed(const ship_weapon *swp);
|
||||
void set_predicted_enemy_pos_turret(vec3d *predicted_enemy_pos, const vec3d *gun_pos, const object *pobjp, const vec3d *enemy_pos, const vec3d *enemy_vel, float weapon_speed, float time_enemy_in_range);
|
||||
@@ -621,7 +618,7 @@ extern float dock_orient_and_approach(object *docker_objp, int docker_index, obj
|
||||
void ai_set_mode_warp_out(object *objp, ai_info *aip);
|
||||
|
||||
// prototyped by Goober5000
|
||||
int get_nearest_objnum(int objnum, int enemy_team_mask, int enemy_wing, float range, int max_attackers, bool for_pursuit, int ship_info_index, int class_type = -1);
|
||||
int get_nearest_objnum(int objnum, int enemy_team_mask, int enemy_wing, float range, int max_attackers, int ship_info_index, int class_type = -1);
|
||||
|
||||
// moved to header file by Goober5000
|
||||
void ai_announce_ship_dying(object *dying_objp);
|
||||
|
||||
@@ -176,12 +176,6 @@ namespace AI {
|
||||
Dont_limit_change_in_speed_due_to_physics_whack,
|
||||
Guards_ignore_protected_attackers,
|
||||
Fix_standard_strafe,
|
||||
Fix_ai_target_recovery, // a) strafing ships that lose their target re-process their orders, like chasing ships already do
|
||||
// b) ships parked in AIM_NONE while holding a standing chase order (attack-any etc.) re-process their orders;
|
||||
// c) target selection for pursuit (chasing, guard reactions, retaliation) skips ships outside the attacker's
|
||||
// actively-pursues list; targets held while not chasing are unaffected, and explicitly ordered targets are
|
||||
// still assigned but not chased or strafed;
|
||||
// d) enemy_wing is reset when a new order takes over (shared with Fix_stale_ai_order_state)
|
||||
Standard_strafe_used_more,
|
||||
Unify_usage_ai_shield_manage_delay,
|
||||
Fix_AI_shield_management_bug,
|
||||
@@ -197,17 +191,6 @@ namespace AI {
|
||||
Purge_player_issued_form_on_wing_after_subsequent_order,
|
||||
Cancel_future_waves_of_any_wing_launched_from_an_exited_ship,
|
||||
Fix_ignore_if_dead_flag,
|
||||
Kamikaze_no_collision_avoidance,
|
||||
Fix_big_ship_waypoint_completion, // a) big ships complete a waypoint within their radius rather than sqrt(radius);
|
||||
// b) completion no longer requires moving 0.1m in a single frame (framerate-dependent)
|
||||
Fix_shockwave_expire_before_do_damage, // shockwaves whose lifetime is shorter than one frame apply their area damage at least once before expiring
|
||||
Fix_small_ai_recover_after_engines_repaired, // ensure small ship AI can switch back to useful AI modes if engines get repaired
|
||||
Fix_model_path_refresh_randomization, // a subsystem path keeps its randomized point when the path is refreshed because the target moved
|
||||
Fix_bay_speed_ramp, // the fighterbay speed ramp covers only the bay path itself, not points that route a departing ship around the carrier, and never exceeds max speed
|
||||
Fix_stale_ai_order_state, // a) enemy_wing, guard_*, previous_mode, resume_goal_time, and the targeted subsystem (with its path) are reset when a new order takes over (enemy_wing is also reset under Fix_ai_target_recovery);
|
||||
// b) a dynamic chase saves previous_mode/previous_submode; it and strafe entry leave them alone during an ongoing dynamic goal (evading a weapon still overwrites them, which is harmless since the evade resume re-processes orders);
|
||||
// c) resuming guard duty discards any subsystem target and path left over from the interruption;
|
||||
// d) a ship ordered to guard itself, or to guard a wing it leads (including one that becomes leader mid-mission), treats that goal as unachievable instead of holding it forever
|
||||
|
||||
NUM_VALUES
|
||||
};
|
||||
|
||||
+6
-42
@@ -140,7 +140,7 @@ void parse_ai_profiles_tbl(const char *filename)
|
||||
// don't create multiple profiles with the same name
|
||||
if (previous_profile != NULL)
|
||||
{
|
||||
Warning(LOCATION, "An AI profile named '%s' already exists! The new one will not be created.\n", profile_name);
|
||||
Warning(LOCATION, "An ai profile named '%s' already exists! The new one will not be created.\n", profile_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -412,7 +412,7 @@ void parse_ai_profiles_tbl(const char *filename)
|
||||
|
||||
set_flag(profile, "$disable player secondary doublefire:", AI::Profile_Flags::Disable_player_secondary_doublefire);
|
||||
|
||||
set_flag(profile, "$disable AI secondary doublefire:", AI::Profile_Flags::Disable_ai_secondary_doublefire);
|
||||
set_flag(profile, "$disable ai secondary doublefire:", AI::Profile_Flags::Disable_ai_secondary_doublefire);
|
||||
|
||||
set_flag(profile, "$disable weapon damage scaling:", AI::Profile_Flags::Disable_weapon_damage_scaling);
|
||||
|
||||
@@ -450,7 +450,7 @@ void parse_ai_profiles_tbl(const char *filename)
|
||||
|
||||
set_flag(profile, "$force beam turrets to use normal fov:", AI::Profile_Flags::Force_beam_turret_fov);
|
||||
|
||||
set_flag(profile, "$fix AI class bug:", AI::Profile_Flags::Fix_ai_class_bug);
|
||||
set_flag(profile, "$fix ai class bug:", AI::Profile_Flags::Fix_ai_class_bug);
|
||||
|
||||
set_flag(profile, "$turrets ignore targets radius in range checks:", AI::Profile_Flags::Turrets_ignore_target_radius);
|
||||
|
||||
@@ -505,13 +505,13 @@ void parse_ai_profiles_tbl(const char *filename)
|
||||
profile->ai_path_mode = j;
|
||||
}
|
||||
else {
|
||||
Warning(LOCATION, "Invalid AI path mode '%s' specified", buf);
|
||||
Warning(LOCATION, "Invalid ai path mode '%s' specified", buf);
|
||||
}
|
||||
}
|
||||
|
||||
set_flag(profile, "$no warp camera:", AI::Profile_Flags::No_warp_camera);
|
||||
|
||||
set_flag(profile, "$fix AI path order bug:", AI::Profile_Flags::Fix_ai_path_order_bug);
|
||||
set_flag(profile, "$fix ai path order bug:", AI::Profile_Flags::Fix_ai_path_order_bug);
|
||||
|
||||
set_flag(profile, "$strict turret-tagged-only targeting:", AI::Profile_Flags::Strict_turret_tagged_only_targeting);
|
||||
|
||||
@@ -622,7 +622,7 @@ void parse_ai_profiles_tbl(const char *filename)
|
||||
profile->ai_range_aware_secondary_select_mode = j;
|
||||
}
|
||||
else {
|
||||
Warning(LOCATION, "Invalid AI secondary range awareness mode '%s' specified", buf);
|
||||
Warning(LOCATION, "Invalid ai secondary range awareness mode '%s' specified", buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,8 +677,6 @@ void parse_ai_profiles_tbl(const char *filename)
|
||||
|
||||
set_flag(profile, "$fix standard strafe:", AI::Profile_Flags::Fix_standard_strafe);
|
||||
|
||||
set_flag(profile, "$fix AI target recovery:", AI::Profile_Flags::Fix_ai_target_recovery);
|
||||
|
||||
set_flag(profile, "$standard strafe used more:", AI::Profile_Flags::Standard_strafe_used_more);
|
||||
|
||||
if (optional_string("$standard strafe triggers under this speed:")) {
|
||||
@@ -693,14 +691,6 @@ void parse_ai_profiles_tbl(const char *filename)
|
||||
stuff_float(&profile->strafe_max_unhit_time);
|
||||
}
|
||||
|
||||
if (optional_string("$strafe retreat collide time:")) {
|
||||
stuff_float(&profile->strafe_retreat_collide_time);
|
||||
}
|
||||
|
||||
if (optional_string("$strafe retreat collide distance:")) {
|
||||
stuff_float(&profile->strafe_retreat_collide_distance);
|
||||
}
|
||||
|
||||
if (optional_string("$guard uses big-orbit for target radius above:")) {
|
||||
stuff_float(&profile->guard_big_orbit_above_target_radius);
|
||||
}
|
||||
@@ -759,19 +749,6 @@ void parse_ai_profiles_tbl(const char *filename)
|
||||
|
||||
set_flag(profile, "$fix 'ignore if dead' flag:", AI::Profile_Flags::Fix_ignore_if_dead_flag);
|
||||
|
||||
set_flag(profile, "$no collision avoidance for kamikaze fighters:", AI::Profile_Flags::Kamikaze_no_collision_avoidance);
|
||||
|
||||
set_flag(profile, "$fix big ship waypoint completion:", AI::Profile_Flags::Fix_big_ship_waypoint_completion);
|
||||
|
||||
set_flag(profile, "$fix shockwave expiring before dealing damage:", AI::Profile_Flags::Fix_shockwave_expire_before_do_damage);
|
||||
|
||||
set_flag(profile, "$fix fighter/bomber AI recovers after engines repaired:", AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired);
|
||||
|
||||
set_flag(profile, "$fix subsystem path randomization on refresh:", AI::Profile_Flags::Fix_model_path_refresh_randomization);
|
||||
|
||||
set_flag(profile, "$fix fighterbay speed ramp:", AI::Profile_Flags::Fix_bay_speed_ramp);
|
||||
|
||||
set_flag(profile, "$fix stale AI order state:", AI::Profile_Flags::Fix_stale_ai_order_state);
|
||||
|
||||
// end of options ----------------------------------------
|
||||
|
||||
@@ -872,8 +849,6 @@ void ai_profile_t::reset()
|
||||
standard_strafe_when_below_speed = 3.0f;
|
||||
strafe_retreat_box_dist = 300.0f;
|
||||
strafe_max_unhit_time = 20.0f;
|
||||
strafe_retreat_collide_time = 2.0f;
|
||||
strafe_retreat_collide_distance = 100.0f;
|
||||
|
||||
guard_big_orbit_above_target_radius = 500.0f;
|
||||
guard_big_orbit_max_speed_percent = 1.0f;
|
||||
@@ -1000,15 +975,4 @@ void ai_profile_t::reset()
|
||||
if (mod_supports_version(26, 0, 0)) {
|
||||
flags.set(AI::Profile_Flags::Fix_ignore_if_dead_flag);
|
||||
}
|
||||
if (mod_supports_version(26, 2, 0)) {
|
||||
flags.set(AI::Profile_Flags::Kamikaze_no_collision_avoidance);
|
||||
flags.set(AI::Profile_Flags::Fix_big_ship_waypoint_completion);
|
||||
flags.set(AI::Profile_Flags::Fix_shockwave_expire_before_do_damage);
|
||||
flags.set(AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired);
|
||||
flags.set(AI::Profile_Flags::Fix_standard_strafe);
|
||||
flags.set(AI::Profile_Flags::Fix_ai_target_recovery);
|
||||
flags.set(AI::Profile_Flags::Fix_model_path_refresh_randomization);
|
||||
flags.set(AI::Profile_Flags::Fix_bay_speed_ramp);
|
||||
flags.set(AI::Profile_Flags::Fix_stale_ai_order_state);
|
||||
}
|
||||
}
|
||||
@@ -143,8 +143,6 @@ public:
|
||||
float standard_strafe_when_below_speed; // Speed at which standard strafing large ships is possibly triggered
|
||||
float strafe_retreat_box_dist; // Distance beyond the bounding box to retreat to strafing point
|
||||
float strafe_max_unhit_time; // Maximum amount of time to stay in strafe mode if not hit
|
||||
float strafe_retreat_collide_time; // When anticipated collision time is less than this, begin retreat from strafe
|
||||
float strafe_retreat_collide_distance; // When perpendicular distance to *surface* is less than this, begin retreat from strafe
|
||||
|
||||
// AI guard options --wookieejedi
|
||||
float guard_big_orbit_above_target_radius; // Radius of guardee that triggers ai_big_guard()
|
||||
@@ -163,7 +161,7 @@ extern int Num_ai_profiles;
|
||||
extern int Default_ai_profile;
|
||||
extern ai_profile_t Ai_profiles[MAX_AI_PROFILES];
|
||||
|
||||
#define AI_PROFILES_INDEX(ai_p) (static_cast<int>((ai_p)-Ai_profiles))
|
||||
#define AI_PROFILES_INDEX(ai_p) ((int)((ai_p) - Ai_profiles))
|
||||
|
||||
void ai_profiles_init();
|
||||
|
||||
|
||||
+82
-97
@@ -40,6 +40,9 @@
|
||||
|
||||
// AI BIG MAGIC NUMBERS
|
||||
// Select strafing options are now exposed to modders --wookieejedi
|
||||
#define STRAFE_RETREAT_COLLIDE_TIME 2.0 // when anticipated collision time is less than this, begin retreat
|
||||
#define STRAFE_RETREAT_COLLIDE_DIST 100 // when perpendicular distance to *surface* is less than this, begin retreat
|
||||
|
||||
#define EVADE_BOX_BASE_DISTANCE 300 // standard distance to end evade submode
|
||||
#define EVADE_BOX_MIN_DISTANCE 200 // minimun distance to end evade submode, after long time
|
||||
|
||||
@@ -66,16 +69,6 @@ static bool ai_big_strafe_maybe_retreat(const vec3d *target_pos);
|
||||
extern void compute_desired_rvec(vec3d *rvec, const vec3d *goal_pos, const vec3d *cur_pos);
|
||||
extern void big_ship_collide_recover_start(const object *objp, const object *big_objp, const vec3d *collision_normal);
|
||||
|
||||
// Record the mode being left as the one to return to, unless a dynamic goal is already in progress
|
||||
// (in which case previous_mode still refers to the mode that goal interrupted).
|
||||
static void ai_big_save_previous_mode(ai_info *aip)
|
||||
{
|
||||
if (The_mission.ai_profile->flags[AI::Profile_Flags::Fix_stale_ai_order_state] && aip->active_goal == AI_ACTIVE_GOAL_DYNAMIC)
|
||||
return;
|
||||
|
||||
aip->previous_mode = aip->mode;
|
||||
}
|
||||
|
||||
|
||||
// Called by ai_big_pick_attack_point.
|
||||
// Generates a random attack point.
|
||||
@@ -509,7 +502,7 @@ bool ai_big_maybe_follow_subsys_path(bool do_dot_check)
|
||||
// for now, only follow the path to the first point
|
||||
if ( aip->path_cur < (aip->path_start+aip->path_length-1) ) {
|
||||
if ( aip->goal_objnum != aip->target_objnum ) {
|
||||
ai_big_save_previous_mode(aip);
|
||||
aip->previous_mode = aip->mode;
|
||||
aip->mode = AIM_NONE;
|
||||
aip->submode = -1;
|
||||
aip->submode_start_time = Missiontime;
|
||||
@@ -716,8 +709,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
|
||||
if (vm_vec_dot(&in_vec, &objp->orient.vec.fvec) > 0.0f) {
|
||||
dist = vm_vec_normalize(&in_vec);
|
||||
if ((dist < 200.0f) && (vm_vec_dot(&in_vec, &objp->orient.vec.fvec) > 0.95f)) {
|
||||
if ((Objects[objp->parent].signature == objp->parent_sig) && (vm_vec_dist_quick(&objp->pos, &Objects[objp->parent].pos) < 300.0f)
|
||||
&& !ai_declines_pursuit(Pl_objp, &Objects[objp->parent])) {
|
||||
if ((Objects[objp->parent].signature == objp->parent_sig) && (vm_vec_dist_quick(&objp->pos, &Objects[objp->parent].pos) < 300.0f)) {
|
||||
set_target_objnum(aip, objp->parent);
|
||||
aip->submode = SM_ATTACK;
|
||||
aip->submode_start_time = Missiontime;
|
||||
@@ -738,7 +730,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
|
||||
// including ai_profile flag and if enemy fighters are near
|
||||
if (Pl_objp->phys_info.speed < The_mission.ai_profile->standard_strafe_when_below_speed &&
|
||||
(The_mission.ai_profile->flags[AI::Profile_Flags::Standard_strafe_used_more] || ai_big_maybe_start_strafe(aip, sip))) {
|
||||
ai_big_save_previous_mode(aip);
|
||||
aip->previous_mode = aip->mode;
|
||||
aip->mode = AIM_STRAFE;
|
||||
aip->submode_parm0 = Missiontime; // use parm0 as time strafe mode entered (i.e. MODE start time)
|
||||
ai_big_strafe_position();
|
||||
@@ -747,7 +739,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
|
||||
|
||||
//Maybe enter glide strafe (check every 8 seconds, on a different schedule for each ship)
|
||||
if ((sip->can_glide == true) && !(aip->ai_flags[AI::AI_Flags::Kamikaze]) && static_randf((Missiontime + static_rand(aip->shipnum)) >> 19) < aip->ai_glide_strafe_percent) {
|
||||
ai_big_save_previous_mode(aip);
|
||||
aip->previous_mode = aip->mode;
|
||||
aip->mode = AIM_STRAFE;
|
||||
aip->submode_parm0 = Missiontime; // use parm0 as time strafe mode entered (i.e. MODE start time)
|
||||
aip->submode = AIS_STRAFE_GLIDE_ATTACK;
|
||||
@@ -1019,7 +1011,7 @@ static void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy)
|
||||
// switch ai ship into chase mode
|
||||
void ai_big_switch_to_chase_mode(ai_info *aip)
|
||||
{
|
||||
ai_big_save_previous_mode(aip);
|
||||
aip->previous_mode = aip->mode;
|
||||
aip->mode = AIM_CHASE;
|
||||
aip->submode = SM_ATTACK;
|
||||
aip->submode_start_time = Missiontime;
|
||||
@@ -1119,7 +1111,7 @@ void ai_big_chase()
|
||||
} else if (En_objp->flags[Object::Object_Flags::Protected]) { // If protected and we're not attacking a subsystem, stop attacking!
|
||||
update_aspect_lock_information(aip, &vec_to_enemy, dist_to_enemy - En_objp->radius, En_objp->radius);
|
||||
aip->target_objnum = -1;
|
||||
if (find_enemy(OBJ_INDEX(Pl_objp), MAX_ENEMY_DISTANCE, The_mission.ai_profile->max_attackers[Game_skill_level], ai_targets_for_pursuit(aip)) == -1) {
|
||||
if (find_enemy(OBJ_INDEX(Pl_objp), MAX_ENEMY_DISTANCE, The_mission.ai_profile->max_attackers[Game_skill_level]) == -1) {
|
||||
ai_do_default_behavior(Pl_objp);
|
||||
return;
|
||||
}
|
||||
@@ -1206,78 +1198,70 @@ void ai_big_chase()
|
||||
}
|
||||
|
||||
// If a collision is expected, pull out!
|
||||
if (!(The_mission.ai_profile->flags[AI::Profile_Flags::Kamikaze_no_collision_avoidance] && aip->ai_flags[AI::AI_Flags::Kamikaze])) {
|
||||
float dist_normal_to_enemy;
|
||||
|
||||
float dist_normal_to_enemy;
|
||||
|
||||
if (vm_vec_mag_squared(&aip->big_attack_surface_normal) > 0.9) {
|
||||
if (aip->ai_profile_flags[AI::Profile_Flags::Improved_subsystem_attack_pathing])
|
||||
dist_normal_to_enemy = fl_abs((dist_to_enemy / vm_vec_dot(&vec_to_enemy, &aip->big_attack_surface_normal)));
|
||||
else // I'm fairly sure this retail code VVV meant to use / instead of *
|
||||
dist_normal_to_enemy = fl_abs((dist_to_enemy * vm_vec_dot(&vec_to_enemy, &aip->big_attack_surface_normal)));
|
||||
}
|
||||
else {
|
||||
// don;t have normal so use a conservative value here
|
||||
dist_normal_to_enemy = 0.3f * dist_to_enemy;
|
||||
}
|
||||
|
||||
// float time_to_enemy = dist_normal_to_enemy / Pl_objp->phys_info.speed * fl_abs(vm_vec_dot(&Pl_objp->phys_info.vel, &aip->big_attack_surface_normal));
|
||||
// if (Framecount % 30 == 1) {
|
||||
// mprintf(("normal dist; %.1f, time: %.1f\n", dist_normal_to_enemy, time_to_enemy));
|
||||
// }
|
||||
|
||||
// since we're not in strafe and we may get a bad normal, cap dist_normal_to_enemy as MIN(0.3*dist_to_enemy, self)
|
||||
// this will allow us to get closer on a bad normal
|
||||
dist_normal_to_enemy = MAX(0.3f * dist_to_enemy, dist_normal_to_enemy);
|
||||
|
||||
if (dist_to_enemy < ATTACK_COLLIDE_BASE_DIST) {
|
||||
// within 50m or 1sec
|
||||
float time_to_enemy;
|
||||
if (vm_vec_mag_squared(&aip->big_attack_surface_normal) > 0.9) {
|
||||
if (Pl_objp->phys_info.speed > 0.1) {
|
||||
time_to_enemy = dist_normal_to_enemy / fl_abs(vm_vec_dot(&Pl_objp->phys_info.vel, &aip->big_attack_surface_normal));
|
||||
}
|
||||
else {
|
||||
// a big time
|
||||
time_to_enemy = 100.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (Pl_objp->phys_info.speed > 0.1) {
|
||||
time_to_enemy = dist_normal_to_enemy / Pl_objp->phys_info.speed;
|
||||
}
|
||||
else {
|
||||
// a big time
|
||||
time_to_enemy = 100.0f;
|
||||
}
|
||||
}
|
||||
|
||||
float speed_dist = MAX(0.0f, (Pl_objp->phys_info.speed - 50) * 2);
|
||||
if ((dist_normal_to_enemy < ATTACK_COLLIDE_AVOID_DIST + speed_dist) || (time_to_enemy < ATTACK_COLLIDE_AVOID_TIME)) {
|
||||
// get away, simulate crsh recovery (don't use avoid)
|
||||
// accelerate_ship(aip, -1.0f);
|
||||
big_ship_collide_recover_start(Pl_objp, En_objp, nullptr);
|
||||
// aip->submode = SM_AVOID;
|
||||
// aip->submode_start_time = Missiontime;
|
||||
}
|
||||
else if ((dist_normal_to_enemy < ATTACK_COLLIDE_SLOW_DIST) || (time_to_enemy < ATTACK_COLLIDE_SLOW_TIME)) {
|
||||
// slow down
|
||||
accelerate_ship(aip, -1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if ((dot_to_enemy > 1.0f - 0.1f * En_objp->radius/(dist_to_enemy + 1.0f)) && (Pl_objp->phys_info.speed > dist_to_enemy/5.0f)) {
|
||||
if (might_collide_with_ship(Pl_objp, En_objp, dot_to_enemy, dist_to_enemy, (aip->targeted_subsys == NULL)*2.0f + 1.5f)) {
|
||||
if ((Missiontime - aip->last_hit_time > F1_0*4) && (dist_to_enemy < Pl_objp->radius*2 + En_objp->radius*2)) {
|
||||
accelerate_ship(aip, -1.0f);
|
||||
} else {
|
||||
aip->submode = SM_AVOID;
|
||||
aip->submode_start_time = Missiontime;
|
||||
}
|
||||
}
|
||||
} */
|
||||
if (vm_vec_mag_squared(&aip->big_attack_surface_normal) > 0.9) {
|
||||
if (aip->ai_profile_flags[AI::Profile_Flags::Improved_subsystem_attack_pathing])
|
||||
dist_normal_to_enemy = fl_abs((dist_to_enemy / vm_vec_dot(&vec_to_enemy, &aip->big_attack_surface_normal)));
|
||||
else // I'm fairly sure this retail code VVV meant to use / instead of *
|
||||
dist_normal_to_enemy = fl_abs((dist_to_enemy * vm_vec_dot(&vec_to_enemy, &aip->big_attack_surface_normal)));
|
||||
} else {
|
||||
// don;t have normal so use a conservative value here
|
||||
dist_normal_to_enemy = 0.3f * dist_to_enemy;
|
||||
}
|
||||
|
||||
// float time_to_enemy = dist_normal_to_enemy / Pl_objp->phys_info.speed * fl_abs(vm_vec_dot(&Pl_objp->phys_info.vel, &aip->big_attack_surface_normal));
|
||||
// if (Framecount % 30 == 1) {
|
||||
// mprintf(("normal dist; %.1f, time: %.1f\n", dist_normal_to_enemy, time_to_enemy));
|
||||
// }
|
||||
|
||||
// since we're not in strafe and we may get a bad normal, cap dist_normal_to_enemy as MIN(0.3*dist_to_enemy, self)
|
||||
// this will allow us to get closer on a bad normal
|
||||
dist_normal_to_enemy = MAX(0.3f*dist_to_enemy, dist_normal_to_enemy);
|
||||
|
||||
if (dist_to_enemy < ATTACK_COLLIDE_BASE_DIST) {
|
||||
// within 50m or 1sec
|
||||
float time_to_enemy;
|
||||
if (vm_vec_mag_squared(&aip->big_attack_surface_normal) > 0.9) {
|
||||
if (Pl_objp->phys_info.speed > 0.1) {
|
||||
time_to_enemy = dist_normal_to_enemy / fl_abs(vm_vec_dot(&Pl_objp->phys_info.vel, &aip->big_attack_surface_normal));
|
||||
} else {
|
||||
// a big time
|
||||
time_to_enemy = 100.0f;
|
||||
}
|
||||
} else {
|
||||
if (Pl_objp->phys_info.speed > 0.1) {
|
||||
time_to_enemy = dist_normal_to_enemy / Pl_objp->phys_info.speed;
|
||||
} else {
|
||||
// a big time
|
||||
time_to_enemy = 100.0f;
|
||||
}
|
||||
}
|
||||
|
||||
float speed_dist = MAX(0.0f, (Pl_objp->phys_info.speed-50) * 2);
|
||||
if ((dist_normal_to_enemy < ATTACK_COLLIDE_AVOID_DIST + speed_dist) || (time_to_enemy < ATTACK_COLLIDE_AVOID_TIME) ) {
|
||||
// get away, simulate crsh recovery (don't use avoid)
|
||||
// accelerate_ship(aip, -1.0f);
|
||||
big_ship_collide_recover_start(Pl_objp, En_objp, nullptr);
|
||||
// aip->submode = SM_AVOID;
|
||||
// aip->submode_start_time = Missiontime;
|
||||
} else if ((dist_normal_to_enemy < ATTACK_COLLIDE_SLOW_DIST) || (time_to_enemy < ATTACK_COLLIDE_SLOW_TIME) ) {
|
||||
// slow down
|
||||
accelerate_ship(aip, -1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if ((dot_to_enemy > 1.0f - 0.1f * En_objp->radius/(dist_to_enemy + 1.0f)) && (Pl_objp->phys_info.speed > dist_to_enemy/5.0f)) {
|
||||
if (might_collide_with_ship(Pl_objp, En_objp, dot_to_enemy, dist_to_enemy, (aip->targeted_subsys == NULL)*2.0f + 1.5f)) {
|
||||
if ((Missiontime - aip->last_hit_time > F1_0*4) && (dist_to_enemy < Pl_objp->radius*2 + En_objp->radius*2)) {
|
||||
accelerate_ship(aip, -1.0f);
|
||||
} else {
|
||||
aip->submode = SM_AVOID;
|
||||
aip->submode_start_time = Missiontime;
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
switch (aip->submode) {
|
||||
@@ -1460,8 +1444,8 @@ static bool ai_big_strafe_maybe_retreat(const vec3d *target_pos)
|
||||
collide_time = false;
|
||||
collide_distance = false;
|
||||
} else {
|
||||
collide_time = (Pl_objp->phys_info.speed > 0.0f) && (dist_to_target / Pl_objp->phys_info.speed) < (The_mission.ai_profile->strafe_retreat_collide_time);
|
||||
collide_distance = dist_to_target < ((The_mission.ai_profile->strafe_retreat_collide_distance) + speed_to_dist_penalty);
|
||||
collide_time = (dist_to_target / Pl_objp->phys_info.speed) < STRAFE_RETREAT_COLLIDE_TIME;
|
||||
collide_distance = dist_to_target < (STRAFE_RETREAT_COLLIDE_DIST + speed_to_dist_penalty);
|
||||
}
|
||||
} else {
|
||||
float dist_normal_to_target;
|
||||
@@ -1471,8 +1455,8 @@ static bool ai_big_strafe_maybe_retreat(const vec3d *target_pos)
|
||||
} else {
|
||||
dist_normal_to_target = 0.2f * dist_to_target;
|
||||
}
|
||||
collide_time = (Pl_objp->phys_info.speed > 0.0f) && (dist_normal_to_target / Pl_objp->phys_info.speed) < (The_mission.ai_profile->strafe_retreat_collide_time);
|
||||
collide_distance = dist_normal_to_target < ((The_mission.ai_profile->strafe_retreat_collide_distance) + speed_to_dist_penalty);
|
||||
collide_time = (dist_normal_to_target / Pl_objp->phys_info.speed) < STRAFE_RETREAT_COLLIDE_TIME;
|
||||
collide_distance = dist_normal_to_target < (STRAFE_RETREAT_COLLIDE_DIST + speed_to_dist_penalty);
|
||||
}
|
||||
|
||||
//if ((dot_to_enemy > 1.0f - 0.1f * En_objp->radius/(dist_to_enemy + 1.0f)) && (Pl_objp->phys_info.speed > dist_to_enemy/5.0f))
|
||||
@@ -1878,7 +1862,7 @@ void ai_big_strafe()
|
||||
|
||||
/*
|
||||
if ( aip->goal_objnum != aip->target_objnum ) {
|
||||
Assertion(false, "The goal objnum does not match the target objnum in ai_big_strafe(), please report to the SCP!"); // what is going on here? - Get Alan
|
||||
UNREACHABLE("The goal objnum does not match the target objnum in ai_big_strafe(), please report to the SCP!"); // what is going on here? - Get Alan
|
||||
aip->mode = AIM_NONE;
|
||||
return;
|
||||
}
|
||||
@@ -1979,25 +1963,26 @@ int ai_big_maybe_enter_strafe_mode(const object *pl_objp, int weapon_objnum)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ai_declines_pursuit(pl_objp, parent_objp)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Maybe the ship which fired the weapon isn't the current target
|
||||
if ( OBJ_INDEX(parent_objp) != aip->target_objnum ) {
|
||||
|
||||
//JAS IMPOSSIBLE if (1) { // consider_target_only ) {
|
||||
//JAS IMPOSSIBLE return 0;
|
||||
//JAS IMPOSSIBLE } else {
|
||||
// switch targets
|
||||
sip = &Ship_info[Ships[parent_objp->instance].ship_info_index];
|
||||
if ( !(sip->is_big_or_huge()) || (sip->flags[Ship::Info_Flags::Transport]) ) {
|
||||
return 0;
|
||||
}
|
||||
set_target_objnum(aip, OBJ_INDEX(parent_objp));
|
||||
//JAS IMPOSSIBLE }
|
||||
}
|
||||
|
||||
ai_big_strafe_maybe_attack_turret(pl_objp, weapon_objp);
|
||||
|
||||
// if we've got this far, the weapon must have come from the player's target, and it is a
|
||||
// big/capital ship... so enter strafe mode
|
||||
ai_big_save_previous_mode(aip);
|
||||
aip->previous_mode = aip->mode;
|
||||
aip->mode = AIM_STRAFE;
|
||||
aip->submode_parm0 = Missiontime; // use parm0 as time strafe mode entered (i.e. MODE start time)
|
||||
aip->submode = AIS_STRAFE_AVOID;
|
||||
|
||||
+166
-321
File diff suppressed because it is too large.
Load diff
Whitespace-only changes.
+11
-63
@@ -911,24 +911,7 @@ void ai_add_goal_sub_scripting(ai_goal_type type, ai_goal_mode mode, int submode
|
||||
}
|
||||
}
|
||||
|
||||
// find a dockpoint on the given ship that is compatible with the specified dock-type flags (c.f. ai_goal_fixup_dockpoints)
|
||||
static int ai_goal_find_compatible_dockpoint(int shipnum, int type_flags)
|
||||
{
|
||||
for (int i = 0; i < Num_dock_type_names; i++)
|
||||
{
|
||||
if (type_flags & Dock_type_names[i].def)
|
||||
{
|
||||
int dock_index = ai_goal_find_dockpoint(shipnum, Dock_type_names[i].def);
|
||||
if (dock_index >= 0)
|
||||
return dock_index;
|
||||
}
|
||||
}
|
||||
|
||||
// no compatible type-specific point found; fall back to a generic one
|
||||
return ai_goal_find_dockpoint(shipnum, DOCK_TYPE_GENERIC);
|
||||
}
|
||||
|
||||
void ai_add_ship_goal_scripting(ai_goal_mode mode, int submode, int priority, const char *shipname, ai_info *aip, int int_data, float float_data, int docker_index, int dockee_index)
|
||||
void ai_add_ship_goal_scripting(ai_goal_mode mode, int submode, int priority, const char *shipname, ai_info *aip, int int_data, float float_data)
|
||||
{
|
||||
int empty_index;
|
||||
ai_goal *aigp;
|
||||
@@ -944,27 +927,7 @@ void ai_add_ship_goal_scripting(ai_goal_mode mode, int submode, int priority, co
|
||||
}
|
||||
|
||||
if ( (mode == AI_GOAL_REARM_REPAIR) || (mode == AI_GOAL_DOCK) ) {
|
||||
// if the caller specified one or both dockpoints, honor them and choose the other side to match
|
||||
if ( mode == AI_GOAL_DOCK && (docker_index >= 0 || dockee_index >= 0) ) {
|
||||
int dockee_shipnum = ship_name_lookup(shipname);
|
||||
Assertion(dockee_shipnum >= 0, "Couldn't find dock target '%s'; get a coder!", shipname);
|
||||
|
||||
// if only one point was given, choose the other to match its dock type
|
||||
if ( docker_index < 0 ) {
|
||||
polymodel *dockee_pm = model_get(Ship_info[Ships[dockee_shipnum].ship_info_index].model_num);
|
||||
docker_index = ai_goal_find_compatible_dockpoint(aip->shipnum, dockee_pm->docking_bays[dockee_index].type_flags);
|
||||
} else if ( dockee_index < 0 ) {
|
||||
polymodel *docker_pm = model_get(Ship_info[Ships[aip->shipnum].ship_info_index].model_num);
|
||||
dockee_index = ai_goal_find_compatible_dockpoint(dockee_shipnum, docker_pm->docking_bays[docker_index].type_flags);
|
||||
}
|
||||
|
||||
aigp->docker.index = docker_index;
|
||||
aigp->dockee.index = dockee_index;
|
||||
aigp->flags.set(AI::Goal_Flags::Docker_index_valid);
|
||||
aigp->flags.set(AI::Goal_Flags::Dockee_index_valid);
|
||||
} else {
|
||||
ai_goal_fixup_dockpoints( aip, aigp );
|
||||
}
|
||||
ai_goal_fixup_dockpoints( aip, aigp );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1290,7 +1253,7 @@ void ai_add_goal_sub_sexp( int sexp, ai_goal_type type, ai_info *aip, ai_goal *a
|
||||
} else if ( op == OP_AI_IGNORE_NEW ) {
|
||||
aigp->ai_mode = AI_GOAL_IGNORE_NEW;
|
||||
} else
|
||||
UNREACHABLE("Coding error: unhandled AI goal %d in ai_add_goal_sub_sexp!", op);
|
||||
UNREACHABLE("Coding error: unhandled AI goal in ai_add_goal_sub_sexp!");
|
||||
|
||||
break;
|
||||
|
||||
@@ -1803,20 +1766,6 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp )
|
||||
|
||||
auto target_ship_entry = aigp->target_name == nullptr ? nullptr : ship_registry_get(aigp->target_name);
|
||||
|
||||
// a ship can't guard itself, and the leader of a wing is the ship the rest of the wing guards
|
||||
if (The_mission.ai_profile->flags[AI::Profile_Flags::Fix_stale_ai_order_state])
|
||||
{
|
||||
if (aigp->ai_mode == AI_GOAL_GUARD && target_ship_entry && target_ship_entry->has_shipp() && target_ship_entry->shipp() == shipp)
|
||||
return ai_achievability::NOT_ACHIEVABLE;
|
||||
|
||||
if (aigp->ai_mode == AI_GOAL_GUARD_WING)
|
||||
{
|
||||
int wingnum = wing_name_lookup(aigp->target_name);
|
||||
if (wingnum >= 0 && Wings[wingnum].ship_index[0] == objp->instance)
|
||||
return ai_achievability::NOT_ACHIEVABLE;
|
||||
}
|
||||
}
|
||||
|
||||
// warp (depart) only achievable if there's somewhere to depart to
|
||||
if (aigp->ai_mode == AI_GOAL_WARP)
|
||||
{
|
||||
@@ -2107,7 +2056,7 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp )
|
||||
if (target_ship_entry->shipp()->subsys_info[SUBSYSTEM_TURRET].type_count == 0)
|
||||
return ai_achievability::NOT_ACHIEVABLE;
|
||||
} else {
|
||||
Assertion(false, "Target name %s is not an arrived ship!", aigp->target_name);
|
||||
UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name);
|
||||
return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid
|
||||
}
|
||||
}
|
||||
@@ -2156,8 +2105,8 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp )
|
||||
return ai_achievability::NOT_KNOWN;
|
||||
|
||||
// we must also determine if we're prevented from docking for any reason
|
||||
Assertion(target_ship_entry && target_ship_entry->has_shipp(), "Target name %s is not an arrived ship!", aigp->target_name);
|
||||
if (!target_ship_entry || !target_ship_entry->has_shipp()) {
|
||||
UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name);
|
||||
return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid
|
||||
}
|
||||
auto goal_objp = target_ship_entry->objp();
|
||||
@@ -2214,7 +2163,7 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp )
|
||||
if (aip->goal_objnum != target_ship_entry->objnum)
|
||||
return ai_achievability::NOT_KNOWN;
|
||||
} else {
|
||||
Assertion(false, "Target name %s is not an arrived ship!", aigp->target_name);
|
||||
UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name);
|
||||
return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid
|
||||
}
|
||||
}
|
||||
@@ -2228,14 +2177,14 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp )
|
||||
aigp->ai_submode = ship_find_subsys( target_ship_entry->shipp(), aigp->docker.name );
|
||||
aigp->flags.remove(AI::Goal_Flags::Subsys_needs_fixup);
|
||||
} else {
|
||||
Assertion(false, "Target name %s is not an arrived ship!", aigp->target_name);
|
||||
UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name);
|
||||
return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid
|
||||
}
|
||||
}
|
||||
} else if ( ((aigp->ai_mode == AI_GOAL_IGNORE) || (aigp->ai_mode == AI_GOAL_IGNORE_NEW)) && (status == SHIP_STATUS_ARRIVED) ) {
|
||||
// for ignoring a ship, call the ai_ignore object function, then declare the goal satisfied
|
||||
Assertion(target_ship_entry && target_ship_entry->has_objp(), "Target name %s is not an arrived ship!", aigp->target_name);
|
||||
if (!target_ship_entry || !target_ship_entry->has_objp()) {
|
||||
UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name);
|
||||
return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid
|
||||
}
|
||||
auto ignored = target_ship_entry->objp();
|
||||
@@ -2284,16 +2233,16 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp )
|
||||
{
|
||||
// short circuit a couple of cases. Ship not arrived shouldn't happen. Ship gone means
|
||||
// we mark the goal as not achievable.
|
||||
Assertion(status != SHIP_STATUS_NOT_ARRIVED, "Ship %s cannot rearm a target %s that hasn't arrived; get Allender or a SCP member", shipp->ship_name, aigp->target_name); // get Allender. this shouldn't happen!!!
|
||||
if ( status == SHIP_STATUS_NOT_ARRIVED ) {
|
||||
UNREACHABLE("Ship %s cannot rearm a target %s that hasn't arrived; get Allender or a SCP member", shipp->ship_name, aigp->target_name); // get Allender. this shouldn't happen!!!
|
||||
return ai_achievability::NOT_ACHIEVABLE;
|
||||
}
|
||||
|
||||
if ( status == SHIP_STATUS_GONE )
|
||||
return ai_achievability::NOT_ACHIEVABLE;
|
||||
|
||||
Assertion(target_ship_entry && target_ship_entry->has_shipp(), "Target name %s is not an arrived ship!", aigp->target_name);
|
||||
if ( !target_ship_entry || !target_ship_entry->has_shipp() ) {
|
||||
UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name);
|
||||
return ai_achievability::NOT_ACHIEVABLE;
|
||||
}
|
||||
|
||||
@@ -2549,9 +2498,8 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
|
||||
if ( !(Player_use_ai) && (objp->flags[Object::Object_Flags::Player_ship]) && (current_goal->ai_mode != AI_GOAL_FORM_ON_WING) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ai_reset_order_state(aip);
|
||||
|
||||
std::unique_ptr<ai_goal> current_goal_backup;
|
||||
auto current_goal_target_ship = current_goal->target_name ? ship_registry_get(current_goal->target_name) : nullptr;
|
||||
|
||||
+1
-5
@@ -106,10 +106,6 @@ inline bool ai_goal_is_specific_chase(ai_goal_mode ai_mode)
|
||||
{
|
||||
return ai_mode == AI_GOAL_CHASE || ai_mode == AI_GOAL_CHASE_WING || ai_mode == AI_GOAL_CHASE_SHIP_CLASS || ai_mode == AI_GOAL_CHASE_SHIP_TYPE;
|
||||
}
|
||||
inline bool ai_goal_is_standing_chase(ai_goal_mode ai_mode)
|
||||
{
|
||||
return ai_mode == AI_GOAL_CHASE_ANY;
|
||||
}
|
||||
|
||||
enum class ai_achievability { ACHIEVABLE, NOT_ACHIEVABLE, NOT_KNOWN, SATISFIED };
|
||||
|
||||
@@ -183,7 +179,7 @@ extern void ai_process_mission_orders( int objnum, ai_info *aip );
|
||||
extern int ai_goal_num(ai_goal *goals);
|
||||
|
||||
// adds goals to ships/wing through sexpressions
|
||||
extern void ai_add_ship_goal_scripting(ai_goal_mode mode, int submode, int priority, const char *shipname, ai_info *aip, int int_data, float float_data, int docker_index = -1, int dockee_index = -1);
|
||||
extern void ai_add_ship_goal_scripting(ai_goal_mode mode, int submode, int priority, const char *shipname, ai_info *aip, int int_data, float float_data);
|
||||
extern void ai_add_ship_goal_sexp(int sexp, ai_goal_type type, ai_info *aip);
|
||||
extern void ai_add_wing_goal_sexp(int sexp, ai_goal_type type, wing *wingp);
|
||||
extern void ai_add_goal_sub_sexp(int sexp, ai_goal_type type, ai_info *aip, ai_goal *aigp, const char *actor_name);
|
||||
|
||||
+94
-52
@@ -350,18 +350,6 @@ const weapon_info *get_turret_weapon_wip(const ship_weapon *swp, int weapon_num)
|
||||
return &Weapon_info[wi_index];
|
||||
}
|
||||
|
||||
// similar to the above, since "weapon_num" is a bank index over multiple banks
|
||||
static std::pair<int, int> get_turret_weapon_bank(int weapon_num)
|
||||
{
|
||||
int pbank = -1;
|
||||
int sbank = -1;
|
||||
if (weapon_num >= MAX_SHIP_PRIMARY_BANKS)
|
||||
sbank = weapon_num - MAX_SHIP_PRIMARY_BANKS;
|
||||
else
|
||||
pbank = weapon_num;
|
||||
return { pbank, sbank };
|
||||
}
|
||||
|
||||
int get_turret_weapon_next_fire_stamp(const ship_weapon *swp, int weapon_num)
|
||||
{
|
||||
Assert(weapon_num < MAX_SHIP_WEAPONS);
|
||||
@@ -1107,8 +1095,7 @@ int find_turret_enemy(const ship_subsys *turret_subsys, int objnum, const vec3d
|
||||
int target_objnum = aip->target_objnum;
|
||||
|
||||
if (Objects[target_objnum].signature == aip->target_signature) {
|
||||
// The parent's target can be a weapon or an asteroid, so make sure it's a ship before indexing Ships[]
|
||||
ship* target_shipp = (Objects[target_objnum].type == OBJ_SHIP) ? &Ships[Objects[target_objnum].instance] : nullptr;
|
||||
ship* target_shipp = &Ships[Objects[target_objnum].instance];
|
||||
if (target_shipp && iff_matches_mask(target_shipp->team, enemy_team_mask)) {
|
||||
if (!(Objects[target_objnum].flags[Object::Object_Flags::Protected])) { // check this flag as well
|
||||
// nprintf(("AI", "Frame %i: Object %i resuming goal of object %i\n", AI_FrameCount, objnum,
|
||||
@@ -1741,7 +1728,6 @@ bool turret_fire_weapon(int weapon_num,
|
||||
auto wip = get_turret_weapon_wip(&turret->weapons, weapon_num);
|
||||
if (!wip)
|
||||
return false;
|
||||
auto [turret_pbank, turret_sbank] = get_turret_weapon_bank(weapon_num);
|
||||
|
||||
bool in_lab = (gameseq_get_state() == GS_STATE_LAB);
|
||||
|
||||
@@ -1768,7 +1754,7 @@ bool turret_fire_weapon(int weapon_num,
|
||||
|
||||
parent_aip = &Ai_info[Ships[Objects[parent_objnum].instance].ai_index];
|
||||
parent_ship = &Ships[Objects[parent_objnum].instance];
|
||||
int turret_weapon_class = WEAPON_INFO_INDEX(wip);
|
||||
int turret_weapon_class = weapon_info_get_index(wip);
|
||||
|
||||
#ifndef NDEBUG
|
||||
// moved here from check_ok_to_fire
|
||||
@@ -1852,7 +1838,6 @@ bool turret_fire_weapon(int weapon_num,
|
||||
else
|
||||
fire_info.target_subsys = nullptr;
|
||||
fire_info.turret = turret;
|
||||
fire_info.bank = turret_pbank;
|
||||
fire_info.burst_seed = old_burst_seed;
|
||||
fire_info.fire_method = BFM_TURRET_FIRED;
|
||||
fire_info.per_burst_rotation = swp->per_burst_rot;
|
||||
@@ -1865,6 +1850,7 @@ bool turret_fire_weapon(int weapon_num,
|
||||
fire_info.target_pos1 = turret->last_aim_enemy_pos;
|
||||
}
|
||||
|
||||
|
||||
// fire a beam weapon
|
||||
weapon_objnum = beam_fire(&fire_info);
|
||||
|
||||
@@ -1890,53 +1876,113 @@ bool turret_fire_weapon(int weapon_num,
|
||||
}
|
||||
// don't fire swam, but set up swarm info instead
|
||||
else if ((wip->wi_flags[Weapon::Info_Flags::Swarm]) || (wip->wi_flags[Weapon::Info_Flags::Corkscrew])) {
|
||||
// swarm and corkscrew are not restricted to missiles, so check whichever bank is actually firing
|
||||
if (!in_lab && (turret->system_info->flags[Model::Subsystem_Flags::Turret_use_ammo])) {
|
||||
bool has_ammo = (turret_pbank >= 0)
|
||||
? swp->primary_bank_ammo[turret_pbank] > 0
|
||||
: ship_secondary_has_ammo(swp, turret_sbank);
|
||||
if (!has_ammo)
|
||||
return false;
|
||||
if (swp->current_secondary_bank < 0) {
|
||||
swp->current_secondary_bank = 0;
|
||||
}
|
||||
int bank_to_fire = swp->current_secondary_bank;
|
||||
if (!in_lab && (turret->system_info->flags[Model::Subsystem_Flags::Turret_use_ammo]) && !ship_secondary_has_ammo(swp, bank_to_fire)) {
|
||||
if (!(turret->system_info->flags[Model::Subsystem_Flags::Use_multiple_guns])) {
|
||||
swp->current_secondary_bank++;
|
||||
if (swp->current_secondary_bank >= swp->num_secondary_banks) {
|
||||
swp->current_secondary_bank = 0;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
turret_swarm_set_up_info(parent_objnum, turret, wip, turret->turret_next_fire_pos, in_lab);
|
||||
|
||||
turret_swarm_set_up_info(parent_objnum, turret, wip, turret->turret_next_fire_pos, turret_pbank, turret_sbank, in_lab);
|
||||
turret->flags.set(Ship::Subsystem_Flags::Has_fired); //set fired flag for scripting -nike
|
||||
return true;
|
||||
turret->flags.set(Ship::Subsystem_Flags::Has_fired); //set fired flag for scripting -nike
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// now do anything else
|
||||
else {
|
||||
float shots_mult = wip->weapon_launch_curves.get_output(weapon_info::WeaponLaunchCurveOutputs::SHOTS_MULT, launch_curve_data);
|
||||
int shots = fl2i(i2fl(wip->shots) * shots_mult);
|
||||
|
||||
// note that wip is reassigned to the created weapon's class inside the loop, so any
|
||||
// property of the bank's own weapon must be read before we get there
|
||||
bool no_ammo_needed = (turret_sbank >= 0) && Weapon_info[swp->secondary_bank_weapons[turret_sbank]].wi_flags[Weapon::Info_Flags::SecondaryNoAmmo];
|
||||
for (int i = 0; i < shots; i++) {
|
||||
if (!in_lab && turret->system_info->flags[Model::Subsystem_Flags::Turret_use_ammo]) {
|
||||
if (turret_pbank >= 0) {
|
||||
int bank_to_fire, num_slots = turret->system_info->turret_num_firing_points;
|
||||
if (wip->subtype == WP_LASER) {
|
||||
int points;
|
||||
if (swp->num_primary_banks <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (swp->current_primary_bank < 0){
|
||||
swp->current_primary_bank = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
int num_primary_banks = swp->num_primary_banks;
|
||||
|
||||
Assert(num_primary_banks > 0);
|
||||
if (num_primary_banks < 1){
|
||||
return false;
|
||||
}
|
||||
|
||||
bank_to_fire = swp->current_primary_bank;
|
||||
|
||||
if (turret->system_info->flags[Model::Subsystem_Flags::Turret_salvo]) {
|
||||
points = turret->system_info->turret_num_firing_points;
|
||||
points = num_slots;
|
||||
} else {
|
||||
points = 1;
|
||||
}
|
||||
|
||||
if (swp->primary_bank_ammo[turret_pbank] >= points) {
|
||||
swp->primary_bank_ammo[turret_pbank] -= points;
|
||||
} else if ((swp->primary_bank_ammo[turret_pbank] >= 0) && !(The_mission.ai_profile->flags[AI::Profile_Flags::Prevent_negative_turret_ammo])) {
|
||||
if (swp->primary_bank_ammo[bank_to_fire] >= points) {
|
||||
swp->primary_bank_ammo[bank_to_fire] -= points;
|
||||
} else if ((swp->primary_bank_ammo[bank_to_fire] >= 0) && !(The_mission.ai_profile->flags[AI::Profile_Flags::Prevent_negative_turret_ammo])) {
|
||||
// default behavior allowed ammo to be negative
|
||||
swp->primary_bank_ammo[turret_pbank] -= points;
|
||||
swp->primary_bank_ammo[bank_to_fire] -= points;
|
||||
} else if (!(turret->system_info->flags[Model::Subsystem_Flags::Use_multiple_guns]) && (swp->primary_bank_ammo[bank_to_fire] < 0)) {
|
||||
swp->current_primary_bank++;
|
||||
if (swp->current_primary_bank >= swp->num_primary_banks) {
|
||||
swp->current_primary_bank = 0;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (turret_sbank >= 0) {
|
||||
if (!no_ammo_needed) {
|
||||
if (swp->secondary_bank_ammo[turret_sbank] > 0) {
|
||||
swp->secondary_bank_ammo[turret_sbank]--;
|
||||
} else if ((swp->secondary_bank_ammo[turret_sbank] == 0) && !(The_mission.ai_profile->flags[AI::Profile_Flags::Prevent_negative_turret_ammo])) {
|
||||
else if (wip->subtype == WP_MISSILE) {
|
||||
if (swp->num_secondary_banks <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (swp->current_secondary_bank < 0){
|
||||
swp->current_secondary_bank = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
bank_to_fire = swp->current_secondary_bank;
|
||||
|
||||
int start_slot, end_slot;
|
||||
|
||||
start_slot = swp->secondary_next_slot[bank_to_fire];
|
||||
end_slot = start_slot;
|
||||
|
||||
for (int j = start_slot; j <= end_slot; j++) {
|
||||
swp->secondary_next_slot[bank_to_fire]++;
|
||||
|
||||
if (Weapon_info[swp->secondary_bank_weapons[bank_to_fire]].wi_flags[Weapon::Info_Flags::SecondaryNoAmmo])
|
||||
continue;
|
||||
|
||||
if (swp->secondary_next_slot[bank_to_fire] > (num_slots - 1)){
|
||||
swp->secondary_next_slot[bank_to_fire] = 0;
|
||||
}
|
||||
|
||||
if (swp->secondary_bank_ammo[bank_to_fire] > 0) {
|
||||
swp->secondary_bank_ammo[bank_to_fire]--;
|
||||
} else if ((swp->secondary_bank_ammo[bank_to_fire] == 0) && !(The_mission.ai_profile->flags[AI::Profile_Flags::Prevent_negative_turret_ammo])) {
|
||||
// default behavior allowed ammo to be negative
|
||||
swp->secondary_bank_ammo[turret_sbank]--;
|
||||
swp->secondary_bank_ammo[bank_to_fire]--;
|
||||
} else if (!(turret->system_info->flags[Model::Subsystem_Flags::Use_multiple_guns]) && (swp->secondary_bank_ammo[bank_to_fire] < 0)) {
|
||||
swp->current_secondary_bank++;
|
||||
if (swp->current_secondary_bank >= swp->num_secondary_banks) {
|
||||
swp->current_secondary_bank = 0;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -1951,7 +1997,7 @@ bool turret_fire_weapon(int weapon_num,
|
||||
// so we need to get the position info separately for each shot
|
||||
ship_get_global_turret_gun_info(&Objects[parent_objnum], turret, &firing_pos_buf, false, nullptr, true, nullptr);
|
||||
|
||||
weapon_objnum = weapon_create(firing_pos, &firing_orient, turret_weapon_class, parent_objnum, -1, true, false, swp, turret_pbank, turret_sbank, launch_curve_data);
|
||||
weapon_objnum = weapon_create(firing_pos, &firing_orient, turret_weapon_class, parent_objnum, -1, true, false, 0.0f, turret, launch_curve_data);
|
||||
weapon_set_tracking_info(weapon_objnum, parent_objnum, turret->turret_enemy_objnum, 1, turret->targeted_subsys);
|
||||
|
||||
//nprintf(("AI", "Turret_time_enemy_in_range = %7.3f\n", ss->turret_time_enemy_in_range));
|
||||
@@ -2015,9 +2061,9 @@ bool turret_fire_weapon(int weapon_num,
|
||||
subsys_index = ship_get_subsys_index(turret);
|
||||
Assert( subsys_index != -1 );
|
||||
if(wip->wi_flags[Weapon::Info_Flags::Flak]){
|
||||
send_flak_fired_packet( parent_objnum, subsys_index, weapon_objnum, flak_range, launch_curve_data.distance_to_target, launch_curve_data.target_radius, launch_curve_data.target_forward_speed );
|
||||
send_flak_fired_packet( parent_objnum, subsys_index, weapon_objnum, flak_range, launch_curve_data.distance_to_target, launch_curve_data.target_radius );
|
||||
} else {
|
||||
send_turret_fired_packet( parent_objnum, subsys_index, weapon_objnum, launch_curve_data.distance_to_target, launch_curve_data.target_radius, launch_curve_data.target_forward_speed );
|
||||
send_turret_fired_packet( parent_objnum, subsys_index, weapon_objnum, launch_curve_data.distance_to_target, launch_curve_data.target_radius );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2091,11 +2137,10 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
|
||||
tsi->turret->system_info->turret_num_firing_points,
|
||||
0.f,
|
||||
0.f,
|
||||
0.f,
|
||||
};
|
||||
|
||||
// create weapon and homing info
|
||||
weapon_objnum = weapon_create(&turret_pos, &firing_orient, tsi->weapon_class, tsi->parent_objnum, -1, true, false, &tsi->turret->weapons, tsi->swp_pbank, tsi->swp_sbank, launch_curve_data);
|
||||
weapon_objnum = weapon_create(&turret_pos, &firing_orient, tsi->weapon_class, tsi->parent_objnum, -1, true, false, 0.0f, tsi->turret, launch_curve_data);
|
||||
weapon_set_tracking_info(weapon_objnum, tsi->parent_objnum, tsi->target_objnum, 1, tsi->target_subsys);
|
||||
|
||||
// do other cool stuff if weapon is created.
|
||||
@@ -2143,7 +2188,7 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
|
||||
|
||||
subsys_index = ship_get_subsys_index(tsi->turret);
|
||||
Assert( subsys_index != -1 );
|
||||
send_turret_fired_packet( tsi->parent_objnum, subsys_index, weapon_objnum, 0.f, 0.f, 0.f);
|
||||
send_turret_fired_packet( tsi->parent_objnum, subsys_index, weapon_objnum, 0.f, 0.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2316,11 +2361,9 @@ void ai_turret_execute_behavior(const ship *shipp, ship_subsys *ss)
|
||||
float turret_barrel_length = -1.0f;
|
||||
|
||||
float target_radius = 0.f;
|
||||
float target_forward_speed = 0.f;
|
||||
|
||||
if (lep != nullptr) {
|
||||
target_radius = lep->radius;
|
||||
target_forward_speed = lep->phys_info.fspeed;
|
||||
}
|
||||
|
||||
// grab the data for the launch curve inputs
|
||||
@@ -2328,7 +2371,6 @@ void ai_turret_execute_behavior(const ship *shipp, ship_subsys *ss)
|
||||
ss->system_info->turret_num_firing_points,
|
||||
base_dist_to_enemy,
|
||||
target_radius,
|
||||
target_forward_speed,
|
||||
};
|
||||
|
||||
//WMC - go through all valid weapons. Fire spawns if there are any.
|
||||
|
||||
@@ -1439,9 +1439,9 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
|
||||
// everything above was calculated relative to the heavy's position
|
||||
vec3d actual_world_hit_pos = mc.hit_point_world + heavy_obj->pos;
|
||||
if ((shipp->is_arriving()) && (shipp->warpin_effect != nullptr))
|
||||
warp_effect = shipp->warpin_effect.get();
|
||||
warp_effect = shipp->warpin_effect;
|
||||
else if ((shipp->flags[Ship::Ship_Flags::Depart_warp]) && (shipp->warpout_effect != nullptr))
|
||||
warp_effect = shipp->warpout_effect.get();
|
||||
warp_effect = shipp->warpout_effect;
|
||||
|
||||
if (warp_effect != nullptr && point_is_clipped_by_warp(&actual_world_hit_pos, warp_effect))
|
||||
mc_ret_val = 0;
|
||||
@@ -1693,7 +1693,7 @@ static void asteroid_do_area_effect(object *asteroid_objp)
|
||||
if ( weapon_area_calc_damage(ship_objp, &asteroid_objp->pos, asip->inner_rad, asip->outer_rad, asip->blast, asip->damage, &blast, &damage, asip->outer_rad) == -1 )
|
||||
continue;
|
||||
|
||||
ship_apply_global_damage(ship_objp, asteroid_objp, &asteroid_objp->pos, damage, asip->damage_type_idx, DamageSource::Explosion);
|
||||
ship_apply_global_damage(ship_objp, asteroid_objp, &asteroid_objp->pos, damage, asip->damage_type_idx);
|
||||
weapon_area_apply_blast(nullptr, ship_objp, &asteroid_objp->pos, blast, false);
|
||||
} // end for
|
||||
}
|
||||
|
||||
+42
-46
@@ -13,7 +13,6 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define BMPMAN_INTERNAL
|
||||
|
||||
#include "globalincs/pstypes.h"
|
||||
#include "anim/animplay.h"
|
||||
#include "anim/packunpack.h"
|
||||
#include "bmpman/bm_internal.h"
|
||||
@@ -84,12 +83,7 @@ static bool bm_inited = false;
|
||||
static uint Bm_next_signature = 0x1234;
|
||||
static int Bm_low_mem = 0;
|
||||
|
||||
struct bm_lookup_cache_entry {
|
||||
ubyte* data;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
SCP_map<int, bm_lookup_cache_entry> bm_lookup_cache;
|
||||
SCP_map<int,ubyte*> bm_lookup_cache;
|
||||
|
||||
/**
|
||||
* How much RAM bmpman can use for textures.
|
||||
@@ -150,31 +144,30 @@ bitmap_slot* bm_get_slot(int handle, bool separate_ani_frames) {
|
||||
// Declaration of private functions and templates(declared as static type func(type param);)
|
||||
|
||||
bitmap_lookup::bitmap_lookup(int bitmap_num):
|
||||
Bitmap_data(nullptr),
|
||||
Width(0),
|
||||
Height(0),
|
||||
Num_channels(3)
|
||||
Bitmap_data(NULL)
|
||||
{
|
||||
if ( !bm_is_valid(bitmap_num) ) return;
|
||||
|
||||
Num_channels = 3;
|
||||
|
||||
if ( bm_has_alpha_channel(bitmap_num) ) {
|
||||
Num_channels = 4;
|
||||
}
|
||||
|
||||
bitmap_entry *be = bm_get_entry(bitmap_num);
|
||||
|
||||
Width = be->bm.w;
|
||||
Height = be->bm.h;
|
||||
|
||||
|
||||
auto cache_search = bm_lookup_cache.find(bitmap_num);
|
||||
if (cache_search == bm_lookup_cache.end()) {
|
||||
// The texture in graphics memory may be smaller than the bitmap itself, e.g. when mipmap levels
|
||||
// are culled at lower texture detail settings, so the readback reports the dimensions of the
|
||||
// data it actually returns.
|
||||
Bitmap_data = gr_get_bitmap_from_texture(bitmap_num, &Width, &Height);
|
||||
Bitmap_data = (ubyte*)vm_malloc(Width * Height * Num_channels * sizeof(ubyte));
|
||||
|
||||
if (Bitmap_data != nullptr) {
|
||||
bm_lookup_cache.insert({bitmap_num, {Bitmap_data, Width, Height}});
|
||||
}
|
||||
gr_get_bitmap_from_texture((void*)Bitmap_data, bitmap_num);
|
||||
bm_lookup_cache.insert({bitmap_num, Bitmap_data});
|
||||
} else {
|
||||
Bitmap_data = cache_search->second.data;
|
||||
Width = cache_search->second.width;
|
||||
Height = cache_search->second.height;
|
||||
Bitmap_data = cache_search->second;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,11 +190,6 @@ float bitmap_lookup::get_channel_alpha(float u, float v)
|
||||
{
|
||||
Assert( Bitmap_data != NULL );
|
||||
|
||||
// without an alpha channel there is nothing to look up, and indexing channel 3 would read out of bounds
|
||||
if ( Num_channels < 4 ) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
int x = fl2i(map_texture_address(u) * (Width-1));
|
||||
int y = fl2i(map_texture_address(v) * (Height-1));
|
||||
|
||||
@@ -210,7 +198,7 @@ float bitmap_lookup::get_channel_alpha(float u, float v)
|
||||
|
||||
void clear_bm_lookup_cache() {
|
||||
for(auto &iter: bm_lookup_cache) {
|
||||
vm_free(iter.second.data);
|
||||
free(iter.second);
|
||||
}
|
||||
bm_lookup_cache.clear();
|
||||
}
|
||||
@@ -611,8 +599,8 @@ int bm_create_3d(int bpp, int w, int h, int d, void* data) {
|
||||
return -1;
|
||||
|
||||
// make sure that we have valid data
|
||||
Assertion(data != nullptr, "No valid data received for 3D Bitmap creation!");
|
||||
if (data == nullptr) {
|
||||
UNREACHABLE("No valid data received for 3D Bitmap creation!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1036,13 +1024,6 @@ void bm_init() {
|
||||
bm_inited = true;
|
||||
}
|
||||
|
||||
bool bm_is_cubemap(int handle)
|
||||
{
|
||||
const BM_TYPE type = bm_get_entry(handle)->comp_type;
|
||||
return type == BM_TYPE_CUBEMAP_DDS || type == BM_TYPE_CUBEMAP_DXT1 || type == BM_TYPE_CUBEMAP_DXT3 ||
|
||||
type == BM_TYPE_CUBEMAP_DXT5;
|
||||
}
|
||||
|
||||
int bm_is_compressed(int num) {
|
||||
auto entry = bm_get_entry(num);
|
||||
BM_TYPE type = BM_TYPE_NONE;
|
||||
@@ -1229,7 +1210,7 @@ static int bm_load_info(BM_TYPE type, const char *filename, CFILE *img_cfp, int
|
||||
}
|
||||
}
|
||||
else {
|
||||
UNREACHABLE("Unknown file type %d specified! This is probably a coding error.", type);
|
||||
UNREACHABLE("Unknown file type specified! This is probably a coding error.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -3481,22 +3462,37 @@ bool bm_validate_filename(const SCP_string& file, bool single_frame, bool animat
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_Surface* bm_to_sdl_surface(int handle)
|
||||
{
|
||||
SDL_Surface* bm_to_sdl_surface(int handle) {
|
||||
Assertion(bm_is_valid(handle), "%d is no valid bitmap handle!", handle);
|
||||
|
||||
int w;
|
||||
int h;
|
||||
|
||||
bm_get_info(handle, &w, &h, nullptr, nullptr);
|
||||
Uint32 rmask, gmask, bmask, amask;
|
||||
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
rmask = 0x0000ff00;
|
||||
gmask = 0x00ff0000;
|
||||
bmask = 0xff000000;
|
||||
amask = 0x000000ff;
|
||||
#else
|
||||
rmask = 0x00ff0000;
|
||||
gmask = 0x0000ff00;
|
||||
bmask = 0x000000ff;
|
||||
amask = 0xff000000;
|
||||
#endif
|
||||
|
||||
SDL_Surface* bitmapSurface = SDL_CreateRGBSurface(0, w, h, 32, rmask, gmask, bmask, amask);
|
||||
if (SDL_LockSurface(bitmapSurface) < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
bitmap* bmp = bm_lock(handle, 32, BMP_TEX_XPARENT);
|
||||
|
||||
auto bitmapSurface = SDL_CreateSurface(bmp->w, bmp->h, SDL_PIXELFORMAT_BGRA32);
|
||||
|
||||
if (bitmapSurface) {
|
||||
memcpy(bitmapSurface->pixels, reinterpret_cast<void *>(bmp->data),
|
||||
bmp->w * bmp->h * (bmp->bpp >> 3));
|
||||
}
|
||||
memcpy(bitmapSurface->pixels, reinterpret_cast<void*>(bmp->data), static_cast<size_t>(w * h * 4));
|
||||
|
||||
bm_unlock(handle);
|
||||
bm_unload(handle);
|
||||
SDL_UnlockSurface(bitmapSurface);
|
||||
|
||||
return bitmapSurface;
|
||||
|
||||
|
||||
@@ -594,14 +594,6 @@ void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
|
||||
*/
|
||||
int bm_is_compressed(int handle);
|
||||
|
||||
/**
|
||||
* @brief Returns true if the bitmap indexed by handle was loaded from a cubemap image file
|
||||
*
|
||||
* @note Render targets return false, even cubemap ones, and so do BC7 (DX10) DDS cubemaps, whose cube flag the DDS
|
||||
* loader does not keep
|
||||
*/
|
||||
bool bm_is_cubemap(int handle);
|
||||
|
||||
/**
|
||||
* @brief Gets the correct TCACHE_TYPE for compressed graphics (uncompressed are assumed TCACHE_TYPE_NORMAL)
|
||||
*/
|
||||
|
||||
+25
-43
@@ -56,10 +56,6 @@ APPLY_TO_FOV_T(-, sub)
|
||||
|
||||
// Used to set the default value for in-game options
|
||||
static float fov_default = DEFAULT_FOV;
|
||||
static float cockpit_fov_default = DEFAULT_FOV;
|
||||
static bool cockpit_fov_toggle_default = false;
|
||||
|
||||
bool Use_cockpit_fov = false;
|
||||
|
||||
static SCP_string fov_display(float val)
|
||||
{
|
||||
@@ -77,21 +73,6 @@ static void parse_fov_func()
|
||||
fov_default = value;
|
||||
}
|
||||
|
||||
static void parse_cockpit_fov_func()
|
||||
{
|
||||
float value;
|
||||
stuff_float(&value);
|
||||
CLAMP(value, 0.436332f, 1.5708f);
|
||||
cockpit_fov_default = value;
|
||||
}
|
||||
|
||||
static void parse_cockpit_fov_toggle_func()
|
||||
{
|
||||
bool value;
|
||||
stuff_boolean(&value);
|
||||
cockpit_fov_toggle_default = value;
|
||||
}
|
||||
|
||||
// coverity[GLOBAL_INIT_ORDER] -- safe; OptionBuilder::finish() uses Meyers singleton
|
||||
auto FovOption = options::OptionBuilder<float>("Graphics.FOV",
|
||||
std::pair<const char*, int>{"Field Of View", 1703},
|
||||
@@ -109,6 +90,25 @@ auto FovOption = options::OptionBuilder<float>("Graphics.FOV",
|
||||
.parser(parse_fov_func)
|
||||
.finish();
|
||||
|
||||
bool Use_cockpit_fov = false;
|
||||
|
||||
// coverity[GLOBAL_INIT_ORDER] -- safe; OptionBuilder::finish() uses Meyers singleton
|
||||
auto CockpitFOVToggleOption = options::OptionBuilder<bool>("Graphics.CockpitFOVToggle",
|
||||
std::pair<const char*, int>{"Cockpit FOV Toggle", 1838},
|
||||
std::pair<const char*, int>{"Whether or not to use a different FOV for cockpit rendering from normal rendering", 1839})
|
||||
.category(std::make_pair("Graphics", 1825))
|
||||
.default_val(false)
|
||||
.change_listener([](bool val, bool) {
|
||||
if (!val) {
|
||||
COCKPIT_ZOOM_DEFAULT = VIEWER_ZOOM_DEFAULT;
|
||||
}
|
||||
return true; // This option will always persist so we never return false
|
||||
})
|
||||
.level(options::ExpertLevel::Advanced)
|
||||
.bind_to(&Use_cockpit_fov)
|
||||
.importance(61)
|
||||
.finish();
|
||||
|
||||
// coverity[GLOBAL_INIT_ORDER] -- safe; OptionBuilder::finish() uses Meyers singleton
|
||||
auto CockpitFovOption = options::OptionBuilder<float>("Graphics.CockpitFOV",
|
||||
std::pair<const char*, int>{"Cockpit Field Of View", 1840},
|
||||
@@ -116,35 +116,17 @@ auto CockpitFovOption = options::OptionBuilder<float>("Graphics.CockpitFOV",
|
||||
.category(std::make_pair("Graphics", 1825))
|
||||
.range(0.436332f, 1.5708f)
|
||||
.change_listener([](const float& val, bool) {
|
||||
// Graphics.CockpitFOVToggle has its own listener that re-applies this value, so the
|
||||
// result is the same whichever of the two options the manager happens to load first.
|
||||
COCKPIT_ZOOM_DEFAULT = Use_cockpit_fov ? fov_t(val) : VIEWER_ZOOM_DEFAULT;
|
||||
if (Use_cockpit_fov){
|
||||
COCKPIT_ZOOM_DEFAULT = val;
|
||||
} else {
|
||||
COCKPIT_ZOOM_DEFAULT = VIEWER_ZOOM_DEFAULT;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.display(fov_display)
|
||||
.default_func([]() { return cockpit_fov_default; })
|
||||
.default_val(fov_default)
|
||||
.level(options::ExpertLevel::Advanced)
|
||||
.importance(62)
|
||||
.parser(parse_cockpit_fov_func)
|
||||
.finish();
|
||||
|
||||
// coverity[GLOBAL_INIT_ORDER] -- safe; OptionBuilder::finish() uses Meyers singleton
|
||||
auto CockpitFOVToggleOption = options::OptionBuilder<bool>("Graphics.CockpitFOVToggle",
|
||||
std::pair<const char*, int>{"Cockpit FOV Toggle", 1838},
|
||||
std::pair<const char*, int>{"Whether or not to use a different FOV for cockpit rendering from normal rendering", 1839})
|
||||
.category(std::make_pair("Graphics", 1825))
|
||||
.default_func([]() {return cockpit_fov_toggle_default;})
|
||||
// This does the work of bind_to(&Use_cockpit_fov) and then re-applies Graphics.CockpitFOV,
|
||||
// because that option's listener needs Use_cockpit_fov to already hold its final value.
|
||||
// Doing it here makes the pair of options independent of the order the manager loads them in.
|
||||
.change_listener([](bool val, bool) {
|
||||
Use_cockpit_fov = val;
|
||||
COCKPIT_ZOOM_DEFAULT = val ? fov_t(CockpitFovOption->getValue()) : VIEWER_ZOOM_DEFAULT;
|
||||
return true; // This option will always persist so we never return false
|
||||
})
|
||||
.level(options::ExpertLevel::Advanced)
|
||||
.importance(61)
|
||||
.parser(parse_cockpit_fov_toggle_func)
|
||||
.finish();
|
||||
|
||||
//*************************CLASS: camera*************************
|
||||
|
||||
@@ -249,7 +249,7 @@ void photo_mode_compute_hud_layout()
|
||||
if (param.type == photo_mode_param_type::INT_RANGE) {
|
||||
snprintf(buf, sizeof(buf), "%s: %d", XSTR(param.label, param.xstr_id), param.max_val);
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%s: %s", XSTR(param.label, param.xstr_id), XSTR("Off", 1286));
|
||||
snprintf(buf, sizeof(buf), "%s: %s", XSTR(param.label, param.xstr_id), XSTR("Off", 1285));
|
||||
}
|
||||
measure(buf);
|
||||
}
|
||||
|
||||
+17
-92
@@ -33,7 +33,7 @@
|
||||
#include "parse/encrypt.h"
|
||||
#include "cfilesystem.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <limits>
|
||||
|
||||
char Cfile_root_dir[CFILE_ROOT_DIRECTORY_LEN] = "";
|
||||
@@ -85,7 +85,7 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
|
||||
{ CF_TYPE_INTEL_ANIMS, "data" DIR_SEPARATOR_STR "intelanims", ".pcx .ani .eff .tga .jpg .png .dds .ktx", CF_TYPE_DATA },
|
||||
{ CF_TYPE_SCRIPTS, "data" DIR_SEPARATOR_STR "scripts", ".lua .lc .fnl", CF_TYPE_DATA },
|
||||
{ CF_TYPE_FICTION, "data" DIR_SEPARATOR_STR "fiction", ".txt", CF_TYPE_DATA },
|
||||
{ CF_TYPE_FREDDOCS, "data" DIR_SEPARATOR_STR "freddocs", ".html .css .png .jpg", CF_TYPE_DATA }
|
||||
{ CF_TYPE_FREDDOCS, "data" DIR_SEPARATOR_STR "freddocs", ".html .qch .css .png .jpg", CF_TYPE_DATA }
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -185,12 +185,7 @@ int cfile_init(const char *exe_dir, const char *cdrom_dir)
|
||||
|
||||
char buf[CFILE_ROOT_DIRECTORY_LEN];
|
||||
|
||||
#ifndef __ANDROID__
|
||||
strncpy(buf, exe_dir, CFILE_ROOT_DIRECTORY_LEN - 1);
|
||||
#else
|
||||
(void)exe_dir;
|
||||
strncpy(buf, os_android_get_working_folder_path().c_str(), CFILE_ROOT_DIRECTORY_LEN - 1);
|
||||
#endif
|
||||
strncpy(buf, exe_dir, CFILE_ROOT_DIRECTORY_LEN - 1);
|
||||
|
||||
buf[CFILE_ROOT_DIRECTORY_LEN - 1] = '\0';
|
||||
|
||||
@@ -837,7 +832,7 @@ static int cfget_cfile_block()
|
||||
mprintf(("Out of cfile blocks! Currently opened files:\n"));
|
||||
dump_opened_files();
|
||||
|
||||
Warning(LOCATION, "There are no more free cfile blocks. This means that there are too many files opened by FSO.\n"
|
||||
UNREACHABLE("There are no more free cfile blocks. This means that there are too many files opened by FSO.\n"
|
||||
"This is probably caused by a programming or scripting error where a file does not get closed."); // out of free cfile blocks
|
||||
return -1;
|
||||
}
|
||||
@@ -1110,98 +1105,28 @@ void cfread_string(char *buf, int n, CFILE *file)
|
||||
} while (c != 0 );
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct string_len_header {
|
||||
int len = 0;
|
||||
int stored = 0;
|
||||
int start = 0;
|
||||
bool length_cut = false;
|
||||
};
|
||||
|
||||
// a past-the-end length is clamped like any cfread, but a negative one has nothing to clamp to, so inside a
|
||||
// limited section it throws and the loader skips the rest of the section
|
||||
string_len_header read_string_len_header(CFILE* file)
|
||||
void cfread_string_len(char *buf, int buffer_size, CFILE *file)
|
||||
{
|
||||
string_len_header h;
|
||||
if (!cf_is_valid(file)) {
|
||||
return h;
|
||||
int len;
|
||||
len = cfread_int(file);
|
||||
Assertion( (len <= buffer_size), "String cannot fit in buffer, len: %i, buffer: %i", len, buffer_size);
|
||||
if (len) {
|
||||
cfread(buf, len, 1, file);
|
||||
Assertion(len != buffer_size || buf[len - 1] == 0, "Unterminated string does not fit in buffer");
|
||||
}
|
||||
int before = cftell(file);
|
||||
h.length_cut = cfread(&h.len, sizeof(h.len), 1, file) != 1;
|
||||
h.start = cftell(file);
|
||||
if (h.length_cut) {
|
||||
// a clean end of file reads as an empty string without a warning, as cfread_int does
|
||||
h.length_cut = (h.start != before) || (cfeof(file) == 0);
|
||||
return h;
|
||||
}
|
||||
h.len = INTEL_INT(h.len);
|
||||
if ((h.len < 0) && (file->max_read_len != 0)) {
|
||||
throw cfile::max_read_length("Attempted to read a string of negative length " + std::to_string(h.len));
|
||||
}
|
||||
h.stored = static_cast<int>(cf_check_read_size(file, static_cast<size_t>(std::max(h.len, 0))));
|
||||
return h;
|
||||
}
|
||||
|
||||
// reads count of the stored characters and leaves the file just past the whole string; false if the read failed
|
||||
bool read_string_len_body(const string_len_header& h, char* dest, int count, CFILE* file)
|
||||
{
|
||||
bool ok = (count <= 0) || (cfread(dest, count, 1, file) == 1);
|
||||
if (!ok || (h.stored > count)) {
|
||||
cfseek(file, h.start + h.stored, CF_SEEK_SET);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
// warned last, so the file position is right even if a debug build stops here
|
||||
void warn_string_len(const string_len_header& h, bool read_ok, bool cut, int buffer_size, CFILE* file)
|
||||
{
|
||||
if (h.length_cut) {
|
||||
Warning(LOCATION, "cfread_string_len: cut-off string length field in %s", cf_get_filename(file));
|
||||
} else if (!read_ok) {
|
||||
Warning(LOCATION,
|
||||
"cfread_string_len: could not read a string of %d characters in %s",
|
||||
h.stored,
|
||||
cf_get_filename(file));
|
||||
} else if (h.len != h.stored) {
|
||||
Warning(LOCATION, "cfread_string_len: corrupt string length %d in %s", h.len, cf_get_filename(file));
|
||||
} else if (cut) {
|
||||
Warning(LOCATION,
|
||||
"cfread_string_len: a string of %d bytes was cut to fit a buffer of %d in %s",
|
||||
h.len,
|
||||
buffer_size,
|
||||
cf_get_filename(file));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void cfread_string_len(char* buf, int buffer_size, CFILE* file)
|
||||
{
|
||||
Assertion(buffer_size > 0, "cfread_string_len needs room for at least the terminator, buffer: %i", buffer_size);
|
||||
string_len_header h = read_string_len_header(file);
|
||||
if (buffer_size <= 0) {
|
||||
bool read_ok = read_string_len_body(h, buf, 0, file);
|
||||
warn_string_len(h, read_ok, h.stored > 0, buffer_size, file);
|
||||
return;
|
||||
}
|
||||
int count = std::min(h.stored, buffer_size);
|
||||
bool read_ok = read_string_len_body(h, buf, count, file);
|
||||
int kept = read_ok ? count : 0;
|
||||
bool cut = (kept == buffer_size) && (memchr(buf, 0, buffer_size) == nullptr);
|
||||
buf[std::min(kept, buffer_size - 1)] = 0;
|
||||
warn_string_len(h, read_ok, cut, buffer_size, file);
|
||||
buf[MIN(len, buffer_size - 1)] = 0;
|
||||
}
|
||||
|
||||
SCP_string cfread_string_len(CFILE *file)
|
||||
{
|
||||
string_len_header h = read_string_len_header(file);
|
||||
int len = cfread_int(file);
|
||||
|
||||
SCP_string str;
|
||||
str.resize(h.stored);
|
||||
bool read_ok = read_string_len_body(h, str.data(), h.stored, file);
|
||||
if (!read_ok) {
|
||||
str.clear();
|
||||
}
|
||||
warn_string_len(h, read_ok, false, 0, file);
|
||||
str.resize(len);
|
||||
|
||||
if (len)
|
||||
cfread(&str[0], len, 1, file);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
+2
-8
@@ -320,26 +320,20 @@ void cfread_string(char *buf,int n, CFILE *file);
|
||||
/**
|
||||
* @brief Read a fixed length string that is not null-terminated, with the length stored in file.
|
||||
*
|
||||
* Keeps at most buffer_size - 1 characters and leaves the file just past the whole string, unless it throws.
|
||||
*
|
||||
* If it is not null-terminated, the length of the string *must* be less than the size of the buffer (to make room for one)
|
||||
*
|
||||
* @param buf Pre-allocated array to store string
|
||||
* @param buffer_size Size of pre-allocated array
|
||||
* @param file File to read from
|
||||
*
|
||||
* @note Appends NULL character to string (buf)
|
||||
* @note Bad data gets a warning; at a clean end of file, or with an invalid file, the string is empty and nothing is
|
||||
* warned. Inside a limited section (cf_set_max_read_len), a negative length, or a read that still passes the limit
|
||||
* once clamped to the end of the file, throws cfile::max_read_length.
|
||||
*/
|
||||
void cfread_string_len(char *buf,int buffer_size, CFILE *file);
|
||||
|
||||
/**
|
||||
* @brief Read a string from the file where the length is stored in the file
|
||||
*
|
||||
* @param file The file to read the string from
|
||||
* @return The string that was read
|
||||
*
|
||||
* @note Warns and throws like the char* overload, except that nothing is cut.
|
||||
*/
|
||||
SCP_string cfread_string_len(CFILE *file);
|
||||
|
||||
|
||||
+14
-24
@@ -193,8 +193,21 @@ int cfseek( CFILE *cfile, int offset, int where )
|
||||
}
|
||||
|
||||
|
||||
size_t cf_check_read_size(CFILE* cfile, size_t size)
|
||||
// cfread() reads from a file
|
||||
//
|
||||
// returns: returns the number of full elements read
|
||||
//
|
||||
//
|
||||
int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
|
||||
{
|
||||
if(!cf_is_valid(cfile))
|
||||
return 0;
|
||||
|
||||
size_t size = elsize*nelem;
|
||||
|
||||
if(buf == NULL || size <= 0)
|
||||
return 0;
|
||||
|
||||
if ( (cfile->raw_position+size) > cfile->size ) {
|
||||
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
|
||||
size = cfile->size - cfile->raw_position;
|
||||
@@ -213,29 +226,6 @@ size_t cf_check_read_size(CFILE* cfile, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
// cfread() reads from a file
|
||||
//
|
||||
// returns: returns the number of full elements read
|
||||
//
|
||||
//
|
||||
int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
|
||||
{
|
||||
if(!cf_is_valid(cfile))
|
||||
return 0;
|
||||
|
||||
size_t size = elsize*nelem;
|
||||
|
||||
if(buf == nullptr || size <= 0)
|
||||
return 0;
|
||||
|
||||
size = cf_check_read_size(cfile, size);
|
||||
if (size < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t bytes_read;
|
||||
if (cfile->data != nullptr) {
|
||||
// This is a file from memory
|
||||
|
||||
@@ -62,9 +62,4 @@ void cf_check_compression(CFILE* cfile);
|
||||
// Used to clear compression info data and free dynamic memory used by compression
|
||||
void cf_clear_compression_info(CFILE* cfile);
|
||||
|
||||
// Clamps a read of size bytes to the end of the file and returns the clamped size, or 0 at the end of the file
|
||||
// without checking the limit; throws cfile::max_read_length if the clamped read would pass the file's read limit
|
||||
// (cf_set_max_read_len).
|
||||
size_t cf_check_read_size(CFILE* cfile, size_t size);
|
||||
|
||||
#endif
|
||||
+71
-222
@@ -15,7 +15,6 @@
|
||||
#include "globalincs/pstypes.h"
|
||||
#include "globalincs/systemvars.h"
|
||||
#include "globalincs/version.h"
|
||||
#include "graphics/2d.h"
|
||||
#include "graphics/openxr.h"
|
||||
#include "graphics/shadows.h"
|
||||
#include "hud/hudconfig.h"
|
||||
@@ -75,7 +74,6 @@ const char *cmdline_arg_types[] =
|
||||
enum class flag_output_type {
|
||||
Binary,
|
||||
Json_V1,
|
||||
Json_V2,
|
||||
};
|
||||
|
||||
// variables
|
||||
@@ -358,7 +356,6 @@ cmdline_parm fb_explosions_arg("-fb_explosions", NULL, AT_NONE);
|
||||
cmdline_parm fb_thrusters_arg("-fb_thrusters", NULL, AT_NONE);
|
||||
cmdline_parm shadow_quality_arg("-shadow_quality", NULL, AT_INT);
|
||||
cmdline_parm enable_shadows_arg("-enable_shadows", NULL, AT_NONE);
|
||||
cmdline_parm rt_shadows_arg("-rt_shadows", nullptr, AT_NONE);
|
||||
cmdline_parm no_deferred_lighting_arg("-no_deferred", NULL, AT_NONE); // Cmdline_no_deferred
|
||||
cmdline_parm deferred_lighting_cockpit_arg("-deferred_cockpit", nullptr, AT_NONE);
|
||||
cmdline_parm anisotropy_level_arg("-anisotropic_filter", NULL, AT_INT);
|
||||
@@ -516,7 +513,6 @@ cmdline_parm deprecated_res_arg("-res", "Deprecated, resolution, formatted like
|
||||
cmdline_parm render_res_arg("-render_res", "Resolution, formatted like 1600x900", AT_STRING);
|
||||
cmdline_parm window_res_arg("-window_res", "Window resolution, formatted like 1600x900.", AT_STRING);
|
||||
cmdline_parm center_res_arg("-center_res", "Resolution of center monitor, formatted like 1600x900", AT_STRING);
|
||||
cmdline_parm hdr_nits_arg("-hdr", "Forces HDR output on, overriding the in-game HDR setting. Optionally takes paper white and peak luminance in nits, formatted like 400,1500, overriding the in-game HDR nits settings.", AT_STRING);
|
||||
cmdline_parm verify_vps_arg("-verify_vps", NULL, AT_NONE); // Cmdline_verify_vps -- spew VP crcs to vp_crcs.txt
|
||||
cmdline_parm parse_cmdline_only(PARSE_COMMAND_LINE_STRING, "Ignore any cmdline_fso.cfg files", AT_NONE);
|
||||
cmdline_parm reparse_mainhall_arg("-reparse_mainhall", NULL, AT_NONE); //Cmdline_reparse_mainhall
|
||||
@@ -531,7 +527,6 @@ cmdline_parm show_video_info("-show_video_info", NULL, AT_NONE); //Cmdline_show_
|
||||
cmdline_parm frame_profile_arg("-profile_frame_time", NULL, AT_NONE); //Cmdline_frame_profile
|
||||
cmdline_parm debug_window_arg("-debug_window", NULL, AT_NONE); // Cmdline_debug_window
|
||||
cmdline_parm graphics_debug_output_arg("-gr_debug", nullptr, AT_NONE); // Cmdline_graphics_debug_output
|
||||
cmdline_parm gr_sync_validation_arg("-gr_sync_validation", nullptr, AT_NONE); // Cmdline_gr_sync_validation (implies -gr_debug)
|
||||
cmdline_parm log_to_stdout_arg("-stdout_log", nullptr, AT_NONE); // Cmdline_log_to_stdout
|
||||
cmdline_parm slow_frames_ok_arg("-slow_frames_ok", nullptr, AT_NONE); // Cmdline_slow_frames_ok
|
||||
cmdline_parm fixed_seed_rand("-seed", nullptr, AT_INT); // Cmdline_rng_seed,Cmdline_reuse_rng_seed;
|
||||
@@ -539,7 +534,6 @@ cmdline_parm luadev_arg("-luadev", "Make lua errors non-fatal", AT_NONE); // Cmd
|
||||
cmdline_parm override_arg("-override_data", "Enable override directory", AT_NONE); // Cmdline_override_data
|
||||
cmdline_parm imgui_debug_arg("-imgui_debug", nullptr, AT_NONE);
|
||||
cmdline_parm vulkan("-vulkan", nullptr, AT_NONE);
|
||||
cmdline_parm opengl("-opengl", nullptr, AT_NONE);
|
||||
cmdline_parm multithreading("-threads", nullptr, AT_INT);
|
||||
|
||||
char *Cmdline_start_mission = NULL;
|
||||
@@ -556,12 +550,7 @@ int Cmdline_show_pos = 0;
|
||||
int Cmdline_show_stats = 0;
|
||||
int Cmdline_save_render_targets = 0;
|
||||
bool Cmdline_window = false;
|
||||
#ifdef __ANDROID__
|
||||
// Default to borderless in the legacy window-mode path as well.
|
||||
bool Cmdline_fullscreen_window = true;
|
||||
#else
|
||||
bool Cmdline_fullscreen_window = false;
|
||||
#endif
|
||||
std::optional<std::pair<uint16_t, uint16_t>>Cmdline_window_res = std::nullopt;
|
||||
char *Cmdline_res = 0;
|
||||
char *Cmdline_center_res = 0;
|
||||
@@ -578,13 +567,12 @@ bool Cmdline_frame_profile = false;
|
||||
bool Cmdline_show_video_info = false;
|
||||
bool Cmdline_debug_window = false;
|
||||
bool Cmdline_graphics_debug_output = false;
|
||||
bool Cmdline_gr_sync_validation = false;
|
||||
bool Cmdline_log_to_stdout = false;
|
||||
bool Cmdline_slow_frames_ok = false;
|
||||
bool Cmdline_lua_devmode = false;
|
||||
bool Cmdline_override_data = false;
|
||||
bool Cmdline_show_imgui_debug = false;
|
||||
GraphicsAPI Cmdline_graphics_api = GraphicsAPI::Default;
|
||||
bool Cmdline_vulkan = false;
|
||||
int Cmdline_multithreading = 1;
|
||||
|
||||
// Other
|
||||
@@ -1364,58 +1352,51 @@ static void handle_unix_modlist(char **modlist, size_t *len)
|
||||
|
||||
// external entry point into this modules
|
||||
|
||||
static void json_add_version(json_t* root) {
|
||||
auto version_obj = json_object();
|
||||
|
||||
json_object_set_new(version_obj, "full", json_string(FS_VERSION_FULL));
|
||||
json_object_set_new(version_obj, "major", json_integer(FS_VERSION_MAJOR));
|
||||
json_object_set_new(version_obj, "minor", json_integer(FS_VERSION_MINOR));
|
||||
json_object_set_new(version_obj, "build", json_integer(FS_VERSION_BUILD));
|
||||
|
||||
json_object_set_new(version_obj, "has_revision", json_boolean(FS_VERSION_HAS_REVIS));
|
||||
json_object_set_new(version_obj, "revision", json_integer(FS_VERSION_REVIS));
|
||||
json_object_set_new(version_obj, "revision_str", json_string(FS_VERSION_REVIS_STR));
|
||||
|
||||
json_object_set_new(root, "version", version_obj);
|
||||
}
|
||||
|
||||
static void json_add_easy_flags(json_t* root) {
|
||||
auto easy_array = json_array();
|
||||
|
||||
for (auto& easy_flag : easy_flags) {
|
||||
json_array_append_new(easy_array, json_string(easy_flag.name));
|
||||
}
|
||||
|
||||
json_object_set_new(root, "easy_flags", easy_array);
|
||||
}
|
||||
|
||||
static void json_add_flags(json_t* root) {
|
||||
auto flags_array = json_array();
|
||||
|
||||
for (auto& flag : exe_params) {
|
||||
auto flag_obj = json_object();
|
||||
|
||||
json_object_set_new(flag_obj, "name", json_string(flag.name));
|
||||
json_object_set_new(flag_obj, "description", json_string(flag.desc));
|
||||
json_object_set_new(flag_obj, "fso_only", json_boolean(flag.fso_only));
|
||||
json_object_set_new(flag_obj, "on_flags", json_integer(flag.on_flags));
|
||||
json_object_set_new(flag_obj, "off_flags", json_integer(flag.off_flags));
|
||||
json_object_set_new(flag_obj, "type", json_string(flag.type));
|
||||
json_object_set_new(flag_obj, "web_url", json_string(flag.web_url));
|
||||
|
||||
json_array_append_new(flags_array, flag_obj);
|
||||
}
|
||||
|
||||
json_object_set_new(root, "flags", flags_array);
|
||||
}
|
||||
|
||||
static json_t* json_get_v1() {
|
||||
auto root = json_object();
|
||||
|
||||
json_add_version(root);
|
||||
json_add_easy_flags(root);
|
||||
json_add_flags(root);
|
||||
{
|
||||
auto version_obj = json_object();
|
||||
|
||||
json_object_set_new(version_obj, "full", json_string(FS_VERSION_FULL));
|
||||
json_object_set_new(version_obj, "major", json_integer(FS_VERSION_MAJOR));
|
||||
json_object_set_new(version_obj, "minor", json_integer(FS_VERSION_MINOR));
|
||||
json_object_set_new(version_obj, "build", json_integer(FS_VERSION_BUILD));
|
||||
|
||||
json_object_set_new(version_obj, "has_revision", json_boolean(FS_VERSION_HAS_REVIS));
|
||||
json_object_set_new(version_obj, "revision", json_integer(FS_VERSION_REVIS));
|
||||
json_object_set_new(version_obj, "revision_str", json_string(FS_VERSION_REVIS_STR));
|
||||
|
||||
json_object_set_new(root, "version", version_obj);
|
||||
}
|
||||
{
|
||||
auto easy_array = json_array();
|
||||
|
||||
for (auto& easy_flag : easy_flags) {
|
||||
json_array_append_new(easy_array, json_string(easy_flag.name));
|
||||
}
|
||||
|
||||
json_object_set_new(root, "easy_flags", easy_array);
|
||||
}
|
||||
{
|
||||
auto flags_array = json_array();
|
||||
|
||||
for (auto& flag : exe_params) {
|
||||
auto flag_obj = json_object();
|
||||
|
||||
json_object_set_new(flag_obj, "name", json_string(flag.name));
|
||||
json_object_set_new(flag_obj, "description", json_string(flag.desc));
|
||||
json_object_set_new(flag_obj, "fso_only", json_boolean(flag.fso_only));
|
||||
json_object_set_new(flag_obj, "on_flags", json_integer(flag.on_flags));
|
||||
json_object_set_new(flag_obj, "off_flags", json_integer(flag.off_flags));
|
||||
json_object_set_new(flag_obj, "type", json_string(flag.type));
|
||||
json_object_set_new(flag_obj, "web_url", json_string(flag.web_url));
|
||||
|
||||
json_array_append_new(flags_array, flag_obj);
|
||||
}
|
||||
|
||||
json_object_set_new(root, "flags", flags_array);
|
||||
}
|
||||
{
|
||||
auto caps_array = json_array();
|
||||
|
||||
@@ -1526,19 +1507,6 @@ static json_t* json_get_v1() {
|
||||
return root;
|
||||
}
|
||||
|
||||
// json_v2 reports version, supported flags, and the preferences path for launchers,
|
||||
// without querying graphics, audio, or joystick devices.
|
||||
static json_t* json_get_v2() {
|
||||
auto root = json_object();
|
||||
|
||||
json_add_version(root);
|
||||
json_add_easy_flags(root);
|
||||
json_add_flags(root);
|
||||
json_object_set_new(root, "pref_path", json_string(os_get_config_path().c_str()));
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
static void write_flags_file() {
|
||||
FILE *fp = fopen("flags.lch","w");
|
||||
|
||||
@@ -1596,8 +1564,6 @@ static flag_output_type get_flags_output_type() {
|
||||
return flag_output_type::Binary;
|
||||
} else if (type == "json_v1") {
|
||||
return flag_output_type::Json_V1;
|
||||
} else if (type == "json_v2") {
|
||||
return flag_output_type::Json_V2;
|
||||
} else {
|
||||
// This is supposed to make it easy for the launcher to recognize an unsupported type
|
||||
printf("OUTPUT TYPE NOT SUPPORTED!\n");
|
||||
@@ -1608,23 +1574,17 @@ static flag_output_type get_flags_output_type() {
|
||||
|
||||
static void write_flags() {
|
||||
auto type = get_flags_output_type();
|
||||
|
||||
if (type == flag_output_type::Binary) {
|
||||
switch(type) {
|
||||
case flag_output_type::Binary:
|
||||
write_flags_file();
|
||||
return;
|
||||
break;
|
||||
case flag_output_type::Json_V1:
|
||||
json_t* root = json_get_v1();
|
||||
|
||||
json_dumpf(root, stdout, JSON_INDENT(4));
|
||||
json_decref(root);
|
||||
break;
|
||||
}
|
||||
|
||||
json_t* root = (type == flag_output_type::Json_V1) ? json_get_v1() : json_get_v2();
|
||||
|
||||
#ifdef __ANDROID__
|
||||
char* dumped = json_dumps(root, JSON_INDENT(4));
|
||||
os_android_set_flags_string(dumped ? dumped : "");
|
||||
free(dumped);
|
||||
#else
|
||||
json_dumpf(root, stdout, JSON_INDENT(4));
|
||||
#endif
|
||||
|
||||
json_decref(root);
|
||||
}
|
||||
|
||||
bool SetCmdlineParams()
|
||||
@@ -1815,45 +1775,38 @@ bool SetCmdlineParams()
|
||||
}
|
||||
|
||||
// d3d windowed
|
||||
// We need to set both the raw global (for the legacy !Using_in_game_options path) and the
|
||||
// Option<T> override (for the modern path) since either backend may be the one actually consulted.
|
||||
if(window_arg.found()) {
|
||||
options::OptionsManager::instance()->setOverride("Graphics.WindowMode",
|
||||
std::unique_ptr<json_t>(json_integer(static_cast<int>(os::ViewportState::Windowed))), "-window");
|
||||
// We need to set both values since we don't know if we are going to use the new config system
|
||||
//options::OptionsManager::instance()->setOverride("Graphics.WindowMode", "0");
|
||||
Cmdline_window = true;
|
||||
Cmdline_fullscreen_window = false;
|
||||
}
|
||||
|
||||
if ( fullscreen_window_arg.found( ) )
|
||||
{
|
||||
options::OptionsManager::instance()->setOverride("Graphics.WindowMode",
|
||||
std::unique_ptr<json_t>(json_integer(static_cast<int>(os::ViewportState::Borderless))),
|
||||
"-fullscreen_window");
|
||||
//options::OptionsManager::instance()->setOverride("Graphics.WindowMode", "1");
|
||||
Cmdline_fullscreen_window = true;
|
||||
Cmdline_window = false; /* Make sure no-one sets both */
|
||||
}
|
||||
|
||||
if(render_res_arg.found() || deprecated_res_arg.found()){
|
||||
const char* res_flag_name;
|
||||
if (render_res_arg.found()) {
|
||||
Cmdline_res = render_res_arg.str();
|
||||
res_flag_name = "-render_res";
|
||||
}
|
||||
else {
|
||||
Cmdline_res = deprecated_res_arg.str();
|
||||
res_flag_name = "-res";
|
||||
mprintf(("Deprecated -res argument. Use -render_res instead...\n"));
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
/*int width = 0;
|
||||
int height = 0;
|
||||
|
||||
if (sscanf(Cmdline_res, "%dx%d", &width, &height) == 2) {
|
||||
options::OptionsManager::instance()->setOverride("Graphics.Resolution",
|
||||
std::unique_ptr<json_t>(json_pack("{s:i, s:i}", "width", width, "height", height)), res_flag_name);
|
||||
SCP_string override;
|
||||
sprintf(override, "{\"width\":%d,\"height\":%d}", width, height);
|
||||
options::OptionsManager::instance()->setOverride("Graphics.Resolution", override);
|
||||
} else {
|
||||
Warning(LOCATION, "Failed to parse -res parameter \"%s\". Must be in format \"<width>x<height>\".\n", Cmdline_res);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
if(window_res_arg.found()){
|
||||
int width = 0;
|
||||
@@ -1869,24 +1822,6 @@ bool SetCmdlineParams()
|
||||
if(center_res_arg.found()){
|
||||
Cmdline_center_res = center_res_arg.str();
|
||||
}
|
||||
if (hdr_nits_arg.found()) {
|
||||
// presence of the flag alone forces HDR output on, overriding the in-game HDR setting
|
||||
options::OptionsManager::instance()->setOverride("Graphics.HDR",
|
||||
std::unique_ptr<json_t>(json_true()), "-hdr");
|
||||
|
||||
if (hdr_nits_arg.has_param()) {
|
||||
float paperwhite_nits = 0.0f, peak_nits = 0.0f;
|
||||
if (sscanf(hdr_nits_arg.str(), "%f,%f", &paperwhite_nits, &peak_nits) == 2 && paperwhite_nits > 0.0f && peak_nits > 0.0f) {
|
||||
// json_real keeps these JSON reals; json_unpack's "f" format rejects a bare integer like "400"
|
||||
options::OptionsManager::instance()->setOverride("Graphics.HDRPaperWhite",
|
||||
std::unique_ptr<json_t>(json_real(paperwhite_nits)), "-hdr");
|
||||
options::OptionsManager::instance()->setOverride("Graphics.HDRPeakLuminance",
|
||||
std::unique_ptr<json_t>(json_real(peak_nits)), "-hdr");
|
||||
} else {
|
||||
Warning(LOCATION, "Failed to parse -hdr parameter \"%s\". Must be in format \"<paperwhite_nits>,<peak_nits>\".\n", hdr_nits_arg.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(almission_arg.found()){//DTP for autoload mission // developer oritentated
|
||||
Cmdline_almission = almission_arg.str();
|
||||
Cmdline_use_last_pilot = 1;
|
||||
@@ -1979,20 +1914,17 @@ bool SetCmdlineParams()
|
||||
|
||||
if ( fov_arg.found() ) {
|
||||
auto val = fov_arg.get_float();
|
||||
if (val <= 0.1f) {
|
||||
val = DEFAULT_FOV;
|
||||
if (val > 0.1) {
|
||||
VIEWER_ZOOM_DEFAULT = val;
|
||||
} else {
|
||||
VIEWER_ZOOM_DEFAULT = DEFAULT_FOV;
|
||||
}
|
||||
VIEWER_ZOOM_DEFAULT = val;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.FOV",
|
||||
std::unique_ptr<json_t>(json_real(val)), "-fov");
|
||||
}
|
||||
|
||||
if ( fov_cockpit_arg.found() ) {
|
||||
auto val = fov_cockpit_arg.get_float();
|
||||
if (val > 0.1f) {
|
||||
if (val > 0.1) {
|
||||
COCKPIT_ZOOM_DEFAULT = val;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.CockpitFOV",
|
||||
std::unique_ptr<json_t>(json_real(val)), "-fov_cockpit");
|
||||
}
|
||||
else {
|
||||
COCKPIT_ZOOM_DEFAULT = VIEWER_ZOOM_DEFAULT;
|
||||
@@ -2015,18 +1947,13 @@ bool SetCmdlineParams()
|
||||
|
||||
Cmdline_fullscreen_window = false;
|
||||
Cmdline_window = true; /* Make sure no-one sets both */
|
||||
// These replace the removeWindowModeOption()/removeVSyncOption() calls that used to hide these two
|
||||
// options in VR. An override keeps them visible but disabled in the options menu, with the tooltip
|
||||
// naming -vr as the reason, which tells the player more than the control simply not being there.
|
||||
options::OptionsManager::instance()->setOverride("Graphics.WindowMode",
|
||||
std::unique_ptr<json_t>(json_integer(static_cast<int>(os::ViewportState::Windowed))), "-vr");
|
||||
removeWindowModeOption();
|
||||
|
||||
// Turn off VSync, since we definitely don't want to be capped by the main monitor
|
||||
// the OpenXR runtime should have a buffered wait which will behave, effectively,
|
||||
// as a VSync to VR goggle driver
|
||||
Gr_enable_vsync = false;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.VSync",
|
||||
std::unique_ptr<json_t>(json_false()), "-vr");
|
||||
removeVSyncOption();
|
||||
|
||||
openxr_prepare();
|
||||
}
|
||||
@@ -2081,8 +2008,6 @@ bool SetCmdlineParams()
|
||||
if(no_vsync_arg.found() )
|
||||
{
|
||||
Gr_enable_vsync = false;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.VSync",
|
||||
std::unique_ptr<json_t>(json_false()), "-no_vsync");
|
||||
}
|
||||
|
||||
if ( normal_arg.found() ) {
|
||||
@@ -2116,15 +2041,11 @@ bool SetCmdlineParams()
|
||||
case 5:
|
||||
Gr_aa_mode = AntiAliasMode::SMAA_High;
|
||||
break;
|
||||
case 6:
|
||||
case 6:
|
||||
Gr_aa_mode = AntiAliasMode::SMAA_Ultra;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
options::OptionsManager::instance()->setOverride("Graphics.AAMode",
|
||||
std::unique_ptr<json_t>(json_integer(static_cast<int>(Gr_aa_mode))),
|
||||
post_process_aa_preset_arg.found() ? "-aa_preset" : "-aa");
|
||||
}
|
||||
|
||||
if (msaa_enabled_arg.found()) {
|
||||
@@ -2140,9 +2061,6 @@ bool SetCmdlineParams()
|
||||
Cmdline_msaa_enabled = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
options::OptionsManager::instance()->setOverride("Graphics.MSAASamples",
|
||||
std::unique_ptr<json_t>(json_integer(Cmdline_msaa_enabled)), "-msaa");
|
||||
}
|
||||
|
||||
if ( glow_arg.found() )
|
||||
@@ -2268,8 +2186,6 @@ bool SetCmdlineParams()
|
||||
if ( softparticles_arg.found() )
|
||||
{
|
||||
Cmdline_softparticles = 1;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.SoftParticles",
|
||||
std::unique_ptr<json_t>(json_true()), "-soft_particles");
|
||||
}
|
||||
|
||||
if ( fb_explosions_arg.found() )
|
||||
@@ -2277,31 +2193,14 @@ bool SetCmdlineParams()
|
||||
Gr_framebuffer_effects.set(FramebufferEffects::Shockwaves, true);
|
||||
}
|
||||
|
||||
if (fb_thrusters_arg.found())
|
||||
if (fb_thrusters_arg.found())
|
||||
{
|
||||
Gr_framebuffer_effects.set(FramebufferEffects::Thrusters, true);
|
||||
}
|
||||
|
||||
if (fb_explosions_arg.found() || fb_thrusters_arg.found()) {
|
||||
SCP_string reason;
|
||||
if (fb_explosions_arg.found()) {
|
||||
reason = "-fb_explosions";
|
||||
}
|
||||
if (fb_thrusters_arg.found()) {
|
||||
if (!reason.empty()) {
|
||||
reason += " ";
|
||||
}
|
||||
reason += "-fb_thrusters";
|
||||
}
|
||||
options::OptionsManager::instance()->setOverride("Graphics.FramebufferEffects",
|
||||
std::unique_ptr<json_t>(json_integer(static_cast<json_int_t>(Gr_framebuffer_effects.to_u64()))), reason);
|
||||
}
|
||||
|
||||
if ( no_postprocess_arg.found() )
|
||||
{
|
||||
Gr_post_processing_enabled = false;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.PostProcessing",
|
||||
std::unique_ptr<json_t>(json_false()), "-no_post_process");
|
||||
}
|
||||
|
||||
if( reparse_mainhall_arg.found() )
|
||||
@@ -2315,19 +2214,12 @@ bool SetCmdlineParams()
|
||||
Shadow_quality_uses_mod_option = true;
|
||||
|
||||
Shadow_quality = ShadowQuality::Medium;
|
||||
|
||||
// Deliberately not calling setOverride() here: mod_table_init() (which runs after cmdline parsing but
|
||||
// before OptionsManager::loadInitialValues()) may still adjust Shadow_quality via game_settings.tbl's
|
||||
// "$Shadow Quality Default:" when Shadow_quality_uses_mod_option is set, and an override registered now
|
||||
// would freeze in the Medium fallback and ignore that later adjustment. Graphics.Shadows' default_func
|
||||
// reads Shadow_quality instead, so this value reaches the in-game options path that way, and the
|
||||
// player keeps the ability to change it.
|
||||
}
|
||||
|
||||
if( shadow_quality_arg.found() )
|
||||
{
|
||||
// set that we are not using default shadow quality level --wookieejedi
|
||||
Shadow_quality_uses_mod_option = false;
|
||||
Shadow_quality_uses_mod_option = false;
|
||||
|
||||
switch (shadow_quality_arg.get_int()) {
|
||||
case 0:
|
||||
@@ -2350,47 +2242,21 @@ bool SetCmdlineParams()
|
||||
Shadow_quality = ShadowQuality::Disabled;
|
||||
break;
|
||||
}
|
||||
|
||||
// Unlike `-enable_shadows` alone, an explicit quality level is an unambiguous hard override that
|
||||
// nothing else (mod defaults included) should be able to silently override.
|
||||
options::OptionsManager::instance()->setOverride("Graphics.Shadows",
|
||||
std::unique_ptr<json_t>(json_integer(static_cast<int>(Shadow_quality))), "-shadow_quality");
|
||||
}
|
||||
|
||||
if( rt_shadows_arg.found() )
|
||||
{
|
||||
// Equivalent to picking "Raytraced" in the Shadow Method option. Silently
|
||||
// has no effect if the renderer/hardware doesn't support
|
||||
// CAPABILITY_RAYTRACED_SHADOWS -- the CSM path is used either way.
|
||||
Shadow_render_method = ShadowRenderMethod::Raytraced;
|
||||
|
||||
// No need to gate this on shadows_raytracing_supported(): that answer is only meaningful after
|
||||
// gr_init(), which runs later, and shadows_remove_unsupported_options() then removes this option
|
||||
// altogether on hardware that cannot raytrace, so the override never reaches the options menu there.
|
||||
options::OptionsManager::instance()->setOverride("Graphics.ShadowRenderMethod",
|
||||
std::unique_ptr<json_t>(json_integer(static_cast<int>(ShadowRenderMethod::Raytraced))), "-rt_shadows");
|
||||
}
|
||||
|
||||
if( no_deferred_lighting_arg.found() )
|
||||
{
|
||||
Cmdline_no_deferred_lighting = 1;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.DeferredLighting",
|
||||
std::unique_ptr<json_t>(json_false()), "-no_deferred");
|
||||
}
|
||||
|
||||
if( deferred_lighting_cockpit_arg.found() )
|
||||
{
|
||||
Cmdline_deferred_lighting_cockpit = true;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.DeferredCockpitLighting",
|
||||
std::unique_ptr<json_t>(json_true()), "-deferred_cockpit");
|
||||
}
|
||||
|
||||
if (anisotropy_level_arg.found())
|
||||
if (anisotropy_level_arg.found())
|
||||
{
|
||||
Cmdline_aniso_level = anisotropy_level_arg.get_int();
|
||||
|
||||
options::OptionsManager::instance()->setOverride("Graphics.Anisotropy",
|
||||
std::unique_ptr<json_t>(json_real(static_cast<double>(Cmdline_aniso_level))), "-anisotropic_filter");
|
||||
}
|
||||
|
||||
if (frame_profile_write_file.found())
|
||||
@@ -2441,16 +2307,6 @@ bool SetCmdlineParams()
|
||||
Cmdline_graphics_debug_output = true;
|
||||
}
|
||||
|
||||
if (gr_sync_validation_arg.found()) {
|
||||
// Enables the Vulkan validation layer + debug messenger + synchronization
|
||||
// validation feature (see VulkanRenderer::initializeInstance), but NOT the
|
||||
// engine-level graphics debug output: -gr_debug additionally draws debug
|
||||
// overlays (e.g. output_uniform_debug_data), which are unrelated to GPU
|
||||
// sync validation and would otherwise appear as spurious on-screen
|
||||
// artifacts. Keep this a pure GPU-validation switch.
|
||||
Cmdline_gr_sync_validation = true;
|
||||
}
|
||||
|
||||
if (log_to_stdout_arg.found()) {
|
||||
Cmdline_log_to_stdout = true;
|
||||
}
|
||||
@@ -2476,14 +2332,7 @@ bool SetCmdlineParams()
|
||||
}
|
||||
|
||||
if (vulkan.found()) {
|
||||
Cmdline_graphics_api = GraphicsAPI::Vulkan;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.RenderAPI",
|
||||
std::unique_ptr<json_t>(json_integer(static_cast<int>(GraphicsAPI::Vulkan))), "-vulkan");
|
||||
}
|
||||
else if (opengl.found()) {
|
||||
Cmdline_graphics_api = GraphicsAPI::OpenGL;
|
||||
options::OptionsManager::instance()->setOverride("Graphics.RenderAPI",
|
||||
std::unique_ptr<json_t>(json_integer(static_cast<int>(GraphicsAPI::OpenGL))), "-opengl");
|
||||
Cmdline_vulkan = true;
|
||||
}
|
||||
|
||||
//Deprecated flags - CommanderDJ
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#define FS_CMDLINE_HEADER_FILE
|
||||
|
||||
#include <optional>
|
||||
#include "graphics/2d.h"
|
||||
|
||||
int parse_cmdline(int argc, char *argv[]);
|
||||
|
||||
@@ -154,18 +153,19 @@ extern bool Cmdline_frame_profile;
|
||||
extern bool Cmdline_show_video_info;
|
||||
extern bool Cmdline_debug_window;
|
||||
extern bool Cmdline_graphics_debug_output;
|
||||
extern bool Cmdline_gr_sync_validation;
|
||||
extern bool Cmdline_log_to_stdout;
|
||||
extern bool Cmdline_slow_frames_ok;
|
||||
extern bool Cmdline_lua_devmode;
|
||||
extern bool Cmdline_override_data;
|
||||
extern bool Cmdline_show_imgui_debug;
|
||||
extern GraphicsAPI Cmdline_graphics_api;
|
||||
extern bool Cmdline_vulkan;
|
||||
extern int Cmdline_multithreading;
|
||||
|
||||
enum class WeaponSpewType { NONE = 0, STANDARD, ALL };
|
||||
extern WeaponSpewType Cmdline_spew_weapon_stats;
|
||||
|
||||
extern void removeVSyncOption();
|
||||
extern void removeWindowModeOption();
|
||||
extern void removeResolutionOption();
|
||||
extern void removeResolutionVROption();
|
||||
|
||||
|
||||
@@ -739,7 +739,7 @@ void control_config_bind(int i, const CC_bind &new_bind, selItem order, bool API
|
||||
Undo_stack stack;
|
||||
stack.save(Control_config[i].first);
|
||||
stack.save(Control_config[i].second);
|
||||
Undo_controls.save_stack(std::move(stack));
|
||||
Undo_controls.save_stack(stack);
|
||||
|
||||
CCB old(Control_config[i]);
|
||||
|
||||
@@ -770,7 +770,7 @@ bool control_config_remove_binding(int ctrl, selItem item, bool API_Access)
|
||||
|
||||
stack.save(Control_config[ctrl].first);
|
||||
stack.save(Control_config[ctrl].second);
|
||||
Undo_controls.save_stack(std::move(stack));
|
||||
Undo_controls.save_stack(stack);
|
||||
|
||||
Control_config[ctrl].first.clear();
|
||||
Control_config[ctrl].second.clear();
|
||||
@@ -804,7 +804,7 @@ bool control_config_remove_binding(int ctrl, selItem item, bool API_Access)
|
||||
|
||||
default:
|
||||
// Coder forgot to add a case!
|
||||
UNREACHABLE("Unhandled selItem case: %i", static_cast<int>(item));
|
||||
UNREACHABLE("Unhandled selItem case.");
|
||||
}
|
||||
|
||||
if (success)
|
||||
@@ -873,7 +873,7 @@ bool control_config_clear_other(int ctrl, bool API_Access)
|
||||
return false;
|
||||
}
|
||||
|
||||
Undo_controls.save_stack(std::move(stack));
|
||||
Undo_controls.save_stack(stack);
|
||||
control_config_conflict_check();
|
||||
|
||||
if (!API_Access) {
|
||||
@@ -911,7 +911,7 @@ bool control_config_clear_all(bool API_Access)
|
||||
return false;
|
||||
}
|
||||
|
||||
Undo_controls.save_stack(std::move(stack));
|
||||
Undo_controls.save_stack(stack);
|
||||
control_config_conflict_check();
|
||||
|
||||
if (!API_Access) {
|
||||
@@ -975,7 +975,7 @@ bool control_config_do_reset(bool cycle, bool API_Access)
|
||||
stack.save(item.first);
|
||||
stack.save(item.second);
|
||||
}
|
||||
Undo_controls.save_stack(std::move(stack));
|
||||
Undo_controls.save_stack(stack);
|
||||
|
||||
control_config_use_preset(Control_config_presets[Defaults_cycle_pos]);
|
||||
|
||||
@@ -1097,7 +1097,7 @@ bool control_config_toggle_modifier(int bit, int ctrl, bool API_Access)
|
||||
Undo_stack stack;
|
||||
stack.save(Control_config[ctrl].first);
|
||||
stack.save(Control_config[ctrl].second);
|
||||
Undo_controls.save_stack(std::move(stack));
|
||||
Undo_controls.save_stack(stack);
|
||||
|
||||
Control_config[ctrl].take(CC_bind(CID_KEYBOARD, static_cast<short>(k ^ bit)), -1);
|
||||
control_config_conflict_check();
|
||||
@@ -1322,7 +1322,7 @@ bool control_config_accept(bool API_Access)
|
||||
|
||||
// Check if a hardcoded preset with name already exists. If so, complain to user and force retry
|
||||
auto it = std::find_if(Control_config_presets.begin(), Control_config_presets.end(), [str](CC_preset& p) {
|
||||
return ((p.name == str) && ((p.get_type() == Preset_t::tbl) || (p.get_type() == Preset_t::hardcode)));
|
||||
return ((p.name == str) && ((p.type == Preset_t::tbl) || (p.type == Preset_t::hardcode)));
|
||||
});
|
||||
|
||||
if (it != Control_config_presets.end()) {
|
||||
@@ -1353,14 +1353,15 @@ bool control_config_accept(bool API_Access)
|
||||
}
|
||||
|
||||
// Pack the current bindings into a preset, then save the file
|
||||
CC_preset preset(std::move(str), Preset_t::pst);
|
||||
CC_preset preset;
|
||||
preset.name = std::move(str);
|
||||
std::copy(Control_config.begin(), Control_config.end(), std::back_inserter(preset.bindings));
|
||||
Control_config_presets.push_back(preset);
|
||||
save_preset_file(preset, true);
|
||||
|
||||
// Reload the presets from file. Do this instead of just pushing the preset to the vector direct to get
|
||||
// consistant ordering
|
||||
Control_config_presets.erase(Control_config_presets.begin() + 1, Control_config_presets.end());
|
||||
Control_config_presets.resize(1);
|
||||
load_preset_files();
|
||||
|
||||
// finally, save the new preset so that changes will get saved to this preset
|
||||
@@ -1777,7 +1778,7 @@ bool control_config_create_new_preset(const SCP_string& newName, bool overwrite)
|
||||
|
||||
// Check if a hardcoded preset with name already exists. If so, complain to user and force retry
|
||||
auto it = std::find_if(Control_config_presets.begin(), Control_config_presets.end(), [newName](CC_preset& p) {
|
||||
return (p.name == newName) && ((p.get_type() == Preset_t::tbl) || (p.get_type() == Preset_t::hardcode));
|
||||
return (p.name == newName) && ((p.type == Preset_t::tbl) || (p.type == Preset_t::hardcode));
|
||||
});
|
||||
|
||||
if (it != Control_config_presets.end()) {
|
||||
@@ -1790,7 +1791,9 @@ bool control_config_create_new_preset(const SCP_string& newName, bool overwrite)
|
||||
}
|
||||
|
||||
// Pack the current bindings into a preset, then save the file
|
||||
CC_preset preset(newName, Preset_t::pst);
|
||||
CC_preset preset;
|
||||
preset.name = newName;
|
||||
preset.type = Preset_t::pst;
|
||||
std::copy(Control_config.begin(), Control_config.end(), std::back_inserter(preset.bindings));
|
||||
|
||||
// Done with the file
|
||||
@@ -1802,7 +1805,7 @@ bool control_config_create_new_preset(const SCP_string& newName, bool overwrite)
|
||||
save_preset_file(preset, true);
|
||||
|
||||
// Reload the presets from file.
|
||||
Control_config_presets.erase(Control_config_presets.begin() + 1, Control_config_presets.end());
|
||||
Control_config_presets.resize(1);
|
||||
load_preset_files(newName);
|
||||
|
||||
// use the newly created preset
|
||||
@@ -1810,9 +1813,10 @@ bool control_config_create_new_preset(const SCP_string& newName, bool overwrite)
|
||||
|
||||
return true;
|
||||
|
||||
} else if ((clone->name != preset.name) || (clone->get_type() != Preset_t::pst)) {
|
||||
} else if ((clone->name != preset.name) || (clone->type != Preset_t::pst)) {
|
||||
// Complain and ignore if the preset names or the type differs
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return false; //should be unreachable, but just in case
|
||||
@@ -1822,7 +1826,7 @@ bool control_config_clone_preset(const CC_preset& preset, const SCP_string& newN
|
||||
|
||||
// Check if a hardcoded preset with name already exists. If so, complain to user and force retry
|
||||
auto it = std::find_if(Control_config_presets.begin(), Control_config_presets.end(), [newName](CC_preset& p) {
|
||||
return (p.name == newName) && ((p.get_type() == Preset_t::tbl) || (p.get_type() == Preset_t::hardcode));
|
||||
return (p.name == newName) && ((p.type == Preset_t::tbl) || (p.type == Preset_t::hardcode));
|
||||
});
|
||||
|
||||
if (it != Control_config_presets.end()) {
|
||||
@@ -1834,13 +1838,13 @@ bool control_config_clone_preset(const CC_preset& preset, const SCP_string& newN
|
||||
return false;
|
||||
}
|
||||
|
||||
CC_preset newPreset(newName, Preset_t::pst);
|
||||
newPreset.bindings = preset.bindings;
|
||||
CC_preset newPreset = preset;
|
||||
newPreset.name = newName;
|
||||
|
||||
bool success = save_preset_file(newPreset, false);
|
||||
|
||||
// Reload the presets from file.
|
||||
Control_config_presets.erase(Control_config_presets.begin() + 1, Control_config_presets.end());
|
||||
Control_config_presets.resize(1);
|
||||
load_preset_files(newName);
|
||||
|
||||
// use the newly cloned preset
|
||||
@@ -3116,7 +3120,7 @@ void control_get_axes_readings(int *axis_v, float frame_time)
|
||||
case CC_TYPE_AXIS_BTN_POS:
|
||||
default:
|
||||
//This should never happen, especially with the above Assertion. This is required as incomplete switches on an enum generate warnings
|
||||
UNREACHABLE("Unhandled control item type %d", static_cast<int>(item.type));
|
||||
UNREACHABLE("Unhandled control item type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,28 +572,20 @@ public:
|
||||
* A preset, a collection of bindings for use in Control_config with an associated name
|
||||
*/
|
||||
class CC_preset {
|
||||
public:
|
||||
public:
|
||||
SCP_vector<CCB> bindings;
|
||||
SCP_string name;
|
||||
Preset_t type = Preset_t::hardcode;
|
||||
|
||||
private:
|
||||
// No default value: the type is always set explicitly by the constructor
|
||||
Preset_t type;
|
||||
public:
|
||||
CC_preset() = default;
|
||||
CC_preset(const CC_preset& A) = default;
|
||||
|
||||
public:
|
||||
// No default constructor: every preset must be created with an explicit type
|
||||
CC_preset(SCP_string preset_name, Preset_t preset_type) : name(std::move(preset_name)), type(preset_type) {}
|
||||
CC_preset(const CC_preset&) = default;
|
||||
|
||||
// Preserve target's preset type during copy assignment
|
||||
CC_preset& operator=(const CC_preset& other);
|
||||
|
||||
Preset_t get_type() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
bool is_duplicate_of(const CC_preset& other) const;
|
||||
CC_preset& operator=(const CC_preset&);
|
||||
/*!
|
||||
* Checks if the given preset is a duplicate of this one
|
||||
*/
|
||||
bool is_duplicate_of(CC_preset&);
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
@@ -292,8 +292,10 @@ void control_config_common_init_bindings() {
|
||||
// init default preset
|
||||
Control_config_presets.clear();
|
||||
|
||||
CC_preset preset("default", Preset_t::hardcode);
|
||||
CC_preset preset;
|
||||
preset.bindings.reserve(Control_config.size());
|
||||
preset.name = "default";
|
||||
preset.type = Preset_t::hardcode;
|
||||
|
||||
for (auto &item : Control_config) {
|
||||
preset.bindings.push_back(CCB(item));
|
||||
@@ -680,7 +682,7 @@ const char *textify_scancode(int code)
|
||||
}
|
||||
|
||||
SCP_string name;
|
||||
unicode::convert_encoding(name, SDL_GetKeyName(SDL_GetKeyFromScancode(fs2_to_sdl(keycode), SDL_KMOD_NONE, false)), unicode::Encoding::Encoding_utf8);
|
||||
unicode::convert_encoding(name, SDL_GetKeyName(SDL_GetKeyFromScancode(fs2_to_sdl(keycode))), unicode::Encoding::Encoding_utf8);
|
||||
strcat_s(text, name.c_str());
|
||||
return text;
|
||||
}
|
||||
@@ -1731,13 +1733,14 @@ size_t read_bind_1(CC_preset &preset) {
|
||||
*/
|
||||
void control_config_common_read_section(int s, bool first_override) {
|
||||
Assertion((s == 0) || (s == 1), "Expected value of s to be either 0 or 1, found %i instead.", s);
|
||||
CC_preset new_preset("", Preset_t::tbl);
|
||||
CC_preset new_preset;
|
||||
|
||||
// Set references to the default preset and bindings
|
||||
auto& default_preset = Control_config_presets[0];
|
||||
auto& default_bindings = default_preset.bindings;
|
||||
|
||||
new_preset.bindings.clear();
|
||||
new_preset.type = Preset_t::tbl;
|
||||
|
||||
if (s == 0) {
|
||||
// #ControlConfigOverride
|
||||
@@ -2385,7 +2388,7 @@ SCP_string ValToCID(CID id) {
|
||||
|
||||
if (it == mCIDNameToVal.cend()) {
|
||||
// Shouldn't happen
|
||||
UNREACHABLE("Unknown CID value %i", id);
|
||||
Error(LOCATION, "Unknown CID value %i", id);
|
||||
return "NONE";
|
||||
|
||||
} else {
|
||||
@@ -2515,11 +2518,9 @@ SCP_string ValToJoy(const CC_bind &bind) {
|
||||
if (it == mAxisNameToVal.end()) {
|
||||
// should never happen
|
||||
UNREACHABLE("Unknown error occured during reverse lookup of joy input string.");
|
||||
str = "NONE";
|
||||
} else {
|
||||
// print out value
|
||||
str = it->first;
|
||||
}
|
||||
} // else print out value
|
||||
|
||||
str = it->first;
|
||||
|
||||
/* } else if (bind.flags & CCF_HAT) {
|
||||
// TODO Still currently encoded as buttons
|
||||
@@ -2608,51 +2609,25 @@ void CC_bind::invert_toggle() {
|
||||
flags ^= CCF_INVERTED;
|
||||
}
|
||||
|
||||
|
||||
static bool compare_btn(short cid, const CC_bind& A, char& A_flags, const CC_bind& B, char& B_flags)
|
||||
{
|
||||
auto A_btn = A.get_btn();
|
||||
auto B_btn = B.get_btn();
|
||||
|
||||
auto current = io::joystick::getPlayerJoystick(cid);
|
||||
|
||||
if (current && current->isGamepad()) {
|
||||
if (A_btn >= SDL_GAMEPAD_BUTTON_COUNT) {
|
||||
A_btn = (A_btn - SDL_GAMEPAD_BUTTON_COUNT) + SDL_GAMEPAD_AXIS_LEFT_TRIGGER;
|
||||
A_flags |= CCF_AXIS_BTN;
|
||||
}
|
||||
|
||||
if (B_btn >= SDL_GAMEPAD_BUTTON_COUNT) {
|
||||
B_btn = (B_btn - SDL_GAMEPAD_BUTTON_COUNT) + SDL_GAMEPAD_AXIS_LEFT_TRIGGER;
|
||||
B_flags |= CCF_AXIS_BTN;
|
||||
}
|
||||
}
|
||||
|
||||
return (A_btn == B_btn);
|
||||
}
|
||||
|
||||
bool CC_bind::conflicts_with(const CC_bind& B) const {
|
||||
char A_flags = flags;
|
||||
char B_flags = B.flags;
|
||||
|
||||
// Bail early if CID or btn are not the same
|
||||
if ((cid != B.cid) || !compare_btn(cid, *this, A_flags, B, B_flags)) {
|
||||
if ((cid != B.cid) || (btn != B.btn)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if A is an Axis or Axis Button, and if B is an Axis or Axis Button
|
||||
char mask = (CCF_AXIS_BTN | CCF_AXIS);
|
||||
if ((A_flags & mask) && (B_flags & mask)) {
|
||||
if ((flags & mask) && (B.flags & mask)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if Hat
|
||||
if (A_flags & B_flags & CCF_HAT) {
|
||||
if (flags & B.flags & CCF_HAT) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if Ball
|
||||
if (A_flags & B_flags & CCF_BALL) {
|
||||
if (flags & B.flags & CCF_BALL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2664,7 +2639,7 @@ bool CC_bind::conflicts_with(const CC_bind& B) const {
|
||||
// First off, check if A or B is NOT a button, as according to the mask. Buttons do not have a flag, so we check
|
||||
// if they are any of the other input types
|
||||
// Next, we return the inverse of the result. Negative of a Negative = Positive. Not Not a button = Is a button
|
||||
return !((A_flags | B_flags) & mask);
|
||||
return !((flags | B.flags) & mask);
|
||||
}
|
||||
|
||||
bool CC_bind::is_inverted() const {
|
||||
@@ -2755,19 +2730,10 @@ SCP_string CC_bind::textify() const {
|
||||
case CID_JOY0:
|
||||
case CID_JOY1:
|
||||
case CID_JOY2:
|
||||
case CID_JOY3: {
|
||||
auto axis = joy_get_button_axis(cid, btn);
|
||||
|
||||
if (axis < 0) {
|
||||
Assert((btn >= 0) && (btn < JOY_TOTAL_BUTTONS));
|
||||
retval = SCP_string(textify_button(btn));
|
||||
} else {
|
||||
Assert((axis >= 0) && (axis < NUM_AXIS_TEXT));
|
||||
retval = SCP_string(Axis_text[axis]);
|
||||
}
|
||||
|
||||
case CID_JOY3:
|
||||
Assert((btn >= 0) && (btn < JOY_TOTAL_BUTTONS));
|
||||
retval = SCP_string(textify_button(btn));
|
||||
break;
|
||||
}
|
||||
|
||||
case CID_NONE:
|
||||
default:
|
||||
@@ -2999,22 +2965,23 @@ CCI_builder& CCI_builder::operator()(IoActionId action_id, short primary, short
|
||||
return *this;
|
||||
}
|
||||
|
||||
CC_preset& CC_preset::operator=(const CC_preset& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
bindings = other.bindings;
|
||||
name = other.name;
|
||||
// 'type' is intentionally preserved to maintain instance identity
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
CC_preset& CC_preset::operator=(const CC_preset& A) {
|
||||
name = A.name;
|
||||
type = A.type;
|
||||
|
||||
bool CC_preset::is_duplicate_of(const CC_preset& other) const
|
||||
{
|
||||
for (size_t i = 0; i < other.bindings.size(); ++i) {
|
||||
if (bindings[i] != other.bindings[i]) {
|
||||
std::copy(A.bindings.begin(), A.bindings.end(), bindings.begin());
|
||||
|
||||
return *this;
|
||||
};
|
||||
|
||||
bool CC_preset::is_duplicate_of(CC_preset& A) {
|
||||
for (size_t i = 0; i < A.bindings.size(); ++i) {
|
||||
if (bindings[i] != A.bindings[i]) {
|
||||
// Found a binding that's different. Thus, this preset is not a duplicate
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Else, did not find any differences in the bindings. Thus, this preset is a duplicate
|
||||
return true;
|
||||
}
|
||||
@@ -74,7 +74,9 @@ void load_preset_files(SCP_string clone) {
|
||||
|
||||
|
||||
// Start reading in data
|
||||
CC_preset preset(file, Preset_t::pst);
|
||||
CC_preset preset;
|
||||
preset.name = file;
|
||||
preset.type = Preset_t::pst;
|
||||
preset.bindings.resize(Control_config.size());
|
||||
|
||||
size_t size;
|
||||
@@ -132,7 +134,7 @@ void load_preset_files(SCP_string clone) {
|
||||
if ((clone == preset.name) || (it == Control_config_presets.end())) {
|
||||
Control_config_presets.push_back(preset);
|
||||
|
||||
} else if ((it->name != preset.name) || ((it->get_type() != Preset_t::pst))) {
|
||||
} else if ((it->name != preset.name) || (it->type != Preset_t::pst)) {
|
||||
if (gameseq_get_state() == GS_STATE_CONTROL_CONFIG) {
|
||||
popup(PF_TITLE_WHITE | PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, "Preset '%s' is a duplicate of an existing preset, ignoring", preset.name.c_str());
|
||||
} else {
|
||||
@@ -171,7 +173,7 @@ bool delete_preset_file(CC_preset preset) {
|
||||
cf_delete(filename.c_str(), CF_TYPE_PLAYER_BINDS, CF_LOCATION_ROOT_USER | CF_LOCATION_ROOT_GAME | CF_LOCATION_TYPE_ROOT);
|
||||
|
||||
// Reload the presets from file.
|
||||
Control_config_presets.erase(Control_config_presets.begin() + 1, Control_config_presets.end());
|
||||
Control_config_presets.resize(1);
|
||||
load_preset_files();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -49,7 +49,7 @@ VideoPresenter::VideoPresenter(const MovieProperties& props) : _properties(props
|
||||
material_set_unlit(&_rgb_material, _planeTextureHandles[0], 1.0f, true, false);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE("Unhandled enum value %d!", static_cast<int>(props.pixelFormat));
|
||||
UNREACHABLE("Unhandled enum value!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ void VideoPresenter::uploadVideoFrame(const VideoFramePtr& frame) {
|
||||
bpp = 32;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE("Unhandled enum value %d!", static_cast<int>(_properties.pixelFormat));
|
||||
UNREACHABLE("Unhandled enum value!");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ void VideoPresenter::displayFrame(float x1, float y1, float x2, float y2, float
|
||||
gr_render_primitives(&_rgb_material, PRIM_TYPE_TRISTRIP, &layout, 0, 4, gr_immediate_buffer_handle, offset);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE("Unhandled enum value %d!", static_cast<int>(_properties.pixelFormat));
|
||||
UNREACHABLE("Unhandled enum value!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,8 +537,7 @@ void cutscenes_screen_init()
|
||||
int u = 0;
|
||||
for (auto cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut, ++u)
|
||||
{
|
||||
if ((cut->flags.any_of(Cutscene::Cutscene_Flags::Viewable,Cutscene::Cutscene_Flags::Always_viewable)) &&
|
||||
!cut->flags[Cutscene::Cutscene_Flags::Never_viewable])
|
||||
if (cut->flags[Cutscene::Cutscene_Flags::Viewable, Cutscene::Cutscene_Flags::Always_viewable] && !cut->flags[Cutscene::Cutscene_Flags::Never_viewable])
|
||||
{
|
||||
Cutscene_list.push_back(u);
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "globalincs/pstypes.h"
|
||||
#include "freespace.h"
|
||||
#include "globalincs/pstypes.h"
|
||||
#include "globalincs/alphacolors.h"
|
||||
#include "globalincs/systemvars.h"
|
||||
#include "io/cursor.h"
|
||||
@@ -208,7 +208,7 @@ void movie_display_loop(Player* player, PlaybackState* state) {
|
||||
auto sleepTime = static_cast<std::uint64_t>((1. / (4. * player->getMovieProperties().fps)) * 1000.);
|
||||
|
||||
auto listener = [state](const SDL_Event& event) {
|
||||
switch (event.key.key) {
|
||||
switch (event.key.keysym.sym) {
|
||||
case SDLK_ESCAPE:
|
||||
case SDLK_KP_ENTER:
|
||||
case SDLK_RETURN:
|
||||
@@ -220,7 +220,7 @@ void movie_display_loop(Player* player, PlaybackState* state) {
|
||||
}
|
||||
};
|
||||
// Use a dedicated listener here since we want to listen for the KEYUP event
|
||||
auto key_handle = os::events::addEventListener(SDL_EVENT_KEY_UP, os::events::DEFAULT_LISTENER_WEIGHT - 10, listener);
|
||||
auto key_handle = os::events::addEventListener(SDL_KEYUP, os::events::DEFAULT_LISTENER_WEIGHT - 10, listener);
|
||||
|
||||
// slight hack to make sure that game_set_frametime() doesn't also try to cap the framerate
|
||||
auto fpsCapSave = Cmdline_NoFPSCap;
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "cutscene/VideoPresenter.h"
|
||||
#include "cutscene/ffmpeg/FFMPEGDecoder.h"
|
||||
|
||||
#include "cmdline/cmdline.h"
|
||||
|
||||
#include "graphics/2d.h"
|
||||
|
||||
#include "globalincs/alphacolors.h"
|
||||
@@ -54,7 +52,7 @@ void videoPlaybackInit(PlayerState* state) {
|
||||
|
||||
Assert(state != NULL);
|
||||
|
||||
if (gr_screen.mode != GraphicsAPI::Stub) {
|
||||
if (gr_screen.mode != GR_STUB) {
|
||||
// The video presenter is independent of the underlying graphics API
|
||||
state->videoPresenter.reset(new VideoPresenter(state->props));
|
||||
}
|
||||
|
||||
+10
-114
@@ -1,12 +1,18 @@
|
||||
|
||||
#include "ddsutils/ddsutils.h"
|
||||
#include "cfile/cfile.h"
|
||||
#include "graphics/2d.h"
|
||||
#include "osapi/osregistry.h"
|
||||
#ifdef USE_OPENGL_ES
|
||||
#include "graphics/opengl/es_compatibility.h"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_OPENGL
|
||||
#include <glad/glad.h>
|
||||
#else
|
||||
static constexpr int GLAD_GL_EXT_texture_compression_s3tc = 0;
|
||||
static constexpr int GLAD_GL_ARB_texture_compression_bptc = 0;
|
||||
#endif
|
||||
|
||||
#define BCDEC_IMPLEMENTATION 1
|
||||
PUSH_SUPPRESS_WARNINGS
|
||||
#include "ddsutils/bcdec.h"
|
||||
@@ -54,11 +60,11 @@ static bool conversion_needed(const DDS_HEADER &dds_header)
|
||||
case FOURCC_DXT1:
|
||||
case FOURCC_DXT3:
|
||||
case FOURCC_DXT5:
|
||||
return !gr_is_capable(gr_capability::CAPABILITY_S3TC);
|
||||
return !GLAD_GL_EXT_texture_compression_s3tc;
|
||||
|
||||
case FOURCC_DX10:
|
||||
// anything other than BC7 will end up invalid
|
||||
return !gr_is_capable(gr_capability::CAPABILITY_BPTC);
|
||||
return !GLAD_GL_ARB_texture_compression_bptc;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -220,7 +226,7 @@ static size_t compute_dds_size(const DDS_HEADER &dds_header, bool converting = f
|
||||
|
||||
if (dds_header.ddspf.dwFlags & DDPF_FOURCC) {
|
||||
// size of data block (4x4)
|
||||
d_size += dds_compressed_mip_size(d_width, d_height, (dds_header.ddspf.dwFourCC == FOURCC_DXT1) ? 8 : 16) * d_depth;
|
||||
d_size += ((d_width + 3) / 4) * ((d_height + 3) / 4) * d_depth * ((dds_header.ddspf.dwFourCC == FOURCC_DXT1) ? 8 : 16);
|
||||
} else {
|
||||
d_size += d_width * d_height * d_depth * (dds_header.ddspf.dwRGBBitCount / 8);
|
||||
}
|
||||
@@ -546,116 +552,6 @@ int dds_read_bitmap(const char *filename, ubyte *data, ubyte *bpp, int cf_type)
|
||||
return DDS_ERROR_NONE;
|
||||
}
|
||||
|
||||
int dds_decompress_top_mip_bgra(const char *filename, int cf_type,
|
||||
int *out_width, int *out_height,
|
||||
SCP_vector<ubyte> &out_pixels)
|
||||
{
|
||||
Assert(filename != nullptr);
|
||||
|
||||
// normalize to a .dds extension, same as dds_read_bitmap
|
||||
char real_name[MAX_FILENAME_LEN];
|
||||
strcpy_s(real_name, filename);
|
||||
char *p = strchr(real_name, '.');
|
||||
if (p) { *p = 0; }
|
||||
strcat_s(real_name, ".dds");
|
||||
|
||||
CFILE *cfp = cfopen(real_name, "rb", cf_type);
|
||||
if (cfp == nullptr)
|
||||
return DDS_ERROR_INVALID_FILENAME;
|
||||
|
||||
DDS_HEADER dds_header;
|
||||
DDS_HEADER_DXT10 dx10_header;
|
||||
int retval = _dds_read_header(cfp, dds_header, &dx10_header);
|
||||
if (retval != DDS_ERROR_NONE) {
|
||||
cfclose(cfp);
|
||||
return retval;
|
||||
}
|
||||
|
||||
// only 2D FOURCC-compressed images are supported here
|
||||
if (!(dds_header.ddspf.dwFlags & DDPF_FOURCC) ||
|
||||
(dds_header.dwCaps2 & (DDSCAPS2_CUBEMAP | DDSCAPS2_VOLUME)) ||
|
||||
(dds_header.dwFlags & DDSD_DEPTH) ||
|
||||
(dds_header.dwDepth > 1)) {
|
||||
cfclose(cfp);
|
||||
return DDS_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
void (*decode)(const void *, void *, int) = nullptr;
|
||||
int block_size = 0;
|
||||
switch (dds_header.ddspf.dwFourCC) {
|
||||
case FOURCC_DXT1: decode = bcdec_bc1; block_size = BCDEC_BC1_BLOCK_SIZE; break;
|
||||
case FOURCC_DXT3: decode = bcdec_bc2; block_size = BCDEC_BC2_BLOCK_SIZE; break;
|
||||
case FOURCC_DXT5: decode = bcdec_bc3; block_size = BCDEC_BC3_BLOCK_SIZE; break;
|
||||
case FOURCC_DX10:
|
||||
if (!valid_dx10_format(dx10_header) ||
|
||||
dx10_header.resourceDimension != D3D10_RESOURCE_DIMENSION::D3D10_RESOURCE_DIMENSION_TEXTURE2D ||
|
||||
dx10_header.arraySize > 1) {
|
||||
cfclose(cfp);
|
||||
return DDS_ERROR_UNSUPPORTED;
|
||||
}
|
||||
decode = bcdec_bc7;
|
||||
block_size = BCDEC_BC7_BLOCK_SIZE;
|
||||
break;
|
||||
default:
|
||||
cfclose(cfp);
|
||||
return DDS_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
const int w = static_cast<int>(dds_header.dwWidth);
|
||||
const int h = static_cast<int>(dds_header.dwHeight);
|
||||
if (w <= 0 || h <= 0) {
|
||||
cfclose(cfp);
|
||||
return DDS_ERROR_INVALID_FORMAT;
|
||||
}
|
||||
|
||||
// BCn data is stored as ceil(w/4) * ceil(h/4) 4x4 blocks; dimensions
|
||||
// don't have to be multiples of 4.
|
||||
const int blocks_w = (w + 3) / 4;
|
||||
const int blocks_h = (h + 3) / 4;
|
||||
const int padded_w = blocks_w * 4;
|
||||
const int padded_h = blocks_h * 4;
|
||||
const size_t compressed_size = static_cast<size_t>(blocks_w) * blocks_h * block_size;
|
||||
|
||||
// _dds_read_header leaves the file positioned right after the header
|
||||
// (including the DX10 sub-header if present), so the next read is the
|
||||
// top mip's pixel data.
|
||||
SCP_vector<ubyte> compressed(compressed_size);
|
||||
const int got = cfread(compressed.data(), 1, static_cast<int>(compressed_size), cfp);
|
||||
cfclose(cfp);
|
||||
if (got != static_cast<int>(compressed_size))
|
||||
return DDS_ERROR_INVALID_FORMAT;
|
||||
|
||||
// Decode into a padded buffer so edge blocks have room, then crop to w*h.
|
||||
SCP_vector<ubyte> decoded(static_cast<size_t>(padded_w) * padded_h * 4);
|
||||
const int dec_stride = padded_w * 4;
|
||||
const ubyte *src = compressed.data();
|
||||
|
||||
for (int by = 0; by < blocks_h; ++by) {
|
||||
for (int bx = 0; bx < blocks_w; ++bx) {
|
||||
ubyte *blk_dst = decoded.data() + (by * 4) * dec_stride + (bx * 4) * 4;
|
||||
decode(src, blk_dst, dec_stride);
|
||||
src += block_size;
|
||||
}
|
||||
}
|
||||
|
||||
out_pixels.assign(static_cast<size_t>(w) * h * 4, 0);
|
||||
const int dst_stride = w * 4;
|
||||
for (int y = 0; y < h; ++y) {
|
||||
std::memcpy(out_pixels.data() + static_cast<size_t>(y) * dst_stride,
|
||||
decoded.data() + static_cast<size_t>(y) * dec_stride,
|
||||
static_cast<size_t>(dst_stride));
|
||||
}
|
||||
|
||||
// bcdec outputs RGBA byte-order; swap to BGRA
|
||||
for (size_t x = 0; x < out_pixels.size(); x += 4) {
|
||||
std::swap(out_pixels[x], out_pixels[x + 2]);
|
||||
}
|
||||
|
||||
if (out_width) *out_width = w;
|
||||
if (out_height) *out_height = h;
|
||||
return DDS_ERROR_NONE;
|
||||
}
|
||||
|
||||
// save some image data as a DDS image
|
||||
// NOTE: we only support, uncompressed, 24-bit RGB and 32-bit RGBA images here!!
|
||||
void dds_save_image(int width, int height, int bpp, int num_mipmaps, ubyte *data, int cubemap, const char *filename)
|
||||
|
||||
@@ -273,27 +273,6 @@ typedef struct {
|
||||
} DDS_HEADER_DXT10;
|
||||
#pragma pack()
|
||||
|
||||
// Block size in bytes for a 4x4 texel block of a compressed DDS format.
|
||||
// comp_type is one of the DDS_DXT*/DDS_CUBEMAP_DXT* constants.
|
||||
inline int dds_block_size(int comp_type) {
|
||||
switch (comp_type) {
|
||||
case DDS_DXT1:
|
||||
case DDS_CUBEMAP_DXT1:
|
||||
return 8;
|
||||
case DDS_DXT3: case DDS_CUBEMAP_DXT3:
|
||||
case DDS_DXT5: case DDS_CUBEMAP_DXT5:
|
||||
case DDS_BC7:
|
||||
return 16;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Size in bytes of one mip level of a block-compressed texture.
|
||||
inline size_t dds_compressed_mip_size(int w, int h, int block_size) {
|
||||
return static_cast<size_t>(((w + 3) / 4) * ((h + 3) / 4) * block_size);
|
||||
}
|
||||
|
||||
#define DDS_OFFSET 4+sizeof(DDS_HEADER) //place where the data starts -- should be 128
|
||||
#define DX10_OFFSET DDS_OFFSET+sizeof(DDS_HEADER_DXT10) // Unless a DX10 header is present
|
||||
|
||||
@@ -306,15 +285,6 @@ int dds_read_header(const char *filename, CFILE *img_cfp = NULL, int *width = 0,
|
||||
//size of the data it stored in size
|
||||
int dds_read_bitmap(const char *filename, ubyte *data, ubyte *bpp = NULL, int cf_type = CF_TYPE_ANY);
|
||||
|
||||
// Decompress just the top mip of a 2D FOURCC-compressed DDS (DXT1/3/5, BC7)
|
||||
// to 32-bpp BGRA, regardless of what the renderer's compression support is.
|
||||
// Intended for tool/preview code that needs raw pixels and doesn't care
|
||||
// about mipmaps or cubemap faces. On success, out_pixels is sized to
|
||||
// width*height*4 in BGRA byte order.
|
||||
int dds_decompress_top_mip_bgra(const char *filename, int cf_type,
|
||||
int *out_width, int *out_height,
|
||||
SCP_vector<ubyte> &out_pixels);
|
||||
|
||||
// writes a DDS file using given data
|
||||
void dds_save_image(int width, int height, int bpp, int num_mipmaps, ubyte *data = NULL, int cubemap = 0, const char *filename = NULL);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ int Debris_num_submodels = 0;
|
||||
|
||||
particle::ParticleEffectHandle Debris_hit_particle;
|
||||
|
||||
#define DEBRIS_INDEX(dp) (static_cast<int>((dp)-Debris.data()))
|
||||
#define DEBRIS_INDEX(dp) (int)(dp-Debris.data())
|
||||
|
||||
// Find the first available arc slot. If none is available, and no_create is false, add one.
|
||||
debris_electrical_arc *debris_find_or_create_electrical_arc_slot(debris *db, bool no_create);
|
||||
@@ -337,7 +337,7 @@ void debris_process_post(object * obj, float frame_time)
|
||||
break;
|
||||
|
||||
default:
|
||||
Assertion(false, "Unhandled case %d for electrical arc creation in debris_process_post()!", n);
|
||||
UNREACHABLE("Unhandled case %d for electrical arc creation in debris_process_post()!", n);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1152,9 +1152,9 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
|
||||
// everything above was calculated relative to the heavy's position
|
||||
vec3d actual_world_hit_pos = mc.hit_point_world + heavy_obj->pos;
|
||||
if ((shipp->is_arriving()) && (shipp->warpin_effect != nullptr))
|
||||
warp_effect = shipp->warpin_effect.get();
|
||||
warp_effect = shipp->warpin_effect;
|
||||
else if ((shipp->flags[Ship::Ship_Flags::Depart_warp]) && (shipp->warpout_effect != nullptr))
|
||||
warp_effect = shipp->warpout_effect.get();
|
||||
warp_effect = shipp->warpout_effect;
|
||||
|
||||
if (warp_effect != nullptr && point_is_clipped_by_warp(&actual_world_hit_pos, warp_effect))
|
||||
mc_ret_val = 0;
|
||||
|
||||
@@ -489,15 +489,13 @@ void dc_putc(char c)
|
||||
}
|
||||
|
||||
bool handle_textInputEvent(const SDL_Event& event) {
|
||||
const char *p = event.text.text;
|
||||
|
||||
if (*p != '\0' && *p != '\1') {
|
||||
for (; *p; ++p) {
|
||||
if (*p < 32)
|
||||
if (event.text.text[0] != '\0' && event.text.text[0] != '\1') {
|
||||
for (char c : event.text.text) {
|
||||
if (c < 32)
|
||||
break;
|
||||
|
||||
if (dc_command_buf.size() < MAX_CLI_LEN) {
|
||||
dc_command_buf.push_back(*p);
|
||||
dc_command_buf.push_back(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -517,8 +515,8 @@ void debug_console(void (*_func)(void))
|
||||
dc_init();
|
||||
}
|
||||
|
||||
auto textListener = os::events::addEventListener(SDL_EVENT_TEXT_INPUT, 10000, &handle_textInputEvent);
|
||||
SDL_StartTextInput(os::getSDLMainWindow());
|
||||
auto textListener = os::events::addEventListener(SDL_TEXTINPUT, 10000, &handle_textInputEvent);
|
||||
SDL_StartTextInput();
|
||||
|
||||
dc_draw(TRUE);
|
||||
|
||||
@@ -620,7 +618,7 @@ void debug_console(void (*_func)(void))
|
||||
dc_draw(TRUE);
|
||||
}
|
||||
|
||||
SDL_StopTextInput(os::getSDLMainWindow());
|
||||
SDL_StopTextInput();
|
||||
os::events::removeEventListener(textListener);
|
||||
|
||||
while( key_inkey() ) {
|
||||
|
||||
+4
-26
@@ -228,7 +228,7 @@ bool Decal::isValid() const {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
UNREACHABLE("Only ships are currently supported for decals!");
|
||||
Assertion(false, "Only ships are currently supported for decals!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ float smoothstep(float edge0, float edge1, float x) {
|
||||
namespace decals {
|
||||
|
||||
void initialize() {
|
||||
if (gr_screen.mode == GraphicsAPI::Stub) {
|
||||
if (gr_screen.mode == GR_STUB) {
|
||||
Decal_system_active = false;
|
||||
return;
|
||||
}
|
||||
@@ -361,10 +361,6 @@ void pageInDecal(const creation_info& info) {
|
||||
DecalDefinitions[info.definition_handle].pageIn();
|
||||
}
|
||||
|
||||
bool decalSystemActive() {
|
||||
return Decal_system_active && Decal_option_active && gr_is_capable(gr_capability::CAPABILITY_INSTANCED_RENDERING);
|
||||
}
|
||||
|
||||
void initializeMission() {
|
||||
active_decals.clear();
|
||||
}
|
||||
@@ -463,7 +459,7 @@ inline static void renderDecal(graphics::decal_draw_list& draw_list, const Decal
|
||||
}
|
||||
|
||||
void renderAll() {
|
||||
if (!decalSystemActive()) {
|
||||
if (!Decal_system_active || !Decal_option_active || !gr_is_capable(gr_capability::CAPABILITY_INSTANCED_RENDERING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -486,24 +482,6 @@ void renderAll() {
|
||||
++iter;
|
||||
}
|
||||
|
||||
for (auto iter = active_single_frame_decals.begin(); iter != active_single_frame_decals.end();) {
|
||||
if (!iter->isValid()) {
|
||||
// if we're sitting on the very last element, popping-back will invalidate the iterator!
|
||||
if (iter + 1 == active_single_frame_decals.end()) {
|
||||
active_single_frame_decals.pop_back();
|
||||
break;
|
||||
}
|
||||
|
||||
*iter = active_single_frame_decals.back();
|
||||
active_single_frame_decals.pop_back();
|
||||
continue;
|
||||
}
|
||||
|
||||
// next decal, only increment the iterator if we found a valid value so nothing gets skipped
|
||||
// otherwise we may skip a decal which can then get through to the draw_list loop while being invalid
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (active_decals.empty() && active_single_frame_decals.empty()) {
|
||||
return;
|
||||
}
|
||||
@@ -564,7 +542,7 @@ void addDecal(creation_info& info, const object* host, int submodel, const vec3d
|
||||
}
|
||||
|
||||
void addSingleFrameDecal(Decal&& info) {
|
||||
active_single_frame_decals.push_back(std::move(info));
|
||||
active_single_frame_decals.push_back(info);
|
||||
}
|
||||
|
||||
void invalidateForShip(const ship* shipp) {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "object/object.h"
|
||||
|
||||
#include "utils/RandomRange.h"
|
||||
#include "utils/reset_on_move.h"
|
||||
|
||||
namespace decals {
|
||||
|
||||
@@ -21,12 +20,9 @@ class DecalDefinition {
|
||||
SCP_string _normalMapFilename;
|
||||
bool _loopNormal = true;
|
||||
|
||||
// reset_on_move so that the defaulted move operations below transfer the
|
||||
// handles; the destructor bm_release()s them, so a moved-from element must
|
||||
// not keep aliasing live handles
|
||||
util::reset_on_move<int, -1> _diffuseBitmap;
|
||||
util::reset_on_move<int, -1> _glowBitmap;
|
||||
util::reset_on_move<int, -1> _normalBitmap;
|
||||
int _diffuseBitmap = -1;
|
||||
int _glowBitmap = -1;
|
||||
int _normalBitmap = -1;
|
||||
|
||||
public:
|
||||
explicit DecalDefinition(SCP_string name);
|
||||
@@ -133,8 +129,6 @@ void loadBitmaps(const creation_info& info);
|
||||
*/
|
||||
void pageInDecal(const creation_info& info);
|
||||
|
||||
bool decalSystemActive();
|
||||
|
||||
/**
|
||||
* @brief Shut down the decal system. Must be called from game_shutdown
|
||||
*/
|
||||
|
||||
@@ -1,33 +1,17 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp sampler2DArray;
|
||||
#endif
|
||||
|
||||
#include "gamma.sdr"
|
||||
|
||||
layout(location=0) out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
layout (location = 0) in vec4 fragTexCoord;
|
||||
layout (location = 1) in vec4 fragColor;
|
||||
|
||||
layout (set = 1, binding = 1) uniform sampler2DArray baseMap;
|
||||
|
||||
layout (set = 2, binding = 0, std140) uniform genericData {
|
||||
vec4 color;
|
||||
float intensity;
|
||||
};
|
||||
#else
|
||||
in vec4 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
out vec4 fragOut0;
|
||||
|
||||
uniform sampler2DArray baseMap;
|
||||
|
||||
layout (std140) uniform genericData {
|
||||
vec4 color;
|
||||
float intensity;
|
||||
};
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -1,25 +1,3 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout (location = 0) in vec4 vertPosition;
|
||||
layout (location = 1) in vec4 vertColor;
|
||||
layout (location = 2) in vec4 vertTexCoord;
|
||||
|
||||
layout (location = 0) out vec4 fragTexCoord;
|
||||
layout (location = 1) out vec4 fragColor;
|
||||
|
||||
layout (set = 2, binding = 1, std140) uniform matrixData {
|
||||
mat4 modelViewMatrix;
|
||||
mat4 projMatrix;
|
||||
};
|
||||
|
||||
layout (set = 2, binding = 0, std140) uniform genericData {
|
||||
vec4 color;
|
||||
float intensity;
|
||||
};
|
||||
#else
|
||||
in vec4 vertPosition;
|
||||
in vec4 vertTexCoord;
|
||||
in vec4 vertColor;
|
||||
@@ -36,7 +14,6 @@ layout (std140) uniform genericData {
|
||||
vec4 color;
|
||||
float intensity;
|
||||
};
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -1,25 +1,11 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp sampler2D;
|
||||
#endif
|
||||
|
||||
layout(location=0) out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(location = 0) in vec2 fragTexCoord;
|
||||
layout(set = 1, binding = 1) uniform sampler2D bloomed;
|
||||
#else
|
||||
in vec4 fragTexCoord;
|
||||
|
||||
uniform sampler2D bloomed;
|
||||
#endif
|
||||
out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(std140, set = 2, binding = 0)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform genericData {
|
||||
uniform sampler2D bloomed;
|
||||
|
||||
layout (std140) uniform genericData {
|
||||
float bloom_intensity;
|
||||
int levels;
|
||||
};
|
||||
|
||||
@@ -1,32 +1,16 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
precision highp sampler2D;
|
||||
#endif
|
||||
out vec4 fragOut0;
|
||||
|
||||
layout(location = 0) out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(location = 0) in vec2 fragTexCoord;
|
||||
layout(set = 1, binding = 1) uniform sampler2D tex;
|
||||
#else
|
||||
in vec4 fragTexCoord;
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 2, binding = 0, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform genericData {
|
||||
float texSize;
|
||||
int level;
|
||||
int pad[2];
|
||||
};
|
||||
uniform sampler2D tex;
|
||||
|
||||
const float TapSize = 1.0;
|
||||
|
||||
layout (std140) uniform genericData {
|
||||
float texSize;
|
||||
int level;
|
||||
};
|
||||
|
||||
// Gaussian Blur
|
||||
// 2 passes required
|
||||
void main()
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp sampler2D;
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(location = 0) in vec2 fragTexCoord;
|
||||
layout(set = 1, binding = 1) uniform sampler2D tex;
|
||||
#else
|
||||
in vec4 fragTexCoord;
|
||||
out vec4 fragOut0;
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
const float Luminance = 0.08;
|
||||
const float fMiddleGray = 0.2;
|
||||
const float fWhiteCutoff = 0.4;
|
||||
|
||||
@@ -1,35 +1,17 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp sampler2D;
|
||||
precision highp sampler2DArray;
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(location = 0) in vec2 fragTexCoord;
|
||||
layout(set = 1, binding = 1) uniform sampler2D tex;
|
||||
#else
|
||||
in vec4 fragTexCoord;
|
||||
out vec4 fragOut0;
|
||||
|
||||
#ifdef COPY_ARRAY
|
||||
uniform sampler2DArray tex;
|
||||
#else
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#if defined(COPY_ARRAY) && !defined(VULKAN)
|
||||
#ifdef COPY_ARRAY
|
||||
fragOut0 = texture(tex, vec3(fragTexCoord.xy, 0));
|
||||
#else
|
||||
fragOut0 = texture(tex, fragTexCoord.xy);
|
||||
#endif
|
||||
|
||||
#ifdef CLAMP01
|
||||
// Used to derive a [0,1]-bounded proxy from an extended-range HDR source,
|
||||
// e.g. for FXAA/SMAA edge detection when the real output carries values
|
||||
// above 1.0.
|
||||
fragOut0 = min(fragOut0, vec4(1.0));
|
||||
#endif
|
||||
}
|
||||
@@ -1,9 +1,3 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
precision highp sampler2D;
|
||||
precision highp sampler2DArray;
|
||||
#endif
|
||||
|
||||
// NOTE: The technique and some of this code is based on this tutorial:
|
||||
// http://martindevans.me/game-development/2015/02/27/Drawing-Stuff-On-Other-Stuff-With-Deferred-Screenspace-Decals/
|
||||
@@ -12,37 +6,9 @@ precision highp sampler2DArray;
|
||||
#include "normals.sdr"
|
||||
#include "gamma.sdr"
|
||||
|
||||
#ifdef VULKAN
|
||||
// G-buffer: 6 attachments, 1/3/5 are write-masked by pipeline blend state
|
||||
layout (location = 0) out vec4 fragOut0; // Color/Diffuse
|
||||
layout (location = 1) out vec4 fragOut1; // Position (masked)
|
||||
layout (location = 2) out vec4 fragOut2; // Normal
|
||||
layout (location = 3) out vec4 fragOut3; // Specular (masked)
|
||||
layout (location = 4) out vec4 fragOut4; // Emissive
|
||||
layout (location = 5) out vec4 fragOut5; // Composite (masked)
|
||||
|
||||
layout (location = 0) flat in mat4 invModelMatrix; // locations 0-3
|
||||
layout (location = 4) flat in vec3 decalDirection;
|
||||
layout (location = 5) flat in float normal_angle_cutoff;
|
||||
layout (location = 6) flat in float angle_fade_start;
|
||||
layout (location = 7) flat in float alpha_scale;
|
||||
|
||||
layout (set = 1, binding = 1) uniform sampler2DArray decalTextures;
|
||||
#define diffuseMap decalTextures
|
||||
#define glowMap decalTextures
|
||||
#define normalMap decalTextures
|
||||
|
||||
layout (set = 1, binding = 4) uniform sampler2D gDepthBuffer;
|
||||
layout (set = 1, binding = 6) uniform sampler2D gNormalBuffer;
|
||||
#else
|
||||
layout (location=0) out vec4 fragOut0; // Diffuse buffer
|
||||
#ifndef GL_ES
|
||||
layout (location=1) out vec4 fragOut1; // Normal buffer
|
||||
layout (location=2) out vec4 fragOut2; // Emissive buffer
|
||||
#else
|
||||
layout (location=2) out vec4 fragOut1; // Normal buffer -> COLOR_ATTACHMENT2
|
||||
layout (location=4) out vec4 fragOut2; // Emissive buffer -> COLOR_ATTACHMENT4
|
||||
#endif
|
||||
out vec4 fragOut0; // Diffuse buffer
|
||||
out vec4 fragOut1; // Normal buffer
|
||||
out vec4 fragOut2; // Emissive buffer
|
||||
|
||||
flat in mat4 invModelMatrix;
|
||||
flat in vec3 decalDirection;
|
||||
@@ -56,14 +22,8 @@ uniform sampler2D gNormalBuffer;
|
||||
uniform sampler2DArray diffuseMap;
|
||||
uniform sampler2DArray glowMap;
|
||||
uniform sampler2DArray normalMap;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout (set = 1, binding = 2, std140)
|
||||
#else
|
||||
layout (std140)
|
||||
#endif
|
||||
uniform decalGlobalData {
|
||||
layout (std140) uniform decalGlobalData {
|
||||
mat4 viewMatrix;
|
||||
mat4 projMatrix;
|
||||
mat4 invViewMatrix;
|
||||
@@ -72,12 +32,7 @@ uniform decalGlobalData {
|
||||
vec2 viewportSize;
|
||||
};
|
||||
|
||||
#ifdef VULKAN
|
||||
layout (set = 2, binding = 3, std140)
|
||||
#else
|
||||
layout (std140)
|
||||
#endif
|
||||
uniform decalInfoData {
|
||||
layout (std140) uniform decalInfoData {
|
||||
int diffuse_index;
|
||||
int glow_index;
|
||||
int normal_index;
|
||||
@@ -90,16 +45,8 @@ vec3 computeViewPosition(vec2 textureCoord) {
|
||||
vec4 clipSpaceLocation;
|
||||
vec2 normalizedCoord = textureCoord / viewportSize;
|
||||
|
||||
#ifdef VULKAN
|
||||
clipSpaceLocation.x = normalizedCoord.x * 2.0 - 1.0;
|
||||
// Vulkan negative viewport inverts Y mapping
|
||||
clipSpaceLocation.y = 1.0 - normalizedCoord.y * 2.0;
|
||||
// Vulkan depth is [0,1] — use directly
|
||||
clipSpaceLocation.z = texelFetch(gDepthBuffer, ivec2(textureCoord), 0).r;
|
||||
#else
|
||||
clipSpaceLocation.xy = normalizedCoord * 2.0f - 1.0f;
|
||||
clipSpaceLocation.z = texelFetch(gDepthBuffer, ivec2(textureCoord), 0).r * 2.0f - 1.0f;
|
||||
#endif
|
||||
clipSpaceLocation.w = 1.0f;
|
||||
|
||||
vec4 homogenousLocation = invProjMatrix * clipSpaceLocation;
|
||||
@@ -110,24 +57,24 @@ vec3 computeViewPosition(vec2 textureCoord) {
|
||||
vec3 getPixelNormal(vec3 frag_position, vec2 tex_coord, inout float alpha, out vec3 binormal, out vec3 tangent) {
|
||||
#ifdef USE_NORMAL_MAP
|
||||
// If we can then we just use the existing normal buffer
|
||||
vec3 normal = texelFetch(gNormalBuffer, ivec2(tex_coord), 0).xyz;
|
||||
vec3 normal = texelFetch(gNormalBuffer, ivec2(tex_coord), 0).xyz;
|
||||
|
||||
// If we use the normal map then we don't really need these values so we don't need to compute them here
|
||||
binormal = vec3(0.0);
|
||||
tangent = vec3(0.0);
|
||||
binormal = vec3(0.0);
|
||||
tangent = vec3(0.0);
|
||||
#else
|
||||
// Use some fancy screen-space derivates to determine the normal of the current pixel by looking at the surrounding pixels
|
||||
vec3 pos_dx = dFdx(frag_position);
|
||||
vec3 pos_dy = dFdy(frag_position);
|
||||
|
||||
vec3 normal = normalize(cross(pos_dx, pos_dy));
|
||||
vec3 normal = normalize(cross(pos_dx, pos_dy));
|
||||
|
||||
binormal = normalize(pos_dx);
|
||||
tangent = normalize(pos_dy);
|
||||
binormal = normalize(pos_dx);
|
||||
tangent = normalize(pos_dy);
|
||||
#endif
|
||||
|
||||
//Calculate angle between surface normal and decal direction
|
||||
float angle = acos(clamp(dot(normal, decalDirection), -1.0, 1.0));
|
||||
float angle = acos(dot(normal, decalDirection));
|
||||
|
||||
if (angle > normal_angle_cutoff) {
|
||||
// The angle between surface normal and decal direction is too big
|
||||
@@ -135,7 +82,7 @@ vec3 getPixelNormal(vec3 frag_position, vec2 tex_coord, inout float alpha, out v
|
||||
}
|
||||
|
||||
// Make a smooth alpha transition leading up to an edge
|
||||
alpha = alpha * (1.0 - smoothstep(angle_fade_start, normal_angle_cutoff, angle));
|
||||
alpha = alpha * (1 - smoothstep(angle_fade_start, normal_angle_cutoff, angle));
|
||||
|
||||
return normal;
|
||||
}
|
||||
@@ -215,18 +162,7 @@ void main() {
|
||||
normal_out = tangentToView * decalNormal * alpha;
|
||||
}
|
||||
|
||||
#ifdef VULKAN
|
||||
// 6-attachment G-buffer; attachments 1/3/5 are write-masked
|
||||
fragOut0 = diffuse_out;
|
||||
fragOut1 = vec4(0.0);
|
||||
fragOut2 = vec4(normal_out, 0.0);
|
||||
fragOut3 = vec4(0.0);
|
||||
fragOut4 = emissive_out;
|
||||
fragOut5 = vec4(0.0);
|
||||
#else
|
||||
// OpenGL: 3 draw buffers mapped to attachments 0/2/4
|
||||
fragOut0 = diffuse_out;
|
||||
fragOut1 = vec4(normal_out, 0.0);
|
||||
fragOut2 = emissive_out;
|
||||
#endif
|
||||
}
|
||||
@@ -1,24 +1,4 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
// Binding 0: box vertex positions
|
||||
layout (location = 0) in vec4 vertPosition;
|
||||
|
||||
// Binding 1: per-instance model matrix (mat4 = 4 vec4s at locations 8-11)
|
||||
layout (location = 8) in vec4 vertModelMatrix0;
|
||||
layout (location = 9) in vec4 vertModelMatrix1;
|
||||
layout (location = 10) in vec4 vertModelMatrix2;
|
||||
layout (location = 11) in vec4 vertModelMatrix3;
|
||||
|
||||
layout (location = 0) flat out mat4 invModelMatrix; // locations 0-3
|
||||
layout (location = 4) flat out vec3 decalDirection;
|
||||
layout (location = 5) flat out float normal_angle_cutoff;
|
||||
layout (location = 6) flat out float angle_fade_start;
|
||||
layout (location = 7) flat out float alpha_scale;
|
||||
#else
|
||||
in vec4 vertPosition;
|
||||
in mat4 vertModelMatrix;
|
||||
|
||||
@@ -27,14 +7,8 @@ flat out vec3 decalDirection;
|
||||
flat out float normal_angle_cutoff;
|
||||
flat out float angle_fade_start;
|
||||
flat out float alpha_scale;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout (set = 1, binding = 2, std140)
|
||||
#else
|
||||
layout (std140)
|
||||
#endif
|
||||
uniform decalGlobalData {
|
||||
layout (std140) uniform decalGlobalData {
|
||||
mat4 viewMatrix;
|
||||
mat4 projMatrix;
|
||||
mat4 invViewMatrix;
|
||||
@@ -43,12 +17,7 @@ uniform decalGlobalData {
|
||||
vec2 viewportSize;
|
||||
};
|
||||
|
||||
#ifdef VULKAN
|
||||
layout (set = 2, binding = 3, std140)
|
||||
#else
|
||||
layout (std140)
|
||||
#endif
|
||||
uniform decalInfoData {
|
||||
layout (std140) uniform decalInfoData {
|
||||
int diffuse_index;
|
||||
int glow_index;
|
||||
int normal_index;
|
||||
@@ -58,11 +27,6 @@ uniform decalInfoData {
|
||||
};
|
||||
|
||||
void main() {
|
||||
#ifdef VULKAN
|
||||
// Reconstruct per-instance model matrix from 4 vec4 columns
|
||||
mat4 vertModelMatrix = mat4(vertModelMatrix0, vertModelMatrix1, vertModelMatrix2, vertModelMatrix3);
|
||||
#endif
|
||||
|
||||
normal_angle_cutoff = vertModelMatrix[0][3];
|
||||
angle_fade_start = vertModelMatrix[1][3];
|
||||
alpha_scale = vertModelMatrix[2][3];
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
#ifdef GL_ES
|
||||
#extension GL_EXT_clip_cull_distance : enable
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
precision highp sampler2DArray;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 2, binding = 0, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform genericData {
|
||||
mat4 modelMatrix;
|
||||
|
||||
vec4 color;
|
||||
|
||||
vec4 clipEquation;
|
||||
|
||||
int baseMapIndex;
|
||||
int alphaTexture;
|
||||
int noTexturing;
|
||||
int srgb;
|
||||
|
||||
float intensity;
|
||||
float alphaThreshold;
|
||||
uint clipEnabled;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
|
||||
layout(set = 1, binding = 1) uniform sampler2DArray baseMap;
|
||||
|
||||
layout(location = 0) in vec4 fragTexCoord;
|
||||
layout(location = 1) in vec4 fragColor;
|
||||
#ifdef SDR_FLAG_SW_CLIP_FALLBACK
|
||||
layout(location = 2) in float vClipDist;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef SDR_FLAG_SW_CLIP_FALLBACK
|
||||
in float vClipDist;
|
||||
#endif
|
||||
|
||||
uniform sampler2DArray baseMap;
|
||||
|
||||
in vec4 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
#endif
|
||||
|
||||
#include "gamma.sdr"
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef SDR_FLAG_SW_CLIP_FALLBACK
|
||||
if (clipEnabled != 0u && vClipDist < 0.0) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
vec4 baseColor = texture(baseMap, vec3(fragTexCoord.xy, float(baseMapIndex)));
|
||||
if(alphaThreshold > baseColor.a) discard;
|
||||
baseColor.rgb = (srgb == 1) ? srgb_to_linear(baseColor.rgb) : baseColor.rgb;
|
||||
vec4 blendColor = (srgb == 1) ? vec4(srgb_to_linear(fragColor.rgb), fragColor.a) : fragColor;
|
||||
fragOut0 = mix(mix(baseColor * blendColor, vec4(blendColor.rgb, baseColor.r * blendColor.a), float(alphaTexture)), blendColor, float(noTexturing)) * intensity;
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
#ifdef GL_ES
|
||||
#extension GL_EXT_clip_cull_distance : enable
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 2, binding = 0, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform genericData {
|
||||
mat4 modelMatrix;
|
||||
|
||||
vec4 color;
|
||||
|
||||
vec4 clipEquation;
|
||||
|
||||
int baseMapIndex;
|
||||
int alphaTexture;
|
||||
int noTexturing;
|
||||
int srgb;
|
||||
|
||||
float intensity;
|
||||
float alphaThreshold;
|
||||
uint clipEnabled;
|
||||
};
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 2, binding = 1, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform matrixData {
|
||||
mat4 modelViewMatrix;
|
||||
mat4 projMatrix;
|
||||
};
|
||||
|
||||
#ifdef VULKAN
|
||||
|
||||
layout(location = 0) in vec4 vertPosition;
|
||||
layout(location = 1) in vec4 vertColor;
|
||||
layout(location = 2) in vec4 vertTexCoord;
|
||||
|
||||
layout(location = 0) out vec4 fragTexCoord;
|
||||
layout(location = 1) out vec4 fragColor;
|
||||
#ifdef SDR_FLAG_SW_CLIP_FALLBACK
|
||||
layout(location = 2) out float vClipDist;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef SDR_FLAG_SW_CLIP_FALLBACK
|
||||
out float vClipDist;
|
||||
#endif
|
||||
|
||||
out vec4 fragTexCoord;
|
||||
in vec4 vertTexCoord;
|
||||
out vec4 fragColor;
|
||||
in vec4 vertColor;
|
||||
in vec4 vertPosition;
|
||||
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
fragTexCoord = vertTexCoord;
|
||||
fragColor = vertColor * color;
|
||||
gl_Position = projMatrix * modelViewMatrix * vertPosition;
|
||||
|
||||
if (clipEnabled != 0u) {
|
||||
#ifndef SDR_FLAG_SW_CLIP_FALLBACK
|
||||
gl_ClipDistance[0] = dot(clipEquation, modelMatrix * vertPosition);
|
||||
#else
|
||||
vClipDist = dot(clipEquation, modelMatrix * vertPosition);
|
||||
#endif
|
||||
} else {
|
||||
#ifndef SDR_FLAG_SW_CLIP_FALLBACK
|
||||
gl_ClipDistance[0] = 1.0;
|
||||
#else
|
||||
vClipDist = 1.0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
layout (location=0) out vec4 fragOut0;
|
||||
layout (location=1) out vec4 fragOut1;
|
||||
layout (location=2) out vec4 fragOut2;
|
||||
layout (location=3) out vec4 fragOut3;
|
||||
layout (location=4) out vec4 fragOut4;
|
||||
layout (location=5) out vec4 fragOut5;
|
||||
|
||||
out vec4 fragOut0;
|
||||
out vec4 fragOut1;
|
||||
out vec4 fragOut2;
|
||||
out vec4 fragOut3;
|
||||
out vec4 fragOut4;
|
||||
out vec4 fragOut5;
|
||||
void main()
|
||||
{
|
||||
fragOut0 = vec4(0.0, 0.0, 0.0, 1.0); // color
|
||||
|
||||
@@ -1,103 +1,45 @@
|
||||
//? #version 150
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
precision highp sampler2D;
|
||||
precision highp samplerCube;
|
||||
precision highp sampler2DArrayShadow;
|
||||
#endif
|
||||
|
||||
#include "lighting.sdr" //! #include "lighting.sdr"
|
||||
#include "gamma.sdr" //! #include "gamma.sdr"
|
||||
#include "shadows.sdr" //! #include "shadows.sdr"
|
||||
#include "z-compress.sdr" //! #include "z-compress.sdr"
|
||||
|
||||
#ifndef GL_ES
|
||||
layout(location = 0) out vec4 fragOut0;
|
||||
#else
|
||||
layout(location = 5) out vec4 fragOut0; //COLOR_ATTACHMENTn is on location n in ES, here it uses COLOR_ATTACHMENT5
|
||||
#endif
|
||||
out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 1, binding = 1) uniform sampler2D sTextures[16];
|
||||
#define ColorBuffer sTextures[0]
|
||||
#define NormalBuffer sTextures[1]
|
||||
#define PositionBuffer sTextures[2]
|
||||
#define SpecBuffer sTextures[3]
|
||||
|
||||
layout(set = 0, binding = 2) uniform sampler2DArrayShadow shadow_map;
|
||||
|
||||
#ifdef ENV_MAP
|
||||
layout(set = 0, binding = 3) uniform samplerCube sEnvmap;
|
||||
layout(set = 0, binding = 4) uniform samplerCube sIrrmap;
|
||||
#endif
|
||||
|
||||
#ifdef RT_SHADOWS
|
||||
layout(set = 0, binding = 5) uniform accelerationStructureEXT shadow_tlas;
|
||||
#endif
|
||||
#else
|
||||
uniform sampler2D ColorBuffer;
|
||||
uniform sampler2D NormalBuffer;
|
||||
uniform sampler2D PositionBuffer;
|
||||
uniform sampler2D SpecBuffer;
|
||||
uniform sampler2DArrayShadow shadow_map;
|
||||
uniform sampler2DArray shadow_map;
|
||||
|
||||
#ifdef ENV_MAP
|
||||
uniform samplerCube sEnvmap;
|
||||
uniform samplerCube sIrrmap;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 0, binding = 1, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform globalDeferredData {
|
||||
layout (std140) uniform globalDeferredData {
|
||||
mat4 shadow_mv_matrix;
|
||||
mat4 shadow_proj_matrix[4];
|
||||
|
||||
mat4 inv_view_matrix;
|
||||
|
||||
float veryneardist;
|
||||
float neardist;
|
||||
float middist;
|
||||
float fardist;
|
||||
|
||||
float invScreenWidth;
|
||||
float invScreenHeight;
|
||||
|
||||
float nearPlane;
|
||||
};
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 0, binding = 6, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform shadowCascadeParams {
|
||||
int cascade_offset;
|
||||
int cascade_count;
|
||||
float rtShadowBiasMin;
|
||||
float rtShadowBiasMax;
|
||||
|
||||
mat4 shadow_mv_matrix;
|
||||
|
||||
// See shadow_cascade_static_data (uniform_structs.h).
|
||||
vec3 shadow_ray_view_origin;
|
||||
int shadow_ray_cull_mask;
|
||||
mat4 shadow_proj_matrix[NUM_SHADOW_CASCADES];
|
||||
vec4 cascade_distances[(NUM_SHADOW_CASCADES + 4 - 1) / 4];
|
||||
vec4 smoothness_factors[(NUM_SHADOW_CASCADES + 4 - 1) / 4];
|
||||
};
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 2, binding = 1, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform matrixData {
|
||||
layout (std140) uniform matrixData {
|
||||
mat4 modelViewMatrix;
|
||||
mat4 projMatrix;
|
||||
};
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 0, binding = 0, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform lightData {
|
||||
layout (std140) uniform lightData {
|
||||
vec3 diffuseLightColor;
|
||||
float coneAngle;
|
||||
|
||||
@@ -105,18 +47,18 @@ uniform lightData {
|
||||
float coneInnerAngle;
|
||||
|
||||
vec3 coneDir;
|
||||
int dualCone;
|
||||
bool dualCone;
|
||||
|
||||
vec3 scale;
|
||||
float lightRadius;
|
||||
|
||||
int lightType;
|
||||
int enable_shadows;
|
||||
bool enable_shadows;
|
||||
|
||||
float sourceRadius;
|
||||
};
|
||||
|
||||
// Nearest point sphere and tube light calculations taken from
|
||||
// Nearest point sphere and tube light calculations taken from
|
||||
// "Real Shading in Unreal Engine 4" by Brian Karis, Epic Games
|
||||
// Part of SIGGRAPH 2013 Course: Physically Based Shading in Theory and Practice
|
||||
|
||||
@@ -124,7 +66,7 @@ vec3 ExpandLightSize(in vec3 lightDir, in vec3 reflectDir) {
|
||||
// There's an extra max(...,sourceRadius) call here vs the version in the paper.
|
||||
// This prevents the centerToRay calculation from choosing a point behind
|
||||
// the reflection ray's origin (i.e. underneath the surface).
|
||||
// this is necessary for situations where the fragment being shaded lies inside
|
||||
// this is necessary for situations where the fragment being shaded lies inside
|
||||
// the sourceRadius of the light.
|
||||
// Instead, we choose a point suffciently far away from the reflection origin (hence max(...,sourceRadius))
|
||||
// so that we have a gradual transition as the shaded fragments along the surface
|
||||
@@ -132,13 +74,12 @@ vec3 ExpandLightSize(in vec3 lightDir, in vec3 reflectDir) {
|
||||
vec3 centerToRay = max(dot(lightDir, reflectDir),sourceRadius) * reflectDir - lightDir;
|
||||
return lightDir + centerToRay * clamp(sourceRadius/length(centerToRay), 0.0, 1.0);
|
||||
}
|
||||
void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 lightDirOut, out float attenuation, out float area_normalisation, out float lightDist)
|
||||
void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 lightDirOut, out float attenuation, out float area_normalisation)
|
||||
{
|
||||
if (lightType == LT_DIRECTIONAL) {
|
||||
lightDirOut = normalize(lightDir);
|
||||
attenuation = 1.0;
|
||||
area_normalisation = 1.0;
|
||||
lightDist = RT_SHADOW_MAX_DISTANCE;
|
||||
} else {
|
||||
vec3 lightPosition = modelViewMatrix[3].xyz;
|
||||
// Positional light source
|
||||
@@ -151,9 +92,8 @@ void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 li
|
||||
// move lightDirOut towards the ray defined by reflectDir
|
||||
lightDirOut = ExpandLightSize(lightDirOut, reflectDir);
|
||||
dist = length(lightDirOut);
|
||||
lightDist = dist;
|
||||
// Energy conservation term
|
||||
float alpha_adjust = clamp(alpha + (sourceRadius/(2.0*dist)), 0.0, 1.0);
|
||||
float alpha_adjust = clamp(alpha + (sourceRadius/(2*dist)), 0.0, 1.0);
|
||||
area_normalisation = alpha/alpha_adjust;
|
||||
area_normalisation *= area_normalisation;
|
||||
//end chunk
|
||||
@@ -194,9 +134,8 @@ void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 li
|
||||
// Same principle as in LT_POINT, treat chosen location as a spherelight.
|
||||
lightDirOut = ExpandLightSize(lightDirOut, reflectDir);
|
||||
float dist = length(lightDirOut);
|
||||
lightDist = dist;
|
||||
// Energy conservation term
|
||||
float alpha_adjust = min(alpha + (sourceRadius/(2.0*dist)), 1.0);
|
||||
float alpha_adjust = min(alpha + (sourceRadius/(2*dist)), 1.0);
|
||||
area_normalisation = alpha/alpha_adjust;
|
||||
// don't need to square as it's a line rather than a sphere.
|
||||
//end chunk
|
||||
@@ -210,11 +149,10 @@ void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 li
|
||||
lightDirOut = lightPosition - position.xyz;
|
||||
float coneDot = dot(normalize(-lightDirOut), coneDir);
|
||||
float dist = length(lightDirOut);
|
||||
lightDist = dist;
|
||||
attenuation = 1.0 - clamp(sqrt(dist / lightRadius), 0.0, 1.0);
|
||||
area_normalisation = 1.0;
|
||||
|
||||
if(dualCone != 0) {
|
||||
if(dualCone) {
|
||||
if(abs(coneDot) < coneAngle) {
|
||||
discard;
|
||||
} else {
|
||||
@@ -243,11 +181,11 @@ void ComputeEnvLight(float alpha, float ao, vec3 light_dir, vec3 eyeDir, vec3 no
|
||||
// so let s = (2/alpha^2 - 2)
|
||||
// 1/2 log(s + 1) = 1/2 log(2/alpha^2 -1)
|
||||
|
||||
const float ENV_REZ = 512.0; // Ideally this would be #define'd and shader recompiled with envmap rez changes
|
||||
const float REZ_BIAS = log2(ENV_REZ * sqrt(3.0));
|
||||
const float ENV_REZ = 512; // Ideally this would be #define'd and shader recompiled with envmap rez changes
|
||||
const float REZ_BIAS = log2(ENV_REZ * sqrt(3));
|
||||
|
||||
float alphaSqr = alpha * alpha;
|
||||
float rough_bias = 0.5 * log2(2.0/alphaSqr - 1.0);
|
||||
float rough_bias = 0.5 * log2(2/alphaSqr - 1);
|
||||
float mip_bias = REZ_BIAS - rough_bias;
|
||||
|
||||
// Sample light, using mip bias to blur it.
|
||||
@@ -265,7 +203,7 @@ void ComputeEnvLight(float alpha, float ao, vec3 light_dir, vec3 eyeDir, vec3 no
|
||||
// Pseudo-IBL, so use k_IBL
|
||||
float k = alpha * alpha/ 2.0f;
|
||||
|
||||
float NdotL = max(dot(light_dir, normal),0.0);
|
||||
float NdotL = max(dot(light_dir, normal),0);
|
||||
|
||||
float g1vNL = GeometrySchlickGGX(NdotL, k);
|
||||
vec3 specEnvLighting = specEnvColour.rgb * fresnel * g1vNL;
|
||||
@@ -317,35 +255,24 @@ void main()
|
||||
vec3 lightDir;
|
||||
float attenuation;
|
||||
float area_normalisation;
|
||||
float lightDist;
|
||||
GetLightInfo(position, alpha, reflectDir, lightDir, attenuation, area_normalisation, lightDist);
|
||||
GetLightInfo(position, alpha, reflectDir, lightDir, attenuation, area_normalisation);
|
||||
|
||||
if (enable_shadows != 0) {
|
||||
#ifdef RT_SHADOWS
|
||||
// Ray origin in TLAS-relative space; see shadow_cascade_static_data (uniform_structs.h).
|
||||
// Only the rotation of inv_view_matrix is used: its translation is the (large) camera
|
||||
// world position, which shadow_ray_view_origin supplies already rebased onto the TLAS.
|
||||
vec3 worldPos = mat3(inv_view_matrix) * position + shadow_ray_view_origin;
|
||||
vec3 worldNormal = normalize((inv_view_matrix * vec4(normal, 0.0)).xyz);
|
||||
vec3 worldLightDir = normalize((inv_view_matrix * vec4(lightDir, 0.0)).xyz);
|
||||
|
||||
float rtShadowBias = computeRtShadowBias(length(position), rtShadowBiasMin, rtShadowBiasMax);
|
||||
attenuation *= traceShadowRay(shadow_tlas, worldPos, worldNormal, worldLightDir, lightDist, rtShadowBias, uint(shadow_ray_cull_mask));
|
||||
#else
|
||||
if (enable_shadows) {
|
||||
vec4 fragShadowPos = shadow_mv_matrix * inv_view_matrix * vec4(position, 1.0);
|
||||
vec4 fragShadowUV[NUM_SHADOW_CASCADES];
|
||||
for (int i = 0; i < NUM_SHADOW_CASCADES; i++) {
|
||||
fragShadowUV[i] = transformToShadowMap(shadow_proj_matrix[i], i, fragShadowPos);
|
||||
}
|
||||
vec4 fragShadowUV[4];
|
||||
fragShadowUV[0] = transformToShadowMap(shadow_proj_matrix[0], 0, fragShadowPos);
|
||||
fragShadowUV[1] = transformToShadowMap(shadow_proj_matrix[1], 1, fragShadowPos);
|
||||
fragShadowUV[2] = transformToShadowMap(shadow_proj_matrix[2], 2, fragShadowPos);
|
||||
fragShadowUV[3] = transformToShadowMap(shadow_proj_matrix[3], 3, fragShadowPos);
|
||||
|
||||
attenuation *= getShadowValue(shadow_map, -position.z, fragShadowUV, cascade_distances, smoothness_factors, cascade_offset, cascade_count);
|
||||
#endif
|
||||
attenuation *= getShadowValue(shadow_map, -position.z, fragShadowPos.z, fragShadowUV, fardist, middist,
|
||||
neardist, veryneardist);
|
||||
}
|
||||
|
||||
vec3 halfVec = normalize(lightDir + eyeDir);
|
||||
float NdotL = clamp(dot(normal, lightDir), 0.0, 1.0);
|
||||
fragmentColor.rgb = computeLighting(specColor.rgb, diffColor, lightDir, normal.xyz, halfVec, eyeDir, roughness, fresnel, NdotL).rgb * diffuseLightColor * attenuation * area_normalisation;
|
||||
}
|
||||
|
||||
|
||||
fragOut0 = max(fragmentColor, vec4(0.0));
|
||||
}
|
||||
@@ -1,32 +1,14 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
#endif
|
||||
|
||||
#include "lighting.sdr"
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(location = 0) in vec4 vertPosition;
|
||||
#else
|
||||
in vec4 vertPosition;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 2, binding = 1, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform matrixData {
|
||||
layout (std140) uniform matrixData {
|
||||
mat4 modelViewMatrix;
|
||||
mat4 projMatrix;
|
||||
};
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(set = 0, binding = 0, std140)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform lightData {
|
||||
layout (std140) uniform lightData {
|
||||
vec3 diffuseLightColor;
|
||||
float coneAngle;
|
||||
|
||||
@@ -34,13 +16,13 @@ uniform lightData {
|
||||
float coneInnerAngle;
|
||||
|
||||
vec3 coneDir;
|
||||
int dualCone;
|
||||
bool dualCone;
|
||||
|
||||
vec3 scale;
|
||||
float lightRadius;
|
||||
|
||||
int lightType;
|
||||
int enable_shadows;
|
||||
bool enable_shadows;
|
||||
|
||||
float sourceRadius;
|
||||
};
|
||||
@@ -48,13 +30,7 @@ uniform lightData {
|
||||
void main()
|
||||
{
|
||||
if (lightType == LT_DIRECTIONAL || lightType == LT_AMBIENT) {
|
||||
#ifdef VULKAN
|
||||
// Fullscreen triangle from gl_VertexIndex (no vertex buffer)
|
||||
vec2 pos = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
|
||||
gl_Position = vec4(pos * 2.0 - 1.0, 0.0, 1.0);
|
||||
#else
|
||||
gl_Position = vec4(vertPosition.xyz, 1.0);
|
||||
#endif
|
||||
} else {
|
||||
gl_Position = projMatrix * modelViewMatrix * vec4(vertPosition.xyz * scale, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,37 +1,15 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp sampler2D;
|
||||
precision highp sampler2DArray;
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(location = 0) in vec4 fragTexCoord;
|
||||
layout(location = 1) in vec4 fragColor;
|
||||
layout(location = 2) in float fragOffset;
|
||||
|
||||
layout(set = 1, binding = 1) uniform sampler2DArray baseMap;
|
||||
layout(set = 1, binding = 4) uniform sampler2D depthMap;
|
||||
layout(set = 1, binding = 5) uniform sampler2D frameBuffer;
|
||||
layout(set = 1, binding = 6) uniform sampler2D distMap;
|
||||
#else
|
||||
in vec4 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
in float fragOffset;
|
||||
|
||||
out vec4 fragOut0;
|
||||
|
||||
uniform sampler2DArray baseMap;
|
||||
uniform sampler2D depthMap;
|
||||
uniform sampler2D distMap;
|
||||
uniform sampler2D frameBuffer;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(std140, set = 2, binding = 0)
|
||||
#else
|
||||
layout (std140)
|
||||
#endif
|
||||
uniform genericData {
|
||||
layout (std140) uniform genericData {
|
||||
float window_width;
|
||||
float window_height;
|
||||
float use_offset;
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(location = 0) in vec4 vertPosition;
|
||||
layout(location = 1) in vec4 vertColor;
|
||||
layout(location = 2) in vec4 vertTexCoord;
|
||||
layout(location = 6) in float vertRadius;
|
||||
|
||||
layout(location = 0) out vec4 fragTexCoord;
|
||||
layout(location = 1) out vec4 fragColor;
|
||||
layout(location = 2) out float fragOffset;
|
||||
#else
|
||||
in vec4 vertPosition;
|
||||
in vec4 vertTexCoord;
|
||||
in vec4 vertColor;
|
||||
@@ -19,24 +5,13 @@ in float vertRadius;
|
||||
out vec4 fragTexCoord;
|
||||
out vec4 fragColor;
|
||||
out float fragOffset;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(std140, set = 2, binding = 1)
|
||||
#else
|
||||
layout (std140)
|
||||
#endif
|
||||
uniform matrixData {
|
||||
layout (std140) uniform matrixData {
|
||||
mat4 modelViewMatrix;
|
||||
mat4 projMatrix;
|
||||
};
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(std140, set = 2, binding = 0)
|
||||
#else
|
||||
layout (std140)
|
||||
#endif
|
||||
uniform genericData {
|
||||
layout (std140) uniform genericData {
|
||||
float window_width;
|
||||
float window_height;
|
||||
float use_offset;
|
||||
|
||||
@@ -1,39 +1,18 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
precision highp sampler2D;
|
||||
precision highp sampler2DArray;
|
||||
#endif
|
||||
|
||||
#include "gamma.sdr"
|
||||
#include "z-compress.sdr"
|
||||
|
||||
layout(location = 0) out vec4 fragOut0;
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(location = 0) in vec4 fragTexCoord;
|
||||
layout(location = 1) in vec4 fragColor;
|
||||
layout(location = 2) in float fragRadius;
|
||||
layout(location = 3) in vec4 fragPosition;
|
||||
|
||||
layout(set = 1, binding = 1) uniform sampler2DArray baseMap;
|
||||
layout(set = 1, binding = 4) uniform sampler2D depthMap;
|
||||
#else
|
||||
in float fragRadius;
|
||||
in vec4 fragPosition;
|
||||
in vec4 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
out vec4 fragOut0;
|
||||
|
||||
uniform sampler2DArray baseMap;
|
||||
uniform sampler2D depthMap;
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
layout(std140, set = 2, binding = 0)
|
||||
#else
|
||||
layout(std140)
|
||||
#endif
|
||||
uniform genericData {
|
||||
layout (std140) uniform genericData {
|
||||
float window_width;
|
||||
float window_height;
|
||||
float nearZ;
|
||||
@@ -60,13 +39,7 @@ void main()
|
||||
float sceneDepthLinear;
|
||||
float fragDepthLinear;
|
||||
if ( linear_depth == 1 ) {
|
||||
// Position buffer .z == 0 means no deferred geometry was rendered at this pixel
|
||||
// (G-buffer was cleared to zero). Treat as max distance so particles render fully.
|
||||
if (sceneDepth.z == 0.0) {
|
||||
sceneDepthLinear = farZ;
|
||||
} else {
|
||||
sceneDepthLinear = -uncompress_depth_value(sceneDepth.z);
|
||||
}
|
||||
sceneDepthLinear = -uncompress_depth_value(sceneDepth.z);
|
||||
fragDepthLinear = -fragPosition.z;
|
||||
} else {
|
||||
sceneDepthLinear = ( 2.0 * farZ * nearZ ) / ( farZ + nearZ - sceneDepth.x * (farZ-nearZ) );
|
||||
|
||||
Loaded 100 of 1226 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user