Update CMake to specify FXC.EXE to use (#502)
This commit is contained in:
Родитель
55b93efe35
Коммит
8193c66888
|
@ -91,9 +91,45 @@ jobs:
|
|||
with:
|
||||
arch: ${{ matrix.arch }}
|
||||
|
||||
- name: 'Set triplet'
|
||||
shell: pwsh
|
||||
run: |
|
||||
if ("${{ matrix.arch }}" -eq "amd64")
|
||||
{
|
||||
echo "VCPKG_DEFAULT_TRIPLET=x64-windows" >> $env:GITHUB_ENV
|
||||
}
|
||||
elseif ("${{ matrix.arch }}" -eq "amd64_x86")
|
||||
{
|
||||
echo "VCPKG_DEFAULT_TRIPLET=x86-windows" >> $env:GITHUB_ENV
|
||||
}
|
||||
elseif ("${{ matrix.arch }}" -eq "amd64_arm64")
|
||||
{
|
||||
if ("${{ matrix.build_type }}" -match "^arm64ec")
|
||||
{
|
||||
echo "VCPKG_DEFAULT_TRIPLET=arm64ec-windows" >> $env:GITHUB_ENV
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "VCPKG_DEFAULT_TRIPLET=arm64-windows" >> $env:GITHUB_ENV
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "::error Unknown architecture/build-type triplet mapping"
|
||||
}
|
||||
|
||||
- uses: lukka/run-vcpkg@v11
|
||||
with:
|
||||
runVcpkgInstall: true
|
||||
vcpkgJsonGlob: '**/build/vcpkg.json'
|
||||
vcpkgGitCommitId: '7516a02de04e8f8ff4e4beb8f5bac0565f9bf9da'
|
||||
|
||||
- name: 'Configure CMake'
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=ON -DBUILD_TOOLS=OFF -DBUILD_SAMPLE=OFF
|
||||
run: >
|
||||
cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=ON -DBUILD_TOOLS=OFF -DBUILD_SAMPLE=OFF -DENABLE_LIBJPEG_SUPPORT=ON -DENABLE_LIBPNG_SUPPORT=ON
|
||||
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_MANIFEST_DIR="${{ github.workspace }}/build"
|
||||
-DVCPKG_TARGET_TRIPLET="${env:VCPKG_DEFAULT_TRIPLET}"
|
||||
|
||||
- name: 'Build'
|
||||
working-directory: ${{ github.workspace }}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
#
|
||||
# http://go.microsoft.com/fwlink/?LinkId=248926
|
||||
|
||||
name: 'CMake (WSL)'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
paths-ignore:
|
||||
- '*.md'
|
||||
- LICENSE
|
||||
- '.nuget/*'
|
||||
- build/*.cmd
|
||||
- build/*.json
|
||||
- build/*.props
|
||||
- build/*.ps1
|
||||
- build/*.targets
|
||||
- build/*.yml
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
matrix:
|
||||
build_type: [x64-Debug-Linux, x64-Release-Linux]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: seanmiddleditch/gha-setup-ninja@v5
|
||||
|
||||
- uses: lukka/run-vcpkg@v11
|
||||
with:
|
||||
runVcpkgInstall: true
|
||||
vcpkgJsonGlob: '**/build/vcpkg.json'
|
||||
vcpkgGitCommitId: '7516a02de04e8f8ff4e4beb8f5bac0565f9bf9da'
|
||||
|
||||
- name: 'Configure CMake'
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: >
|
||||
cmake --preset=${{ matrix.build_type }} -DENABLE_OPENEXR_SUPPORT=ON -DENABLE_LIBJPEG_SUPPORT=ON -DENABLE_LIBPNG_SUPPORT=ON
|
||||
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_MANIFEST_DIR="${{ github.workspace }}/build"
|
||||
-DVCPKG_TARGET_TRIPLET="x64-linux"
|
||||
|
||||
- name: 'Build'
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: cmake --build out/build/${{ matrix.build_type }}
|
|
@ -86,7 +86,7 @@ namespace
|
|||
void OnPNGRead(png_structp st, png_bytep ptr, size_t len)
|
||||
{
|
||||
FILE* fin = reinterpret_cast<FILE*>(png_get_io_ptr(st));
|
||||
fread(ptr, len, 1, fin);
|
||||
std::ignore = fread(ptr, len, 1, fin);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ if((DEFINED XBOX_CONSOLE_TARGET) AND (NOT (XBOX_CONSOLE_TARGET STREQUAL "durango
|
|||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(build/CompilerAndLinker.cmake)
|
||||
|
||||
#--- Library
|
||||
set(LIBRARY_HEADERS
|
||||
|
@ -142,11 +143,12 @@ elseif((BUILD_XBOX_EXTS_XBOXONE OR BUILD_XBOX_EXTS_SCARLETT) AND WIN32)
|
|||
Auxiliary/DirectXTexXboxTile.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
if(BUILD_DX11 AND WIN32 AND (NOT (XBOX_CONSOLE_TARGET STREQUAL "durango")))
|
||||
set(SHADER_SOURCES
|
||||
DirectXTex/Shaders/BC6HEncode.hlsl
|
||||
DirectXTex/Shaders/BC7Encode.hlsl)
|
||||
|
||||
if(BUILD_DX11 AND WIN32)
|
||||
list(APPEND LIBRARY_SOURCES
|
||||
DirectXTex/BCDirectCompute.h
|
||||
DirectXTex/BCDirectCompute.cpp
|
||||
|
@ -183,7 +185,7 @@ if(ENABLE_LIBPNG_SUPPORT)
|
|||
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexPNG.cpp)
|
||||
endif()
|
||||
|
||||
if(BUILD_DX11 AND WIN32)
|
||||
if(BUILD_DX11 AND WIN32 AND (NOT (XBOX_CONSOLE_TARGET STREQUAL "durango")))
|
||||
if(NOT COMPILED_SHADERS)
|
||||
if(USE_PREBUILT_SHADERS)
|
||||
message(FATAL_ERROR "ERROR: Using prebuilt shaders requires the COMPILED_SHADERS variable is set")
|
||||
|
@ -197,12 +199,16 @@ if(BUILD_DX11 AND WIN32)
|
|||
list(APPEND LIBRARY_SOURCES ${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc)
|
||||
|
||||
if(NOT USE_PREBUILT_SHADERS)
|
||||
find_program(DIRECTX_FXC_TOOL FXC.EXE
|
||||
HINTS "C:/Program Files (x86)/Windows Kits/10/bin/${CMAKE_SYSTEM_VERSION}/${DIRECTX_HOST_ARCH}"
|
||||
"C:/Program Files (x86)/Windows Kits/10/bin/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}/${DIRECTX_HOST_ARCH}")
|
||||
message(STATUS "Using LegacyShaderCompiler found in ${DIRECTX_FXC_TOOL}")
|
||||
add_custom_command(
|
||||
OUTPUT "${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc"
|
||||
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders/CompileShaders.cmd"
|
||||
DEPENDS ${SHADER_SOURCES}
|
||||
COMMENT "Generating HLSL shaders..."
|
||||
COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" CompileShaders.cmd > "${COMPILED_SHADERS}/compileshaders.log"
|
||||
COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" $<$<BOOL:${DIRECTX_FXC_TOOL}>:LegacyShaderCompiler=${DIRECTX_FXC_TOOL}> CompileShaders.cmd > "${COMPILED_SHADERS}/compileshaders.log"
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders"
|
||||
USES_TERMINAL)
|
||||
endif()
|
||||
|
@ -319,6 +325,7 @@ if(directx-headers_FOUND)
|
|||
message(STATUS "Using DirectX-Headers package")
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC USING_DIRECTX_HEADERS)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC,Intel>:/wd4062> $<$<CXX_COMPILER_ID:Clang,IntelLLVM>:-Wno-switch-enum>)
|
||||
endif()
|
||||
|
||||
#--- Package
|
||||
|
@ -520,8 +527,6 @@ if(MSVC)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
include(build/CompilerAndLinker.cmake)
|
||||
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_definitions(${t} PRIVATE ${COMPILER_DEFINES})
|
||||
target_compile_options(${t} PRIVATE ${COMPILER_SWITCHES})
|
||||
|
|
|
@ -1369,8 +1369,8 @@ namespace
|
|||
int8_t v = ((((t >> 5) & 0x1f) ^ m) - m) + 16;
|
||||
int8_t u = (((t & 0x1f) ^ m) - m) + 16;
|
||||
|
||||
uint32_t t2 = u << 3 | u >> 2;
|
||||
uint32_t t3 = v << 3 | v >> 2;
|
||||
auto t2 = static_cast<uint32_t>(u << 3 | u >> 2);
|
||||
auto t3 = static_cast<uint32_t>(v << 3 | v >> 2);
|
||||
|
||||
*(dPtr++) = t1 | (t2 << 8) | (t3 << 16) | 0xff000000;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ if %PROCESSOR_ARCHITECTURE%.==ARM64. (set FXCARCH=arm64) else (if %PROCESSOR_ARC
|
|||
|
||||
set FXCOPTS=/nologo /WX /Ges /Zi /Zpc /Qstrip_reflect /Qstrip_debug
|
||||
|
||||
if defined LegacyShaderCompiler goto fxcviaenv
|
||||
set PCFXC="%WindowsSdkVerBinPath%%FXCARCH%\fxc.exe"
|
||||
if exist %PCFXC% goto continue
|
||||
set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
|
||||
|
@ -17,6 +18,12 @@ set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
|
|||
if exist %PCFXC% goto continue
|
||||
|
||||
set PCFXC=fxc.exe
|
||||
goto continue
|
||||
|
||||
:fxcviaenv
|
||||
set PCFXC="%LegacyShaderCompiler%"
|
||||
if not exist %PCFXC% goto needfxc
|
||||
goto continue
|
||||
|
||||
:continue
|
||||
if not defined CompileShadersOutput set CompileShadersOutput=Compiled
|
||||
|
@ -54,3 +61,7 @@ echo %fxc%
|
|||
echo %fxc4%
|
||||
%fxc4% || set error=1
|
||||
exit /b
|
||||
|
||||
:needfxc
|
||||
echo ERROR: CompileShaders requires FXC.EXE
|
||||
exit /b 1
|
||||
|
|
|
@ -32,6 +32,13 @@ elseif(CMAKE_VS_PLATFORM_NAME_DEFAULT MATCHES "^[Aa][Rr][Mm]64EC$")
|
|||
set(DIRECTX_ARCH arm64ec)
|
||||
endif()
|
||||
|
||||
#--- Determines host architecture
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "[Aa][Rr][Mm]64|aarch64|arm64")
|
||||
set(DIRECTX_HOST_ARCH arm64)
|
||||
else()
|
||||
set(DIRECTX_HOST_ARCH x64)
|
||||
endif()
|
||||
|
||||
#--- Build with Unicode Win32 APIs per "UTF-8 Everywhere"
|
||||
if(WIN32)
|
||||
list(APPEND COMPILER_DEFINES _UNICODE UNICODE)
|
||||
|
|
|
@ -24,6 +24,7 @@ pr:
|
|||
- build/*.cmake
|
||||
- build/*.in
|
||||
- build/DirectXTex-GitHub-CMake-Xbox-Dev17.yml
|
||||
- DirectXTex/Shaders/CompileShaders.cmd
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
|
|
|
@ -21,6 +21,7 @@ pr:
|
|||
paths:
|
||||
include:
|
||||
- build/DirectXTex-GitHub-Dev17.yml
|
||||
- DirectXTex/Shaders/CompileShaders.cmd
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
|
|
|
@ -25,6 +25,7 @@ pr:
|
|||
- build/*.in
|
||||
- build/*.cmake
|
||||
- build/SetupBWOI.*
|
||||
- DirectXTex/Shaders/CompileShaders.cmd
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
|
|
|
@ -21,6 +21,7 @@ pr:
|
|||
paths:
|
||||
include:
|
||||
- build/DirectXTex-GitHub.yml
|
||||
- DirectXTex/Shaders/CompileShaders.cmd
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
"dependencies": [
|
||||
"directxmath",
|
||||
"directx-headers",
|
||||
"openexr",
|
||||
{
|
||||
"name": "openexr",
|
||||
"platform": "linux | (windows & !arm64ec)"
|
||||
},
|
||||
"libpng",
|
||||
"libjpeg-turbo"
|
||||
]
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче