Compare commits

..

No commits in common. "main" and "jun2020" have entirely different histories.

242 changed files with 71931 additions and 47807 deletions

View File

@ -1,370 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library using CMake with VS Generator (GitHub Actions covers Ninja).
schedules:
- cron: "0 5 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
pr:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
drafts: false
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
- repository: vcpkgRepo
name: Microsoft/vcpkg
type: github
endpoint: microsoft
ref: refs/tags/$(VCPKG_TAG)
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: VCPKG_ROOT
value: '$(Build.SourcesDirectory)/vcpkg'
- name: VCPKG_CMAKE_DIR
value: '$(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake'
- name: VCPKG_MANIFEST_DIR
value: '$(Build.SourcesDirectory)/build'
- name: VS_GENERATOR
value: 'Visual Studio 17 2022'
- name: WIN10_SDK
value: '10.0.19041.0'
- name: WIN11_SDK
value: '10.0.22000.0'
pool:
vmImage: windows-2022
jobs:
- job: CMAKE_BUILD
displayName: CMake using VS Generator
steps:
- checkout: self
clean: true
fetchTags: false
- task: CMake@1
displayName: 'CMake (MSVC): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (MSVC): Config x86'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A Win32 -B out2
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build x86 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Build x86 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (MSVC): Config ARM64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A ARM64 -B out3
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build ARM64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out3 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Build ARM64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out3 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (UWP): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out4
-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=10.0
- task: CMake@1
displayName: 'CMake (UWP): Build x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out4 -v
- task: CMake@1
displayName: 'CMake (ClangCl): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -T clangcl -B out5
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out5 -v --config Debug
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out5 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (ClangCl): Config ARM64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A ARM64 -T clangcl -B out6
-DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)
- task: CMake@1
displayName: 'CMake (ClangCl): Build ARM64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out6 -v --config Debug
- task: CMake@1
displayName: 'CMake (Win10): Config'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out7
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=ON
- task: CMake@1
displayName: 'CMake (Win10): Build'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out7 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC Spectre): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out8
-DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=OFF
- task: CMake@1
displayName: 'CMake (MSVC Spectre): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out8 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC Spectre): Build x64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out8 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (MSVC Spectre): Config ARM64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A ARM64 -B out9
-DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=OFF
- task: CMake@1
displayName: 'CMake (MSVC Spectre): Build ARM64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out9 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC Spectre): Build ARM64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out9 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (Win10 Spectre): Config'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out10
-DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=ON
- task: CMake@1
displayName: 'CMake (Win10 Spectre): Build'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out10 -v --config Debug
- task: CMake@1
displayName: 'CMake (NO_WCHAR_T): Config'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out11
-DNO_WCHAR_T=ON
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)
-DBUILD_DX12=ON
- task: CMake@1
displayName: 'CMake (NO_WCHAR_T): Build'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out11 -v --config Debug
- task: CMake@1
displayName: 'CMake (DLL): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out12
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=ON
-DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out12 -v --config Debug
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out12 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (UWP DLL): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out13
-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=10.0
-DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (UWP DLL): Build x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out13 -v
- job: CMAKE_BUILD_VCPKG
displayName: CMake using VCPKG
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: vcpkgRepo
displayName: Fetch VCPKG
clean: true
fetchTags: false
fetchDepth: 1
path: 's/vcpkg'
- task: CmdLine@2
displayName: VCPKG Bootstrap
inputs:
script: call bootstrap-vcpkg.bat
workingDirectory: $(VCPKG_ROOT)
- task: CmdLine@2
displayName: VCPKG install packages
inputs:
script: call vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x64-windows
workingDirectory: $(VCPKG_ROOT)
- task: CMake@1
displayName: 'CMake (MSVC): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-windows
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 w/ OpenEXR'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out2 -DENABLE_OPENEXR_SUPPORT=ON -DBUILD_TESTING=OFF -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-windows
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug w/ OpenEXR'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 w/ libjpeg'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out3 -DENABLE_LIBJPEG_SUPPORT=ON -DBUILD_TESTING=OFF -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-windows
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug w/ libjpeg'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out3 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 w/ libpng'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out4 -DENABLE_LIBPNG_SUPPORT=ON -DBUILD_TESTING=OFF -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-windows
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug w/ libpng'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out4 -v --config Debug

View File

@ -1,397 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library with Xbox extensions using CMake.
schedules:
- cron: "0 4 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger: none
pr:
branches:
include:
- main
paths:
include:
- '.azuredevops/pipelines/DirectXTex-GitHub-CMake-Xbox-Dev17.yml'
- CMake*
- build/*.cmake
- build/*.in
- DirectXTex/Shaders/CompileShaders.cmd
- Auxiliary/*Xbox*
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
trigger: none
- repository: testRepo
name: walbourn/directxtextest
type: github
endpoint: microsoft
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: VS_GENERATOR
value: 'Visual Studio 17 2022'
- name: WIN10_SDK
value: '10.0.19041.0'
- name: EXTRACTED_FOLDER
value: '$(ExtractedFolder)'
- name: URL_FEED
value: $(ADOFeedURL)
- name: VC_PATH
value: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC'
- name: GameDKLatest
value: '$(ExtractedFolder)\Microsoft.gdk.xbox.$(GDK_EDITION)\native\$(GDK_EDITION)\'
- name: skipNugetSecurityAnalysis
value: true # We explicitly call this task so we don't need it to be auto-injected
pool:
vmImage: windows-2022
jobs:
- job: CMAKE_BUILD
displayName: CMake using VS Generator
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_SCARLETT=ON -DBUILD_SAMPLE=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Release (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (ClangCl): Config x64 (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -T clangcl -B out2
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_SCARLETT=ON -DBUILD_SAMPLE=OFF
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Debug (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out2 -v --config Debug
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Release (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out2 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 (Xbox One)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out3
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_XBOXONE=ON -DBUILD_SAMPLE=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out3 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Release (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out3 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (ClangCl): Config x64 (Xbox One)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -T clangcl -B out4
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_XBOXONE=ON -DBUILD_SAMPLE=OFF
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Debug (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out4 -v --config Debug
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Release (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out4 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (DLL): Config x64 (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out5
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_SCARLETT=ON -DBUILD_SAMPLE=OFF
-DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Debug (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out5 -v --config Debug
- task: CMake@1
displayName: 'CMake (DLL): Config x64 (Xbox One)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out6
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_XBOXONE=ON -DBUILD_SAMPLE=OFF
-DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Debug (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out6 -v --config Debug
- job: BUILD_GDK_CMAKE_XS
displayName: 'Xbox Series X|S Extensions BUILD_TESTING=ON'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CmdLine@2
displayName: Setup BWOI for GDK command-line
inputs:
script: |
call "$(VC_PATH)\Auxiliary\Build\vcvars64.bat"
echo ##vso[task.setvariable variable=WindowsSdkVerBinPath;]%WindowsSdkVerBinPath%
echo ##vso[task.prependpath]%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
echo ##vso[task.prependpath]%VCINSTALLDIR%Tools\Llvm\x64\bin
echo ##vso[task.prependpath]%WindowsSdkBinPath%x64
echo ##vso[task.prependpath]%WindowsSdkVerBinPath%x64
echo ##vso[task.prependpath]%VCToolsInstallDir%bin\HostX64\x64
call $(Build.SourcesDirectory)\build\SetupBWOI.cmd $(EXTRACTED_FOLDER) $(GDK_EDITION) Scarlett
echo ##vso[task.setvariable variable=GameDKLatest;]%GameDKLatest%
echo ##vso[task.setvariable variable=GRDKLatest;]%GRDKLatest%
echo ##vso[task.setvariable variable=GXDKLatest;]%GXDKLatest%
echo ##vso[task.setvariable variable=INCLUDE;]%INCLUDE%
echo ##vso[task.setvariable variable=LIB;]%LIB%
echo ##vso[task.prependpath]%ADDBIN%
failOnStderr: true
- task: CMake@1
displayName: 'CMake (MSVC): Config Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-GDKX-S
- task: CMake@1
displayName: 'CMake (MSVC): Build Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-GDKX-S
- task: CMake@1
displayName: 'CMake (MSVC): Config Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release-GDKX-S
- task: CMake@1
displayName: 'CMake (MSVC): Build Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Release-GDKX-S
- job: BUILD_GDK_CMAKE_X
displayName: 'Xbox One Extensions BUILD_TESTING=ON'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CmdLine@2
displayName: Setup BWOI for GDK command-line
inputs:
script: |
call "$(VC_PATH)\Auxiliary\Build\vcvars64.bat"
echo ##vso[task.setvariable variable=WindowsSdkVerBinPath;]%WindowsSdkVerBinPath%
echo ##vso[task.prependpath]%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
echo ##vso[task.prependpath]%VCINSTALLDIR%Tools\Llvm\x64\bin
echo ##vso[task.prependpath]%WindowsSdkBinPath%x64
echo ##vso[task.prependpath]%WindowsSdkVerBinPath%x64
echo ##vso[task.prependpath]%VCToolsInstallDir%bin\HostX64\x64
call $(Build.SourcesDirectory)\build\SetupBWOI.cmd $(EXTRACTED_FOLDER) $(GDK_EDITION) XboxOne
echo ##vso[task.setvariable variable=GameDKLatest;]%GameDKLatest%
echo ##vso[task.setvariable variable=GRDKLatest;]%GRDKLatest%
echo ##vso[task.setvariable variable=GXDKLatest;]%GXDKLatest%
echo ##vso[task.setvariable variable=INCLUDE;]%INCLUDE%
echo ##vso[task.setvariable variable=LIB;]%LIB%
echo ##vso[task.prependpath]%ADDBIN%
failOnStderr: true
- task: CMake@1
displayName: 'CMake (MSVC): Config Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-GDKX
- task: CMake@1
displayName: 'CMake (MSVC): Build Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-GDKX
- task: CMake@1
displayName: 'CMake (MSVC): Config Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release-GDKX
- task: CMake@1
displayName: 'CMake (MSVC): Build Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Release-GDKX

View File

@ -1,229 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library with Xbox extensions using CMake.
schedules:
- cron: "0 4 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
pr:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
drafts: false
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: VS_GENERATOR
value: 'Visual Studio 16 2019'
- name: WIN10_SDK
value: '10.0.19041.0'
- name: EXTRACTED_FOLDER
value: '$(ExtractedFolder)'
- name: URL_FEED
value: $(ADOFeedURL)
- name: GameDKLatest
value: '$(ExtractedFolder)\Microsoft.gdk.xbox.$(GDK_EDITION)\native\$(GDK_EDITION)\'
- name: skipNugetSecurityAnalysis
value: true # We explicitly call this task so we don't need it to be auto-injected
pool:
vmImage: windows-2019
jobs:
- job: CMAKE_BUILD
displayName: CMake using VS Generator
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_SCARLETT=ON -DBUILD_SAMPLE=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Release (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (ClangCl): Config x64 (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -T clangcl -B out2
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_SCARLETT=ON -DBUILD_SAMPLE=OFF
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Debug (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out2 -v --config Debug
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Release (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out2 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 (Xbox One)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out3
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_XBOXONE=ON -DBUILD_SAMPLE=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out3 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Release (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out3 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (ClangCl): Config x64 (Xbox One)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -T clangcl -B out4
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_XBOXONE=ON -DBUILD_SAMPLE=OFF
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Debug (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out4 -v --config Debug
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Release (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out4 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (DLL): Config x64 (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out5
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_SCARLETT=ON -DBUILD_SAMPLE=OFF
-DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Debug (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out5 -v --config Debug
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Release (Xbox Series X|S)'
inputs:
cwd: ''
cmakeArgs: --build out5 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (DLL): Config x64 (Xbox One)'
inputs:
cwd: ''
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out6
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_XBOX_EXTS_XBOXONE=ON -DBUILD_SAMPLE=OFF
-DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Debug (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out6 -v --config Debug
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Release (Xbox One)'
inputs:
cwd: ''
cmakeArgs: --build out6 -v --config RelWithDebInfo

View File

@ -1,321 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library using CMake with VS Generator (GitHub Actions covers Ninja).
schedules:
- cron: "0 5 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
pr:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
drafts: false
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
- repository: vcpkgRepo
name: Microsoft/vcpkg
type: github
endpoint: microsoft
ref: refs/tags/$(VCPKG_TAG)
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: VCPKG_ROOT
value: '$(Build.SourcesDirectory)/vcpkg'
- name: VCPKG_CMAKE_DIR
value: '$(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake'
- name: VCPKG_MANIFEST_DIR
value: '$(Build.SourcesDirectory)/build'
- name: VS_GENERATOR
value: 'Visual Studio 16 2019'
- name: WIN10_SDK
value: '10.0.19041.0'
- name: WIN11_SDK
value: '10.0.22000.0'
pool:
vmImage: windows-2019
jobs:
- job: CMAKE_BUILD
displayName: CMake using VS Generator
steps:
- checkout: self
clean: true
fetchTags: false
- task: CMake@1
displayName: 'CMake (MSVC): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (MSVC): Config x86'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A Win32 -B out2
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build x86 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Build x86 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (UWP): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out3
-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=10.0
- task: CMake@1
displayName: 'CMake (UWP): Build x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out3 -v
- task: CMake@1
displayName: 'CMake (ClangCl): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -T clangcl -B out4
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out4 -v --config Debug
- task: CMake@1
displayName: 'CMake (ClangCl): Build x64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out4 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (Win10): Config'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out5
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=ON
- task: CMake@1
displayName: 'CMake (Win10): Build'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out5 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC Spectre): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out6
-DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=OFF
- task: CMake@1
displayName: 'CMake (MSVC Spectre): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out6 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC Spectre): Build x64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out6 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (Win10 Spectre): Config'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out7
-DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
-DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=ON
- task: CMake@1
displayName: 'CMake (Win10 Spectre): Build'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out7 -v --config Debug
- task: CMake@1
displayName: 'CMake (NO_WCHAR_T): Config'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out8
-DNO_WCHAR_T=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
-DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)
-DBUILD_DX12=ON
- task: CMake@1
displayName: 'CMake (NO_WCHAR_T): Build'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out8 -v --config Debug
- task: CMake@1
displayName: 'CMake (DLL): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out9
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DBUILD_DX12=ON
-DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out9 -v --config Debug
- task: CMake@1
displayName: 'CMake (DLL): Build x64 Release'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out9 -v --config RelWithDebInfo
- task: CMake@1
displayName: 'CMake (UWP DLL): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out10
-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=10.0
-DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (UWP DLL): Build x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out10 -v
- job: CMAKE_BUILD_VCPKG
displayName: CMake using VCPKG
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: vcpkgRepo
displayName: Fetch VCPKG
clean: true
fetchTags: false
fetchDepth: 1
path: 's/vcpkg'
- task: CmdLine@2
displayName: VCPKG Bootstrap
inputs:
script: call bootstrap-vcpkg.bat
workingDirectory: $(VCPKG_ROOT)
- task: CmdLine@2
displayName: VCPKG install packages
inputs:
script: call vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x64-windows
workingDirectory: $(VCPKG_ROOT)
- task: CMake@1
displayName: 'CMake (MSVC): Config x64'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-windows
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 w/ OpenEXR'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out2 -DENABLE_OPENEXR_SUPPORT=ON -DBUILD_TESTING=OFF -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-windows
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug w/ OpenEXR'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 w/ libjpeg'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out3 -DENABLE_LIBJPEG_SUPPORT=ON -DBUILD_TESTING=OFF -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-windows
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug w/ libjpeg'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out3 -v --config Debug
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 w/ libpng'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out4 -DENABLE_LIBPNG_SUPPORT=ON -DBUILD_TESTING=OFF -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-windows
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Debug w/ libpng'
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out4 -v --config Debug

View File

@ -1,154 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library for Windows Desktop and UWP.
schedules:
- cron: "0 3 * * *"
displayName: 'Nightly build'
branches:
include:
- main
# GitHub Actions handles MSBuild for CI/PR
trigger: none
pr:
branches:
include:
- main
paths:
include:
- '.azuredevops/pipelines/DirectXTex-GitHub-Dev17.yml'
- DirectXTex/Shaders/CompileShaders.cmd
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
Codeql.Enabled: false
pool:
vmImage: windows-2022
jobs:
- job: DESKTOP_BUILD
displayName: 'Windows Desktop'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
strategy:
maxParallel: 3
matrix:
Release_arm64:
BuildPlatform: ARM64
BuildConfiguration: Release
SpectreMitigation: false
Debug_arm64:
BuildPlatform: ARM64
BuildConfiguration: Debug
SpectreMitigation: false
Release_x64:
BuildPlatform: x64
BuildConfiguration: Release
SpectreMitigation: false
Debug_x64:
BuildPlatform: x64
BuildConfiguration: Debug
SpectreMitigation: false
Release_x86:
BuildPlatform: x86
BuildConfiguration: Release
SpectreMitigation: false
Debug_x86:
BuildPlatform: x86
BuildConfiguration: Debug
SpectreMitigation: false
Release_arm64_SpectreMitigated:
BuildPlatform: ARM64
BuildConfiguration: Release
SpectreMitigation: 'Spectre'
Debug_arm64_SpectreMitigated:
BuildPlatform: ARM64
BuildConfiguration: Debug
SpectreMitigation: 'Spectre'
Release_x64_SpectreMitigated:
BuildPlatform: x64
BuildConfiguration: Release
SpectreMitigation: 'Spectre'
Debug_x64_SpectreMitigated:
BuildPlatform: x64
BuildConfiguration: Debug
SpectreMitigation: 'Spectre'
Release_x86_SpectreMitigated:
BuildPlatform: x86
BuildConfiguration: Release
SpectreMitigation: 'Spectre'
Debug_x86_SpectreMitigated:
BuildPlatform: x86
BuildConfiguration: Debug
SpectreMitigation: 'Spectre'
steps:
- checkout: self
clean: true
fetchTags: false
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022.sln
inputs:
solution: DirectXTex_Desktop_2022.sln
msbuildArgs: /p:PreferredToolArchitecture=x64 /p:SpectreMitigation=$(SpectreMitigation)
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArchitecture: x64
condition: ne(variables['BuildPlatform'], 'ARM64')
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022_Win10.sln
inputs:
solution: DirectXTex_Desktop_2022_Win10.sln
msbuildArgs: /p:PreferredToolArchitecture=x64 /p:SpectreMitigation=$(SpectreMitigation)
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArchitecture: x64
- job: UWP_BUILD
displayName: 'Universal Windows Platform (UWP)'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
strategy:
maxParallel: 3
matrix:
Release_arm64:
BuildPlatform: ARM64
BuildConfiguration: Release
Debug_arm64:
BuildPlatform: ARM64
BuildConfiguration: Debug
Release_x64:
BuildPlatform: x64
BuildConfiguration: Release
Debug_x64:
BuildPlatform: x64
BuildConfiguration: Debug
Release_x86:
BuildPlatform: x86
BuildConfiguration: Release
Debug_x86:
BuildPlatform: x86
BuildConfiguration: Debug
steps:
- checkout: self
clean: true
fetchTags: false
- task: VSBuild@1
displayName: Build solution DirectXTex_Windows10_2022.sln
inputs:
solution: DirectXTex_Windows10_2022.sln
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArchitecture: x64

View File

@ -1,359 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library using the Microsoft GDK.
schedules:
- cron: "30 3 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger: none
pr:
branches:
include:
- main
paths:
include:
- '.azuredevops/pipelines/DirectXTex-GitHub-GDK-Dev17.yml'
- '.azuredevops/templates/DirectXTex-build-gdk.yml'
- CMakeList.txt
- build/*.in
- build/*.cmake
- build/SetupBWOI.*
- DirectXTex/Shaders/CompileShaders.cmd
- Auxiliary/*Xbox*
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
trigger: none
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
pool:
vmImage: windows-2022
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: EXTRACTED_FOLDER
value: '$(ExtractedFolder)'
- name: GDKEnableBWOI
value: true
- name: URL_FEED
value: $(ADOFeedURL)
- name: VC_PATH
value: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC'
- name: skipNugetSecurityAnalysis
value: true # We explicitly call this task so we don't need it to be auto-injected
jobs:
- job: BUILD_GDK
displayName: 'Microsoft Game Development Kit (GDK)'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CopyFiles@2
displayName: Set up Directory.Build.props
inputs:
SourceFolder: build
Contents: 'Directory.Build.props'
TargetFolder: $(Build.SourcesDirectory)
- task: MSBuild@1
displayName: Setup BWOI VCTargets
inputs:
solution: build/SetupBWOI.targets
msbuildVersion: 17.0
msbuildArchitecture: x64
msbuildArguments: /p:GDKEditionNumber=$(GDK_EDITION)
- template: '/.azuredevops/templates/DirectXTex-build-gdk.yml'
parameters:
msVersion: '17.0'
vsYear: 2022
- job: BUILD_GDK_CMAKE_SCAR
displayName: 'Microsoft Game Development Kit (GDK) using CMake (Scarlett)'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CmdLine@2
displayName: Setup BWOI for GDK command-line
inputs:
script: |
call "$(VC_PATH)\Auxiliary\Build\vcvars64.bat"
echo ##vso[task.setvariable variable=WindowsSdkVerBinPath;]%WindowsSdkVerBinPath%
echo ##vso[task.prependpath]%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
echo ##vso[task.prependpath]%VCINSTALLDIR%Tools\Llvm\x64\bin
echo ##vso[task.prependpath]%WindowsSdkBinPath%x64
echo ##vso[task.prependpath]%WindowsSdkVerBinPath%x64
echo ##vso[task.prependpath]%VCToolsInstallDir%bin\HostX64\x64
call $(Build.SourcesDirectory)\build\SetupBWOI.cmd $(EXTRACTED_FOLDER) $(GDK_EDITION) Scarlett
echo ##vso[task.setvariable variable=GameDKLatest;]%GameDKLatest%
echo ##vso[task.setvariable variable=GRDKLatest;]%GRDKLatest%
echo ##vso[task.setvariable variable=GXDKLatest;]%GXDKLatest%
echo ##vso[task.setvariable variable=INCLUDE;]%INCLUDE%
echo ##vso[task.setvariable variable=LIB;]%LIB%
echo ##vso[task.prependpath]%ADDBIN%
failOnStderr: true
- task: CMake@1
displayName: 'CMake (MSVC): Config Scarlett Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-Scarlett
- task: CMake@1
displayName: 'CMake (MSVC): Build Scarlett Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-Scarlett
- task: CMake@1
displayName: 'CMake (MSVC): Config Scarlett Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release-Scarlett
- task: CMake@1
displayName: 'CMake (MSVC): Build Scarlett Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Release-Scarlett
- task: CMake@1
displayName: 'CMake (Clang): Config Scarlett Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-Scarlett-Clang
- task: CMake@1
displayName: 'CMake (Clang): Build Scarlett Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-Scarlett-Clang
- task: CMake@1
displayName: 'CMake (Clang): Config Scarlett Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release-Scarlett-Clang
- task: CMake@1
displayName: 'CMake (Clang): Build Scarlett Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Release-Scarlett-Clang
- task: DeleteFiles@1
inputs:
Contents: 'out/build'
- task: CMake@1
displayName: 'CMake (DLL): Config Scarlett Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-Scarlett -DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (DLL): Build Scarlett Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-Scarlett
- job: BUILD_GDK_CMAKE_XBONE
displayName: 'Microsoft Game Development Kit (GDK) using CMake (XboxOne)'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CmdLine@2
displayName: Setup BWOI for GDK command-line
inputs:
script: |
call "$(VC_PATH)\Auxiliary\Build\vcvars64.bat"
echo ##vso[task.setvariable variable=WindowsSdkVerBinPath;]%WindowsSdkVerBinPath%
echo ##vso[task.prependpath]%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
echo ##vso[task.prependpath]%VCINSTALLDIR%Tools\Llvm\x64\bin
echo ##vso[task.prependpath]%WindowsSdkBinPath%x64
echo ##vso[task.prependpath]%WindowsSdkVerBinPath%x64
echo ##vso[task.prependpath]%VCToolsInstallDir%bin\HostX64\x64
call $(Build.SourcesDirectory)\build\SetupBWOI.cmd $(EXTRACTED_FOLDER) $(GDK_EDITION) XboxOne
echo ##vso[task.setvariable variable=GameDKLatest;]%GameDKLatest%
echo ##vso[task.setvariable variable=GRDKLatest;]%GRDKLatest%
echo ##vso[task.setvariable variable=GXDKLatest;]%GXDKLatest%
echo ##vso[task.setvariable variable=INCLUDE;]%INCLUDE%
echo ##vso[task.setvariable variable=LIB;]%LIB%
echo ##vso[task.prependpath]%ADDBIN%
failOnStderr: true
- task: CMake@1
displayName: 'CMake (MSVC): Config XboxOne Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-XboxOne
- task: CMake@1
displayName: 'CMake (MSVC): Build XboxOne Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-XboxOne
- task: CMake@1
displayName: 'CMake (MSVC): Config XboxOne Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release-XboxOne
- task: CMake@1
displayName: 'CMake (MSVC): Build XboxOne Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Release-XboxOne
- task: CMake@1
displayName: 'CMake (Clang): Config XboxOne Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-XboxOne-Clang
- task: CMake@1
displayName: 'CMake (Clang): Build XboxOne Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-XboxOne-Clang
- task: CMake@1
displayName: 'CMake (Clang): Config XboxOne Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release-XboxOne-Clang
- task: CMake@1
displayName: 'CMake (Clang): Build XboxOne Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Release-XboxOne-Clang
- task: DeleteFiles@1
inputs:
Contents: 'out/build'
- task: CMake@1
displayName: 'CMake (DLL): Config XboxOne Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-XboxOne -DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (DLL): Build XboxOne Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-XboxOne

View File

@ -1,138 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library using the Microsoft GDK.
# NOTE: We use x64 MSBuild for the GDK as the NuGets don't include 32-bit support to avoid cross-arch dependencies.
schedules:
- cron: "30 3 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- CMake*
- '.github/**'
- '.nuget/*'
- build/*.cmake
- build/*.cmd
- build/*.in
- build/*.json
- build/*.ps1
pr:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- CMake*
- '.github/**'
- '.nuget/*'
- build/*.cmake
- build/*.cmd
- build/*.in
- build/*.json
- build/*.ps1
drafts: false
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
pool:
vmImage: windows-2019
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: EXTRACTED_FOLDER
value: '$(ExtractedFolder)'
- name: GDKEnableBWOI
value: true
- name: URL_FEED
value: $(ADOFeedURL)
- name: skipNugetSecurityAnalysis
value: true # We explicitly call this task so we don't need it to be auto-injected
jobs:
- job: BUILD_GDK
displayName: 'Microsoft Game Development Kit (GDK)'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CopyFiles@2
displayName: Set up Directory.Build.props
inputs:
SourceFolder: build
Contents: 'Directory.Build.props'
TargetFolder: $(Build.SourcesDirectory)
- task: MSBuild@1
displayName: Setup BWOI VCTargets
inputs:
solution: build/SetupBWOI.targets
msbuildVersion: 16.0
msbuildArchitecture: x64
msbuildArguments: /p:GDKEditionNumber=$(GDK_EDITION)
- template: '/.azuredevops/templates/DirectXTex-build-gdk.yml'
parameters:
msVersion: '16.0'
vsYear: 2019

View File

@ -1,354 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library and test suite using the MinGW compiler.
schedules:
- cron: "0 5 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
pr:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
drafts: false
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
- repository: vcpkgRepo
name: Microsoft/vcpkg
type: github
endpoint: microsoft
ref: refs/tags/$(VCPKG_TAG)
- repository: testRepo
name: walbourn/directxtextest
type: github
endpoint: microsoft
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
pool:
vmImage: windows-2022
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: VCPKG_ROOT
value: '$(Build.SourcesDirectory)/vcpkg'
- name: VCPKG_CMAKE_DIR
value: '$(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake'
- name: VCPKG_MANIFEST_DIR
value: '$(Build.SourcesDirectory)/build'
- name: WIN11_SDK
value: '10.0.22000.0'
- name: BASE_URL
value: https://github.com/brechtsanders/winlibs_mingw/releases/download
- name: URL_MINGW32
value: $(BASE_URL)/12.2.0-14.0.6-10.0.0-ucrt-r2/winlibs-i686-posix-dwarf-gcc-12.2.0-llvm-14.0.6-mingw-w64ucrt-10.0.0-r2.zip
- name: HASH_MINGW32
value: 'fcd1e11b896190da01c83d5b5fb0d37b7c61585e53446c2dab0009debc3915e757213882c35e35396329338de6f0222ba012e23a5af86932db45186a225d1272'
- name: CompileShadersOutput
value: '$(Build.BinariesDirectory)\Shaders'
jobs:
- job: MINGW32_BUILD
displayName: 'Minimalist GNU for Windows (MinGW32)'
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: vcpkgRepo
displayName: Fetch VCPKG
clean: true
fetchTags: false
fetchDepth: 1
path: 's/vcpkg'
- task: CmdLine@2
displayName: VCPKG Bootstrap
inputs:
script: |
call bootstrap-vcpkg.bat
echo ##vso[task.setvariable variable=VCPKG_DEFAULT_TRIPLET;]x86-mingw-static
echo ##vso[task.setvariable variable=VCPKG_DEFAULT_HOST_TRIPLET;]x86-mingw-static
workingDirectory: $(Build.SourcesDirectory)\vcpkg
- task: PowerShell@2
displayName: Install MinGW32 and setup for Windows 11 SDK
inputs:
targetType: inline
script: |
$ProgressPreference = 'SilentlyContinue'
Write-Host "Downloading winlibs..."
Invoke-WebRequest -Uri "$(URL_MINGW32)" -OutFile "gw32.zip"
Write-Host "Downloaded."
$fileHash = Get-FileHash -Algorithm SHA512 gw32.zip | ForEach { $_.Hash} | Out-String
$filehash = $fileHash.Trim()
Write-Host "##[debug]SHA512: " $fileHash
if ($fileHash -ne '$(HASH_MINGW32)') {
Write-Error -Message "##[error]Computed hash does not match!" -ErrorAction Stop
}
Write-Host "Extracting winlibs..."
Expand-Archive -LiteralPath 'gw32.zip'
Write-Host "Extracted."
Write-Host "Added to path: $env:BUILD_SOURCESDIRECTORY\gw32\mingw32\bin"
Write-Host "##vso[task.prependpath]$env:BUILD_SOURCESDIRECTORY\gw32\mingw32\bin"
$sdkroot = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots' | Select-Object -ExpandProperty KitsRoot10
$wsdkbin = "{0}bin\" -f $sdkroot
$wsdkverbin = "{0}bin\$(WIN11_SDK)\" -f $sdkroot
$wsdkarchbin = "{0}bin\$(WIN11_SDK)\x86" -f $sdkroot
if (Test-Path "$wsdkarchbin") {
Write-Host "##vso[task.setvariable variable=WindowsSdkBinPath;]$wsdkbin"
Write-Host "##vso[task.setvariable variable=WindowsSdkVerBinPath;]$wsdkverbin"
Write-Host "##vso[task.prependpath]$wsdkarchbin"
}
else {
Write-Error -Message "##[error]Can't find Windows SDK ($(WIN11_SDK))" -ErrorAction Stop
}
workingDirectory: $(Build.SourcesDirectory)
- task: CmdLine@2
displayName: GCC version
inputs:
script: g++ --version
- task: BatchScript@1
displayName: CompileShaders
inputs:
filename: DirectXTex/Shaders/CompileShaders.cmd
workingFolder: $(Build.SourcesDirectory)\DirectXTex\Shaders
- task: BatchScript@1
displayName: HLSL
inputs:
filename: DDSView/hlsl.cmd
workingFolder: $(Build.SourcesDirectory)\DDSView
- task: CmdLine@2
displayName: VCPKG install packages
inputs:
script: call vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x86-mingw-static
workingDirectory: $(VCPKG_ROOT)
- task: CMake@1
displayName: CMake (MinGW32)
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out -DCMAKE_BUILD_TYPE="Debug" -DDIRECTX_ARCH=x86
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DUSE_PREBUILT_SHADERS=ON -DCOMPILED_SHADERS=$(CompileShadersOutput)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x86-mingw-static
- task: CMake@1
displayName: CMake (MinGW32) Build
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out
- task: CMake@1
displayName: CMake (MinGW32) w/ OpenEXR
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out2 -DCMAKE_BUILD_TYPE="Debug" -DENABLE_OPENEXR_SUPPORT=ON -DDIRECTX_ARCH=x86
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DUSE_PREBUILT_SHADERS=ON -DCOMPILED_SHADERS=$(CompileShadersOutput)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x86-mingw-static
- task: CMake@1
displayName: CMake (MinGW32) Build w/ OpenEXR
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2
- task: CMake@1
displayName: CMake (MinGW32) w/ libjpeg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out3 -DCMAKE_BUILD_TYPE="Debug" -DENABLE_LIBJPEG_SUPPORT=ON -DDIRECTX_ARCH=x86
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DUSE_PREBUILT_SHADERS=ON -DCOMPILED_SHADERS=$(CompileShadersOutput)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x86-mingw-static
- task: CMake@1
displayName: CMake (MinGW32) Build w/ libjpeg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out3
- task: CMake@1
displayName: CMake (MinGW32) w/ libpng
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out4 -DCMAKE_BUILD_TYPE="Debug" -DENABLE_LIBPNG_SUPPORT=ON -DDIRECTX_ARCH=x86
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DUSE_PREBUILT_SHADERS=ON -DCOMPILED_SHADERS=$(CompileShadersOutput)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x86-mingw-static
- task: CMake@1
displayName: CMake (MinGW32) Build w/ libpng
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out4
- job: MINGW64_BUILD
displayName: 'Minimalist GNU for Windows (MinGW-W64) BUILD_TESTING=ON'
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: vcpkgRepo
displayName: Fetch VCPKG
clean: true
fetchTags: false
fetchDepth: 1
path: 's/vcpkg'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: CmdLine@2
displayName: VCPKG Bootstrap
inputs:
script: |
call bootstrap-vcpkg.bat
echo ##vso[task.setvariable variable=VCPKG_DEFAULT_TRIPLET;]x64-mingw-static
echo ##vso[task.setvariable variable=VCPKG_DEFAULT_HOST_TRIPLET;]x64-mingw-static
workingDirectory: $(Build.SourcesDirectory)\vcpkg
- task: PowerShell@2
displayName: Setup for Shader Compilation
inputs:
targetType: inline
script: |
$ProgressPreference = 'SilentlyContinue'
$sdkroot = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots' | Select-Object -ExpandProperty KitsRoot10
$wsdkbin = "{0}bin\" -f $sdkroot
$wsdkverbin = "{0}bin\$(WIN11_SDK)\" -f $sdkroot
$wsdkarchbin = "{0}bin\$(WIN11_SDK)\x64" -f $sdkroot
if (Test-Path "$wsdkarchbin") {
Write-Host "##vso[task.setvariable variable=WindowsSdkBinPath;]$wsdkbin"
Write-Host "##vso[task.setvariable variable=WindowsSdkVerBinPath;]$wsdkverbin"
Write-Host "##vso[task.prependpath]$wsdkarchbin"
}
else {
Write-Error -Message "##[error]Can't find Windows SDK ($(WIN11_SDK))" -ErrorAction Stop
}
- task: CmdLine@2
displayName: GCC version
inputs:
script: g++ --version
- task: BatchScript@1
displayName: CompileShaders.cmd
inputs:
filename: DirectXTex/Shaders/CompileShaders.cmd
workingFolder: $(Build.SourcesDirectory)\DirectXTex\Shaders
- task: BatchScript@1
displayName: HLSL
inputs:
filename: DDSView/hlsl.cmd
workingFolder: $(Build.SourcesDirectory)\DDSView
- task: CmdLine@2
displayName: VCPKG install packages
inputs:
script: call vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x64-mingw-static
workingDirectory: $(VCPKG_ROOT)
- task: CMake@1
displayName: CMake (MinGW-W64)
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out -DCMAKE_BUILD_TYPE="Debug" -DDIRECTX_ARCH=x64
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DUSE_PREBUILT_SHADERS=ON -DCOMPILED_SHADERS=$(CompileShadersOutput)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-mingw-static
- task: CMake@1
displayName: CMake (MinGW-W64) Build
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out
- task: CMake@1
displayName: CMake (MinGW-W64) w/ OpenEXR
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out2 -DCMAKE_BUILD_TYPE="Debug" -DENABLE_OPENEXR_SUPPORT=ON -DDIRECTX_ARCH=x64 -DBUILD_TESTING=OFF
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DUSE_PREBUILT_SHADERS=ON -DCOMPILED_SHADERS=$(CompileShadersOutput)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-mingw-static
- task: CMake@1
displayName: CMake (MinGW-W64) Build w/ OpenEXR
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2
- task: CMake@1
displayName: CMake (MinGW-W64) w/ libjpeg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out3 -DCMAKE_BUILD_TYPE="Debug" -DENABLE_LIBJPEG_SUPPORT=ON -DDIRECTX_ARCH=x64 -DBUILD_TESTING=OFF
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DUSE_PREBUILT_SHADERS=ON -DCOMPILED_SHADERS=$(CompileShadersOutput)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-mingw-static
- task: CMake@1
displayName: CMake (MinGW-W64) Build w/ libjpeg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out3
- task: CMake@1
displayName: CMake (MinGW-W64) w/ libpng
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out4 -DCMAKE_BUILD_TYPE="Debug" -DENABLE_LIBPNG_SUPPORT=ON -DDIRECTX_ARCH=x64 -DBUILD_TESTING=OFF
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DUSE_PREBUILT_SHADERS=ON -DCOMPILED_SHADERS=$(CompileShadersOutput)
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-mingw-static
- task: CMake@1
displayName: CMake (MinGW-W64) Build w/ libpng
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out4

View File

@ -1,157 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library using the latest prerelease of the Windows SDK from nuget.org.
schedules:
- cron: "0 3 * * 6"
displayName: 'Saturday night build'
branches:
include:
- main
always: true
trigger: none
pr: none
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: EXTRACTED_FOLDER
value: $(ExtractedFolder)
- name: WSDKEnableBWOI
value: true
- name: URL_FEED
value: $(ADOFeedURL)
- name: skipNugetSecurityAnalysis
value: true # We explicitly call this task so we don't need it to be auto-injected
pool:
vmImage: windows-2022
jobs:
- job: DESKTOP_BUILD
displayName: 'Windows Desktop'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet Install WSDK x64
inputs:
command: custom
arguments: install -prerelease Microsoft.Windows.SDK.CPP.x64 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet Install WSDK x86
inputs:
command: custom
arguments: install -prerelease Microsoft.Windows.SDK.CPP.x86 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet Install WSDK arm64
inputs:
command: custom
arguments: install -prerelease Microsoft.Windows.SDK.CPP.arm64 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CopyFiles@2
displayName: Set up Directory.Build.props
inputs:
SourceFolder: build
Contents: 'Directory.Build.props'
TargetFolder: $(Build.SourcesDirectory)
- template: '/.azuredevops/templates/DirectXTex-build-win32.yml'
- job: UWP_BUILD
displayName: 'Universal Windows Platform (UWP)'
timeoutInMinutes: 240
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
displayName: NuGet set package source to ADO feed
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet Install WSDK x64
inputs:
command: custom
arguments: install -prerelease Microsoft.Windows.SDK.CPP.x64 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet Install WSDK x86
inputs:
command: custom
arguments: install -prerelease Microsoft.Windows.SDK.CPP.x86 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet Install WSDK arm64
inputs:
command: custom
arguments: install -prerelease Microsoft.Windows.SDK.CPP.arm64 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CopyFiles@2
displayName: Set up Directory.Build.props
inputs:
SourceFolder: build
Contents: 'Directory.Build.props'
TargetFolder: $(Build.SourcesDirectory)
- template: '/.azuredevops/templates/DirectXTex-build-uwp.yml'

View File

@ -1,157 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library using the latest release of the Windows SDK from nuget.org.
schedules:
- cron: "0 3 * * 0"
displayName: 'Sunday night build'
branches:
include:
- main
always: true
trigger: none
pr: none
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: EXTRACTED_FOLDER
value: $(ExtractedFolder)
- name: WSDKEnableBWOI
value: true
- name: URL_FEED
value: $(ADOFeedURL)
- name: skipNugetSecurityAnalysis
value: true # We explicitly call this task so we don't need it to be auto-injected
pool:
vmImage: windows-2022
jobs:
- job: DESKTOP_BUILD
displayName: 'Windows Desktop'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
# We have to use a nuget.config to provide the feed for the 'nuget install' option.
displayName: 'NuGet set package source to ADO feed'
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet Install WSDK x64
inputs:
command: custom
arguments: install Microsoft.Windows.SDK.CPP.x64 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet Install WSDK x86
inputs:
command: custom
arguments: install Microsoft.Windows.SDK.CPP.x86 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet Install WSDK arm64
inputs:
command: custom
arguments: install Microsoft.Windows.SDK.CPP.arm64 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CopyFiles@2
displayName: Set up Directory.Build.props
inputs:
SourceFolder: build
Contents: 'Directory.Build.props'
TargetFolder: $(Build.SourcesDirectory)
- template: '/.azuredevops/templates/DirectXTex-build-win32.yml'
- job: UWP_BUILD
displayName: 'Universal Windows Platform (UWP)'
timeoutInMinutes: 240
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
displayName: 'Create nuget.config with single source'
inputs:
targetType: inline
script: |
$xml = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
'@
$xml | Set-Content -Path "$(Build.SourcesDirectory)\NuGet.config"
- task: NuGetCommand@2
displayName: NuGet set package source to ADO feed
inputs:
command: custom
arguments: sources add -Name xboxgdk -Source $(URL_FEED) -ConfigFile $(Build.SourcesDirectory)\NuGet.config
- task: nuget-security-analysis@0
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet Install WSDK x64
inputs:
command: custom
arguments: install Microsoft.Windows.SDK.CPP.x64 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet Install WSDK x86
inputs:
command: custom
arguments: install Microsoft.Windows.SDK.CPP.x86 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet Install WSDK arm64
inputs:
command: custom
arguments: install Microsoft.Windows.SDK.CPP.arm64 -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: CopyFiles@2
displayName: Set up Directory.Build.props
inputs:
SourceFolder: build
Contents: 'Directory.Build.props'
TargetFolder: $(Build.SourcesDirectory)
- template: '/.azuredevops/templates/DirectXTex-build-uwp.yml'

View File

@ -1,300 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library and test suite.
schedules:
- cron: "30 3 * * *"
displayName: 'Nightly build'
branches:
include:
- main
# GitHub Actions handles test suite for CI/PR
trigger: none
pr:
branches:
include:
- main
paths:
include:
- '.azuredevops/pipelines/DirectXTex-GitHub-Test-Dev17.yml'
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
- repository: testRepo
name: walbourn/directxtextest
type: github
endpoint: microsoft
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
pool:
vmImage: windows-2022
variables:
Codeql.Enabled: false
VC_PATH: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC'
GUID_FEED: $(ADOFeedGUID)
jobs:
- job: DESKTOP_BUILD
displayName: 'Windows Desktop'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
strategy:
maxParallel: 3
matrix:
Release_arm64:
BuildPlatform: ARM64
BuildConfiguration: Release
Debug_arm64:
BuildPlatform: ARM64
BuildConfiguration: Debug
Release_x64:
BuildPlatform: x64
BuildConfiguration: Release
Debug_x64:
BuildPlatform: x64
BuildConfiguration: Debug
Release_x86:
BuildPlatform: x86
BuildConfiguration: Release
Debug_x86:
BuildPlatform: x86
BuildConfiguration: Debug
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: NuGetCommand@2
displayName: NuGet restore tests
inputs:
solution: Tests/DirectXTex_Tests_Desktop_2022.sln
feedRestore: $(GUID_FEED)
includeNuGetOrg: false
- task: VSBuild@1
displayName: Build solution DirectXTex_Tests_Desktop_2022.sln
inputs:
solution: Tests/DirectXTex_Tests_Desktop_2022.sln
vsVersion: 17.0
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArchitecture: x64
condition: ne(variables['BuildPlatform'], 'ARM64')
- task: VSBuild@1
displayName: Build solution DirectXTex_Tests_Desktop_2022_Win10.sln
inputs:
solution: Tests/DirectXTex_Tests_Desktop_2022_Win10.sln
vsVersion: 17.0
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArchitecture: x64
- job: CMAKE_BUILD_X64
displayName: 'CMake for X64 BUILD_TESTING=ON'
timeoutInMinutes: 120
workspace:
clean: all
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: CmdLine@2
displayName: Setup environment for CMake to use VS
inputs:
script: |
call "$(VC_PATH)\Auxiliary\Build\vcvars64.bat"
echo ##vso[task.setvariable variable=WindowsSdkVerBinPath;]%WindowsSdkVerBinPath%
echo ##vso[task.prependpath]%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
echo ##vso[task.prependpath]%VCINSTALLDIR%Tools\Llvm\x64\bin
echo ##vso[task.prependpath]%WindowsSdkBinPath%x64
echo ##vso[task.prependpath]%WindowsSdkVerBinPath%x64
echo ##vso[task.prependpath]%VCToolsInstallDir%bin\Hostx64\x64
echo ##vso[task.setvariable variable=EXTERNAL_INCLUDE;]%EXTERNAL_INCLUDE%
echo ##vso[task.setvariable variable=INCLUDE;]%INCLUDE%
echo ##vso[task.setvariable variable=LIB;]%LIB%
- task: CMake@1
displayName: CMake (MSVC; x64-Debug) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug
- task: CMake@1
displayName: CMake (MSVC; x64-Debug) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/x64-Debug -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (MSVC; x64-Release) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release
- task: CMake@1
displayName: CMake (MSVC; x64-Release) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/x64-Release -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (clang/LLVM; x64-Debug) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-Clang
- task: CMake@1
displayName: CMake (clang/LLVM; x64-Debug) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/x64-Debug-Clang -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (clang/LLVM; x64-Release) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release-Clang
- task: CMake@1
displayName: CMake (clang/LLVM; x64-Release) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/x64-Release-Clang -v
- job: CMAKE_BUILD_ARM64
displayName: 'CMake for ARM64 BUILD_TESTING=ON'
timeoutInMinutes: 120
workspace:
clean: all
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: CmdLine@2
displayName: Setup environment for CMake to use VS
inputs:
script: |
call "$(VC_PATH)\Auxiliary\Build\vcvarsamd64_arm64.bat"
echo ##vso[task.setvariable variable=WindowsSdkVerBinPath;]%WindowsSdkVerBinPath%
echo ##vso[task.prependpath]%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
echo ##vso[task.prependpath]%VCINSTALLDIR%Tools\Llvm\x64\bin
echo ##vso[task.prependpath]%WindowsSdkBinPath%x64
echo ##vso[task.prependpath]%WindowsSdkVerBinPath%x64
echo ##vso[task.prependpath]%VCToolsInstallDir%bin\Hostx64\arm64
echo ##vso[task.setvariable variable=EXTERNAL_INCLUDE;]%EXTERNAL_INCLUDE%
echo ##vso[task.setvariable variable=INCLUDE;]%INCLUDE%
echo ##vso[task.setvariable variable=LIB;]%LIB%
- task: CMake@1
displayName: CMake (MSVC; arm64-Debug) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=arm64-Debug
- task: CMake@1
displayName: CMake (MSVC; arm64-Debug) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/arm64-Debug -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (MSVC; arm64-Release) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=arm64-Release
- task: CMake@1
displayName: CMake (MSVC; arm64-Release) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/arm64-Release -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (clang/LLVM; arm64-Debug) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=arm64-Debug-Clang
- task: CMake@1
displayName: CMake (clang/LLVM; arm64-Debug) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/arm64-Debug-Clang -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (clang/LLVM; arm64-Release) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=arm64-Release-Clang
- task: CMake@1
displayName: CMake (clang/LLVM; arm64-Release) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/arm64-Release-Clang -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (MSVC; arm64ec-Debug) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=arm64ec-Debug
- task: CMake@1
displayName: CMake (MSVC; arm64ec-Debug) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/arm64ec-Debug -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (MSVC; arm64ec-Release) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=arm64ec-Release
- task: CMake@1
displayName: CMake (MSVC; arm64ec-Release) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/arm64ec-Release -v

View File

@ -1,187 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library and test suite.
schedules:
- cron: "30 3 * * *"
displayName: 'Nightly build'
branches:
include:
- main
# GitHub Actions handles test suite for CI/PR
trigger: none
pr:
branches:
include:
- main
paths:
include:
- '.azuredevops/pipelines/DirectXTex-GitHub-Test.yml'
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
- repository: testRepo
name: walbourn/directxtextest
type: github
endpoint: microsoft
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
pool:
vmImage: windows-2019
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: VC_PATH
value: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC'
- name: GUID_FEED
value: $(ADOFeedGUID)
jobs:
- job: DESKTOP_BUILD
displayName: 'Windows Desktop'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
strategy:
maxParallel: 2
matrix:
Release_x64:
BuildPlatform: x64
BuildConfiguration: Release
Debug_x64:
BuildPlatform: x64
BuildConfiguration: Debug
Release_x86:
BuildPlatform: x86
BuildConfiguration: Release
Debug_x86:
BuildPlatform: x86
BuildConfiguration: Debug
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: NuGetCommand@2
displayName: NuGet restore tests
inputs:
solution: Tests/DirectXTex_Tests_Desktop_2019.sln
feedRestore: $(GUID_FEED)
includeNuGetOrg: false
- task: VSBuild@1
displayName: Build solution DirectXTex_Tests_Desktop_2019.sln
inputs:
solution: Tests/DirectXTex_Tests_Desktop_2019.sln
vsVersion: 16.0
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: VSBuild@1
displayName: Build solution DirectXTex_Tests_Desktop_2019_Win10.sln
inputs:
solution: Tests/DirectXTex_Tests_Desktop_2019_Win10.sln
vsVersion: 16.0
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- job: CMAKE_BUILD_X64
displayName: 'CMake for X64 BUILD_TESTING=ON'
timeoutInMinutes: 120
workspace:
clean: all
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: CmdLine@2
displayName: Setup environment for CMake to use VS
inputs:
script: |
call "$(VC_PATH)\Auxiliary\Build\vcvars64.bat"
echo ##vso[task.setvariable variable=WindowsSdkVerBinPath;]%WindowsSdkVerBinPath%
echo ##vso[task.prependpath]%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
echo ##vso[task.prependpath]%VCINSTALLDIR%Tools\Llvm\x64\bin
echo ##vso[task.prependpath]%WindowsSdkBinPath%x64
echo ##vso[task.prependpath]%WindowsSdkVerBinPath%x64
echo ##vso[task.prependpath]%VCToolsInstallDir%bin\Hostx64\x64
echo ##vso[task.setvariable variable=EXTERNAL_INCLUDE;]%EXTERNAL_INCLUDE%
echo ##vso[task.setvariable variable=INCLUDE;]%INCLUDE%
echo ##vso[task.setvariable variable=LIB;]%LIB%
- task: CMake@1
displayName: CMake (MSVC; x64-Debug) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug
- task: CMake@1
displayName: CMake (MSVC; x64-Debug) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/x64-Debug -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (MSVC; x64-Release) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release
- task: CMake@1
displayName: CMake (MSVC; x64-Release) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/x64-Release -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (clang/LLVM; x64-Debug) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-Clang
- task: CMake@1
displayName: CMake (clang/LLVM; x64-Debug) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/x64-Debug-Clang -v
- task: DeleteFiles@1
inputs:
Contents: 'out'
- task: CMake@1
displayName: CMake (clang/LLVM; x64-Release) Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Release-Clang
- task: CMake@1
displayName: CMake (clang/LLVM; x64-Release) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/x64-Release-Clang -v

View File

@ -1,171 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library and test suite using MSBuild+VCPKO
schedules:
- cron: "0 5 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
pr:
branches:
include:
- main
paths:
exclude:
- '*.md'
- LICENSE
- '.github/**'
- '.nuget/*'
- build/*.cmd
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
drafts: false
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
- repository: vcpkgRepo
name: Microsoft/vcpkg
type: github
endpoint: microsoft
ref: refs/tags/$(VCPKG_TAG)
- repository: testRepo
name: walbourn/directxtextest
type: github
endpoint: microsoft
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
pool:
vmImage: windows-2022
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: VCPKG_ROOT
value: '$(Build.SourcesDirectory)/vcpkg'
- name: VCPKG_CMAKE_DIR
value: '$(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake'
- name: VCPKG_MANIFEST_DIR
value: '$(Build.SourcesDirectory)/build'
jobs:
- job: VCPKG_BUILD
displayName: 'Build with MSBuild+VCPKG'
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: vcpkgRepo
displayName: Fetch VCPKG
clean: true
fetchTags: false
fetchDepth: 1
path: 's/vcpkg'
- task: CmdLine@2
displayName: VCPKG Bootstrap
inputs:
script: |
call bootstrap-vcpkg.bat
echo ##vso[task.setvariable variable=VCPKG_DEFAULT_TRIPLET;]x64-windows
echo ##vso[task.setvariable variable=VCPKG_DEFAULT_HOST_TRIPLET;]x64-windows
workingDirectory: $(Build.SourcesDirectory)\vcpkg
- task: CmdLine@2
displayName: VCPKG install packages
inputs:
script: |
call vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x64-windows
call vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x86-windows
call vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=arm64-windows
workingDirectory: $(VCPKG_ROOT)
- task: PowerShell@2
displayName: Setup VCPKG Directory.Build.props and .target files
inputs:
targetType: inline
script: |
$props = "<Project>`n <Import Project=`"`$(MSBuildThisFileDirectory)vcpkg\scripts\buildsystems\msbuild\vcpkg.props`" />`n</Project>`n"
$targets = "<Project>`n <Import Project=`"`$(MSBuildThisFileDirectory)vcpkg\scripts\buildsystems\msbuild\vcpkg.targets`" />`n</Project>`n"
Set-Content -Path "Directory.Build.props" -Value $props
Set-Content -Path "Directory.Build.targets" -Value $targets
workingDirectory: $(Build.SourcesDirectory)
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022_Win10.sln 32dbg
inputs:
solution: DirectXTex_Desktop_2022_Win10.sln
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: x86
configuration: Debug
msbuildArchitecture: x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022_Win10.sln 32rel
inputs:
solution: DirectXTex_Desktop_2022_Win10.sln
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: x86
configuration: Release
msbuildArchitecture: x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022_Win10.sln 64dbg
inputs:
solution: DirectXTex_Desktop_2022_Win10.sln
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: x64
configuration: Debug
msbuildArchitecture: x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022_Win10.sln 64rel
inputs:
solution: DirectXTex_Desktop_2022_Win10.sln
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: x64
configuration: Release
msbuildArchitecture: x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022_Win10.sln arm64dbg
inputs:
solution: DirectXTex_Desktop_2022_Win10.sln
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: ARM64
configuration: Debug
msbuildArchitecture: x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022_Win10.sln arm64rel
inputs:
solution: DirectXTex_Desktop_2022_Win10.sln
msbuildArgs: /p:PreferredToolArchitecture=x64
platform: ARM64
configuration: Release
msbuildArchitecture: x64

View File

@ -1,267 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library for Windows Subsystem for Linux (WSL)
schedules:
- cron: "0 3 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger: none
pr:
branches:
include:
- main
paths:
include:
- '.azuredevops/pipelines/DirectXTex-GitHub-WSL-11.yml'
- CMake*
- build/*.cmake
- build/*.in
- Auxiliary/*EXR*
- Auxiliary/*JPEG*
- Auxiliary/*PNG*
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
trigger: none
- repository: dxHeadersRepo
name: Microsoft/DirectX-Headers
type: github
endpoint: microsoft
ref: refs/heads/main
- repository: dxMathRepo
name: Microsoft/DirectXMath
type: github
endpoint: microsoft
ref: refs/heads/main
- repository: vcpkgRepo
name: Microsoft/vcpkg
type: github
endpoint: microsoft
ref: refs/tags/$(VCPKG_TAG)
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
pool:
vmImage: ubuntu-22.04
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: VCPKG_ROOT
value: '$(Build.SourcesDirectory)/vcpkg'
- name: VCPKG_CMAKE_DIR
value: '$(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake'
- name: VCPKG_MANIFEST_DIR
value: '$(Build.SourcesDirectory)/build'
- name: LOCAL_PKG_DIR
value: '$(Agent.BuildDirectory)/install/'
- name: SAL_URL
value: https://raw.githubusercontent.com/dotnet/runtime/v8.0.1/src/coreclr/pal/inc/rt/sal.h
- name: SAL_HASH
value: 0f5a80b97564217db2ba3e4624cc9eb308e19cc9911dae21d983c4ab37003f4756473297ba81b386c498514cedc1ef5a3553d7002edc09aeb6a1335df973095f
jobs:
- job: BUILD_WSL
displayName: 'Windows Subsystem for Linux (WSL)'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: dxHeadersRepo
displayName: Fetch DirectX-Headers
clean: true
fetchTags: false
fetchDepth: 1
path: 's/DirectX-Headers'
- checkout: dxMathRepo
displayName: Fetch DirectX-Math
clean: true
fetchTags: false
fetchDepth: 1
path: 's/DirectXMath'
- task: CMake@1
displayName: CMake DirectX-Headers
inputs:
cwd: DirectX-Headers
cmakeArgs: >
. -DDXHEADERS_BUILD_TEST=OFF -DDXHEADERS_BUILD_GOOGLE_TEST=OFF
-DCMAKE_INSTALL_PREFIX=$(LOCAL_PKG_DIR)
- task: CMake@1
displayName: CMake DirectX-Headers (Build)
inputs:
cwd: DirectX-Headers
cmakeArgs: --build . -v
- task: CMake@1
displayName: CMake DirectX-Headers (Install)
inputs:
cwd: DirectX-Headers
cmakeArgs: --install .
- task: CMake@1
displayName: CMake DirectXMath
inputs:
cwd: DirectXMath
cmakeArgs: . -DCMAKE_INSTALL_PREFIX=$(LOCAL_PKG_DIR)
- task: CMake@1
displayName: CMake DirectXMath (Build)
inputs:
cwd: DirectXMath
cmakeArgs: --build . -v
- task: CMake@1
displayName: CMake DirectXMath (Install)
inputs:
cwd: DirectXMath
cmakeArgs: --install .
- task: PowerShell@2
displayName: Fetch SAL.H
inputs:
targetType: inline
script: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri "$(SAL_URL)" -OutFile $(LOCAL_PKG_DIR)/include/sal.h
$fileHash = Get-FileHash -Algorithm SHA512 $(LOCAL_PKG_DIR)/include/sal.h | ForEach { $_.Hash} | Out-String
$filehash = $fileHash.Trim()
Write-Host "##[debug]SHA512: " $filehash
if ($fileHash -ne "$(SAL_HASH)") {
Write-Error -Message "##[error]Computed hash does not match!" -ErrorAction Stop
}
- task: CMake@1
displayName: CMake DirectXTex (Config) dbg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out -DCMAKE_BUILD_TYPE=Debug
-DCMAKE_PREFIX_PATH=$(LOCAL_PKG_DIR)/share;$(LOCAL_PKG_DIR)/cmake
- task: CMake@1
displayName: CMake DirectXTex (Build) dbg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v
- task: CMake@1
displayName: CMake DirectXTex (Config) rel
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out2 -DCMAKE_BUILD_TYPE=Release
-DCMAKE_PREFIX_PATH=$(LOCAL_PKG_DIR)/share;$(LOCAL_PKG_DIR)/cmake
- task: CMake@1
displayName: CMake DirectXTex (Build) rel
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v
- job: BUILD_WSL_VCPKG
displayName: 'Windows Subsystem for Linux (WSL) using VCPKG'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: vcpkgRepo
displayName: Fetch VCPKG
clean: true
fetchTags: false
fetchDepth: 1
path: 's/vcpkg'
- task: Bash@3
displayName: VCPKG Bootstrap
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/vcpkg/bootstrap-vcpkg.sh
workingDirectory: $(Build.SourcesDirectory)/vcpkg
- task: CmdLine@2
displayName: GCC and CMake version
inputs:
script: |
g++ --version
cmake --version
- task: CmdLine@2
displayName: VCPKG install packages
inputs:
script: vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x64-linux
workingDirectory: $(VCPKG_ROOT)
- task: CMake@1
displayName: CMake DirectXTex (Config) dbg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out -DCMAKE_BUILD_TYPE=Debug -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) dbg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v
- task: CMake@1
displayName: CMake DirectXTex (Config) rel
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out2 -DCMAKE_BUILD_TYPE=Release -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) rel
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v
- task: CMake@1
displayName: CMake DirectXTex (Config) w/ OpenEXR
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out3 -DCMAKE_BUILD_TYPE=Debug -DENABLE_OPENEXR_SUPPORT=ON -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) w/ OpenEXR
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out3 -v
- task: CMake@1
displayName: CMake DirectXTex (Config) w/ libjpeg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out4 -DCMAKE_BUILD_TYPE=Debug -DENABLE_LIBJPEG_SUPPORT=ON -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) w/ libjpeg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out4 -v
- task: CMake@1
displayName: CMake DirectXTex (Config) w/ libpng
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out5 -DCMAKE_BUILD_TYPE=Debug -DENABLE_LIBPNG_SUPPORT=ON -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) w/ libpng
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out5 -v

View File

@ -1,267 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library for Windows Subsystem for Linux (WSL)
schedules:
- cron: "0 3 * * *"
displayName: 'Nightly build'
branches:
include:
- main
trigger: none
pr:
branches:
include:
- main
paths:
include:
- '.azuredevops/pipelines/DirectXTex-GitHub-WSL-13.yml'
- CMake*
- build/*.cmake
- build/*.in
- Auxiliary/*EXR*
- Auxiliary/*JPEG*
- Auxiliary/*PNG*
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
trigger: none
- repository: dxHeadersRepo
name: Microsoft/DirectX-Headers
type: github
endpoint: microsoft
ref: refs/heads/main
- repository: dxMathRepo
name: Microsoft/DirectXMath
type: github
endpoint: microsoft
ref: refs/heads/main
- repository: vcpkgRepo
name: Microsoft/vcpkg
type: github
endpoint: microsoft
ref: refs/tags/$(VCPKG_TAG)
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
pool:
vmImage: ubuntu-24.04
variables:
- group: dxtex-shared-variables
- name: Codeql.Enabled
value: false
- name: VCPKG_ROOT
value: '$(Build.SourcesDirectory)/vcpkg'
- name: VCPKG_CMAKE_DIR
value: '$(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake'
- name: VCPKG_MANIFEST_DIR
value: '$(Build.SourcesDirectory)/build'
- name: LOCAL_PKG_DIR
value: '$(Agent.BuildDirectory)/install/'
- name: SAL_URL
value: https://raw.githubusercontent.com/dotnet/runtime/v8.0.1/src/coreclr/pal/inc/rt/sal.h
- name: SAL_HASH
value: 0f5a80b97564217db2ba3e4624cc9eb308e19cc9911dae21d983c4ab37003f4756473297ba81b386c498514cedc1ef5a3553d7002edc09aeb6a1335df973095f
jobs:
- job: BUILD_WSL
displayName: 'Windows Subsystem for Linux (WSL)'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: dxHeadersRepo
displayName: Fetch DirectX-Headers
clean: true
fetchTags: false
fetchDepth: 1
path: 's/DirectX-Headers'
- checkout: dxMathRepo
displayName: Fetch DirectX-Math
clean: true
fetchTags: false
fetchDepth: 1
path: 's/DirectXMath'
- task: CMake@1
displayName: CMake DirectX-Headers
inputs:
cwd: DirectX-Headers
cmakeArgs: >
. -DDXHEADERS_BUILD_TEST=OFF -DDXHEADERS_BUILD_GOOGLE_TEST=OFF
-DCMAKE_INSTALL_PREFIX=$(LOCAL_PKG_DIR)
- task: CMake@1
displayName: CMake DirectX-Headers (Build)
inputs:
cwd: DirectX-Headers
cmakeArgs: --build . -v
- task: CMake@1
displayName: CMake DirectX-Headers (Install)
inputs:
cwd: DirectX-Headers
cmakeArgs: --install .
- task: CMake@1
displayName: CMake DirectXMath
inputs:
cwd: DirectXMath
cmakeArgs: . -DCMAKE_INSTALL_PREFIX=$(LOCAL_PKG_DIR)
- task: CMake@1
displayName: CMake DirectXMath (Build)
inputs:
cwd: DirectXMath
cmakeArgs: --build . -v
- task: CMake@1
displayName: CMake DirectXMath (Install)
inputs:
cwd: DirectXMath
cmakeArgs: --install .
- task: PowerShell@2
displayName: Fetch SAL.H
inputs:
targetType: inline
script: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri "$(SAL_URL)" -OutFile $(LOCAL_PKG_DIR)/include/sal.h
$fileHash = Get-FileHash -Algorithm SHA512 $(LOCAL_PKG_DIR)/include/sal.h | ForEach { $_.Hash} | Out-String
$filehash = $fileHash.Trim()
Write-Host "##[debug]SHA512: " $filehash
if ($fileHash -ne "$(SAL_HASH)") {
Write-Error -Message "##[error]Computed hash does not match!" -ErrorAction Stop
}
- task: CMake@1
displayName: CMake DirectXTex (Config) dbg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out -DCMAKE_BUILD_TYPE=Debug
-DCMAKE_PREFIX_PATH=$(LOCAL_PKG_DIR)/share;$(LOCAL_PKG_DIR)/cmake
- task: CMake@1
displayName: CMake DirectXTex (Build) dbg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v
- task: CMake@1
displayName: CMake DirectXTex (Config) rel
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out2 -DCMAKE_BUILD_TYPE=Release
-DCMAKE_PREFIX_PATH=$(LOCAL_PKG_DIR)/share;$(LOCAL_PKG_DIR)/cmake
- task: CMake@1
displayName: CMake DirectXTex (Build) rel
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v
- job: BUILD_WSL_VCPKG
displayName: 'Windows Subsystem for Linux (WSL) using VCPKG'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: vcpkgRepo
displayName: Fetch VCPKG
clean: true
fetchTags: false
fetchDepth: 1
path: 's/vcpkg'
- task: Bash@3
displayName: VCPKG Bootstrap
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/vcpkg/bootstrap-vcpkg.sh
workingDirectory: $(Build.SourcesDirectory)/vcpkg
- task: CmdLine@2
displayName: GCC and CMake version
inputs:
script: |
g++ --version
cmake --version
- task: CmdLine@2
displayName: VCPKG install packages
inputs:
script: vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x64-linux
workingDirectory: $(VCPKG_ROOT)
- task: CMake@1
displayName: CMake DirectXTex (Config) dbg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out -DCMAKE_BUILD_TYPE=Debug -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) dbg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out -v
- task: CMake@1
displayName: CMake DirectXTex (Config) rel
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out2 -DCMAKE_BUILD_TYPE=Release -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) rel
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out2 -v
- task: CMake@1
displayName: CMake DirectXTex (Config) w/ OpenEXR
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out3 -DCMAKE_BUILD_TYPE=Debug -DENABLE_OPENEXR_SUPPORT=ON -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) w/ OpenEXR
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out3 -v
- task: CMake@1
displayName: CMake DirectXTex (Config) w/ libjpeg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out4 -DCMAKE_BUILD_TYPE=Debug -DENABLE_LIBJPEG_SUPPORT=ON -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) w/ libjpeg
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out4 -v
- task: CMake@1
displayName: CMake DirectXTex (Config) w/ libpng
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out5 -DCMAKE_BUILD_TYPE=Debug -DENABLE_LIBPNG_SUPPORT=ON -DDIRECTX_ARCH=x64
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)"
-DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-linux
- task: CMake@1
displayName: CMake DirectXTex (Build) w/ libpng
inputs:
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out5 -v

View File

@ -1,97 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library for Windows Desktop.
schedules:
- cron: "5 3 * * *"
displayName: 'Nightly build'
branches:
include:
- main
# GitHub Actions handles MSBuild for CI/PR
trigger: none
pr:
branches:
include:
- main
paths:
include:
- '.azuredevops/pipelines/DirectXTex-GitHub.yml'
- DirectXTex/Shaders/CompileShaders.cmd
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
Codeql.Enabled: false
pool:
vmImage: windows-2019
jobs:
- job: DESKTOP_BUILD
displayName: 'Windows Desktop'
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
strategy:
maxParallel: 2
matrix:
Release_x64:
BuildPlatform: x64
BuildConfiguration: Release
SpectreMitigation: false
Debug_x64:
BuildPlatform: x64
BuildConfiguration: Debug
SpectreMitigation: false
Release_x86:
BuildPlatform: x86
BuildConfiguration: Release
SpectreMitigation: false
Debug_x86:
BuildPlatform: x86
BuildConfiguration: Debug
SpectreMitigation: false
Release_x64_SpectreMitigated:
BuildPlatform: x64
BuildConfiguration: Release
SpectreMitigation: 'Spectre'
Debug_x64_SpectreMitigated:
BuildPlatform: x64
BuildConfiguration: Debug
SpectreMitigation: 'Spectre'
Release_x86_SpectreMitigated:
BuildPlatform: x86
BuildConfiguration: Release
SpectreMitigation: 'Spectre'
Debug_x86_SpectreMitigated:
BuildPlatform: x86
BuildConfiguration: Debug
SpectreMitigation: 'Spectre'
steps:
- checkout: self
clean: true
fetchTags: false
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019.sln
inputs:
solution: DirectXTex_Desktop_2019.sln
msbuildArgs: /p:PreferredToolArchitecture=x64 /p:SpectreMitigation=$(SpectreMitigation)
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019_Win10.sln
inputs:
solution: DirectXTex_Desktop_2019_Win10.sln
msbuildArgs: /p:PreferredToolArchitecture=x64 /p:SpectreMitigation=$(SpectreMitigation)
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'

View File

@ -1,92 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# OneFuzz code coverage pipeline
pr: none
trigger: none
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
- repository: testRepo
name: walbourn/directxtextest
type: github
endpoint: microsoft
ref: refs/heads/main
pool:
vmImage: windows-latest
parameters:
- name: sasUrl
type: string
displayName: SAS URL
- name: branch
type: string
displayName: Branch
- name: jobID
type: string
displayName: OneFuzz Job ID
- name: buildDate
type: string
displayName: Build Date
- name: commitID
type: string
displayName: Commit ID
variables:
- name: coverage-file
value: cobertura-coverage.xml
- name: job-ID
value: ${{ parameters.jobID }}
- name: build-date
value: ${{ parameters.buildDate }}
- name: branch
value: ${{ parameters.branch }}
- name: sas-url
value: ${{ parameters.sasUrl }}
- name: commit-ID
value: ${{ parameters.commitID }}
jobs:
- job: prod
displayName: Prod Task
workspace:
clean: all
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- powershell: |
Write-Host "Job ID: $(job-ID), Build Date: $(build-date), Branch: $(branch)"
$SASUrl = [System.Uri]::new("$(sas-url)")
azcopy cp $SASUrl.AbsoluteUri ./ --recursive
$ContainerName = $SASURL.LocalPath.Split("/")[1]
Write-Host "##vso[task.setvariable variable=container-name;]$ContainerName"
cd $ContainerName
$size = ((Get-Item .\$(coverage-file)).length)
if ($size -eq 0) {
Write-Host "Cobertura coverage XML is empty."
exit 1
}
displayName: 'Get code coverage from OneFuzz'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: ./$(container-name)\$(coverage-file)
pathToSources: $(Build.SourcesDirectory)
displayName: 'Generate coverage report'

View File

@ -1,152 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
# Builds the library using CMake and submit for file fuzzing
schedules:
- cron: "0 12 1 * *"
displayName: 'Submit for File Fuzzing (Monthly)'
branches:
include:
- main
always: true
trigger: none
pr: none
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
- repository: testRepo
name: walbourn/directxtextest
type: github
endpoint: microsoft
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
Codeql.Enabled: false
VS_GENERATOR: 'Visual Studio 17 2022'
WIN11_SDK: '10.0.22000.0'
pool:
vmImage: windows-2022
jobs:
- job: FUZZ_BUILD
displayName: 'Build for file fuzzing'
steps:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: CMake@1
displayName: 'CMake (MSVC): Config with ASan'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out
-DCMAKE_SYSTEM_VERSION=$(WIN11_SDK) -DBUILD_TOOLS=OFF -DBUILD_SAMPLE=OFF
-DBUILD_FUZZING=ON -DBUILD_TESTING=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build with ASan'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out -v --config RelWithDebInfo
- task: CopyFiles@2
displayName: Copy fuzzer
inputs:
Contents: |
build\OneFuzzConfig.json
out\bin\RelWithDebInfo\fuzzloaders.exe
TargetFolder: .drop
OverWrite: true
flattenFolders: true
- task: CopyFiles@2
displayName: Copy symbols
inputs:
Contents: |
out\bin\RelWithDebInfo\fuzzloaders.pdb
TargetFolder: .drop\symbols
OverWrite: true
flattenFolders: true
- task: PowerShell@2
displayName: Download seed files
inputs:
targetType: inline
script: |
$seedfiles = "AlphaEdge.dds",
"cubea8r8g8b8.dds",
"default_texture_nm.dds",
"dx5_logo.dds",
"hdrtest.dds",
"normalmap.dds",
"grad4d.hdr",
"grad4dunc.hdr",
"BigTree.hdr",
"CBW8.TGA",
"ccm8.tga",
"CTC16.TGA",
"CTC24.TGA",
"CTC32.TGA",
"UTC16.TGA",
"UTC24.TGA",
"UTC32.TGA",
"UBW8.TGA",
"ucm8.tga",
"testimg.ppm",
"grad4d.pfm",
"grad4d.phm",
"grad4d_mono.pfm",
"grad4d_mono.phm";
New-Item -ItemType Directory -Force -Path .drop\seeds\
foreach($filename in $seedfiles)
{
Write-Host "Fetching: $filename"
$url = "https://raw.githubusercontent.com/walbourn/directxtexmedia/main/" + $filename
$target = [System.IO.Path]::Combine(".drop\seeds\", $filename)
Invoke-WebRequest -Uri $url -OutFile $target
}
- task: PowerShell@2
displayName: Copy OneFuzz setup script
inputs:
targetType: 'inline'
script: |
Copy-Item -Path .\build\onefuzz-setup.ps1 -Destination .drop/setup.ps1
- task: MSBuild@1
displayName: 'Copy ASan binaries'
inputs:
solution: build/CopyASAN.targets
msbuildArguments: /p:TargetFolder=$(Build.SourcesDirectory)\.drop
msbuildVersion: 17.0
msbuildArchitecture: x64
- task: PowerShell@2
displayName: List drop files
inputs:
targetType: inline
script: |
Get-ChildItem ".drop" -Recurse | select FullName
- task: onefuzz-task@0
displayName: 'Submit to OneFuzz'
inputs:
onefuzzOSes: 'Windows'
env:
onefuzzDropDirectory: $(Build.SourcesDirectory)\.drop
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

View File

@ -1,201 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Runs various SDL recommended tools on the code.
schedules:
- cron: "0 3 * * 0,3,5"
displayName: 'Three times a week'
branches:
include:
- main
always: true
# GitHub Actions handles CodeQL and PREFAST for CI/PR
trigger: none
pr:
branches:
include:
- main
paths:
include:
- '.azuredevops/pipelines/DirectXTex-SDL.yml'
resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
Codeql.Enabled: true
Codeql.Language: cpp
VC_PATH: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC'
VS_GENERATOR: 'Visual Studio 17 2022'
pool:
vmImage: windows-2022
jobs:
- job: SDL_BUILD
displayName: 'Build using required SDL tools'
workspace:
clean: all
steps:
- checkout: self
clean: true
fetchTags: false
- task: NodeTool@0
displayName: 'NPM install'
inputs:
versionSpec: 14.x
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3
displayName: 'Run Credential Scanner'
inputs:
debugMode: false
folderSuppression: false
- task: PoliCheck@2
displayName: 'Run PoliCheck'
inputs:
result: PoliCheck.xml
- task: Armory@2
displayName: Run ARMory
- task: CMake@1
displayName: 'CMake (MSVC): Config x64'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out -DENABLE_SPECTRE_MITIGATION=ON
- task: CodeQL3000Init@0
inputs:
Enabled: true
- task: VSBuild@1
displayName: 'Build C++ with CodeQL'
inputs:
solution: '$(Build.SourcesDirectory)/out/DirectXTex.sln'
vsVersion: 17.0
platform: x64
configuration: Release
msbuildArchitecture: x64
- task: CodeQL3000Finalize@0
condition: always()
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out -v --config RelWithDebInfo
- task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@4
displayName: 'Run AntiMalware'
inputs:
InputType: 'Basic'
ScanType: 'CustomScan'
FileDirPath: $(Agent.BuildDirectory)
EnableSERVICEs: true
SupportLogOnError: false
TreatSignatureUpdateFailureAs: 'Warning'
SignatureFreshness: 'OneDay'
TreatStaleSignatureAs: 'Error'
condition: always()
- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@4
displayName: 'Run BinSkim'
inputs:
AnalyzeTargetBinskim: ''
AnalyzeTargetGlob: +:file|out\bin\**\RelWithDebInfo\*.exe
AnalyzeVerbose: true
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2
displayName: 'Post Analysis'
inputs:
GdnBreakAllTools: true
GdnBreakPolicy: 'Microsoft'
GdnBreakPolicyMinSev: 'Error'
- task: ComponentGovernanceComponentDetection@0
displayName: Component Detection
- job: SDL_BUILD_DLL
displayName: 'Build using required SDL tools for DLLs'
workspace:
clean: all
steps:
- checkout: self
clean: true
fetchTags: false
- task: NodeTool@0
displayName: 'NPM install'
inputs:
versionSpec: 14.x
- task: CMake@1
displayName: 'CMake (MSVC): Config x64'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: >
-G "$(VS_GENERATOR)" -A x64 -B out
-DENABLE_SPECTRE_MITIGATION=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TOOLS=OFF
- task: CMake@1
displayName: 'CMake (MSVC): Build x64 Release'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out -v --config RelWithDebInfo
- task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@4
displayName: 'Run AntiMalware'
inputs:
InputType: 'Basic'
ScanType: 'CustomScan'
FileDirPath: $(Agent.BuildDirectory)
EnableSERVICEs: true
SupportLogOnError: false
TreatSignatureUpdateFailureAs: 'Warning'
SignatureFreshness: 'OneDay'
TreatStaleSignatureAs: 'Error'
condition: always()
- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@4
displayName: 'Run BinSkim'
inputs:
AnalyzeTargetBinskim: ''
AnalyzeTargetGlob: +:file|out\bin\**\RelWithDebInfo\*.dll
AnalyzeVerbose: true
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2
displayName: 'Post Analysis'
inputs:
GdnBreakAllTools: true
GdnBreakPolicy: 'Microsoft'
GdnBreakPolicyMinSev: 'Error'
- task: ComponentGovernanceComponentDetection@0
displayName: Component Detection
- job: VC_PREFAST
displayName: 'Build using /analyze (PREFAST)'
workspace:
clean: all
steps:
- checkout: self
clean: true
fetchTags: false
- task: CmdLine@2
displayName: Setup environment for CMake to use VS
inputs:
script: |
call "$(VC_PATH)\Auxiliary\Build\vcvars64.bat"
echo ##vso[task.setvariable variable=WindowsSdkVerBinPath;]%WindowsSdkVerBinPath%
echo ##vso[task.prependpath]%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
echo ##vso[task.prependpath]%VCINSTALLDIR%Tools\Llvm\x64\bin
echo ##vso[task.prependpath]%WindowsSdkBinPath%x64
echo ##vso[task.prependpath]%WindowsSdkVerBinPath%x64
echo ##vso[task.prependpath]%VCToolsInstallDir%bin\Hostx64\x64
echo ##vso[task.setvariable variable=EXTERNAL_INCLUDE;]%EXTERNAL_INCLUDE%
echo ##vso[task.setvariable variable=INCLUDE;]%INCLUDE%
echo ##vso[task.setvariable variable=LIB;]%LIB%
- task: CMake@1
displayName: CMake Config
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug -DENABLE_CODE_ANALYSIS=ON
- task: CMake@1
displayName: CMake Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out/build/x64-Debug

View File

@ -1,20 +0,0 @@
name: approver_count
description: Approver count policy for mscodehub/DirectXTex/DirectXTex repository
resource: repository
where:
configuration:
approverCountPolicySettings:
isBlocking: true
requireMinimumApproverCount: 1
creatorVoteCounts: false
allowDownvotes: false
sourcePushOptions:
resetOnSourcePush: false
requireVoteOnLastIteration: true
requireVoteOnEachIteration: false
resetRejectionsOnSourcePush: false
blockLastPusherVote: true
branchNames:
- refs/heads/release
- refs/heads/main
displayName: mscodehub/DirectXTex/DirectXTex Approver Count Policy

View File

@ -1,120 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Template used by GitHub-GDK-* pipelines
parameters:
- name: msVersion
type: string
values:
- '16.0'
- '17.0'
- name: vsYear
type: number
values:
- 2019
- 2022
steps:
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_${{ parameters.vsYear }} pcdbg
continueOnError: true
inputs:
solution: DirectXTex_GDK_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: Gaming.Desktop.x64
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:GDKEditionNumber=$(GDK_EDITION)
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_${{ parameters.vsYear }} pcrel
continueOnError: true
inputs:
solution: DirectXTex_GDK_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: Gaming.Desktop.x64
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:GDKEditionNumber=$(GDK_EDITION)
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_${{ parameters.vsYear }} xbdbg
continueOnError: true
inputs:
solution: DirectXTex_GDK_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: Gaming.Xbox.XboxOne.x64
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:GDKEditionNumber=$(GDK_EDITION)
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_${{ parameters.vsYear }} xbrel
continueOnError: true
inputs:
solution: DirectXTex_GDK_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: Gaming.Xbox.XboxOne.x64
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:GDKEditionNumber=$(GDK_EDITION)
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_${{ parameters.vsYear }} scardbg
continueOnError: true
inputs:
solution: DirectXTex_GDK_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: Gaming.Xbox.Scarlett.x64
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:GDKEditionNumber=$(GDK_EDITION)
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_${{ parameters.vsYear }} scarrel
continueOnError: true
inputs:
solution: DirectXTex_GDK_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: Gaming.Xbox.Scarlett.x64
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:GDKEditionNumber=$(GDK_EDITION)
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_PC_${{ parameters.vsYear }} dbg
continueOnError: true
inputs:
solution: DirectXTex_GXDK_PC_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: x64
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64 /p:GDKEditionNumber=$(GDK_EDITION)
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_PC_${{ parameters.vsYear }} rel
continueOnError: true
inputs:
solution: DirectXTex_GXDK_PC_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: x64
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64 /p:GDKEditionNumber=$(GDK_EDITION)
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_PC_${{ parameters.vsYear }} scardbg
continueOnError: true
inputs:
solution: DirectXTex_GXDK_PC_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: x64
configuration: Debug_Scarlett
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64 /p:GDKEditionNumber=$(GDK_EDITION)
- task: VSBuild@1
displayName: Build solution DirectXTex_GDK_PC_${{ parameters.vsYear }} scarrel
continueOnError: true
inputs:
solution: DirectXTex_GXDK_PC_${{ parameters.vsYear }}.sln
vsVersion: ${{ parameters.msVersion }}
platform: x64
configuration: Release_Scarlett
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64 /p:GDKEditionNumber=$(GDK_EDITION)

View File

@ -1,57 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Template used by SDK-release and SDK-prerelease pipelines
steps:
- task: VSBuild@1
displayName: Build solution DirectXTex_Windows10_2022.sln 32dbg
inputs:
solution: DirectXTex_Windows10_2022.sln
platform: x86
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Windows10_2022.sln 32rel
inputs:
solution: DirectXTex_Windows10_2022.sln
platform: x86
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Windows10_2022.sln 64dbg
inputs:
solution: DirectXTex_Windows10_2022.sln
platform: x64
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Windows10_2022.sln 64rel
inputs:
solution: DirectXTex_Windows10_2022.sln
platform: x64
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
# Windows on ARM 32-bit is deprecated. https://learn.microsoft.com/windows/arm/arm32-to-arm64
- task: VSBuild@1
displayName: Build solution DirectXTex_Windows10_2022.sln arm64dbg
inputs:
solution: DirectXTex_Windows10_2022.sln
platform: ARM64
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Windows10_2022.sln arm64rel
inputs:
solution: DirectXTex_Windows10_2022.sln
platform: ARM64
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64

View File

@ -1,89 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
# Template used by SDK-release and SDK-prerelease pipelines
steps:
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019.sln 32dbg
inputs:
solution: DirectXTex_Desktop_2019.sln
platform: x86
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019.sln 32rel
inputs:
solution: DirectXTex_Desktop_2019.sln
platform: x86
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019.sln 64dbg
inputs:
solution: DirectXTex_Desktop_2019.sln
platform: x64
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019.sln 64rel
inputs:
solution: DirectXTex_Desktop_2019.sln
platform: x64
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019_Win10.sln 32dbg
inputs:
solution: DirectXTex_Desktop_2019_Win10.sln
platform: x86
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019_Win10.sln 32rel
inputs:
solution: DirectXTex_Desktop_2019_Win10.sln
platform: x86
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019_Win10.sln 64dbg
inputs:
solution: DirectXTex_Desktop_2019_Win10.sln
platform: x64
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2019_Win10.sln 64rel
inputs:
solution: DirectXTex_Desktop_2019_Win10.sln
platform: x64
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
# VS 2019 for Win32 on ARM64 is out of support.
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022_Win10.sln arm64dbg
inputs:
solution: DirectXTex_Desktop_2022_Win10.sln
platform: ARM64
configuration: Debug
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64
- task: VSBuild@1
displayName: Build solution DirectXTex_Desktop_2022_Win10.sln arm64rel
inputs:
solution: DirectXTex_Desktop_2022_Win10.sln
platform: ARM64
configuration: Release
msbuildArchitecture: x64
msbuildArgs: /p:PreferredToolArchitecture=x64

View File

@ -1,82 +1,9 @@
root = true
[*.{yml}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = crlf
charset = latin1
[*.{fx,fxh,hlsl,hlsli}]
[*.{cpp,h,inl,fx,hlsl}]
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = crlf
charset = latin1
cpp_space_before_function_open_parenthesis = remove
cpp_space_around_binary_operator = ignore
cpp_space_pointer_reference_alignment = ignore
[*.{cpp,h,hpp,inl}]
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = crlf
charset = latin1
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = false
cpp_indent_case_contents = true
cpp_indent_case_labels = false
cpp_indent_case_contents_when_block = true
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_preprocessor = one_left
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = true
cpp_new_line_before_open_brace_namespace = new_line
cpp_new_line_before_open_brace_type = new_line
cpp_new_line_before_open_brace_function = new_line
cpp_new_line_before_open_brace_block = new_line
cpp_new_line_before_open_brace_lambda = new_line
cpp_new_line_scope_braces_on_separate_lines = true
cpp_new_line_close_brace_same_line_empty_type = true
cpp_new_line_close_brace_same_line_empty_function = true
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = true
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = false
cpp_space_between_empty_parameter_list_parentheses = false
cpp_space_after_keywords_in_control_flow_statements = true
cpp_space_within_control_flow_statement_parentheses = false
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = false
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = true
cpp_space_before_constructor_colon = true
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = false
cpp_space_remove_around_unary_operator = false
cpp_space_around_binary_operator = ignore
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = ignore
cpp_space_around_ternary_operator = insert
cpp_wrap_preserve_blocks = one_liners

1
.gitattributes vendored
View File

@ -14,7 +14,6 @@
*.vcxproj eol=crlf
*.filters eol=crlf
*.sln eol=crlf
*.yml eol=crlf
# Explicitly declare resource files as binary
*.pdb binary

View File

@ -1,6 +0,0 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly

View File

@ -1,9 +0,0 @@
{
"Format": "github-actions",
"exclude": [
".git",
"LICENSE",
"Tests",
"Common/d3dx12.h"
]
}

View File

@ -1,20 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# line-length
MD013: false
# blanks-around-headings
MD022: false
# blanks-around-lists
MD032: false
# no-inline-html
MD033: false
# no-bare-urls
MD034: false
# first-line-heading
MD041: false

View File

@ -1,5 +0,0 @@
# PSScriptAnalyzerSettings.psd1
@{
Severity=@('Error','Warning')
ExcludeRules=@('PSAvoidUsingWriteHost')
}

View File

@ -1,17 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
ignore-from-file: .gitignore
extends: default
rules:
truthy:
check-keys: false
document-start: disable
line-length:
max: 160
comments:
min-spaces-from-content: 1
new-lines:
type: dos

View File

@ -1,133 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
name: 'CTest (BVTs)'
on:
push:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
pull_request:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
permissions:
contents: read
jobs:
build:
runs-on: windows-2022
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
toolver: ['14.29', '14']
build_type: [x64-Release]
arch: [amd64]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Clone test repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: walbourn/directxtextest
path: Tests
ref: main
- name: 'Install Ninja'
run: choco install ninja
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: ${{ matrix.arch }}
toolset: ${{ matrix.toolver }}
- 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"
}
- name: Get vcpkg commit hash
shell: pwsh
run: |
if ($Env:vcpkgRelease) {
echo "Using vcpkg commit from repo variable..."
$VCPKG_COMMIT_ID = $Env:vcpkgRelease
}
else {
echo "Fetching latest vcpkg commit hash..."
$commit = (git ls-remote https://github.com/microsoft/vcpkg.git HEAD | Select-String -Pattern '([a-f0-9]{40})').Matches.Value
$VCPKG_COMMIT_ID = $commit
}
Write-Host "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID"
echo "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID" >> $env:GITHUB_ENV
env:
vcpkgRelease: '${{ vars.VCPKG_COMMIT_ID }}'
- uses: lukka/run-vcpkg@7d259227a1fb6471a0253dd5ab7419835228f7d7 # v11
with:
runVcpkgInstall: true
vcpkgJsonGlob: '**/build/vcpkg.json'
vcpkgGitCommitId: '${{ env.VCPKG_COMMIT_ID }}'
- name: 'Configure CMake'
working-directory: ${{ github.workspace }}
run: >
cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=ON -DBUILD_TOOLS=OFF -DBUILD_SAMPLE=OFF -DBUILD_BVT=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 }}
run: cmake --build out\build\${{ matrix.build_type }}
- name: 'Run BVTs'
working-directory: ${{ github.workspace }}
run: ctest --preset=${{ matrix.build_type }} --output-on-failure

View File

@ -1,78 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
name: "CodeQL"
on:
push:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
pull_request:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
schedule:
- cron: '43 3 * * 3'
permissions:
contents: read
jobs:
analyze:
name: Analyze (C/C++)
runs-on: windows-latest
timeout-minutes: 360
permissions:
actions: read # for github/codeql-action/init to get workflow details
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/autobuild to send a status report
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Install Ninja'
run: choco install ninja
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
- name: Initialize CodeQL
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
with:
languages: c-cpp
build-mode: manual
- name: 'Configure CMake'
working-directory: ${{ github.workspace }}
run: cmake --preset=x64-Debug
- name: 'Build'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\x64-Debug
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
with:
category: "/language:c-cpp"

View File

@ -1,46 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
name: Lint
on:
pull_request:
branches: "main"
paths-ignore:
- LICENSE
- build/*.in
permissions: {}
jobs:
analyze:
permissions:
contents: read
packages: read
statuses: write
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Lint Code Base
uses: super-linter/super-linter@12150456a73e248bdc94d0794898f94e23127c88 # v7.4.0
env:
DEFAULT_BRANCH: origin/main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IGNORE_GITIGNORED_FILES: true
VALIDATE_ALL_CODEBASE: true
VALIDATE_CHECKOV: true
VALIDATE_EDITORCONFIG: true
VALIDATE_GITHUB_ACTIONS: true
VALIDATE_JSON: true
VALIDATE_MARKDOWN: true
VALIDATE_POWERSHELL: true
VALIDATE_GITLEAKS: true
VALIDATE_YAML: true

View File

@ -1,144 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
name: 'CMake (Windows)'
on:
push:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
pull_request:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
permissions:
contents: read
jobs:
build:
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
toolver: ['14.29', '14']
build_type: [x64-Debug, x64-Release]
arch: [amd64]
include:
- toolver: '14.29'
build_type: x86-Debug
arch: amd64_x86
- toolver: '14.29'
build_type: x86-Release
arch: amd64_x86
- toolver: '14'
build_type: x86-Debug
arch: amd64_x86
- toolver: '14'
build_type: x86-Release
arch: amd64_x86
- toolver: '14'
build_type: arm64-Debug
arch: amd64_arm64
- toolver: '14'
build_type: arm64-Release
arch: amd64_arm64
- toolver: '14'
build_type: arm64ec-Debug
arch: amd64_arm64
- toolver: '14'
build_type: arm64ec-Release
arch: amd64_arm64
- toolver: '14'
build_type: x64-Debug-Win8
arch: amd64
- toolver: '14'
build_type: x64-Release-Win8
arch: amd64
- toolver: '14'
build_type: x64-Debug-Clang
arch: amd64
- toolver: '14'
build_type: x64-Release-Clang
arch: amd64
- toolver: '14'
build_type: x86-Debug-Clang
arch: amd64_x86
- toolver: '14'
build_type: x86-Release-Clang
arch: amd64_x86
- toolver: '14'
build_type: arm64-Debug-Clang
arch: amd64_arm64
- toolver: '14'
build_type: arm64-Release-Clang
arch: amd64_arm64
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Install Ninja'
run: choco install ninja
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: ${{ matrix.arch }}
toolset: ${{ matrix.toolver }}
- name: 'Configure CMake'
working-directory: ${{ github.workspace }}
run: cmake --preset=${{ matrix.build_type }}
- name: 'Build'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\${{ matrix.build_type }}
- name: 'Clean up'
working-directory: ${{ github.workspace }}
run: Remove-Item -Path out -Recurse -Force
- if: matrix.arch != 'amd64_arm64'
name: 'Configure CMake (Spectre)'
working-directory: ${{ github.workspace }}
run: cmake --preset=${{ matrix.build_type }} -DENABLE_SPECTRE_MITIGATION=ON
- if: matrix.arch != 'amd64_arm64'
name: 'Build (Spectre)'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\${{ matrix.build_type }}
- if: matrix.arch != 'amd64_arm64'
name: 'Clean up'
working-directory: ${{ github.workspace }}
run: Remove-Item -Path out -Recurse -Force
- name: 'Configure CMake (DLL)'
working-directory: ${{ github.workspace }}
run: cmake --preset=${{ matrix.build_type }} -DBUILD_SHARED_LIBS=ON
- name: 'Build (DLL)'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\${{ matrix.build_type }}

View File

@ -1,84 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
name: MSBuild
on:
push:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*
pull_request:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*
permissions:
contents: read
jobs:
build:
runs-on: windows-2022 # has v142 tools but not v142 spectre libs
strategy:
fail-fast: false
matrix:
vs: [2019, 2022]
build_type: [Debug, Release]
platform: [x86, x64, ARM64]
exclude:
- vs: 2019
platform: ARM64
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0
- if: matrix.platform != 'ARM64'
name: Build
working-directory: ${{ github.workspace }}
run: >
msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
DirectXTex_Desktop_${{ matrix.vs }}.sln
- name: 'Build (Windows 10)'
working-directory: ${{ github.workspace }}
run: >
msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
DirectXTex_Desktop_${{ matrix.vs }}_Win10.sln
- if: matrix.vs == '2022'
name: 'Build (UWP)'
working-directory: ${{ github.workspace }}
run: >
msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
DirectXTex_Windows10_2022.sln
- if: matrix.platform != 'ARM64' && matrix.vs != '2019'
name: 'Build (Spectre)'
working-directory: ${{ github.workspace }}
run: >
msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
/p:SpectreMitigation=Spectre
DirectXTex_Desktop_${{ matrix.vs }}.sln
- if: matrix.platform != 'ARM64' && matrix.vs != '2019'
name: 'Build (Spectre Windows 10)'
working-directory: ${{ github.workspace }}
run: >
msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
/p:SpectreMitigation=Spectre
DirectXTex_Desktop_${{ matrix.vs }}_Win10.sln

View File

@ -1,88 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
name: Microsoft C++ Code Analysis
on:
push:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
pull_request:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
schedule:
- cron: '41 16 * * 1'
permissions:
contents: read
jobs:
analyze:
permissions:
contents: read
security-events: write
actions: read
name: Analyze
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: amd64
- name: Configure CMake
working-directory: ${{ github.workspace }}
run: cmake -B out -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON
- name: 'Build Shaders (BC)'
shell: cmd
working-directory: ./DirectXTex/Shaders
run: CompileShaders.cmd
env:
CompileShadersOutput: ${{ github.workspace }}/out/Shaders/Compiled
- name: 'Build Shaders (DDSVIEW)'
shell: cmd
working-directory: ./DDSView
run: hlsl.cmd
env:
CompileShadersOutput: ${{ github.workspace }}/out/Shaders/Compiled
- name: Initialize MSVC Code Analysis
uses: microsoft/msvc-code-analysis-action@24c285ab36952c9e9182f4b78dfafbac38a7e5ee # v0.1.1
id: run-analysis
with:
cmakeBuildDirectory: ./out
buildConfiguration: Debug
ruleset: NativeRecommendedRules.ruleset
# Upload SARIF file to GitHub Code Scanning Alerts
- name: Upload SARIF to GitHub
uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
with:
sarif_file: ${{ steps.run-analysis.outputs.sarif }}

View File

@ -1,188 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
name: 'CTest (Windows)'
on:
push:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
pull_request:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
env:
DIRECTXTEX_MEDIA_PATH: ${{ github.workspace }}/Media
permissions:
contents: read
jobs:
build:
runs-on: windows-2022
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
toolver: ['14.29', '14']
build_type: [x64-Debug, x64-Release]
arch: [amd64]
include:
- toolver: '14.29'
build_type: x86-Debug
arch: amd64_x86
- toolver: '14.29'
build_type: x86-Release
arch: amd64_x86
- toolver: '14'
build_type: x86-Debug
arch: amd64_x86
- toolver: '14'
build_type: x86-Release
arch: amd64_x86
- toolver: '14'
build_type: x64-Debug-Clang
arch: amd64
- toolver: '14'
build_type: x64-Release-Clang
arch: amd64
- toolver: '14'
build_type: x86-Debug-Clang
arch: amd64_x86
- toolver: '14'
build_type: x86-Release-Clang
arch: amd64_x86
- toolver: '14'
build_type: arm64-Debug
arch: amd64_arm64
- toolver: '14'
build_type: arm64-Release
arch: amd64_arm64
- toolver: '14'
build_type: arm64ec-Debug
arch: amd64_arm64
- toolver: '14'
build_type: arm64ec-Release
arch: amd64_arm64
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Clone test repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: walbourn/directxtextest
path: Tests
ref: main
- name: 'Install Ninja'
run: choco install ninja
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: ${{ matrix.arch }}
toolset: ${{ matrix.toolver }}
- 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"
}
- name: Get vcpkg commit hash
shell: pwsh
run: |
if ($Env:vcpkgRelease) {
echo "Using vcpkg commit from repo variable..."
$VCPKG_COMMIT_ID = $Env:vcpkgRelease
}
else {
echo "Fetching latest vcpkg commit hash..."
$commit = (git ls-remote https://github.com/microsoft/vcpkg.git HEAD | Select-String -Pattern '([a-f0-9]{40})').Matches.Value
$VCPKG_COMMIT_ID = $commit
}
Write-Host "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID"
echo "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID" >> $env:GITHUB_ENV
env:
vcpkgRelease: '${{ vars.VCPKG_COMMIT_ID }}'
- uses: lukka/run-vcpkg@7d259227a1fb6471a0253dd5ab7419835228f7d7 # v11
with:
runVcpkgInstall: true
vcpkgJsonGlob: '**/build/vcpkg.json'
vcpkgGitCommitId: '${{ env.VCPKG_COMMIT_ID }}'
- name: 'Configure CMake'
working-directory: ${{ github.workspace }}
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 }}
run: cmake --build out\build\${{ matrix.build_type }}
- name: 'Clean up'
working-directory: ${{ github.workspace }}
run: Remove-Item -Path out -Recurse -Force
- name: 'Configure CMake (DLL)'
working-directory: ${{ github.workspace }}
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}" -DBUILD_SHARED_LIBS=ON
- name: 'Build (DLL)'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\${{ matrix.build_type }}

View File

@ -1,96 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
name: 'CMake (UWP)'
on:
push:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
pull_request:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
permissions:
contents: read
jobs:
build:
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
build_type: [x64-Debug-UWP, x64-Release-UWP, x64-Debug-UWP-Clang, x64-Release-UWP-Clang]
arch: [amd64]
include:
- build_type: x86-Debug-UWP
arch: amd64_x86
- build_type: x86-Release-UWP
arch: amd64_x86
- build_type: x86-Debug-UWP-Clang
arch: amd64_x86
- build_type: x86-Release-UWP-Clang
arch: amd64_x86
- build_type: arm64-Debug-UWP
arch: amd64_arm64
- build_type: arm64-Release-UWP
arch: amd64_arm64
- build_type: arm64-Debug-UWP-Clang
arch: amd64_arm64
- build_type: arm64-Release-UWP-Clang
arch: amd64_arm64
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Install Ninja'
run: choco install ninja
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: ${{ matrix.arch }}
uwp: true
- name: 'Configure CMake'
working-directory: ${{ github.workspace }}
run: cmake --preset=${{ matrix.build_type }}
- name: 'Build'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\${{ matrix.build_type }}
- name: 'Clean up'
working-directory: ${{ github.workspace }}
run: Remove-Item -Path out -Recurse -Force
- name: 'Configure CMake (DLL)'
working-directory: ${{ github.workspace }}
run: cmake --preset=${{ matrix.build_type }} -DBUILD_SHARED_LIBS=ON
- name: 'Build (DLL)'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\${{ matrix.build_type }}

View File

@ -1,161 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
name: 'CMake (Windows using VCPKG)'
on:
push:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- build/*.cmd
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
pull_request:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- build/*.cmd
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
permissions:
contents: read
jobs:
build:
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
toolver: ['14.29', '14']
build_type: [x64-Debug-VCPKG]
arch: [amd64]
shared: ['OFF']
include:
- toolver: '14'
build_type: x64-Debug-Clang-VCPKG
arch: amd64
shared: 'OFF'
- toolver: '14'
build_type: x86-Debug-VCPKG
arch: amd64_x86
shared: 'OFF'
- toolver: '14'
build_type: arm64-Debug-VCPKG
arch: amd64_arm64
shared: 'OFF'
- toolver: '14'
build_type: arm64ec-Debug-VCPKG
arch: amd64_arm64
shared: 'OFF'
- toolver: '14'
build_type: x64-Debug-MinGW
arch: amd64
shared: 'OFF'
- toolver: '14'
build_type: x64-Release-MinGW
arch: amd64
shared: 'OFF'
- toolver: '14'
build_type: x64-Debug-MinGW
arch: amd64
shared: 'ON'
- toolver: '14'
build_type: x64-Release-MinGW
arch: amd64
shared: 'ON'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Install Ninja'
run: choco install ninja
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: ${{ matrix.arch }}
toolset: ${{ matrix.toolver }}
- name: 'Set triplet'
shell: pwsh
run: |
if ("${{ matrix.arch }}" -eq "amd64")
{
if ("${{ matrix.build_type }}" -match "MinGW")
{
echo "VCPKG_DEFAULT_TRIPLET=x64-mingw-static" >> $env:GITHUB_ENV
}
else
{
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"
}
- name: Get vcpkg commit hash
shell: pwsh
run: |
if ($Env:vcpkgRelease) {
echo "Using vcpkg commit from repo variable..."
$VCPKG_COMMIT_ID = $Env:vcpkgRelease
}
else {
echo "Fetching latest vcpkg commit hash..."
$commit = (git ls-remote https://github.com/microsoft/vcpkg.git HEAD | Select-String -Pattern '([a-f0-9]{40})').Matches.Value
$VCPKG_COMMIT_ID = $commit
}
Write-Host "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID"
echo "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID" >> $env:GITHUB_ENV
env:
vcpkgRelease: '${{ vars.VCPKG_COMMIT_ID }}'
- uses: lukka/run-vcpkg@7d259227a1fb6471a0253dd5ab7419835228f7d7 # v11
with:
runVcpkgInstall: true
vcpkgJsonGlob: '**/build/vcpkg.json'
vcpkgGitCommitId: '${{ env.VCPKG_COMMIT_ID }}'
- name: 'Configure CMake'
working-directory: ${{ github.workspace }}
run: >
cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=OFF
-DENABLE_OPENEXR_SUPPORT=ON -DENABLE_LIBJPEG_SUPPORT=ON -DENABLE_LIBPNG_SUPPORT=ON
-DBUILD_SHARED_LIBS=${{ matrix.shared }}
-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 }}
run: cmake --build out\build\${{ matrix.build_type }}

View File

@ -1,110 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# https://go.microsoft.com/fwlink/?LinkId=248926
name: 'CMake (WSL)'
on:
push:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
pull_request:
branches: "main"
paths-ignore:
- '*.md'
- LICENSE
- '.azuredevops/**'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.xvd
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build_type: [x64-Debug-Linux, x64-Release-Linux]
gcc: [12, 13, 14]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
- name: Get vcpkg commit hash
shell: pwsh
run: |
if ($Env:vcpkgRelease) {
echo "Using vcpkg commit from repo variable..."
$VCPKG_COMMIT_ID = $Env:vcpkgRelease
}
else {
echo "Fetching latest vcpkg commit hash..."
$commit = (git ls-remote https://github.com/microsoft/vcpkg.git HEAD | Select-String -Pattern '([a-f0-9]{40})').Matches.Value
$VCPKG_COMMIT_ID = $commit
}
Write-Host "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID"
echo "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID" >> $env:GITHUB_ENV
env:
vcpkgRelease: '${{ vars.VCPKG_COMMIT_ID }}'
- uses: lukka/run-vcpkg@7d259227a1fb6471a0253dd5ab7419835228f7d7 # v11
with:
runVcpkgInstall: true
vcpkgJsonGlob: '**/build/vcpkg.json'
vcpkgGitCommitId: '${{ env.VCPKG_COMMIT_ID }}'
- 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"
env:
CC: gcc-${{ matrix.gcc }}
CXX: g++-${{ matrix.gcc }}
- name: 'Build'
working-directory: ${{ github.workspace }}
run: cmake --build out/build/${{ matrix.build_type }}
- name: 'Clean up'
working-directory: ${{ github.workspace }}
run: rm -rf out
- name: 'Configure CMake (-shared)'
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" -DBUILD_SHARED_LIBS=ON
env:
CC: gcc-${{ matrix.gcc }}
CXX: g++-${{ matrix.gcc }}
- name: 'Build (-shared)'
working-directory: ${{ github.workspace }}
run: cmake --build out/build/${{ matrix.build_type }}

14
.gitignore vendored
View File

@ -18,24 +18,12 @@
*.VC.db
*.nupkg
.vs
[Bb]in
packages
/DDSView/Shaders/*.inc
/DDSView/Shaders/*.pdb
/DirectXTex/Shaders/Compiled/*.inc
/DirectXTex/Shaders/Compiled/*.pdb
Bin
/ipch
Debug
Durango
Gaming.Xbox.XboxOne.x64
Gaming.Xbox.Scarlett.x64
Gaming.Desktop.x64
Profile
Release
x64
/Tests
/Testing
/wiki
/out
/CMakeUserPresets.json
/build/vcpkg_installed

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.8.6">
<id>directxtex_desktop_2017</id>
<version>0.0.0-SpecifyVersionOnCommandline</version>
<title>DirectXTex Library (VS 2017/2019 Win32)</title>
<authors>Microsoft</authors>
<owners>microsoft,directxtk</owners>
<summary>DirectXTex texture processing library</summary>
<description>This version is for Windows desktop applications using Visual Studio 2017 or Visual Studio 2019 and supports Windows 7 / DirectX 11.
DirectXTex, a shared source library for reading and writing .DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes simple .TGA and .HDR readers and writers since these image file format are commonly used for texture content processing pipelines, but are not currently supported by a built-in WIC codec.</description>
<releaseNotes>Matches the June 1, 2020 release on GitHub.</releaseNotes>
<projectUrl>http://go.microsoft.com/fwlink/?LinkId=248926</projectUrl>
<icon>images\icon.jpg</icon>
<license type="expression">MIT</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<tags>DirectX DirectXTex native nativepackage</tags>
</metadata>
<files>
<file target="docs" src="Readme.*" />
<file target="include" src="DirectXTex\DirectXTex.h" />
<file target="include" src="DirectXTex\DirectXTex.inl" />
<file target="native\lib\Win32\Debug" src="DirectXTex\Bin\Desktop_2017\Win32\Debug\*.lib" />
<file target="native\lib\Win32\Debug" src="DirectXTex\Bin\Desktop_2017\Win32\Debug\*.pdb" />
<file target="native\lib\Win32\Release" src="DirectXTex\Bin\Desktop_2017\Win32\Release\*.lib" />
<file target="native\lib\Win32\Release" src="DirectXTex\Bin\Desktop_2017\Win32\Release\*.pdb" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2017\x64\Debug\*.lib" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2017\x64\Debug\*.pdb" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2017\x64\Release\*.lib" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2017\x64\Release\*.pdb" />
<file src=".nuget/directxtex_desktop_2017.targets" target="build\native" />
<file src=".nuget/icon.jpg" target="images\" />
</files>
</package>

View File

@ -4,26 +4,18 @@
<PropertyGroup Label="Debug" Condition="'$(Configuration.ToLower())' == 'debug'">
<NuGetConfiguration>Debug</NuGetConfiguration>
</PropertyGroup>
<PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' == 'profile'">
<NuGetConfiguration>Release</NuGetConfiguration>
</PropertyGroup>
<PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' == 'release'">
<NuGetConfiguration>Release</NuGetConfiguration>
</PropertyGroup>
<PropertyGroup Condition="'$(NuGetConfiguration)' == ''">
<PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' != 'debug'">
<NuGetConfiguration>Release</NuGetConfiguration>
</PropertyGroup>
<PropertyGroup>
<directxtex-LibPath>$(MSBuildThisFileDirectory)..\..\native\lib\$(PlatformTarget)\$(NuGetConfiguration)</directxtex-LibPath>
<directxtex-LibName Condition="'$(SpectreMitigation)'!='' AND '$(SpectreMitigation)'!='false'">DirectXTex_Spectre</directxtex-LibName>
<directxtex-LibName Condition="'$(directxtex-LibName)'==''">DirectXTex</directxtex-LibName>
<directxtex-LibPath>$(MSBuildThisFileDirectory)..\..\native\lib\$(Platform)\$(NuGetConfiguration)</directxtex-LibPath>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalLibraryDirectories>$(directxtex-LibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(directxtex-LibName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>DirectXTex.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>

View File

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.8.6">
<id>directxtex_desktop_2019</id>
<version>0.0.0-SpecifyVersionOnCommandline</version>
<title>DirectXTex Library (VS 2019/2022 Win32)</title>
<authors>Microsoft</authors>
<owners>microsoft,directxtk</owners>
<summary>DirectXTex texture processing library</summary>
<description>This version is for Windows desktop applications using Visual Studio 2019 (16.11) or Visual Studio 2022 on Windows 8.1 or later.
DirectXTex, a shared source library for reading and writing .DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes simple .TGA and .HDR readers and writers since these image file format are commonly used for texture content processing pipelines, but are not currently supported by a built-in WIC codec.</description>
<releaseNotes>Matches the July 9, 2025 release on GitHub.</releaseNotes>
<projectUrl>http://go.microsoft.com/fwlink/?LinkId=248926</projectUrl>
<repository type="git" url="https://github.com/microsoft/DirectXTex.git" />
<icon>images\icon.jpg</icon>
<readme>docs\README.md</readme>
<license type="expression">MIT</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
<tags>DirectX DirectXTex native nativepackage</tags>
</metadata>
<files>
<file target="docs" src="*.md" />
<file target="include" src="DirectXTex\DirectXTex.h" />
<file target="include" src="DirectXTex\DirectXTex.inl" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Desktop_2019\Win32\Debug\*.lib" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Desktop_2019\Win32\Debug\*.pdb" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Desktop_2019\Win32\DebugSpectre\*.lib" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Desktop_2019\Win32\DebugSpectre\*.pdb" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Desktop_2019\Win32\Release\*.lib" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Desktop_2019\Win32\Release\*.pdb" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Desktop_2019\Win32\ReleaseSpectre\*.lib" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Desktop_2019\Win32\ReleaseSpectre\*.pdb" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2019\x64\Debug\*.lib" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2019\x64\Debug\*.pdb" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2019\x64\DebugSpectre\*.lib" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2019\x64\DebugSpectre\*.pdb" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2019\x64\Release\*.lib" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2019\x64\Release\*.pdb" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2019\x64\ReleaseSpectre\*.lib" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2019\x64\ReleaseSpectre\*.pdb" />
<file src=".nuget/directxtex_desktop_2019.targets" target="build\native" />
<file src=".nuget/icon.jpg" target="images\" />
</files>
</package>

View File

@ -3,70 +3,50 @@
<metadata minClientVersion="2.8.6">
<id>directxtex_desktop_win10</id>
<version>0.0.0-SpecifyVersionOnCommandline</version>
<title>DirectXTex Library (VS 2022 Win32 for Windows 10/11)</title>
<title>DirectXTex Library (VS 2017/2019 Win32 for Windows 10)</title>
<authors>Microsoft</authors>
<owners>microsoft,directxtk</owners>
<summary>DirectXTex texture processing library</summary>
<description>This version is for Windows desktop applications using Visual Studio 2022 on Windows 10 / Windows 11 including both DirectX 11 and DirectX 12.
<description>This version is for Windows desktop applications using Visual Studio 2017 or Visual Studio 2019 and supports Windows 10 including both DirectX 11 and DirectX 12.
DirectXTex, a shared source library for reading and writing .DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes simple .TGA and .HDR readers and writers since these image file format are commonly used for texture content processing pipelines, but are not currently supported by a built-in WIC codec.</description>
<releaseNotes>Matches the July 9, 2025 release on GitHub.</releaseNotes>
<releaseNotes>Matches the June 1, 2020 release on GitHub.</releaseNotes>
<projectUrl>http://go.microsoft.com/fwlink/?LinkId=248926</projectUrl>
<repository type="git" url="https://github.com/microsoft/DirectXTex.git" />
<icon>images\icon.jpg</icon>
<readme>docs\README.md</readme>
<license type="expression">MIT</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
<tags>DirectX DirectXTex native nativepackage ARM64</tags>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<tags>DirectX DirectXTex native nativepackage</tags>
</metadata>
<files>
<file target="docs" src="*.md" />
<file target="docs" src="Readme.*" />
<file target="include" src="DirectXTex\DirectXTex.h" />
<file target="include" src="DirectXTex\DirectXTex.inl" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\Win32\Debug\*.lib" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\Win32\Debug\*.pdb" />
<file target="native\lib\Win32\Debug" src="DirectXTex\Bin\Desktop_2017_Win10\Win32\Debug\*.lib" />
<file target="native\lib\Win32\Debug" src="DirectXTex\Bin\Desktop_2017_Win10\Win32\Debug\*.pdb" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\Win32\DebugSpectre\*.lib" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\Win32\DebugSpectre\*.pdb" />
<file target="native\lib\Win32\Release" src="DirectXTex\Bin\Desktop_2017_Win10\Win32\Release\*.lib" />
<file target="native\lib\Win32\Release" src="DirectXTex\Bin\Desktop_2017_Win10\Win32\Release\*.pdb" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Desktop_2022_Win10\Win32\Release\*.lib" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Desktop_2022_Win10\Win32\Release\*.pdb" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2017_Win10\x64\Debug\*.lib" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2017_Win10\x64\Debug\*.pdb" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Desktop_2022_Win10\Win32\ReleaseSpectre\*.lib" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Desktop_2022_Win10\Win32\ReleaseSpectre\*.pdb" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2017_Win10\x64\Release\*.lib" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2017_Win10\x64\Release\*.pdb" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\x64\Debug\*.lib" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\x64\Debug\*.pdb" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Desktop_2017_Win10\ARM64\Debug\*.lib" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Desktop_2017_Win10\ARM64\Debug\*.pdb" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\x64\DebugSpectre\*.lib" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\x64\DebugSpectre\*.pdb" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2022_Win10\x64\Release\*.lib" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2022_Win10\x64\Release\*.pdb" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2022_Win10\x64\ReleaseSpectre\*.lib" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Desktop_2022_Win10\x64\ReleaseSpectre\*.pdb" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\ARM64\Debug\*.lib" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\ARM64\Debug\*.pdb" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\ARM64\DebugSpectre\*.lib" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Desktop_2022_Win10\ARM64\DebugSpectre\*.pdb" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Desktop_2022_Win10\ARM64\Release\*.lib" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Desktop_2022_Win10\ARM64\Release\*.pdb" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Desktop_2022_Win10\ARM64\ReleaseSpectre\*.lib" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Desktop_2022_Win10\ARM64\ReleaseSpectre\*.pdb" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Desktop_2017_Win10\ARM64\Release\*.lib" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Desktop_2017_Win10\ARM64\Release\*.pdb" />
<file src=".nuget/directxtex_desktop_win10.targets" target="build\native" />
<file src=".nuget/icon.jpg" target="images\" />
</files>
</package>
</package>

View File

@ -2,32 +2,27 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Debug" Condition="'$(Configuration.ToLower())' == 'debug'">
<NuGetConfiguration>Debug</NuGetConfiguration>
<_NuGetConfiguration>Debug</_NuGetConfiguration>
</PropertyGroup>
<PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' == 'profile'">
<NuGetConfiguration>Release</NuGetConfiguration>
<PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' != 'debug'">
<_NuGetConfiguration>Release</_NuGetConfiguration>
</PropertyGroup>
<PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' == 'release'">
<NuGetConfiguration>Release</NuGetConfiguration>
<PropertyGroup Condition="'$(PlatformTarget)' == 'x64'">
<_NuGetPlatform>x64</_NuGetPlatform>
</PropertyGroup>
<PropertyGroup Condition="'$(NuGetConfiguration)' == ''">
<NuGetConfiguration>Release</NuGetConfiguration>
<PropertyGroup Condition="'$(_NuGetPlatform)' == ''">
<_NuGetPlatform>$(Platform)</_NuGetPlatform>
</PropertyGroup>
<PropertyGroup>
<directxtex-LibPath>$(MSBuildThisFileDirectory)..\..\native\lib\$(PlatformTarget)\$(NuGetConfiguration)</directxtex-LibPath>
<directxtex-LibName Condition="'$(SpectreMitigation)'!='' AND '$(SpectreMitigation)'!='false'">DirectXTex_Spectre</directxtex-LibName>
<directxtex-LibName Condition="'$(directxtex-LibName)'==''">DirectXTex</directxtex-LibName>
</PropertyGroup>
<PropertyGroup>
<directxtex-LibPath>$(MSBuildThisFileDirectory)..\..\native\lib\$(PlatformTarget)\$(NuGetConfiguration)</directxtex-LibPath>
<directxtex-LibPath>$(MSBuildThisFileDirectory)..\..\native\lib\$(_NuGetPlatform)\$(_NuGetConfiguration)</directxtex-LibPath>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalLibraryDirectories>$(directxtex-LibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(directxtex-LibName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>DirectXTex.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
@ -38,4 +33,9 @@
</ClCompile>
</ItemDefinitionGroup>
<PropertyGroup>
<_NuGetConfiguration></_NuGetConfiguration>
<_NuGetPlatform></_NuGetPlatform>
</PropertyGroup>
</Project>

View File

@ -7,48 +7,52 @@
<authors>Microsoft</authors>
<owners>microsoft,directxtk</owners>
<summary>DirectXTex texture processing library</summary>
<description>This version is for Universal Windows Platform apps on Windows 10 / Windows 11 using Visual Studio 2022.
<description>This version is for Universal Windows Platform apps on Windows 10 using Visual Studio 2017 or Visual Studio 2019.
DirectXTex, a shared source library for reading and writing .DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes simple .TGA and .HDR readers and writers since these image file format are commonly used for texture content processing pipelines, but are not currently supported by a built-in WIC codec.</description>
<releaseNotes>Matches the July 9, 2025 release on GitHub.</releaseNotes>
<releaseNotes>Matches the June 1, 2020 release on GitHub.</releaseNotes>
<projectUrl>http://go.microsoft.com/fwlink/?LinkId=248926</projectUrl>
<repository type="git" url="https://github.com/microsoft/DirectXTex.git" />
<icon>images\icon.jpg</icon>
<readme>docs\README.md</readme>
<license type="expression">MIT</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
<tags>DirectX DirectXTex native nativepackage ARM64</tags>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<tags>DirectX DirectXTex native nativepackage</tags>
</metadata>
<files>
<file target="docs" src="*.md" />
<file target="docs" src="Readme.*" />
<file target="include" src="DirectXTex\DirectXTex.h" />
<file target="include" src="DirectXTex\DirectXTex.inl" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Windows10_2022\ARM64\Debug\*.lib" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Windows10_2022\ARM64\Debug\*.pdb" />
<file target="native\lib\ARM\Debug" src="DirectXTex\Bin\Windows10_2017\ARM\Debug\*.lib" />
<file target="native\lib\ARM\Debug" src="DirectXTex\Bin\Windows10_2017\ARM\Debug\*.pdb" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Windows10_2022\ARM64\Release\*.lib" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Windows10_2022\ARM64\Release\*.pdb" />
<file target="native\lib\ARM\Release" src="DirectXTex\Bin\Windows10_2017\ARM\Release\*.lib" />
<file target="native\lib\ARM\Release" src="DirectXTex\Bin\Windows10_2017\ARM\Release\*.pdb" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Windows10_2022\Win32\Debug\*.lib" />
<file target="native\lib\x86\Debug" src="DirectXTex\Bin\Windows10_2022\Win32\Debug\*.pdb" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Windows10_2017\ARM64\Debug\*.lib" />
<file target="native\lib\ARM64\Debug" src="DirectXTex\Bin\Windows10_2017\ARM64\Debug\*.pdb" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Windows10_2022\Win32\Release\*.lib" />
<file target="native\lib\x86\Release" src="DirectXTex\Bin\Windows10_2022\Win32\Release\*.pdb" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Windows10_2017\ARM64\Release\*.lib" />
<file target="native\lib\ARM64\Release" src="DirectXTex\Bin\Windows10_2017\ARM64\Release\*.pdb" />
<file target="native\lib\Win32\Debug" src="DirectXTex\Bin\Windows10_2017\Win32\Debug\*.lib" />
<file target="native\lib\Win32\Debug" src="DirectXTex\Bin\Windows10_2017\Win32\Debug\*.pdb" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Windows10_2022\x64\Debug\*.lib" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Windows10_2022\x64\Debug\*.pdb" />
<file target="native\lib\Win32\Release" src="DirectXTex\Bin\Windows10_2017\Win32\Release\*.lib" />
<file target="native\lib\Win32\Release" src="DirectXTex\Bin\Windows10_2017\Win32\Release\*.pdb" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Windows10_2022\x64\Release\*.lib" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Windows10_2022\x64\Release\*.pdb" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Windows10_2017\x64\Debug\*.lib" />
<file target="native\lib\x64\Debug" src="DirectXTex\Bin\Windows10_2017\x64\Debug\*.pdb" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Windows10_2017\x64\Release\*.lib" />
<file target="native\lib\x64\Release" src="DirectXTex\Bin\Windows10_2017\x64\Release\*.pdb" />
<file src=".nuget/directxtex_uwp.targets" target="build\native" />
<file src=".nuget/icon.jpg" target="images\" />
</files>
</package>
</package>

View File

@ -4,18 +4,12 @@
<PropertyGroup Label="Debug" Condition="'$(Configuration.ToLower())' == 'debug'">
<NuGetConfiguration>Debug</NuGetConfiguration>
</PropertyGroup>
<PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' == 'profile'">
<NuGetConfiguration>Release</NuGetConfiguration>
</PropertyGroup>
<PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' == 'release'">
<NuGetConfiguration>Release</NuGetConfiguration>
</PropertyGroup>
<PropertyGroup Condition="'$(NuGetConfiguration)' == ''">
<PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' != 'debug'">
<NuGetConfiguration>Release</NuGetConfiguration>
</PropertyGroup>
<PropertyGroup>
<directxtex-LibPath>$(MSBuildThisFileDirectory)..\..\native\lib\$(PlatformTarget)\$(NuGetConfiguration)</directxtex-LibPath>
<directxtex-LibPath>$(MSBuildThisFileDirectory)..\..\native\lib\$(Platform)\$(NuGetConfiguration)</directxtex-LibPath>
</PropertyGroup>
<ItemDefinitionGroup>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<SignConfigXML>
<job dest="__OUTPATHROOT__" certSubject="NuGet" jobname="NugetSigningTest">
<file src="__INPATHROOT__\directxtex_desktop_2017*.nupkg" signType="CP-401405" dest="__OUTPATHROOT__\directxtex_desktop_2017*.nupkg" />
<file src="__INPATHROOT__\directxtex_desktop_win10*.nupkg" signType="CP-401405" dest="__OUTPATHROOT__\directxtex_desktop_win10*.nupkg" />
</job>
<job certSubject="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" dest="__OUTPATHROOT__" jobname="ISS EngFun" approvers="">
<file src="__INPATHROOT__\texassemble.exe" signType="135020002" dest="__OUTPATHROOT__\texassemble.exe" />
<file src="__INPATHROOT__\texconv.exe" signType="135020002" dest="__OUTPATHROOT__\texconv.exe" />
<file src="__INPATHROOT__\texdiag.exe" signType="135020002" dest="__OUTPATHROOT__\texdiag.exe" />
</job>
</SignConfigXML>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<SignConfigXML>
<job dest="__OUTPATHROOT__" certSubject="NuGet" jobname="NugetSigningTest">
<file src="__INPATHROOT__\directxtex_uwp*.nupkg" signType="CP-401405" dest="__OUTPATHROOT__\directxtex_uwp*.nupkg" />
</job>
</SignConfigXML>

View File

@ -1,11 +1,6 @@
<#
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
#>
param(
[string]$version
)
$versionComma = $version.Replace(".", ",")
$files = 'Texassemble\texassemble.rc', 'Texconv\Texconv.rc', 'Texdiag\texdiag.rc', 'build\DirectXTex.rc.in'
$files = 'Texassemble\texassemble.rc', 'Texconv\Texconv.rc', 'Texdiag\texdiag.rc'
foreach ($file in $files) { (Get-Content $file).replace('1,0,0,0', $versionComma).replace('1.0.0.0', $version) | Set-Content $file }

View File

View File

@ -1,621 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexEXR.cpp
//
// DirectXTex Auxilary functions for using the OpenEXR library
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#include "DirectXTexP.h"
#include "DirectXTexEXR.h"
#include <DirectXPackedVector.h>
#include <cassert>
#include <cstdint>
#include <exception>
#include <memory>
#include <stdexcept>
#include <string>
#include <tuple>
//
// Requires the OpenEXR library <http://www.openexr.com/> and its dependencies.
//
#ifdef __clang__
#pragma clang diagnostic ignored "-Wswitch-enum"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#pragma clang diagnostic ignored "-Wfloat-equal"
#pragma clang diagnostic ignored "-Wimplicit-int-conversion"
#pragma clang diagnostic ignored "-Wlanguage-extension-token"
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#pragma clang diagnostic ignored "-Wshadow-field-in-constructor"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
#pragma warning(push)
#pragma warning(disable : 4244 4996)
#include <ImfRgbaFile.h>
#include <ImfIO.h>
// https://openexr.com/en/latest/PortingGuide.html
#include <OpenEXRConfig.h>
#pragma warning(pop)
#define COMBINED_OPENEXR_VERSION ((10000*OPENEXR_VERSION_MAJOR) + (100*OPENEXR_VERSION_MINOR) + OPENEXR_VERSION_PATCH)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
static_assert(sizeof(Imf::Rgba) == 8, "Mismatch size");
using namespace DirectX;
using PackedVector::XMHALF4;
#ifdef _WIN32
namespace
{
class com_exception : public std::exception
{
public:
com_exception(HRESULT hr) noexcept : result(hr) {}
const char* what() const noexcept override
{
static char s_str[64] = {};
sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast<unsigned int>(result));
return s_str;
}
HRESULT get_result() const noexcept { return result; }
private:
HRESULT result;
};
class InputStream : public Imf::IStream
{
public:
InputStream(HANDLE hFile, const char fileName[]) :
IStream(fileName), m_hFile(hFile)
{
const LARGE_INTEGER dist = {};
LARGE_INTEGER result;
if (!SetFilePointerEx(m_hFile, dist, &result, FILE_END))
{
throw com_exception(HRESULT_FROM_WIN32(GetLastError()));
}
m_EOF = result.QuadPart;
if (!SetFilePointerEx(m_hFile, dist, nullptr, FILE_BEGIN))
{
throw com_exception(HRESULT_FROM_WIN32(GetLastError()));
}
}
InputStream(const InputStream&) = delete;
InputStream& operator = (const InputStream&) = delete;
InputStream(InputStream&&) = delete;
InputStream& operator=(InputStream&&) = delete;
bool read(char c[], int n) override
{
DWORD bytesRead;
if (!ReadFile(m_hFile, c, static_cast<DWORD>(n), &bytesRead, nullptr))
{
throw com_exception(HRESULT_FROM_WIN32(GetLastError()));
}
const LARGE_INTEGER dist = {};
LARGE_INTEGER result;
if (!SetFilePointerEx(m_hFile, dist, &result, FILE_CURRENT))
{
throw com_exception(HRESULT_FROM_WIN32(GetLastError()));
}
return result.QuadPart >= m_EOF;
}
uint64_t tellg() override
{
const LARGE_INTEGER dist = {};
LARGE_INTEGER result;
if (!SetFilePointerEx(m_hFile, dist, &result, FILE_CURRENT))
{
throw com_exception(HRESULT_FROM_WIN32(GetLastError()));
}
return static_cast<uint64_t>(result.QuadPart);
}
void seekg(uint64_t pos) override
{
LARGE_INTEGER dist;
dist.QuadPart = static_cast<LONGLONG>(pos);
if (!SetFilePointerEx(m_hFile, dist, nullptr, FILE_BEGIN))
{
throw com_exception(HRESULT_FROM_WIN32(GetLastError()));
}
}
void clear() override
{
SetLastError(0);
}
#if COMBINED_OPENEXR_VERSION >= 30300
int64_t read(void *buf, uint64_t sz, uint64_t offset) override
{
return Imf::IStream::read(buf, sz, offset);
}
#endif
private:
HANDLE m_hFile;
LONGLONG m_EOF;
};
class OutputStream : public Imf::OStream
{
public:
OutputStream(HANDLE hFile, const char fileName[]) :
OStream(fileName), m_hFile(hFile)
{}
OutputStream(const OutputStream&) = delete;
OutputStream& operator = (const OutputStream&) = delete;
OutputStream(OutputStream&&) = delete;
OutputStream& operator=(OutputStream&&) = delete;
void write(const char c[], int n) override
{
DWORD bytesWritten;
if (!WriteFile(m_hFile, c, static_cast<DWORD>(n), &bytesWritten, nullptr))
{
throw com_exception(HRESULT_FROM_WIN32(GetLastError()));
}
}
uint64_t tellp() override
{
const LARGE_INTEGER dist = {};
LARGE_INTEGER result;
if (!SetFilePointerEx(m_hFile, dist, &result, FILE_CURRENT))
{
throw com_exception(HRESULT_FROM_WIN32(GetLastError()));
}
return static_cast<uint64_t>(result.QuadPart);
}
void seekp(uint64_t pos) override
{
LARGE_INTEGER dist;
dist.QuadPart = static_cast<LONGLONG>(pos);
if (!SetFilePointerEx(m_hFile, dist, nullptr, FILE_BEGIN))
{
throw com_exception(HRESULT_FROM_WIN32(GetLastError()));
}
}
private:
HANDLE m_hFile;
};
}
#endif // _WIN32
//=====================================================================================
// Entry-points
//=====================================================================================
//-------------------------------------------------------------------------------------
// Obtain metadata from EXR file on disk
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::GetMetadataFromEXRFile(const wchar_t* szFile, TexMetadata& metadata)
{
if (!szFile)
return E_INVALIDARG;
#ifdef _WIN32
std::string fileName;
const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
if (nameLength > 0)
{
fileName.resize(static_cast<size_t>(nameLength));
const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
if (result <= 0)
{
fileName.clear();
}
}
ScopedHandle hFile(safe_handle(CreateFile2(
szFile,
GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING,
nullptr)));
if (!hFile)
{
return HRESULT_FROM_WIN32(GetLastError());
}
InputStream stream(hFile.get(), fileName.c_str());
#else
std::wstring wFileName(szFile);
std::string fileName(wFileName.cbegin(), wFileName.cend());
#endif
HRESULT hr = S_OK;
try
{
#ifdef _WIN32
Imf::RgbaInputFile file(stream);
#else
Imf::RgbaInputFile file(fileName.c_str());
#endif
const auto dw = file.dataWindow();
const int width = dw.max.x - dw.min.x + 1;
int height = dw.max.y - dw.min.y + 1;
size_t arraySize = 1;
if (width < 1 || height < 1)
return E_FAIL;
if (file.header().find("envmap") != file.header().end())
{
if (width == height / 6)
{
height = width;
arraySize = 6;
}
}
metadata.width = static_cast<size_t>(width);
metadata.height = static_cast<size_t>(height);
metadata.depth = metadata.mipLevels = 1;
metadata.arraySize = arraySize;
metadata.format = DXGI_FORMAT_R16G16B16A16_FLOAT;
metadata.dimension = TEX_DIMENSION_TEXTURE2D;
}
#ifdef _WIN32
catch (const com_exception& exc)
{
#ifdef _DEBUG
OutputDebugStringA(exc.what());
#endif
hr = exc.get_result();
}
#endif
#if defined(_WIN32) && defined(_DEBUG)
catch (const std::exception& exc)
{
OutputDebugStringA(exc.what());
hr = E_FAIL;
}
#else
catch (const std::exception&)
{
hr = E_FAIL;
}
#endif
catch (...)
{
hr = E_UNEXPECTED;
}
return hr;
}
//-------------------------------------------------------------------------------------
// Load a EXR file from disk
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::LoadFromEXRFile(const wchar_t* szFile, TexMetadata* metadata, ScratchImage& image)
{
if (!szFile)
return E_INVALIDARG;
image.Release();
if (metadata)
{
memset(metadata, 0, sizeof(TexMetadata));
}
#ifdef _WIN32
std::string fileName;
const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
if (nameLength > 0)
{
fileName.resize(static_cast<size_t>(nameLength));
const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
if (result <= 0)
{
fileName.clear();
}
}
ScopedHandle hFile(safe_handle(CreateFile2(
szFile,
GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING,
nullptr)));
if (!hFile)
{
return HRESULT_FROM_WIN32(GetLastError());
}
InputStream stream(hFile.get(), fileName.c_str());
#else
std::wstring wFileName(szFile);
std::string fileName(wFileName.cbegin(), wFileName.cend());
#endif
HRESULT hr = S_OK;
try
{
#ifdef _WIN32
Imf::RgbaInputFile file(stream);
#else
Imf::RgbaInputFile file(fileName.c_str());
#endif
const auto dw = file.dataWindow();
const int width = dw.max.x - dw.min.x + 1;
int height = dw.max.y - dw.min.y + 1;
size_t arraySize = 1;
if (width < 1 || height < 1)
return E_FAIL;
if (file.header().find("envmap") != file.header().end())
{
if (width == height / 6)
{
height = width;
arraySize = 6;
}
}
if (metadata)
{
metadata->width = static_cast<size_t>(width);
metadata->height = static_cast<size_t>(height);
metadata->depth = metadata->mipLevels = 1;
metadata->arraySize = arraySize;
metadata->format = DXGI_FORMAT_R16G16B16A16_FLOAT;
metadata->dimension = TEX_DIMENSION_TEXTURE2D;
}
hr = image.Initialize2D(DXGI_FORMAT_R16G16B16A16_FLOAT,
static_cast<size_t>(width), static_cast<size_t>(height), arraySize, 1u);
if (FAILED(hr))
return hr;
file.setFrameBuffer(reinterpret_cast<Imf::Rgba*>(image.GetPixels()) - dw.min.x - dw.min.y * width, 1, static_cast<size_t>(width));
file.readPixels(dw.min.y, dw.max.y);
}
#ifdef _WIN32
catch (const com_exception& exc)
{
#ifdef _DEBUG
OutputDebugStringA(exc.what());
#endif
hr = exc.get_result();
}
#endif
#if defined(_WIN32) && defined(_DEBUG)
catch (const std::exception& exc)
{
OutputDebugStringA(exc.what());
hr = E_FAIL;
}
#else
catch (const std::exception&)
{
hr = E_FAIL;
}
#endif
catch (...)
{
hr = E_UNEXPECTED;
}
if (FAILED(hr))
{
image.Release();
}
return hr;
}
//-------------------------------------------------------------------------------------
// Save a EXR file to disk
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::SaveToEXRFile(const Image& image, const wchar_t* szFile)
{
if (!szFile)
return E_INVALIDARG;
if (!image.pixels)
return E_POINTER;
if (image.width > INT32_MAX || image.height > INT32_MAX)
return /* HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) */ static_cast<HRESULT>(0x80070032L);
switch (image.format)
{
case DXGI_FORMAT_R16G16B16A16_FLOAT:
if ((image.rowPitch % 8) > 0)
return E_FAIL;
break;
case DXGI_FORMAT_R32G32B32A32_FLOAT:
case DXGI_FORMAT_R32G32B32_FLOAT:
break;
default:
return /* HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) */ static_cast<HRESULT>(0x80070032L);
}
#ifdef _WIN32
std::string fileName;
const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
if (nameLength > 0)
{
fileName.resize(static_cast<size_t>(nameLength));
const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
if (result <= 0)
{
fileName.clear();
}
}
// Create file and write header
ScopedHandle hFile(safe_handle(CreateFile2(
szFile,
GENERIC_WRITE, 0, CREATE_ALWAYS,
nullptr)));
if (!hFile)
{
return HRESULT_FROM_WIN32(GetLastError());
}
auto_delete_file delonfail(hFile.get());
OutputStream stream(hFile.get(), fileName.c_str());
#else
std::wstring wFileName(szFile);
std::string fileName(wFileName.cbegin(), wFileName.cend());
#endif
HRESULT hr = S_OK;
try
{
const auto width = static_cast<int>(image.width);
const auto height = static_cast<int>(image.height);
#ifdef _WIN32
Imf::RgbaOutputFile file(stream, Imf::Header(width, height), Imf::WRITE_RGBA);
#else
Imf::RgbaOutputFile file(fileName.c_str(), Imf::Header(width, height), Imf::WRITE_RGBA);
#endif
if (image.format == DXGI_FORMAT_R16G16B16A16_FLOAT)
{
file.setFrameBuffer(reinterpret_cast<const Imf::Rgba*>(image.pixels), 1, image.rowPitch / 8);
file.writePixels(height);
}
else
{
const auto bytes = static_cast<uint64_t>(image.width) * static_cast<uint64_t>(image.height);
if (bytes > static_cast<uint64_t>(UINT32_MAX))
{
return /* HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) */ static_cast<HRESULT>(0x80070216L);
}
std::unique_ptr<XMHALF4> temp(new (std::nothrow) XMHALF4[static_cast<size_t>(bytes)]);
if (!temp)
return E_OUTOFMEMORY;
file.setFrameBuffer(reinterpret_cast<const Imf::Rgba*>(temp.get()), 1, image.width);
auto sPtr = image.pixels;
auto dPtr = temp.get();
if (image.format == DXGI_FORMAT_R32G32B32A32_FLOAT)
{
for (int j = 0; j < height; ++j)
{
auto srcPtr = reinterpret_cast<const XMFLOAT4*>(sPtr);
auto destPtr = dPtr;
for (int k = 0; k < width; ++k, ++srcPtr, ++destPtr)
{
const XMVECTOR v = XMLoadFloat4(srcPtr);
PackedVector::XMStoreHalf4(destPtr, v);
}
sPtr += image.rowPitch;
dPtr += width;
file.writePixels(1);
}
}
else
{
assert(image.format == DXGI_FORMAT_R32G32B32_FLOAT);
for (int j = 0; j < height; ++j)
{
auto srcPtr = reinterpret_cast<const XMFLOAT3*>(sPtr);
auto destPtr = dPtr;
for (int k = 0; k < width; ++k, ++srcPtr, ++destPtr)
{
XMVECTOR v = XMLoadFloat3(srcPtr);
v = XMVectorSelect(g_XMIdentityR3, v, g_XMSelect1110);
PackedVector::XMStoreHalf4(destPtr, v);
}
sPtr += image.rowPitch;
dPtr += width;
file.writePixels(1);
}
}
}
}
#ifdef _WIN32
catch (const com_exception& exc)
{
#ifdef _DEBUG
OutputDebugStringA(exc.what());
#endif
hr = exc.get_result();
}
#endif
#if defined(_WIN32) && defined(_DEBUG)
catch (const std::exception& exc)
{
OutputDebugStringA(exc.what());
hr = E_FAIL;
}
#else
catch (const std::exception&)
{
hr = E_FAIL;
}
#endif
catch (...)
{
hr = E_UNEXPECTED;
}
if (FAILED(hr))
return hr;
#ifdef _WIN32
delonfail.clear();
#endif
return S_OK;
}

View File

@ -1,28 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexEXR.h
//
// DirectXTex Auxilary functions for using the OpenEXR library
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#pragma once
#include "DirectXTex.h"
namespace DirectX
{
DIRECTX_TEX_API HRESULT __cdecl GetMetadataFromEXRFile(
_In_z_ const wchar_t* szFile,
_Out_ TexMetadata& metadata);
DIRECTX_TEX_API HRESULT __cdecl LoadFromEXRFile(
_In_z_ const wchar_t* szFile,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image);
DIRECTX_TEX_API HRESULT __cdecl SaveToEXRFile(
_In_ const Image& image,
_In_z_ const wchar_t* szFile);
}

View File

@ -1,425 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexJPEG.cpp
//
// DirectXTex Auxilary functions for using the JPEG(https://www.ijg.org) library
//
// For the Windows platform, the strong recommendation is to make use of the WIC
// functions rather than using the open source library. This module exists to support
// Windows Subsystem on Linux.
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#include "DirectXTexP.h"
#include "DirectXTexJPEG.h"
#if __cplusplus < 201703L
#error Requires C++17 (and /Zc:__cplusplus with MSVC)
#endif
#ifndef _BASETSD_H_
#define _BASETSD_H_
#endif
#include <cstdio>
#include <cstdlib>
#include <exception>
#include <filesystem>
#include <stdexcept>
#include <string>
#include <system_error>
#include <vector>
#include <jpeglib.h>
#include <jerror.h>
using namespace DirectX;
using std::filesystem::path;
using ScopedFILE = std::unique_ptr<FILE, int(*)(FILE*)>;
namespace
{
#ifdef _WIN32
ScopedFILE OpenFILE(const path& p) noexcept(false)
{
const std::wstring fpath = p.generic_wstring();
FILE* fp = nullptr;
if (auto ec = _wfopen_s(&fp, fpath.c_str(), L"rb"); ec)
throw std::system_error{ static_cast<int>(_doserrno), std::system_category(), "_wfopen_s" };
return { fp, &fclose };
}
ScopedFILE CreateFILE(const path& p) noexcept(false)
{
const std::wstring fpath = p.generic_wstring();
FILE* fp = nullptr;
if (auto ec = _wfopen_s(&fp, fpath.c_str(), L"w+b"); ec)
throw std::system_error{ static_cast<int>(_doserrno), std::system_category(), "_wfopen_s" };
return { fp, &fclose };
}
#else
ScopedFILE OpenFILE(const path& p) noexcept(false)
{
const std::string fpath = p.generic_string();
FILE* fp = fopen(fpath.c_str(), "rb");
if (!fp)
throw std::system_error{ errno, std::system_category(), "fopen" };
return { fp, &fclose };
}
ScopedFILE CreateFILE(const path& p) noexcept(false)
{
const std::string fpath = p.generic_string();
FILE* fp = fopen(fpath.c_str(), "w+b");
if (!fp)
throw std::system_error{ errno, std::system_category(), "fopen" };
return { fp, &fclose };
}
#endif
[[noreturn]] void OnJPEGError(j_common_ptr ptr)
{
char msg[JMSG_LENGTH_MAX]{};
// "0x89 0x50": PNG
// "0x52 0x49": WEBP
(*ptr->err->format_message)(ptr, msg);
jpeg_destroy(ptr);
throw std::runtime_error{ msg };
}
class JPEGDecompress final
{
jpeg_error_mgr err;
jpeg_decompress_struct dec;
public:
JPEGDecompress() : err{}, dec{}
{
jpeg_std_error(&err);
err.error_exit = &OnJPEGError;
dec.err = &err;
jpeg_create_decompress(&dec);
}
~JPEGDecompress() noexcept
{
jpeg_destroy_decompress(&dec);
}
void UseInput(FILE* fin) noexcept
{
jpeg_stdio_src(&dec, fin);
}
static DXGI_FORMAT TranslateColor(J_COLOR_SPACE colorspace) noexcept
{
switch (colorspace)
{
case JCS_GRAYSCALE: // 1 component
return DXGI_FORMAT_R8_UNORM;
case JCS_RGB: // 3 component, Standard RGB
return DXGI_FORMAT_R8G8B8A8_UNORM;
case JCS_CMYK: // 4 component. WIC retuns this for CMYK
return DXGI_FORMAT_R8G8B8A8_UNORM;
#ifdef LIBJPEG_TURBO_VERSION
case JCS_EXT_RGBX: // 4 component
case JCS_EXT_RGBA:
return DXGI_FORMAT_R8G8B8A8_UNORM;
case JCS_RGB565:
return DXGI_FORMAT_B5G6R5_UNORM;
#endif
case JCS_YCbCr: // 3 component, YCbCr
default:
return DXGI_FORMAT_UNKNOWN;
}
}
void GetMetadata(TexMetadata& metadata) noexcept(false)
{
metadata.width = dec.image_width;
metadata.height = dec.image_height;
metadata.depth = 1;
metadata.arraySize = 1;
metadata.mipLevels = 1;
metadata.dimension = TEX_DIMENSION_TEXTURE2D;
metadata.format = TranslateColor(dec.out_color_space);
if (metadata.format == DXGI_FORMAT_UNKNOWN)
{
throw std::runtime_error{ "unexpected out_color_space in jpeg_decompress_struct" };
}
if (metadata.format == DXGI_FORMAT_R8G8B8A8_UNORM)
{
metadata.miscFlags2 |= TEX_ALPHA_MODE_OPAQUE;
}
}
HRESULT GetHeader(TexMetadata& metadata) noexcept(false)
{
metadata = {};
switch (jpeg_read_header(&dec, false))
{
case JPEG_HEADER_TABLES_ONLY:
[[fallthrough]];
case JPEG_HEADER_OK:
break;
case JPEG_SUSPENDED:
return E_FAIL;
}
GetMetadata(metadata);
return S_OK;
}
#if !defined(LIBJPEG_TURBO_VERSION)
// shift pixels with padding in reverse order (to make it work in-memory)
void ShiftPixels(ScratchImage& image) noexcept
{
size_t num_pixels = dec.output_width * dec.output_height;
uint8_t* dst = image.GetPixels();
const uint8_t* src = dst;
for (size_t i = num_pixels - 1; i > 0; i -= 1)
{
dst[4*i + 0] = src[3*i + 0];
dst[4*i + 1] = src[3*i + 1];
dst[4*i + 2] = src[3*i + 2];
dst[4*i + 3] = 0;
}
}
#endif
HRESULT GetImage(TexMetadata& metadata, ScratchImage& image) noexcept(false)
{
metadata = {};
switch (jpeg_read_header(&dec, true))
{
case JPEG_HEADER_TABLES_ONLY:
GetMetadata(metadata);
[[fallthrough]];
case JPEG_SUSPENDED:
return E_FAIL;
case JPEG_HEADER_OK:
break;
}
GetMetadata(metadata);
// if the JPEG library doesn't have color space conversion, it should be ERROR_NOT_SUPPORTED
if (dec.jpeg_color_space == JCS_YCCK)
{
// CMYK is the known case
if (dec.out_color_space == JCS_CMYK)
return HRESULT_E_NOT_SUPPORTED;
}
if (auto hr = image.Initialize2D(metadata.format, metadata.width, metadata.height, metadata.arraySize, metadata.mipLevels); FAILED(hr))
return hr;
#ifdef LIBJPEG_TURBO_VERSION
// grayscale is the only color space which uses 1 component
if (dec.out_color_space != JCS_GRAYSCALE)
// if there is no proper conversion to 4 component, E_FAIL...
dec.out_color_space = JCS_EXT_RGBX;
#endif
if (jpeg_start_decompress(&dec) == false)
return E_FAIL;
uint8_t* dest = image.GetPixels();
const size_t stride = dec.output_width * static_cast<size_t>(dec.output_components);
std::vector<JSAMPROW> rows(dec.output_height);
for (size_t i = 0u; i < dec.output_height; ++i)
rows[i] = dest + (stride * i);
JDIMENSION leftover = dec.output_height;
while (leftover > 0)
{
JDIMENSION consumed = jpeg_read_scanlines(&dec, &rows[dec.output_scanline], leftover);
leftover -= consumed;
}
if (jpeg_finish_decompress(&dec) == false)
return E_FAIL;
#if !defined(LIBJPEG_TURBO_VERSION)
// if NOT TurboJPEG, we need to make 3 component images to 4 component image
if (dec.out_color_space != JCS_GRAYSCALE)
ShiftPixels(image);
#endif
return S_OK;
}
HRESULT GetImage(ScratchImage& image) noexcept(false)
{
TexMetadata metadata{};
return GetImage(metadata, image);
}
};
class JPEGCompress final
{
jpeg_error_mgr err{};
jpeg_compress_struct enc{};
public:
JPEGCompress() : err{}, enc{}
{
jpeg_std_error(&err);
err.error_exit = &OnJPEGError;
enc.err = &err;
jpeg_create_compress(&enc);
}
~JPEGCompress() noexcept
{
jpeg_destroy_compress(&enc);
}
void UseOutput(FILE* fout)
{
jpeg_stdio_dest(&enc, fout);
}
/// @todo More correct DXGI_FORMAT mapping
HRESULT WriteImage(const Image& image) noexcept(false)
{
switch (image.format)
{
case DXGI_FORMAT_R8_UNORM:
enc.input_components = 1;
enc.in_color_space = JCS_GRAYSCALE;
break;
#ifdef LIBJPEG_TURBO_VERSION
case DXGI_FORMAT_R8G8B8A8_UNORM:
enc.input_components = 4;
enc.in_color_space = JCS_EXT_RGBA;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM:
enc.input_components = 4;
enc.in_color_space = JCS_EXT_BGRA;
break;
#else
case DXGI_FORMAT_R8G8B8A8_UNORM:
enc.input_components = 3;
enc.in_color_space = JCS_RGB;
#endif
default:
return HRESULT_E_NOT_SUPPORTED;
}
enc.image_width = static_cast<JDIMENSION>(image.width);
enc.image_height = static_cast<JDIMENSION>(image.height);
jpeg_set_defaults(&enc);
jpeg_set_quality(&enc, 100, true);
// we will write a row each time ...
jpeg_start_compress(&enc, true);
const size_t stride = enc.image_width * static_cast<size_t>(enc.input_components);
while (enc.next_scanline < enc.image_height)
{
JSAMPROW rows[1]{ image.pixels + stride * enc.next_scanline };
jpeg_write_scanlines(&enc, rows, 1);
}
jpeg_finish_compress(&enc);
return S_OK;
}
};
}
_Use_decl_annotations_
HRESULT DirectX::GetMetadataFromJPEGFile(
const wchar_t* file,
TexMetadata& metadata)
{
if (!file)
return E_INVALIDARG;
try
{
auto fin = OpenFILE(file);
JPEGDecompress decoder{};
decoder.UseInput(fin.get());
return decoder.GetHeader(metadata);
}
catch (const std::bad_alloc&)
{
return E_OUTOFMEMORY;
}
catch (const std::system_error& ec)
{
#ifdef _WIN32
return HRESULT_FROM_WIN32(static_cast<unsigned long>(ec.code().value()));
#else
return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL;
#endif
}
catch (const std::exception&)
{
return E_FAIL;
}
}
_Use_decl_annotations_
HRESULT DirectX::LoadFromJPEGFile(
const wchar_t* file,
TexMetadata* metadata,
ScratchImage&image)
{
if (!file)
return E_INVALIDARG;
image.Release();
try
{
auto fin = OpenFILE(file);
JPEGDecompress decoder{};
decoder.UseInput(fin.get());
if (!metadata)
return decoder.GetImage(image);
return decoder.GetImage(*metadata, image);
}
catch (const std::bad_alloc&)
{
image.Release();
return E_OUTOFMEMORY;
}
catch (const std::system_error& ec)
{
image.Release();
#ifdef _WIN32
return HRESULT_FROM_WIN32(static_cast<unsigned long>(ec.code().value()));
#else
return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL;
#endif
}
catch (const std::exception&)
{
image.Release();
return E_FAIL;
}
}
_Use_decl_annotations_
HRESULT DirectX::SaveToJPEGFile(
const Image& image,
const wchar_t* file)
{
if (!file)
return E_INVALIDARG;
try
{
auto fout = CreateFILE(file);
JPEGCompress encoder{};
encoder.UseOutput(fout.get());
return encoder.WriteImage(image);
}
catch (const std::bad_alloc&)
{
return E_OUTOFMEMORY;
}
catch (const std::system_error& ec)
{
#ifdef _WIN32
return HRESULT_FROM_WIN32(static_cast<unsigned long>(ec.code().value()));
#else
return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL;
#endif
}
catch (const std::exception&)
{
return E_FAIL;
}
}

View File

@ -1,33 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexJPEG.h
//
// DirectXTex Auxilary functions for using the JPEG(https://www.ijg.org) library
//
// For the Windows platform, the strong recommendation is to make use of the WIC
// functions rather than using the open source library. This module exists to support
// Windows Subsystem on Linux.
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#pragma once
#include "DirectXTex.h"
namespace DirectX
{
DIRECTX_TEX_API HRESULT __cdecl GetMetadataFromJPEGFile(
_In_z_ const wchar_t* szFile,
_Out_ TexMetadata& metadata);
DIRECTX_TEX_API HRESULT __cdecl LoadFromJPEGFile(
_In_z_ const wchar_t* szFile,
_Out_opt_ TexMetadata* metadata,
_Out_ ScratchImage& image);
DIRECTX_TEX_API HRESULT __cdecl SaveToJPEGFile(
_In_ const Image& image,
_In_z_ const wchar_t* szFile);
}

View File

@ -1,430 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexPNG.cpp
//
// DirectXTex Auxilary functions for using the PNG(http://www.libpng.org/pub/png/libpng.html) library
//
// For the Windows platform, the strong recommendation is to make use of the WIC
// functions rather than using the open source library. This module exists to support
// Windows Subsystem on Linux.
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#include "DirectXTexP.h"
#include "DirectXTexPNG.h"
#if __cplusplus < 201703L
#error Requires C++17 (and /Zc:__cplusplus with MSVC)
#endif
#include <cstdio>
#include <cstdlib>
#include <exception>
#include <filesystem>
#include <stdexcept>
#include <string>
#include <system_error>
#include <vector>
#include <png.h>
using namespace DirectX;
using std::filesystem::path;
using ScopedFILE = std::unique_ptr<FILE, int(*)(FILE*)>;
namespace
{
#ifdef _WIN32
ScopedFILE OpenFILE(const path& p) noexcept(false)
{
const std::wstring fpath = p.generic_wstring();
FILE* fp = nullptr;
if (auto ec = _wfopen_s(&fp, fpath.c_str(), L"rb"); ec)
throw std::system_error{ static_cast<int>(_doserrno), std::system_category(), "_wfopen_s" };
return { fp, &fclose };
}
ScopedFILE CreateFILE(const path& p) noexcept(false)
{
const std::wstring fpath = p.generic_wstring();
FILE* fp = nullptr;
if (auto ec = _wfopen_s(&fp, fpath.c_str(), L"w+b"); ec)
throw std::system_error{ static_cast<int>(_doserrno), std::system_category(), "_wfopen_s" };
return { fp, &fclose };
}
#else
ScopedFILE OpenFILE(const path& p) noexcept(false)
{
const std::string fpath = p.generic_string();
FILE* fp = fopen(fpath.c_str(), "rb");
if (!fp)
throw std::system_error{ errno, std::system_category(), "fopen" };
return { fp, &fclose };
}
ScopedFILE CreateFILE(const path& p) noexcept(false)
{
const std::string fpath = p.generic_string();
FILE* fp = fopen(fpath.c_str(), "w+b");
if (!fp)
throw std::system_error{ errno, std::system_category(), "fopen" };
return { fp, &fclose };
}
#endif
[[noreturn]] void OnPNGError(png_structp, png_const_charp msg)
{
throw std::runtime_error{ msg };
}
void OnPNGWarning(png_structp, png_const_charp)
{
// drain warning messages ...
}
/// @note If the PNG contains some extra chunks like EXIF, this will be used
void OnPNGRead(png_structp st, png_bytep ptr, size_t len)
{
FILE* fin = reinterpret_cast<FILE*>(png_get_io_ptr(st));
std::ignore = fread(ptr, len, 1, fin);
}
/// @see http://www.libpng.org/pub/png/libpng.html
/// @see http://www.libpng.org/pub/png/libpng-manual.txt
class PNGDecompress final
{
png_structp st;
png_infop info;
public:
PNGDecompress() noexcept(false) : st{ nullptr }, info{ nullptr }
{
st = png_create_read_struct(PNG_LIBPNG_VER_STRING, this, &OnPNGError, &OnPNGWarning);
if (!st)
throw std::runtime_error{ "png_create_read_struct" };
info = png_create_info_struct(st);
if (!info)
{
png_destroy_read_struct(&st, nullptr, nullptr);
throw std::runtime_error{ "png_create_info_struct" };
}
}
~PNGDecompress() noexcept
{
png_destroy_read_struct(&st, &info, nullptr);
}
void UseInput(FILE* fin) noexcept
{
// we assume the signature is unread. if so, we have to use `png_set_sig_bytes`
png_init_io(st, fin);
png_set_read_fn(st, fin, &OnPNGRead);
}
void Update() noexcept(false)
{
png_read_info(st, info);
// check for unsupported cases
png_byte interlacing = png_get_interlace_type(st, info);
if (interlacing != PNG_INTERLACE_NONE)
{
throw std::invalid_argument{ "interlacing not supported" };
}
// color handling
png_byte color_type = png_get_color_type(st, info);
if (color_type == PNG_COLOR_TYPE_GRAY)
{
// bit_depth will be 8 or 16
if (png_get_bit_depth(st, info) < 8)
png_set_expand_gray_1_2_4_to_8(st);
}
else if (color_type == PNG_COLOR_TYPE_PALETTE)
{
// request RGB color
png_set_palette_to_rgb(st);
if (png_get_valid(st, info, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(st);
}
// Here we don't know if the pixel data is in BGR/RGB order
// png_set_bgr(st);
png_set_alpha_mode(st, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);
// make 4 component
// using `png_set_add_alpha` here may confuse `TEX_ALPHA_MODE_OPAQUE` estimation
if (png_get_channels(st, info) == 3)
png_set_filler(st, 0, PNG_FILLER_AFTER);
// prefer DXGI_FORMAT_R8G8B8A8_UNORM. strip in decode
//if (png_get_bit_depth(st, info) > 8)
// png_set_strip_16(st);
png_read_update_info(st, info);
}
/// @note must call `Update` before this
/// @todo Proper detection of DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
DXGI_FORMAT GuessFormat() const noexcept(false)
{
// 1 or 4. 1 is for gray
auto c = png_get_channels(st, info);
if (c == 1)
{
if (png_get_bit_depth(st, info) == 16)
return DXGI_FORMAT_R16_UNORM;
// with `png_set_expand_gray_1_2_4_to_8`, libpng will change to R8_UNORM
return DXGI_FORMAT_R8_UNORM;
}
// 8 or 16. expanded if 1, 2, 4
auto d = png_get_bit_depth(st, info);
if (d == 16)
return DXGI_FORMAT_R16G16B16A16_UNORM;
if (d != 8)
throw std::runtime_error{ "unexpected info from libpng" };
int intent = 0;
if (png_get_sRGB(st, info, &intent) == PNG_INFO_sRGB)
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
return DXGI_FORMAT_R8G8B8A8_UNORM;
}
/// @todo More correct DXGI_FORMAT mapping
void GetHeader(TexMetadata& metadata) noexcept(false)
{
metadata = {};
metadata.width = png_get_image_width(st, info);
metadata.height = png_get_image_height(st, info);
metadata.arraySize = 1;
metadata.mipLevels = 1;
metadata.depth = 1;
metadata.dimension = TEX_DIMENSION_TEXTURE2D;
metadata.format = GuessFormat();
png_byte color_type = png_get_color_type(st, info);
bool have_alpha = (color_type & PNG_COLOR_MASK_ALPHA);
if (have_alpha == false && (metadata.format != DXGI_FORMAT_R8_UNORM))
metadata.miscFlags2 |= TEX_ALPHA_MODE_OPAQUE;
}
/// @todo More correct DXGI_FORMAT mapping
HRESULT GetImage(TexMetadata& metadata, ScratchImage& image) noexcept(false)
{
metadata = {};
GetHeader(metadata);
if (auto hr = image.Initialize2D(metadata.format, metadata.width, metadata.height, metadata.arraySize, metadata.mipLevels); FAILED(hr))
return hr;
auto* dest = image.GetPixels();
const auto stride = metadata.width * png_get_channels(st, info);
std::vector<png_byte*> rows(metadata.height);
for (auto i = 0u; i < metadata.height; ++i)
rows[i] = dest + (stride * i);
png_read_rows(st, rows.data(), nullptr, static_cast<uint32_t>(rows.size()));
png_read_end(st, info);
return S_OK;
}
HRESULT GetImage(ScratchImage& image) noexcept(false)
{
TexMetadata metadata{};
return GetImage(metadata, image);
}
};
/// @see http://www.libpng.org/pub/png/libpng.html
/// @see http://www.libpng.org/pub/png/libpng-manual.txt
class PNGCompress final
{
png_structp st;
png_infop info;
public:
PNGCompress() noexcept(false) : st{ nullptr }, info{ nullptr }
{
st = png_create_write_struct(PNG_LIBPNG_VER_STRING, this, &OnPNGError, &OnPNGWarning);
if (!st)
throw std::runtime_error{ "png_create_write_struct" };
info = png_create_info_struct(st);
if (!info)
{
png_destroy_write_struct(&st, nullptr);
throw std::runtime_error{ "png_create_info_struct" };
}
png_set_compression_level(st, 0);
}
~PNGCompress() noexcept
{
png_destroy_write_struct(&st, &info);
}
void UseOutput(FILE* fout) noexcept
{
png_init_io(st, fout);
}
HRESULT WriteImage(const Image& image) noexcept(false)
{
int color_type = PNG_COLOR_TYPE_RGB;
bool using_bgr = false;
int channel = 4;
int bit_depth = 8;
switch (image.format)
{
case DXGI_FORMAT_R8_UNORM:
color_type = PNG_COLOR_TYPE_GRAY;
channel = 1;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM:
case DXGI_FORMAT_B8G8R8X8_UNORM:
using_bgr = true;
[[fallthrough]];
case DXGI_FORMAT_R8G8B8A8_UNORM:
color_type = PNG_COLOR_TYPE_RGBA;
break;
default:
return HRESULT_E_NOT_SUPPORTED;
}
png_set_IHDR(st, info,
static_cast<uint32_t>(image.width),
static_cast<uint32_t>(image.height),
bit_depth,
color_type,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
png_write_info(st, info);
if (using_bgr)
png_set_bgr(st);
const size_t stride = static_cast<size_t>(channel) * image.width;
std::vector<png_bytep> rows(image.height);
for (size_t i = 0u; i< image.height; ++i)
rows[i] = image.pixels + stride * i;
png_write_rows(st, rows.data(), static_cast<uint32_t>(rows.size()));
// actual write will be done here
png_write_end(st, info);
return S_OK;
}
};
}
_Use_decl_annotations_
HRESULT DirectX::GetMetadataFromPNGFile(
const wchar_t* file,
TexMetadata& metadata)
{
if (!file)
return E_INVALIDARG;
try
{
auto fin = OpenFILE(file);
PNGDecompress decoder{};
decoder.UseInput(fin.get());
decoder.Update();
decoder.GetHeader(metadata);
return S_OK;
}
catch (const std::bad_alloc&)
{
return E_OUTOFMEMORY;
}
catch (const std::system_error& ec)
{
#ifdef _WIN32
return HRESULT_FROM_WIN32(static_cast<unsigned long>(ec.code().value()));
#else
return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL;
#endif
}
catch (const std::invalid_argument&)
{
return HRESULT_E_NOT_SUPPORTED;
}
catch (const std::exception&)
{
return E_FAIL;
}
}
_Use_decl_annotations_
HRESULT DirectX::LoadFromPNGFile(
const wchar_t* file,
TexMetadata* metadata,
ScratchImage& image)
{
if (!file)
return E_INVALIDARG;
image.Release();
try
{
auto fin = OpenFILE(file);
PNGDecompress decoder{};
decoder.UseInput(fin.get());
decoder.Update();
if (metadata == nullptr)
return decoder.GetImage(image);
return decoder.GetImage(*metadata, image);
}
catch (const std::bad_alloc&)
{
image.Release();
return E_OUTOFMEMORY;
}
catch (const std::system_error& ec)
{
image.Release();
#ifdef _WIN32
return HRESULT_FROM_WIN32(static_cast<unsigned long>(ec.code().value()));
#else
return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL;
#endif
}
catch (const std::invalid_argument&)
{
return HRESULT_E_NOT_SUPPORTED;
}
catch (const std::exception&)
{
image.Release();
return E_FAIL;
}
}
_Use_decl_annotations_
HRESULT DirectX::SaveToPNGFile(
const Image& image,
const wchar_t* file)
{
if (!file)
return E_INVALIDARG;
try
{
auto fout = CreateFILE(file);
PNGCompress encoder{};
encoder.UseOutput(fout.get());
return encoder.WriteImage(image);
}
catch (const std::bad_alloc&)
{
return E_OUTOFMEMORY;
}
catch (const std::system_error& ec)
{
#ifdef _WIN32
return HRESULT_FROM_WIN32(static_cast<unsigned long>(ec.code().value()));
#else
return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL;
#endif
}
catch (const std::exception&)
{
return E_FAIL;
}
}

View File

@ -1,33 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexPNG.h
//
// DirectXTex Auxilary functions for using the PNG(http://www.libpng.org/pub/png/libpng.html) library
//
// For the Windows platform, the strong recommendation is to make use of the WIC
// functions rather than using the open source library. This module exists to support
// Windows Subsystem on Linux.
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#pragma once
#include "DirectXTex.h"
namespace DirectX
{
DIRECTX_TEX_API HRESULT __cdecl GetMetadataFromPNGFile(
_In_z_ const wchar_t* szFile,
_Out_ TexMetadata& metadata);
DIRECTX_TEX_API HRESULT __cdecl LoadFromPNGFile(
_In_z_ const wchar_t* szFile,
_Out_opt_ TexMetadata* metadata,
_Out_ ScratchImage& image);
DIRECTX_TEX_API HRESULT __cdecl SaveToPNGFile(
_In_ const Image& image,
_In_z_ const wchar_t* szFile);
}

View File

@ -1,227 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexXbox.h
//
// DirectXTex Auxilary functions for Xbox texture processing
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#pragma once
#ifndef _M_X64
#error This tool is only supported for x64 native
#endif
#include "DirectXTex.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonportable-system-include-path"
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
#include <xg_xs.h>
#else
#include <xg.h>
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef _GAMING_XBOX_SCARLETT
#include <d3d12_xs.h>
#elif defined(_GAMING_XBOX)
#include <d3d12_x.h>
#elif defined(_XBOX_ONE) && defined(_TITLE)
#include <d3d11_x.h>
#else
#include <d3d11_1.h>
#endif
#include <cstdint>
#include <utility>
#define DIRECTX_TEX_XBOX_VERSION 150
namespace Xbox
{
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
using XboxTileMode = XG_SWIZZLE_MODE;
constexpr XboxTileMode c_XboxTileModeInvalid = XG_SWIZZLE_MODE_INVALID;
constexpr XboxTileMode c_XboxTileModeLinear = XG_SWIZZLE_MODE_LINEAR;
#else
using XboxTileMode = XG_TILE_MODE;
constexpr XboxTileMode c_XboxTileModeInvalid = XG_TILE_MODE_INVALID;
constexpr XboxTileMode c_XboxTileModeLinear = XG_TILE_MODE_LINEAR;
#endif
class DIRECTX_TEX_API XboxImage
{
public:
XboxImage() noexcept
: dataSize(0), baseAlignment(0), tilemode(c_XboxTileModeInvalid), metadata{}, memory(nullptr)
{}
XboxImage(XboxImage&& moveFrom) noexcept
: dataSize(0), baseAlignment(0), tilemode(c_XboxTileModeInvalid), metadata{}, memory(nullptr)
{
*this = std::move(moveFrom);
}
~XboxImage() { Release(); }
XboxImage& __cdecl operator= (XboxImage&& moveFrom) noexcept;
XboxImage(const XboxImage&) = delete;
XboxImage& operator=(const XboxImage&) = delete;
HRESULT __cdecl Initialize(_In_ const XG_TEXTURE1D_DESC& desc, _In_ const XG_RESOURCE_LAYOUT& layout, _In_ uint32_t miscFlags2 = 0);
HRESULT __cdecl Initialize(_In_ const XG_TEXTURE2D_DESC& desc, _In_ const XG_RESOURCE_LAYOUT& layout, _In_ uint32_t miscFlags2 = 0);
HRESULT __cdecl Initialize(_In_ const XG_TEXTURE3D_DESC& desc, _In_ const XG_RESOURCE_LAYOUT& layout, _In_ uint32_t miscFlags2 = 0);
HRESULT __cdecl Initialize(_In_ const DirectX::TexMetadata& mdata, _In_ XboxTileMode tm, _In_ uint32_t size, _In_ uint32_t alignment);
void __cdecl Release();
const DirectX::TexMetadata& GetMetadata() const { return metadata; }
XboxTileMode GetTileMode() const { return tilemode; }
uint32_t GetSize() const { return dataSize; }
uint32_t GetAlignment() const { return baseAlignment; }
uint8_t* GetPointer() const { return memory; }
private:
uint32_t dataSize;
uint32_t baseAlignment;
XboxTileMode tilemode;
DirectX::TexMetadata metadata;
uint8_t* memory;
};
//---------------------------------------------------------------------------------
// Image I/O
DIRECTX_TEX_API HRESULT __cdecl GetMetadataFromDDSMemory(
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox);
DIRECTX_TEX_API HRESULT __cdecl GetMetadataFromDDSFile(
_In_z_ const wchar_t* szFile, _Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox);
DIRECTX_TEX_API HRESULT __cdecl GetMetadataFromDDSMemoryEx(
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat);
DIRECTX_TEX_API HRESULT __cdecl GetMetadataFromDDSFileEx(
_In_z_ const wchar_t* szFile, _Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat);
DIRECTX_TEX_API HRESULT __cdecl LoadFromDDSMemory(
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image);
DIRECTX_TEX_API HRESULT __cdecl LoadFromDDSFile(
_In_z_ const wchar_t* szFile,
_Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image);
DIRECTX_TEX_API HRESULT __cdecl LoadFromDDSMemoryEx(
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ DirectX::TexMetadata* metadata,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat,
_Out_ XboxImage& image);
DIRECTX_TEX_API HRESULT __cdecl LoadFromDDSFileEx(
_In_z_ const wchar_t* szFile,
_Out_opt_ DirectX::TexMetadata* metadata,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat,
_Out_ XboxImage& image);
DIRECTX_TEX_API HRESULT __cdecl SaveToDDSMemory(_In_ const XboxImage& xbox, _Out_ DirectX::Blob& blob);
DIRECTX_TEX_API HRESULT __cdecl SaveToDDSFile(_In_ const XboxImage& xbox, _In_z_ const wchar_t* szFile);
#ifdef __cpp_lib_byte
inline HRESULT __cdecl GetMetadataFromDDSMemory(
_In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
_Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox)
{
return GetMetadataFromDDSMemory(reinterpret_cast<const uint8_t*>(pSource), size, metadata, isXbox);
}
inline HRESULT __cdecl GetMetadataFromDDSMemoryEx(
_In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
_Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat)
{
return GetMetadataFromDDSMemoryEx(reinterpret_cast<const uint8_t*>(pSource), size, metadata, isXbox, ddPixelFormat);
}
inline HRESULT __cdecl LoadFromDDSMemory(
_In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
_Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image)
{
return LoadFromDDSMemory(reinterpret_cast<const uint8_t*>(pSource), size, metadata, image);
}
inline HRESULT __cdecl LoadFromDDSMemoryEx(
_In_reads_bytes_(size) const std::byte* pSource, _In_ size_t size,
_Out_opt_ DirectX::TexMetadata* metadata,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat,
_Out_ XboxImage& image)
{
return LoadFromDDSMemoryEx(reinterpret_cast<const uint8_t*>(pSource), size, metadata, ddPixelFormat, image);
}
#endif // __cpp_lib_byte
//---------------------------------------------------------------------------------
// Xbox Texture Tiling / Detiling (requires XG DLL to be present at runtime)
DIRECTX_TEX_API HRESULT __cdecl Tile(_In_ const DirectX::Image& srcImage, _Out_ XboxImage& xbox, _In_ XboxTileMode mode = c_XboxTileModeInvalid);
DIRECTX_TEX_API HRESULT __cdecl Tile(
_In_ const DirectX::Image* srcImages, _In_ size_t nimages, _In_ const DirectX::TexMetadata& metadata,
_Out_ XboxImage& xbox, _In_ XboxTileMode mode = c_XboxTileModeInvalid);
DIRECTX_TEX_API HRESULT __cdecl Detile(_In_ const XboxImage& xbox, _Out_ DirectX::ScratchImage& image);
//---------------------------------------------------------------------------------
// Direct3D 11.X functions
#if defined(_XBOX_ONE) && defined(_TITLE) && defined(__d3d11_x_h__)
DIRECTX_TEX_API HRESULT __cdecl CreateTexture(
_In_ ID3D11DeviceX* d3dDevice,
_In_ const XboxImage& xbox, _Outptr_opt_ ID3D11Resource** ppResource, _Outptr_ void** grfxMemory);
DIRECTX_TEX_API HRESULT __cdecl CreateShaderResourceView(
_In_ ID3D11DeviceX* d3dDevice,
_In_ const XboxImage& xbox, _Outptr_opt_ ID3D11ShaderResourceView** ppSRV, _Outptr_ void** grfxMemory);
DIRECTX_TEX_API void __cdecl FreeTextureMemory(_In_ ID3D11DeviceX* d3dDevice, _In_opt_ void* grfxMemory);
#endif
//---------------------------------------------------------------------------------
// Direct3D 12.X functions
#if ((defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)) && (defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__))
DIRECTX_TEX_API HRESULT __cdecl CreateTexture(
_In_ ID3D12Device* d3dDevice,
_In_ const XboxImage& xbox, _Outptr_opt_ ID3D12Resource** ppResource, _Outptr_ void** grfxMemory);
DIRECTX_TEX_API void __cdecl FreeTextureMemory(_In_ ID3D12Device* d3dDevice, _In_opt_ void* grfxMemory);
#endif
//---------------------------------------------------------------------------------
// DDS helper functions
DIRECTX_TEX_API HRESULT __cdecl EncodeDDSHeader(
const XboxImage& xbox,
_Out_writes_bytes_(maxsize) uint8_t* pDestination, _In_ size_t maxsize) noexcept;
#ifdef __cpp_lib_byte
inline HRESULT __cdecl EncodeDDSHeader(
const XboxImage& xbox,
_Out_writes_bytes_(maxsize) std::byte* pDestination, _In_ size_t maxsize) noexcept
{
return EncodeDDSHeader(xbox, reinterpret_cast<uint8_t*>(pDestination), maxsize);
}
#endif
} // namespace

View File

@ -1,258 +0,0 @@
//-------------------------------------------------------------------------------------
// DirectXTexD3D11X.cpp
//
// DirectXTex Auxilary functions for creating resouces from XboxImage containers
// via the CreatePlacement APIs
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------
#include "DirectXTexP.h"
#include "DirectXTexXbox.h"
#ifdef _GAMING_XBOX
#error This module is not supported for GDK
#elif !defined(_XBOX_ONE) || !defined(_TITLE)
#error This module only supports Xbox One exclusive apps
#endif
using namespace Xbox;
using Microsoft::WRL::ComPtr;
namespace
{
//--------------------------------------------------------------------------------------
// Default XMemAlloc attributes for texture loading
//--------------------------------------------------------------------------------------
const uint64_t c_XMemAllocAttributes = MAKE_XALLOC_ATTRIBUTES(
eXALLOCAllocatorId_MiddlewareReservedMin,
0,
XALLOC_MEMTYPE_GRAPHICS_WRITECOMBINE_GPU_READONLY,
XALLOC_PAGESIZE_64KB,
XALLOC_ALIGNMENT_64K);
}
//=====================================================================================
// Entry-points
//=====================================================================================
//-------------------------------------------------------------------------------------
// Create a texture resource
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::CreateTexture(
ID3D11DeviceX* d3dDevice,
const XboxImage& xbox,
ID3D11Resource** ppResource,
void** grfxMemory)
{
if (!d3dDevice || !ppResource || !grfxMemory)
return E_INVALIDARG;
*grfxMemory = nullptr;
*ppResource = nullptr;
if (!xbox.GetPointer() || !xbox.GetAlignment() || !xbox.GetSize() || xbox.GetTileMode() == c_XboxTileModeInvalid)
return E_INVALIDARG;
// Allocate graphics memory
*grfxMemory = XMemAlloc(xbox.GetSize(), c_XMemAllocAttributes);
if (!*grfxMemory)
return E_OUTOFMEMORY;
// Copy tiled data into graphics memory
memcpy(*grfxMemory, xbox.GetPointer(), xbox.GetSize());
// Create texture resource
auto& metadata = xbox.GetMetadata();
HRESULT hr = E_FAIL;
switch (metadata.dimension)
{
case DirectX::TEX_DIMENSION_TEXTURE1D:
{
D3D11_TEXTURE1D_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
desc.ArraySize = static_cast<UINT>(metadata.arraySize);
desc.Format = metadata.format;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
ID3D11Texture1D* tex = nullptr;
hr = d3dDevice->CreatePlacementTexture1D(&desc, xbox.GetTileMode(), 0, *grfxMemory, &tex);
if (SUCCEEDED(hr) && tex)
{
*ppResource = tex;
}
}
break;
case DirectX::TEX_DIMENSION_TEXTURE2D:
{
D3D11_TEXTURE2D_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.Height = static_cast<UINT>(metadata.height);
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
desc.ArraySize = static_cast<UINT>(metadata.arraySize);
desc.Format = metadata.format;
desc.SampleDesc.Count = 1;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.MiscFlags = (metadata.miscFlags & DirectX::TEX_MISC_TEXTURECUBE) ? D3D11_RESOURCE_MISC_TEXTURECUBE : 0;
ID3D11Texture2D* tex = nullptr;
hr = d3dDevice->CreatePlacementTexture2D(&desc, xbox.GetTileMode(), 0, *grfxMemory, &tex);
if (SUCCEEDED(hr) && tex)
{
*ppResource = tex;
}
}
break;
case DirectX::TEX_DIMENSION_TEXTURE3D:
{
D3D11_TEXTURE3D_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.Height = static_cast<UINT>(metadata.height);
desc.Depth = static_cast<UINT>(metadata.depth);
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
desc.Format = metadata.format;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
ID3D11Texture3D* tex = nullptr;
hr = d3dDevice->CreatePlacementTexture3D(&desc, xbox.GetTileMode(), 0, *grfxMemory, &tex);
if (SUCCEEDED(hr) && tex)
{
*ppResource = tex;
}
}
break;
default:
hr = E_FAIL;
break;
}
if (FAILED(hr))
{
XMemFree(grfxMemory, c_XMemAllocAttributes);
*grfxMemory = nullptr;
}
return hr;
}
//-------------------------------------------------------------------------------------
// Create a shader resource view and associated texture
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::CreateShaderResourceView(
ID3D11DeviceX* d3dDevice,
const XboxImage& xbox,
ID3D11ShaderResourceView** ppSRV,
void** grfxMemory)
{
if (!ppSRV)
return E_INVALIDARG;
*ppSRV = nullptr;
ComPtr<ID3D11Resource> resource;
HRESULT hr = CreateTexture(d3dDevice, xbox, resource.GetAddressOf(), grfxMemory);
if (FAILED(hr))
return hr;
assert(resource);
auto& metadata = xbox.GetMetadata();
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
SRVDesc.Format = metadata.format;
switch (metadata.dimension)
{
case DirectX::TEX_DIMENSION_TEXTURE1D:
if (metadata.arraySize > 1)
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY;
SRVDesc.Texture1DArray.MipLevels = static_cast<UINT>(metadata.mipLevels);
SRVDesc.Texture1DArray.ArraySize = static_cast<UINT>(metadata.arraySize);
}
else
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
SRVDesc.Texture1D.MipLevels = static_cast<UINT>(metadata.mipLevels);
}
break;
case DirectX::TEX_DIMENSION_TEXTURE2D:
if (metadata.IsCubemap())
{
if (metadata.arraySize > 6)
{
assert((metadata.arraySize % 6) == 0);
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
SRVDesc.TextureCubeArray.MipLevels = static_cast<UINT>(metadata.mipLevels);
SRVDesc.TextureCubeArray.NumCubes = static_cast<UINT>(metadata.arraySize / 6);
}
else
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
SRVDesc.TextureCube.MipLevels = static_cast<UINT>(metadata.mipLevels);
}
}
else if (metadata.arraySize > 1)
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
SRVDesc.Texture2DArray.MipLevels = static_cast<UINT>(metadata.mipLevels);
SRVDesc.Texture2DArray.ArraySize = static_cast<UINT>(metadata.arraySize);
}
else
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
SRVDesc.Texture2D.MipLevels = static_cast<UINT>(metadata.mipLevels);
}
break;
case DirectX::TEX_DIMENSION_TEXTURE3D:
assert(metadata.arraySize == 1);
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
SRVDesc.Texture3D.MipLevels = static_cast<UINT>(metadata.mipLevels);
break;
default:
assert(grfxMemory != nullptr);
XMemFree(grfxMemory, c_XMemAllocAttributes);
*grfxMemory = nullptr;
return E_FAIL;
}
hr = d3dDevice->CreateShaderResourceView(resource.Get(), &SRVDesc, ppSRV);
if (FAILED(hr))
{
XMemFree(grfxMemory, c_XMemAllocAttributes);
*grfxMemory = nullptr;
}
return hr;
}
//-------------------------------------------------------------------------------------
// Free allocated graphics memory
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
void Xbox::FreeTextureMemory(ID3D11DeviceX* d3dDevice, void* grfxMemory)
{
UNREFERENCED_PARAMETER(d3dDevice); // used only for overload resolution
if (grfxMemory)
{
XMemFree(grfxMemory, c_XMemAllocAttributes);
}
}

View File

@ -1,117 +0,0 @@
//-------------------------------------------------------------------------------------
// DirectXTexD3D12X.cpp
//
// DirectXTex Auxilary functions for creating resouces from XboxImage containers
// via the CreatePlacedResourceX API
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------
#include "DirectXTexP.h"
#include "DirectXTexXbox.h"
#if !(defined(_XBOX_ONE) && defined(_TITLE)) && !defined(_GAMING_XBOX)
#error This module only supports Xbox exclusive apps
#endif
#ifdef _GAMING_XBOX
#include <xmem.h>
#endif
using namespace Xbox;
using Microsoft::WRL::ComPtr;
namespace
{
//--------------------------------------------------------------------------------------
// Default XMemAlloc attributes for texture loading
//--------------------------------------------------------------------------------------
const uint64_t c_XMemAllocAttributes = MAKE_XALLOC_ATTRIBUTES(
eXALLOCAllocatorId_MiddlewareReservedMin,
0,
XALLOC_MEMTYPE_GRAPHICS_WRITECOMBINE_GPU_READONLY,
XALLOC_PAGESIZE_64KB,
XALLOC_ALIGNMENT_64K
#ifdef _GAMING_XBOX
, 0
#endif
);
}
//=====================================================================================
// Entry-points
//=====================================================================================
//-------------------------------------------------------------------------------------
// Create a texture resource
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::CreateTexture(
ID3D12Device* d3dDevice,
const XboxImage& xbox,
ID3D12Resource** ppResource,
void** grfxMemory)
{
if (!d3dDevice || !ppResource || !grfxMemory)
return E_INVALIDARG;
*grfxMemory = nullptr;
*ppResource = nullptr;
if (!xbox.GetPointer() || !xbox.GetAlignment() || !xbox.GetSize() || xbox.GetTileMode() == c_XboxTileModeInvalid)
return E_INVALIDARG;
// Allocate graphics memory
*grfxMemory = XMemAlloc(xbox.GetSize(), c_XMemAllocAttributes);
if (!*grfxMemory)
return E_OUTOFMEMORY;
// Copy tiled data into graphics memory
memcpy(*grfxMemory, xbox.GetPointer(), xbox.GetSize());
// Create texture resource
auto& metadata = xbox.GetMetadata();
D3D12_RESOURCE_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.Height = static_cast<UINT>(metadata.height);
desc.MipLevels = static_cast<UINT16>(metadata.mipLevels);
desc.DepthOrArraySize = (metadata.dimension == DirectX::TEX_DIMENSION_TEXTURE3D) ? static_cast<UINT16>(metadata.depth) : static_cast<UINT16>(metadata.arraySize);
desc.Format = metadata.format;
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Dimension = static_cast<D3D12_RESOURCE_DIMENSION>(metadata.dimension);
desc.Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x100 | xbox.GetTileMode());
HRESULT hr = d3dDevice->CreatePlacedResourceX(
reinterpret_cast<D3D12_GPU_VIRTUAL_ADDRESS>(*grfxMemory),
&desc,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
nullptr,
IID_GRAPHICS_PPV_ARGS(ppResource));
if (FAILED(hr))
{
XMemFree(*grfxMemory, c_XMemAllocAttributes);
*grfxMemory = nullptr;
}
return hr;
}
//-------------------------------------------------------------------------------------
// Free allocated graphics memory
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
void Xbox::FreeTextureMemory(ID3D12Device* d3dDevice, void* grfxMemory)
{
UNREFERENCED_PARAMETER(d3dDevice); // used only for overload resolution
if (grfxMemory)
{
XMemFree(grfxMemory, c_XMemAllocAttributes);
}
}

View File

@ -1,822 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexXboxDDS.cpp
//
// DirectXTex Auxilary functions for saving "XBOX" Xbox variants of DDS files
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#include "DirectXTexP.h"
#include "DirectXTexXbox.h"
#include "DDS.h"
#if defined(_GAMING_XBOX) || defined(_USE_GXDK)
#include "gxdk.h"
#else
#include "xdk.h"
#endif
using namespace DirectX;
using namespace Xbox;
namespace
{
//-------------------------------------------------------------------------------------
// Decodes DDS header using XBOX extended header (variant of DX10 header)
//-------------------------------------------------------------------------------------
HRESULT DecodeDDSHeader(
_In_reads_bytes_(size) const uint8_t* pSource,
size_t size,
DirectX::TexMetadata& metadata,
_Out_opt_ DDSMetaData* ddPixelFormat,
_Out_opt_ XboxTileMode* tmode,
_Out_opt_ uint32_t* dataSize,
_Out_opt_ uint32_t* baseAlignment)
{
if (!pSource)
return E_INVALIDARG;
if (tmode)
{
*tmode = c_XboxTileModeInvalid;
}
if (dataSize)
{
*dataSize = 0;
}
if (baseAlignment)
{
*baseAlignment = 0;
}
metadata = {};
if (ddPixelFormat)
{
*ddPixelFormat = {};
}
if (size < DDS_MIN_HEADER_SIZE)
{
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
}
// DDS files always start with the same magic number ("DDS ")
const auto dwMagicNumber = *reinterpret_cast<const uint32_t*>(pSource);
if (dwMagicNumber != DDS_MAGIC)
{
return E_FAIL;
}
auto pHeader = reinterpret_cast<const DDS_HEADER*>(reinterpret_cast<const uint8_t*>(pSource) + sizeof(uint32_t));
// Verify header to validate DDS file
if (pHeader->size != sizeof(DDS_HEADER)
|| pHeader->ddspf.size != sizeof(DDS_PIXELFORMAT))
{
return E_FAIL;
}
metadata.mipLevels = pHeader->mipMapCount;
if (metadata.mipLevels == 0)
metadata.mipLevels = 1;
// Check for XBOX extension
if (!(pHeader->ddspf.flags & DDS_FOURCC)
|| (MAKEFOURCC('X', 'B', 'O', 'X') != pHeader->ddspf.fourCC))
{
// We know it's a DDS file, but it's not an XBOX extension
return S_FALSE;
}
// Buffer must be big enough for both headers and magic value
if (size < DDS_XBOX_HEADER_SIZE)
{
return E_FAIL;
}
auto xboxext = reinterpret_cast<const DDS_HEADER_XBOX*>(
reinterpret_cast<const uint8_t*>(pSource) + DDS_MIN_HEADER_SIZE);
metadata.arraySize = xboxext->arraySize;
if (metadata.arraySize == 0)
{
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
}
metadata.format = xboxext->dxgiFormat;
if (!IsValid(metadata.format))
{
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
}
static_assert(static_cast<int>(TEX_MISC_TEXTURECUBE) == static_cast<int>(DDS_RESOURCE_MISC_TEXTURECUBE), "DDS header mismatch");
metadata.miscFlags = xboxext->miscFlag & ~static_cast<uint32_t>(TEX_MISC_TEXTURECUBE);
switch (xboxext->resourceDimension)
{
case DDS_DIMENSION_TEXTURE1D:
if ((pHeader->flags & DDS_HEIGHT) && pHeader->height != 1)
{
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
}
metadata.width = pHeader->width;
metadata.height = 1;
metadata.depth = 1;
metadata.dimension = TEX_DIMENSION_TEXTURE1D;
break;
case DDS_DIMENSION_TEXTURE2D:
if (xboxext->miscFlag & DDS_RESOURCE_MISC_TEXTURECUBE)
{
metadata.miscFlags |= TEX_MISC_TEXTURECUBE;
metadata.arraySize *= 6;
}
metadata.width = pHeader->width;
metadata.height = pHeader->height;
metadata.depth = 1;
metadata.dimension = TEX_DIMENSION_TEXTURE2D;
break;
case DDS_DIMENSION_TEXTURE3D:
if (!(pHeader->flags & DDS_HEADER_FLAGS_VOLUME))
{
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
}
if (metadata.arraySize > 1)
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
metadata.width = pHeader->width;
metadata.height = pHeader->height;
metadata.depth = pHeader->depth;
metadata.dimension = TEX_DIMENSION_TEXTURE3D;
break;
default:
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
}
if (static_cast<XboxTileMode>(xboxext->tileMode) == c_XboxTileModeInvalid)
{
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
}
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
else if (!(xboxext->tileMode & XBOX_TILEMODE_SCARLETT))
{
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
#else
else if (xboxext->tileMode & XBOX_TILEMODE_SCARLETT)
{
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
#endif
static_assert(static_cast<int>(TEX_MISC2_ALPHA_MODE_MASK) == static_cast<int>(DDS_MISC_FLAGS2_ALPHA_MODE_MASK), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_UNKNOWN) == static_cast<int>(DDS_ALPHA_MODE_UNKNOWN), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_STRAIGHT) == static_cast<int>(DDS_ALPHA_MODE_STRAIGHT), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_PREMULTIPLIED) == static_cast<int>(DDS_ALPHA_MODE_PREMULTIPLIED), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_OPAQUE) == static_cast<int>(DDS_ALPHA_MODE_OPAQUE), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_CUSTOM) == static_cast<int>(DDS_ALPHA_MODE_CUSTOM), "DDS header mismatch");
metadata.miscFlags2 = xboxext->miscFlags2;
if (tmode)
{
*tmode = static_cast<XboxTileMode>(xboxext->tileMode & ~XBOX_TILEMODE_SCARLETT);
}
if (baseAlignment)
*baseAlignment = xboxext->baseAlignment;
if (dataSize)
*dataSize = xboxext->dataSize;
// Handle DDS-specific metadata
if (ddPixelFormat)
{
ddPixelFormat->size = pHeader->ddspf.size;
ddPixelFormat->flags = pHeader->ddspf.flags;
ddPixelFormat->fourCC = pHeader->ddspf.fourCC;
ddPixelFormat->RGBBitCount = pHeader->ddspf.RGBBitCount;
ddPixelFormat->RBitMask = pHeader->ddspf.RBitMask;
ddPixelFormat->GBitMask = pHeader->ddspf.GBitMask;
ddPixelFormat->BBitMask = pHeader->ddspf.BBitMask;
ddPixelFormat->ABitMask = pHeader->ddspf.ABitMask;
}
return S_OK;
}
}
//=====================================================================================
// Entry-points
//=====================================================================================
//-------------------------------------------------------------------------------------
// Encodes DDS file header (magic value, header, XBOX extended header)
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::EncodeDDSHeader(
const XboxImage& xbox,
uint8_t* pDestination,
size_t maxsize) noexcept
{
if (!pDestination)
return E_INVALIDARG;
if (maxsize < DDS_XBOX_HEADER_SIZE)
return E_NOT_SUFFICIENT_BUFFER;
*reinterpret_cast<uint32_t*>(pDestination) = DDS_MAGIC;
auto header = reinterpret_cast<DDS_HEADER*>(reinterpret_cast<uint8_t*>(pDestination) + sizeof(uint32_t));
memset(header, 0, sizeof(DDS_HEADER));
header->size = sizeof(DDS_HEADER);
header->flags = DDS_HEADER_FLAGS_TEXTURE;
header->caps = DDS_SURFACE_FLAGS_TEXTURE;
auto& metadata = xbox.GetMetadata();
if (metadata.mipLevels > 0)
{
header->flags |= DDS_HEADER_FLAGS_MIPMAP;
if (metadata.mipLevels > UINT32_MAX)
return E_INVALIDARG;
header->mipMapCount = static_cast<uint32_t>(metadata.mipLevels);
if (header->mipMapCount > 1)
header->caps |= DDS_SURFACE_FLAGS_MIPMAP;
}
switch (metadata.dimension)
{
case TEX_DIMENSION_TEXTURE1D:
if (metadata.width > UINT32_MAX)
return E_INVALIDARG;
header->width = static_cast<uint32_t>(metadata.width);
header->height = header->depth = 1;
break;
case TEX_DIMENSION_TEXTURE2D:
if (metadata.height > UINT32_MAX
|| metadata.width > UINT32_MAX)
return E_INVALIDARG;
header->height = static_cast<uint32_t>(metadata.height);
header->width = static_cast<uint32_t>(metadata.width);
header->depth = 1;
if (metadata.IsCubemap())
{
header->caps |= DDS_SURFACE_FLAGS_CUBEMAP;
header->caps2 |= DDS_CUBEMAP_ALLFACES;
}
break;
case TEX_DIMENSION_TEXTURE3D:
if (metadata.height > UINT32_MAX
|| metadata.width > UINT32_MAX
|| metadata.depth > UINT32_MAX)
return E_INVALIDARG;
header->flags |= DDS_HEADER_FLAGS_VOLUME;
header->caps2 |= DDS_FLAGS_VOLUME;
header->height = static_cast<uint32_t>(metadata.height);
header->width = static_cast<uint32_t>(metadata.width);
header->depth = static_cast<uint32_t>(metadata.depth);
break;
default:
return E_FAIL;
}
size_t rowPitch, slicePitch;
ComputePitch(metadata.format, metadata.width, metadata.height, rowPitch, slicePitch, CP_FLAGS_NONE);
if (slicePitch > UINT32_MAX
|| rowPitch > UINT32_MAX)
return E_FAIL;
if (IsCompressed(metadata.format))
{
header->flags |= DDS_HEADER_FLAGS_LINEARSIZE;
header->pitchOrLinearSize = static_cast<uint32_t>(slicePitch);
}
else
{
header->flags |= DDS_HEADER_FLAGS_PITCH;
header->pitchOrLinearSize = static_cast<uint32_t>(rowPitch);
}
memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_XBOX, sizeof(DDS_PIXELFORMAT));
// Setup XBOX extended header
auto xboxext = reinterpret_cast<DDS_HEADER_XBOX*>(reinterpret_cast<uint8_t*>(header) + sizeof(DDS_HEADER));
memset(xboxext, 0, sizeof(DDS_HEADER_XBOX));
xboxext->dxgiFormat = metadata.format;
xboxext->resourceDimension = metadata.dimension;
if (metadata.arraySize > UINT32_MAX)
return E_INVALIDARG;
static_assert(static_cast<int>(TEX_MISC_TEXTURECUBE) == static_cast<int>(DDS_RESOURCE_MISC_TEXTURECUBE), "DDS header mismatch");
xboxext->miscFlag = metadata.miscFlags & ~static_cast<uint32_t>(TEX_MISC_TEXTURECUBE);
if (metadata.miscFlags & TEX_MISC_TEXTURECUBE)
{
xboxext->miscFlag |= TEX_MISC_TEXTURECUBE;
assert((metadata.arraySize % 6) == 0);
xboxext->arraySize = static_cast<UINT>(metadata.arraySize / 6);
}
else
{
xboxext->arraySize = static_cast<UINT>(metadata.arraySize);
}
static_assert(static_cast<int>(TEX_MISC2_ALPHA_MODE_MASK) == static_cast<int>(DDS_MISC_FLAGS2_ALPHA_MODE_MASK), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_UNKNOWN) == static_cast<int>(DDS_ALPHA_MODE_UNKNOWN), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_STRAIGHT) == static_cast<int>(DDS_ALPHA_MODE_STRAIGHT), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_PREMULTIPLIED) == static_cast<int>(DDS_ALPHA_MODE_PREMULTIPLIED), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_OPAQUE) == static_cast<int>(DDS_ALPHA_MODE_OPAQUE), "DDS header mismatch");
static_assert(static_cast<int>(TEX_ALPHA_MODE_CUSTOM) == static_cast<int>(DDS_ALPHA_MODE_CUSTOM), "DDS header mismatch");
xboxext->miscFlags2 = metadata.miscFlags2;
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
xboxext->tileMode = static_cast<uint32_t>(xbox.GetTileMode()) | XBOX_TILEMODE_SCARLETT;
#else
xboxext->tileMode = static_cast<uint32_t>(xbox.GetTileMode());
#endif
xboxext->baseAlignment = xbox.GetAlignment();
xboxext->dataSize = xbox.GetSize();
#ifdef _GXDK_VER
xboxext->xdkVer = _GXDK_VER;
#elif defined(_XDK_VER)
xboxext->xdkVer = _XDK_VER;
#endif
return S_OK;
}
//-------------------------------------------------------------------------------------
// Obtain metadata from DDS file in memory/on disk
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::GetMetadataFromDDSMemory(
const uint8_t* pSource,
size_t size,
TexMetadata& metadata,
bool& isXbox)
{
return Xbox::GetMetadataFromDDSMemoryEx(pSource, size, metadata, isXbox, nullptr);
}
_Use_decl_annotations_
HRESULT Xbox::GetMetadataFromDDSMemoryEx(
const uint8_t* pSource,
size_t size,
TexMetadata& metadata,
bool& isXbox,
DDSMetaData* ddPixelFormat)
{
if (!pSource || !size)
return E_INVALIDARG;
isXbox = false;
HRESULT hr = DecodeDDSHeader(pSource, size, metadata, ddPixelFormat, nullptr, nullptr, nullptr);
if (hr == S_FALSE)
{
hr = DirectX::GetMetadataFromDDSMemoryEx(pSource, size, DirectX::DDS_FLAGS_NONE, metadata, ddPixelFormat);
}
else if (SUCCEEDED(hr))
{
isXbox = true;
}
return hr;
}
_Use_decl_annotations_
HRESULT Xbox::GetMetadataFromDDSFile(
const wchar_t* szFile,
TexMetadata& metadata,
bool& isXbox)
{
return Xbox::GetMetadataFromDDSFileEx(szFile, metadata, isXbox, nullptr);
}
_Use_decl_annotations_
HRESULT Xbox::GetMetadataFromDDSFileEx(
const wchar_t* szFile,
TexMetadata& metadata,
bool& isXbox,
DDSMetaData* ddPixelFormat)
{
if (!szFile)
return E_INVALIDARG;
isXbox = false;
ScopedHandle hFile(safe_handle(CreateFile2(
szFile,
GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING,
nullptr)));
if (!hFile)
{
return HRESULT_FROM_WIN32(GetLastError());
}
// Get the file size
FILE_STANDARD_INFO fileInfo;
if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo)))
{
return HRESULT_FROM_WIN32(GetLastError());
}
// File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough for a valid DDS file)
if (fileInfo.EndOfFile.HighPart > 0)
{
return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE);
}
// Need at least enough data to fill the standard header and magic number to be a valid DDS
if (fileInfo.EndOfFile.LowPart < DDS_MIN_HEADER_SIZE)
{
return E_FAIL;
}
// Read the header in (including extended header if present)
uint8_t header[DDS_XBOX_HEADER_SIZE] = {};
DWORD bytesRead = 0;
if (!ReadFile(hFile.get(), header, DDS_XBOX_HEADER_SIZE, &bytesRead, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
}
HRESULT hr = DecodeDDSHeader(header, bytesRead, metadata, ddPixelFormat, nullptr, nullptr, nullptr);
if (hr == S_FALSE)
{
hr = DirectX::GetMetadataFromDDSMemoryEx(header, bytesRead, DirectX::DDS_FLAGS_NONE, metadata, ddPixelFormat);
}
else if (SUCCEEDED(hr))
{
isXbox = true;
}
return hr;
}
//-------------------------------------------------------------------------------------
// Load a DDS file in memory
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::LoadFromDDSMemory(
const uint8_t* pSource,
size_t size,
TexMetadata* metadata,
XboxImage& xbox)
{
return Xbox::LoadFromDDSMemoryEx(pSource, size, metadata, nullptr, xbox);
}
_Use_decl_annotations_
HRESULT Xbox::LoadFromDDSMemoryEx(
const uint8_t* pSource,
size_t size,
TexMetadata* metadata,
DDSMetaData* ddPixelFormat,
XboxImage& xbox)
{
if (!pSource || !size)
return E_INVALIDARG;
xbox.Release();
TexMetadata mdata;
uint32_t dataSize;
uint32_t baseAlignment;
XboxTileMode tmode;
HRESULT hr = DecodeDDSHeader(pSource, size, mdata, ddPixelFormat, &tmode, &dataSize, &baseAlignment);
if (hr == S_FALSE)
{
// It's a DDS, but not an XBOX variant
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
if (FAILED(hr))
{
return hr;
}
if (!dataSize || !baseAlignment)
{
return E_FAIL;
}
if (size <= DDS_XBOX_HEADER_SIZE)
{
return E_FAIL;
}
// Copy tiled data
const size_t remaining = size - DDS_XBOX_HEADER_SIZE;
if (remaining < dataSize)
{
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
hr = xbox.Initialize(mdata, tmode, dataSize, baseAlignment);
if (FAILED(hr))
return hr;
assert(xbox.GetPointer() != nullptr);
memcpy(xbox.GetPointer(), reinterpret_cast<const uint8_t*>(pSource) + DDS_XBOX_HEADER_SIZE, dataSize);
if (metadata)
memcpy(metadata, &mdata, sizeof(TexMetadata));
return S_OK;
}
//-------------------------------------------------------------------------------------
// Load a DDS file from disk
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::LoadFromDDSFile(
const wchar_t* szFile,
TexMetadata* metadata,
XboxImage& xbox)
{
return Xbox::LoadFromDDSFileEx(szFile, metadata, nullptr, xbox);
}
_Use_decl_annotations_
HRESULT Xbox::LoadFromDDSFileEx(
const wchar_t* szFile,
TexMetadata* metadata,
DDSMetaData* ddPixelFormat,
XboxImage& xbox)
{
if (!szFile)
return E_INVALIDARG;
xbox.Release();
ScopedHandle hFile(safe_handle(CreateFile2(
szFile,
GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING,
nullptr)));
if (!hFile)
{
return HRESULT_FROM_WIN32(GetLastError());
}
// Get the file size
FILE_STANDARD_INFO fileInfo;
if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo)))
{
return HRESULT_FROM_WIN32(GetLastError());
}
// File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough for a valid DDS file)
if (fileInfo.EndOfFile.HighPart > 0)
{
return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE);
}
// Need at least enough data to fill the standard header and magic number to be a valid DDS
if (fileInfo.EndOfFile.LowPart < DDS_MIN_HEADER_SIZE)
{
return E_FAIL;
}
// Read the header in (including extended header if present)
uint8_t header[DDS_XBOX_HEADER_SIZE] = {};
DWORD bytesRead = 0;
if (!ReadFile(hFile.get(), header, DDS_XBOX_HEADER_SIZE, &bytesRead, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
}
TexMetadata mdata;
XboxTileMode tmode;
uint32_t dataSize;
uint32_t baseAlignment;
HRESULT hr = DecodeDDSHeader(header, bytesRead, mdata, ddPixelFormat, &tmode, &dataSize, &baseAlignment);
if (hr == S_FALSE)
{
// It's a DDS, but not an XBOX variant
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
if (FAILED(hr))
return hr;
if (!dataSize || !baseAlignment)
{
return E_FAIL;
}
// Read tiled data
const DWORD remaining = fileInfo.EndOfFile.LowPart - DDS_XBOX_HEADER_SIZE;
if (remaining == 0)
return E_FAIL;
if (remaining < dataSize)
{
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
hr = xbox.Initialize(mdata, tmode, dataSize, baseAlignment);
if (FAILED(hr))
return hr;
assert(xbox.GetPointer() != nullptr);
if (!ReadFile(hFile.get(), xbox.GetPointer(), dataSize, &bytesRead, nullptr))
{
xbox.Release();
return HRESULT_FROM_WIN32(GetLastError());
}
if (metadata)
memcpy(metadata, &mdata, sizeof(TexMetadata));
return S_OK;
}
//-------------------------------------------------------------------------------------
// Save a DDS file to memory
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::SaveToDDSMemory(const XboxImage& xbox, Blob& blob)
{
if (!xbox.GetPointer() || !xbox.GetSize() || !xbox.GetAlignment())
return E_INVALIDARG;
blob.Release();
HRESULT hr = blob.Initialize(DDS_XBOX_HEADER_SIZE + xbox.GetSize());
if (FAILED(hr))
return hr;
// Copy header
auto pDestination = blob.GetBufferPointer();
assert(pDestination);
hr = EncodeDDSHeader(xbox, pDestination, DDS_XBOX_HEADER_SIZE);
if (FAILED(hr))
{
blob.Release();
return hr;
}
// Copy tiled data
const size_t remaining = blob.GetBufferSize() - DDS_XBOX_HEADER_SIZE;
pDestination += DDS_XBOX_HEADER_SIZE;
if (!remaining)
{
blob.Release();
return E_FAIL;
}
if (remaining < xbox.GetSize())
{
blob.Release();
return E_UNEXPECTED;
}
memcpy(pDestination, xbox.GetPointer(), xbox.GetSize());
return S_OK;
}
//-------------------------------------------------------------------------------------
// Save a DDS file to disk
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::SaveToDDSFile(const XboxImage& xbox, const wchar_t* szFile)
{
if (!szFile || !xbox.GetPointer() || !xbox.GetSize() || !xbox.GetAlignment())
return E_INVALIDARG;
// Create DDS Header
uint8_t header[DDS_XBOX_HEADER_SIZE] = {};
HRESULT hr = EncodeDDSHeader(xbox, header, DDS_XBOX_HEADER_SIZE);
if (FAILED(hr))
return hr;
// Create file and write header
ScopedHandle hFile(safe_handle(CreateFile2(
szFile,
GENERIC_WRITE, 0, CREATE_ALWAYS,
nullptr)));
if (!hFile)
{
return HRESULT_FROM_WIN32(GetLastError());
}
DWORD bytesWritten;
if (!WriteFile(hFile.get(), header, static_cast<DWORD>(DDS_XBOX_HEADER_SIZE), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
}
if (bytesWritten != DDS_XBOX_HEADER_SIZE)
{
return E_FAIL;
}
// Write tiled data
if (!WriteFile(hFile.get(), xbox.GetPointer(), static_cast<DWORD>(xbox.GetSize()), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
}
if (bytesWritten != xbox.GetSize())
{
return E_FAIL;
}
return S_OK;
}
//--------------------------------------------------------------------------------------
// Adapters for /Zc:wchar_t- clients
#if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
namespace Xbox
{
HRESULT __cdecl GetMetadataFromDDSFile(
_In_z_ const __wchar_t* szFile,
_Out_ DirectX::TexMetadata& metadata,
_Out_ bool& isXbox)
{
return GetMetadataFromDDSFile(reinterpret_cast<const unsigned short*>(szFile), metadata, isXbox);
}
HRESULT __cdecl GetMetadataFromDDSFileEx(
_In_z_ const __wchar_t* szFile,
_Out_ DirectX::TexMetadata& metadata,
_Out_ bool& isXbox,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat)
{
return GetMetadataFromDDSFileEx(reinterpret_cast<const unsigned short*>(szFile), metadata, isXbox, ddPixelFormat);
}
HRESULT __cdecl LoadFromDDSFile(
_In_z_ const __wchar_t* szFile,
_Out_opt_ DirectX::TexMetadata* metadata,
_Out_ XboxImage& image)
{
return LoadFromDDSFile(reinterpret_cast<const unsigned short*>(szFile), metadata, image);
}
HRESULT __cdecl LoadFromDDSFileEx(
_In_z_ const __wchar_t* szFile,
_Out_opt_ DirectX::TexMetadata* metadata,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat,
_Out_ XboxImage& image)
{
return LoadFromDDSFileEx(reinterpret_cast<const unsigned short*>(szFile), metadata, ddPixelFormat, image);
}
HRESULT __cdecl SaveToDDSFile(_In_ const XboxImage& xbox, _In_z_ const __wchar_t* szFile)
{
return SaveToDDSFile(xbox, reinterpret_cast<const unsigned short*>(szFile));
}
}
#endif // !_NATIVE_WCHAR_T_DEFINED

View File

@ -1,559 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexXboxDetile.cpp
//
// DirectXTex Auxilary functions for converting from Xbox tiled to linear
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#include "DirectXTexP.h"
#include "DirectXTexXbox.h"
using Microsoft::WRL::ComPtr;
using namespace DirectX;
using namespace DirectX::Internal;
using namespace Xbox;
namespace
{
//----------------------------------------------------------------------------------
inline HRESULT DetileByElement1D(
const XboxImage& xbox,
uint32_t level,
_In_ XGTextureAddressComputer* computer,
const XG_RESOURCE_LAYOUT& layout,
_In_reads_(nimages) const Image* const * result,
size_t nimages,
size_t bpp,
size_t w,
bool packed)
{
const uint8_t* sptr = xbox.GetPointer();
const uint8_t* endPtr = sptr + layout.SizeBytes;
assert((nimages > 0) && (nimages <= UINT32_MAX));
for (size_t item = 0; item < nimages; ++item)
{
const Image* img = result[item];
if (!img || !img->pixels)
return E_POINTER;
assert(img->width == result[0]->width);
assert(img->height == result[0]->height);
assert(img->rowPitch == result[0]->rowPitch);
assert(img->format == result[0]->format);
uint8_t* dptr = img->pixels;
for (size_t x = 0; x < w; ++x)
{
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
const UINT64 element = (packed) ? (x >> 1) : x;
const size_t offset = computer->GetTexelElementOffsetBytes(0, static_cast<uint32_t>(level), element, 0, static_cast<uint32_t>(item), 0, nullptr);
#else
const size_t offset = computer->GetTexelElementOffsetBytes(0, static_cast<uint32_t>(level), x, 0, static_cast<uint32_t>(item), 0);
#endif
if (offset == size_t(-1))
return E_FAIL;
const uint8_t* src = sptr + offset;
if ((src + bpp) > endPtr)
return E_FAIL;
memcpy(dptr, src, bpp);
dptr += bpp;
if (packed)
++x;
}
}
return S_OK;
}
//-------------------------------------------------------------------------------------
// 1D Tiling
//-------------------------------------------------------------------------------------
HRESULT Detile1D(
const XboxImage& xbox,
uint32_t level,
_In_ XGTextureAddressComputer* computer,
const XG_RESOURCE_LAYOUT& layout,
_In_reads_(nimages) const Image** result,
size_t nimages)
{
if (!nimages || nimages > UINT32_MAX)
return E_INVALIDARG;
if (!xbox.GetPointer() || !computer || !result || !result[0])
return E_POINTER;
assert(layout.Planes == 1);
const DXGI_FORMAT format = result[0]->format;
assert(format == xbox.GetMetadata().format);
assert(!IsCompressed(format));
bool byelement = IsTypeless(format);
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
if (nimages > 1)
byelement = true;
#endif
if (IsPacked(format))
{
const size_t bpp = (BitsPerPixel(format) + 7) / 8;
// XG (XboxOne) incorrectly returns 2 instead of 4 here for layout.Plane[0].BytesPerElement
const size_t w = result[0]->width;
assert(((w + 1) / 2) == layout.Plane[0].MipLayout[level].WidthElements);
return DetileByElement1D(xbox, level, computer, layout, result, nimages, bpp, w, true);
}
else if (byelement)
{
//--- Typeless is done with per-element copy ----------------------------------
const size_t bpp = (BitsPerPixel(format) + 7) / 8;
assert(bpp == layout.Plane[0].BytesPerElement);
const size_t w = result[0]->width;
assert(w == layout.Plane[0].MipLayout[level].WidthElements);
return DetileByElement1D(xbox, level, computer, layout, result, nimages, bpp, w, false);
}
else
{
//--- Standard format handling ------------------------------------------------
auto& mip = layout.Plane[0].MipLayout[level];
const UINT32 tiledPixels = mip.PitchPixels * mip.PaddedDepthOrArraySize;
auto scanline = make_AlignedArrayXMVECTOR(tiledPixels + result[0]->width);
XMVECTOR* target = scanline.get();
XMVECTOR* tiled = target + result[0]->width;
#ifdef _DEBUG
memset(target, 0xCD, sizeof(XMVECTOR) * result[0]->width);
memset(tiled, 0xDD, sizeof(XMVECTOR) * tiledPixels);
#endif
// Load tiled texture
if ((xbox.GetSize() - mip.OffsetBytes) < mip.SizeBytes)
return E_FAIL;
if (!LoadScanline(tiled, tiledPixels, xbox.GetPointer() + mip.OffsetBytes, mip.SizeBytes, xbox.GetMetadata().format))
return E_FAIL;
// Perform detiling
for (size_t item = 0; item < nimages; ++item)
{
const Image* img = result[item];
if (!img || !img->pixels)
return E_POINTER;
assert(img->width == result[0]->width);
assert(img->height == result[0]->height);
assert(img->rowPitch == result[0]->rowPitch);
assert(img->format == result[0]->format);
for (size_t x = 0; x < img->width; ++x)
{
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
size_t offset = computer->GetTexelElementOffsetBytes(0, level, x, 0, static_cast<uint32_t>(item), 0, nullptr);
#else
size_t offset = computer->GetTexelElementOffsetBytes(0, level, x, 0, static_cast<uint32_t>(item), 0);
#endif
if (offset == size_t(-1))
return E_FAIL;
assert(offset >= mip.OffsetBytes);
assert(offset < mip.OffsetBytes + mip.SizeBytes);
offset = (offset - mip.OffsetBytes) / layout.Plane[0].BytesPerElement;
assert(offset < tiledPixels);
target[x] = tiled[offset];
}
if (!StoreScanline(img->pixels, img->rowPitch, img->format, target, img->width))
return E_FAIL;
}
}
return S_OK;
}
//-------------------------------------------------------------------------------------
// 2D Tiling
//-------------------------------------------------------------------------------------
HRESULT Detile2D(
const XboxImage& xbox,
uint32_t level,
_In_ XGTextureAddressComputer* computer,
_In_reads_(nimages) const Image** result,
size_t nimages)
{
if (!nimages || nimages > UINT32_MAX)
return E_INVALIDARG;
if (!xbox.GetPointer() || !computer || !result || !result[0])
return E_POINTER;
assert(xbox.GetMetadata().format == result[0]->format);
uint8_t* baseAddr = xbox.GetPointer();
const auto& metadata = xbox.GetMetadata();
for (size_t item = 0; item < nimages; ++item)
{
const Image* img = result[item];
if (!img || !img->pixels)
return E_POINTER;
assert(img->width == result[0]->width);
assert(img->height == result[0]->height);
assert(img->rowPitch == result[0]->rowPitch);
assert(img->format == result[0]->format);
HRESULT hr = computer->CopyFromSubresource(
img->pixels,
0u,
metadata.CalculateSubresource(level, item),
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
0u,
#endif
baseAddr,
static_cast<UINT32>(img->rowPitch),
0u);
if (FAILED(hr))
{
return hr;
}
}
return S_OK;
}
//-------------------------------------------------------------------------------------
// 3D Tiling
//-------------------------------------------------------------------------------------
HRESULT Detile3D(
const XboxImage& xbox,
uint32_t level,
_In_ XGTextureAddressComputer* computer,
const Image& result)
{
if (!computer || !xbox.GetPointer() || !result.pixels)
return E_POINTER;
assert(xbox.GetMetadata().format == result.format);
uint8_t* baseAddr = xbox.GetPointer();
const auto& metadata = xbox.GetMetadata();
return computer->CopyFromSubresource(
result.pixels,
0u,
metadata.CalculateSubresource(level, 0),
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
0u,
#endif
baseAddr,
static_cast<UINT32>(result.rowPitch),
static_cast<UINT32>(result.slicePitch));
}
}
//=====================================================================================
// Entry-points
//=====================================================================================
//-------------------------------------------------------------------------------------
// Detile image
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::Detile(
const XboxImage& xbox,
DirectX::ScratchImage& image)
{
if (!xbox.GetSize() || !xbox.GetPointer() || xbox.GetTileMode() == c_XboxTileModeInvalid)
return E_INVALIDARG;
image.Release();
auto& metadata = xbox.GetMetadata();
if (metadata.format == DXGI_FORMAT_R1_UNORM
|| IsVideo(metadata.format))
{
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
switch (metadata.format)
{
case DXGI_FORMAT_R32G32B32_TYPELESS:
case DXGI_FORMAT_R32G32B32_FLOAT:
case DXGI_FORMAT_R32G32B32_UINT:
case DXGI_FORMAT_R32G32B32_SINT:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
default:
break;
}
XG_RESOURCE_LAYOUT layout = {};
switch (metadata.dimension)
{
case TEX_DIMENSION_TEXTURE1D:
{
if (metadata.width > D3D11_REQ_TEXTURE1D_U_DIMENSION
|| metadata.mipLevels > D3D11_REQ_MIP_LEVELS
|| metadata.arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION)
return E_INVALIDARG;
XG_TEXTURE1D_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
desc.ArraySize = static_cast<UINT>(metadata.arraySize);
desc.Format = static_cast<XG_FORMAT>(metadata.format);
desc.Usage = XG_USAGE_DEFAULT;
desc.BindFlags = XG_BIND_SHADER_RESOURCE;
desc.MiscFlags = (metadata.IsCubemap()) ? XG_RESOURCE_MISC_TEXTURECUBE : 0;
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode = xbox.GetTileMode();
#else
desc.TileMode = xbox.GetTileMode();
#endif
ComPtr<XGTextureAddressComputer> computer;
HRESULT hr = XGCreateTexture1DComputer(&desc, computer.GetAddressOf());
if (FAILED(hr))
return hr;
hr = computer->GetResourceLayout(&layout);
if (FAILED(hr))
return hr;
if (layout.Planes != 1)
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
if (layout.SizeBytes != xbox.GetSize()
|| layout.BaseAlignmentBytes != xbox.GetAlignment())
return E_UNEXPECTED;
hr = image.Initialize(metadata);
if (FAILED(hr))
return hr;
for (size_t level = 0; level < metadata.mipLevels; ++level)
{
if (metadata.arraySize > 1)
{
std::vector<const Image*> images;
images.reserve(metadata.arraySize);
for (size_t item = 0; item < metadata.arraySize; ++item)
{
const Image* img = image.GetImage(level, item, 0);
if (!img)
{
image.Release();
return E_FAIL;
}
images.push_back(img);
}
hr = Detile1D(xbox, static_cast<uint32_t>(level), computer.Get(), layout, &images[0], images.size());
}
else
{
const Image* img = image.GetImage(level, 0, 0);
if (!img)
{
image.Release();
return E_FAIL;
}
hr = Detile1D(xbox, static_cast<uint32_t>(level), computer.Get(), layout, &img, 1);
}
if (FAILED(hr))
{
image.Release();
return hr;
}
}
}
break;
case TEX_DIMENSION_TEXTURE2D:
{
if (metadata.width > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION
|| metadata.height > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION
|| metadata.mipLevels > D3D11_REQ_MIP_LEVELS
|| metadata.arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION)
return E_INVALIDARG;
XG_TEXTURE2D_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.Height = static_cast<UINT>(metadata.height);
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
desc.ArraySize = static_cast<UINT>(metadata.arraySize);
desc.Format = static_cast<XG_FORMAT>(metadata.format);
desc.SampleDesc.Count = 1;
desc.Usage = XG_USAGE_DEFAULT;
desc.BindFlags = XG_BIND_SHADER_RESOURCE;
desc.MiscFlags = (metadata.miscFlags & TEX_MISC_TEXTURECUBE) ? XG_RESOURCE_MISC_TEXTURECUBE : 0;
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode = xbox.GetTileMode();
#else
desc.TileMode = xbox.GetTileMode();
#endif
ComPtr<XGTextureAddressComputer> computer;
HRESULT hr = XGCreateTexture2DComputer(&desc, computer.GetAddressOf());
if (FAILED(hr))
return hr;
hr = computer->GetResourceLayout(&layout);
if (FAILED(hr))
return hr;
if (layout.Planes != 1)
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
if (layout.SizeBytes != xbox.GetSize()
|| layout.BaseAlignmentBytes != xbox.GetAlignment())
return E_UNEXPECTED;
hr = image.Initialize(metadata);
if (FAILED(hr))
return hr;
for (size_t level = 0; level < metadata.mipLevels; ++level)
{
if (metadata.arraySize > 1)
{
std::vector<const Image*> images;
images.reserve(metadata.arraySize);
for (size_t item = 0; item < metadata.arraySize; ++item)
{
const Image* img = image.GetImage(level, item, 0);
if (!img)
{
image.Release();
return E_FAIL;
}
images.push_back(img);
}
hr = Detile2D(xbox, static_cast<uint32_t>(level), computer.Get(), &images[0], images.size());
}
else
{
const Image* img = image.GetImage(level, 0, 0);
if (!img)
{
image.Release();
return E_FAIL;
}
hr = Detile2D(xbox, static_cast<uint32_t>(level), computer.Get(), &img, 1);
}
if (FAILED(hr))
{
image.Release();
return hr;
}
}
}
break;
case TEX_DIMENSION_TEXTURE3D:
{
if (metadata.width > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
|| metadata.height > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
|| metadata.depth > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
|| metadata.mipLevels > D3D11_REQ_MIP_LEVELS
|| metadata.arraySize != 1)
return E_INVALIDARG;
XG_TEXTURE3D_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.Height = static_cast<UINT>(metadata.height);
desc.Depth = static_cast<UINT>(metadata.depth);
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
desc.Format = static_cast<XG_FORMAT>(metadata.format);
desc.Usage = XG_USAGE_DEFAULT;
desc.BindFlags = XG_BIND_SHADER_RESOURCE;
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode = xbox.GetTileMode();
#else
desc.TileMode = xbox.GetTileMode();
#endif
ComPtr<XGTextureAddressComputer> computer;
HRESULT hr = XGCreateTexture3DComputer(&desc, computer.GetAddressOf());
if (FAILED(hr))
return hr;
hr = computer->GetResourceLayout(&layout);
if (FAILED(hr))
return hr;
if (layout.Planes != 1)
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
if (layout.SizeBytes != xbox.GetSize()
|| layout.BaseAlignmentBytes != xbox.GetAlignment())
return E_UNEXPECTED;
hr = image.Initialize(metadata);
if (FAILED(hr))
return hr;
auto d = static_cast<uint32_t>(metadata.depth);
size_t index = 0;
for (size_t level = 0; level < metadata.mipLevels; ++level)
{
if ((index + d) > image.GetImageCount())
{
image.Release();
return E_FAIL;
}
// Relies on the fact that slices are contiguous
hr = Detile3D(xbox, static_cast<uint32_t>(level), computer.Get(), image.GetImages()[index]);
if (FAILED(hr))
{
image.Release();
return hr;
}
index += d;
if (d > 1)
d >>= 1;
}
}
break;
default:
return E_FAIL;
}
return S_OK;
}

View File

@ -1,319 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexXboxImage.cpp
//
// DirectXTex Auxilary functions for Xbox texture blob
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#include "DirectXTexP.h"
#include "DirectXTexXbox.h"
using namespace DirectX;
using namespace Xbox;
// Sanity check XG library values against DirectXTex's values
static_assert(static_cast<int>(XG_FORMAT_UNKNOWN) == static_cast<int>(DXGI_FORMAT_UNKNOWN), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32B32A32_TYPELESS) == static_cast<int>(DXGI_FORMAT_R32G32B32A32_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32B32A32_FLOAT) == static_cast<int>(DXGI_FORMAT_R32G32B32A32_FLOAT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32B32A32_UINT) == static_cast<int>(DXGI_FORMAT_R32G32B32A32_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32B32A32_SINT) == static_cast<int>(DXGI_FORMAT_R32G32B32A32_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32B32_TYPELESS) == static_cast<int>(DXGI_FORMAT_R32G32B32_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32B32_FLOAT) == static_cast<int>(DXGI_FORMAT_R32G32B32_FLOAT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32B32_UINT) == static_cast<int>(DXGI_FORMAT_R32G32B32_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32B32_SINT) == static_cast<int>(DXGI_FORMAT_R32G32B32_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16B16A16_TYPELESS) == static_cast<int>(DXGI_FORMAT_R16G16B16A16_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16B16A16_FLOAT) == static_cast<int>(DXGI_FORMAT_R16G16B16A16_FLOAT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16B16A16_UNORM) == static_cast<int>(DXGI_FORMAT_R16G16B16A16_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16B16A16_UINT) == static_cast<int>(DXGI_FORMAT_R16G16B16A16_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16B16A16_SNORM) == static_cast<int>(DXGI_FORMAT_R16G16B16A16_SNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16B16A16_SINT) == static_cast<int>(DXGI_FORMAT_R16G16B16A16_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32_TYPELESS) == static_cast<int>(DXGI_FORMAT_R32G32_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32_FLOAT) == static_cast<int>(DXGI_FORMAT_R32G32_FLOAT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32_UINT) == static_cast<int>(DXGI_FORMAT_R32G32_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G32_SINT) == static_cast<int>(DXGI_FORMAT_R32G32_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32G8X24_TYPELESS) == static_cast<int>(DXGI_FORMAT_R32G8X24_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_D32_FLOAT_S8X24_UINT) == static_cast<int>(DXGI_FORMAT_D32_FLOAT_S8X24_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32_FLOAT_X8X24_TYPELESS) == static_cast<int>(DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_X32_TYPELESS_G8X24_UINT) == static_cast<int>(DXGI_FORMAT_X32_TYPELESS_G8X24_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R10G10B10A2_TYPELESS) == static_cast<int>(DXGI_FORMAT_R10G10B10A2_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R10G10B10A2_UNORM) == static_cast<int>(DXGI_FORMAT_R10G10B10A2_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R10G10B10A2_UINT) == static_cast<int>(DXGI_FORMAT_R10G10B10A2_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R11G11B10_FLOAT) == static_cast<int>(DXGI_FORMAT_R11G11B10_FLOAT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8B8A8_TYPELESS) == static_cast<int>(DXGI_FORMAT_R8G8B8A8_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8B8A8_UNORM) == static_cast<int>(DXGI_FORMAT_R8G8B8A8_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8B8A8_UNORM_SRGB) == static_cast<int>(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8B8A8_UINT) == static_cast<int>(DXGI_FORMAT_R8G8B8A8_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8B8A8_SNORM) == static_cast<int>(DXGI_FORMAT_R8G8B8A8_SNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8B8A8_SINT) == static_cast<int>(DXGI_FORMAT_R8G8B8A8_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16_TYPELESS) == static_cast<int>(DXGI_FORMAT_R16G16_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16_FLOAT) == static_cast<int>(DXGI_FORMAT_R16G16_FLOAT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16_UNORM) == static_cast<int>(DXGI_FORMAT_R16G16_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16_UINT) == static_cast<int>(DXGI_FORMAT_R16G16_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16_SNORM) == static_cast<int>(DXGI_FORMAT_R16G16_SNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16G16_SINT) == static_cast<int>(DXGI_FORMAT_R16G16_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32_TYPELESS) == static_cast<int>(DXGI_FORMAT_R32_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_D32_FLOAT) == static_cast<int>(DXGI_FORMAT_D32_FLOAT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32_FLOAT) == static_cast<int>(DXGI_FORMAT_R32_FLOAT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32_UINT) == static_cast<int>(DXGI_FORMAT_R32_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R32_SINT) == static_cast<int>(DXGI_FORMAT_R32_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R24G8_TYPELESS) == static_cast<int>(DXGI_FORMAT_R24G8_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_D24_UNORM_S8_UINT) == static_cast<int>(DXGI_FORMAT_D24_UNORM_S8_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R24_UNORM_X8_TYPELESS) == static_cast<int>(DXGI_FORMAT_R24_UNORM_X8_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_X24_TYPELESS_G8_UINT) == static_cast<int>(DXGI_FORMAT_X24_TYPELESS_G8_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8_TYPELESS) == static_cast<int>(DXGI_FORMAT_R8G8_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8_UNORM) == static_cast<int>(DXGI_FORMAT_R8G8_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8_UINT) == static_cast<int>(DXGI_FORMAT_R8G8_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8_SNORM) == static_cast<int>(DXGI_FORMAT_R8G8_SNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8_SINT) == static_cast<int>(DXGI_FORMAT_R8G8_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16_TYPELESS) == static_cast<int>(DXGI_FORMAT_R16_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16_FLOAT) == static_cast<int>(DXGI_FORMAT_R16_FLOAT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_D16_UNORM) == static_cast<int>(DXGI_FORMAT_D16_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16_UNORM) == static_cast<int>(DXGI_FORMAT_R16_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16_UINT) == static_cast<int>(DXGI_FORMAT_R16_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16_SNORM) == static_cast<int>(DXGI_FORMAT_R16_SNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R16_SINT) == static_cast<int>(DXGI_FORMAT_R16_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8_TYPELESS) == static_cast<int>(DXGI_FORMAT_R8_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8_UNORM) == static_cast<int>(DXGI_FORMAT_R8_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8_UINT) == static_cast<int>(DXGI_FORMAT_R8_UINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8_SNORM) == static_cast<int>(DXGI_FORMAT_R8_SNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8_SINT) == static_cast<int>(DXGI_FORMAT_R8_SINT), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_A8_UNORM) == static_cast<int>(DXGI_FORMAT_A8_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R1_UNORM) == static_cast<int>(DXGI_FORMAT_R1_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R9G9B9E5_SHAREDEXP) == static_cast<int>(DXGI_FORMAT_R9G9B9E5_SHAREDEXP), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R8G8_B8G8_UNORM) == static_cast<int>(DXGI_FORMAT_R8G8_B8G8_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_G8R8_G8B8_UNORM) == static_cast<int>(DXGI_FORMAT_G8R8_G8B8_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC1_TYPELESS) == static_cast<int>(DXGI_FORMAT_BC1_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC1_UNORM) == static_cast<int>(DXGI_FORMAT_BC1_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC1_UNORM_SRGB) == static_cast<int>(DXGI_FORMAT_BC1_UNORM_SRGB), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC2_TYPELESS) == static_cast<int>(DXGI_FORMAT_BC2_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC2_UNORM) == static_cast<int>(DXGI_FORMAT_BC2_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC2_UNORM_SRGB) == static_cast<int>(DXGI_FORMAT_BC2_UNORM_SRGB), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC3_TYPELESS) == static_cast<int>(DXGI_FORMAT_BC3_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC3_UNORM) == static_cast<int>(DXGI_FORMAT_BC3_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC3_UNORM_SRGB) == static_cast<int>(DXGI_FORMAT_BC3_UNORM_SRGB), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC4_TYPELESS) == static_cast<int>(DXGI_FORMAT_BC4_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC4_UNORM) == static_cast<int>(DXGI_FORMAT_BC4_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC4_SNORM) == static_cast<int>(DXGI_FORMAT_BC4_SNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC5_TYPELESS) == static_cast<int>(DXGI_FORMAT_BC5_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC5_UNORM) == static_cast<int>(DXGI_FORMAT_BC5_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC5_SNORM) == static_cast<int>(DXGI_FORMAT_BC5_SNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_B5G6R5_UNORM) == static_cast<int>(DXGI_FORMAT_B5G6R5_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_B5G5R5A1_UNORM) == static_cast<int>(DXGI_FORMAT_B5G5R5A1_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_B8G8R8A8_UNORM) == static_cast<int>(DXGI_FORMAT_B8G8R8A8_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_B8G8R8X8_UNORM) == static_cast<int>(DXGI_FORMAT_B8G8R8X8_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_R10G10B10_XR_BIAS_A2_UNORM) == static_cast<int>(DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_B8G8R8A8_TYPELESS) == static_cast<int>(DXGI_FORMAT_B8G8R8A8_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_B8G8R8A8_UNORM_SRGB) == static_cast<int>(DXGI_FORMAT_B8G8R8A8_UNORM_SRGB), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_B8G8R8X8_TYPELESS) == static_cast<int>(DXGI_FORMAT_B8G8R8X8_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_B8G8R8X8_UNORM_SRGB) == static_cast<int>(DXGI_FORMAT_B8G8R8X8_UNORM_SRGB), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC6H_TYPELESS) == static_cast<int>(DXGI_FORMAT_BC6H_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC6H_UF16) == static_cast<int>(DXGI_FORMAT_BC6H_UF16), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC6H_SF16) == static_cast<int>(DXGI_FORMAT_BC6H_SF16), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC7_TYPELESS) == static_cast<int>(DXGI_FORMAT_BC7_TYPELESS), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC7_UNORM) == static_cast<int>(DXGI_FORMAT_BC7_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_BC7_UNORM_SRGB) == static_cast<int>(DXGI_FORMAT_BC7_UNORM_SRGB), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_AYUV) == static_cast<int>(DXGI_FORMAT_AYUV), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_Y410) == static_cast<int>(DXGI_FORMAT_Y410), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_Y416) == static_cast<int>(DXGI_FORMAT_Y416), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_NV12) == static_cast<int>(DXGI_FORMAT_NV12), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_P010) == static_cast<int>(DXGI_FORMAT_P010), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_P016) == static_cast<int>(DXGI_FORMAT_P016), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_420_OPAQUE) == static_cast<int>(DXGI_FORMAT_420_OPAQUE), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_YUY2) == static_cast<int>(DXGI_FORMAT_YUY2), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_Y210) == static_cast<int>(DXGI_FORMAT_Y210), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_Y216) == static_cast<int>(DXGI_FORMAT_Y216), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_NV11) == static_cast<int>(DXGI_FORMAT_NV11), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_AI44) == static_cast<int>(DXGI_FORMAT_AI44), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_IA44) == static_cast<int>(DXGI_FORMAT_IA44), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_P8) == static_cast<int>(DXGI_FORMAT_P8), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_A8P8) == static_cast<int>(DXGI_FORMAT_A8P8), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_FORMAT_B4G4R4A4_UNORM) == static_cast<int>(DXGI_FORMAT_B4G4R4A4_UNORM), "XG vs. DXGI mismatch");
static_assert(static_cast<int>(XG_RESOURCE_DIMENSION_TEXTURE1D) == static_cast<int>(TEX_DIMENSION_TEXTURE1D), "XG vs. Direct3D 11 mismatch");
static_assert(static_cast<int>(XG_RESOURCE_DIMENSION_TEXTURE2D) == static_cast<int>(TEX_DIMENSION_TEXTURE2D), "XG vs. Direct3D 11 mismatch");
static_assert(static_cast<int>(XG_RESOURCE_DIMENSION_TEXTURE3D) == static_cast<int>(TEX_DIMENSION_TEXTURE3D), "XG vs. Direct3D 11 mismatch");
static_assert(static_cast<int>(XG_RESOURCE_MISC_TEXTURECUBE) == static_cast<int>(TEX_MISC_TEXTURECUBE), "XG vs. Direct3D 11 mismatch");
//--------------------------------------------------------------------------------------
// Initialize memory
//--------------------------------------------------------------------------------------
XboxImage& XboxImage::operator= (XboxImage&& moveFrom) noexcept
{
if (this != &moveFrom)
{
Release();
dataSize = moveFrom.dataSize;
baseAlignment = moveFrom.baseAlignment;
tilemode = moveFrom.tilemode;
metadata = moveFrom.metadata;
memory = moveFrom.memory;
moveFrom.dataSize = 0;
moveFrom.baseAlignment = 0;
moveFrom.tilemode = c_XboxTileModeInvalid;
moveFrom.memory = nullptr;
}
return *this;
}
_Use_decl_annotations_
HRESULT XboxImage::Initialize(const XG_TEXTURE1D_DESC& desc, const XG_RESOURCE_LAYOUT& layout, uint32_t miscFlags2)
{
if (!layout.SizeBytes || !layout.BaseAlignmentBytes)
return E_INVALIDARG;
Release();
if (layout.SizeBytes > UINT32_MAX
|| layout.BaseAlignmentBytes > UINT32_MAX)
return E_FAIL;
memory = reinterpret_cast<uint8_t*>(_aligned_malloc(layout.SizeBytes, 16));
if (!memory)
return E_OUTOFMEMORY;
memset(memory, 0, layout.SizeBytes);
memset(&metadata, 0, sizeof(metadata));
metadata.width = desc.Width;
metadata.height = 1;
metadata.depth = 1;
metadata.arraySize = desc.ArraySize;
metadata.mipLevels = layout.MipLevels;
metadata.format = static_cast<DXGI_FORMAT>(desc.Format);
metadata.dimension = TEX_DIMENSION_TEXTURE1D;
metadata.miscFlags2 = miscFlags2;
dataSize = static_cast<uint32_t>(layout.SizeBytes);
baseAlignment = static_cast<uint32_t>(layout.BaseAlignmentBytes);
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
tilemode = desc.SwizzleMode;
#else
tilemode = desc.TileMode;
#endif
return S_OK;
}
_Use_decl_annotations_
HRESULT XboxImage::Initialize(const XG_TEXTURE2D_DESC& desc, const XG_RESOURCE_LAYOUT& layout, uint32_t miscFlags2)
{
if (!layout.SizeBytes || !layout.BaseAlignmentBytes)
return E_INVALIDARG;
Release();
if (layout.SizeBytes > UINT32_MAX
|| layout.BaseAlignmentBytes > UINT32_MAX)
return E_FAIL;
memory = reinterpret_cast<uint8_t*>(_aligned_malloc(layout.SizeBytes, 16));
if (!memory)
return E_OUTOFMEMORY;
memset(memory, 0, layout.SizeBytes);
memset(&metadata, 0, sizeof(metadata));
metadata.width = desc.Width;
metadata.height = desc.Height;
metadata.depth = 1;
metadata.arraySize = desc.ArraySize;
metadata.mipLevels = layout.MipLevels;
metadata.miscFlags = (desc.MiscFlags & XG_RESOURCE_MISC_TEXTURECUBE) ? TEX_MISC_TEXTURECUBE : 0;
metadata.format = static_cast<DXGI_FORMAT>(desc.Format);
metadata.dimension = TEX_DIMENSION_TEXTURE2D;
metadata.miscFlags2 = miscFlags2;
dataSize = static_cast<uint32_t>(layout.SizeBytes);
baseAlignment = static_cast<uint32_t>(layout.BaseAlignmentBytes);
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
tilemode = desc.SwizzleMode;
#else
tilemode = desc.TileMode;
#endif
return S_OK;
}
_Use_decl_annotations_
HRESULT XboxImage::Initialize(const XG_TEXTURE3D_DESC& desc, const XG_RESOURCE_LAYOUT& layout, uint32_t miscFlags2)
{
if (!layout.SizeBytes || !layout.BaseAlignmentBytes)
return E_INVALIDARG;
Release();
if (layout.SizeBytes > UINT32_MAX
|| layout.BaseAlignmentBytes > UINT32_MAX)
return E_FAIL;
memory = reinterpret_cast<uint8_t*>(_aligned_malloc(layout.SizeBytes, 16));
if (!memory)
return E_OUTOFMEMORY;
memset(memory, 0, layout.SizeBytes);
memset(&metadata, 0, sizeof(metadata));
metadata.width = desc.Width;
metadata.height = desc.Height;
metadata.depth = desc.Depth;
metadata.arraySize = 1;
metadata.mipLevels = layout.MipLevels;
metadata.format = static_cast<DXGI_FORMAT>(desc.Format);
metadata.dimension = TEX_DIMENSION_TEXTURE3D;
metadata.miscFlags2 = miscFlags2;
dataSize = static_cast<uint32_t>(layout.SizeBytes);
baseAlignment = static_cast<uint32_t>(layout.BaseAlignmentBytes);
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
tilemode = desc.SwizzleMode;
#else
tilemode = desc.TileMode;
#endif
return S_OK;
}
_Use_decl_annotations_
HRESULT XboxImage::Initialize(const DirectX::TexMetadata& mdata, XboxTileMode tm, uint32_t size, uint32_t alignment)
{
if (!size || !alignment || tm == c_XboxTileModeInvalid)
return E_INVALIDARG;
Release();
memory = reinterpret_cast<uint8_t*>(_aligned_malloc(size, 16));
if (!memory)
return E_OUTOFMEMORY;
memset(memory, 0, size);
metadata = mdata;
dataSize = size;
baseAlignment = alignment;
tilemode = tm;
return S_OK;
}
//--------------------------------------------------------------------------------------
// Release memory
//--------------------------------------------------------------------------------------
void XboxImage::Release()
{
if (memory)
{
_aligned_free(memory);
memory = nullptr;
}
}

View File

@ -1,758 +0,0 @@
//--------------------------------------------------------------------------------------
// File: DirectXTexXboxTile.cpp
//
// DirectXTex Auxilary functions for converting from linear to Xbox tiling
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#include "DirectXTexP.h"
#include "DirectXTexXbox.h"
//#define VERBOSE
using Microsoft::WRL::ComPtr;
using namespace DirectX;
using namespace DirectX::Internal;
using namespace Xbox;
namespace
{
//----------------------------------------------------------------------------------
inline HRESULT TileByElement1D(
_In_reads_(nimages) const Image* const * images,
size_t nimages,
uint32_t level,
_In_ XGTextureAddressComputer* computer,
_In_ const XG_RESOURCE_LAYOUT& layout,
const XboxImage& xbox,
size_t bpp,
size_t w,
bool packed)
{
uint8_t* dptr = xbox.GetPointer();
const uint8_t* endPtr = dptr + layout.SizeBytes;
for (size_t item = 0; item < nimages; ++item)
{
const Image* img = images[item];
if (!img || !img->pixels)
return E_POINTER;
assert(img->width == images[0]->width);
assert(img->height == images[0]->height);
assert(img->rowPitch == images[0]->rowPitch);
assert(img->format == images[0]->format);
const uint8_t* sptr = img->pixels;
for (size_t x = 0; x < w; ++x)
{
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
UINT64 element = (packed) ? (x >> 1) : x;
size_t offset = computer->GetTexelElementOffsetBytes(0, level, element, 0, static_cast<uint32_t>(item), 0, nullptr);
#else
size_t offset = computer->GetTexelElementOffsetBytes(0, level, x, 0, static_cast<uint32_t>(item), 0);
#endif
if (offset == size_t(-1))
return E_FAIL;
uint8_t* dest = dptr + offset;
if ((dest + bpp) > endPtr)
return E_FAIL;
memcpy(dest, sptr, bpp);
sptr += bpp;
if (packed)
++x;
}
}
return S_OK;
}
//----------------------------------------------------------------------------------
#ifdef VERBOSE
void DebugPrintDesc(const XG_TEXTURE1D_DESC& desc)
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"XG_TEXTURE1D_DESC = { %u, %u, %u, %u, %u, %u, %u, %u, %u, %u }\n",
desc.Width, desc.MipLevels, desc.ArraySize, desc.Format, desc.Usage, desc.BindFlags, desc.CPUAccessFlags, desc.MiscFlags,
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode,
#else
desc.TileMode,
#endif
desc.Pitch);
OutputDebugStringW(buff);
}
void DebugPrintDesc(const XG_TEXTURE2D_DESC& desc)
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"XG_TEXTURE2D_DESC = { %u, %u, %u, %u, %u, { %u, %u }, %u, %u, %u, %u, %u, %u }\n",
desc.Width, desc.Height, desc.MipLevels, desc.ArraySize, desc.Format, desc.SampleDesc.Count, desc.SampleDesc.Quality, desc.Usage, desc.BindFlags, desc.CPUAccessFlags, desc.MiscFlags,
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode,
#else
desc.TileMode,
#endif
desc.Pitch);
OutputDebugStringW(buff);
}
void DebugPrintDesc(const XG_TEXTURE3D_DESC& desc)
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"XG_TEXTURE3D_DESC = { %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u }\n",
desc.Width, desc.Height, desc.Depth, desc.MipLevels, desc.Format, desc.Usage, desc.BindFlags, desc.CPUAccessFlags, desc.MiscFlags,
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode,
#else
desc.TileMode,
#endif
desc.Pitch);
OutputDebugStringW(buff);
}
void DebugPrintLayout(const XG_RESOURCE_LAYOUT& layout)
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"Layout %u planes, %uD, %u mips, %llu size, %llu alignment\n", layout.Planes, layout.Dimension - 1, layout.MipLevels, layout.SizeBytes, layout.BaseAlignmentBytes);
OutputDebugStringW(buff);
for (size_t p = 0; p < layout.Planes; ++p)
{
auto& plane = layout.Plane[p];
swprintf_s(buff, L"Plane %zu: %u bpe, %llu size, %llu offset, %llu alignment\n", p, plane.BytesPerElement, plane.SizeBytes, plane.BaseOffsetBytes, plane.BaseAlignmentBytes);
OutputDebugStringW(buff);
for (size_t level = 0; level < layout.MipLevels; ++level)
{
auto& mip = plane.MipLayout[level];
swprintf_s(buff, L"\tLevel %zu: %llu size, %llu slice2D, %llu offset, %u alignment\n", level, mip.SizeBytes, mip.Slice2DSizeBytes, mip.OffsetBytes, mip.AlignmentBytes);
OutputDebugStringW(buff);
swprintf_s(buff, L"\t\t%u x %u x %u (padded %u x %u x %u)\n", mip.WidthElements, mip.HeightElements, mip.DepthOrArraySize,
mip.PaddedWidthElements, mip.PaddedHeightElements, mip.PaddedDepthOrArraySize);
OutputDebugStringW(buff);
swprintf_s(buff, L"\t\tpitch %u pixels (%u bytes)\n", mip.PitchPixels, mip.PitchBytes);
OutputDebugStringW(buff);
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
swprintf_s(buff, L"\t\t\t%u samples, %u swizzlemode\n", mip.SampleCount, mip.SwizzleMode);
#else
swprintf_s(buff, L"\t\t\t%u samples, %u tilemode\n", mip.SampleCount, mip.TileMode);
#endif
OutputDebugStringW(buff);
}
}
}
#endif
//-------------------------------------------------------------------------------------
// 1D Tiling
//-------------------------------------------------------------------------------------
HRESULT Tile1D(
_In_reads_(nimages) const Image** images,
size_t nimages,
uint32_t level,
_In_ XGTextureAddressComputer* computer,
const XG_RESOURCE_LAYOUT& layout,
const XboxImage& xbox)
{
if (!nimages || nimages > UINT32_MAX)
return E_INVALIDARG;
if (!images || !images[0] || !computer || !xbox.GetPointer())
return E_POINTER;
assert(layout.Planes == 1);
const DXGI_FORMAT format = images[0]->format;
assert(format == xbox.GetMetadata().format);
assert(!IsCompressed(format));
bool byelement = IsTypeless(format);
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
if (nimages > 1)
byelement = true;
#endif
if (IsPacked(format))
{
const size_t bpp = (BitsPerPixel(format) + 7) / 8;
// XG (XboxOne) incorrectly returns 2 instead of 4 here for layout.Plane[0].BytesPerElement
const size_t w = images[0]->width;
assert(((w + 1) / 2) == layout.Plane[0].MipLayout[level].WidthElements);
return TileByElement1D(images, nimages, level, computer, layout, xbox, bpp, w, true);
}
else if (byelement)
{
//--- Typeless is done with per-element copy ----------------------------------
const size_t bpp = (BitsPerPixel(format) + 7) / 8;
assert(bpp == layout.Plane[0].BytesPerElement);
const size_t w = images[0]->width;
assert(w == layout.Plane[0].MipLayout[level].WidthElements);
return TileByElement1D(images, nimages, level, computer, layout, xbox, bpp, w, false);
}
else
{
//--- Standard format handling ------------------------------------------------
auto& mip = layout.Plane[0].MipLayout[level];
const UINT32 tiledPixels = mip.PitchPixels * mip.PaddedDepthOrArraySize;
auto scanline = make_AlignedArrayXMVECTOR(images[0]->width + tiledPixels);
XMVECTOR* row = scanline.get();
XMVECTOR* tiled = row + images[0]->width;
#ifdef _DEBUG
memset(row, 0xCD, sizeof(XMVECTOR) * images[0]->width);
#endif
memset(tiled, 0, sizeof(XMVECTOR) * tiledPixels);
// Perform tiling
for (size_t item = 0; item < nimages; ++item)
{
const Image* img = images[item];
if (!img || !img->pixels)
return E_POINTER;
assert(img->width == images[0]->width);
assert(img->height == images[0]->height);
assert(img->rowPitch == images[0]->rowPitch);
assert(img->format == images[0]->format);
if (!LoadScanline(row, img->width, img->pixels, img->rowPitch, img->format))
return E_FAIL;
for (size_t x = 0; x < img->width; ++x)
{
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
size_t offset = computer->GetTexelElementOffsetBytes(0, level, x, 0, static_cast<uint32_t>(item), 0, nullptr);
#else
size_t offset = computer->GetTexelElementOffsetBytes(0, level, x, 0, static_cast<uint32_t>(item), 0);
#endif
if (offset == size_t(-1))
return E_FAIL;
assert(offset >= mip.OffsetBytes);
assert(offset < mip.OffsetBytes + mip.SizeBytes);
offset = (offset - mip.OffsetBytes) / layout.Plane[0].BytesPerElement;
assert(offset < tiledPixels);
tiled[offset] = row[x];
}
}
// Store tiled texture
assert(mip.OffsetBytes + mip.SizeBytes <= layout.SizeBytes);
if (!StoreScanline(xbox.GetPointer() + mip.OffsetBytes, mip.SizeBytes, xbox.GetMetadata().format, tiled, tiledPixels))
return E_FAIL;
}
return S_OK;
}
//-------------------------------------------------------------------------------------
// 2D Tiling
//-------------------------------------------------------------------------------------
HRESULT Tile2D(
_In_reads_(nimages) const Image** images,
size_t nimages,
uint32_t level,
_In_ XGTextureAddressComputer* computer,
const XboxImage& xbox)
{
if (!nimages || nimages > UINT32_MAX)
return E_INVALIDARG;
if (!images || !images[0] || !computer || !xbox.GetPointer())
return E_POINTER;
uint8_t* baseAddr = xbox.GetPointer();
const auto& metadata = xbox.GetMetadata();
for (size_t item = 0; item < nimages; ++item)
{
const Image* img = images[item];
if (!img || !img->pixels)
return E_POINTER;
assert(img->width == images[0]->width);
assert(img->height == images[0]->height);
assert(img->rowPitch == images[0]->rowPitch);
assert(img->format == images[0]->format);
HRESULT hr = computer->CopyIntoSubresource(
baseAddr,
0u,
metadata.CalculateSubresource(level, item),
img->pixels,
static_cast<UINT32>(img->rowPitch),
0u);
if (FAILED(hr))
{
return hr;
}
}
return S_OK;
}
//-------------------------------------------------------------------------------------
// 3D Tiling
//-------------------------------------------------------------------------------------
HRESULT Tile3D(
const Image& image,
uint32_t level,
_In_ XGTextureAddressComputer* computer,
const XboxImage& xbox)
{
if (!image.pixels || !computer || !xbox.GetPointer())
return E_POINTER;
uint8_t* baseAddr = xbox.GetPointer();
const auto& metadata = xbox.GetMetadata();
return computer->CopyIntoSubresource(
baseAddr,
0u,
metadata.CalculateSubresource(level, 0),
image.pixels,
static_cast<UINT32>(image.rowPitch),
static_cast<UINT32>(image.slicePitch));
}
}
//=====================================================================================
// Entry-points
//=====================================================================================
//-------------------------------------------------------------------------------------
// Tile image
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::Tile(
const DirectX::Image& srcImage,
XboxImage& xbox,
XboxTileMode mode)
{
if (!srcImage.pixels
|| srcImage.width > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION
|| srcImage.height > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION)
return E_INVALIDARG;
xbox.Release();
if (srcImage.format == DXGI_FORMAT_R1_UNORM
|| IsVideo(srcImage.format))
{
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
if (mode == c_XboxTileModeInvalid)
{
// If no specific tile mode is given, assume the optimal default
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
mode = XGComputeOptimalSwizzleMode(XG_RESOURCE_DIMENSION_TEXTURE2D, static_cast<XG_FORMAT>(srcImage.format),
static_cast<UINT>(srcImage.width), static_cast<UINT>(srcImage.height),
1, 1, XG_BIND_SHADER_RESOURCE);
#else
mode = XGComputeOptimalTileMode(XG_RESOURCE_DIMENSION_TEXTURE2D, static_cast<XG_FORMAT>(srcImage.format),
static_cast<UINT>(srcImage.width), static_cast<UINT>(srcImage.height),
1, 1, XG_BIND_SHADER_RESOURCE);
#endif
}
XG_TEXTURE2D_DESC desc = {};
desc.Width = static_cast<UINT>(srcImage.width);
desc.Height = static_cast<UINT>(srcImage.height);
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = static_cast<XG_FORMAT>(srcImage.format);
desc.SampleDesc.Count = 1;
desc.Usage = XG_USAGE_DEFAULT;
desc.BindFlags = XG_BIND_SHADER_RESOURCE;
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode = mode;
#else
desc.TileMode = mode;
#endif
ComPtr<XGTextureAddressComputer> computer;
HRESULT hr = XGCreateTexture2DComputer(&desc, computer.GetAddressOf());
if (FAILED(hr))
return hr;
XG_RESOURCE_LAYOUT layout;
hr = computer->GetResourceLayout(&layout);
if (FAILED(hr))
return hr;
if (layout.Planes != 1)
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
hr = xbox.Initialize(desc, layout);
if (FAILED(hr))
return hr;
const Image* images = &srcImage;
hr = Tile2D(&images, 1, 0, computer.Get(), xbox);
if (FAILED(hr))
{
xbox.Release();
return hr;
}
return S_OK;
}
//-------------------------------------------------------------------------------------
// Tile image (complex)
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::Tile(
const DirectX::Image* srcImages,
size_t nimages,
const DirectX::TexMetadata& metadata,
XboxImage& xbox,
XboxTileMode mode)
{
if (!srcImages || !nimages || nimages > UINT32_MAX)
return E_INVALIDARG;
switch (metadata.dimension)
{
case TEX_DIMENSION_TEXTURE1D:
if (metadata.width > D3D11_REQ_TEXTURE1D_U_DIMENSION
|| metadata.mipLevels > D3D11_REQ_MIP_LEVELS
|| metadata.arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION)
return E_INVALIDARG;
break;
case TEX_DIMENSION_TEXTURE2D:
if (metadata.width > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION
|| metadata.height > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION
|| metadata.mipLevels > D3D11_REQ_MIP_LEVELS
|| metadata.arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION)
return E_INVALIDARG;
break;
case TEX_DIMENSION_TEXTURE3D:
if (metadata.width > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
|| metadata.height > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
|| metadata.depth > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
|| metadata.mipLevels > D3D11_REQ_MIP_LEVELS
|| metadata.arraySize != 1)
return E_INVALIDARG;
break;
default:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
xbox.Release();
if (metadata.format == DXGI_FORMAT_R1_UNORM
|| IsVideo(metadata.format))
{
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
switch (metadata.format)
{
case DXGI_FORMAT_R32G32B32_TYPELESS:
case DXGI_FORMAT_R32G32B32_FLOAT:
case DXGI_FORMAT_R32G32B32_UINT:
case DXGI_FORMAT_R32G32B32_SINT:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
default:
break;
}
if (mode == c_XboxTileModeInvalid)
{
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
mode = XGComputeOptimalSwizzleMode(static_cast<XG_RESOURCE_DIMENSION>(metadata.dimension), static_cast<XG_FORMAT>(metadata.format),
static_cast<UINT>(metadata.width), static_cast<UINT>(metadata.height),
static_cast<UINT>((metadata.dimension == TEX_DIMENSION_TEXTURE3D) ? metadata.depth : metadata.arraySize),
1, XG_BIND_SHADER_RESOURCE);
#else
// If no specific tile mode is given, assume the optimal default
mode = XGComputeOptimalTileMode(static_cast<XG_RESOURCE_DIMENSION>(metadata.dimension), static_cast<XG_FORMAT>(metadata.format),
static_cast<UINT>(metadata.width), static_cast<UINT>(metadata.height),
static_cast<UINT>((metadata.dimension == TEX_DIMENSION_TEXTURE3D) ? metadata.depth : metadata.arraySize),
1, XG_BIND_SHADER_RESOURCE);
#endif
}
XG_RESOURCE_LAYOUT layout = {};
switch (metadata.dimension)
{
case TEX_DIMENSION_TEXTURE1D:
{
XG_TEXTURE1D_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
desc.ArraySize = static_cast<UINT>(metadata.arraySize);
desc.Format = static_cast<XG_FORMAT>(metadata.format);
desc.Usage = XG_USAGE_DEFAULT;
desc.BindFlags = XG_BIND_SHADER_RESOURCE;
desc.MiscFlags = (metadata.IsCubemap()) ? XG_RESOURCE_MISC_TEXTURECUBE : 0;
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode = mode;
#else
desc.TileMode = mode;
#endif
#ifdef VERBOSE
DebugPrintDesc(desc);
#endif
ComPtr<XGTextureAddressComputer> computer;
HRESULT hr = XGCreateTexture1DComputer(&desc, computer.GetAddressOf());
if (FAILED(hr))
return hr;
hr = computer->GetResourceLayout(&layout);
if (FAILED(hr))
return hr;
#ifdef VERBOSE
DebugPrintLayout(layout);
#endif
if (layout.Planes != 1)
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
hr = xbox.Initialize(desc, layout, metadata.miscFlags2);
if (FAILED(hr))
return hr;
for (size_t level = 0; level < metadata.mipLevels; ++level)
{
if (metadata.arraySize > 1)
{
std::vector<const Image*> images;
images.reserve(metadata.arraySize);
for (size_t item = 0; item < metadata.arraySize; ++item)
{
const size_t index = metadata.ComputeIndex(level, item, 0);
if (index >= nimages)
{
xbox.Release();
return E_FAIL;
}
images.push_back(&srcImages[index]);
}
hr = Tile1D(&images[0], images.size(), static_cast<uint32_t>(level), computer.Get(), layout, xbox);
}
else
{
const size_t index = metadata.ComputeIndex(level, 0, 0);
if (index >= nimages)
{
xbox.Release();
return E_FAIL;
}
const Image* images = &srcImages[index];
hr = Tile1D(&images, 1, static_cast<uint32_t>(level), computer.Get(), layout, xbox);
}
if (FAILED(hr))
{
xbox.Release();
return hr;
}
}
}
break;
case TEX_DIMENSION_TEXTURE2D:
{
XG_TEXTURE2D_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.Height = static_cast<UINT>(metadata.height);
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
desc.ArraySize = static_cast<UINT>(metadata.arraySize);
desc.Format = static_cast<XG_FORMAT>(metadata.format);
desc.SampleDesc.Count = 1;
desc.Usage = XG_USAGE_DEFAULT;
desc.BindFlags = XG_BIND_SHADER_RESOURCE;
desc.MiscFlags = (metadata.miscFlags & TEX_MISC_TEXTURECUBE) ? XG_RESOURCE_MISC_TEXTURECUBE : 0;
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode = mode;
#else
desc.TileMode = mode;
#endif
#ifdef VERBOSE
DebugPrintDesc(desc);
#endif
ComPtr<XGTextureAddressComputer> computer;
HRESULT hr = XGCreateTexture2DComputer(&desc, computer.GetAddressOf());
if (FAILED(hr))
return hr;
hr = computer->GetResourceLayout(&layout);
if (FAILED(hr))
return hr;
#ifdef VERBOSE
DebugPrintLayout(layout);
#endif
if (layout.Planes != 1)
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
hr = xbox.Initialize(desc, layout, metadata.miscFlags2);
if (FAILED(hr))
return hr;
for (size_t level = 0; level < metadata.mipLevels; ++level)
{
if (metadata.arraySize > 1)
{
std::vector<const Image*> images;
images.reserve(metadata.arraySize);
for (size_t item = 0; item < metadata.arraySize; ++item)
{
const size_t index = metadata.ComputeIndex(level, item, 0);
if (index >= nimages)
{
xbox.Release();
return E_FAIL;
}
images.push_back(&srcImages[index]);
}
hr = Tile2D(&images[0], images.size(), static_cast<uint32_t>(level), computer.Get(), xbox);
}
else
{
const size_t index = metadata.ComputeIndex(level, 0, 0);
if (index >= nimages)
{
xbox.Release();
return E_FAIL;
}
const Image* images = &srcImages[index];
hr = Tile2D(&images, 1, static_cast<uint32_t>(level), computer.Get(), xbox);
}
if (FAILED(hr))
{
xbox.Release();
return hr;
}
}
}
break;
case TEX_DIMENSION_TEXTURE3D:
{
XG_TEXTURE3D_DESC desc = {};
desc.Width = static_cast<UINT>(metadata.width);
desc.Height = static_cast<UINT>(metadata.height);
desc.Depth = static_cast<UINT>(metadata.depth);
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
desc.Format = static_cast<XG_FORMAT>(metadata.format);
desc.Usage = XG_USAGE_DEFAULT;
desc.BindFlags = XG_BIND_SHADER_RESOURCE;
#if defined(_GAMING_XBOX_SCARLETT) || defined(_USE_SCARLETT)
desc.SwizzleMode = mode;
#else
desc.TileMode = mode;
#endif
#ifdef VERBOSE
DebugPrintDesc(desc);
#endif
ComPtr<XGTextureAddressComputer> computer;
HRESULT hr = XGCreateTexture3DComputer(&desc, computer.GetAddressOf());
if (FAILED(hr))
return hr;
hr = computer->GetResourceLayout(&layout);
if (FAILED(hr))
return hr;
#ifdef VERBOSE
DebugPrintLayout(layout);
#endif
if (layout.Planes != 1)
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
hr = xbox.Initialize(desc, layout, metadata.miscFlags2);
if (FAILED(hr))
return hr;
auto d = static_cast<uint32_t>(metadata.depth);
size_t index = 0;
for (size_t level = 0; level < metadata.mipLevels; ++level)
{
if ((index + d) > nimages)
{
xbox.Release();
return E_FAIL;
}
// Relies on the fact that slices are contiguous
hr = Tile3D(srcImages[index], static_cast<uint32_t>(level), computer.Get(), xbox);
if (FAILED(hr))
{
xbox.Release();
return hr;
}
index += d;
if (d > 1)
d >>= 1;
}
}
break;
default:
return E_FAIL;
}
return S_OK;
}

View File

@ -1,32 +1,16 @@
# Copyright (c) Microsoft Corporation.
# DirectX Texture Library
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkId=248926
cmake_minimum_required (VERSION 3.20)
cmake_minimum_required (VERSION 3.11)
set(DIRECTXTEX_VERSION 2.0.8)
project (DirectXTex LANGUAGES CXX)
if(XBOX_CONSOLE_TARGET STREQUAL "durango")
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
endif()
project (DirectXTex
VERSION ${DIRECTXTEX_VERSION}
DESCRIPTION "DirectX Texture Library"
HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkId=248926"
LANGUAGES CXX)
if(DEFINED XBOX_CONSOLE_TARGET)
set(CMAKE_CXX_STANDARD_LIBRARIES "")
endif()
option(BUILD_TOOLS "Build tex command-line tools" ON)
option(BUILD_SHARED_LIBS "Build DirectXTex as a shared library" OFF)
option(BUILD_SAMPLE "Build DDSView sample (requires fxc.exe)" ON)
# Includes the functions for Direct3D 11 resources and DirectCompute compression
option(BUILD_DX11 "Build with DirectX11 Runtime support (requires fxc.exe)" ON)
# Includes the functions for creating Direct3D 11 resources at runtime
option(BUILD_DX11 "Build with DirectX11 Runtime support" ON)
# Includes the functions for creating Direct3D 12 resources at runtime
option(BUILD_DX12 "Build with DirectX12 Runtime support" ON)
@ -34,77 +18,32 @@ option(BUILD_DX12 "Build with DirectX12 Runtime support" ON)
# Enable the use of OpenMP for software BC6H/BC7 compression
option(BC_USE_OPENMP "Build with OpenMP support" ON)
# Builds Xbox extensions for Host PC
option(BUILD_XBOX_EXTS_XBOXONE "Build Xbox library extensions for Xbox One" OFF)
option(BUILD_XBOX_EXTS_SCARLETT "Build Xbox library extensions for Xbox Series X|S" OFF)
# https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/
option(ENABLE_SPECTRE_MITIGATION "Build using /Qspectre for MSVC" OFF)
option(DISABLE_MSVC_ITERATOR_DEBUGGING "Disable iterator debugging in Debug configurations with the MSVC CRT" OFF)
option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)
option(ENABLE_CODE_COVERAGE "Build with code-coverage" OFF)
option(USE_PREBUILT_SHADERS "Use externally built HLSL shaders" OFF)
option(NO_WCHAR_T "Use legacy wide-character as unsigned short" OFF)
option(BUILD_FUZZING "Build for fuzz testing" OFF)
# Includes the functions for loading/saving OpenEXR files at runtime
option(ENABLE_OPENEXR_SUPPORT "Build with OpenEXR support" OFF)
# See https://www.ijg.org/
option(ENABLE_LIBJPEG_SUPPORT "Build with libjpeg support" OFF)
# See http://www.libpng.org/pub/png/libpng.html
option(ENABLE_LIBPNG_SUPPORT "Build with libpng support" OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
if(WINDOWS_STORE OR (DEFINED XBOX_CONSOLE_TARGET))
set(BUILD_DX12 ON)
set(BUILD_TOOLS OFF)
set(BUILD_SAMPLE OFF)
endif()
if((DEFINED XBOX_CONSOLE_TARGET) AND (NOT (XBOX_CONSOLE_TARGET STREQUAL "durango")))
set(BUILD_DX11 OFF)
endif()
include(GNUInstallDirs)
include(build/CompilerAndLinker.cmake)
if((DEFINED DIRECTX_ARCH) AND (${DIRECTX_ARCH} STREQUAL "arm64ec"))
# OpenEXR doesn't support ARM64EC
set(ENABLE_OPENEXR_SUPPORT OFF)
endif()
#--- Library
set(LIBRARY_HEADERS
DirectXTex/DirectXTex.h
DirectXTex/DirectXTex.inl)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
set(LIBRARY_SOURCES
DirectXTex/BC.h
DirectXTex/BCDirectCompute.h
DirectXTex/d3dx12.h
DirectXTex/DDS.h
DirectXTex/DirectXTex.h
DirectXTex/DirectXTexP.h
DirectXTex/filters.h
DirectXTex/scoped.h
DirectXTex/BC.cpp
DirectXTex/BC4BC5.cpp
DirectXTex/BC6HBC7.cpp
DirectXTex/BCDirectCompute.cpp
DirectXTex/DirectXTexCompress.cpp
DirectXTex/DirectXTexCompressGPU.cpp
DirectXTex/DirectXTexConvert.cpp
DirectXTex/DirectXTexDDS.cpp
DirectXTex/DirectXTexFlipRotate.cpp
DirectXTex/DirectXTexHDR.cpp
DirectXTex/DirectXTexImage.cpp
DirectXTex/DirectXTexMipmaps.cpp
@ -113,593 +52,121 @@ set(LIBRARY_SOURCES
DirectXTex/DirectXTexPMAlpha.cpp
DirectXTex/DirectXTexResize.cpp
DirectXTex/DirectXTexTGA.cpp
DirectXTex/DirectXTexUtil.cpp)
DirectXTex/DirectXTexUtil.cpp
DirectXTex/DirectXTexWIC.cpp)
if(WIN32)
list(APPEND LIBRARY_SOURCES
DirectXTex/DirectXTexFlipRotate.cpp
DirectXTex/DirectXTexWIC.cpp)
set(SHADER_SOURCES
DirectXTex/Shaders/BC6HEncode.hlsl
DirectXTex/Shaders/BC7Encode.hlsl)
if(BUILD_DX11 MATCHES ON)
set(LIBRARY_SOURCES ${LIBRARY_SOURCES} DirectXTex/DirectXTexD3D11.cpp)
endif()
if(BUILD_DX12 MATCHES ON)
set(LIBRARY_SOURCES ${LIBRARY_SOURCES} DirectXTex/DirectXTexD3D12.cpp)
endif()
if(DEFINED XBOX_CONSOLE_TARGET)
add_library(${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} DirectXTex/Shaders/Compiled/BC6HEncode_EncodeBlockCS.inc)
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexXbox.h)
list(APPEND LIBRARY_SOURCES
Auxiliary/DirectXTexXboxDDS.cpp
Auxiliary/DirectXTexXboxDetile.cpp
Auxiliary/DirectXTexXboxImage.cpp
Auxiliary/DirectXTexXboxTile.cpp)
if((XBOX_CONSOLE_TARGET STREQUAL "durango") AND BUILD_DX11)
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexXboxD3D11X.cpp)
endif()
if(BUILD_DX12)
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexXboxD3D12X.cpp)
endif()
elseif((BUILD_XBOX_EXTS_XBOXONE OR BUILD_XBOX_EXTS_SCARLETT) AND WIN32)
if(DEFINED ENV{GameDKLatest})
cmake_path(SET GameDK_DIR "$ENV{GameDKLatest}")
endif()
if(DEFINED ENV{XboxOneXDKLatest})
cmake_path(SET XboxOneXDK_DIR "$ENV{XboxOneXDKLatest}")
endif()
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexXbox.h)
list(APPEND LIBRARY_SOURCES
Auxiliary/DirectXTexXboxDDS.cpp
Auxiliary/DirectXTexXboxDetile.cpp
Auxiliary/DirectXTexXboxImage.cpp
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)
list(APPEND LIBRARY_SOURCES
DirectXTex/BCDirectCompute.h
DirectXTex/BCDirectCompute.cpp
DirectXTex/DirectXTexCompressGPU.cpp
DirectXTex/DirectXTexD3D11.cpp)
endif()
if(BUILD_DX12)
list(APPEND LIBRARY_SOURCES DirectXTex/DirectXTexD3D12.cpp)
if(NOT (DEFINED XBOX_CONSOLE_TARGET))
list(APPEND LIBRARY_SOURCES Common/d3dx12.h)
endif()
endif()
if(ENABLE_OPENEXR_SUPPORT)
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexEXR.h)
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexEXR.cpp)
endif()
if(ENABLE_LIBJPEG_SUPPORT)
if(WIN32)
message(STATUS "Use of the Windows Imaging Component (WIC) instead of libjpeg is recommended.")
endif()
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexJPEG.h)
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexJPEG.cpp)
endif()
if(ENABLE_LIBPNG_SUPPORT)
if(WIN32)
message(STATUS "Use of the Windows Imaging Component (WIC) instead of libpng is recommended.")
endif()
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexPNG.h)
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexPNG.cpp)
endif()
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")
endif()
set(COMPILED_SHADERS ${CMAKE_CURRENT_BINARY_DIR}/Shaders/Compiled)
file(MAKE_DIRECTORY ${COMPILED_SHADERS})
else()
file(TO_CMAKE_PATH ${COMPILED_SHADERS} COMPILED_SHADERS)
endif()
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}" $<$<BOOL:${DIRECTX_FXC_TOOL}>:LegacyShaderCompiler=${DIRECTX_FXC_TOOL}> CompileShaders.cmd > "${COMPILED_SHADERS}/compileshaders.log"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders"
USES_TERMINAL)
endif()
endif()
if(WIN32 AND BUILD_SHARED_LIBS)
message(STATUS "Build library as a DLL")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/build/DirectXTex.rc.in"
"${CMAKE_CURRENT_BINARY_DIR}/DirectXTex.rc" @ONLY)
add_library(${PROJECT_NAME} SHARED ${LIBRARY_SOURCES} ${LIBRARY_HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/DirectXTex.rc")
target_compile_definitions(${PROJECT_NAME} PRIVATE DIRECTX_TEX_EXPORT)
target_compile_definitions(${PROJECT_NAME} INTERFACE DIRECTX_TEX_IMPORT)
if(XBOX_CONSOLE_TARGET MATCHES "scarlett")
target_link_libraries(${PROJECT_NAME} PRIVATE xgameplatform.lib xg_xs.lib xmem.lib)
elseif(XBOX_CONSOLE_TARGET MATCHES "xboxone")
target_link_libraries(${PROJECT_NAME} PRIVATE xgameplatform.lib xg_x.lib xmem.lib)
elseif(XBOX_CONSOLE_TARGET MATCHES "durango")
target_link_libraries(${PROJECT_NAME} PRIVATE kernelx.lib xg_x.lib combase.lib)
endif()
else()
add_library(${PROJECT_NAME} ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
endif()
if(BUILD_DX11 AND WIN32)
target_include_directories(${PROJECT_NAME} PRIVATE ${COMPILED_SHADERS})
endif()
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/DirectXTex/Shaders/Compiled/BC6HEncode_EncodeBlockCS.inc"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/DirectXTex/Shaders/CompileShaders.cmd"
DEPENDS ${SHADER_SOURCES}
COMMENT "Generating HLSL shaders..."
COMMAND "CompileShaders.cmd"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/DirectXTex/Shaders"
USES_TERMINAL)
source_group(${PROJECT_NAME} REGULAR_EXPRESSION DirectXTex/*.*)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/DirectXTex>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_include_directories(${PROJECT_NAME} PUBLIC DirectXTex)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
if(BC_USE_OPENMP)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(${PROJECT_NAME} PUBLIC OpenMP::OpenMP_CXX)
else()
set(BC_USE_OPENMP OFF)
endif()
endif()
if(ENABLE_OPENEXR_SUPPORT)
find_package(OpenEXR REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC OpenEXR::OpenEXR)
endif()
if(BUILD_XBOX_EXTS_SCARLETT AND WIN32)
if(EXISTS "${GameDK_DIR}/GXDK/toolKit/include/gxdk.h")
message(STATUS "Building Xbox extensions for Xbox Series X|S")
add_library(Xbox::GDKX SHARED IMPORTED)
set_target_properties(Xbox::GDKX PROPERTIES
IMPORTED_LOCATION "${GameDK_DIR}/GXDK/bin/Scarlett/xg_xs.dll"
IMPORTED_IMPLIB "${GameDK_DIR}/GXDK/toolKit/lib/amd64/Scarlett/xg_xs.lib"
MAP_IMPORTED_CONFIG_MINSIZEREL ""
MAP_IMPORTED_CONFIG_RELWITHDEBINFO ""
INTERFACE_COMPILE_DEFINITIONS "_USE_GXDK;_USE_SCARLETT"
INTERFACE_INCLUDE_DIRECTORIES "${GameDK_DIR}/GXDK/toolKit/include;${GameDK_DIR}/GXDK/toolKit/include/Scarlett")
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_XBOX_EXTS)
target_link_libraries(${PROJECT_NAME} PUBLIC Xbox::GDKX)
else()
message(FATAL_ERROR "Building Xbox extensions requires GameDKLatest")
endif()
elseif(BUILD_XBOX_EXTS_XBOXONE AND WIN32)
if(EXISTS "${GameDK_DIR}/GXDK/toolKit/include/gxdk.h")
message(STATUS "Building Xbox extensions for XboxOne using the Microsoft GDK")
add_library(Xbox::GDKX SHARED IMPORTED)
set_target_properties(Xbox::GDKX PROPERTIES
IMPORTED_LOCATION "${GameDK_DIR}/GXDK/bin/XboxOne/xg.dll"
IMPORTED_IMPLIB "${GameDK_DIR}/GXDK/toolKit/lib/amd64/XboxOne/xg.lib"
MAP_IMPORTED_CONFIG_MINSIZEREL ""
MAP_IMPORTED_CONFIG_RELWITHDEBINFO ""
INTERFACE_COMPILE_DEFINITIONS "_USE_GXDK"
INTERFACE_INCLUDE_DIRECTORIES "${GameDK_DIR}/GXDK/toolKit/include;${GameDK_DIR}/GXDK/toolKit/include/XboxOne")
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_XBOX_EXTS)
target_link_libraries(${PROJECT_NAME} PUBLIC Xbox::GDKX)
elseif(EXISTS "${XboxOneXDK_DIR}/PC/include/xdk.h")
message(STATUS "Building Xbox extensions for XboxOne using the Xbox One XDK")
add_library(Xbox::XDK SHARED IMPORTED)
set_target_properties(Xbox::XDK PROPERTIES
IMPORTED_LOCATION "${XboxOneXDK_DIR}/bin/xg.dll"
IMPORTED_IMPLIB "${XboxOneXDK_DIR}/PC/lib/amd64/xg.lib"
MAP_IMPORTED_CONFIG_MINSIZEREL ""
MAP_IMPORTED_CONFIG_RELWITHDEBINFO ""
INTERFACE_INCLUDE_DIRECTORIES "${XboxOneXDK_DIR}/PC/include")
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_XBOX_EXTS)
target_link_libraries(${PROJECT_NAME} PUBLIC Xbox::XDK)
else()
message(FATAL_ERROR "Building Xbox extensions requires GameDKLatest or XboxOneXDKLatest")
endif()
endif()
if(ENABLE_LIBJPEG_SUPPORT)
find_package(JPEG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC JPEG::JPEG)
endif()
if(ENABLE_LIBPNG_SUPPORT)
find_package(PNG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC PNG::PNG)
endif()
if(NOT MINGW)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXTex/DirectXTexP.h)
endif()
if(MINGW OR (NOT WIN32))
find_package(directxmath CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectXMath)
if(MSVC)
# Use max Warning Level
string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
find_package(directx-headers CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
target_compile_definitions(${PROJECT_NAME} PUBLIC USING_DIRECTX_HEADERS)
else()
find_package(directxmath CONFIG QUIET)
find_package(directx-headers CONFIG QUIET)
# Not using typeid or dynamic_cast, so disable RTTI to save binary size
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
endif()
if(directxmath_FOUND)
message(STATUS "Using DirectXMath package")
target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectXMath)
endif()
add_executable(texassemble Texassemble/texassemble.cpp)
target_link_libraries(texassemble ${PROJECT_NAME})
source_group(texassemble REGULAR_EXPRESSION Texassemble/*.*)
if(directx-headers_FOUND)
message(STATUS "Using DirectX-Headers package")
target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectX-Headers)
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS)
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC,Intel>:/wd4062> $<$<CXX_COMPILER_ID:Clang,IntelLLVM>:-Wno-switch-enum>)
endif()
add_executable(texconv Texconv/texconv.cpp)
target_link_libraries(texconv ${PROJECT_NAME})
source_group(texconv REGULAR_EXPRESSION Texconv/*.*)
#--- Package
include(CMakePackageConfigHelpers)
string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME)
write_basic_package_version_file(
${PACKAGE_NAME}-config-version.cmake
VERSION ${DIRECTXTEX_VERSION}
COMPATIBILITY AnyNewerVersion)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/build/${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE Microsoft::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
install(FILES ${LIBRARY_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
# Create pkg-config file
include(build/JoinPaths.cmake)
# from: https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files
join_paths(DIRECTXTEX_INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
join_paths(DIRECTXTEX_LIBDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
set(DIRECTXTEX_DEP_L "")
if(ENABLE_OPENEXR_SUPPORT)
list(APPEND DIRECTXTEX_DEP_L "OpenEXR")
endif()
if(directxmath_FOUND)
list(APPEND DIRECTXTEX_DEP_L "DirectXMath")
endif()
if(directx-headers_FOUND)
list(APPEND DIRECTXTEX_DEP_L "DirectX-Headers")
endif()
if(ENABLE_LIBJPEG_SUPPORT AND JPEG_FOUND)
list(APPEND DIRECTXTEX_DEP_L "libjpeg")
endif()
if(ENABLE_LIBPNG_SUPPORT AND PNG_FOUND)
list(APPEND DIRECTXTEX_DEP_L "libpng")
endif()
list(LENGTH DIRECTXTEX_DEP_L DEP_L)
if(DEP_L)
STRING(REPLACE ";" ", " DIRECTXTEX_DEP " ${DIRECTXTEX_DEP_L}")
endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/build/DirectXTex.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/DirectXTex.pc" @ONLY)
# Install the pkg-config file
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DirectXTex.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
#--- Command-line tools
set(TOOL_EXES "")
if(BUILD_TOOLS AND WIN32)
add_executable(texassemble
Texassemble/texassemble.cpp
Texassemble/texassemble.rc
Common/CmdLineHelpers.h
Common/settings.manifest
Texassemble/AnimatedGif.cpp)
target_compile_features(texassemble PRIVATE cxx_std_17)
target_link_libraries(texassemble PRIVATE ${PROJECT_NAME} ole32.lib version.lib)
source_group(texassemble REGULAR_EXPRESSION Texassemble/*.*)
list(APPEND TOOL_EXES texassemble)
endif()
if(BUILD_TOOLS AND BUILD_DX11 AND WIN32)
add_executable(texconv
Texconv/texconv.cpp
Texconv/texconv.rc
Common/CmdLineHelpers.h
Common/settings.manifest
Texconv/ExtendedBMP.cpp
Texconv/PortablePixMap.cpp)
target_compile_features(texconv PRIVATE cxx_std_17)
target_link_libraries(texconv PRIVATE ${PROJECT_NAME} ole32.lib shell32.lib version.lib)
source_group(texconv REGULAR_EXPRESSION Texconv/*.*)
list(APPEND TOOL_EXES texconv)
endif()
if(BUILD_TOOLS AND WIN32)
add_executable(texdiag
Texdiag/texdiag.cpp
Texdiag/texdiag.rc
Common/CmdLineHelpers.h
Common/settings.manifest)
target_compile_features(texdiag PRIVATE cxx_std_17)
target_link_libraries(texdiag PRIVATE ${PROJECT_NAME} ole32.lib version.lib)
source_group(texdiag REGULAR_EXPRESSION Texdiag/*.*)
list(APPEND TOOL_EXES texdiag)
endif()
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_include_directories(${t} PRIVATE Common)
endforeach()
if(BUILD_TOOLS AND WIN32)
if(ENABLE_OPENEXR_SUPPORT)
foreach(t IN LISTS TOOL_EXES)
target_include_directories(${t} PRIVATE Auxiliary)
target_link_libraries(${t} PRIVATE ${OPENEXR_ILMIMF_LIBRARY})
target_compile_definitions(${t} PRIVATE USE_OPENEXR)
endforeach()
endif()
if(ENABLE_LIBJPEG_SUPPORT)
foreach(t IN LISTS TOOL_EXES)
target_include_directories(${t} PRIVATE Auxiliary)
target_link_libraries(${t} PRIVATE JPEG::JPEG)
target_compile_definitions(${t} PRIVATE USE_LIBJPEG)
endforeach()
endif()
if(ENABLE_LIBPNG_SUPPORT)
foreach(t IN LISTS TOOL_EXES)
target_include_directories(${t} PRIVATE Auxiliary)
target_link_libraries(${t} PRIVATE PNG::PNG)
target_compile_definitions(${t} PRIVATE USE_LIBPNG)
endforeach()
endif()
if(BUILD_XBOX_EXTS_SCARLETT OR BUILD_XBOX_EXTS_XBOXONE)
target_include_directories(texconv PRIVATE Auxiliary)
target_compile_definitions(texconv PRIVATE USE_XBOX_EXTS)
target_link_libraries(texconv PUBLIC $<TARGET_NAME_IF_EXISTS:Xbox::GDKX> $<TARGET_NAME_IF_EXISTS:Xbox::XDK>)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21")
add_custom_command(TARGET texconv POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_RUNTIME_DLLS:texconv> $<TARGET_FILE_DIR:texconv>
COMMAND_EXPAND_LISTS
)
endif()
endif()
endif()
#--- DDSView sample
if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32)
list(APPEND TOOL_EXES ddsview)
add_executable(ddsview WIN32
DDSView/ddsview.cpp
DDSView/ddsview.rc
${COMPILED_SHADERS}/ddsview_ps1D.inc)
target_link_libraries(ddsview PRIVATE ${PROJECT_NAME} d3d11.lib ole32.lib)
source_group(ddsview REGULAR_EXPRESSION DDSView/*.*)
target_include_directories(ddsview PRIVATE ${COMPILED_SHADERS})
if(NOT USE_PREBUILT_SHADERS)
add_custom_command(
OUTPUT "${COMPILED_SHADERS}/ddsview_ps1D.inc"
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DDSView/hlsl.cmd"
DEPENDS "DDSView/ddsview.hlsl"
COMMENT "Generating HLSL shaders for DDSView..."
COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" $<$<BOOL:${DIRECTX_FXC_TOOL}>:LegacyShaderCompiler=${DIRECTX_FXC_TOOL}> hlsl.cmd > "${COMPILED_SHADERS}/hlsl_ddsview.log"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DDSView"
USES_TERMINAL)
endif()
endif()
if(directxmath_FOUND)
foreach(t IN LISTS TOOL_EXES)
target_link_libraries(${t} PRIVATE Microsoft::DirectXMath)
endforeach()
endif()
if(TOOL_EXES)
message(STATUS "Building tools: ${TOOL_EXES}")
endif()
add_executable(texdiag Texdiag/texdiag.cpp)
target_link_libraries(texdiag ${PROJECT_NAME})
source_group(texdiag REGULAR_EXPRESSION Texdiag/*.*)
if(MSVC)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /Wall /GR-)
endforeach()
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast)
target_compile_options(texassemble PRIVATE /fp:fast)
target_compile_options(texconv PRIVATE /fp:fast)
target_compile_options(texdiag PRIVATE /fp:fast)
if(NO_WCHAR_T)
message(STATUS "Using non-native wchar_t as unsigned short")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE "/Zc:wchar_t-")
endforeach()
if (${CMAKE_SIZEOF_VOID_P} EQUAL "4")
target_compile_options(${PROJECT_NAME} PRIVATE /arch:SSE2)
target_compile_options(texassemble PRIVATE /arch:SSE2)
target_compile_options(texconv PRIVATE /arch:SSE2)
target_compile_options(texdiag PRIVATE /arch:SSE2)
endif()
endif()
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_definitions(${t} PRIVATE ${COMPILER_DEFINES})
target_compile_options(${t} PRIVATE ${COMPILER_SWITCHES})
target_link_options(${t} PRIVATE ${LINKER_SWITCHES})
endforeach()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|IntelLLVM")
set(WarningsLib -Wall -Wpedantic -Wextra)
if((BUILD_XBOX_EXTS_XBOXONE OR BUILD_XBOX_EXTS_SCARLETT) AND WIN32)
list(APPEND WarningsLib "-Wno-microsoft-enum-value" "-Wno-non-virtual-dtor" "-Wno-ignored-pragmas" "-Wno-deprecated-dynamic-exception-spec")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
list(APPEND WarningsLib "-Wno-reserved-identifier")
endif()
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
list(APPEND WarningsLib "-Wno-unsafe-buffer-usage")
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set(WarningsLib "-Wpedantic" "-Wextra")
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-switch-default" "-Wno-covered-switch-default" "-Wno-language-extension-token" "-Wno-missing-prototypes" "-Wno-global-constructors" "-Wno-double-promotion")
foreach(t IN LISTS TOOL_EXES)
target_compile_options(${t} PRIVATE ${WarningsEXE})
endforeach()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE "-Wno-ignored-attributes" "-Walloc-size-larger-than=4GB")
# OpenMP is not supported for clang for Windows by default
if(BUILD_SHARED_LIBS)
target_compile_options(${t} PRIVATE "-Wno-attributes")
endif()
endforeach()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-language-extension-token" "-Wno-missing-prototypes")
target_compile_options(texassemble PRIVATE ${WarningsEXE})
target_compile_options(texconv PRIVATE ${WarningsEXE})
target_compile_options(texdiag PRIVATE ${WarningsEXE} "-Wno-double-promotion" )
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
target_compile_options(${PROJECT_NAME} PRIVATE /permissive- /JMC- /Zc:__cplusplus)
target_compile_options(texassemble PRIVATE /permissive- /Zc:__cplusplus)
target_compile_options(texconv PRIVATE /permissive- /Zc:__cplusplus)
target_compile_options(texdiag PRIVATE /permissive- /Zc:__cplusplus)
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.37)
AND (NOT (${DIRECTX_ARCH} MATCHES "^arm"))
AND ((${DIRECTX_ARCH} STREQUAL "x64") OR (CMAKE_SIZEOF_VOID_P EQUAL 8)))
# Enable since DirectXTex library has a lot of large switch statements
target_compile_options(${PROJECT_NAME} PRIVATE /jumptablerdata)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
target_compile_options(${PROJECT_NAME} PRIVATE /Zc:preprocessor /wd5105)
target_compile_options(texassemble PRIVATE /Zc:preprocessor /wd5105)
target_compile_options(texconv PRIVATE /Zc:preprocessor /wd5105)
target_compile_options(texdiag PRIVATE /Zc:preprocessor /wd5105)
endif()
if(ENABLE_CODE_ANALYSIS)
message(STATUS "Building with Code Analysis (PREFIX)")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /analyze /WX)
endforeach()
if(BC_USE_OPENMP MATCHES ON)
target_compile_options(${PROJECT_NAME} PRIVATE /openmp /Zc:twoPhase-)
target_compile_options(texconv PRIVATE /openmp /Zc:twoPhase-)
endif()
if(ENABLE_SPECTRE_MITIGATION
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.13)
AND (NOT ENABLE_OPENEXR_SUPPORT)
AND (NOT WINDOWS_STORE))
message(STATUS "Building Spectre-mitigated libraries")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE "/Qspectre")
endforeach()
endif()
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
AND BUILD_XBOX_EXTS_XBOXONE)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /wd5104 /wd5204)
endforeach()
endif()
set(WarningsEXE "/wd4061" "/wd4062" "/wd4365" "/wd4514" "/wd4571" "/wd4625" "/wd4626" "/wd4627" "/wd4668" "/wd4710" "/wd4711" "/wd4751" "/wd4774" "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd5219")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.34)
list(APPEND WarningsEXE "/wd5262" "/wd5264")
endif()
foreach(t IN LISTS TOOL_EXES)
target_compile_options(${t} PRIVATE ${WarningsEXE})
endforeach()
if(BUILD_FUZZING AND (NOT WINDOWS_STORE))
string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.32)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE ${ASAN_SWITCHES})
target_link_libraries(${t} PRIVATE ${ASAN_LIBS})
endforeach()
endif()
endif()
set(WarningsEXE "/wd4061" "/wd4062" "/wd4365" "/wd4668" "/wd4710" "/wd4820" "/wd5039" "/wd5045")
target_compile_options(texassemble PRIVATE ${WarningsEXE})
target_compile_options(texconv PRIVATE ${WarningsEXE})
target_compile_options(texdiag PRIVATE ${WarningsEXE})
endif()
if(WIN32)
if(XBOX_CONSOLE_TARGET STREQUAL "durango")
set(WINVER 0x0602)
elseif(BUILD_DX12 OR (${DIRECTX_ARCH} MATCHES "^arm64"))
message(STATUS "Building with DirectX 12 Runtime support")
set(WINVER 0x0A00)
elseif(${DIRECTX_ARCH} MATCHES "^arm")
set(WINVER 0x0602)
target_compile_definitions(${PROJECT_NAME} PRIVATE _UNICODE UNICODE)
target_compile_definitions(texassemble PRIVATE _UNICODE UNICODE _WIN32_WINNT=0x0601)
target_compile_definitions(texconv PRIVATE _UNICODE UNICODE _WIN32_WINNT=0x0601)
target_compile_definitions(texdiag PRIVATE _UNICODE UNICODE _WIN32_WINNT=0x0601)
if(BUILD_DX12 MATCHES ON)
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0A00)
else()
message(STATUS "Building with Windows 8.1 compatibility")
set(WINVER 0x0603)
endif()
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_definitions(${t} PRIVATE _WIN32_WINNT=${WINVER})
endforeach()
if(DISABLE_MSVC_ITERATOR_DEBUGGING)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_definitions(${t} PRIVATE _ITERATOR_DEBUG_LEVEL=0)
endforeach()
endif()
endif()
if(BUILD_TOOLS AND BUILD_DX11 AND WIN32)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT texconv)
endif()
if(BUILD_TOOLS AND (NOT VCPKG_TOOLCHAIN))
foreach(t IN LISTS TOOL_EXES)
install(TARGETS ${t} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endforeach()
endif()
#--- Test suite
if(WIN32 AND (NOT WINDOWS_STORE) AND (NOT (DEFINED XBOX_CONSOLE_TARGET)))
include(CTest)
if(BUILD_TESTING AND (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Tests/CMakeLists.txt"))
enable_testing()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Tests)
if(ENABLE_CODE_COVERAGE AND (DEFINED COV_COMPILER_SWITCHES))
target_compile_options(${PROJECT_NAME} PRIVATE ${COV_COMPILER_SWITCHES})
endif()
elseif(BUILD_FUZZING AND (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Tests/fuzzloaders/CMakeLists.txt"))
message(STATUS "Building for fuzzing")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Tests/fuzzloaders)
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0601)
endif()
endif()

View File

@ -1,444 +0,0 @@
{
"version": 2,
"configurePresets": [
{
"name": "base",
"displayName": "Basic Config",
"description": "Basic build using Ninja generator",
"generator": "Ninja",
"hidden": true,
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": { "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}" }
},
{
"name": "x64",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": { "DIRECTX_ARCH": "x64" },
"hidden": true
},
{
"name": "x86",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": { "DIRECTX_ARCH": "x86" },
"hidden": true
},
{
"name": "ARM64",
"architecture": {
"value": "arm64",
"strategy": "external"
},
"cacheVariables": { "DIRECTX_ARCH": "arm64" },
"hidden": true
},
{
"name": "ARM64EC",
"architecture": {
"value": "arm64ec",
"strategy": "external"
},
"cacheVariables": { "DIRECTX_ARCH": "arm64ec" },
"environment": {
"CFLAGS": "/arm64EC",
"CXXFLAGS": "/arm64EC"
},
"hidden": true
},
{
"name": "Debug",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" },
"hidden": true
},
{
"name": "Release",
"cacheVariables":
{
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": true
},
"hidden": true
},
{
"name": "MSVC",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "cl.exe"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "Clang",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang-cl.exe"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "Clang-X86",
"environment": {
"CFLAGS": "-m32",
"CXXFLAGS": "-m32"
},
"hidden": true
},
{
"name": "Clang-AArch64",
"environment": {
"CFLAGS": "--target=arm64-pc-windows-msvc",
"CXXFLAGS": "--target=arm64-pc-windows-msvc"
},
"hidden": true
},
{
"name": "GNUC",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++.exe"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "Win8",
"cacheVariables": {
"BUILD_DX12": false
},
"hidden": true
},
{
"name": "GDKX",
"cacheVariables": {
"BUILD_XBOX_EXTS_XBOXONE": true
},
"environment": {
"XboxOneXDKLatest": ""
},
"hidden": true
},
{
"name": "GDKXS",
"cacheVariables": {
"BUILD_XBOX_EXTS_SCARLETT": true
},
"hidden": true
},
{
"name": "XDK",
"cacheVariables": {
"BUILD_XBOX_EXTS_XBOXONE": true
},
"environment": {
"GameDKLatest": ""
},
"hidden": true
},
{
"name": "UWP",
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "WindowsStore",
"CMAKE_SYSTEM_VERSION": "10.0",
"BUILD_DX12": true
},
"hidden": true
},
{
"name": "Scarlett",
"cacheVariables": {
"XBOX_CONSOLE_TARGET": "scarlett"
},
"hidden": true
},
{
"name": "XboxOne",
"cacheVariables": {
"XBOX_CONSOLE_TARGET": "xboxone"
},
"hidden": true
},
{
"name": "Durango",
"cacheVariables": {
"XBOX_CONSOLE_TARGET": "durango"
},
"hidden": true
},
{
"name": "VCPKG",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"type": "FILEPATH"
}
},
"hidden": true
},
{
"name": "EXR",
"cacheVariables": {
"ENABLE_OPENEXR_SUPPORT": true
},
"hidden": true
},
{
"name": "JPEG_PNG",
"cacheVariables": {
"ENABLE_LIBJPEG_SUPPORT": true,
"ENABLE_LIBPNG_SUPPORT": true
},
"hidden": true
},
{
"name": "MinGW32",
"hidden": true,
"environment": {
"PATH": "$penv{PATH};c:/mingw32/bin;c:/mingw32/libexec/gcc/i686-w64-mingw32/12.2.0"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x86-mingw-static",
"VCPKG_HOST_TRIPLET": "x64-windows"
}
},
{
"name": "MinGW64",
"hidden": true,
"environment": {
"PATH": "$penv{PATH};c:/mingw64/bin;c:/mingw64/libexec/gcc/x86_64-w64-mingw32/12.2.0"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-mingw-static",
"VCPKG_HOST_TRIPLET": "x64-windows"
}
},
{
"name": "Intel",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "icl.exe",
"BUILD_TOOLS": false
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "IntelLLVM",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "icx.exe"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "Analyze",
"cacheVariables":
{
"ENABLE_CODE_ANALYSIS": true
},
"hidden": true
},
{
"name": "Coverage",
"cacheVariables":
{
"BUILD_TOOLS": false,
"ENABLE_CODE_COVERAGE": true
},
"hidden": true
},
{
"name": "Fuzzing",
"cacheVariables": {
"BUILD_FUZZING": true,
"BUILD_TESTING": false
},
"hidden": true
},
{ "name": "x64-Debug" , "description": "MSVC for x64 (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "MSVC" ] },
{ "name": "x64-Release" , "description": "MSVC for x64 (Release) with DX12", "inherits": [ "base", "x64", "Release", "MSVC" ] },
{ "name": "x86-Debug" , "description": "MSVC for x86 (Debug) with DX12", "inherits": [ "base", "x86", "Debug", "MSVC" ] },
{ "name": "x86-Release" , "description": "MSVC for x86 (Release) with DX12", "inherits": [ "base", "x86", "Release", "MSVC" ] },
{ "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug) with DX12", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] },
{ "name": "arm64-Release" , "description": "MSVC for ARM64 (Release) with DX12", "inherits": [ "base", "ARM64", "Release", "MSVC" ] },
{ "name": "arm64ec-Debug" , "description": "MSVC for ARM64EC (Debug) with DX12", "inherits": [ "base", "ARM64EC", "Debug", "MSVC" ] },
{ "name": "arm64ec-Release", "description": "MSVC for ARM64EC (Release) with DX12", "inherits": [ "base", "ARM64EC", "Release", "MSVC" ] },
{ "name": "x64-Debug-UWP" , "description": "MSVC for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "MSVC", "UWP" ] },
{ "name": "x64-Release-UWP" , "description": "MSVC for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "MSVC", "UWP" ] },
{ "name": "x86-Debug-UWP" , "description": "MSVC for x86 (Debug) for UWP", "inherits": [ "base", "x86", "Debug", "MSVC", "UWP" ] },
{ "name": "x86-Release-UWP" , "description": "MSVC for x86 (Release) for UWP", "inherits": [ "base", "x86", "Release", "MSVC", "UWP" ] },
{ "name": "arm64-Debug-UWP" , "description": "MSVC for ARM64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "MSVC", "UWP" ] },
{ "name": "arm64-Release-UWP", "description": "MSVC for ARM64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "MSVC", "UWP" ] },
{ "name": "x64-Debug-Win8" , "description": "MSVC for x64 (Debug) for Windows 8.1", "inherits": [ "base", "x64", "Debug", "MSVC", "Win8" ] },
{ "name": "x64-Release-Win8" , "description": "MSVC for x64 (Release) for Windows 8.1", "inherits": [ "base", "x64", "Release", "MSVC", "Win8" ] },
{ "name": "x86-Debug-Win8" , "description": "MSVC for x86 (Debug) for Windows 8.1", "inherits": [ "base", "x86", "Debug", "MSVC", "Win8" ] },
{ "name": "x86-Release-Win8" , "description": "MSVC for x86 (Release) for Windows 8.1", "inherits": [ "base", "x86", "Release", "MSVC", "Win8" ] },
{ "name": "x64-Debug-Scarlett" , "description": "MSVC for x64 (Debug) for Xbox Series X|S", "inherits": [ "base", "x64", "Debug", "MSVC", "Scarlett" ] },
{ "name": "x64-Release-Scarlett" , "description": "MSVC for x64 (Release) for Xbox Series X|S", "inherits": [ "base", "x64", "Release", "MSVC", "Scarlett" ] },
{ "name": "x64-Debug-XboxOne" , "description": "MSVC for x64 (Debug) for Xbox One", "inherits": [ "base", "x64", "Debug", "MSVC", "XboxOne" ] },
{ "name": "x64-Release-XboxOne" , "description": "MSVC for x64 (Release) for Xbox One", "inherits": [ "base", "x64", "Release", "MSVC", "XboxOne" ] },
{ "name": "x64-Debug-Durango" , "description": "MSVC for x64 (Debug) for legacy Xbox One XDK", "inherits": [ "base", "x64", "Debug", "MSVC", "Durango" ] },
{ "name": "x64-Release-Durango" , "description": "MSVC for x64 (Release) for legacy Xbox One XDK", "inherits": [ "base", "x64", "Release", "MSVC", "Durango" ] },
{ "name": "x64-Debug-VCPKG" , "description": "MSVC for x64 (Debug) using VCPKG", "inherits": [ "base", "x64", "Debug", "MSVC", "VCPKG" ] },
{ "name": "x64-Release-VCPKG" , "description": "MSVC for x64 (Release) using VCPKG", "inherits": [ "base", "x64", "Release", "MSVC", "VCPKG" ] },
{ "name": "x86-Debug-VCPKG" , "description": "MSVC for x86 (Debug) using VCPKG", "inherits": [ "base", "x86", "Debug", "MSVC", "VCPKG" ] },
{ "name": "x86-Release-VCPKG" , "description": "MSVC for x86 (Release) using VCPKG", "inherits": [ "base", "x86", "Release", "MSVC", "VCPKG" ] },
{ "name": "arm64-Debug-VCPKG" , "description": "MSVC for ARM64 (Debug) using VCPKG", "inherits": [ "base", "ARM64", "Debug", "MSVC", "VCPKG" ] },
{ "name": "arm64-Release-VCPKG" , "description": "MSVC for ARM64 (Release) using VCPKG", "inherits": [ "base", "ARM64", "Release", "MSVC", "VCPKG" ] },
{ "name": "arm64ec-Debug-VCPKG" , "description": "MSVC for ARM64EC (Debug) using VCPKG", "inherits": [ "base", "ARM64EC", "Debug", "MSVC", "VCPKG" ], "cacheVariables": { "VCPKG_TARGET_TRIPLET": "arm64ec-windows" } },
{ "name": "arm64ec-Release-VCPKG", "description": "MSVC for ARM64EC (Release) using VCPKG", "inherits": [ "base", "ARM64EC", "Release", "MSVC", "VCPKG" ], "cacheVariables": { "VCPKG_TARGET_TRIPLET": "arm64ec-windows" } },
{ "name": "x64-Debug-EXR" , "description": "MSVC for x64 (Debug) using VCPKG/OpenEXR", "inherits": [ "base", "x64", "Debug", "MSVC", "VCPKG", "EXR" ] },
{ "name": "x64-Release-EXR" , "description": "MSVC for x64 (Release) using VCPKG/OpenEXR", "inherits": [ "base", "x64", "Release", "MSVC", "VCPKG", "EXR" ] },
{ "name": "x64-Debug-JPEG-PNG" , "description": "MSVC for x64 (Debug) using VCPKG/PNG/JPEG", "inherits": [ "base", "x64", "Debug", "MSVC", "VCPKG", "JPEG_PNG" ] },
{ "name": "x64-Release-JPEG-PNG", "description": "MSVC for x64 (Release) using VCPKG/PNG/JPEG", "inherits": [ "base", "x64", "Release", "MSVC", "VCPKG", "JPEG_PNG" ] },
{ "name": "x64-Debug-Clang" , "description": "Clang/LLVM for x64 (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "Clang" ] },
{ "name": "x64-Release-Clang" , "description": "Clang/LLVM for x64 (Release) with DX12", "inherits": [ "base", "x64", "Release", "Clang" ] },
{ "name": "x86-Debug-Clang" , "description": "Clang/LLVM for x86 (Debug) with DX12", "inherits": [ "base", "x86", "Debug", "Clang", "Clang-X86" ] },
{ "name": "x86-Release-Clang" , "description": "Clang/LLVM for x86 (Release) with DX12", "inherits": [ "base", "x86", "Release", "Clang", "Clang-X86" ] },
{ "name": "arm64-Debug-Clang" , "description": "Clang/LLVM for AArch64 (Debug) with DX12", "inherits": [ "base", "ARM64", "Debug", "Clang", "Clang-AArch64" ] },
{ "name": "arm64-Release-Clang", "description": "Clang/LLVM for AArch64 (Release) with DX12", "inherits": [ "base", "ARM64", "Release", "Clang", "Clang-AArch64" ] },
{ "name": "x64-Debug-UWP-Clang" , "description": "Clang/LLVM for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "Clang", "UWP" ] },
{ "name": "x64-Release-UWP-Clang" , "description": "Clang/LLVM for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "Clang", "UWP" ] },
{ "name": "x86-Debug-UWP-Clang" , "description": "Clang/LLVM for x86 (Debug) for UWP", "inherits": [ "base", "x86", "Debug", "Clang", "Clang-X86", "UWP" ] },
{ "name": "x86-Release-UWP-Clang" , "description": "Clang/LLVM for x86 (Release) for UWP", "inherits": [ "base", "x86", "Release", "Clang", "Clang-X86", "UWP" ] },
{ "name": "arm64-Debug-UWP-Clang" , "description": "Clang/LLVM for AArch64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "Clang", "Clang-AArch64", "UWP" ] },
{ "name": "arm64-Release-UWP-Clang", "description": "Clang/LLVM for AArch64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "Clang", "Clang-AArch64", "UWP" ] },
{ "name": "x64-Debug-Win8-Clang" , "description": "Clang/LLVM for x64 (Debug) for Windows 8.1", "inherits": [ "base", "x64", "Debug", "Clang", "Win8" ] },
{ "name": "x64-Release-Win8-Clang", "description": "Clang/LLVM for x64 (Release) for Windows 8.1", "inherits": [ "base", "x64", "Release", "Clang", "Win8" ] },
{ "name": "x86-Debug-Win8-Clang" , "description": "Clang/LLVM for x86 (Debug) for Windows 8.1", "inherits": [ "base", "x86", "Debug", "Clang", "Clang-X86", "Win8" ] },
{ "name": "x86-Release-Win8-Clang", "description": "Clang/LLVM for x86 (Release) for Windows 8.1", "inherits": [ "base", "x86", "Release", "Clang", "Clang-X86", "Win8" ] },
{ "name": "x64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Debug) using VCPKG/OpenEXR", "inherits": [ "base", "x64", "Debug", "Clang", "VCPKG" ] },
{ "name": "x64-Release-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Release) using VCPKG/OpenEXR", "inherits": [ "base", "x64", "Release", "Clang", "VCPKG" ] },
{ "name": "x86-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Debug) using VCPKG/OpenEXR", "inherits": [ "base", "x86", "Debug", "Clang", "Clang-X86", "VCPKG" ] },
{ "name": "x86-Release-Clang-VCPKG" , "description": "Clang/LLVM for x86 (Release) using VCPKG/OpenEXR", "inherits": [ "base", "x86", "Release", "Clang", "Clang-X86", "VCPKG" ] },
{ "name": "arm64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for AArch64 (Debug) using VCPKG/OpenEXR", "inherits": [ "base", "ARM64", "Debug", "Clang", "Clang-AArch64", "VCPKG" ] },
{ "name": "arm64-Release-Clang-VCPKG", "description": "Clang/LLVM for AArch64 (Release) using VCPKG/OpenEXR", "inherits": [ "base", "ARM64", "Release", "Clang", "Clang-AArch64", "VCPKG" ] },
{ "name": "x64-Debug-Clang-JPEG-PNG" , "description": "Clang/LLVM for x64 (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "Clang", "VCPKG", "JPEG_PNG" ] },
{ "name": "x64-Release-Clang-JPEG-PNG" , "description": "Clang/LLVM for x64 (Release) with DX12", "inherits": [ "base", "x64", "Release", "Clang", "VCPKG", "JPEG_PNG" ] },
{ "name": "x64-Debug-GDKX" , "description": "MSVC for x64 (Debug) Xbox One Extensions", "inherits": [ "base", "x64", "Debug", "GDKX", "MSVC" ] },
{ "name": "x64-Release-GDKX" , "description": "MSVC for x64 (Release) Xbox One Extensions", "inherits": [ "base", "x64", "Release", "GDKX", "MSVC" ] },
{ "name": "x64-Debug-GDKX-S" , "description": "MSVC for x64 (Debug) Xbox Series X|S Extensions", "inherits": [ "base", "x64", "Debug", "GDKXS", "MSVC" ] },
{ "name": "x64-Release-GDKX-S" , "description": "MSVC for x64 (Release) Xbox Series X|S Extensions", "inherits": [ "base", "x64", "Release", "GDKXS", "MSVC" ] },
{ "name": "x64-Debug-XDK" , "description": "MSVC for x64 (Debug) Xbox One Extensions (legacy)", "inherits": [ "base", "x64", "Debug", "XDK", "MSVC" ] },
{ "name": "x64-Release-XDK" , "description": "MSVC for x64 (Release) Xbox One Extensions (legacy)", "inherits": [ "base", "x64", "Release", "XDK", "MSVC" ] },
{ "name": "x64-Debug-GDKX-Clang" , "description": "MSVC for x64 (Debug) Xbox One Extensions", "inherits": [ "base", "x64", "Debug", "GDKX", "Clang" ] },
{ "name": "x64-Release-GDKX-Clang" , "description": "MSVC for x64 (Release) Xbox One Extensions", "inherits": [ "base", "x64", "Release", "GDKX", "Clang" ] },
{ "name": "x64-Debug-GDKX-S-Clang" , "description": "MSVC for x64 (Debug) Xbox Series X|S Extensions", "inherits": [ "base", "x64", "Debug", "GDKXS", "Clang" ] },
{ "name": "x64-Release-GDKX-S-Clang" , "description": "MSVC for x64 (Release) Xbox Series X|S Extensions", "inherits": [ "base", "x64", "Release", "GDKXS", "Clang" ] },
{ "name": "x64-Debug-Scarlett-Clang" , "description": "Clang/LLVM for x64 (Debug) for Xbox Series X|S", "inherits": [ "base", "x64", "Debug", "Clang", "Scarlett" ] },
{ "name": "x64-Release-Scarlett-Clang", "description": "Clang/LLVM for x64 (Release) for Xbox Series X|S", "inherits": [ "base", "x64", "Release", "Clang", "Scarlett" ] },
{ "name": "x64-Debug-XboxOne-Clang" , "description": "Clang/LLVM for x64 (Debug) for Xbox One", "inherits": [ "base", "x64", "Debug", "Clang", "XboxOne" ] },
{ "name": "x64-Release-XboxOne-Clang" , "description": "Clang/LLVM for x64 (Release) for Xbox One", "inherits": [ "base", "x64", "Release", "Clang", "XboxOne" ] },
{ "name": "x64-Debug-MinGW" , "description": "MinG-W64 (Debug)", "inherits": [ "base", "x64", "Debug", "GNUC", "VCPKG", "MinGW64" ] },
{ "name": "x64-Release-MinGW", "description": "MinG-W64 (Release)", "inherits": [ "base", "x64", "Release", "GNUC", "VCPKG", "MinGW64" ] },
{ "name": "x86-Debug-MinGW" , "description": "MinG-W32 (Debug)", "inherits": [ "base", "x86", "Debug", "GNUC", "VCPKG", "MinGW32" ] },
{ "name": "x86-Release-MinGW", "description": "MinG-W32 (Release)", "inherits": [ "base", "x86", "Release", "GNUC", "VCPKG", "MinGW32" ] },
{ "name": "x64-Debug-MinGW-JPEG-PNG" , "description": "MinG-W64 (Debug)", "inherits": [ "base", "x64", "Debug", "GNUC", "VCPKG", "MinGW64", "JPEG_PNG" ] },
{ "name": "x64-Release-MinGW-JPEG-PNG", "description": "MinG-W64 (Release)", "inherits": [ "base", "x64", "Release", "GNUC", "VCPKG", "MinGW64", "JPEG_PNG" ] },
{ "name": "x86-Debug-MinGW-JPEG-PNG" , "description": "MinG-W32 (Debug)", "inherits": [ "base", "x86", "Debug", "GNUC", "VCPKG", "MinGW32", "JPEG_PNG" ] },
{ "name": "x86-Release-MinGW-JPEG-PNG", "description": "MinG-W32 (Release)", "inherits": [ "base", "x86", "Release", "GNUC", "VCPKG", "MinGW32", "JPEG_PNG" ] },
{ "name": "x64-Debug-Linux", "description": "WSL Linux x64 (Debug)", "inherits": [ "base", "x64", "Debug", "VCPKG", "JPEG_PNG" ] },
{ "name": "x64-Release-Linux", "description": "WSL Linux x64 (Release)", "inherits": [ "base", "x64", "Release", "VCPKG", "JPEG_PNG" ] },
{ "name": "arm64-Debug-Linux", "description": "WSL Linux ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "VCPKG", "JPEG_PNG" ] },
{ "name": "arm64-Release-Linux", "description": "WSL Linux ARM64 (Release)", "inherits": [ "base", "ARM64", "Release", "VCPKG", "JPEG_PNG" ] },
{ "name": "x64-Debug-ICC" , "description": "Intel Classic Compiler (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "Intel" ] },
{ "name": "x64-Release-ICC" , "description": "Intel Classic Compiler (Release) with DX12", "inherits": [ "base", "x64", "Release", "Intel" ] },
{ "name": "x64-Debug-ICX" , "description": "Intel oneAPI Compiler (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "IntelLLVM" ] },
{ "name": "x64-Release-ICX" , "description": "Intel oneAPI Compiler (Release) with DX12", "inherits": [ "base", "x64", "Release", "IntelLLVM" ] },
{ "name": "x64-Analyze" , "description": "MSVC for x64 (Debug) with DX12 using /analyze", "inherits": [ "base", "x64", "Debug", "MSVC", "Analyze" ] },
{ "name": "x64-Coverage" , "description": "MSVC for x64 (Debug) with DX12 w/ Code Coverage", "inherits": [ "base", "x64", "Debug", "MSVC", "Coverage" ] },
{ "name": "x64-Coverage-Clang", "description": "Clang/LLVM for x64 (Debug) with DX12 w/ Code Coverage", "inherits": [ "base", "x64", "Debug", "Clang", "Coverage" ] },
{ "name": "x64-Fuzzing" , "description": "MSVC for x64 (Release) with ASan", "inherits": [ "base", "x64", "Release", "MSVC", "Fuzzing" ] }
],
"testPresets": [
{ "name": "x64-Debug" , "configurePreset": "x64-Debug" },
{ "name": "x64-Release" , "configurePreset": "x64-Release" },
{ "name": "x86-Debug" , "configurePreset": "x86-Debug" },
{ "name": "x86-Release" , "configurePreset": "x86-Release" },
{ "name": "arm64-Debug" , "configurePreset": "arm64-Debug" },
{ "name": "arm64-Release" , "configurePreset": "arm64-Release" },
{ "name": "arm64ec-Debug" , "configurePreset": "arm64ec-Debug" },
{ "name": "arm64ec-Release", "configurePreset": "arm64ec-Release" },
{ "name": "x64-Debug-VCPKG" , "configurePreset": "x64-Debug-VCPKG" },
{ "name": "x64-Release-VCPKG" , "configurePreset": "x64-Release-VCPKG" },
{ "name": "x86-Debug-VCPKG" , "configurePreset": "x86-Debug-VCPKG" },
{ "name": "x86-Release-VCPKG" , "configurePreset": "x86-Release-VCPKG" },
{ "name": "arm64-Debug-VCPKG" , "configurePreset": "arm64-Debug-VCPKG" },
{ "name": "arm64-Release-VCPKG" , "configurePreset": "arm64-Release-VCPKG" },
{ "name": "arm64ec-Debug-VCPKG" , "configurePreset": "arm64ec-Debug-VCPKG" },
{ "name": "arm64ec-Release-VCPKG", "configurePreset": "arm64ec-Release-VCPKG" },
{ "name": "x64-Debug-Clang" , "configurePreset": "x64-Debug-Clang" },
{ "name": "x64-Release-Clang" , "configurePreset": "x64-Release-Clang" },
{ "name": "x86-Debug-Clang" , "configurePreset": "x86-Debug-Clang" },
{ "name": "x86-Release-Clang" , "configurePreset": "x86-Release-Clang" },
{ "name": "arm64-Debug-Clang" , "configurePreset": "arm64-Debug-Clang" },
{ "name": "arm64-Release-Clang", "configurePreset": "arm64-Release-Clang" },
{ "name": "x64-Debug-GDKX" , "configurePreset": "x64-Debug-GDKX" },
{ "name": "x64-Release-GDKX" , "configurePreset": "x64-Release-GDKX" },
{ "name": "x64-Debug-GDKX-S" , "configurePreset": "x64-Debug-GDKX-S" },
{ "name": "x64-Release-GDKX-S" , "configurePreset": "x64-Release-GDKX-S" },
{ "name": "x64-Debug-MinGW" , "configurePreset": "x64-Debug-MinGW" },
{ "name": "x64-Release-MinGW" , "configurePreset": "x64-Release-MinGW" },
{ "name": "x86-Debug-MinGW" , "configurePreset": "x86-Debug-MinGW" },
{ "name": "x86-Release-MinGW" , "configurePreset": "x86-Release-MinGW" },
{ "name": "x64-Debug-ICC" , "configurePreset": "x64-Debug-ICC" },
{ "name": "x64-Release-ICC" , "configurePreset": "x64-Release-ICC"},
{ "name": "x64-Debug-ICX" , "configurePreset": "x64-Debug-ICX" },
{ "name": "x64-Release-ICX" , "configurePreset": "x64-Release-ICX"},
{ "name": "x64-Debug-JPEG-PNG" , "configurePreset": "x64-Debug-JPEG-PNG" },
{ "name": "x64-Release-JPEG-PNG", "configurePreset": "x64-Release-JPEG-PNG"}
]
}

52
CMakeSettings.json Normal file
View File

@ -0,0 +1,52 @@
{
"configurations": [
{
"name": "x86-Clang-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x86" ],
"variables": []
},
{
"name": "x86-Clang-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x86" ],
"variables": []
},
{
"name": "x64-Clang-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64" ],
"variables": []
},
{
"name": "x64-Clang-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64" ],
"variables": []
}
]
}

View File

@ -1,10 +0,0 @@
# Microsoft Open Source Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
Resources:
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
- Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support)

View File

@ -1,375 +0,0 @@
//--------------------------------------------------------------------------------------
// File: CmdLineHelpers.h
//
// Command-line tool shared functions
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#pragma once
#if __cplusplus < 201703L
#error Requires C++17 (and /Zc:__cplusplus with MSVC)
#endif
#include <algorithm>
#include <cstdio>
#include <cwchar>
#include <filesystem>
#include <fstream>
#include <list>
#include <memory>
#include <set>
#include <string>
#ifndef TOOL_VERSION
#error Define TOOL_VERSION before including this header
#endif
namespace Helpers
{
struct handle_closer { void operator()(HANDLE h) { if (h) CloseHandle(h); } };
using ScopedHandle = std::unique_ptr<void, handle_closer>;
inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
struct find_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } };
using ScopedFindHandle = std::unique_ptr<void, find_closer>;
#ifdef _PREFAST_
#pragma prefast(disable : 26018, "Only used with static internal arrays")
#endif
struct SConversion
{
std::wstring szSrc;
std::wstring szFolder;
};
template<typename T>
struct SValue
{
const wchar_t* name;
T value;
};
template<typename T>
T LookupByName(const wchar_t _In_z_ *pName, const SValue<T> *pArray)
{
while (pArray->name)
{
if (!_wcsicmp(pName, pArray->name))
return pArray->value;
pArray++;
}
return static_cast<T>(0);
}
template<typename T>
const wchar_t* LookupByValue(T value, const SValue<T> *pArray)
{
while (pArray->name)
{
if (value == pArray->value)
return pArray->name;
pArray++;
}
return L"";
}
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList)
{
for (auto pFormat = pFormatList; pFormat->name; pFormat++)
{
if (pFormat->value == Format)
{
wprintf(L"%ls", pFormat->name);
return;
}
}
wprintf(L"*UNKNOWN*");
}
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList1, const SValue<DXGI_FORMAT>* pFormatList2)
{
for (auto pFormat = pFormatList1; pFormat->name; pFormat++)
{
if (pFormat->value == Format)
{
wprintf(L"%ls", pFormat->name);
return;
}
}
for (auto pFormat = pFormatList2; pFormat->name; pFormat++)
{
if (pFormat->value == Format)
{
wprintf(L"%ls", pFormat->name);
return;
}
}
wprintf(L"*UNKNOWN*");
}
template<typename T>
void PrintList(size_t cch, const SValue<T> *pValue)
{
while (pValue->name)
{
const size_t cchName = wcslen(pValue->name);
if (cch + cchName + 2 >= 80)
{
wprintf(L"\n ");
cch = 6;
}
wprintf(L"%ls ", pValue->name);
cch += cchName + 2;
pValue++;
}
wprintf(L"\n");
}
void PrintLogo(bool versionOnly, _In_z_ const wchar_t* name, _In_z_ const wchar_t* desc)
{
wchar_t version[32] = {};
wchar_t appName[_MAX_PATH] = {};
if (GetModuleFileNameW(nullptr, appName, _MAX_PATH))
{
const DWORD size = GetFileVersionInfoSizeW(appName, nullptr);
if (size > 0)
{
auto verInfo = std::make_unique<uint8_t[]>(size);
if (GetFileVersionInfoW(appName, 0, size, verInfo.get()))
{
LPVOID lpstr = nullptr;
UINT strLen = 0;
if (VerQueryValueW(verInfo.get(), L"\\StringFileInfo\\040904B0\\ProductVersion", &lpstr, &strLen))
{
wcsncpy_s(version, reinterpret_cast<const wchar_t*>(lpstr), strLen);
}
}
}
}
if (!*version || wcscmp(version, L"1.0.0.0") == 0)
{
swprintf_s(version, L"%03d (library)", TOOL_VERSION);
}
if (versionOnly)
{
wprintf(L"%ls version %ls\n", name, version);
}
else
{
wprintf(L"%ls Version %ls\n", desc, version);
wprintf(L"Copyright (C) Microsoft Corp.\n");
#ifdef _DEBUG
wprintf(L"*** Debug build ***\n");
#endif
wprintf(L"\n");
}
}
void SearchForFiles(const std::filesystem::path& path, std::list<SConversion>& files, bool recursive, _In_opt_z_ const wchar_t* folder)
{
// Process files
WIN32_FIND_DATAW findData = {};
ScopedFindHandle hFile(safe_handle(FindFirstFileExW(path.c_str(),
FindExInfoBasic, &findData,
FindExSearchNameMatch, nullptr,
FIND_FIRST_EX_LARGE_FETCH)));
if (hFile)
{
for (;;)
{
if (!(findData.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY)))
{
SConversion conv = {};
conv.szSrc = path.parent_path().append(findData.cFileName).native();
if (folder)
{
conv.szFolder = folder;
}
files.push_back(conv);
}
if (!FindNextFileW(hFile.get(), &findData))
break;
}
}
// Process directories
if (recursive)
{
auto searchDir = path.parent_path().append(L"*");
hFile.reset(safe_handle(FindFirstFileExW(searchDir.c_str(),
FindExInfoBasic, &findData,
FindExSearchLimitToDirectories, nullptr,
FIND_FIRST_EX_LARGE_FETCH)));
if (!hFile)
return;
for (;;)
{
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (findData.cFileName[0] != L'.')
{
auto subfolder = (folder)
? (std::wstring(folder) + std::wstring(findData.cFileName) + std::filesystem::path::preferred_separator)
: (std::wstring(findData.cFileName) + std::filesystem::path::preferred_separator);
auto subdir = path.parent_path().append(findData.cFileName).append(path.filename().c_str());
SearchForFiles(subdir, files, recursive, subfolder.c_str());
}
}
if (!FindNextFileW(hFile.get(), &findData))
break;
}
}
}
void ProcessFileList(std::wifstream& inFile, std::list<SConversion>& files)
{
std::list<SConversion> flist;
std::set<std::wstring> excludes;
for (;;)
{
std::wstring fname;
std::getline(inFile, fname);
if (!inFile)
break;
if (fname[0] == L'#')
{
// Comment
}
else if (fname[0] == L'-')
{
if (flist.empty())
{
wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname.c_str());
}
else
{
std::filesystem::path path(fname.c_str() + 1);
auto& npath = path.make_preferred();
if (wcspbrk(fname.c_str(), L"?*") != nullptr)
{
std::list<SConversion> removeFiles;
SearchForFiles(npath, removeFiles, false, nullptr);
for (auto& it : removeFiles)
{
std::wstring name = it.szSrc;
std::transform(name.begin(), name.end(), name.begin(), towlower);
excludes.insert(name);
}
}
else
{
std::wstring name = npath.c_str();
std::transform(name.begin(), name.end(), name.begin(), towlower);
excludes.insert(name);
}
}
}
else if (wcspbrk(fname.c_str(), L"?*") != nullptr)
{
std::filesystem::path path(fname.c_str());
SearchForFiles(path.make_preferred(), flist, false, nullptr);
}
else
{
SConversion conv = {};
std::filesystem::path path(fname.c_str());
conv.szSrc = path.make_preferred().native();
flist.push_back(conv);
}
}
inFile.close();
if (!excludes.empty())
{
// Remove any excluded files
for (auto it = flist.begin(); it != flist.end();)
{
std::wstring name = it->szSrc;
std::transform(name.begin(), name.end(), name.begin(), towlower);
auto item = it;
++it;
if (excludes.find(name) != excludes.end())
{
flist.erase(item);
}
}
}
if (flist.empty())
{
wprintf(L"WARNING: No file names found in -flist\n");
}
else
{
files.splice(files.end(), flist);
}
}
const wchar_t* GetErrorDesc(HRESULT hr)
{
static wchar_t desc[1024] = {};
LPWSTR errorText = nullptr;
const DWORD result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER,
nullptr, static_cast<DWORD>(hr),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPWSTR>(&errorText), 0, nullptr);
*desc = 0;
if (result > 0 && errorText)
{
swprintf_s(desc, L": %ls", errorText);
size_t len = wcslen(desc);
if (len >= 1)
{
desc[len - 1] = 0;
}
if (errorText)
LocalFree(errorText);
for (wchar_t* ptr = desc; *ptr != 0; ++ptr)
{
if (*ptr == L'\r' || *ptr == L'\n')
{
*ptr = L' ';
}
}
}
return desc;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +0,0 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10 / Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
<asmv3:application>
<asmv3:windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
// a full-featured DDS file reader, writer, and texture processing pipeline see
// the 'Texconv' sample and the 'DirectXTex' library.
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
@ -18,9 +18,6 @@
#include <d3d11_1.h>
#pragma comment(lib,"dxguid.lib")
#include <cstddef>
#include <cstdint>
@ -30,37 +27,14 @@ namespace DirectX
#define DDS_ALPHA_MODE_DEFINED
enum DDS_ALPHA_MODE : uint32_t
{
DDS_ALPHA_MODE_UNKNOWN = 0,
DDS_ALPHA_MODE_STRAIGHT = 1,
DDS_ALPHA_MODE_UNKNOWN = 0,
DDS_ALPHA_MODE_STRAIGHT = 1,
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
DDS_ALPHA_MODE_OPAQUE = 3,
DDS_ALPHA_MODE_CUSTOM = 4,
DDS_ALPHA_MODE_OPAQUE = 3,
DDS_ALPHA_MODE_CUSTOM = 4,
};
#endif
#ifndef DDS_LOADER_FLAGS_DEFINED
#define DDS_LOADER_FLAGS_DEFINED
enum DDS_LOADER_FLAGS : uint32_t
{
DDS_LOADER_DEFAULT = 0,
DDS_LOADER_FORCE_SRGB = 0x1,
DDS_LOADER_IGNORE_SRGB = 0x2,
};
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#endif
DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif
// Standard version
HRESULT CreateDDSTextureFromMemory(
_In_ ID3D11Device* d3dDevice,
@ -109,7 +83,7 @@ namespace DirectX
_In_ unsigned int bindFlags,
_In_ unsigned int cpuAccessFlags,
_In_ unsigned int miscFlags,
_In_ DDS_LOADER_FLAGS loadFlags,
_In_ bool forceSRGB,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
@ -122,7 +96,7 @@ namespace DirectX
_In_ unsigned int bindFlags,
_In_ unsigned int cpuAccessFlags,
_In_ unsigned int miscFlags,
_In_ DDS_LOADER_FLAGS loadFlags,
_In_ bool forceSRGB,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
@ -138,7 +112,7 @@ namespace DirectX
_In_ unsigned int bindFlags,
_In_ unsigned int cpuAccessFlags,
_In_ unsigned int miscFlags,
_In_ DDS_LOADER_FLAGS loadFlags,
_In_ bool forceSRGB,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
@ -152,7 +126,7 @@ namespace DirectX
_In_ unsigned int bindFlags,
_In_ unsigned int cpuAccessFlags,
_In_ unsigned int miscFlags,
_In_ DDS_LOADER_FLAGS loadFlags,
_In_ bool forceSRGB,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
// a full-featured DDS file reader, writer, and texture processing pipeline see
// the 'Texconv' sample and the 'DirectXTex' library.
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
@ -16,24 +16,8 @@
#pragma once
#ifdef __MINGW32__
#include <unknwn.h>
#endif
#ifndef _WIN32
#include <wsl/winadapter.h>
#include <wsl/wrladapter.h>
#endif
#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS)
#include <directx/d3d12.h>
#include <dxguids/dxguids.h>
#else
#include <d3d12.h>
#pragma comment(lib,"dxguid.lib")
#endif
#include <cstddef>
#include <cstdint>
#include <memory>
#include <vector>
@ -45,39 +29,21 @@ namespace DirectX
#define DDS_ALPHA_MODE_DEFINED
enum DDS_ALPHA_MODE : uint32_t
{
DDS_ALPHA_MODE_UNKNOWN = 0,
DDS_ALPHA_MODE_STRAIGHT = 1,
DDS_ALPHA_MODE_UNKNOWN = 0,
DDS_ALPHA_MODE_STRAIGHT = 1,
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
DDS_ALPHA_MODE_OPAQUE = 3,
DDS_ALPHA_MODE_CUSTOM = 4,
DDS_ALPHA_MODE_OPAQUE = 3,
DDS_ALPHA_MODE_CUSTOM = 4,
};
#endif
#ifndef DDS_LOADER_FLAGS_DEFINED
#define DDS_LOADER_FLAGS_DEFINED
enum DDS_LOADER_FLAGS : uint32_t
enum DDS_LOADER_FLAGS
{
DDS_LOADER_DEFAULT = 0,
DDS_LOADER_FORCE_SRGB = 0x1,
DDS_LOADER_IGNORE_SRGB = 0x2,
DDS_LOADER_MIP_RESERVE = 0x8,
DDS_LOADER_DEFAULT = 0,
DDS_LOADER_FORCE_SRGB = 0x1,
DDS_LOADER_MIP_RESERVE = 0x8,
};
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#endif
DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif
// Standard version
HRESULT __cdecl LoadDDSTextureFromMemory(
_In_ ID3D12Device* d3dDevice,
@ -106,7 +72,7 @@ namespace DirectX
size_t ddsDataSize,
size_t maxsize,
D3D12_RESOURCE_FLAGS resFlags,
DDS_LOADER_FLAGS loadFlags,
unsigned int loadFlags,
_Outptr_ ID3D12Resource** texture,
std::vector<D3D12_SUBRESOURCE_DATA>& subresources,
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
@ -117,7 +83,7 @@ namespace DirectX
_In_z_ const wchar_t* szFileName,
size_t maxsize,
D3D12_RESOURCE_FLAGS resFlags,
DDS_LOADER_FLAGS loadFlags,
unsigned int loadFlags,
_Outptr_ ID3D12Resource** texture,
std::unique_ptr<uint8_t[]>& ddsData,
std::vector<D3D12_SUBRESOURCE_DATA>& subresources,

View File

@ -7,7 +7,7 @@
// a full-featured DDS file reader, writer, and texture processing pipeline see
// the 'Texconv' sample and the 'DirectXTex' library.
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
@ -18,24 +18,12 @@
#include <d3d9types.h>
#include <assert.h>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <memory>
#include <new>
#include <wrl/client.h>
#ifdef _MSC_VER
// Off by default warnings
#pragma warning(disable : 4619 4616 4623 4626 5027)
// C4619/4616 #pragma warning warnings
// C4623 default constructor was implicitly defined as deleted
// C4626 assignment operator was implicitly defined as deleted
// C5027 move assignment operator was implicitly defined as deleted
#endif
#ifdef __clang__
#pragma clang diagnostic ignored "-Wcovered-switch-default"
#pragma clang diagnostic ignored "-Wswitch-enum"
@ -48,7 +36,7 @@ using Microsoft::WRL::ComPtr;
// Macros
//--------------------------------------------------------------------------------------
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
#endif /* defined(MAKEFOURCC) */
@ -58,23 +46,21 @@ using Microsoft::WRL::ComPtr;
//
// See DDS.h in the 'Texconv' sample and the 'DirectXTex' library
//--------------------------------------------------------------------------------------
namespace
{
#pragma pack(push,1)
constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS "
const uint32_t DDS_MAGIC = 0x20534444; // "DDS "
struct DDS_PIXELFORMAT
{
uint32_t size;
uint32_t flags;
uint32_t fourCC;
uint32_t RGBBitCount;
uint32_t RBitMask;
uint32_t GBitMask;
uint32_t BBitMask;
uint32_t ABitMask;
};
struct DDS_PIXELFORMAT
{
uint32_t size;
uint32_t flags;
uint32_t fourCC;
uint32_t RGBBitCount;
uint32_t RBitMask;
uint32_t GBitMask;
uint32_t BBitMask;
uint32_t ABitMask;
};
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
@ -93,37 +79,34 @@ namespace
#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ
#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\
DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\
DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ )
DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\
DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ )
#define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP
struct DDS_HEADER
{
uint32_t size;
uint32_t flags;
uint32_t height;
uint32_t width;
uint32_t pitchOrLinearSize;
uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags
uint32_t mipMapCount;
uint32_t reserved1[11];
DDS_PIXELFORMAT ddspf;
uint32_t caps;
uint32_t caps2;
uint32_t caps3;
uint32_t caps4;
uint32_t reserved2;
};
struct DDS_HEADER
{
uint32_t size;
uint32_t flags;
uint32_t height;
uint32_t width;
uint32_t pitchOrLinearSize;
uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags
uint32_t mipMapCount;
uint32_t reserved1[11];
DDS_PIXELFORMAT ddspf;
uint32_t caps;
uint32_t caps2;
uint32_t caps3;
uint32_t caps4;
uint32_t reserved2;
};
#pragma pack(pop)
static_assert(sizeof(DDS_PIXELFORMAT) == 32, "DDS pixel format size mismatch");
static_assert(sizeof(DDS_HEADER) == 124, "DDS Header size mismatch");
constexpr size_t DDS_DX9_HEADER_SIZE = sizeof(uint32_t) + sizeof(DDS_HEADER);
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
namespace
{
struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } };
using ScopedHandle = std::unique_ptr<void, handle_closer>;
@ -143,20 +126,18 @@ namespace
return E_POINTER;
}
*bitSize = 0;
if (ddsDataSize > UINT32_MAX)
{
return E_FAIL;
}
if (ddsDataSize < DDS_DX9_HEADER_SIZE)
if (ddsDataSize < (sizeof(uint32_t) + sizeof(DDS_HEADER)))
{
return E_FAIL;
}
// DDS files always start with the same magic number ("DDS ")
const auto dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData);
auto dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData);
if (dwMagicNumber != DDS_MAGIC)
{
return E_FAIL;
@ -181,8 +162,9 @@ namespace
// setup the pointers in the process request
*header = hdr;
*bitData = ddsData + DDS_DX9_HEADER_SIZE;
*bitSize = ddsDataSize - DDS_DX9_HEADER_SIZE;
auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER);
*bitData = ddsData + offset;
*bitSize = ddsDataSize - offset;
return S_OK;
}
@ -201,13 +183,23 @@ namespace
return E_POINTER;
}
*bitSize = 0;
// open the file
ScopedHandle hFile(safe_handle(CreateFile2(
fileName,
GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING,
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
ScopedHandle hFile(safe_handle(CreateFile2(fileName,
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
nullptr)));
#else
ScopedHandle hFile(safe_handle(CreateFileW(fileName,
GENERIC_READ,
FILE_SHARE_READ,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr)));
#endif
if (!hFile)
{
return HRESULT_FROM_WIN32(GetLastError());
@ -227,7 +219,7 @@ namespace
}
// Need at least enough data to fill the header and magic number to be a valid DDS
if (fileInfo.EndOfFile.LowPart < DDS_DX9_HEADER_SIZE)
if (fileInfo.EndOfFile.LowPart < (sizeof(uint32_t) + sizeof(DDS_HEADER)))
{
return E_FAIL;
}
@ -240,29 +232,26 @@ namespace
}
// read the data in
DWORD bytesRead = 0;
DWORD BytesRead = 0;
if (!ReadFile(hFile.get(),
ddsData.get(),
fileInfo.EndOfFile.LowPart,
&bytesRead,
&BytesRead,
nullptr
))
{
ddsData.reset();
return HRESULT_FROM_WIN32(GetLastError());
}
if (bytesRead < fileInfo.EndOfFile.LowPart)
if (BytesRead < fileInfo.EndOfFile.LowPart)
{
ddsData.reset();
return E_FAIL;
}
// DDS files always start with the same magic number ("DDS ")
const auto dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData.get());
auto dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData.get());
if (dwMagicNumber != DDS_MAGIC)
{
ddsData.reset();
return E_FAIL;
}
@ -272,7 +261,6 @@ namespace
if (hdr->size != sizeof(DDS_HEADER) ||
hdr->ddspf.size != sizeof(DDS_PIXELFORMAT))
{
ddsData.reset();
return E_FAIL;
}
@ -281,14 +269,14 @@ namespace
(MAKEFOURCC('D', 'X', '1', '0') == hdr->ddspf.fourCC))
{
// We don't support the new DX10 header for Direct3D 9
ddsData.reset();
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
// setup the pointers in the process request
*header = hdr;
*bitData = ddsData.get() + DDS_DX9_HEADER_SIZE;
*bitSize = fileInfo.EndOfFile.LowPart - DDS_DX9_HEADER_SIZE;
auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER);
*bitData = ddsData.get() + offset;
*bitSize = fileInfo.EndOfFile.LowPart - offset;
return S_OK;
}
@ -330,9 +318,6 @@ namespace
case D3DFMT_INDEX32:
case D3DFMT_G16R16F:
case D3DFMT_R32F:
#if !defined(D3D_DISABLE_9EX)
case D3DFMT_D32_LOCKABLE:
#endif
return 32;
case D3DFMT_R8G8B8:
@ -357,9 +342,6 @@ namespace
case D3DFMT_INDEX16:
case D3DFMT_R16F:
case D3DFMT_YUY2:
// From DX docs, reference/d3d/enums/d3dformat.asp
// (note how it says that D3DFMT_R8G8_B8G8 is "A 16-bit packed RGB format analogous to UYVY (U0Y0, V0Y1, U2Y2, and so on)")
case D3DFMT_UYVY:
return 16;
case D3DFMT_R3G3B2:
@ -368,28 +350,40 @@ namespace
case D3DFMT_P8:
case D3DFMT_L8:
case D3DFMT_A4L4:
case D3DFMT_DXT2:
case D3DFMT_DXT3:
case D3DFMT_DXT4:
case D3DFMT_DXT5:
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/directxvideoaccelerationdxvavideosubtypes.asp
case MAKEFOURCC('A', 'I', '4', '4'):
case MAKEFOURCC('I', 'A', '4', '4'):
#if !defined(D3D_DISABLE_9EX)
case D3DFMT_S8_LOCKABLE:
#endif
return 8;
case D3DFMT_DXT1:
return 4;
case D3DFMT_DXT2:
case D3DFMT_DXT3:
case D3DFMT_DXT4:
case D3DFMT_DXT5:
return 8;
// From DX docs, reference/d3d/enums/d3dformat.asp
// (note how it says that D3DFMT_R8G8_B8G8 is "A 16-bit packed RGB format analogous to UYVY (U0Y0, V0Y1, U2Y2, and so on)")
case D3DFMT_UYVY:
return 16;
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/directxvideoaccelerationdxvavideosubtypes.asp
case MAKEFOURCC('A', 'I', '4', '4'):
case MAKEFOURCC('I', 'A', '4', '4'):
return 8;
case MAKEFOURCC('Y', 'V', '1', '2'):
return 12;
#if !defined(D3D_DISABLE_9EX)
#if !defined(D3D_DISABLE_9EX)
case D3DFMT_D32_LOCKABLE:
return 32;
case D3DFMT_S8_LOCKABLE:
return 8;
case D3DFMT_A1:
return 1;
#endif
#endif // !D3D_DISABLE_9EX
default:
return 0;
@ -404,7 +398,7 @@ namespace
_In_ size_t width,
_In_ size_t height,
_In_ D3DFORMAT fmt,
_Out_opt_ size_t* outNumBytes,
size_t* outNumBytes,
_Out_opt_ size_t* outRowBytes,
_Out_opt_ size_t* outNumRows) noexcept
{
@ -417,9 +411,6 @@ namespace
size_t bpe = 0;
switch (static_cast<int>(fmt))
{
case D3DFMT_UNKNOWN:
return E_INVALIDARG;
case D3DFMT_DXT1:
bc = true;
bpe = 8;
@ -469,7 +460,7 @@ namespace
}
else
{
const size_t bpp = BitsPerPixel(fmt);
size_t bpp = BitsPerPixel(fmt);
if (!bpp)
return E_INVALIDARG;
@ -478,13 +469,13 @@ namespace
numBytes = rowBytes * height;
}
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!");
if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX)
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
#else
#else
static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!");
#endif
#endif
if (outNumBytes)
{
@ -504,7 +495,7 @@ namespace
//--------------------------------------------------------------------------------------
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
D3DFORMAT GetD3D9Format(const DDS_PIXELFORMAT& ddpf) noexcept
{
@ -589,16 +580,6 @@ namespace
{
return D3DFMT_A8R3G3B2;
}
// NVTT versions 1.x wrote these as RGB instead of LUMINANCE
if (ISBITMASK(0xffff, 0, 0, 0))
{
return D3DFMT_L16;
}
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
{
return D3DFMT_A8L8;
}
break;
case 8:
@ -607,35 +588,14 @@ namespace
return D3DFMT_R3G3B2;
}
// NVTT versions 1.x wrote these as RGB instead of LUMINANCE
if (ISBITMASK(0xff, 0, 0, 0))
{
return D3DFMT_L8;
}
// Paletted texture formats are typically not supported on modern video cards aka D3DFMT_P8, D3DFMT_A8P8
break;
default:
return D3DFMT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_LUMINANCE)
{
switch (ddpf.RGBBitCount)
if (8 == ddpf.RGBBitCount)
{
case 16:
if (ISBITMASK(0xffff, 0, 0, 0))
{
return D3DFMT_L16;
}
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
{
return D3DFMT_A8L8;
}
break;
case 8:
if (ISBITMASK(0x0f, 0, 0, 0xf0))
{
return D3DFMT_A4L4;
@ -644,14 +604,19 @@ namespace
{
return D3DFMT_L8;
}
}
if (16 == ddpf.RGBBitCount)
{
if (ISBITMASK(0xffff, 0, 0, 0))
{
return D3DFMT_L16;
}
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
{
return D3DFMT_A8L8; // Some DDS writers assume the bitcount should be 8 instead of 16
return D3DFMT_A8L8;
}
break;
default:
return D3DFMT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_ALPHA)
@ -663,9 +628,16 @@ namespace
}
else if (ddpf.flags & DDS_BUMPDUDV)
{
switch (ddpf.RGBBitCount)
if (16 == ddpf.RGBBitCount)
{
if (ISBITMASK(0x00ff, 0xff00, 0, 0))
{
return D3DFMT_V8U8;
}
}
if (32 == ddpf.RGBBitCount)
{
case 32:
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))
{
return D3DFMT_Q8W8V8U8;
@ -678,39 +650,24 @@ namespace
{
return D3DFMT_A2W10V10U10;
}
break;
case 16:
if (ISBITMASK(0x00ff, 0xff00, 0, 0))
{
return D3DFMT_V8U8;
}
break;
default:
return D3DFMT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_BUMPLUMINANCE)
{
switch (ddpf.RGBBitCount)
if (16 == ddpf.RGBBitCount)
{
case 32:
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0))
{
return D3DFMT_X8L8V8U8;
}
break;
case 16:
if (ISBITMASK(0x001f, 0x03e0, 0xfc00, 0))
{
return D3DFMT_L6V5U5;
}
break;
}
default:
return D3DFMT_UNKNOWN;
if (32 == ddpf.RGBBitCount)
{
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0))
{
return D3DFMT_X8L8V8U8;
}
}
}
else if (ddpf.flags & DDS_FOURCC)
@ -767,26 +724,21 @@ namespace
case D3DFMT_A32B32G32R32F:
case D3DFMT_CxV8U8:
return static_cast<D3DFORMAT>(ddpf.fourCC);
default:
return D3DFMT_UNKNOWN;
}
}
return D3DFMT_UNKNOWN;
}
#undef ISBITMASK
#undef ISBITMASK
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
HRESULT CreateTextureFromDDS(
_In_ LPDIRECT3DDEVICE9 device,
_In_ const DDS_HEADER* header,
_In_reads_bytes_(bitSize) const uint8_t* bitData,
_In_ size_t bitSize,
_In_ DWORD usage,
_In_ D3DPOOL pool,
_Outptr_ LPDIRECT3DBASETEXTURE9* texture,
bool generateMipsIfMissing) noexcept
{
@ -810,7 +762,7 @@ namespace
// We could support a subset of 'DX10' extended header DDS files, but we'll assume here we are only
// supporting legacy DDS files for a Direct3D9 device
const D3DFORMAT fmt = GetD3D9Format(header->ddspf);
D3DFORMAT fmt = GetD3D9Format(header->ddspf);
if (fmt == D3DFMT_UNKNOWN || BitsPerPixel(fmt) == 0)
{
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
@ -830,22 +782,15 @@ namespace
// Create the volume texture (let the runtime do the validation)
ComPtr<IDirect3DVolumeTexture9> pTexture;
hr = device->CreateVolumeTexture(iWidth, iHeight, iDepth, iMipCount,
usage, fmt, pool, pTexture.GetAddressOf(), nullptr);
0, fmt, D3DPOOL_DEFAULT, pTexture.GetAddressOf(), nullptr);
if (FAILED(hr))
return hr;
ComPtr<IDirect3DVolumeTexture9> pStagingTexture;
if (pool == D3DPOOL_DEFAULT)
{
hr = device->CreateVolumeTexture(iWidth, iHeight, iDepth, iMipCount,
0u, fmt, D3DPOOL_SYSTEMMEM, pStagingTexture.GetAddressOf(), nullptr);
if (FAILED(hr))
return hr;
}
else
{
pStagingTexture = pTexture;
}
hr = device->CreateVolumeTexture(iWidth, iHeight, iDepth, iMipCount,
0, fmt, D3DPOOL_SYSTEMMEM, pStagingTexture.GetAddressOf(), nullptr);
if (FAILED(hr))
return hr;
// Lock, fill, unlock
size_t NumBytes = 0;
@ -902,12 +847,9 @@ namespace
iDepth = 1;
}
if (pool == D3DPOOL_DEFAULT)
{
hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get());
if (FAILED(hr))
return hr;
}
hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get());
if (FAILED(hr))
return hr;
*texture = pTexture.Detach();
}
@ -928,22 +870,15 @@ namespace
// Create the cubemap (let the runtime do the validation)
ComPtr<IDirect3DCubeTexture9> pTexture;
hr = device->CreateCubeTexture(iWidth, iMipCount,
usage, fmt, pool, pTexture.GetAddressOf(), nullptr);
0, fmt, D3DPOOL_DEFAULT, pTexture.GetAddressOf(), nullptr);
if (FAILED(hr))
return hr;
ComPtr<IDirect3DCubeTexture9> pStagingTexture;
if (pool == D3DPOOL_DEFAULT)
{
hr = device->CreateCubeTexture(iWidth, iMipCount,
0u, fmt, D3DPOOL_SYSTEMMEM, pStagingTexture.GetAddressOf(), nullptr);
if (FAILED(hr))
return hr;
}
else
{
pStagingTexture = pTexture;
}
hr = device->CreateCubeTexture(iWidth, iMipCount,
0, fmt, D3DPOOL_SYSTEMMEM, pStagingTexture.GetAddressOf(), nullptr);
if (FAILED(hr))
return hr;
// Lock, fill, unlock
size_t NumBytes = 0;
@ -997,12 +932,9 @@ namespace
}
}
if (pool == D3DPOOL_DEFAULT)
{
hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get());
if (FAILED(hr))
return hr;
}
hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get());
if (FAILED(hr))
return hr;
*texture = pTexture.Detach();
}
@ -1015,28 +947,19 @@ namespace
}
// Create the texture (let the runtime do the validation)
if (generateMipsIfMissing)
usage |= D3DUSAGE_AUTOGENMIPMAP;
ComPtr<IDirect3DTexture9> pTexture;
hr = device->CreateTexture(iWidth, iHeight, iMipCount,
usage, fmt, pool,
generateMipsIfMissing ? D3DUSAGE_AUTOGENMIPMAP : 0u,
fmt, D3DPOOL_DEFAULT,
pTexture.GetAddressOf(), nullptr);
if (FAILED(hr))
return hr;
ComPtr<IDirect3DTexture9> pStagingTexture;
if (pool == D3DPOOL_DEFAULT)
{
hr = device->CreateTexture(iWidth, iHeight, iMipCount,
0u, fmt, D3DPOOL_SYSTEMMEM, pStagingTexture.GetAddressOf(), nullptr);
if (FAILED(hr))
return hr;
}
else
{
pStagingTexture = pTexture;
}
hr = device->CreateTexture(iWidth, iHeight, iMipCount,
0u, fmt, D3DPOOL_SYSTEMMEM, pStagingTexture.GetAddressOf(), nullptr);
if (FAILED(hr))
return hr;
// Lock, fill, unlock
size_t NumBytes = 0;
@ -1081,12 +1004,9 @@ namespace
iHeight = 1;
}
if (pool == D3DPOOL_DEFAULT)
{
hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get());
if (FAILED(hr))
return hr;
}
hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get());
if (FAILED(hr))
return hr;
*texture = pTexture.Detach();
}
@ -1103,19 +1023,6 @@ HRESULT DirectX::CreateDDSTextureFromMemory(
size_t ddsDataSize,
LPDIRECT3DBASETEXTURE9* texture,
bool generateMipsIfMissing) noexcept
{
return CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, 0u, D3DPOOL_DEFAULT, generateMipsIfMissing, texture);
}
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromMemoryEx(
LPDIRECT3DDEVICE9 d3dDevice,
const uint8_t* ddsData,
size_t ddsDataSize,
_In_ DWORD usage,
_In_ D3DPOOL pool,
bool generateMipsIfMissing,
LPDIRECT3DBASETEXTURE9* texture) noexcept
{
if (texture)
{
@ -1145,13 +1052,11 @@ HRESULT DirectX::CreateDDSTextureFromMemoryEx(
header,
bitData,
bitSize,
usage,
pool,
texture,
generateMipsIfMissing);
}
// Type-specific standard versions
// Type-specific versions
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromMemory(
LPDIRECT3DDEVICE9 d3dDevice,
@ -1169,7 +1074,7 @@ HRESULT DirectX::CreateDDSTextureFromMemory(
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, 0u, D3DPOOL_DEFAULT, generateMipsIfMissing, tex.GetAddressOf());
HRESULT hr = CreateDDSTextureFromMemory(d3dDevice, ddsData, ddsDataSize, tex.GetAddressOf(), generateMipsIfMissing);
if (SUCCEEDED(hr))
{
hr = E_FAIL;
@ -1199,7 +1104,7 @@ HRESULT DirectX::CreateDDSTextureFromMemory(
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, 0u, D3DPOOL_DEFAULT, false, tex.GetAddressOf());
HRESULT hr = CreateDDSTextureFromMemory(d3dDevice, ddsData, ddsDataSize, tex.GetAddressOf(), false);
if (SUCCEEDED(hr))
{
hr = E_FAIL;
@ -1229,105 +1134,7 @@ HRESULT DirectX::CreateDDSTextureFromMemory(
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, 0u, D3DPOOL_DEFAULT, false, tex.GetAddressOf());
if (SUCCEEDED(hr))
{
hr = E_FAIL;
if (tex->GetType() == D3DRTYPE_VOLUMETEXTURE)
{
*texture = static_cast<LPDIRECT3DVOLUMETEXTURE9>(tex.Detach());
return S_OK;
}
}
return hr;
}
// Type-specific extended versions
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromMemoryEx(
LPDIRECT3DDEVICE9 d3dDevice,
const uint8_t* ddsData,
size_t ddsDataSize,
DWORD usage,
D3DPOOL pool,
bool generateMipsIfMissing,
LPDIRECT3DTEXTURE9* texture) noexcept
{
if (texture)
{
*texture = nullptr;
}
if (!d3dDevice || !ddsData || !ddsDataSize || !texture)
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, usage, pool, generateMipsIfMissing, tex.GetAddressOf());
if (SUCCEEDED(hr))
{
hr = E_FAIL;
if (tex->GetType() == D3DRTYPE_TEXTURE)
{
*texture = static_cast<LPDIRECT3DTEXTURE9>(tex.Detach());
return S_OK;
}
}
return hr;
}
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromMemoryEx(
LPDIRECT3DDEVICE9 d3dDevice,
const uint8_t* ddsData,
size_t ddsDataSize,
DWORD usage,
D3DPOOL pool,
LPDIRECT3DCUBETEXTURE9* texture) noexcept
{
if (texture)
{
*texture = nullptr;
}
if (!d3dDevice || !ddsData || !ddsDataSize || !texture)
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, usage, pool, false, tex.GetAddressOf());
if (SUCCEEDED(hr))
{
hr = E_FAIL;
if (tex->GetType() == D3DRTYPE_CUBETEXTURE)
{
*texture = static_cast<LPDIRECT3DCUBETEXTURE9>(tex.Detach());
return S_OK;
}
}
return hr;
}
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromMemoryEx(
LPDIRECT3DDEVICE9 d3dDevice,
const uint8_t* ddsData,
size_t ddsDataSize,
DWORD usage,
D3DPOOL pool,
LPDIRECT3DVOLUMETEXTURE9* texture) noexcept
{
if (texture)
{
*texture = nullptr;
}
if (!d3dDevice || !ddsData || !ddsDataSize || !texture)
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, usage, pool, false, tex.GetAddressOf());
HRESULT hr = CreateDDSTextureFromMemory(d3dDevice, ddsData, ddsDataSize, tex.GetAddressOf(), false);
if (SUCCEEDED(hr))
{
hr = E_FAIL;
@ -1349,18 +1156,6 @@ HRESULT DirectX::CreateDDSTextureFromFile(
const wchar_t* fileName,
LPDIRECT3DBASETEXTURE9* texture,
bool generateMipsIfMissing) noexcept
{
return CreateDDSTextureFromFileEx(d3dDevice, fileName, 0u, D3DPOOL_DEFAULT, generateMipsIfMissing, texture);
}
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromFileEx(
LPDIRECT3DDEVICE9 d3dDevice,
const wchar_t* fileName,
_In_ DWORD usage,
_In_ D3DPOOL pool,
bool generateMipsIfMissing,
LPDIRECT3DBASETEXTURE9* texture) noexcept
{
if (texture)
{
@ -1391,13 +1186,11 @@ HRESULT DirectX::CreateDDSTextureFromFileEx(
header,
bitData,
bitSize,
usage,
pool,
texture,
generateMipsIfMissing);
}
// Type-specific standard versions
// Type-specific versions
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromFile(
LPDIRECT3DDEVICE9 d3dDevice,
@ -1414,7 +1207,7 @@ HRESULT DirectX::CreateDDSTextureFromFile(
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, fileName, 0u, D3DPOOL_DEFAULT, generateMipsIfMissing, tex.GetAddressOf());
HRESULT hr = CreateDDSTextureFromFile(d3dDevice, fileName, tex.GetAddressOf(), generateMipsIfMissing);
if (SUCCEEDED(hr))
{
hr = E_FAIL;
@ -1443,7 +1236,7 @@ HRESULT DirectX::CreateDDSTextureFromFile(
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, fileName, 0u, D3DPOOL_DEFAULT, false, tex.GetAddressOf());
HRESULT hr = CreateDDSTextureFromFile(d3dDevice, fileName, tex.GetAddressOf(), false);
if (SUCCEEDED(hr))
{
hr = E_FAIL;
@ -1472,102 +1265,7 @@ HRESULT DirectX::CreateDDSTextureFromFile(
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, szFileName, 0u, D3DPOOL_DEFAULT, false, tex.GetAddressOf());
if (SUCCEEDED(hr))
{
hr = E_FAIL;
if (tex->GetType() == D3DRTYPE_VOLUMETEXTURE)
{
*texture = static_cast<LPDIRECT3DVOLUMETEXTURE9>(tex.Detach());
return S_OK;
}
}
return hr;
}
// Type-specific extended versions
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromFileEx(
LPDIRECT3DDEVICE9 d3dDevice,
const wchar_t* fileName,
DWORD usage,
D3DPOOL pool,
bool generateMipsIfMissing,
LPDIRECT3DTEXTURE9* texture) noexcept
{
if (texture)
{
*texture = nullptr;
}
if (!d3dDevice || !fileName || !texture)
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, fileName, usage, pool, generateMipsIfMissing, tex.GetAddressOf());
if (SUCCEEDED(hr))
{
hr = E_FAIL;
if (tex->GetType() == D3DRTYPE_TEXTURE)
{
*texture = static_cast<LPDIRECT3DTEXTURE9>(tex.Detach());
return S_OK;
}
}
return hr;
}
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromFileEx(
LPDIRECT3DDEVICE9 d3dDevice,
const wchar_t* fileName,
DWORD usage,
D3DPOOL pool,
LPDIRECT3DCUBETEXTURE9* texture) noexcept
{
if (texture)
{
*texture = nullptr;
}
if (!d3dDevice || !fileName || !texture)
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, fileName, usage, pool, false, tex.GetAddressOf());
if (SUCCEEDED(hr))
{
hr = E_FAIL;
if (tex->GetType() == D3DRTYPE_CUBETEXTURE)
{
*texture = static_cast<LPDIRECT3DCUBETEXTURE9>(tex.Detach());
return S_OK;
}
}
return hr;
}
_Use_decl_annotations_
HRESULT DirectX::CreateDDSTextureFromFileEx(
LPDIRECT3DDEVICE9 d3dDevice,
const wchar_t* szFileName,
DWORD usage,
D3DPOOL pool,
LPDIRECT3DVOLUMETEXTURE9* texture) noexcept
{
if (texture)
{
*texture = nullptr;
}
if (!d3dDevice || !szFileName || !texture)
return E_INVALIDARG;
ComPtr<IDirect3DBaseTexture9> tex;
HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, szFileName, usage, pool, false, tex.GetAddressOf());
HRESULT hr = CreateDDSTextureFromFile(d3dDevice, szFileName, tex.GetAddressOf(), false);
if (SUCCEEDED(hr))
{
hr = E_FAIL;

View File

@ -7,7 +7,7 @@
// a full-featured DDS file reader, writer, and texture processing pipeline see
// the 'Texconv' sample and the 'DirectXTex' library.
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
@ -21,7 +21,6 @@
#include <d3d9.h>
#include <cstddef>
#include <cstdint>
@ -41,25 +40,7 @@ namespace DirectX
_Outptr_ LPDIRECT3DBASETEXTURE9* texture,
bool generateMipsIfMissing = false) noexcept;
// Extended version
HRESULT CreateDDSTextureFromMemoryEx(
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
_In_ size_t ddsDataSize,
_In_ DWORD usage,
_In_ D3DPOOL pool,
bool generateMipsIfMissing,
_Outptr_ LPDIRECT3DBASETEXTURE9* texture) noexcept;
HRESULT CreateDDSTextureFromFileEx(
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_z_ const wchar_t* fileName,
_In_ DWORD usage,
_In_ D3DPOOL pool,
bool generateMipsIfMissing,
_Outptr_ LPDIRECT3DBASETEXTURE9* texture) noexcept;
// Type-specific standard versions
// Type-specific versions
HRESULT CreateDDSTextureFromMemory(
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
@ -94,52 +75,4 @@ namespace DirectX
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_z_ const wchar_t* fileName,
_Outptr_ LPDIRECT3DVOLUMETEXTURE9* texture) noexcept;
// Type-specific extended versions
HRESULT CreateDDSTextureFromMemoryEx(
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
_In_ size_t ddsDataSize,
_In_ DWORD usage,
_In_ D3DPOOL pool,
bool generateMipsIfMissing,
_Outptr_ LPDIRECT3DTEXTURE9* texture) noexcept;
HRESULT CreateDDSTextureFromFileEx(
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_z_ const wchar_t* fileName,
_In_ DWORD usage,
_In_ D3DPOOL pool,
bool generateMipsIfMissing,
_Outptr_ LPDIRECT3DTEXTURE9* texture) noexcept;
HRESULT CreateDDSTextureFromMemoryEx(
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
_In_ size_t ddsDataSize,
_In_ DWORD usage,
_In_ D3DPOOL pool,
_Outptr_ LPDIRECT3DCUBETEXTURE9* texture) noexcept;
HRESULT CreateDDSTextureFromFileEx(
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_z_ const wchar_t* fileName,
_In_ DWORD usage,
_In_ D3DPOOL pool,
_Outptr_ LPDIRECT3DCUBETEXTURE9* texture) noexcept;
HRESULT CreateDDSTextureFromMemoryEx(
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
_In_ size_t ddsDataSize,
_In_ DWORD usage,
_In_ D3DPOOL pool,
_Outptr_ LPDIRECT3DVOLUMETEXTURE9* texture) noexcept;
HRESULT CreateDDSTextureFromFileEx(
_In_ LPDIRECT3DDEVICE9 d3dDevice,
_In_z_ const wchar_t* fileName,
_In_ DWORD usage,
_In_ D3DPOOL pool,
_Outptr_ LPDIRECT3DVOLUMETEXTURE9* texture) noexcept;
}

View File

@ -28,7 +28,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_MAIN_ICON ICON "..\\Common\\directx.ico"
IDI_MAIN_ICON ICON "directx.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -31,44 +31,42 @@
<ProjectGuid>{9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}</ProjectGuid>
<RootNamespace>DDSView</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|X64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|X64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|X64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
@ -92,38 +90,38 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</IntDir>
<OutDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DDSView</TargetName>
<GenerateManifest>true</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|X64'">
<OutDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</IntDir>
<OutDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DDSView</TargetName>
<GenerateManifest>true</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</IntDir>
<OutDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DDSView</TargetName>
<GenerateManifest>true</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|X64'">
<OutDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</IntDir>
<OutDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DDSView</TargetName>
<GenerateManifest>true</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
<OutDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</IntDir>
<OutDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DDSView</TargetName>
<GenerateManifest>true</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|X64'">
<OutDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2022\$(Platform)\$(Configuration)\</IntDir>
<OutDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2017\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DDSView</TargetName>
<GenerateManifest>true</GenerateManifest>
</PropertyGroup>
@ -134,23 +132,30 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LargeAddressAware>true</LargeAddressAware>
<CETCompat>true</CETCompat>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|X64'">
<ClCompile>
@ -158,22 +163,29 @@
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<CETCompat>true</CETCompat>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
@ -181,13 +193,12 @@
<Optimization>MaxSpeed</Optimization>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -196,24 +207,30 @@
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LargeAddressAware>true</LargeAddressAware>
<CETCompat>true</CETCompat>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|X64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -221,11 +238,18 @@
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<CETCompat>true</CETCompat>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
<ClCompile>
@ -233,13 +257,12 @@
<Optimization>MaxSpeed</Optimization>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -248,24 +271,30 @@
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LargeAddressAware>true</LargeAddressAware>
<CETCompat>true</CETCompat>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|X64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -273,11 +302,18 @@
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<CETCompat>true</CETCompat>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="DDSView.cpp" />
@ -286,33 +322,13 @@
<ResourceCompile Include="DDSView.rc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DirectXTex\DirectXTex_Desktop_2022.vcxproj">
<ProjectReference Include="..\DirectXTex\DirectXTex_Desktop_2017.vcxproj">
<Project>{371b9fa9-4c90-4ac6-a123-aced756d6c77}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="ddsview.hlsl" />
<None Include="ddsview.fx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
<Target Name="ATGEnsureShaders" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0])</_ATGFXCPath>
<_ATGFXCPath>$(_ATGFXCPath.Replace("x64",""))</_ATGFXCPath>
<_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\</_ATGFXCPath>
<_ATGFXCVer>$([System.Text.RegularExpressions.Regex]::Match($(_ATGFXCPath), `10\.0\.\d+\.0`))</_ATGFXCVer>
<_ATGFXCVer Condition="'$(_ATGFXCVer)' != '' and !HasTrailingSlash('$(_ATGFXCVer)')">$(_ATGFXCVer)\</_ATGFXCVer>
</PropertyGroup>
<Exec Condition="!Exists('Shaders/ddsview_vs.inc')" WorkingDirectory="$(ProjectDir)" Command="hlsl" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath);WindowsSDKVersion=$(_ATGFXCVer);CompileShadersOutput=$(ProjectDir)\Shaders" LogStandardErrorAsError="true" />
<PropertyGroup>
<_ATGFXCPath />
<_ATGFXCVer />
</PropertyGroup>
</Target>
<Target Name="ATGDeleteShaders" AfterTargets="Clean">
<ItemGroup>
<_ATGShaderHeaders Include="$(ProjectDir)Shaders/*.inc" />
</ItemGroup>
<Delete Files="@(_ATGShaderHeaders)" />
</Target>
</Project>

View File

@ -15,6 +15,6 @@
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="ddsview.hlsl" />
<None Include="ddsview.fx" />
</ItemGroup>
</Project>

View File

@ -36,13 +36,11 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|X64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
@ -134,11 +132,12 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
@ -146,11 +145,18 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LargeAddressAware>true</LargeAddressAware>
<AdditionalOptions>/CETCOMPAT %(AdditionalOptions)</AdditionalOptions>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|X64'">
<ClCompile>
@ -158,22 +164,30 @@
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalOptions>/CETCOMPAT %(AdditionalOptions)</AdditionalOptions>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
@ -181,12 +195,12 @@
<Optimization>MaxSpeed</Optimization>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
@ -196,23 +210,30 @@
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LargeAddressAware>true</LargeAddressAware>
<AdditionalOptions>/CETCOMPAT %(AdditionalOptions)</AdditionalOptions>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|X64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
@ -221,11 +242,18 @@
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<AdditionalOptions>/CETCOMPAT %(AdditionalOptions)</AdditionalOptions>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
<ClCompile>
@ -233,12 +261,12 @@
<Optimization>MaxSpeed</Optimization>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
@ -248,23 +276,30 @@
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LargeAddressAware>true</LargeAddressAware>
<AdditionalOptions>/CETCOMPAT %(AdditionalOptions)</AdditionalOptions>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|X64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalIncludeDirectories>..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\DirectXTex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ControlFlowGuard>Guard</ControlFlowGuard>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
</ClCompile>
<Link>
@ -273,11 +308,18 @@
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<AdditionalOptions>/CETCOMPAT %(AdditionalOptions)</AdditionalOptions>
</Link>
<Manifest>
<EnableDPIAwareness>false</EnableDPIAwareness>
</Manifest>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="DDSView.cpp" />
@ -291,28 +333,8 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="ddsview.hlsl" />
<None Include="ddsview.fx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
<Target Name="ATGEnsureShaders" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0])</_ATGFXCPath>
<_ATGFXCPath>$(_ATGFXCPath.Replace("x64",""))</_ATGFXCPath>
<_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\</_ATGFXCPath>
<_ATGFXCVer>$([System.Text.RegularExpressions.Regex]::Match($(_ATGFXCPath), `10\.0\.\d+\.0`))</_ATGFXCVer>
<_ATGFXCVer Condition="'$(_ATGFXCVer)' != '' and !HasTrailingSlash('$(_ATGFXCVer)')">$(_ATGFXCVer)\</_ATGFXCVer>
</PropertyGroup>
<Exec Condition="!Exists('Shaders/ddsview_vs.inc')" WorkingDirectory="$(ProjectDir)" Command="hlsl" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath);WindowsSDKVersion=$(_ATGFXCVer);CompileShadersOutput=$(ProjectDir)\Shaders" LogStandardErrorAsError="true" />
<PropertyGroup>
<_ATGFXCPath />
<_ATGFXCVer />
</PropertyGroup>
</Target>
<Target Name="ATGDeleteShaders" AfterTargets="Clean">
<ItemGroup>
<_ATGShaderHeaders Include="$(ProjectDir)Shaders/*.inc" />
</ItemGroup>
<Delete Files="@(_ATGShaderHeaders)" />
</Target>
</Project>

View File

@ -15,6 +15,6 @@
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="ddsview.hlsl" />
<None Include="ddsview.fx" />
</ItemGroup>
</Project>

View File

@ -1,38 +1,29 @@
//--------------------------------------------------------------------------------------
// File: DDSView.cpp
//
// DirectX 11 DDS File Viewer sample for DirectXTex
// DirectX 11 DDS File Viewer
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#include <windows.h>
#include <assert.h>
#include <stdio.h>
#include <dxgiformat.h>
#include <d3d11.h>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cwchar>
#include <iterator>
#include <tuple>
#include <dxgiformat.h>
#include <d3d11_1.h>
#include <directxmath.h>
#include <DirectXMath.h>
#ifdef _MSC_VER
#pragma warning(disable : 4619 4616 26812)
#endif
#include "DirectXTex.h"
#include <shellapi.h>
using namespace DirectX;
//--------------------------------------------------------------------------------------
@ -55,229 +46,174 @@ struct CBArrayControl
//--------------------------------------------------------------------------------------
namespace
{
#include "ddsview_vs.inc"
#include "ddsview_ps1D.inc"
#include "ddsview_ps1Darray.inc"
#include "ddsview_ps2D.inc"
#include "ddsview_ps2Darray.inc"
#include "ddsview_ps3D.inc"
#include "ddsview_psCube.inc"
}
// fxc ddsview.fx /nologo /EVS /Tvs_4_1 /Fhshaders\vs.h
#include "shaders\vs.h"
// fxc ddsview.fx /nologo /EPS_1D /Tps_4_1 /Fhshaders\ps1D.h
#include "shaders\ps1D.h"
// fxc ddsview.fx /nologo /EPS_1DArray /Tps_4_1 /Fhshaders\ps1Darray.h
#include "shaders\\ps1Darray.h"
// fxc ddsview.fx /nologo /EPS_2D /Tps_4_1 /Fhshaders\ps2D.h
#include "shaders\\ps2D.h"
// fxc ddsview.fx /nologo /EPS_2DArray /Tps_4_1 /Fhshaders\ps2Darray.h
#include "shaders\ps2Darray.h"
// fxc ddsview.fx /nologo /EPS_3D /Tps_4_1 /Fhshaders\ps3D.h
#include "shaders\ps3D.h"
// fxc ddsview.fx /nologo /EPS_Cube /Tps_4_1 /Fhshaders\psCube.h
#include "shaders\psCube.h"
//--------------------------------------------------------------------------------------
namespace
{
HINSTANCE g_hInst = nullptr;
HWND g_hWnd = nullptr;
D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL;
D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0;
ID3D11Device* g_pd3dDevice = nullptr;
ID3D11DeviceContext* g_pImmediateContext = nullptr;
IDXGISwapChain* g_pSwapChain = nullptr;
ID3D11RenderTargetView* g_pRenderTargetView = nullptr;
ID3D11Texture2D* g_pDepthStencil = nullptr;
ID3D11DepthStencilView* g_pDepthStencilView = nullptr;
ID3D11VertexShader* g_pVertexShader = nullptr;
ID3D11PixelShader* g_pPixelShader = nullptr;
ID3D11InputLayout* g_pVertexLayout = nullptr;
ID3D11Buffer* g_pVertexBuffer = nullptr;
ID3D11Buffer* g_pIndexBuffer = nullptr;
ID3D11Buffer* g_pCBArrayControl = nullptr;
ID3D11ShaderResourceView* g_pSRV = nullptr;
ID3D11BlendState* g_AlphaBlendState = nullptr;
ID3D11SamplerState* g_pSamplerLinear = nullptr;
HINSTANCE g_hInst = nullptr;
HWND g_hWnd = nullptr;
D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL;
D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0;
ID3D11Device* g_pd3dDevice = nullptr;
ID3D11DeviceContext* g_pImmediateContext = nullptr;
IDXGISwapChain* g_pSwapChain = nullptr;
ID3D11RenderTargetView* g_pRenderTargetView = nullptr;
ID3D11Texture2D* g_pDepthStencil = nullptr;
ID3D11DepthStencilView* g_pDepthStencilView = nullptr;
ID3D11VertexShader* g_pVertexShader = nullptr;
ID3D11PixelShader* g_pPixelShader = nullptr;
ID3D11InputLayout* g_pVertexLayout = nullptr;
ID3D11Buffer* g_pVertexBuffer = nullptr;
ID3D11Buffer* g_pIndexBuffer = nullptr;
ID3D11Buffer* g_pCBArrayControl = nullptr;
ID3D11ShaderResourceView* g_pSRV = nullptr;
ID3D11BlendState* g_AlphaBlendState = nullptr;
ID3D11SamplerState* g_pSamplerLinear = nullptr;
UINT g_iCurrentIndex = 0;
UINT g_iMaxIndex = 1;
UINT g_iCurrentIndex = 0;
UINT g_iMaxIndex = 1;
UINT g_iIndices = 0;
UINT g_iIndices = 0;
LPCWSTR g_szAppName = L"DDSView";
}
//--------------------------------------------------------------------------------------
HRESULT InitWindow(HINSTANCE hInstance, int nCmdShow, const TexMetadata& mdata);
HRESULT InitDevice(const TexMetadata& mdata);
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow, const TexMetadata& mdata );
HRESULT InitDevice( const TexMetadata& mdata );
void CleanupDevice();
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
void Render();
//--------------------------------------------------------------------------------------
#ifdef _MSC_VER
#pragma warning( suppress : 6262 )
#endif
int WINAPI wWinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE /*hPrevInstance*/,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow )
{
static const wchar_t* c_usage = L"Usage: ddsview [-forcesrgb] <filename>";
UNREFERENCED_PARAMETER( hPrevInstance );
UNREFERENCED_PARAMETER( lpCmdLine );
if (!*lpCmdLine)
if ( !*lpCmdLine )
{
MessageBoxW(nullptr, c_usage, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
MessageBoxW( nullptr, L"Usage: ddsview <filename>", L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0;
}
int argc = 0;
auto argList = CommandLineToArgvW(lpCmdLine, &argc);
const wchar_t* filename = nullptr;
bool forceSRGB = false;
for(int i = 0; i < argc; ++i)
{
if (*argList[i] == '-' || *argList[i] == '/')
{
if (_wcsicmp(argList[i]+1, L"forcesrgb") == 0)
{
forceSRGB = true;
}
}
else if (!filename)
{
filename = argList[i];
}
}
if (!filename)
{
MessageBoxW(nullptr, c_usage, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
return 1;
}
TexMetadata mdata;
HRESULT hr = GetMetadataFromDDSFile(filename, DDS_FLAGS_NONE, mdata);
if (FAILED(hr))
HRESULT hr = GetMetadataFromDDSFile( lpCmdLine, DDS_FLAGS_NONE, mdata );
if ( FAILED(hr) )
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"Failed to open texture file\n\nFilename = %ls\nHRESULT %08X", filename, static_cast<unsigned int>(hr));
MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
return 1;
swprintf_s( buff, L"Failed to open texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, static_cast<unsigned int>(hr) );
MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0;
}
if (FAILED(InitWindow(hInstance, nCmdShow, mdata)))
return 1;
if( FAILED( InitWindow( hInstance, nCmdShow, mdata ) ) )
return 0;
SetWindowTextW(g_hWnd, filename);
SetWindowTextW( g_hWnd, lpCmdLine );
if (FAILED(InitDevice(mdata)))
if( FAILED( InitDevice( mdata ) ) )
{
CleanupDevice();
return 1;
return 0;
}
if (mdata.dimension == TEX_DIMENSION_TEXTURE3D)
{
if (mdata.arraySize > 1)
if ( mdata.arraySize > 1 )
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"Arrays of volume textures are not supported\n\nFilename = %ls\nArray size %zu", filename, mdata.arraySize);
MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
return 1;
swprintf_s( buff, L"Arrays of volume textures are not supported\n\nFilename = %ls\nArray size %zu", lpCmdLine, mdata.arraySize );
MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0;
}
g_iMaxIndex = static_cast<UINT>(mdata.depth);
g_iMaxIndex = static_cast<UINT>( mdata.depth );
}
else if (mdata.arraySize > 1)
else
{
if (g_featureLevel < D3D_FEATURE_LEVEL_10_0)
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"Texture arrays require DirectX 10 hardware or later\n\nFilename = %ls\nArray size %zu", filename, mdata.arraySize);
MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
return 1;
}
g_iMaxIndex = static_cast<UINT>(mdata.arraySize);
g_iMaxIndex = static_cast<UINT>( mdata.arraySize );
}
switch (mdata.format)
switch( mdata.format )
{
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_SNORM:
case DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT_BC5_UNORM:
if (g_featureLevel < D3D_FEATURE_LEVEL_10_0)
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"BC4/BC5 requires DirectX 10 hardware or later\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d", filename, mdata.format, g_featureLevel);
MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
return 1;
}
break;
case DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT_BC7_TYPELESS:
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
if (g_featureLevel < D3D_FEATURE_LEVEL_11_0)
if ( g_featureLevel < D3D_FEATURE_LEVEL_11_0 )
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"BC6H/BC7 requires DirectX 11 hardware or later\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d", filename, mdata.format, g_featureLevel);
MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
return 1;
swprintf_s( buff, L"BC6H/BC7 requires DirectX 11 hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d", lpCmdLine, mdata.format, g_featureLevel );
MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0;
}
break;
default:
{
UINT flags = 0;
hr = g_pd3dDevice->CheckFormatSupport(mdata.format, &flags);
constexpr UINT required = D3D11_FORMAT_SUPPORT_TEXTURE1D | D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURE3D;
if (FAILED(hr) || !(flags & required))
hr = g_pd3dDevice->CheckFormatSupport ( mdata.format, &flags );
if ( FAILED(hr) || !(flags & (D3D11_FORMAT_SUPPORT_TEXTURE1D|D3D11_FORMAT_SUPPORT_TEXTURE2D|D3D11_FORMAT_SUPPORT_TEXTURE3D)) )
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"Format not supported by this DirectX hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d\nHRESULT = %08X", filename, mdata.format, g_featureLevel, static_cast<unsigned int>(hr));
MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
return 1;
swprintf_s( buff, L"Format not supported by DirectX hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d\nHRESULT = %08X", lpCmdLine, mdata.format, g_featureLevel, static_cast<unsigned int>(hr) );
MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0;
}
}
break;
}
ScratchImage image;
hr = LoadFromDDSFile(filename, DDS_FLAGS_NONE, &mdata, image);
if (FAILED(hr))
hr = LoadFromDDSFile( lpCmdLine, DDS_FLAGS_NONE, &mdata, image );
if ( FAILED(hr) )
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"Failed to load texture file\n\nFilename = %ls\nHRESULT %08X", filename, static_cast<unsigned int>(hr));
MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
return 1;
swprintf_s( buff, L"Failed to load texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, static_cast<unsigned int>(hr) );
MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0;
}
// Special case to make sure Texture cubes remain arrays
mdata.miscFlags &= ~TEX_MISC_TEXTURECUBE;
if (forceSRGB)
{
mdata.format = MakeSRGB(mdata.format);
image.OverrideFormat(mdata.format);
}
hr = CreateShaderResourceView(g_pd3dDevice, image.GetImages(), image.GetImageCount(), mdata, &g_pSRV);
if (FAILED(hr))
hr = CreateShaderResourceView( g_pd3dDevice, image.GetImages(), image.GetImageCount(), mdata, &g_pSRV );
if ( FAILED(hr) )
{
wchar_t buff[2048] = {};
swprintf_s(buff, L"Failed creating texture from file\n\nFilename = %ls\nHRESULT = %08X", filename, static_cast<unsigned int>(hr));
MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION);
return 1;
swprintf_s( buff, L"Failed creating texture from file\n\nFilename = %ls\nHRESULT = %08X", lpCmdLine, static_cast<unsigned int>(hr) );
MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0;
}
// Main message loop
MSG msg = {};
while (WM_QUIT != msg.message)
while( WM_QUIT != msg.message )
{
if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
@ -287,103 +223,103 @@ int WINAPI wWinMain(
CleanupDevice();
return static_cast<int>(msg.wParam);
return ( int )msg.wParam;
}
//--------------------------------------------------------------------------------------
HRESULT InitWindow(
HINSTANCE hInstance,
int nCmdShow,
const TexMetadata& mdata)
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow, const TexMetadata& mdata )
{
// Register class
WNDCLASSEXW wcex = {};
wcex.cbSize = sizeof(WNDCLASSEXW);
WNDCLASSEXW wcex;
wcex.cbSize = sizeof( WNDCLASSEXW );
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIconW(hInstance, reinterpret_cast<LPCWSTR>(IDI_MAIN_ICON));
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
wcex.hIcon = LoadIcon( hInstance, ( LPCTSTR )IDI_MAIN_ICON );
wcex.hCursor = LoadCursor( nullptr, IDC_ARROW );
wcex.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 );
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = L"DDSViewWindowClass";
wcex.hIconSm = LoadIconW(wcex.hInstance, reinterpret_cast<LPCWSTR>(IDI_MAIN_ICON));
if (!RegisterClassExW(&wcex))
wcex.hIconSm = LoadIcon( wcex.hInstance, ( LPCTSTR )IDI_MAIN_ICON );
if( !RegisterClassExW( &wcex ) )
return E_FAIL;
// Create window
g_hInst = hInstance;
RECT rc = { 0, 0, 640, 480 };
int cxborder = GetSystemMetrics(SM_CXBORDER);
int cxedge = GetSystemMetrics(SM_CXEDGE);
int screenX = GetSystemMetrics(SM_CXSCREEN) - std::max(cxborder, cxedge);
if (rc.right < static_cast<LONG>(mdata.width))
rc.right = static_cast<LONG>(mdata.width);
if (rc.right > screenX)
int cxborder = GetSystemMetrics( SM_CXBORDER );
int cxedge = GetSystemMetrics( SM_CXEDGE );
int screenX = GetSystemMetrics( SM_CXSCREEN ) - std::max( cxborder, cxedge );
if( rc.right < (LONG)mdata.width )
rc.right = (LONG)mdata.width;
if ( rc.right > screenX )
rc.right = screenX;
int cyborder = GetSystemMetrics(SM_CYBORDER);
int cyedge = GetSystemMetrics(SM_CYEDGE);
int screenY = GetSystemMetrics(SM_CYSCREEN) - std::max(cyborder, cyedge);
if (rc.bottom < static_cast<LONG>(mdata.height))
rc.bottom = static_cast<LONG>(mdata.height);
if (rc.bottom > screenY)
int cyborder = GetSystemMetrics( SM_CYBORDER );
int cyedge = GetSystemMetrics( SM_CYEDGE );
int screenY = GetSystemMetrics( SM_CYSCREEN ) - std::max( cyborder, cyedge );
if ( rc.bottom < (LONG)mdata.height )
rc.bottom = (LONG)mdata.height;
if ( rc.bottom > screenY )
rc.bottom = screenY;
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
g_hWnd = CreateWindowW(L"DDSViewWindowClass", g_szAppName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance,
nullptr);
if (!g_hWnd)
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
g_hWnd = CreateWindowW( L"DDSViewWindowClass", L"DDS View", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance,
nullptr );
if( !g_hWnd )
return E_FAIL;
ShowWindow(g_hWnd, nCmdShow);
ShowWindow( g_hWnd, nCmdShow );
return S_OK;
}
//--------------------------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch (message)
PAINTSTRUCT ps;
HDC hdc;
switch( message )
{
case WM_PAINT:
{
PAINTSTRUCT ps;
std::ignore = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
}
break;
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
case WM_KEYDOWN:
if (wParam == VK_RIGHT)
{
if (g_iCurrentIndex < g_iMaxIndex - 1)
++g_iCurrentIndex;
}
else if (wParam == VK_LEFT)
{
if (g_iCurrentIndex > 0)
case WM_KEYDOWN:
if ( wParam == VK_RIGHT )
{
--g_iCurrentIndex;
if ( g_iCurrentIndex < g_iMaxIndex-1 )
++g_iCurrentIndex;
}
}
else if (wParam >= '0' && wParam <= '9')
{
UINT index = (wParam == '0') ? 10u : static_cast<UINT>(wParam - '1');
if (index < g_iMaxIndex)
g_iCurrentIndex = index;
}
InvalidateRect(hWnd, nullptr, FALSE);
break;
else if ( wParam == VK_LEFT )
{
if ( g_iCurrentIndex > 0 )
{
--g_iCurrentIndex;
}
}
else if ( wParam >= '0' && wParam <= '9' )
{
UINT index = (wParam == '0') ? 10 : ((UINT) (wParam - '1'));
if ( index < g_iMaxIndex )
g_iCurrentIndex = index;
}
InvalidateRect( hWnd, nullptr, FALSE );
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
return 0;
@ -391,14 +327,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
//--------------------------------------------------------------------------------------
HRESULT InitDevice(const TexMetadata& mdata)
HRESULT InitDevice( const TexMetadata& mdata )
{
HRESULT hr = S_OK;
RECT rc;
GetClientRect(g_hWnd, &rc);
auto width = static_cast<UINT>(rc.right - rc.left);
auto height = static_cast<UINT>(rc.bottom - rc.top);
GetClientRect( g_hWnd, &rc );
UINT width = rc.right - rc.left;
UINT height = rc.bottom - rc.top;
UINT createDeviceFlags = 0;
#if defined( DEBUG ) || defined( _DEBUG )
@ -411,7 +347,7 @@ HRESULT InitDevice(const TexMetadata& mdata)
D3D_DRIVER_TYPE_WARP,
D3D_DRIVER_TYPE_REFERENCE,
};
constexpr UINT numDriverTypes = static_cast<UINT>(std::size(driverTypes));
UINT numDriverTypes = ARRAYSIZE( driverTypes );
D3D_FEATURE_LEVEL featureLevels[] =
{
@ -419,7 +355,7 @@ HRESULT InitDevice(const TexMetadata& mdata)
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
};
constexpr UINT numFeatureLevels = static_cast<UINT>(std::size(featureLevels));
UINT numFeatureLevels = ARRAYSIZE( featureLevels );
DXGI_SWAP_CHAIN_DESC sd = {};
sd.BufferCount = 1;
@ -431,35 +367,32 @@ HRESULT InitDevice(const TexMetadata& mdata)
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = g_hWnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++)
for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ )
{
g_driverType = driverTypes[driverTypeIndex];
// See https://walbourn.github.io/anatomy-of-direct3d-11-create-device/
hr = D3D11CreateDeviceAndSwapChain(nullptr, g_driverType, nullptr,
createDeviceFlags, featureLevels, numFeatureLevels,
D3D11_SDK_VERSION, &sd,
&g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext);
if (SUCCEEDED(hr))
hr = D3D11CreateDeviceAndSwapChain( nullptr, g_driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels,
D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext );
if( SUCCEEDED( hr ) )
break;
}
if (FAILED(hr))
if( FAILED( hr ) )
return hr;
// Create a render target view
ID3D11Texture2D* pBackBuffer = nullptr;
hr = g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
if (FAILED(hr))
hr = g_pSwapChain->GetBuffer( 0, IID_PPV_ARGS(&pBackBuffer) );
if( FAILED( hr ) )
return hr;
D3D11_RENDER_TARGET_VIEW_DESC vd = {};
vd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
vd.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, &vd, &g_pRenderTargetView);
hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, &vd, &g_pRenderTargetView );
pBackBuffer->Release();
if (FAILED(hr))
if( FAILED( hr ) )
return hr;
// Create depth stencil texture
@ -470,10 +403,13 @@ HRESULT InitDevice(const TexMetadata& mdata)
descDepth.ArraySize = 1;
descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
descDepth.SampleDesc.Count = 1;
descDepth.SampleDesc.Quality = 0;
descDepth.Usage = D3D11_USAGE_DEFAULT;
descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL;
hr = g_pd3dDevice->CreateTexture2D(&descDepth, nullptr, &g_pDepthStencil);
if (FAILED(hr))
descDepth.CPUAccessFlags = 0;
descDepth.MiscFlags = 0;
hr = g_pd3dDevice->CreateTexture2D( &descDepth, nullptr, &g_pDepthStencil );
if( FAILED( hr ) )
return hr;
// Create the depth stencil view
@ -481,19 +417,25 @@ HRESULT InitDevice(const TexMetadata& mdata)
descDSV.Format = descDepth.Format;
descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
descDSV.Texture2D.MipSlice = 0;
hr = g_pd3dDevice->CreateDepthStencilView(g_pDepthStencil, &descDSV, &g_pDepthStencilView);
if (FAILED(hr))
hr = g_pd3dDevice->CreateDepthStencilView( g_pDepthStencil, &descDSV, &g_pDepthStencilView );
if( FAILED( hr ) )
return hr;
g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetView, g_pDepthStencilView);
g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, g_pDepthStencilView );
// Setup the viewport
const D3D11_VIEWPORT vp = { 0.f, 0.f, static_cast<float>(width), static_cast<float>(height), 0.f, 1.f };
g_pImmediateContext->RSSetViewports(1, &vp);
D3D11_VIEWPORT vp;
vp.Width = (FLOAT)width;
vp.Height = (FLOAT)height;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
vp.TopLeftX = 0;
vp.TopLeftY = 0;
g_pImmediateContext->RSSetViewports( 1, &vp );
// Create the vertex shader
hr = g_pd3dDevice->CreateVertexShader(g_VS, sizeof(g_VS), nullptr, &g_pVertexShader);
if (FAILED(hr))
hr = g_pd3dDevice->CreateVertexShader( g_VS, sizeof(g_VS), nullptr, &g_pVertexShader );
if( FAILED( hr ) )
return hr;
// Define the input layout
@ -502,15 +444,15 @@ HRESULT InitDevice(const TexMetadata& mdata)
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, sizeof(XMFLOAT4), D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
constexpr UINT numElements = static_cast<UINT>(std::size(layout));
UINT numElements = ARRAYSIZE( layout );
// Create the input layout
hr = g_pd3dDevice->CreateInputLayout(layout, numElements, g_VS, sizeof(g_VS), &g_pVertexLayout);
if (FAILED(hr))
hr = g_pd3dDevice->CreateInputLayout( layout, numElements, g_VS, sizeof(g_VS), &g_pVertexLayout );
if( FAILED( hr ) )
return hr;
// Set the input layout
g_pImmediateContext->IASetInputLayout(g_pVertexLayout);
g_pImmediateContext->IASetInputLayout( g_pVertexLayout );
// Select the pixel shader
bool isCubeMap = false;
@ -518,10 +460,10 @@ HRESULT InitDevice(const TexMetadata& mdata)
const BYTE* pshader = nullptr;
size_t pshader_size = 0;
switch (mdata.dimension)
switch ( mdata.dimension )
{
case TEX_DIMENSION_TEXTURE1D:
if (mdata.arraySize > 1)
if ( mdata.arraySize > 1)
{
pshader = g_PS_1DArray;
pshader_size = sizeof(g_PS_1DArray);
@ -535,13 +477,13 @@ HRESULT InitDevice(const TexMetadata& mdata)
break;
case TEX_DIMENSION_TEXTURE2D:
if (mdata.miscFlags & TEX_MISC_TEXTURECUBE)
if ( mdata.miscFlags & TEX_MISC_TEXTURECUBE )
{
pshader = g_PS_Cube;
pshader_size = sizeof(g_PS_Cube);
isCubeMap = true;
}
else if (mdata.arraySize > 1)
else if ( mdata.arraySize > 1 )
{
pshader = g_PS_2DArray;
pshader_size = sizeof(g_PS_2DArray);
@ -562,11 +504,11 @@ HRESULT InitDevice(const TexMetadata& mdata)
return E_FAIL;
}
assert(pshader && pshader_size > 0);
assert( pshader && pshader_size > 0 );
// Create the pixel shader
hr = g_pd3dDevice->CreatePixelShader(pshader, pshader_size, nullptr, &g_pPixelShader);
if (FAILED(hr))
hr = g_pd3dDevice->CreatePixelShader( pshader, pshader_size, nullptr, &g_pPixelShader );
if( FAILED( hr ) )
return hr;
// Create vertex buffer
@ -578,87 +520,87 @@ HRESULT InitDevice(const TexMetadata& mdata)
// Render cubemaps as horizontal cross
// XPOS
{ XMFLOAT4(.5f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 0.f, 0.f) },
{ XMFLOAT4(1.f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 0.f, 0.f) },
{ XMFLOAT4(.5f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 0.f, 0.f) },
{ XMFLOAT4(1.f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 0.f, 0.f) },
{ XMFLOAT4( .5f, .25f, 0.f, 1.f ), XMFLOAT4( 0.f, 0.f, 0.f, 0.f ) },
{ XMFLOAT4( 1.f, .25f, 0.f, 1.f ), XMFLOAT4( 1.f, 0.f, 0.f, 0.f ) },
{ XMFLOAT4( .5f, -.25f, 0.f, 1.f ), XMFLOAT4( 0.f, 1.f, 0.f, 0.f ) },
{ XMFLOAT4( 1.f, -.25f, 0.f, 1.f ), XMFLOAT4( 1.f, 1.f, 0.f, 0.f ) },
// XNEG
{ XMFLOAT4(-.5f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 1.f, 0.f) },
{ XMFLOAT4(0.f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 1.f, 0.f) },
{ XMFLOAT4(-.5f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 1.f, 0.f) },
{ XMFLOAT4(0.f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 1.f, 0.f) },
{ XMFLOAT4( -.5f, .25f, 0.f, 1.f ), XMFLOAT4( 0.f, 0.f, 1.f, 0.f ) },
{ XMFLOAT4( 0.f, .25f, 0.f, 1.f ), XMFLOAT4( 1.f, 0.f, 1.f, 0.f ) },
{ XMFLOAT4( -.5f, -.25f, 0.f, 1.f ), XMFLOAT4( 0.f, 1.f, 1.f, 0.f ) },
{ XMFLOAT4( 0.f, -.25f, 0.f, 1.f ), XMFLOAT4( 1.f, 1.f, 1.f, 0.f ) },
// YPOS
{ XMFLOAT4(-.5f, .75f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 2.f, 0.f) },
{ XMFLOAT4(0.f, .75f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 2.f, 0.f) },
{ XMFLOAT4(-.5f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 2.f, 0.f) },
{ XMFLOAT4(0.f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 2.f, 0.f) },
{ XMFLOAT4( -.5f, .75f, 0.f, 1.f ), XMFLOAT4( 0.f, 0.f, 2.f, 0.f ) },
{ XMFLOAT4( 0.f, .75f, 0.f, 1.f ), XMFLOAT4( 1.f, 0.f, 2.f, 0.f ) },
{ XMFLOAT4( -.5f, .25f, 0.f, 1.f ), XMFLOAT4( 0.f, 1.f, 2.f, 0.f ) },
{ XMFLOAT4( 0.f, .25f, 0.f, 1.f ), XMFLOAT4( 1.f, 1.f, 2.f, 0.f ) },
// YNEG
{ XMFLOAT4(-.5f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 3.f, 0.f) },
{ XMFLOAT4(0.f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 3.f, 0.f) },
{ XMFLOAT4(-.5f, -.75f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 3.f, 0.f) },
{ XMFLOAT4(0.f, -.75f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 3.f, 0.f) },
{ XMFLOAT4( -.5f, -.25f, 0.f, 1.f ), XMFLOAT4( 0.f, 0.f, 3.f, 0.f ) },
{ XMFLOAT4( 0.f, -.25f, 0.f, 1.f ), XMFLOAT4( 1.f, 0.f, 3.f, 0.f ) },
{ XMFLOAT4( -.5f, -.75f, 0.f, 1.f ), XMFLOAT4( 0.f, 1.f, 3.f, 0.f ) },
{ XMFLOAT4( 0.f, -.75f, 0.f, 1.f ), XMFLOAT4( 1.f, 1.f, 3.f, 0.f ) },
// ZPOS
{ XMFLOAT4(0.f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 4.f, 0.f) },
{ XMFLOAT4(.5f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 4.f, 0.f) },
{ XMFLOAT4(0.f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 4.f, 0.f) },
{ XMFLOAT4(.5f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 4.f, 0.f) },
{ XMFLOAT4( 0.f, .25f, 0.f, 1.f ), XMFLOAT4( 0.f, 0.f, 4.f, 0.f ) },
{ XMFLOAT4( .5f, .25f, 0.f, 1.f ), XMFLOAT4( 1.f, 0.f, 4.f, 0.f ) },
{ XMFLOAT4( 0.f, -.25f, 0.f, 1.f ), XMFLOAT4( 0.f, 1.f, 4.f, 0.f ) },
{ XMFLOAT4( .5f, -.25f, 0.f, 1.f ), XMFLOAT4( 1.f, 1.f, 4.f, 0.f ) },
// ZNEG
{ XMFLOAT4(-1.f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 5.f, 0.f) },
{ XMFLOAT4(-.5f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 5.f, 0.f) },
{ XMFLOAT4(-1.f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 5.f, 0.f) },
{ XMFLOAT4(-.5f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 5.f, 0.f) },
{ XMFLOAT4( -1.f, .25f, 0.f, 1.f ), XMFLOAT4( 0.f, 0.f, 5.f, 0.f ) },
{ XMFLOAT4( -.5f, .25f, 0.f, 1.f ), XMFLOAT4( 1.f, 0.f, 5.f, 0.f ) },
{ XMFLOAT4( -1.f, -.25f, 0.f, 1.f ), XMFLOAT4( 0.f, 1.f, 5.f, 0.f ) },
{ XMFLOAT4( -.5f, -.25f, 0.f, 1.f ), XMFLOAT4( 1.f, 1.f, 5.f, 0.f ) },
};
static const SimpleVertex vertices[] =
{
{ XMFLOAT4(-1.f, 1.f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 0.f, 0.f) },
{ XMFLOAT4(1.f, 1.f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 0.f, 0.f) },
{ XMFLOAT4(-1.f, -1.f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 0.f, 0.f) },
{ XMFLOAT4(1.f, -1.f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 0.f, 0.f) },
{ XMFLOAT4( -1.f, 1.f, 0.f, 1.f ), XMFLOAT4( 0.f, 0.f, 0.f, 0.f ) },
{ XMFLOAT4( 1.f, 1.f, 0.f, 1.f ), XMFLOAT4( 1.f, 0.f, 0.f, 0.f ) },
{ XMFLOAT4( -1.f, -1.f, 0.f, 1.f ), XMFLOAT4( 0.f, 1.f, 0.f, 0.f ) },
{ XMFLOAT4( 1.f, -1.f, 0.f, 1.f ), XMFLOAT4( 1.f, 1.f, 0.f, 0.f ) },
};
static const SimpleVertex vertices1D[] =
{
{ XMFLOAT4(-1.f, .05f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 0.f, 0.f) },
{ XMFLOAT4(1.f, .05f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 0.f, 0.f) },
{ XMFLOAT4(-1.f, -.05f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 0.f, 0.f) },
{ XMFLOAT4(1.f, -.05f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 0.f, 0.f) },
{ XMFLOAT4( -1.f, .05f, 0.f, 1.f ), XMFLOAT4( 0.f, 0.f, 0.f, 0.f ) },
{ XMFLOAT4( 1.f, .05f, 0.f, 1.f ), XMFLOAT4( 1.f, 0.f, 0.f, 0.f ) },
{ XMFLOAT4( -1.f, -.05f, 0.f, 1.f ), XMFLOAT4( 0.f, 0.f, 0.f, 0.f ) },
{ XMFLOAT4( 1.f, -.05f, 0.f, 1.f ), XMFLOAT4( 1.f, 0.f, 0.f, 0.f ) },
};
if (isCubeMap)
if ( isCubeMap )
{
nverts = static_cast<UINT>(std::size(verticesCube));
nverts = _countof(verticesCube);
InitData.pSysMem = verticesCube;
}
else if (is1D)
else if ( is1D )
{
nverts = static_cast<UINT>(std::size(vertices1D));
nverts = _countof(vertices1D);
InitData.pSysMem = vertices1D;
}
else
{
nverts = static_cast<UINT>(std::size(vertices));
nverts = _countof(vertices);
InitData.pSysMem = vertices;
}
D3D11_BUFFER_DESC bd = {};
bd.Usage = D3D11_USAGE_DEFAULT;
bd.ByteWidth = sizeof(SimpleVertex) * nverts;
bd.ByteWidth = sizeof( SimpleVertex ) * nverts;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
hr = g_pd3dDevice->CreateBuffer(&bd, &InitData, &g_pVertexBuffer);
if (FAILED(hr))
hr = g_pd3dDevice->CreateBuffer( &bd, &InitData, &g_pVertexBuffer );
if( FAILED( hr ) )
return hr;
// Set vertex buffer
UINT stride = sizeof(SimpleVertex);
UINT stride = sizeof( SimpleVertex );
UINT offset = 0;
g_pImmediateContext->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset);
g_pImmediateContext->IASetVertexBuffers( 0, 1, &g_pVertexBuffer, &stride, &offset );
// Create index buffer
static const WORD indicesCube[] =
@ -683,14 +625,14 @@ HRESULT InitDevice(const TexMetadata& mdata)
2, 1, 3
};
if (isCubeMap)
if ( isCubeMap )
{
g_iIndices = static_cast<UINT>(std::size(indicesCube));
g_iIndices = _countof(indicesCube);
InitData.pSysMem = indicesCube;
}
else
{
g_iIndices = static_cast<UINT>(std::size(indices));
g_iIndices = _countof(indices);
InitData.pSysMem = indices;
}
@ -698,23 +640,23 @@ HRESULT InitDevice(const TexMetadata& mdata)
bd.ByteWidth = g_iIndices * sizeof(WORD);
bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = 0;
hr = g_pd3dDevice->CreateBuffer(&bd, &InitData, &g_pIndexBuffer);
if (FAILED(hr))
hr = g_pd3dDevice->CreateBuffer( &bd, &InitData, &g_pIndexBuffer );
if( FAILED( hr ) )
return hr;
// Set index buffer
g_pImmediateContext->IASetIndexBuffer(g_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
g_pImmediateContext->IASetIndexBuffer( g_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0 );
// Set primitive topology
g_pImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
g_pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
// Create the constant buffers
bd.Usage = D3D11_USAGE_DEFAULT;
bd.ByteWidth = sizeof(CBArrayControl);
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
bd.CPUAccessFlags = 0;
hr = g_pd3dDevice->CreateBuffer(&bd, nullptr, &g_pCBArrayControl);
if (FAILED(hr))
hr = g_pd3dDevice->CreateBuffer( &bd, nullptr, &g_pCBArrayControl );
if( FAILED( hr ) )
return hr;
// Create the state objects
@ -726,11 +668,11 @@ HRESULT InitDevice(const TexMetadata& mdata)
sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
sampDesc.MinLOD = 0;
sampDesc.MaxLOD = D3D11_FLOAT32_MAX;
hr = g_pd3dDevice->CreateSamplerState(&sampDesc, &g_pSamplerLinear);
if (FAILED(hr))
hr = g_pd3dDevice->CreateSamplerState( &sampDesc, &g_pSamplerLinear );
if( FAILED( hr ) )
return hr;
D3D11_BLEND_DESC dsc =
D3D11_BLEND_DESC dsc =
{
false,
false,
@ -745,11 +687,11 @@ HRESULT InitDevice(const TexMetadata& mdata)
D3D11_BLEND_OP_ADD,
D3D11_COLOR_WRITE_ENABLE_ALL
},
// ...
}
// ...
}
};
hr = g_pd3dDevice->CreateBlendState(&dsc, &g_AlphaBlendState);
if (FAILED(hr))
hr = g_pd3dDevice->CreateBlendState(&dsc, &g_AlphaBlendState );
if( FAILED(hr) )
return hr;
return S_OK;
@ -760,45 +702,46 @@ HRESULT InitDevice(const TexMetadata& mdata)
void Render()
{
float ClearColor[4] = { 0.f, 1.f, 1.f, 1.0f }; //red,green,blue,alpha
g_pImmediateContext->ClearRenderTargetView(g_pRenderTargetView, ClearColor);
g_pImmediateContext->ClearDepthStencilView(g_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, ClearColor );
g_pImmediateContext->ClearDepthStencilView( g_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0 );
float bf[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
g_pImmediateContext->OMSetBlendState(g_AlphaBlendState, bf, 0xffffffff);
float bf [4] = {1.0f, 1.0f, 1.0f, 1.0f};
g_pImmediateContext->OMSetBlendState( g_AlphaBlendState, bf, 0xffffffff );
CBArrayControl cb = {};
cb.Index = static_cast<float>(g_iCurrentIndex);
g_pImmediateContext->UpdateSubresource(g_pCBArrayControl, 0, nullptr, &cb, 0, 0);
CBArrayControl cb;
cb.Index = (float)g_iCurrentIndex;
g_pImmediateContext->UpdateSubresource( g_pCBArrayControl, 0, nullptr, &cb, 0, 0 );
g_pImmediateContext->VSSetShader(g_pVertexShader, nullptr, 0);
g_pImmediateContext->PSSetShader(g_pPixelShader, nullptr, 0);
g_pImmediateContext->PSSetConstantBuffers(0, 1, &g_pCBArrayControl);
g_pImmediateContext->PSSetShaderResources(0, 1, &g_pSRV);
g_pImmediateContext->PSSetSamplers(0, 1, &g_pSamplerLinear);
g_pImmediateContext->DrawIndexed(g_iIndices, 0, 0);
g_pImmediateContext->VSSetShader( g_pVertexShader, nullptr, 0 );
g_pImmediateContext->PSSetShader( g_pPixelShader, nullptr, 0 );
g_pImmediateContext->PSSetConstantBuffers( 0, 1, &g_pCBArrayControl );
g_pImmediateContext->PSSetShaderResources( 0, 1, &g_pSRV );
g_pImmediateContext->PSSetSamplers( 0, 1, &g_pSamplerLinear );
g_pImmediateContext->DrawIndexed( g_iIndices, 0, 0 );
g_pSwapChain->Present(0, 0);
g_pSwapChain->Present( 0, 0 );
}
//--------------------------------------------------------------------------------------
void CleanupDevice()
{
if (g_pImmediateContext) g_pImmediateContext->ClearState();
if( g_pImmediateContext ) g_pImmediateContext->ClearState();
if (g_pSamplerLinear) g_pSamplerLinear->Release();
if (g_AlphaBlendState) g_AlphaBlendState->Release();
if (g_pSRV) g_pSRV->Release();
if (g_pVertexBuffer) g_pVertexBuffer->Release();
if (g_pIndexBuffer) g_pIndexBuffer->Release();
if (g_pCBArrayControl) g_pCBArrayControl->Release();
if (g_pVertexLayout) g_pVertexLayout->Release();
if (g_pVertexShader) g_pVertexShader->Release();
if (g_pPixelShader) g_pPixelShader->Release();
if (g_pDepthStencil) g_pDepthStencil->Release();
if (g_pDepthStencilView) g_pDepthStencilView->Release();
if (g_pRenderTargetView) g_pRenderTargetView->Release();
if (g_pSwapChain) g_pSwapChain->Release();
if (g_pImmediateContext) g_pImmediateContext->Release();
if (g_pd3dDevice) g_pd3dDevice->Release();
if( g_pSamplerLinear ) g_pSamplerLinear->Release();
if( g_AlphaBlendState ) g_AlphaBlendState->Release();
if( g_pSRV ) g_pSRV->Release();
if( g_pVertexBuffer ) g_pVertexBuffer->Release();
if( g_pIndexBuffer ) g_pIndexBuffer->Release();
if( g_pCBArrayControl ) g_pCBArrayControl->Release();
if( g_pVertexLayout ) g_pVertexLayout->Release();
if( g_pVertexShader ) g_pVertexShader->Release();
if( g_pPixelShader ) g_pPixelShader->Release();
if( g_pDepthStencil ) g_pDepthStencil->Release();
if( g_pDepthStencilView ) g_pDepthStencilView->Release();
if( g_pRenderTargetView ) g_pRenderTargetView->Release();
if( g_pSwapChain ) g_pSwapChain->Release();
if( g_pImmediateContext ) g_pImmediateContext->Release();
if( g_pd3dDevice ) g_pd3dDevice->Release();
}

View File

@ -1,24 +1,24 @@
//--------------------------------------------------------------------------------------
// File: ddsview.fx
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
// Constant Buffer Variables
//--------------------------------------------------------------------------------------
Texture1D tx1D : register(t0);
Texture1DArray tx1DArray : register(t0);
Texture1D tx1D : register( t0 );
Texture1DArray tx1DArray : register( t0 );
Texture2D tx2D : register(t0);
Texture2DArray tx2DArray : register(t0);
Texture2D tx2D : register( t0 );
Texture2DArray tx2DArray : register( t0 );
Texture3D tx3D : register(t0);
Texture3D tx3D : register( t0 );
SamplerState samLinear : register(s0);
SamplerState samLinear : register( s0 );
cbuffer cbArrayControl : register(b0)
cbuffer cbArrayControl : register( b0 )
{
float Index;
};
@ -40,7 +40,7 @@ struct PS_INPUT
//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
PS_INPUT VS(VS_INPUT input)
PS_INPUT VS( VS_INPUT input )
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = input.Pos;
@ -52,35 +52,35 @@ PS_INPUT VS(VS_INPUT input)
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS_1D(PS_INPUT input) : SV_Target
float4 PS_1D( PS_INPUT input) : SV_Target
{
return tx1D.Sample(samLinear, input.Tex.x);
return tx1D.Sample( samLinear, input.Tex.x );
}
float4 PS_1DArray(PS_INPUT input) : SV_Target
float4 PS_1DArray( PS_INPUT input) : SV_Target
{
return tx1DArray.Sample(samLinear, float2(input.Tex.x, Index));
return tx1DArray.Sample( samLinear, float2(input.Tex.x, Index) );
}
float4 PS_2D(PS_INPUT input) : SV_Target
float4 PS_2D( PS_INPUT input) : SV_Target
{
return tx2D.Sample(samLinear, input.Tex.xy);
return tx2D.Sample( samLinear, input.Tex.xy );
}
float4 PS_2DArray(PS_INPUT input) : SV_Target
float4 PS_2DArray( PS_INPUT input) : SV_Target
{
return tx2DArray.Sample(samLinear, float3(input.Tex.xy, Index));
return tx2DArray.Sample( samLinear, float3(input.Tex.xy, Index) );
}
float4 PS_3D(PS_INPUT input) : SV_Target
float4 PS_3D( PS_INPUT input) : SV_Target
{
int Width, Height, Depth;
tx3D.GetDimensions(Width, Height, Depth);
tx3D.GetDimensions( Width, Height, Depth);
return tx3D.Sample(samLinear, float3(input.Tex.xy, Index / Depth));
return tx3D.Sample( samLinear, float3(input.Tex.xy, Index / Depth) );
}
float4 PS_Cube(PS_INPUT input) : SV_Target
float4 PS_Cube( PS_INPUT input) : SV_Target
{
return tx2DArray.Sample(samLinear, float3(input.Tex.xy, input.Tex.z + (6*Index)));
return tx2DArray.Sample( samLinear, float3(input.Tex.xy, input.Tex.z + (6*Index)) );
}

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,81 +1,8 @@
@echo off
rem Copyright (c) Microsoft Corporation.
rem Licensed under the MIT License.
fxc ddsview.fx /nologo /EVS /Tvs_4_1 /Fhshaders\vs.h
fxc ddsview.fx /nologo /EPS_1D /Tps_4_1 /Fhshaders\ps1D.h
fxc ddsview.fx /nologo /EPS_1DArray /Tps_4_1 /Fhshaders\ps1Darray.h
fxc ddsview.fx /nologo /EPS_2D /Tps_4_1 /Fhshaders\ps2D.h
fxc ddsview.fx /nologo /EPS_2DArray /Tps_4_1 /Fhshaders\ps2Darray.h
fxc ddsview.fx /nologo /EPS_3D /Tps_4_1 /Fhshaders\ps3D.h
fxc ddsview.fx /nologo /EPS_Cube /Tps_4_1 /Fhshaders\psCube.h
setlocal
set error=0
if %PROCESSOR_ARCHITECTURE%.==ARM64. (set FXCARCH=arm64) else (if %PROCESSOR_ARCHITECTURE%.==AMD64. (set FXCARCH=x64) else (set FXCARCH=x86))
set FXCOPTS=/nologo /WX /Ges /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"
if exist %PCFXC% goto continue
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=Shaders
set StrTrim=%CompileShadersOutput%##
set StrTrim=%StrTrim: ##=%
set CompileShadersOutput=%StrTrim:##=%
@if not exist "%CompileShadersOutput%" mkdir "%CompileShadersOutput%"
set FXC=%PCFXC% ddsview.hlsl %FXCOPTS% /EVS /Tvs_4_1 /Fh%CompileShadersOutput%\ddsview_vs.inc
echo %FXC%
%FXC%
@if ERRORLEVEL 1 goto error
set FXC=%PCFXC% ddsview.hlsl %FXCOPTS% /EPS_1D /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps1D.inc
echo %FXC%
%FXC%
@if ERRORLEVEL 1 goto error
set FXC=%PCFXC% ddsview.hlsl %FXCOPTS% /EPS_1DArray /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps1Darray.inc
echo %FXC%
%FXC%
@if ERRORLEVEL 1 goto error
set FXC=%PCFXC% ddsview.hlsl %FXCOPTS% /EPS_2D /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps2D.inc
echo %FXC%
%FXC%
@if ERRORLEVEL 1 goto error
set FXC=%PCFXC% ddsview.hlsl %FXCOPTS% /EPS_2DArray /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps2Darray.inc
echo %FXC%
%FXC%
@if ERRORLEVEL 1 goto error
set FXC=%PCFXC% ddsview.hlsl %FXCOPTS% /EPS_3D /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps3D.inc
echo %FXC%
%FXC%
@if ERRORLEVEL 1 goto error
set FXC=%PCFXC% ddsview.hlsl %FXCOPTS% /EPS_Cube /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_psCube.inc
echo %FXC%
%FXC%
@if ERRORLEVEL 1 goto error
@echo --- Shaders built ok ---
endlocal
exit /b 0
:error
@echo --- ERROR: Shader build failed ---
exit /b 1
:needfxc
echo ERROR: CompileShaders requires FXC.EXE
exit /b 1
:end

179
DDSView/shaders/ps1D.h Normal file
View File

@ -0,0 +1,179 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc ddsview.fx /nologo /EPS_1D /Tps_4_1 /Fhshaders\ps1D.h
//
//
// Buffer Definitions:
//
// cbuffer cbArrayControl
// {
//
// float Index; // Offset: 0 Size: 4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// samLinear sampler NA NA 0 1
// tx1D texture float4 1d 0 1
// cbArrayControl cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture1d (float,float,float,float) t0
dcl_input_ps linear v1.x
dcl_output o0.xyzw
sample o0.xyzw, v1.xxxx, t0.xyzw, s0
ret
// Approximately 2 instruction slots used
#endif
const BYTE g_PS_1D[] =
{
68, 88, 66, 67, 71, 33,
105, 235, 206, 215, 61, 110,
190, 73, 39, 172, 36, 251,
31, 148, 1, 0, 0, 0,
220, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
84, 1, 0, 0, 172, 1,
0, 0, 224, 1, 0, 0,
96, 2, 0, 0, 82, 68,
69, 70, 24, 1, 0, 0,
1, 0, 0, 0, 156, 0,
0, 0, 3, 0, 0, 0,
28, 0, 0, 0, 1, 4,
255, 255, 0, 1, 0, 0,
228, 0, 0, 0, 124, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0,
134, 0, 0, 0, 2, 0,
0, 0, 5, 0, 0, 0,
2, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0,
1, 0, 0, 0, 13, 0,
0, 0, 139, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 115, 97,
109, 76, 105, 110, 101, 97,
114, 0, 116, 120, 49, 68,
0, 99, 98, 65, 114, 114,
97, 121, 67, 111, 110, 116,
114, 111, 108, 0, 171, 171,
139, 0, 0, 0, 1, 0,
0, 0, 180, 0, 0, 0,
16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
204, 0, 0, 0, 0, 0,
0, 0, 4, 0, 0, 0,
0, 0, 0, 0, 212, 0,
0, 0, 0, 0, 0, 0,
73, 110, 100, 101, 120, 0,
171, 171, 0, 0, 3, 0,
1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
77, 105, 99, 114, 111, 115,
111, 102, 116, 32, 40, 82,
41, 32, 72, 76, 83, 76,
32, 83, 104, 97, 100, 101,
114, 32, 67, 111, 109, 112,
105, 108, 101, 114, 32, 57,
46, 50, 57, 46, 57, 53,
50, 46, 51, 49, 49, 49,
0, 171, 171, 171, 73, 83,
71, 78, 80, 0, 0, 0,
2, 0, 0, 0, 8, 0,
0, 0, 56, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 15, 0,
0, 0, 68, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 15, 1,
0, 0, 83, 86, 95, 80,
79, 83, 73, 84, 73, 79,
78, 0, 84, 69, 88, 67,
79, 79, 82, 68, 0, 171,
171, 171, 79, 83, 71, 78,
44, 0, 0, 0, 1, 0,
0, 0, 8, 0, 0, 0,
32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
83, 86, 95, 84, 97, 114,
103, 101, 116, 0, 171, 171,
83, 72, 68, 82, 120, 0,
0, 0, 65, 0, 0, 0,
30, 0, 0, 0, 106, 8,
0, 1, 89, 0, 0, 4,
70, 142, 32, 0, 0, 0,
0, 0, 1, 0, 0, 0,
90, 0, 0, 3, 0, 96,
16, 0, 0, 0, 0, 0,
88, 16, 0, 4, 0, 112,
16, 0, 0, 0, 0, 0,
85, 85, 0, 0, 98, 16,
0, 3, 18, 16, 16, 0,
1, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
0, 0, 0, 0, 69, 0,
0, 9, 242, 32, 16, 0,
0, 0, 0, 0, 6, 16,
16, 0, 1, 0, 0, 0,
70, 126, 16, 0, 0, 0,
0, 0, 0, 96, 16, 0,
0, 0, 0, 0, 62, 0,
0, 1, 83, 84, 65, 84,
116, 0, 0, 0, 2, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 2, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};

192
DDSView/shaders/ps1Darray.h Normal file
View File

@ -0,0 +1,192 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc ddsview.fx /nologo /EPS_1DArray /Tps_4_1 /Fhshaders\ps1Darray.h
//
//
// Buffer Definitions:
//
// cbuffer cbArrayControl
// {
//
// float Index; // Offset: 0 Size: 4
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// samLinear sampler NA NA 0 1
// tx1DArray texture float4 1darray 0 1
// cbArrayControl cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture1darray (float,float,float,float) t0
dcl_input_ps linear v1.x
dcl_output o0.xyzw
dcl_temps 1
mov r0.x, v1.x
mov r0.y, cb0[0].x
sample o0.xyzw, r0.xyxx, t0.xyzw, s0
ret
// Approximately 4 instruction slots used
#endif
const BYTE g_PS_1DArray[] =
{
68, 88, 66, 67, 210, 249,
153, 123, 172, 65, 50, 100,
250, 1, 76, 219, 67, 149,
143, 209, 1, 0, 0, 0,
20, 3, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
88, 1, 0, 0, 176, 1,
0, 0, 228, 1, 0, 0,
152, 2, 0, 0, 82, 68,
69, 70, 28, 1, 0, 0,
1, 0, 0, 0, 160, 0,
0, 0, 3, 0, 0, 0,
28, 0, 0, 0, 1, 4,
255, 255, 0, 1, 0, 0,
232, 0, 0, 0, 124, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0,
134, 0, 0, 0, 2, 0,
0, 0, 5, 0, 0, 0,
3, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0,
1, 0, 0, 0, 13, 0,
0, 0, 144, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 115, 97,
109, 76, 105, 110, 101, 97,
114, 0, 116, 120, 49, 68,
65, 114, 114, 97, 121, 0,
99, 98, 65, 114, 114, 97,
121, 67, 111, 110, 116, 114,
111, 108, 0, 171, 144, 0,
0, 0, 1, 0, 0, 0,
184, 0, 0, 0, 16, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 208, 0,
0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 2, 0,
0, 0, 216, 0, 0, 0,
0, 0, 0, 0, 73, 110,
100, 101, 120, 0, 171, 171,
0, 0, 3, 0, 1, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 77, 105,
99, 114, 111, 115, 111, 102,
116, 32, 40, 82, 41, 32,
72, 76, 83, 76, 32, 83,
104, 97, 100, 101, 114, 32,
67, 111, 109, 112, 105, 108,
101, 114, 32, 57, 46, 50,
57, 46, 57, 53, 50, 46,
51, 49, 49, 49, 0, 171,
171, 171, 73, 83, 71, 78,
80, 0, 0, 0, 2, 0,
0, 0, 8, 0, 0, 0,
56, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
68, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0,
0, 0, 15, 1, 0, 0,
83, 86, 95, 80, 79, 83,
73, 84, 73, 79, 78, 0,
84, 69, 88, 67, 79, 79,
82, 68, 0, 171, 171, 171,
79, 83, 71, 78, 44, 0,
0, 0, 1, 0, 0, 0,
8, 0, 0, 0, 32, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 83, 86,
95, 84, 97, 114, 103, 101,
116, 0, 171, 171, 83, 72,
68, 82, 172, 0, 0, 0,
65, 0, 0, 0, 43, 0,
0, 0, 106, 8, 0, 1,
89, 0, 0, 4, 70, 142,
32, 0, 0, 0, 0, 0,
1, 0, 0, 0, 90, 0,
0, 3, 0, 96, 16, 0,
0, 0, 0, 0, 88, 56,
0, 4, 0, 112, 16, 0,
0, 0, 0, 0, 85, 85,
0, 0, 98, 16, 0, 3,
18, 16, 16, 0, 1, 0,
0, 0, 101, 0, 0, 3,
242, 32, 16, 0, 0, 0,
0, 0, 104, 0, 0, 2,
1, 0, 0, 0, 54, 0,
0, 5, 18, 0, 16, 0,
0, 0, 0, 0, 10, 16,
16, 0, 1, 0, 0, 0,
54, 0, 0, 6, 34, 0,
16, 0, 0, 0, 0, 0,
10, 128, 32, 0, 0, 0,
0, 0, 0, 0, 0, 0,
69, 0, 0, 9, 242, 32,
16, 0, 0, 0, 0, 0,
70, 0, 16, 0, 0, 0,
0, 0, 70, 126, 16, 0,
0, 0, 0, 0, 0, 96,
16, 0, 0, 0, 0, 0,
62, 0, 0, 1, 83, 84,
65, 84, 116, 0, 0, 0,
4, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
2, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 2, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0
};

144
DDSView/shaders/ps2D.h Normal file
View File

@ -0,0 +1,144 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc ddsview.fx /nologo /EPS_2D /Tps_4_1 /Fhshaders\ps2D.h
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// samLinear sampler NA NA 0 1
// tx2D texture float4 2d 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
sample o0.xyzw, v1.xyxx, t0.xyzw, s0
ret
// Approximately 2 instruction slots used
#endif
const BYTE g_PS_2D[] =
{
68, 88, 66, 67, 45, 73,
251, 77, 247, 44, 253, 34,
100, 41, 211, 74, 100, 236,
72, 69, 1, 0, 0, 0,
80, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
216, 0, 0, 0, 48, 1,
0, 0, 100, 1, 0, 0,
212, 1, 0, 0, 82, 68,
69, 70, 156, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0,
28, 0, 0, 0, 1, 4,
255, 255, 0, 1, 0, 0,
107, 0, 0, 0, 92, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0,
102, 0, 0, 0, 2, 0,
0, 0, 5, 0, 0, 0,
4, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0,
1, 0, 0, 0, 13, 0,
0, 0, 115, 97, 109, 76,
105, 110, 101, 97, 114, 0,
116, 120, 50, 68, 0, 77,
105, 99, 114, 111, 115, 111,
102, 116, 32, 40, 82, 41,
32, 72, 76, 83, 76, 32,
83, 104, 97, 100, 101, 114,
32, 67, 111, 109, 112, 105,
108, 101, 114, 32, 57, 46,
50, 57, 46, 57, 53, 50,
46, 51, 49, 49, 49, 0,
73, 83, 71, 78, 80, 0,
0, 0, 2, 0, 0, 0,
8, 0, 0, 0, 56, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 68, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 0,
0, 0, 1, 0, 0, 0,
15, 3, 0, 0, 83, 86,
95, 80, 79, 83, 73, 84,
73, 79, 78, 0, 84, 69,
88, 67, 79, 79, 82, 68,
0, 171, 171, 171, 79, 83,
71, 78, 44, 0, 0, 0,
1, 0, 0, 0, 8, 0,
0, 0, 32, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 15, 0,
0, 0, 83, 86, 95, 84,
97, 114, 103, 101, 116, 0,
171, 171, 83, 72, 68, 82,
104, 0, 0, 0, 65, 0,
0, 0, 26, 0, 0, 0,
106, 8, 0, 1, 90, 0,
0, 3, 0, 96, 16, 0,
0, 0, 0, 0, 88, 24,
0, 4, 0, 112, 16, 0,
0, 0, 0, 0, 85, 85,
0, 0, 98, 16, 0, 3,
50, 16, 16, 0, 1, 0,
0, 0, 101, 0, 0, 3,
242, 32, 16, 0, 0, 0,
0, 0, 69, 0, 0, 9,
242, 32, 16, 0, 0, 0,
0, 0, 70, 16, 16, 0,
1, 0, 0, 0, 70, 126,
16, 0, 0, 0, 0, 0,
0, 96, 16, 0, 0, 0,
0, 0, 62, 0, 0, 1,
83, 84, 65, 84, 116, 0,
0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0
};

192
DDSView/shaders/ps2Darray.h Normal file
View File

@ -0,0 +1,192 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc ddsview.fx /nologo /EPS_2DArray /Tps_4_1 /Fhshaders\ps2Darray.h
//
//
// Buffer Definitions:
//
// cbuffer cbArrayControl
// {
//
// float Index; // Offset: 0 Size: 4
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// samLinear sampler NA NA 0 1
// tx2DArray texture float4 2darray 0 1
// cbArrayControl cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2darray (float,float,float,float) t0
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 1
mov r0.xy, v1.xyxx
mov r0.z, cb0[0].x
sample o0.xyzw, r0.xyzx, t0.xyzw, s0
ret
// Approximately 4 instruction slots used
#endif
const BYTE g_PS_2DArray[] =
{
68, 88, 66, 67, 55, 138,
65, 43, 181, 212, 29, 116,
142, 112, 89, 51, 193, 95,
148, 33, 1, 0, 0, 0,
20, 3, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
88, 1, 0, 0, 176, 1,
0, 0, 228, 1, 0, 0,
152, 2, 0, 0, 82, 68,
69, 70, 28, 1, 0, 0,
1, 0, 0, 0, 160, 0,
0, 0, 3, 0, 0, 0,
28, 0, 0, 0, 1, 4,
255, 255, 0, 1, 0, 0,
232, 0, 0, 0, 124, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0,
134, 0, 0, 0, 2, 0,
0, 0, 5, 0, 0, 0,
5, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0,
1, 0, 0, 0, 13, 0,
0, 0, 144, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 115, 97,
109, 76, 105, 110, 101, 97,
114, 0, 116, 120, 50, 68,
65, 114, 114, 97, 121, 0,
99, 98, 65, 114, 114, 97,
121, 67, 111, 110, 116, 114,
111, 108, 0, 171, 144, 0,
0, 0, 1, 0, 0, 0,
184, 0, 0, 0, 16, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 208, 0,
0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 2, 0,
0, 0, 216, 0, 0, 0,
0, 0, 0, 0, 73, 110,
100, 101, 120, 0, 171, 171,
0, 0, 3, 0, 1, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 77, 105,
99, 114, 111, 115, 111, 102,
116, 32, 40, 82, 41, 32,
72, 76, 83, 76, 32, 83,
104, 97, 100, 101, 114, 32,
67, 111, 109, 112, 105, 108,
101, 114, 32, 57, 46, 50,
57, 46, 57, 53, 50, 46,
51, 49, 49, 49, 0, 171,
171, 171, 73, 83, 71, 78,
80, 0, 0, 0, 2, 0,
0, 0, 8, 0, 0, 0,
56, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
68, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0,
0, 0, 15, 3, 0, 0,
83, 86, 95, 80, 79, 83,
73, 84, 73, 79, 78, 0,
84, 69, 88, 67, 79, 79,
82, 68, 0, 171, 171, 171,
79, 83, 71, 78, 44, 0,
0, 0, 1, 0, 0, 0,
8, 0, 0, 0, 32, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 83, 86,
95, 84, 97, 114, 103, 101,
116, 0, 171, 171, 83, 72,
68, 82, 172, 0, 0, 0,
65, 0, 0, 0, 43, 0,
0, 0, 106, 8, 0, 1,
89, 0, 0, 4, 70, 142,
32, 0, 0, 0, 0, 0,
1, 0, 0, 0, 90, 0,
0, 3, 0, 96, 16, 0,
0, 0, 0, 0, 88, 64,
0, 4, 0, 112, 16, 0,
0, 0, 0, 0, 85, 85,
0, 0, 98, 16, 0, 3,
50, 16, 16, 0, 1, 0,
0, 0, 101, 0, 0, 3,
242, 32, 16, 0, 0, 0,
0, 0, 104, 0, 0, 2,
1, 0, 0, 0, 54, 0,
0, 5, 50, 0, 16, 0,
0, 0, 0, 0, 70, 16,
16, 0, 1, 0, 0, 0,
54, 0, 0, 6, 66, 0,
16, 0, 0, 0, 0, 0,
10, 128, 32, 0, 0, 0,
0, 0, 0, 0, 0, 0,
69, 0, 0, 9, 242, 32,
16, 0, 0, 0, 0, 0,
70, 2, 16, 0, 0, 0,
0, 0, 70, 126, 16, 0,
0, 0, 0, 0, 0, 96,
16, 0, 0, 0, 0, 0,
62, 0, 0, 1, 83, 84,
65, 84, 116, 0, 0, 0,
4, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
2, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 2, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0
};

198
DDSView/shaders/ps3D.h Normal file
View File

@ -0,0 +1,198 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc ddsview.fx /nologo /EPS_3D /Tps_4_1 /Fhshaders\ps3D.h
//
//
// Buffer Definitions:
//
// cbuffer cbArrayControl
// {
//
// float Index; // Offset: 0 Size: 4
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// samLinear sampler NA NA 0 1
// tx3D texture float4 3d 0 1
// cbArrayControl cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture3d (float,float,float,float) t0
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 1
resinfo r0.x, l(0), t0.zxyw
div r0.z, cb0[0].x, r0.x
mov r0.xy, v1.xyxx
sample o0.xyzw, r0.xyzx, t0.xyzw, s0
ret
// Approximately 5 instruction slots used
#endif
const BYTE g_PS_3D[] =
{
68, 88, 66, 67, 119, 18,
113, 52, 66, 105, 65, 45,
139, 58, 175, 102, 69, 213,
121, 186, 1, 0, 0, 0,
52, 3, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
84, 1, 0, 0, 172, 1,
0, 0, 224, 1, 0, 0,
184, 2, 0, 0, 82, 68,
69, 70, 24, 1, 0, 0,
1, 0, 0, 0, 156, 0,
0, 0, 3, 0, 0, 0,
28, 0, 0, 0, 1, 4,
255, 255, 0, 1, 0, 0,
228, 0, 0, 0, 124, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0,
134, 0, 0, 0, 2, 0,
0, 0, 5, 0, 0, 0,
8, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0,
1, 0, 0, 0, 13, 0,
0, 0, 139, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 115, 97,
109, 76, 105, 110, 101, 97,
114, 0, 116, 120, 51, 68,
0, 99, 98, 65, 114, 114,
97, 121, 67, 111, 110, 116,
114, 111, 108, 0, 171, 171,
139, 0, 0, 0, 1, 0,
0, 0, 180, 0, 0, 0,
16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
204, 0, 0, 0, 0, 0,
0, 0, 4, 0, 0, 0,
2, 0, 0, 0, 212, 0,
0, 0, 0, 0, 0, 0,
73, 110, 100, 101, 120, 0,
171, 171, 0, 0, 3, 0,
1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
77, 105, 99, 114, 111, 115,
111, 102, 116, 32, 40, 82,
41, 32, 72, 76, 83, 76,
32, 83, 104, 97, 100, 101,
114, 32, 67, 111, 109, 112,
105, 108, 101, 114, 32, 57,
46, 50, 57, 46, 57, 53,
50, 46, 51, 49, 49, 49,
0, 171, 171, 171, 73, 83,
71, 78, 80, 0, 0, 0,
2, 0, 0, 0, 8, 0,
0, 0, 56, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 15, 0,
0, 0, 68, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 15, 3,
0, 0, 83, 86, 95, 80,
79, 83, 73, 84, 73, 79,
78, 0, 84, 69, 88, 67,
79, 79, 82, 68, 0, 171,
171, 171, 79, 83, 71, 78,
44, 0, 0, 0, 1, 0,
0, 0, 8, 0, 0, 0,
32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
83, 86, 95, 84, 97, 114,
103, 101, 116, 0, 171, 171,
83, 72, 68, 82, 208, 0,
0, 0, 65, 0, 0, 0,
52, 0, 0, 0, 106, 8,
0, 1, 89, 0, 0, 4,
70, 142, 32, 0, 0, 0,
0, 0, 1, 0, 0, 0,
90, 0, 0, 3, 0, 96,
16, 0, 0, 0, 0, 0,
88, 40, 0, 4, 0, 112,
16, 0, 0, 0, 0, 0,
85, 85, 0, 0, 98, 16,
0, 3, 50, 16, 16, 0,
1, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
0, 0, 0, 0, 104, 0,
0, 2, 1, 0, 0, 0,
61, 0, 0, 7, 18, 0,
16, 0, 0, 0, 0, 0,
1, 64, 0, 0, 0, 0,
0, 0, 38, 125, 16, 0,
0, 0, 0, 0, 14, 0,
0, 8, 66, 0, 16, 0,
0, 0, 0, 0, 10, 128,
32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 10, 0,
16, 0, 0, 0, 0, 0,
54, 0, 0, 5, 50, 0,
16, 0, 0, 0, 0, 0,
70, 16, 16, 0, 1, 0,
0, 0, 69, 0, 0, 9,
242, 32, 16, 0, 0, 0,
0, 0, 70, 2, 16, 0,
0, 0, 0, 0, 70, 126,
16, 0, 0, 0, 0, 0,
0, 96, 16, 0, 0, 0,
0, 0, 62, 0, 0, 1,
83, 84, 65, 84, 116, 0,
0, 0, 5, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0
};

194
DDSView/shaders/psCube.h Normal file
View File

@ -0,0 +1,194 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc ddsview.fx /nologo /EPS_Cube /Tps_4_1 /Fhshaders\psCube.h
//
//
// Buffer Definitions:
//
// cbuffer cbArrayControl
// {
//
// float Index; // Offset: 0 Size: 4
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// samLinear sampler NA NA 0 1
// tx2DArray texture float4 2darray 0 1
// cbArrayControl cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float xyz
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2darray (float,float,float,float) t0
dcl_input_ps linear v1.xyz
dcl_output o0.xyzw
dcl_temps 1
mad r0.z, cb0[0].x, l(6.000000), v1.z
mov r0.xy, v1.xyxx
sample o0.xyzw, r0.xyzx, t0.xyzw, s0
ret
// Approximately 4 instruction slots used
#endif
const BYTE g_PS_Cube[] =
{
68, 88, 66, 67, 255, 88,
222, 202, 51, 233, 113, 192,
119, 52, 43, 119, 92, 83,
243, 127, 1, 0, 0, 0,
36, 3, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
88, 1, 0, 0, 176, 1,
0, 0, 228, 1, 0, 0,
168, 2, 0, 0, 82, 68,
69, 70, 28, 1, 0, 0,
1, 0, 0, 0, 160, 0,
0, 0, 3, 0, 0, 0,
28, 0, 0, 0, 1, 4,
255, 255, 0, 1, 0, 0,
232, 0, 0, 0, 124, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0,
134, 0, 0, 0, 2, 0,
0, 0, 5, 0, 0, 0,
5, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0,
1, 0, 0, 0, 13, 0,
0, 0, 144, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 115, 97,
109, 76, 105, 110, 101, 97,
114, 0, 116, 120, 50, 68,
65, 114, 114, 97, 121, 0,
99, 98, 65, 114, 114, 97,
121, 67, 111, 110, 116, 114,
111, 108, 0, 171, 144, 0,
0, 0, 1, 0, 0, 0,
184, 0, 0, 0, 16, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 208, 0,
0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 2, 0,
0, 0, 216, 0, 0, 0,
0, 0, 0, 0, 73, 110,
100, 101, 120, 0, 171, 171,
0, 0, 3, 0, 1, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 77, 105,
99, 114, 111, 115, 111, 102,
116, 32, 40, 82, 41, 32,
72, 76, 83, 76, 32, 83,
104, 97, 100, 101, 114, 32,
67, 111, 109, 112, 105, 108,
101, 114, 32, 57, 46, 50,
57, 46, 57, 53, 50, 46,
51, 49, 49, 49, 0, 171,
171, 171, 73, 83, 71, 78,
80, 0, 0, 0, 2, 0,
0, 0, 8, 0, 0, 0,
56, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
68, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0,
0, 0, 15, 7, 0, 0,
83, 86, 95, 80, 79, 83,
73, 84, 73, 79, 78, 0,
84, 69, 88, 67, 79, 79,
82, 68, 0, 171, 171, 171,
79, 83, 71, 78, 44, 0,
0, 0, 1, 0, 0, 0,
8, 0, 0, 0, 32, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 83, 86,
95, 84, 97, 114, 103, 101,
116, 0, 171, 171, 83, 72,
68, 82, 188, 0, 0, 0,
65, 0, 0, 0, 47, 0,
0, 0, 106, 8, 0, 1,
89, 0, 0, 4, 70, 142,
32, 0, 0, 0, 0, 0,
1, 0, 0, 0, 90, 0,
0, 3, 0, 96, 16, 0,
0, 0, 0, 0, 88, 64,
0, 4, 0, 112, 16, 0,
0, 0, 0, 0, 85, 85,
0, 0, 98, 16, 0, 3,
114, 16, 16, 0, 1, 0,
0, 0, 101, 0, 0, 3,
242, 32, 16, 0, 0, 0,
0, 0, 104, 0, 0, 2,
1, 0, 0, 0, 50, 0,
0, 10, 66, 0, 16, 0,
0, 0, 0, 0, 10, 128,
32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 64,
0, 0, 0, 0, 192, 64,
42, 16, 16, 0, 1, 0,
0, 0, 54, 0, 0, 5,
50, 0, 16, 0, 0, 0,
0, 0, 70, 16, 16, 0,
1, 0, 0, 0, 69, 0,
0, 9, 242, 32, 16, 0,
0, 0, 0, 0, 70, 2,
16, 0, 0, 0, 0, 0,
70, 126, 16, 0, 0, 0,
0, 0, 0, 96, 16, 0,
0, 0, 0, 0, 62, 0,
0, 1, 83, 84, 65, 84,
116, 0, 0, 0, 4, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 2, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};

131
DDSView/shaders/vs.h Normal file
View File

@ -0,0 +1,131 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc ddsview.fx /nologo /EVS /Tvs_4_1 /Fhshaders\vs.h
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// POSITION 0 xyzw 0 NONE float xyzw
// TEXCOORD 0 xyzw 1 NONE float xyzw
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float xyzw
// TEXCOORD 0 xyzw 1 NONE float xyzw
//
vs_4_1
dcl_globalFlags refactoringAllowed
dcl_input v0.xyzw
dcl_input v1.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
mov o0.xyzw, v0.xyzw
mov o1.xyzw, v1.xyzw
ret
// Approximately 3 instruction slots used
#endif
const BYTE g_VS[] =
{
68, 88, 66, 67, 243, 4,
207, 4, 72, 185, 125, 253,
86, 236, 11, 103, 199, 128,
83, 243, 1, 0, 0, 0,
40, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
140, 0, 0, 0, 224, 0,
0, 0, 56, 1, 0, 0,
172, 1, 0, 0, 82, 68,
69, 70, 80, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
28, 0, 0, 0, 1, 4,
254, 255, 0, 1, 0, 0,
28, 0, 0, 0, 77, 105,
99, 114, 111, 115, 111, 102,
116, 32, 40, 82, 41, 32,
72, 76, 83, 76, 32, 83,
104, 97, 100, 101, 114, 32,
67, 111, 109, 112, 105, 108,
101, 114, 32, 57, 46, 50,
57, 46, 57, 53, 50, 46,
51, 49, 49, 49, 0, 171,
171, 171, 73, 83, 71, 78,
76, 0, 0, 0, 2, 0,
0, 0, 8, 0, 0, 0,
56, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 15, 0, 0,
65, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0,
0, 0, 15, 15, 0, 0,
80, 79, 83, 73, 84, 73,
79, 78, 0, 84, 69, 88,
67, 79, 79, 82, 68, 0,
171, 171, 79, 83, 71, 78,
80, 0, 0, 0, 2, 0,
0, 0, 8, 0, 0, 0,
56, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
68, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0,
0, 0, 15, 0, 0, 0,
83, 86, 95, 80, 79, 83,
73, 84, 73, 79, 78, 0,
84, 69, 88, 67, 79, 79,
82, 68, 0, 171, 171, 171,
83, 72, 68, 82, 108, 0,
0, 0, 65, 0, 1, 0,
27, 0, 0, 0, 106, 8,
0, 1, 95, 0, 0, 3,
242, 16, 16, 0, 0, 0,
0, 0, 95, 0, 0, 3,
242, 16, 16, 0, 1, 0,
0, 0, 103, 0, 0, 4,
242, 32, 16, 0, 0, 0,
0, 0, 1, 0, 0, 0,
101, 0, 0, 3, 242, 32,
16, 0, 1, 0, 0, 0,
54, 0, 0, 5, 242, 32,
16, 0, 0, 0, 0, 0,
70, 30, 16, 0, 0, 0,
0, 0, 54, 0, 0, 5,
242, 32, 16, 0, 1, 0,
0, 0, 70, 30, 16, 0,
1, 0, 0, 0, 62, 0,
0, 1, 83, 84, 65, 84,
116, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 4, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};

View File

@ -1,9 +1,9 @@
//-------------------------------------------------------------------------------------
// BC.cpp
//
//
// Block-compression (BC) functionality for BC1, BC2, BC3 (orginal DXTn formats)
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
@ -69,7 +69,7 @@ namespace
uint32_t cSteps,
uint32_t flags) noexcept
{
constexpr float fEpsilon = (0.25f / 64.0f) * (0.25f / 64.0f);
static const float fEpsilon = (0.25f / 64.0f) * (0.25f / 64.0f);
static const float pC3[] = { 2.0f / 2.0f, 1.0f / 2.0f, 0.0f / 2.0f };
static const float pD3[] = { 0.0f / 2.0f, 1.0f / 2.0f, 2.0f / 2.0f };
static const float pC4[] = { 3.0f / 3.0f, 2.0f / 3.0f, 1.0f / 3.0f, 0.0f / 3.0f };
@ -84,9 +84,9 @@ namespace
for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++)
{
#ifdef COLOR_WEIGHTS
#ifdef COLOR_WEIGHTS
if (pPoints[iPoint].a > 0.0f)
#endif // COLOR_WEIGHTS
#endif // COLOR_WEIGHTS
{
if (pPoints[iPoint].r < X.r)
X.r = pPoints[iPoint].r;
@ -109,9 +109,9 @@ namespace
}
// Diagonal axis
const HDRColorA AB(Y.r - X.r, Y.g - X.g, Y.b - X.b, 0.0f);
HDRColorA AB(Y.r - X.r, Y.g - X.g, Y.b - X.b, 0.0f);
const float fAB = AB.r * AB.r + AB.g * AB.g + AB.b * AB.b;
float fAB = AB.r * AB.r + AB.g * AB.g + AB.b * AB.b;
// Single color block.. no need to root-find
if (fAB < FLT_MIN)
@ -122,11 +122,11 @@ namespace
}
// Try all four axis directions, to determine which diagonal best fits data
const float fABInv = 1.0f / fAB;
float fABInv = 1.0f / fAB;
HDRColorA Dir(AB.r * fABInv, AB.g * fABInv, AB.b * fABInv, 0.0f);
const HDRColorA Mid(
HDRColorA Mid(
(X.r + Y.r) * 0.5f,
(X.g + Y.g) * 0.5f,
(X.b + Y.b) * 0.5f,
@ -144,7 +144,7 @@ namespace
float f;
#ifdef COLOR_WEIGHTS
#ifdef COLOR_WEIGHTS
f = Pt.r + Pt.g + Pt.b;
fDir[0] += pPoints[iPoint].a * f * f;
@ -156,7 +156,7 @@ namespace
f = Pt.r - Pt.g - Pt.b;
fDir[3] += pPoints[iPoint].a * f * f;
#else
#else
f = Pt.r + Pt.g + Pt.b;
fDir[0] += f * f;
@ -168,7 +168,7 @@ namespace
f = Pt.r - Pt.g - Pt.b;
fDir[3] += f * f;
#endif // COLOR_WEIGHTS
#endif // COLOR_WEIGHTS
}
float fDirMax = fDir[0];
@ -185,12 +185,12 @@ namespace
if (iDirMax & 2)
{
const float f = X.g; X.g = Y.g; Y.g = f;
float f = X.g; X.g = Y.g; Y.g = f;
}
if (iDirMax & 1)
{
const float f = X.b; X.b = Y.b; Y.b = f;
float f = X.b; X.b = Y.b; Y.b = f;
}
@ -203,7 +203,7 @@ namespace
}
// Use Newton's Method to find local minima of sum-of-squares error.
const auto fSteps = static_cast<float>(cSteps - 1);
auto fSteps = static_cast<float>(cSteps - 1);
for (size_t iIteration = 0; iIteration < 8; iIteration++)
{
@ -224,12 +224,12 @@ namespace
Dir.g = Y.g - X.g;
Dir.b = Y.b - X.b;
const float fLen = (Dir.r * Dir.r + Dir.g * Dir.g + Dir.b * Dir.b);
float fLen = (Dir.r * Dir.r + Dir.g * Dir.g + Dir.b * Dir.b);
if (fLen < (1.0f / 4096.0f))
break;
const float fScale = fSteps / fLen;
float fScale = fSteps / fLen;
Dir.r *= fScale;
Dir.g *= fScale;
@ -244,7 +244,7 @@ namespace
for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++)
{
const float fDot = (pPoints[iPoint].r - X.r) * Dir.r +
float fDot = (pPoints[iPoint].r - X.r) * Dir.r +
(pPoints[iPoint].g - X.g) * Dir.g +
(pPoints[iPoint].b - X.b) * Dir.b;
@ -264,13 +264,13 @@ namespace
Diff.b = pSteps[iStep].b - pPoints[iPoint].b;
Diff.a = 0.0f;
#ifdef COLOR_WEIGHTS
const float fC = pC[iStep] * pPoints[iPoint].a * (1.0f / 8.0f);
const float fD = pD[iStep] * pPoints[iPoint].a * (1.0f / 8.0f);
#else
const float fC = pC[iStep] * (1.0f / 8.0f);
const float fD = pD[iStep] * (1.0f / 8.0f);
#endif // COLOR_WEIGHTS
#ifdef COLOR_WEIGHTS
float fC = pC[iStep] * pPoints[iPoint].a * (1.0f / 8.0f);
float fD = pD[iStep] * pPoints[iPoint].a * (1.0f / 8.0f);
#else
float fC = pC[iStep] * (1.0f / 8.0f);
float fD = pD[iStep] * (1.0f / 8.0f);
#endif // COLOR_WEIGHTS
d2X += fC * pC[iStep];
dX.r += fC * Diff.r;
@ -286,7 +286,7 @@ namespace
// Move endpoints
if (d2X > 0.0f)
{
const float f = -1.0f / d2X;
float f = -1.0f / d2X;
X.r += dX.r * f;
X.g += dX.g * f;
@ -295,7 +295,7 @@ namespace
if (d2Y > 0.0f)
{
const float f = -1.0f / d2Y;
float f = -1.0f / d2Y;
Y.r += dY.r * f;
Y.g += dY.g * f;
@ -405,8 +405,8 @@ namespace
uSteps = 4u;
}
// Quantize block to R56B5, using Floyd Stienberg error diffusion. This
// increases the chance that colors will map directly to the quantized
// Quantize block to R56B5, using Floyd Stienberg error diffusion. This
// increases the chance that colors will map directly to the quantized
// axis endpoints.
HDRColorA Color[NUM_PIXELS_PER_BLOCK];
HDRColorA Error[NUM_PIXELS_PER_BLOCK];
@ -434,11 +434,11 @@ namespace
Color[i].g = static_cast<float>(static_cast<int32_t>(Clr.g * 63.0f + 0.5f)) * (1.0f / 63.0f);
Color[i].b = static_cast<float>(static_cast<int32_t>(Clr.b * 31.0f + 0.5f)) * (1.0f / 31.0f);
#ifdef COLOR_WEIGHTS
#ifdef COLOR_WEIGHTS
Color[i].a = pColor[i].a;
#else
#else
Color[i].a = 1.0f;
#endif // COLOR_WEIGHTS
#endif // COLOR_WEIGHTS
if (flags & BC_FLAGS_DITHER_RGB)
{
@ -513,8 +513,8 @@ namespace
ColorD.a = ColorB.a;
}
const uint16_t wColorA = Encode565(&ColorC);
const uint16_t wColorB = Encode565(&ColorD);
uint16_t wColorA = Encode565(&ColorC);
uint16_t wColorB = Encode565(&ColorD);
if ((uSteps == 4) && (wColorA == wColorB))
{
@ -588,8 +588,8 @@ namespace
Dir.b = Step[1].b - Step[0].b;
Dir.a = 0.0f;
const auto fSteps = static_cast<float>(uSteps - 1);
const float fScale = (wColorA != wColorB) ? (fSteps / (Dir.r * Dir.r + Dir.g * Dir.g + Dir.b * Dir.b)) : 0.0f;
auto fSteps = static_cast<float>(uSteps - 1);
float fScale = (wColorA != wColorB) ? (fSteps / (Dir.r * Dir.r + Dir.g * Dir.g + Dir.b * Dir.b)) : 0.0f;
Dir.r *= fScale;
Dir.g *= fScale;
@ -630,7 +630,7 @@ namespace
Clr.b += Error[i].b;
}
const float fDot = (Clr.r - Step[0].r) * Dir.r + (Clr.g - Step[0].g) * Dir.g + (Clr.b - Step[0].b) * Dir.b;
float fDot = (Clr.r - Step[0].r) * Dir.r + (Clr.g - Step[0].g) * Dir.g + (Clr.b - Step[0].b) * Dir.b;
uint32_t iStep;
if (fDot <= 0.0f)
@ -688,7 +688,7 @@ namespace
#ifdef COLOR_WEIGHTS
void EncodeSolidBC1(_Out_ D3DX_BC1 *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor)
{
#ifdef COLOR_AVG_0WEIGHTS
#ifdef COLOR_AVG_0WEIGHTS
// Compute avg color
HDRColorA Color;
Color.r = pColor[0].r;
@ -706,10 +706,10 @@ namespace
Color.g *= 1.0f / 16.0f;
Color.b *= 1.0f / 16.0f;
const uint16_t wColor = Encode565(&Color);
#else
const uint16_t wColor = 0x0000;
#endif // COLOR_AVG_0WEIGHTS
uint16_t wColor = Encode565(&Color);
#else
uint16_t wColor = 0x0000;
#endif // COLOR_AVG_0WEIGHTS
// Encode solid block
pBC->rgb[0] = wColor;
@ -750,14 +750,14 @@ void DirectX::D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float threshol
HDRColorA clr;
XMStoreFloat4(reinterpret_cast<XMFLOAT4*>(&clr), pColor[i]);
const float fAlph = clr.a + fError[i];
float fAlph = clr.a + fError[i];
Color[i].r = clr.r;
Color[i].g = clr.g;
Color[i].b = clr.b;
Color[i].a = static_cast<float>(static_cast<int32_t>(clr.a + fError[i] + 0.5f));
const float fDiff = fAlph - Color[i].a;
float fDiff = fAlph - Color[i].a;
if (3 != (i & 3))
{
@ -814,7 +814,7 @@ void DirectX::D3DXDecodeBC2(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < 8; ++i, dw >>= 4)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSetW(pColor[i], static_cast<float>(dw & 0xf) * (1.0f / 15.0f));
}
@ -849,14 +849,14 @@ void DirectX::D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags
if (flags & BC_FLAGS_DITHER_A)
fAlph += fError[i];
const auto u = static_cast<uint32_t>(fAlph * 15.0f + 0.5f);
auto u = static_cast<uint32_t>(fAlph * 15.0f + 0.5f);
pBC2->bitmap[i >> 3] >>= 4;
pBC2->bitmap[i >> 3] |= (u << 28);
if (flags & BC_FLAGS_DITHER_A)
{
const float fDiff = fAlph - float(u) * (1.0f / 15.0f);
float fDiff = fAlph - float(u) * (1.0f / 15.0f);
if (3 != (i & 3))
{
@ -954,8 +954,8 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags
auto pBC3 = reinterpret_cast<D3DX_BC3 *>(pBC);
// Quantize block to A8, using Floyd Stienberg error diffusion. This
// increases the chance that colors will map directly to the quantized
// Quantize block to A8, using Floyd Stienberg error diffusion. This
// increases the chance that colors will map directly to the quantized
// axis endpoints.
float fAlpha[NUM_PIXELS_PER_BLOCK] = {};
float fError[NUM_PIXELS_PER_BLOCK] = {};
@ -978,7 +978,7 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags
if (flags & BC_FLAGS_DITHER_A)
{
const float fDiff = fAlph - fAlpha[i];
float fDiff = fAlph - fAlpha[i];
if (3 != (i & 3))
{
@ -1027,13 +1027,13 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags
}
// Optimize and Quantize Min and Max values
const uint32_t uSteps = ((0.0f == fMinAlpha) || (1.0f == fMaxAlpha)) ? 6u : 8u;
uint32_t uSteps = ((0.0f == fMinAlpha) || (1.0f == fMaxAlpha)) ? 6u : 8u;
float fAlphaA, fAlphaB;
OptimizeAlpha<false>(&fAlphaA, &fAlphaB, fAlpha, uSteps);
const auto bAlphaA = static_cast<uint8_t>(static_cast<int32_t>(fAlphaA * 255.0f + 0.5f));
const auto bAlphaB = static_cast<uint8_t>(static_cast<int32_t>(fAlphaB * 255.0f + 0.5f));
auto bAlphaA = static_cast<uint8_t>(static_cast<int32_t>(fAlphaA * 255.0f + 0.5f));
auto bAlphaB = static_cast<uint8_t>(static_cast<int32_t>(fAlphaB * 255.0f + 0.5f));
fAlphaA = static_cast<float>(bAlphaA) * (1.0f / 255.0f);
fAlphaB = static_cast<float>(bAlphaB) * (1.0f / 255.0f);
@ -1084,8 +1084,8 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags
}
// Encode alpha bitmap
const auto fSteps = static_cast<float>(uSteps - 1);
const float fScale = (fStep[0] != fStep[1]) ? (fSteps / (fStep[1] - fStep[0])) : 0.0f;
auto fSteps = static_cast<float>(uSteps - 1);
float fScale = (fStep[0] != fStep[1]) ? (fSteps / (fStep[1] - fStep[0])) : 0.0f;
if (flags & BC_FLAGS_DITHER_A)
memset(fError, 0x00, NUM_PIXELS_PER_BLOCK * sizeof(float));
@ -1094,15 +1094,15 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags
{
uint32_t dw = 0;
const size_t iMin = iSet * 8;
const size_t iLim = iMin + 8;
size_t iMin = iSet * 8;
size_t iLim = iMin + 8;
for (size_t i = iMin; i < iLim; ++i)
{
float fAlph = Color[i].a;
if (flags & BC_FLAGS_DITHER_A)
fAlph += fError[i];
const float fDot = (fAlph - fStep[0]) * fScale;
float fDot = (fAlph - fStep[0]) * fScale;
uint32_t iStep;
if (fDot <= 0.0f)
@ -1116,7 +1116,7 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags
if (flags & BC_FLAGS_DITHER_A)
{
const float fDiff = (fAlph - fStep[iStep]);
float fDiff = (fAlph - fStep[iStep]);
if (3 != (i & 3))
fError[i + 1] += fDiff * (7.0f / 16.0f);

View File

@ -1,9 +1,9 @@
//-------------------------------------------------------------------------------------
// BC.h
//
//
// Block-compression (BC) functionality
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
@ -11,6 +11,7 @@
#pragma once
#include <assert.h>
#include <DirectXMath.h>
#include <DirectXPackedVector.h>
@ -27,156 +28,141 @@ namespace DirectX
// Constants
//-------------------------------------------------------------------------------------
enum BC_FLAGS : uint32_t
enum BC_FLAGS : uint32_t
{
BC_FLAGS_NONE = 0x0,
BC_FLAGS_DITHER_RGB = 0x10000, // Enables dithering for RGB colors for BC1-3
BC_FLAGS_DITHER_A = 0x20000, // Enables dithering for Alpha channel for BC1-3
BC_FLAGS_UNIFORM = 0x40000, // By default, uses perceptual weighting for BC1-3; this flag makes it a uniform weighting
BC_FLAGS_USE_3SUBSETS = 0x80000, // By default, BC7 skips mode 0 & 2; this flag adds those modes back
BC_FLAGS_FORCE_BC7_MODE6 = 0x100000, // BC7 should only use mode 6; skip other modes
};
//-------------------------------------------------------------------------------------
// Structures
//-------------------------------------------------------------------------------------
class LDRColorA;
class HDRColorA
{
public:
float r, g, b, a;
public:
HDRColorA() = default;
HDRColorA(float _r, float _g, float _b, float _a) noexcept : r(_r), g(_g), b(_b), a(_a) {}
HDRColorA(const HDRColorA& c) noexcept : r(c.r), g(c.g), b(c.b), a(c.a) {}
// binary operators
HDRColorA operator + (const HDRColorA& c) const noexcept
{
BC_FLAGS_NONE = 0x0,
BC_FLAGS_DITHER_RGB = 0x10000,
// Enables dithering for RGB colors for BC1-3
BC_FLAGS_DITHER_A = 0x20000,
// Enables dithering for Alpha channel for BC1-3
BC_FLAGS_UNIFORM = 0x40000,
// By default, uses perceptual weighting for BC1-3; this flag makes it a uniform weighting
BC_FLAGS_USE_3SUBSETS = 0x80000,
// By default, BC7 skips mode 0 & 2; this flag adds those modes back
BC_FLAGS_FORCE_BC7_MODE6 = 0x100000,
// BC7 should only use mode 6; skip other modes
};
//-------------------------------------------------------------------------------------
// Structures
//-------------------------------------------------------------------------------------
class LDRColorA;
class HDRColorA
{
public:
float r, g, b, a;
public:
HDRColorA() = default;
HDRColorA(float _r, float _g, float _b, float _a) noexcept : r(_r), g(_g), b(_b), a(_a) {}
HDRColorA(HDRColorA const&) = default;
HDRColorA& operator= (const HDRColorA&) = default;
HDRColorA(HDRColorA&&) = default;
HDRColorA& operator= (HDRColorA&&) = default;
// binary operators
HDRColorA operator + (const HDRColorA& c) const noexcept
{
return HDRColorA(r + c.r, g + c.g, b + c.b, a + c.a);
}
HDRColorA operator - (const HDRColorA& c) const noexcept
{
return HDRColorA(r - c.r, g - c.g, b - c.b, a - c.a);
}
HDRColorA operator * (float f) const noexcept
{
return HDRColorA(r * f, g * f, b * f, a * f);
}
HDRColorA operator / (float f) const noexcept
{
const float fInv = 1.0f / f;
return HDRColorA(r * fInv, g * fInv, b * fInv, a * fInv);
}
float operator * (const HDRColorA& c) const noexcept
{
return r * c.r + g * c.g + b * c.b + a * c.a;
}
// assignment operators
HDRColorA& operator += (const HDRColorA& c) noexcept
{
r += c.r;
g += c.g;
b += c.b;
a += c.a;
return *this;
}
HDRColorA& operator -= (const HDRColorA& c) noexcept
{
r -= c.r;
g -= c.g;
b -= c.b;
a -= c.a;
return *this;
}
HDRColorA& operator *= (float f) noexcept
{
r *= f;
g *= f;
b *= f;
a *= f;
return *this;
}
HDRColorA& operator /= (float f) noexcept
{
const float fInv = 1.0f / f;
r *= fInv;
g *= fInv;
b *= fInv;
a *= fInv;
return *this;
}
HDRColorA& Clamp(_In_ float fMin, _In_ float fMax) noexcept
{
r = std::min<float>(fMax, std::max<float>(fMin, r));
g = std::min<float>(fMax, std::max<float>(fMin, g));
b = std::min<float>(fMax, std::max<float>(fMin, b));
a = std::min<float>(fMax, std::max<float>(fMin, a));
return *this;
}
HDRColorA(const LDRColorA& c) noexcept;
HDRColorA& operator = (const LDRColorA& c) noexcept;
LDRColorA ToLDRColorA() const noexcept;
};
inline HDRColorA* HDRColorALerp(_Out_ HDRColorA *pOut, _In_ const HDRColorA *pC1, _In_ const HDRColorA *pC2, _In_ float s) noexcept
{
pOut->r = pC1->r + s * (pC2->r - pC1->r);
pOut->g = pC1->g + s * (pC2->g - pC1->g);
pOut->b = pC1->b + s * (pC2->b - pC1->b);
pOut->a = pC1->a + s * (pC2->a - pC1->a);
return pOut;
return HDRColorA(r + c.r, g + c.g, b + c.b, a + c.a);
}
HDRColorA operator - (const HDRColorA& c) const noexcept
{
return HDRColorA(r - c.r, g - c.g, b - c.b, a - c.a);
}
HDRColorA operator * (float f) const noexcept
{
return HDRColorA(r * f, g * f, b * f, a * f);
}
HDRColorA operator / (float f) const noexcept
{
float fInv = 1.0f / f;
return HDRColorA(r * fInv, g * fInv, b * fInv, a * fInv);
}
float operator * (const HDRColorA& c) const noexcept
{
return r * c.r + g * c.g + b * c.b + a * c.a;
}
// assignment operators
HDRColorA& operator += (const HDRColorA& c) noexcept
{
r += c.r;
g += c.g;
b += c.b;
a += c.a;
return *this;
}
HDRColorA& operator -= (const HDRColorA& c) noexcept
{
r -= c.r;
g -= c.g;
b -= c.b;
a -= c.a;
return *this;
}
HDRColorA& operator *= (float f) noexcept
{
r *= f;
g *= f;
b *= f;
a *= f;
return *this;
}
HDRColorA& operator /= (float f) noexcept
{
float fInv = 1.0f / f;
r *= fInv;
g *= fInv;
b *= fInv;
a *= fInv;
return *this;
}
HDRColorA& Clamp(_In_ float fMin, _In_ float fMax) noexcept
{
r = std::min<float>(fMax, std::max<float>(fMin, r));
g = std::min<float>(fMax, std::max<float>(fMin, g));
b = std::min<float>(fMax, std::max<float>(fMin, b));
a = std::min<float>(fMax, std::max<float>(fMin, a));
return *this;
}
HDRColorA(const LDRColorA& c) noexcept;
HDRColorA& operator = (const LDRColorA& c) noexcept;
LDRColorA ToLDRColorA() const noexcept;
};
inline HDRColorA* HDRColorALerp(_Out_ HDRColorA *pOut, _In_ const HDRColorA *pC1, _In_ const HDRColorA *pC2, _In_ float s) noexcept
{
pOut->r = pC1->r + s * (pC2->r - pC1->r);
pOut->g = pC1->g + s * (pC2->g - pC1->g);
pOut->b = pC1->b + s * (pC2->b - pC1->b);
pOut->a = pC1->a + s * (pC2->a - pC1->a);
return pOut;
}
#pragma pack(push,1)
// BC1/DXT1 compression (4 bits per texel)
struct D3DX_BC1
{
uint16_t rgb[2]; // 565 colors
uint32_t bitmap; // 2bpp rgb bitmap
};
struct D3DX_BC1
{
uint16_t rgb[2]; // 565 colors
uint32_t bitmap; // 2bpp rgb bitmap
};
// BC2/DXT2/3 compression (8 bits per texel)
struct D3DX_BC2
{
uint32_t bitmap[2]; // 4bpp alpha bitmap
D3DX_BC1 bc1; // BC1 rgb data
};
// BC2/DXT2/3 compression (8 bits per texel)
struct D3DX_BC2
{
uint32_t bitmap[2]; // 4bpp alpha bitmap
D3DX_BC1 bc1; // BC1 rgb data
};
// BC3/DXT4/5 compression (8 bits per texel)
struct D3DX_BC3
{
uint8_t alpha[2]; // alpha values
uint8_t bitmap[6]; // 3bpp alpha bitmap
D3DX_BC1 bc1; // BC1 rgb data
};
// BC3/DXT4/5 compression (8 bits per texel)
struct D3DX_BC3
{
uint8_t alpha[2]; // alpha values
uint8_t bitmap[6]; // 3bpp alpha bitmap
D3DX_BC1 bc1; // BC1 rgb data
};
#pragma pack(pop)
//-------------------------------------------------------------------------------------
@ -184,162 +170,162 @@ namespace DirectX
//-------------------------------------------------------------------------------------
#pragma warning(push)
#pragma warning(disable : 4127)
template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPoints, uint32_t cSteps) noexcept
template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPoints, uint32_t cSteps) noexcept
{
static const float pC6[] = { 5.0f / 5.0f, 4.0f / 5.0f, 3.0f / 5.0f, 2.0f / 5.0f, 1.0f / 5.0f, 0.0f / 5.0f };
static const float pD6[] = { 0.0f / 5.0f, 1.0f / 5.0f, 2.0f / 5.0f, 3.0f / 5.0f, 4.0f / 5.0f, 5.0f / 5.0f };
static const float pC8[] = { 7.0f / 7.0f, 6.0f / 7.0f, 5.0f / 7.0f, 4.0f / 7.0f, 3.0f / 7.0f, 2.0f / 7.0f, 1.0f / 7.0f, 0.0f / 7.0f };
static const float pD8[] = { 0.0f / 7.0f, 1.0f / 7.0f, 2.0f / 7.0f, 3.0f / 7.0f, 4.0f / 7.0f, 5.0f / 7.0f, 6.0f / 7.0f, 7.0f / 7.0f };
const float *pC = (6 == cSteps) ? pC6 : pC8;
const float *pD = (6 == cSteps) ? pD6 : pD8;
const float MAX_VALUE = 1.0f;
const float MIN_VALUE = (bRange) ? -1.0f : 0.0f;
// Find Min and Max points, as starting point
float fX = MAX_VALUE;
float fY = MIN_VALUE;
if (8 == cSteps)
{
static const float pC6[] = { 5.0f / 5.0f, 4.0f / 5.0f, 3.0f / 5.0f, 2.0f / 5.0f, 1.0f / 5.0f, 0.0f / 5.0f };
static const float pD6[] = { 0.0f / 5.0f, 1.0f / 5.0f, 2.0f / 5.0f, 3.0f / 5.0f, 4.0f / 5.0f, 5.0f / 5.0f };
static const float pC8[] = { 7.0f / 7.0f, 6.0f / 7.0f, 5.0f / 7.0f, 4.0f / 7.0f, 3.0f / 7.0f, 2.0f / 7.0f, 1.0f / 7.0f, 0.0f / 7.0f };
static const float pD8[] = { 0.0f / 7.0f, 1.0f / 7.0f, 2.0f / 7.0f, 3.0f / 7.0f, 4.0f / 7.0f, 5.0f / 7.0f, 6.0f / 7.0f, 7.0f / 7.0f };
const float *pC = (6 == cSteps) ? pC6 : pC8;
const float *pD = (6 == cSteps) ? pD6 : pD8;
constexpr float MAX_VALUE = 1.0f;
constexpr float MIN_VALUE = (bRange) ? -1.0f : 0.0f;
// Find Min and Max points, as starting point
float fX = MAX_VALUE;
float fY = MIN_VALUE;
if (8 == cSteps)
for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++)
{
for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++)
{
if (pPoints[iPoint] < fX)
fX = pPoints[iPoint];
if (pPoints[iPoint] < fX)
fX = pPoints[iPoint];
if (pPoints[iPoint] > fY)
fY = pPoints[iPoint];
}
if (pPoints[iPoint] > fY)
fY = pPoints[iPoint];
}
else
{
for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++)
{
if (pPoints[iPoint] < fX && pPoints[iPoint] > MIN_VALUE)
fX = pPoints[iPoint];
if (pPoints[iPoint] > fY && pPoints[iPoint] < MAX_VALUE)
fY = pPoints[iPoint];
}
if (fX == fY)
{
fY = MAX_VALUE;
}
}
// Use Newton's Method to find local minima of sum-of-squares error.
const auto fSteps = static_cast<float>(cSteps - 1);
for (size_t iIteration = 0; iIteration < 8; iIteration++)
{
if ((fY - fX) < (1.0f / 256.0f))
break;
float const fScale = fSteps / (fY - fX);
// Calculate new steps
float pSteps[8];
for (size_t iStep = 0; iStep < cSteps; iStep++)
pSteps[iStep] = pC[iStep] * fX + pD[iStep] * fY;
if (6 == cSteps)
{
pSteps[6] = MIN_VALUE;
pSteps[7] = MAX_VALUE;
}
// Evaluate function, and derivatives
float dX = 0.0f;
float dY = 0.0f;
float d2X = 0.0f;
float d2Y = 0.0f;
for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++)
{
const float fDot = (pPoints[iPoint] - fX) * fScale;
uint32_t iStep;
if (fDot <= 0.0f)
{
// D3DX10 / D3DX11 didn't take into account the proper minimum value for the bRange (BC4S/BC5S) case
iStep = ((6 == cSteps) && (pPoints[iPoint] <= (fX + MIN_VALUE) * 0.5f)) ? 6u : 0u;
}
else if (fDot >= fSteps)
{
iStep = ((6 == cSteps) && (pPoints[iPoint] >= (fY + MAX_VALUE) * 0.5f)) ? 7u : (cSteps - 1);
}
else
{
iStep = uint32_t(fDot + 0.5f);
}
if (iStep < cSteps)
{
// D3DX had this computation backwards (pPoints[iPoint] - pSteps[iStep])
// this fix improves RMS of the alpha component
const float fDiff = pSteps[iStep] - pPoints[iPoint];
dX += pC[iStep] * fDiff;
d2X += pC[iStep] * pC[iStep];
dY += pD[iStep] * fDiff;
d2Y += pD[iStep] * pD[iStep];
}
}
// Move endpoints
if (d2X > 0.0f)
fX -= dX / d2X;
if (d2Y > 0.0f)
fY -= dY / d2Y;
if (fX > fY)
{
const float f = fX; fX = fY; fY = f;
}
if ((dX * dX < (1.0f / 64.0f)) && (dY * dY < (1.0f / 64.0f)))
break;
}
*pX = (fX < MIN_VALUE) ? MIN_VALUE : (fX > MAX_VALUE) ? MAX_VALUE : fX;
*pY = (fY < MIN_VALUE) ? MIN_VALUE : (fY > MAX_VALUE) ? MAX_VALUE : fY;
}
else
{
for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++)
{
if (pPoints[iPoint] < fX && pPoints[iPoint] > MIN_VALUE)
fX = pPoints[iPoint];
if (pPoints[iPoint] > fY && pPoints[iPoint] < MAX_VALUE)
fY = pPoints[iPoint];
}
if (fX == fY)
{
fY = MAX_VALUE;
}
}
// Use Newton's Method to find local minima of sum-of-squares error.
auto fSteps = static_cast<float>(cSteps - 1);
for (size_t iIteration = 0; iIteration < 8; iIteration++)
{
if ((fY - fX) < (1.0f / 256.0f))
break;
float fScale = fSteps / (fY - fX);
// Calculate new steps
float pSteps[8];
for (size_t iStep = 0; iStep < cSteps; iStep++)
pSteps[iStep] = pC[iStep] * fX + pD[iStep] * fY;
if (6 == cSteps)
{
pSteps[6] = MIN_VALUE;
pSteps[7] = MAX_VALUE;
}
// Evaluate function, and derivatives
float dX = 0.0f;
float dY = 0.0f;
float d2X = 0.0f;
float d2Y = 0.0f;
for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++)
{
float fDot = (pPoints[iPoint] - fX) * fScale;
uint32_t iStep;
if (fDot <= 0.0f)
{
// D3DX10 / D3DX11 didn't take into account the proper minimum value for the bRange (BC4S/BC5S) case
iStep = ((6 == cSteps) && (pPoints[iPoint] <= (fX + MIN_VALUE) * 0.5f)) ? 6u : 0u;
}
else if (fDot >= fSteps)
{
iStep = ((6 == cSteps) && (pPoints[iPoint] >= (fY + MAX_VALUE) * 0.5f)) ? 7u : (cSteps - 1);
}
else
{
iStep = uint32_t(fDot + 0.5f);
}
if (iStep < cSteps)
{
// D3DX had this computation backwards (pPoints[iPoint] - pSteps[iStep])
// this fix improves RMS of the alpha component
float fDiff = pSteps[iStep] - pPoints[iPoint];
dX += pC[iStep] * fDiff;
d2X += pC[iStep] * pC[iStep];
dY += pD[iStep] * fDiff;
d2Y += pD[iStep] * pD[iStep];
}
}
// Move endpoints
if (d2X > 0.0f)
fX -= dX / d2X;
if (d2Y > 0.0f)
fY -= dY / d2Y;
if (fX > fY)
{
float f = fX; fX = fY; fY = f;
}
if ((dX * dX < (1.0f / 64.0f)) && (dY * dY < (1.0f / 64.0f)))
break;
}
*pX = (fX < MIN_VALUE) ? MIN_VALUE : (fX > MAX_VALUE) ? MAX_VALUE : fX;
*pY = (fY < MIN_VALUE) ? MIN_VALUE : (fY > MAX_VALUE) ? MAX_VALUE : fY;
}
#pragma warning(pop)
//-------------------------------------------------------------------------------------
// Functions
//-------------------------------------------------------------------------------------
typedef void (*BC_DECODE)(XMVECTOR *pColor, const uint8_t *pBC);
typedef void (*BC_ENCODE)(uint8_t *pDXT, const XMVECTOR *pColor, uint32_t flags);
typedef void (*BC_DECODE)(XMVECTOR *pColor, const uint8_t *pBC);
typedef void (*BC_ENCODE)(uint8_t *pDXT, const XMVECTOR *pColor, uint32_t flags);
void D3DXDecodeBC1(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC2(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC3(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC4U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC4S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC5U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC5S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC6HU(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC6HS(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC7(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC1(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC2(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC3(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC4U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC4S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC5U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC5S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC6HU(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC6HS(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC7(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float threshold, _In_ uint32_t flags) noexcept;
// BC1 requires one additional parameter, so it doesn't match signature of BC_ENCODE above
void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float threshold, _In_ uint32_t flags) noexcept;
// BC1 requires one additional parameter, so it doesn't match signature of BC_ENCODE above
void D3DXEncodeBC2(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC3(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC4U(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC4S(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC5U(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC5S(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC6HU(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC6HS(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC7(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC2(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC3(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC4U(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC4S(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC5U(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC5S(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC6HU(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC6HS(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC7(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
} // namespace

View File

@ -1,9 +1,9 @@
//-------------------------------------------------------------------------------------
// BC4BC5.cpp
//
//
// Block-compression (BC) functionality for BC4 and BC5 (DirectX 10 texture compression)
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
@ -40,18 +40,18 @@ namespace
{
float R(size_t uOffset) const noexcept
{
const size_t uIndex = GetIndex(uOffset);
size_t uIndex = GetIndex(uOffset);
return DecodeFromIndex(uIndex);
}
float DecodeFromIndex(size_t uIndex) const noexcept
{
if (uIndex == 0)
return float(red_0) / 255.0f;
return red_0 / 255.0f;
if (uIndex == 1)
return float(red_1) / 255.0f;
const float fred_0 = float(red_0) / 255.0f;
const float fred_1 = float(red_1) / 255.0f;
return red_1 / 255.0f;
float fred_0 = red_0 / 255.0f;
float fred_1 = red_1 / 255.0f;
if (red_0 > red_1)
{
uIndex -= 1;
@ -96,21 +96,21 @@ namespace
{
float R(size_t uOffset) const noexcept
{
const size_t uIndex = GetIndex(uOffset);
size_t uIndex = GetIndex(uOffset);
return DecodeFromIndex(uIndex);
}
float DecodeFromIndex(size_t uIndex) const noexcept
{
const int8_t sred_0 = (red_0 == -128) ? -127 : red_0;
const int8_t sred_1 = (red_1 == -128) ? -127 : red_1;
int8_t sred_0 = (red_0 == -128) ? -127 : red_0;
int8_t sred_1 = (red_1 == -128) ? -127 : red_1;
if (uIndex == 0)
return float(sred_0) / 127.0f;
return sred_0 / 127.0f;
if (uIndex == 1)
return float(sred_1) / 127.0f;
const float fred_0 = float(sred_0) / 127.0f;
const float fred_1 = float(sred_1) / 127.0f;
return sred_1 / 127.0f;
float fred_0 = sred_0 / 127.0f;
float fred_1 = sred_1 / 127.0f;
if (red_0 > red_1)
{
uIndex -= 1;
@ -157,7 +157,7 @@ namespace
//-------------------------------------------------------------------------------------
void inline FloatToSNorm(_In_ float fVal, _Out_ int8_t *piSNorm) noexcept
{
constexpr uint32_t dwMostNeg = (1 << (8 * sizeof(int8_t) - 1));
const uint32_t dwMostNeg = (1 << (8 * sizeof(int8_t) - 1));
if (isnan(fVal))
fVal = 0;
@ -186,8 +186,8 @@ namespace
_Out_ uint8_t &endpointU_1) noexcept
{
// The boundary of codec for signed/unsigned format
constexpr float MIN_NORM = 0.f;
constexpr float MAX_NORM = 1.f;
const float MIN_NORM = 0.f;
const float MAX_NORM = 1.f;
// Find max/min of input texels
float fBlockMax = theTexelsU[0];
@ -206,7 +206,7 @@ namespace
// If there are boundary values in input texels, should use 4 interpolated color values to guarantee
// the exact code of the boundary values.
const bool bUsing4BlockCodec = (MIN_NORM == fBlockMin || MAX_NORM == fBlockMax);
bool bUsing4BlockCodec = (MIN_NORM == fBlockMin || MAX_NORM == fBlockMax);
// Using Optimize
float fStart, fEnd;
@ -241,8 +241,8 @@ namespace
_Out_ int8_t &endpointU_1) noexcept
{
// The boundary of codec for signed/unsigned format
constexpr float MIN_NORM = -1.f;
constexpr float MAX_NORM = 1.f;
const float MIN_NORM = -1.f;
const float MAX_NORM = 1.f;
// Find max/min of input texels
float fBlockMax = theTexelsU[0];
@ -261,7 +261,7 @@ namespace
// If there are boundary values in input texels, should use 4 interpolated color values to guarantee
// the exact code of the boundary values.
const bool bUsing4BlockCodec = (MIN_NORM == fBlockMin || MAX_NORM == fBlockMax);
bool bUsing4BlockCodec = (MIN_NORM == fBlockMin || MAX_NORM == fBlockMax);
// Using Optimize
float fStart, fEnd;
@ -338,7 +338,7 @@ namespace
float fBestDelta = 100000;
for (size_t uIndex = 0; uIndex < 8; uIndex++)
{
const float fCurrentDelta = fabsf(rGradient[uIndex] - theTexelsU[i]);
float fCurrentDelta = fabsf(rGradient[uIndex] - theTexelsU[i]);
if (fCurrentDelta < fBestDelta)
{
uBestIndex = uIndex;
@ -365,7 +365,7 @@ namespace
float fBestDelta = 100000;
for (size_t uIndex = 0; uIndex < 8; uIndex++)
{
const float fCurrentDelta = fabsf(rGradient[uIndex] - theTexelsU[i]);
float fCurrentDelta = fabsf(rGradient[uIndex] - theTexelsU[i]);
if (fCurrentDelta < fBestDelta)
{
uBestIndex = uIndex;
@ -395,7 +395,7 @@ void DirectX::D3DXDecodeBC4U(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSet(pBC4->R(i), 0, 0, 1.0f);
}
}
@ -410,7 +410,7 @@ void DirectX::D3DXDecodeBC4S(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSet(pBC4->R(i), 0, 0, 1.0f);
}
}
@ -472,7 +472,7 @@ void DirectX::D3DXDecodeBC5U(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSet(pBCR->R(i), pBCG->R(i), 0, 1.0f);
}
}
@ -488,7 +488,7 @@ void DirectX::D3DXDecodeBC5S(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSet(pBCR->R(i), pBCG->R(i), 0, 1.0f);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
//-------------------------------------------------------------------------------------
// BCDirectCompute.cpp
//
//
// Direct3D 11 Compute Shader BC Compressor
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------
@ -20,27 +20,13 @@ using Microsoft::WRL::ComPtr;
namespace
{
namespace cs5
{
#include "BC7Encode_EncodeBlockCS.inc"
#include "BC7Encode_TryMode02CS.inc"
#include "BC7Encode_TryMode137CS.inc"
#include "BC7Encode_TryMode456CS.inc"
#include "BC6HEncode_EncodeBlockCS.inc"
#include "BC6HEncode_TryModeG10CS.inc"
#include "BC6HEncode_TryModeLE10CS.inc"
}
namespace cs4
{
#include "BC7Encode_EncodeBlockCS_cs40.inc"
#include "BC7Encode_TryMode02CS_cs40.inc"
#include "BC7Encode_TryMode137CS_cs40.inc"
#include "BC7Encode_TryMode456CS_cs40.inc"
#include "BC6HEncode_EncodeBlockCS_cs40.inc"
#include "BC6HEncode_TryModeG10CS_cs40.inc"
#include "BC6HEncode_TryModeLE10CS_cs40.inc"
}
#include "Shaders\Compiled\BC7Encode_EncodeBlockCS.inc"
#include "Shaders\Compiled\BC7Encode_TryMode02CS.inc"
#include "Shaders\Compiled\BC7Encode_TryMode137CS.inc"
#include "Shaders\Compiled\BC7Encode_TryMode456CS.inc"
#include "Shaders\Compiled\BC6HEncode_EncodeBlockCS.inc"
#include "Shaders\Compiled\BC6HEncode_TryModeG10CS.inc"
#include "Shaders\Compiled\BC6HEncode_TryModeLE10CS.inc"
struct BufferBC6HBC7
{
@ -101,7 +87,8 @@ GPUCompressBC::GPUCompressBC() noexcept :
m_bc7_mode137(false),
m_width(0),
m_height(0)
{}
{
}
//-------------------------------------------------------------------------------------
@ -112,12 +99,12 @@ HRESULT GPUCompressBC::Initialize(ID3D11Device* pDevice)
return E_INVALIDARG;
// Check for DirectCompute support
const D3D_FEATURE_LEVEL fl = pDevice->GetFeatureLevel();
D3D_FEATURE_LEVEL fl = pDevice->GetFeatureLevel();
if (fl < D3D_FEATURE_LEVEL_10_0)
{
// DirectCompute not supported on Feature Level 9.x hardware
return HRESULT_E_NOT_SUPPORTED;
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
if (fl < D3D_FEATURE_LEVEL_11_0)
@ -132,7 +119,7 @@ HRESULT GPUCompressBC::Initialize(ID3D11Device* pDevice)
if (!hwopts.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x)
{
return HRESULT_E_NOT_SUPPORTED;
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
}
@ -145,53 +132,39 @@ HRESULT GPUCompressBC::Initialize(ID3D11Device* pDevice)
//--- Create compute shader library: BC6H -----------------------------------------
// Modes 11-14
auto blob = (fl >= D3D_FEATURE_LEVEL_11_0) ? cs5::BC6HEncode_TryModeG10CS : cs4::BC6HEncode_TryModeG10CS;
auto blobSize = (fl >= D3D_FEATURE_LEVEL_11_0) ? sizeof(cs5::BC6HEncode_TryModeG10CS) : sizeof(cs4::BC6HEncode_TryModeG10CS);
HRESULT hr = pDevice->CreateComputeShader(blob, blobSize, nullptr, m_BC6H_tryModeG10CS.ReleaseAndGetAddressOf());
HRESULT hr = pDevice->CreateComputeShader(BC6HEncode_TryModeG10CS, sizeof(BC6HEncode_TryModeG10CS), nullptr, m_BC6H_tryModeG10CS.ReleaseAndGetAddressOf());
if (FAILED(hr))
return hr;
// Modes 1-10
blob = (fl >= D3D_FEATURE_LEVEL_11_0) ? cs5::BC6HEncode_TryModeLE10CS : cs4::BC6HEncode_TryModeLE10CS;
blobSize = (fl >= D3D_FEATURE_LEVEL_11_0) ? sizeof(cs5::BC6HEncode_TryModeLE10CS) : sizeof(cs4::BC6HEncode_TryModeLE10CS);
hr = pDevice->CreateComputeShader(blob, blobSize, nullptr, m_BC6H_tryModeLE10CS.ReleaseAndGetAddressOf());
hr = pDevice->CreateComputeShader(BC6HEncode_TryModeLE10CS, sizeof(BC6HEncode_TryModeLE10CS), nullptr, m_BC6H_tryModeLE10CS.ReleaseAndGetAddressOf());
if (FAILED(hr))
return hr;
// Encode
blob = (fl >= D3D_FEATURE_LEVEL_11_0) ? cs5::BC6HEncode_EncodeBlockCS : cs4::BC6HEncode_EncodeBlockCS;
blobSize = (fl >= D3D_FEATURE_LEVEL_11_0) ? sizeof(cs5::BC6HEncode_EncodeBlockCS) : sizeof(cs4::BC6HEncode_EncodeBlockCS);
hr = pDevice->CreateComputeShader(blob, blobSize, nullptr, m_BC6H_encodeBlockCS.ReleaseAndGetAddressOf());
hr = pDevice->CreateComputeShader(BC6HEncode_EncodeBlockCS, sizeof(BC6HEncode_EncodeBlockCS), nullptr, m_BC6H_encodeBlockCS.ReleaseAndGetAddressOf());
if (FAILED(hr))
return hr;
//--- Create compute shader library: BC7 ------------------------------------------
// Modes 4, 5, 6
blob = (fl >= D3D_FEATURE_LEVEL_11_0) ? cs5::BC7Encode_TryMode456CS : cs4::BC7Encode_TryMode456CS;
blobSize = (fl >= D3D_FEATURE_LEVEL_11_0) ? sizeof(cs5::BC7Encode_TryMode456CS) : sizeof(cs4::BC7Encode_TryMode456CS);
hr = pDevice->CreateComputeShader(blob, blobSize, nullptr, m_BC7_tryMode456CS.ReleaseAndGetAddressOf());
hr = pDevice->CreateComputeShader(BC7Encode_TryMode456CS, sizeof(BC7Encode_TryMode456CS), nullptr, m_BC7_tryMode456CS.ReleaseAndGetAddressOf());
if (FAILED(hr))
return hr;
// Modes 1, 3, 7
blob = (fl >= D3D_FEATURE_LEVEL_11_0) ? cs5::BC7Encode_TryMode137CS : cs4::BC7Encode_TryMode137CS;
blobSize = (fl >= D3D_FEATURE_LEVEL_11_0) ? sizeof(cs5::BC7Encode_TryMode137CS) : sizeof(cs4::BC7Encode_TryMode137CS);
hr = pDevice->CreateComputeShader(blob, blobSize, nullptr, m_BC7_tryMode137CS.ReleaseAndGetAddressOf());
hr = pDevice->CreateComputeShader(BC7Encode_TryMode137CS, sizeof(BC7Encode_TryMode137CS), nullptr, m_BC7_tryMode137CS.ReleaseAndGetAddressOf());
if (FAILED(hr))
return hr;
// Modes 0, 2
blob = (fl >= D3D_FEATURE_LEVEL_11_0) ? cs5::BC7Encode_TryMode02CS : cs4::BC7Encode_TryMode02CS;
blobSize = (fl >= D3D_FEATURE_LEVEL_11_0) ? sizeof(cs5::BC7Encode_TryMode02CS) : sizeof(cs4::BC7Encode_TryMode02CS);
hr = pDevice->CreateComputeShader(blob, blobSize, nullptr, m_BC7_tryMode02CS.ReleaseAndGetAddressOf());
hr = pDevice->CreateComputeShader(BC7Encode_TryMode02CS, sizeof(BC7Encode_TryMode02CS), nullptr, m_BC7_tryMode02CS.ReleaseAndGetAddressOf());
if (FAILED(hr))
return hr;
// Encode
blob = (fl >= D3D_FEATURE_LEVEL_11_0) ? cs5::BC7Encode_EncodeBlockCS : cs4::BC7Encode_EncodeBlockCS;
blobSize = (fl >= D3D_FEATURE_LEVEL_11_0) ? sizeof(cs5::BC7Encode_EncodeBlockCS) : sizeof(cs4::BC7Encode_EncodeBlockCS);
hr = pDevice->CreateComputeShader(blob, blobSize, nullptr, m_BC7_encodeBlockCS.ReleaseAndGetAddressOf());
hr = pDevice->CreateComputeShader(BC7Encode_EncodeBlockCS, sizeof(BC7Encode_EncodeBlockCS), nullptr, m_BC7_encodeBlockCS.ReleaseAndGetAddressOf());
if (FAILED(hr))
return hr;
@ -224,9 +197,9 @@ HRESULT GPUCompressBC::Prepare(size_t width, size_t height, uint32_t flags, DXGI
m_bc7_mode137 = true;
}
const size_t xblocks = std::max<size_t>(1, (width + 3) >> 2);
const size_t yblocks = std::max<size_t>(1, (height + 3) >> 2);
const size_t num_blocks = xblocks * yblocks;
size_t xblocks = std::max<size_t>(1, (width + 3) >> 2);
size_t yblocks = std::max<size_t>(1, (height + 3) >> 2);
size_t num_blocks = xblocks * yblocks;
switch (format)
{
@ -249,7 +222,7 @@ HRESULT GPUCompressBC::Prepare(size_t width, size_t height, uint32_t flags, DXGI
default:
m_bcformat = m_srcformat = DXGI_FORMAT_UNKNOWN;
return HRESULT_E_NOT_SUPPORTED;
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
m_bcformat = format;
@ -259,11 +232,11 @@ HRESULT GPUCompressBC::Prepare(size_t width, size_t height, uint32_t flags, DXGI
return E_POINTER;
// Create structured buffers
const uint64_t sizeInBytes = uint64_t(num_blocks) * sizeof(BufferBC6HBC7);
uint64_t sizeInBytes = uint64_t(num_blocks) * sizeof(BufferBC6HBC7);
if (sizeInBytes >= UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW;
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
const auto bufferSize = static_cast<size_t>(sizeInBytes);
auto bufferSize = static_cast<size_t>(sizeInBytes);
{
D3D11_BUFFER_DESC desc = {};
@ -379,6 +352,7 @@ HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage)
|| srcImage.height != destImage.height
|| srcImage.width != m_width
|| srcImage.height != m_height
|| srcImage.format != m_srcformat
|| destImage.format != m_bcformat)
{
return E_UNEXPECTED;
@ -390,7 +364,7 @@ HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage)
return E_POINTER;
// We need to avoid the hardware doing additional colorspace conversion
const DXGI_FORMAT inputFormat = (m_srcformat == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) ? DXGI_FORMAT_R8G8B8A8_UNORM : m_srcformat;
DXGI_FORMAT inputFormat = (m_srcformat == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) ? DXGI_FORMAT_R8G8B8A8_UNORM : m_srcformat;
ComPtr<ID3D11Texture2D> sourceTex;
{
@ -449,22 +423,22 @@ HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage)
return E_UNEXPECTED;
}
constexpr UINT MAX_BLOCK_BATCH = 64u;
const UINT MAX_BLOCK_BATCH = 64;
auto pContext = m_context.Get();
if (!pContext)
return E_UNEXPECTED;
const size_t xblocks = std::max<size_t>(1, (m_width + 3) >> 2);
const size_t yblocks = std::max<size_t>(1, (m_height + 3) >> 2);
size_t xblocks = std::max<size_t>(1, (m_width + 3) >> 2);
size_t yblocks = std::max<size_t>(1, (m_height + 3) >> 2);
const auto num_total_blocks = static_cast<UINT>(xblocks * yblocks);
auto num_total_blocks = static_cast<UINT>(xblocks * yblocks);
UINT num_blocks = num_total_blocks;
UINT start_block_id = 0;
while (num_blocks > 0)
{
const UINT n = std::min<UINT>(num_blocks, MAX_BLOCK_BATCH);
const UINT uThreadGroupCount = n;
UINT n = std::min<UINT>(num_blocks, MAX_BLOCK_BATCH);
UINT uThreadGroupCount = n;
{
D3D11_MAPPED_SUBRESOURCE mapped;
@ -623,9 +597,9 @@ HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage)
auto pSrc = static_cast<const uint8_t *>(mapped.pData);
uint8_t *pDest = destImage.pixels;
const size_t pitch = xblocks * sizeof(BufferBC6HBC7);
size_t pitch = xblocks * sizeof(BufferBC6HBC7);
const size_t rows = std::max<size_t>(1, (destImage.height + 3) >> 2);
size_t rows = std::max<size_t>(1, (destImage.height + 3) >> 2);
for (size_t h = 0; h < rows; ++h)
{

View File

@ -1,9 +1,9 @@
//-------------------------------------------------------------------------------------
// BCDirectCompute.h
//
//
// Direct3D 11 Compute Shader BC Compressor
//
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------
@ -17,12 +17,6 @@ namespace DirectX
public:
GPUCompressBC() noexcept;
GPUCompressBC(GPUCompressBC&&) = default;
GPUCompressBC& operator= (GPUCompressBC&&) = default;
GPUCompressBC(GPUCompressBC const&) = delete;
GPUCompressBC& operator= (GPUCompressBC const&) = delete;
HRESULT Initialize(_In_ ID3D11Device* pDevice);
HRESULT Prepare(size_t width, size_t height, uint32_t flags, DXGI_FORMAT format, float alphaWeight);

Some files were not shown because too many files have changed in this diff Show More