Fix MSVC compilation flags, improve build script, and update README

This commit is contained in:
Schryzon
2026-07-04 23:57:35 +08:00
parent ac9b24890a
commit bdc9658b8b
5 changed files with 120 additions and 54 deletions
+5
View File
@@ -40,3 +40,8 @@ tmp_*.py
build_*.txt
*.log
New Text Document.txt
# Local executables and configs
ac6recomp.exe
ac6recomp.toml
extract-xiso.exe
+32
View File
@@ -31,6 +31,19 @@ Users must supply their own legally obtained game files locally.
## Build
### Option A: Automatic Setup (Recommended)
You can use the automated build script which handles environment setup, ISO extraction, and the multi-step CMake build:
1. Place your legally obtained **Ace Combat 6 ISO** in the repository root directory.
2. Run `setup_and_build.bat`. The script will automatically locate Visual Studio, extract the assets, run codegen, and build the runtime using the MSVC backend.
3. Once completed, copy the compiled executable and default config to the root directory to run:
```powershell
Copy-Item out/build/win-amd64-relwithdebinfo/ac6recomp.exe . -Force
Copy-Item out/build/win-amd64-relwithdebinfo/ac6recomp.toml . -Force
```
4. Run `ac6recomp.exe` directly from the root directory.
5. Optionally create a shortcut to the executable file.
### Option B: Manual Build
```bash
cmake --preset win-amd64-relwithdebinfo
cmake --build --preset win-amd64-relwithdebinfo --target ac6recomp_codegen
@@ -42,6 +55,25 @@ The executable is placed at `out/build/win-amd64-relwithdebinfo/ac6recomp.exe`.
On Windows, use the preset commands above rather than plain `cmake -L` in the repo root. If you previously configured from an `x86` Visual Studio prompt or with the wrong compiler on `PATH`, delete `out/build/win-amd64-relwithdebinfo` and re-run the preset from a normal 64-bit PowerShell/CMD window or an x64 Native Tools prompt.
## Recommended Configuration Tweaks
Create or modify `ac6recomp.toml` in your out or root directory with these settings to optimize your gameplay experience:
```toml
# Play in Fullscreen
fullscreen = true
# (Forces point lists to expand to triangle strips in the VS, bypassing deprecated GPU point-sprite limits)
d3d12_expand_point_sprites_in_vs = true
# Eliminate Microstutters
# (Decouples presentation from UI event loop thread and enables G-Sync/FreeSync VRR tearing support)
host_present_from_non_ui_thread = true
d3d12_allow_variable_refresh_rate_and_tearing = true
d3d12_low_latency_swap_chain = true
d3d12_max_frame_latency = 1
```
## Modding Docs
- [Texture Swap Modding Guide](docs/TEXTURE_SWAP_MODDING_GUIDE.txt)
@@ -1,15 +0,0 @@
# Auto-generated cvar configuration
log_level = "debug"
log_file = "ac6recomp.log"
direct_host_resolve = false
vfetch_index_rounding_bias = true
guest_vblank_sync_to_refresh = true
window_width = 1920
window_height = 1080
video_mode_width = 1920
video_mode_height = 1080
resolution = "1080p"
d3d12_allow_variable_refresh_rate_and_tearing = false
host_present_from_non_ui_thread = false
ac6_performance_mode = false
ac6_unlock_fps = true
+80 -39
View File
@@ -1,6 +1,48 @@
@echo off
setlocal enabledelayedexpansion
echo =========================================
echo Visual Studio Environment Initialization
echo =========================================
:: Check if already in a VS developer prompt
if not "%VCINSTALLDIR%"=="" (
echo [OK] Already running in Visual Studio developer environment.
goto :env_ready
)
:: Locate vswhere.exe
set "VSWHERE_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "!VSWHERE_PATH!" (
set "VSWHERE_PATH=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
)
if exist "!VSWHERE_PATH!" (
echo Locating Visual Studio installation...
for /f "usebackq tokens=*" %%i in (`"!VSWHERE_PATH!" -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set "VS_INSTALL_DIR=%%i"
)
if not "!VS_INSTALL_DIR!"=="" (
set "VCVARS_BAT=!VS_INSTALL_DIR!\VC\Auxiliary\Build\vcvars64.bat"
if exist "!VCVARS_BAT!" (
echo [OK] Found Visual Studio variables script: !VCVARS_BAT!
echo Initializing x64 Developer Environment...
:: Call vcvars64.bat inside a temporary environment block, then preserve env
:: We do this by calling it and dumping the env changes
call "!VCVARS_BAT!" >nul
goto :env_ready
)
)
)
echo [WARNING] Could not automatically initialize Visual Studio developer environment.
echo If compilation fails, please run this script from the "x64 Native Tools Command Prompt for VS".
echo.
:env_ready
echo =========================================
echo Prerequisites Check
echo =========================================
@@ -28,14 +70,13 @@ if %errorlevel% neq 0 (
clang --version >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Clang not found on PATH.
echo Please download LLVM/Clang from https://github.com/llvm/llvm-project/releases or via Visual Studio Installer ^(C++ Clang tools^) and add to PATH.
echo Please install LLVM/Clang or select the "C++ Clang tools for Windows" component in the Visual Studio Installer.
pause
exit /b 1
)
clang++ --version >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Clang++ not found on PATH.
echo Please ensure clang++ is available.
pause
exit /b 1
)
@@ -49,7 +90,7 @@ if !errorlevel! equ 0 set sdk_found=1
if !sdk_found! equ 0 (
echo [ERROR] Windows SDK 10.0.19041+ not found in registry.
echo Please install it via the Visual Studio Installer by selecting the "Windows 10 SDK (10.0.19041.0)" or newer under the "Desktop development with C++" workload.
echo Please install it via the Visual Studio Installer.
pause
exit /b 1
)
@@ -57,41 +98,22 @@ echo [OK] All prerequisites found!
echo.
echo =========================================
echo Environment Check
echo Environment Validation
echo =========================================
if /I "%VSCMD_ARG_TGT_ARCH%"=="x86" (
echo [ERROR] Detected an x86 Visual Studio developer environment.
echo This project must be configured from an x64 environment.
echo Close this shell and reopen a normal 64-bit PowerShell/CMD window, or use an x64 Native Tools prompt.
echo Please run this script in an x64 Native Tools prompt.
pause
exit /b 1
)
if /I "%Platform%"=="x86" (
echo [ERROR] Detected Platform=x86 in the current shell.
echo This project must be configured for a 64-bit target.
echo Close this shell and reopen a normal 64-bit PowerShell/CMD window, or use an x64 Native Tools prompt.
pause
exit /b 1
)
echo [OK] No x86-only VS environment detected.
echo.
echo =========================================
echo Git Branch Check
echo =========================================
for /f "delims=" %%i in ('git rev-parse --abbrev-ref HEAD') do set CURRENT_BRANCH=%%i
echo Current branch: !CURRENT_BRANCH!
if /I "!CURRENT_BRANCH!"=="main" (
echo Switching from main to dev-test branch...
git checkout dev-test
if !errorlevel! neq 0 (
echo [ERROR] Failed to checkout dev-test branch.
pause
exit /b 1
)
) else (
echo Already on !CURRENT_BRANCH! branch or not on main.
)
echo [OK] Target environment is 64-bit.
echo.
echo =========================================
@@ -117,28 +139,44 @@ if not exist "!EXTRACT_XISO_EXE!" (
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri 'https://github.com/XboxDev/extract-xiso/releases/download/build-202505152050/extract-xiso-Win32_Release.zip' -OutFile 'extract-xiso.zip'; Expand-Archive -Path 'extract-xiso.zip' -DestinationPath 'extract-xiso-temp' -Force; Move-Item -Path 'extract-xiso-temp\artifacts\extract-xiso.exe' -Destination '.' -Force; Remove-Item 'extract-xiso.zip'; Remove-Item 'extract-xiso-temp' -Recurse -Force"
if not exist "!EXTRACT_XISO_EXE!" (
echo [ERROR] Failed to download or extract extract-xiso.
echo Please download it manually from https://github.com/XboxDev/extract-xiso/releases and place extract-xiso.exe in this folder.
pause
exit /b 1
)
)
set EXTRACT_DIR=assets
echo Extracting '!ISO_FILE!' to '!EXTRACT_DIR!' directory...
if not exist "!EXTRACT_DIR!" mkdir "!EXTRACT_DIR!"
!EXTRACT_XISO_EXE! -d "!EXTRACT_DIR!" "!ISO_FILE!"
if !errorlevel! neq 0 (
echo [ERROR] Failed to extract ISO.
pause
exit /b 1
if exist "!EXTRACT_DIR!\default.xex" (
echo [OK] '!EXTRACT_DIR!\default.xex' already exists. Skipping extraction.
) else (
echo Extracting '!ISO_FILE!' to '!EXTRACT_DIR!' directory...
if not exist "!EXTRACT_DIR!" mkdir "!EXTRACT_DIR!"
!EXTRACT_XISO_EXE! -d "!EXTRACT_DIR!" "!ISO_FILE!"
if !errorlevel! neq 0 (
echo [ERROR] Failed to extract ISO.
pause
exit /b 1
)
echo [OK] Extraction complete!
)
echo [OK] Extraction complete!
echo.
echo =========================================
echo Building the Game
echo Building the Game (MSVC Backend)
echo =========================================
echo Step 1: Configuring...
:: Check for clean build argument
set "clean_build=0"
if "%~1"=="--clean" set "clean_build=1"
if "%~1"=="-clean" set "clean_build=1"
if "%~1"=="clean" set "clean_build=1"
if "!clean_build!"=="1" (
echo Cleaning previous build directory out...
if exist "out" rd /s /q "out"
) else (
echo Incremental build enabled. Use --clean argument for a clean build.
)
echo Step 1: Configuring CMake...
cmake --preset win-amd64-relwithdebinfo
if !errorlevel! neq 0 (
echo [ERROR] Configuration failed.
@@ -154,7 +192,7 @@ if !errorlevel! neq 0 (
exit /b 1
)
echo Step 3: Re-configuring...
echo Step 3: Re-configuring CMake...
cmake --preset win-amd64-relwithdebinfo
if !errorlevel! neq 0 (
echo [ERROR] Re-configuration failed.
@@ -163,9 +201,12 @@ if !errorlevel! neq 0 (
)
echo Step 4: Building the runtime...
cmake --build --preset win-amd64-relwithdebinfo
cmake --build --preset win-amd64-relwithdebinfo > build.log 2>&1
if !errorlevel! neq 0 (
echo [ERROR] Build failed.
echo [ERROR] Build failed. Showing the last 50 lines of build.log:
echo --------------------------------------------------
powershell -Command "Get-Content build.log -Tail 50"
echo --------------------------------------------------
pause
exit /b 1
)
+3
View File
@@ -103,6 +103,9 @@ add_compile_options(
$<$<CONFIG:RELEASE>:-DNDEBUG>
-fno-char8_t
)
if(MSVC)
add_compile_options(/arch:AVX2)
endif()
# Platform detection (supports AMD64 and ARM64)
if(WIN32)