mirror of
https://github.com/microsoft/DirectXTex
synced 2024-11-21 12:00:06 +00:00
Update CMake to specify FXC.EXE to use (#502)
This commit is contained in:
parent
55b93efe35
commit
8193c66888
38
.github/workflows/test.yml
vendored
38
.github/workflows/test.yml
vendored
@ -91,9 +91,45 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
arch: ${{ matrix.arch }}
|
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'
|
- name: 'Configure CMake'
|
||||||
working-directory: ${{ github.workspace }}
|
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'
|
- name: 'Build'
|
||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
|
54
.github/workflows/wsl.yml
vendored
Normal file
54
.github/workflows/wsl.yml
vendored
Normal file
@ -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)
|
void OnPNGRead(png_structp st, png_bytep ptr, size_t len)
|
||||||
{
|
{
|
||||||
FILE* fin = reinterpret_cast<FILE*>(png_get_io_ptr(st));
|
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()
|
endif()
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
include(build/CompilerAndLinker.cmake)
|
||||||
|
|
||||||
#--- Library
|
#--- Library
|
||||||
set(LIBRARY_HEADERS
|
set(LIBRARY_HEADERS
|
||||||
@ -142,16 +143,17 @@ elseif((BUILD_XBOX_EXTS_XBOXONE OR BUILD_XBOX_EXTS_SCARLETT) AND WIN32)
|
|||||||
Auxiliary/DirectXTexXboxTile.cpp)
|
Auxiliary/DirectXTexXboxTile.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SHADER_SOURCES
|
|
||||||
DirectXTex/Shaders/BC6HEncode.hlsl
|
|
||||||
DirectXTex/Shaders/BC7Encode.hlsl)
|
|
||||||
|
|
||||||
if(BUILD_DX11 AND WIN32)
|
if(BUILD_DX11 AND WIN32 AND (NOT (XBOX_CONSOLE_TARGET STREQUAL "durango")))
|
||||||
list(APPEND LIBRARY_SOURCES
|
set(SHADER_SOURCES
|
||||||
DirectXTex/BCDirectCompute.h
|
DirectXTex/Shaders/BC6HEncode.hlsl
|
||||||
DirectXTex/BCDirectCompute.cpp
|
DirectXTex/Shaders/BC7Encode.hlsl)
|
||||||
DirectXTex/DirectXTexCompressGPU.cpp
|
|
||||||
DirectXTex/DirectXTexD3D11.cpp)
|
list(APPEND LIBRARY_SOURCES
|
||||||
|
DirectXTex/BCDirectCompute.h
|
||||||
|
DirectXTex/BCDirectCompute.cpp
|
||||||
|
DirectXTex/DirectXTexCompressGPU.cpp
|
||||||
|
DirectXTex/DirectXTexD3D11.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_DX12)
|
if(BUILD_DX12)
|
||||||
@ -183,7 +185,7 @@ if(ENABLE_LIBPNG_SUPPORT)
|
|||||||
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexPNG.cpp)
|
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexPNG.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_DX11 AND WIN32)
|
if(BUILD_DX11 AND WIN32 AND (NOT (XBOX_CONSOLE_TARGET STREQUAL "durango")))
|
||||||
if(NOT COMPILED_SHADERS)
|
if(NOT COMPILED_SHADERS)
|
||||||
if(USE_PREBUILT_SHADERS)
|
if(USE_PREBUILT_SHADERS)
|
||||||
message(FATAL_ERROR "ERROR: Using prebuilt shaders requires the COMPILED_SHADERS variable is set")
|
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)
|
list(APPEND LIBRARY_SOURCES ${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc)
|
||||||
|
|
||||||
if(NOT USE_PREBUILT_SHADERS)
|
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(
|
add_custom_command(
|
||||||
OUTPUT "${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc"
|
OUTPUT "${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc"
|
||||||
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders/CompileShaders.cmd"
|
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders/CompileShaders.cmd"
|
||||||
DEPENDS ${SHADER_SOURCES}
|
DEPENDS ${SHADER_SOURCES}
|
||||||
COMMENT "Generating HLSL shaders..."
|
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"
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders"
|
||||||
USES_TERMINAL)
|
USES_TERMINAL)
|
||||||
endif()
|
endif()
|
||||||
@ -319,6 +325,7 @@ if(directx-headers_FOUND)
|
|||||||
message(STATUS "Using DirectX-Headers package")
|
message(STATUS "Using DirectX-Headers package")
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
|
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC USING_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()
|
endif()
|
||||||
|
|
||||||
#--- Package
|
#--- Package
|
||||||
@ -520,8 +527,6 @@ if(MSVC)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(build/CompilerAndLinker.cmake)
|
|
||||||
|
|
||||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||||
target_compile_definitions(${t} PRIVATE ${COMPILER_DEFINES})
|
target_compile_definitions(${t} PRIVATE ${COMPILER_DEFINES})
|
||||||
target_compile_options(${t} PRIVATE ${COMPILER_SWITCHES})
|
target_compile_options(${t} PRIVATE ${COMPILER_SWITCHES})
|
||||||
|
@ -1369,8 +1369,8 @@ namespace
|
|||||||
int8_t v = ((((t >> 5) & 0x1f) ^ m) - m) + 16;
|
int8_t v = ((((t >> 5) & 0x1f) ^ m) - m) + 16;
|
||||||
int8_t u = (((t & 0x1f) ^ m) - m) + 16;
|
int8_t u = (((t & 0x1f) ^ m) - m) + 16;
|
||||||
|
|
||||||
uint32_t t2 = u << 3 | u >> 2;
|
auto t2 = static_cast<uint32_t>(u << 3 | u >> 2);
|
||||||
uint32_t t3 = v << 3 | v >> 2;
|
auto t3 = static_cast<uint32_t>(v << 3 | v >> 2);
|
||||||
|
|
||||||
*(dPtr++) = t1 | (t2 << 8) | (t3 << 16) | 0xff000000;
|
*(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
|
set FXCOPTS=/nologo /WX /Ges /Zi /Zpc /Qstrip_reflect /Qstrip_debug
|
||||||
|
|
||||||
|
if defined LegacyShaderCompiler goto fxcviaenv
|
||||||
set PCFXC="%WindowsSdkVerBinPath%%FXCARCH%\fxc.exe"
|
set PCFXC="%WindowsSdkVerBinPath%%FXCARCH%\fxc.exe"
|
||||||
if exist %PCFXC% goto continue
|
if exist %PCFXC% goto continue
|
||||||
set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
|
set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
|
||||||
@ -17,6 +18,12 @@ set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
|
|||||||
if exist %PCFXC% goto continue
|
if exist %PCFXC% goto continue
|
||||||
|
|
||||||
set PCFXC=fxc.exe
|
set PCFXC=fxc.exe
|
||||||
|
goto continue
|
||||||
|
|
||||||
|
:fxcviaenv
|
||||||
|
set PCFXC="%LegacyShaderCompiler%"
|
||||||
|
if not exist %PCFXC% goto needfxc
|
||||||
|
goto continue
|
||||||
|
|
||||||
:continue
|
:continue
|
||||||
if not defined CompileShadersOutput set CompileShadersOutput=Compiled
|
if not defined CompileShadersOutput set CompileShadersOutput=Compiled
|
||||||
@ -54,3 +61,7 @@ echo %fxc%
|
|||||||
echo %fxc4%
|
echo %fxc4%
|
||||||
%fxc4% || set error=1
|
%fxc4% || set error=1
|
||||||
exit /b
|
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)
|
set(DIRECTX_ARCH arm64ec)
|
||||||
endif()
|
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"
|
#--- Build with Unicode Win32 APIs per "UTF-8 Everywhere"
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND COMPILER_DEFINES _UNICODE UNICODE)
|
list(APPEND COMPILER_DEFINES _UNICODE UNICODE)
|
||||||
|
@ -24,6 +24,7 @@ pr:
|
|||||||
- build/*.cmake
|
- build/*.cmake
|
||||||
- build/*.in
|
- build/*.in
|
||||||
- build/DirectXTex-GitHub-CMake-Xbox-Dev17.yml
|
- build/DirectXTex-GitHub-CMake-Xbox-Dev17.yml
|
||||||
|
- DirectXTex/Shaders/CompileShaders.cmd
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
repositories:
|
repositories:
|
||||||
|
@ -21,6 +21,7 @@ pr:
|
|||||||
paths:
|
paths:
|
||||||
include:
|
include:
|
||||||
- build/DirectXTex-GitHub-Dev17.yml
|
- build/DirectXTex-GitHub-Dev17.yml
|
||||||
|
- DirectXTex/Shaders/CompileShaders.cmd
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
repositories:
|
repositories:
|
||||||
|
@ -25,6 +25,7 @@ pr:
|
|||||||
- build/*.in
|
- build/*.in
|
||||||
- build/*.cmake
|
- build/*.cmake
|
||||||
- build/SetupBWOI.*
|
- build/SetupBWOI.*
|
||||||
|
- DirectXTex/Shaders/CompileShaders.cmd
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
repositories:
|
repositories:
|
||||||
|
@ -21,6 +21,7 @@ pr:
|
|||||||
paths:
|
paths:
|
||||||
include:
|
include:
|
||||||
- build/DirectXTex-GitHub.yml
|
- build/DirectXTex-GitHub.yml
|
||||||
|
- DirectXTex/Shaders/CompileShaders.cmd
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
repositories:
|
repositories:
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
"dependencies": [
|
"dependencies": [
|
||||||
"directxmath",
|
"directxmath",
|
||||||
"directx-headers",
|
"directx-headers",
|
||||||
"openexr",
|
{
|
||||||
|
"name": "openexr",
|
||||||
|
"platform": "linux | (windows & !arm64ec)"
|
||||||
|
},
|
||||||
"libpng",
|
"libpng",
|
||||||
"libjpeg-turbo"
|
"libjpeg-turbo"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user