├── .azuredevops
├── pipelines
│ ├── DirectXTK-GitHub-CMake-Dev17.yml
│ ├── DirectXTK-GitHub-CMake.yml
│ ├── DirectXTK-GitHub-Dev17.yml
│ ├── DirectXTK-GitHub-GDK-Dev17.yml
│ ├── DirectXTK-GitHub-GDK.yml
│ ├── DirectXTK-GitHub-MinGW.yml
│ ├── DirectXTK-GitHub-SDK-prerelease.yml
│ ├── DirectXTK-GitHub-SDK-release.yml
│ ├── DirectXTK-GitHub-Test-Dev17.yml
│ ├── DirectXTK-GitHub-Test.yml
│ ├── DirectXTK-GitHub-WSL-11.yml
│ ├── DirectXTK-GitHub-WSL-13.yml
│ ├── DirectXTK-GitHub.yml
│ ├── DirectXTK-OneFuzz-Audio.yml
│ ├── DirectXTK-OneFuzz-Coverage.yml
│ ├── DirectXTK-OneFuzz-Meshes.yml
│ ├── DirectXTK-OneFuzz.yml
│ └── DirectXTK-SDL.yml
├── policies
│ └── approvercountpolicy.yml
└── templates
│ ├── DirectXTK-build-uwp-arm64.yml
│ ├── DirectXTK-build-uwp.yml
│ └── DirectXTK-build-win32.yml
├── .editorconfig
├── .gitattributes
├── .github
├── dependabot.yml
├── linters
│ ├── .editorconfig-checker.json
│ ├── .markdown-lint.yml
│ ├── .powershell-psscriptanalyzer.psd1
│ └── .yaml-lint.yml
└── workflows
│ ├── bvt.yml
│ ├── codeql.yml
│ ├── lint.yml
│ ├── main.yml
│ ├── msbuild.yml
│ ├── msvc.yml
│ ├── test.yml
│ ├── uwp.yml
│ ├── vcpkg.yml
│ └── win10.yml
├── .gitignore
├── .nuget
├── directxtk_desktop_2019.nuspec
├── directxtk_desktop_2019.targets
├── directxtk_desktop_win10.nuspec
├── directxtk_desktop_win10.targets
├── directxtk_uwp.nuspec
├── directxtk_uwp.targets
└── icon.jpg
├── .onefuzz
├── Audio
├── AudioEngine.cpp
├── DynamicSoundEffectInstance.cpp
├── SoundCommon.cpp
├── SoundCommon.h
├── SoundEffect.cpp
├── SoundEffectInstance.cpp
├── SoundStreamInstance.cpp
├── WAVFileReader.cpp
├── WAVFileReader.h
├── WaveBank.cpp
├── WaveBankReader.cpp
└── WaveBankReader.h
├── CHANGELOG.md
├── CMakeLists.txt
├── CMakePresets.json
├── CODE_OF_CONDUCT.md
├── DirectXTK_Desktop_2019.sln
├── DirectXTK_Desktop_2019.vcxproj
├── DirectXTK_Desktop_2019.vcxproj.filters
├── DirectXTK_Desktop_2019_Win10.sln
├── DirectXTK_Desktop_2019_Win10.vcxproj
├── DirectXTK_Desktop_2019_Win10.vcxproj.filters
├── DirectXTK_Desktop_2022.sln
├── DirectXTK_Desktop_2022.vcxproj
├── DirectXTK_Desktop_2022.vcxproj.filters
├── DirectXTK_Desktop_2022_Win10.sln
├── DirectXTK_Desktop_2022_Win10.vcxproj
├── DirectXTK_Desktop_2022_Win10.vcxproj.filters
├── DirectXTK_GDK_2019.sln
├── DirectXTK_GDK_2019.vcxproj
├── DirectXTK_GDK_2019.vcxproj.filters
├── DirectXTK_GDK_2022.sln
├── DirectXTK_GDK_2022.vcxproj
├── DirectXTK_GDK_2022.vcxproj.filters
├── DirectXTK_Windows10_2022.sln
├── DirectXTK_Windows10_2022.vcxproj
├── DirectXTK_Windows10_2022.vcxproj.filters
├── Inc
├── Audio.h
├── BufferHelpers.h
├── CommonStates.h
├── DDSTextureLoader.h
├── DirectXHelpers.h
├── Effects.h
├── GamePad.h
├── GeometricPrimitive.h
├── GraphicsMemory.h
├── Keyboard.h
├── Model.h
├── Mouse.h
├── PostProcess.h
├── PrimitiveBatch.h
├── ScreenGrab.h
├── SimpleMath.h
├── SimpleMath.inl
├── SpriteBatch.h
├── SpriteFont.h
├── VertexTypes.h
├── WICTextureLoader.h
└── XboxDDSTextureLoader.h
├── LICENSE
├── MakeSpriteFont
├── BitmapImporter.cs
├── BitmapUtils.cs
├── CharacterRegion.cs
├── CommandLineOptions.cs
├── CommandLineParser.cs
├── Glyph.cs
├── GlyphCropper.cs
├── GlyphPacker.cs
├── IFontImporter.cs
├── MakeSpriteFont.csproj
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── SpriteFontWriter.cs
└── TrueTypeImporter.cs
├── README.md
├── SECURITY.md
├── Src
├── AlignedNew.h
├── AlphaTestEffect.cpp
├── BasicEffect.cpp
├── BasicPostProcess.cpp
├── Bezier.h
├── BinaryReader.cpp
├── BinaryReader.h
├── BufferHelpers.cpp
├── CMO.h
├── CommonStates.cpp
├── DDS.h
├── DDSTextureLoader.cpp
├── DGSLEffect.cpp
├── DGSLEffectFactory.cpp
├── DebugEffect.cpp
├── DemandCreate.h
├── DirectXHelpers.cpp
├── DualPostProcess.cpp
├── DualTextureEffect.cpp
├── EffectCommon.cpp
├── EffectCommon.h
├── EffectFactory.cpp
├── EnvironmentMapEffect.cpp
├── GamePad.cpp
├── GeometricPrimitive.cpp
├── Geometry.cpp
├── Geometry.h
├── GraphicsMemory.cpp
├── Keyboard.cpp
├── LoaderHelpers.h
├── Model.cpp
├── ModelLoadCMO.cpp
├── ModelLoadSDKMESH.cpp
├── ModelLoadVBO.cpp
├── Mouse.cpp
├── NormalMapEffect.cpp
├── PBREffect.cpp
├── PBREffectFactory.cpp
├── PlatformHelpers.h
├── PrimitiveBatch.cpp
├── SDKMesh.h
├── ScreenGrab.cpp
├── Shaders
│ ├── AlphaTestEffect.fx
│ ├── BasicEffect.fx
│ ├── Common.fxh
│ ├── CompileShaders.cmd
│ ├── DGSLEffect.fx
│ ├── DGSLLambert.hlsl
│ ├── DGSLPhong.hlsl
│ ├── DGSLUnlit.hlsl
│ ├── DebugEffect.fx
│ ├── DualTextureEffect.fx
│ ├── EnvironmentMapEffect.fx
│ ├── Lighting.fxh
│ ├── NormalMapEffect.fx
│ ├── PBRCommon.fxh
│ ├── PBREffect.fx
│ ├── PixelPacking_Velocity.hlsli
│ ├── PostProcess.fx
│ ├── SkinnedEffect.fx
│ ├── Skinning.fxh
│ ├── SpriteEffect.fx
│ ├── Structures.fxh
│ ├── ToneMap.fx
│ └── Utilities.fxh
├── SharedResourcePool.h
├── SimpleMath.cpp
├── SkinnedEffect.cpp
├── SpriteBatch.cpp
├── SpriteFont.cpp
├── TeapotData.inc
├── ToneMapPostProcess.cpp
├── VertexTypes.cpp
├── WICTextureLoader.cpp
├── XboxDDSTextureLoader.cpp
├── pch.cpp
├── pch.h
└── vbo.h
├── XWBTool
├── CmdLineHelpers.h
├── directx.ico
├── settings.manifest
├── xwbtool.cpp
├── xwbtool.rc
├── xwbtool_Desktop_2019.vcxproj
├── xwbtool_Desktop_2019.vcxproj.filters
├── xwbtool_Desktop_2022.vcxproj
└── xwbtool_Desktop_2022.vcxproj.filters
└── build
├── CompilerAndLinker.cmake
├── CopyASan.targets
├── DirectXTK-config.cmake.in
├── DirectXTK.pc.in
├── DirectXTK.rc.in
├── Directory.Build.props
├── JoinPaths.cmake
├── OneFuzzConfig.json
├── SetupBWOI.cmd
├── SetupBWOI.targets
├── onefuzz-setup.ps1
├── preparerelease.ps1
├── vcpkg.json
└── versioninfo.ps1
/.azuredevops/pipelines/DirectXTK-GitHub-Dev17.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | # Builds the library for Windows Desktop and UWP.
7 |
8 | schedules:
9 | - cron: "0 2 * * *"
10 | displayName: 'Nightly build'
11 | branches:
12 | include:
13 | - main
14 |
15 | # GitHub Actions handles MSBuild for CI/PR
16 | trigger: none
17 | pr:
18 | branches:
19 | include:
20 | - main
21 | paths:
22 | include:
23 | - '.azuredevops/pipelines/DirectXTK-GitHub-Dev17.yml'
24 | - Src/Shaders/CompileShaders.cmd
25 |
26 | resources:
27 | repositories:
28 | - repository: self
29 | type: git
30 | ref: refs/heads/main
31 |
32 | name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
33 |
34 | pool:
35 | vmImage: windows-2022
36 |
37 | variables:
38 | - group: dxtk-shared-variables
39 | - name: Codeql.Enabled
40 | value: false
41 | - name: GUID_FEED
42 | value: $(ADOFeedGUID)
43 |
44 | jobs:
45 | - job: DESKTOP_BUILD
46 | displayName: 'Windows Desktop'
47 | timeoutInMinutes: 120
48 | cancelTimeoutInMinutes: 1
49 | strategy:
50 | maxParallel: 3
51 | matrix:
52 | Release_arm64:
53 | BuildPlatform: ARM64
54 | BuildConfiguration: Release
55 | Debug_arm64:
56 | BuildPlatform: ARM64
57 | BuildConfiguration: Debug
58 | Release_x64:
59 | BuildPlatform: x64
60 | BuildConfiguration: Release
61 | Debug_x64:
62 | BuildPlatform: x64
63 | BuildConfiguration: Debug
64 | Release_x86:
65 | BuildPlatform: x86
66 | BuildConfiguration: Release
67 | Debug_x86:
68 | BuildPlatform: x86
69 | BuildConfiguration: Debug
70 | Release_Mixed:
71 | BuildPlatform: 'Mixed Platforms'
72 | BuildConfiguration: Release
73 | Debug_Mixed:
74 | BuildPlatform: 'Mixed Platforms'
75 | BuildConfiguration: Debug
76 | steps:
77 | - checkout: self
78 | clean: true
79 | fetchTags: false
80 | - task: VSBuild@1
81 | displayName: Build solution DirectXTK_Desktop_2022.sln
82 | inputs:
83 | solution: DirectXTK_Desktop_2022.sln
84 | msbuildArgs: /p:PreferredToolArchitecture=x64
85 | platform: '$(BuildPlatform)'
86 | configuration: '$(BuildConfiguration)'
87 | msbuildArchitecture: x64
88 | condition: ne(variables['BuildPlatform'], 'ARM64')
89 | - task: VSBuild@1
90 | displayName: Build solution DirectXTK_Desktop_2022_Win10.sln
91 | inputs:
92 | solution: DirectXTK_Desktop_2022_Win10.sln
93 | msbuildArgs: /p:PreferredToolArchitecture=x64
94 | platform: '$(BuildPlatform)'
95 | configuration: '$(BuildConfiguration)'
96 | msbuildArchitecture: x64
97 |
98 | - job: UWP_BUILD
99 | displayName: 'Universal Windows Platform (UWP)'
100 | timeoutInMinutes: 120
101 | cancelTimeoutInMinutes: 1
102 | strategy:
103 | maxParallel: 3
104 | matrix:
105 | Release_arm64:
106 | BuildPlatform: ARM64
107 | BuildConfiguration: Release
108 | Debug_arm64:
109 | BuildPlatform: ARM64
110 | BuildConfiguration: Debug
111 | Release_x64:
112 | BuildPlatform: x64
113 | BuildConfiguration: Release
114 | Debug_x64:
115 | BuildPlatform: x64
116 | BuildConfiguration: Debug
117 | Release_x86:
118 | BuildPlatform: x86
119 | BuildConfiguration: Release
120 | Debug_x86:
121 | BuildPlatform: x86
122 | BuildConfiguration: Debug
123 | steps:
124 | - checkout: self
125 | clean: true
126 | fetchTags: false
127 | - task: VSBuild@1
128 | displayName: Build solution DirectXTK_Windows10_2022.sln
129 | inputs:
130 | solution: DirectXTK_Windows10_2022.sln
131 | msbuildArgs: /p:PreferredToolArchitecture=x64
132 | platform: '$(BuildPlatform)'
133 | configuration: '$(BuildConfiguration)'
134 | msbuildArchitecture: x64
135 |
--------------------------------------------------------------------------------
/.azuredevops/pipelines/DirectXTK-GitHub.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | # Builds the library for Windows Desktop.
7 |
8 | schedules:
9 | - cron: "0 2 * * *"
10 | displayName: 'Nightly build'
11 | branches:
12 | include:
13 | - main
14 |
15 | # GitHub Actions handles MSBuild for CI/PR
16 | trigger: none
17 | pr:
18 | branches:
19 | include:
20 | - main
21 | paths:
22 | include:
23 | - '.azuredevops/pipelines/DirectXTK-GitHub.yml'
24 | - Src/Shaders/CompileShaders.cmd
25 |
26 | resources:
27 | repositories:
28 | - repository: self
29 | type: git
30 | ref: refs/heads/main
31 |
32 | name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
33 |
34 | pool:
35 | vmImage: windows-2019
36 |
37 | variables:
38 | - group: dxtk-shared-variables
39 | - name: Codeql.Enabled
40 | value: false
41 | - name: GUID_FEED
42 | value: $(ADOFeedGUID)
43 |
44 | jobs:
45 | - job: DESKTOP_BUILD
46 | displayName: 'Windows Desktop'
47 | timeoutInMinutes: 120
48 | cancelTimeoutInMinutes: 1
49 | strategy:
50 | maxParallel: 2
51 | matrix:
52 | Release_x64:
53 | BuildPlatform: x64
54 | BuildConfiguration: Release
55 | Debug_x64:
56 | BuildPlatform: x64
57 | BuildConfiguration: Debug
58 | Release_x86:
59 | BuildPlatform: x86
60 | BuildConfiguration: Release
61 | Debug_x86:
62 | BuildPlatform: x86
63 | BuildConfiguration: Debug
64 | Release_Mixed:
65 | BuildPlatform: 'Mixed Platforms'
66 | BuildConfiguration: Release
67 | Debug_Mixed:
68 | BuildPlatform: 'Mixed Platforms'
69 | BuildConfiguration: Debug
70 | steps:
71 | - checkout: self
72 | clean: true
73 | fetchTags: false
74 | - task: VSBuild@1
75 | displayName: Build solution DirectXTK_Desktop_2019.sln
76 | inputs:
77 | solution: DirectXTK_Desktop_2019.sln
78 | msbuildArgs: /p:PreferredToolArchitecture=x64
79 | platform: '$(BuildPlatform)'
80 | configuration: '$(BuildConfiguration)'
81 | - task: VSBuild@1
82 | displayName: Build solution DirectXTK_Desktop_2019_Win10.sln
83 | inputs:
84 | solution: DirectXTK_Desktop_2019_Win10.sln
85 | msbuildArgs: /p:PreferredToolArchitecture=x64
86 | platform: '$(BuildPlatform)'
87 | configuration: '$(BuildConfiguration)'
88 |
--------------------------------------------------------------------------------
/.azuredevops/pipelines/DirectXTK-OneFuzz-Audio.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # https://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | # Builds the library using CMake and submit for file fuzzing for audio formats
7 |
8 | schedules:
9 | - cron: "0 11 10 * *"
10 | displayName: 'Submit for File Fuzzing (Monthly)'
11 | branches:
12 | include:
13 | - main
14 | always: true
15 |
16 | trigger: none
17 | pr: none
18 |
19 | resources:
20 | repositories:
21 | - repository: self
22 | type: git
23 | ref: refs/heads/main
24 | - repository: testRepo
25 | name: walbourn/directxtktest
26 | type: github
27 | endpoint: microsoft
28 | ref: refs/heads/main
29 |
30 | name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
31 |
32 | variables:
33 | Codeql.Enabled: false
34 | VS_GENERATOR: 'Visual Studio 17 2022'
35 | WIN11_SDK: '10.0.22000.0'
36 |
37 | pool:
38 | vmImage: windows-2022
39 |
40 | jobs:
41 | - job: FUZZ_BUILD
42 | displayName: 'Build for file fuzzing (WAV, XWB)'
43 | steps:
44 | - checkout: self
45 | clean: true
46 | fetchTags: false
47 | fetchDepth: 1
48 | path: 's'
49 | - checkout: testRepo
50 | displayName: Fetch Tests
51 | clean: true
52 | fetchTags: false
53 | fetchDepth: 1
54 | path: 's/Tests'
55 | - task: CMake@1
56 | displayName: 'CMake (MSVC): Config with ASan'
57 | inputs:
58 | cwd: $(Build.SourcesDirectory)
59 | cmakeArgs: >
60 | -G "$(VS_GENERATOR)" -A x64 -B out
61 | -DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)
62 | -DBUILD_TOOLS=OFF -DBUILD_XAUDIO_WIN10=ON -DBUILD_FUZZING=ON -DBUILD_TESTING=OFF
63 | -DBUILD_AUDIO_FUZZING=ON
64 | - task: CMake@1
65 | displayName: 'CMake (MSVC): Build with ASan'
66 | inputs:
67 | cwd: $(Build.SourcesDirectory)
68 | cmakeArgs: --build out -v --config RelWithDebInfo
69 | - task: CopyFiles@2
70 | displayName: Copy fuzzer
71 | inputs:
72 | Contents: |
73 | build\OneFuzzConfig.json
74 | out\bin\RelWithDebInfo\fuzzloaders.exe
75 | TargetFolder: .drop
76 | OverWrite: true
77 | flattenFolders: true
78 | - task: CopyFiles@2
79 | displayName: Copy symbols
80 | inputs:
81 | Contents: |
82 | out\bin\RelWithDebInfo\fuzzloaders.pdb
83 | TargetFolder: .drop\symbols
84 | OverWrite: true
85 | flattenFolders: true
86 | - task: CopyFiles@2
87 | displayName: Copy seed files
88 | inputs:
89 | Contents: |
90 | Tests\BasicAudioTest\Alarm01.wav
91 | Tests\BasicAudioTest\Alarm01_adpcm.wav
92 | Tests\BasicAudioTest\Alarm01_float.wav
93 | Tests\BasicAudioTest\Alarm01_xwma.wav
94 | Tests\BasicAudioTest\ADPCMdroid.xwb
95 | Tests\BasicAudioTest\wavebank.xwb
96 | Tests\BasicAudioTest\xwmadroid.xwb
97 | TargetFolder: .drop\seeds
98 | OverWrite: true
99 | flattenFolders: true
100 |
101 | - task: PowerShell@2
102 | displayName: Copy OneFuzz setup script
103 | inputs:
104 | targetType: 'inline'
105 | script: |
106 | Copy-Item -Path .\build\onefuzz-setup.ps1 -Destination .drop/setup.ps1
107 |
108 | - task: MSBuild@1
109 | displayName: 'Copy ASan binaries'
110 | inputs:
111 | solution: build/CopyASAN.targets
112 | msbuildArguments: /p:TargetFolder=$(Build.SourcesDirectory)\.drop
113 | msbuildVersion: 17.0
114 | msbuildArchitecture: x64
115 | - task: PowerShell@2
116 | displayName: List drop files
117 | inputs:
118 | targetType: inline
119 | script: |
120 | Get-ChildItem ".drop" -Recurse | select FullName
121 |
122 | - task: onefuzz-task@0
123 | displayName: 'Submit to OneFuzz'
124 | inputs:
125 | onefuzzOSes: 'Windows'
126 | env:
127 | onefuzzDropDirectory: $(Build.SourcesDirectory)\.drop
128 | SYSTEM_ACCESSTOKEN: $(System.AccessToken)
129 |
--------------------------------------------------------------------------------
/.azuredevops/pipelines/DirectXTK-OneFuzz-Coverage.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # https://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | # OneFuzz code coverage pipeline
7 |
8 | pr: none
9 | trigger: none
10 |
11 | pool:
12 | vmImage: windows-latest
13 |
14 | resources:
15 | repositories:
16 | - repository: self
17 | type: git
18 | ref: refs/heads/main
19 | - repository: testRepo
20 | name: walbourn/directxtktest
21 | type: github
22 | endpoint: microsoft
23 | ref: refs/heads/main
24 |
25 | parameters:
26 | - name: sasUrl
27 | type: string
28 | displayName: SAS URL
29 | - name: branch
30 | type: string
31 | displayName: Branch
32 | - name: jobID
33 | type: string
34 | displayName: OneFuzz Job ID
35 | - name: buildDate
36 | type: string
37 | displayName: Build Date
38 | - name: commitID
39 | type: string
40 | displayName: Commit ID
41 |
42 | variables:
43 | - name: coverage-file
44 | value: cobertura-coverage.xml
45 | - name: job-ID
46 | value: ${{ parameters.jobID }}
47 | - name: build-date
48 | value: ${{ parameters.buildDate }}
49 | - name: branch
50 | value: ${{ parameters.branch }}
51 | - name: sas-url
52 | value: ${{ parameters.sasUrl }}
53 | - name: commit-ID
54 | value: ${{ parameters.commitID }}
55 |
56 | jobs:
57 | - job: prod
58 | displayName: Prod Task
59 | workspace:
60 | clean: all
61 | steps:
62 | - checkout: self
63 | clean: true
64 | fetchTags: false
65 | fetchDepth: 1
66 | path: 's'
67 | - checkout: testRepo
68 | displayName: Fetch Tests
69 | clean: true
70 | fetchTags: false
71 | fetchDepth: 1
72 | path: 's/Tests'
73 | - powershell: |
74 | Write-Host "Job ID: $(job-ID), Build Date: $(build-date), Branch: $(branch)"
75 | $SASUrl = [System.Uri]::new("$(sas-url)")
76 | azcopy cp $SASUrl.AbsoluteUri ./ --recursive
77 | $ContainerName = $SASURL.LocalPath.Split("/")[1]
78 | Write-Host "##vso[task.setvariable variable=container-name;]$ContainerName"
79 | cd $ContainerName
80 | $size = ((Get-Item .\$(coverage-file)).length)
81 | if ($size -eq 0) {
82 | Write-Host "Cobertura coverage XML is empty."
83 | exit 1
84 | }
85 | displayName: 'Get code coverage from OneFuzz'
86 |
87 | - task: PublishCodeCoverageResults@1
88 | inputs:
89 | codeCoverageTool: 'Cobertura'
90 | summaryFileLocation: ./$(container-name)\$(coverage-file)
91 | pathToSources: $(Build.SourcesDirectory)
92 | displayName: 'Generate coverage report'
93 |
--------------------------------------------------------------------------------
/.azuredevops/pipelines/DirectXTK-OneFuzz-Meshes.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # https://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | # Builds the library using CMake and submit for file fuzzing for meshes
7 |
8 | schedules:
9 | - cron: "0 11 20 * *"
10 | displayName: 'Submit for File Fuzzing (Monthly)'
11 | branches:
12 | include:
13 | - main
14 | always: true
15 |
16 | trigger: none
17 | pr: none
18 |
19 | resources:
20 | repositories:
21 | - repository: self
22 | type: git
23 | ref: refs/heads/main
24 | - repository: testRepo
25 | name: walbourn/directxtktest
26 | type: github
27 | endpoint: microsoft
28 | ref: refs/heads/main
29 |
30 | name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
31 |
32 | variables:
33 | Codeql.Enabled: false
34 | VS_GENERATOR: 'Visual Studio 17 2022'
35 | WIN11_SDK: '10.0.22000.0'
36 |
37 | pool:
38 | vmImage: windows-2022
39 |
40 | jobs:
41 | - job: FUZZ_BUILD
42 | displayName: 'Build for file fuzzing (CMO, SDKMESH, VBO)'
43 | steps:
44 | - checkout: self
45 | clean: true
46 | fetchTags: false
47 | fetchDepth: 1
48 | path: 's'
49 | - checkout: testRepo
50 | displayName: Fetch Tests
51 | clean: true
52 | fetchTags: false
53 | fetchDepth: 1
54 | path: 's/Tests'
55 | - task: CMake@1
56 | displayName: 'CMake (MSVC): Config with ASan'
57 | inputs:
58 | cwd: $(Build.SourcesDirectory)
59 | cmakeArgs: >
60 | -G "$(VS_GENERATOR)" -A x64 -B out
61 | -DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)
62 | -DBUILD_TOOLS=OFF -DBUILD_XAUDIO_WIN10=ON -DBUILD_FUZZING=ON -DBUILD_TESTING=OFF
63 | -DBUILD_MESH_FUZZING=ON
64 | - task: CMake@1
65 | displayName: 'CMake (MSVC): Build with ASan'
66 | inputs:
67 | cwd: $(Build.SourcesDirectory)
68 | cmakeArgs: --build out -v --config RelWithDebInfo
69 | - task: CopyFiles@2
70 | displayName: Copy fuzzer
71 | inputs:
72 | Contents: |
73 | build\OneFuzzConfig.json
74 | out\bin\RelWithDebInfo\fuzzloaders.exe
75 | TargetFolder: .drop
76 | OverWrite: true
77 | flattenFolders: true
78 | - task: CopyFiles@2
79 | displayName: Copy symbols
80 | inputs:
81 | Contents: |
82 | out\bin\RelWithDebInfo\fuzzloaders.pdb
83 | TargetFolder: .drop\symbols
84 | OverWrite: true
85 | flattenFolders: true
86 | - task: CopyFiles@2
87 | displayName: Copy seed files
88 | inputs:
89 | Contents: |
90 | Tests\AnimTest\teapot.cmo
91 | Tests\DGSLTest\teapot_unlit.cmo
92 | Tests\ModelTest\cup.sdkmesh
93 | Tests\AnimTest\soldier.sdkmesh
94 | Tests\PBRModelTest\BrokenCube.sdkmesh
95 | Tests\ModelTest\player_ship_a.vbo
96 | Tests\PBRTest\BrokenCube.vbo
97 | TargetFolder: .drop\seeds
98 | OverWrite: true
99 | flattenFolders: true
100 |
101 | - task: PowerShell@2
102 | displayName: Copy OneFuzz setup script
103 | inputs:
104 | targetType: 'inline'
105 | script: |
106 | Copy-Item -Path .\build\onefuzz-setup.ps1 -Destination .drop/setup.ps1
107 |
108 | - task: MSBuild@1
109 | displayName: 'Copy ASan binaries'
110 | inputs:
111 | solution: build/CopyASAN.targets
112 | msbuildArguments: /p:TargetFolder=$(Build.SourcesDirectory)\.drop
113 | msbuildVersion: 17.0
114 | msbuildArchitecture: x64
115 | - task: PowerShell@2
116 | displayName: List drop files
117 | inputs:
118 | targetType: inline
119 | script: |
120 | Get-ChildItem ".drop" -Recurse | select FullName
121 |
122 | - task: onefuzz-task@0
123 | displayName: 'Submit to OneFuzz'
124 | inputs:
125 | onefuzzOSes: 'Windows'
126 | env:
127 | onefuzzDropDirectory: $(Build.SourcesDirectory)\.drop
128 | SYSTEM_ACCESSTOKEN: $(System.AccessToken)
129 |
--------------------------------------------------------------------------------
/.azuredevops/pipelines/DirectXTK-OneFuzz.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # https://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | # Builds the library using CMake and submit for file fuzzing for texture loading
7 |
8 | schedules:
9 | - cron: "0 11 1 * *"
10 | displayName: 'Submit for File Fuzzing (Monthly)'
11 | branches:
12 | include:
13 | - main
14 | always: true
15 |
16 | trigger: none
17 | pr: none
18 |
19 | resources:
20 | repositories:
21 | - repository: self
22 | type: git
23 | ref: refs/heads/main
24 | - repository: testRepo
25 | name: walbourn/directxtktest
26 | type: github
27 | endpoint: microsoft
28 | ref: refs/heads/main
29 |
30 | name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
31 |
32 | variables:
33 | Codeql.Enabled: false
34 | VS_GENERATOR: 'Visual Studio 17 2022'
35 | WIN11_SDK: '10.0.22000.0'
36 |
37 | pool:
38 | vmImage: windows-2022
39 |
40 | jobs:
41 | - job: FUZZ_BUILD
42 | displayName: 'Build for file fuzzing (DDS)'
43 | steps:
44 | - checkout: self
45 | clean: true
46 | fetchTags: false
47 | fetchDepth: 1
48 | path: 's'
49 | - checkout: testRepo
50 | displayName: Fetch Tests
51 | clean: true
52 | fetchTags: false
53 | fetchDepth: 1
54 | path: 's/Tests'
55 | - task: CMake@1
56 | displayName: 'CMake (MSVC): Config with ASan'
57 | inputs:
58 | cwd: $(Build.SourcesDirectory)
59 | cmakeArgs: >
60 | -G "$(VS_GENERATOR)" -A x64 -B out
61 | -DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)
62 | -DBUILD_TOOLS=OFF -DBUILD_XAUDIO_WIN10=ON -DBUILD_FUZZING=ON -DBUILD_TESTING=OFF
63 | - task: CMake@1
64 | displayName: 'CMake (MSVC): Build with ASan'
65 | inputs:
66 | cwd: $(Build.SourcesDirectory)
67 | cmakeArgs: --build out -v --config RelWithDebInfo
68 | - task: CopyFiles@2
69 | displayName: Copy fuzzer
70 | inputs:
71 | Contents: |
72 | build\OneFuzzConfig.json
73 | out\bin\RelWithDebInfo\fuzzloaders.exe
74 | TargetFolder: .drop
75 | OverWrite: true
76 | flattenFolders: true
77 | - task: CopyFiles@2
78 | displayName: Copy symbols
79 | inputs:
80 | Contents: |
81 | out\bin\RelWithDebInfo\fuzzloaders.pdb
82 | TargetFolder: .drop\symbols
83 | OverWrite: true
84 | flattenFolders: true
85 | - task: PowerShell@2
86 | displayName: Download seed files
87 | inputs:
88 | targetType: inline
89 | script: |
90 | $seedfiles = "AlphaEdge.dds",
91 | "cubea8r8g8b8.dds",
92 | "default_texture_nm.dds",
93 | "dx5_logo.dds",
94 | "hdrtest.dds",
95 | "normalmap.dds";
96 |
97 | New-Item -ItemType Directory -Force -Path .drop\seeds\
98 |
99 | foreach($filename in $seedfiles)
100 | {
101 | Write-Host "Fetching: $filename"
102 | $url = "https://raw.githubusercontent.com/walbourn/directxtexmedia/main/" + $filename
103 | $target = [System.IO.Path]::Combine(".drop\seeds\", $filename)
104 | Invoke-WebRequest -Uri $url -OutFile $target
105 | }
106 |
107 | - task: PowerShell@2
108 | displayName: Copy OneFuzz setup script
109 | inputs:
110 | targetType: 'inline'
111 | script: |
112 | Copy-Item -Path .\build\onefuzz-setup.ps1 -Destination .drop/setup.ps1
113 |
114 | - task: MSBuild@1
115 | displayName: 'Copy ASan binaries'
116 | inputs:
117 | solution: build/CopyASAN.targets
118 | msbuildArguments: /p:TargetFolder=$(Build.SourcesDirectory)\.drop
119 | msbuildVersion: 17.0
120 | msbuildArchitecture: x64
121 | - task: PowerShell@2
122 | displayName: List drop files
123 | inputs:
124 | targetType: inline
125 | script: |
126 | Get-ChildItem ".drop" -Recurse | select FullName
127 |
128 | - task: onefuzz-task@0
129 | displayName: 'Submit to OneFuzz'
130 | inputs:
131 | onefuzzOSes: 'Windows'
132 | env:
133 | onefuzzDropDirectory: $(Build.SourcesDirectory)\.drop
134 | SYSTEM_ACCESSTOKEN: $(System.AccessToken)
135 |
--------------------------------------------------------------------------------
/.azuredevops/policies/approvercountpolicy.yml:
--------------------------------------------------------------------------------
1 | name: approver_count
2 | description: Approver count policy for mscodehub/DirectXTK/DirectXTK repository
3 | resource: repository
4 | where:
5 | configuration:
6 | approverCountPolicySettings:
7 | isBlocking: true
8 | requireMinimumApproverCount: 1
9 | creatorVoteCounts: false
10 | allowDownvotes: false
11 | sourcePushOptions:
12 | resetOnSourcePush: false
13 | requireVoteOnLastIteration: true
14 | requireVoteOnEachIteration: false
15 | resetRejectionsOnSourcePush: false
16 | blockLastPusherVote: true
17 | branchNames:
18 | - refs/heads/release
19 | - refs/heads/main
20 | displayName: mscodehub/DirectXTK/DirectXTK Approver Count Policy
21 |
--------------------------------------------------------------------------------
/.azuredevops/templates/DirectXTK-build-uwp-arm64.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | # Template used by SDK-release and SDK-prerelease pipelines
7 |
8 | steps:
9 | - task: VSBuild@1
10 | displayName: Build solution DirectXTK_Windows10_2022.sln arm64dbg
11 | inputs:
12 | solution: DirectXTK_Windows10_2022.sln
13 | msbuildArgs: /p:PreferredToolArchitecture=x64
14 | platform: ARM64
15 | configuration: Debug
16 | - task: VSBuild@1
17 | displayName: Build solution DirectXTK_Windows10_2022.sln arm64rel
18 | inputs:
19 | solution: DirectXTK_Windows10_2022.sln
20 | msbuildArgs: /p:PreferredToolArchitecture=x64
21 | platform: ARM64
22 | configuration: Release
23 |
--------------------------------------------------------------------------------
/.azuredevops/templates/DirectXTK-build-uwp.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | # Template used by SDK-release and SDK-prerelease pipelines
7 |
8 | steps:
9 | - task: VSBuild@1
10 | displayName: Build solution DirectXTK_Windows10_2022.sln 32dbg
11 | inputs:
12 | solution: DirectXTK_Windows10_2022.sln
13 | msbuildArgs: /p:PreferredToolArchitecture=x64
14 | platform: x86
15 | configuration: Debug
16 | - task: VSBuild@1
17 | displayName: Build solution DirectXTK_Windows10_2022.sln 32rel
18 | inputs:
19 | solution: DirectXTK_Windows10_2022.sln
20 | msbuildArgs: /p:PreferredToolArchitecture=x64
21 | platform: x86
22 | configuration: Release
23 | - task: VSBuild@1
24 | displayName: Build solution DirectXTK_Windows10_2022.sln 64dbg
25 | inputs:
26 | solution: DirectXTK_Windows10_2022.sln
27 | msbuildArgs: /p:PreferredToolArchitecture=x64
28 | platform: x64
29 | configuration: Debug
30 | - task: VSBuild@1
31 | displayName: Build solution DirectXTK_Windows10_2022.sln 64rel
32 | inputs:
33 | solution: DirectXTK_Windows10_2022.sln
34 | msbuildArgs: /p:PreferredToolArchitecture=x64
35 | platform: x64
36 | configuration: Release
37 |
--------------------------------------------------------------------------------
/.azuredevops/templates/DirectXTK-build-win32.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | # Template used by SDK-release and SDK-prerelease pipelines
7 |
8 | steps:
9 | - task: VSBuild@1
10 | displayName: Build solution DirectXTK_Desktop_2019.sln 32dbg
11 | inputs:
12 | solution: DirectXTK_Desktop_2019.sln
13 | msbuildArgs: /p:PreferredToolArchitecture=x64
14 | platform: x86
15 | configuration: Debug
16 | - task: VSBuild@1
17 | displayName: Build solution DirectXTK_Desktop_2019.sln 32rel
18 | inputs:
19 | solution: DirectXTK_Desktop_2019.sln
20 | msbuildArgs: /p:PreferredToolArchitecture=x64
21 | platform: x86
22 | configuration: Release
23 | - task: VSBuild@1
24 | displayName: Build solution DirectXTK_Desktop_2019.sln 64dbg
25 | inputs:
26 | solution: DirectXTK_Desktop_2019.sln
27 | msbuildArgs: /p:PreferredToolArchitecture=x64
28 | platform: x64
29 | configuration: Debug
30 | - task: VSBuild@1
31 | displayName: Build solution DirectXTK_Desktop_2019.sln 64rel
32 | inputs:
33 | solution: DirectXTK_Desktop_2019.sln
34 | msbuildArgs: /p:PreferredToolArchitecture=x64
35 | platform: x64
36 | configuration: Release
37 | - task: CmdLine@2
38 | displayName: 'Reclaim diskspace'
39 | inputs:
40 | script: del *.pch /s
41 | workingDirectory: $(Build.SourcesDirectory)
42 | failOnStderr: false
43 | - task: VSBuild@1
44 | displayName: Build solution DirectXTK_Desktop_2019.sln managed dbg
45 | inputs:
46 | solution: DirectXTK_Desktop_2019.sln
47 | msbuildArgs: /p:PreferredToolArchitecture=x64
48 | platform: Mixed Platforms
49 | configuration: Debug
50 | - task: VSBuild@1
51 | displayName: Build solution DirectXTK_Desktop_2019.sln managed rel
52 | inputs:
53 | solution: DirectXTK_Desktop_2019.sln
54 | msbuildArgs: /p:PreferredToolArchitecture=x64
55 | platform: Mixed Platforms
56 | configuration: Release
57 | - task: VSBuild@1
58 | displayName: Build solution DirectXTK_Desktop_2019_Win10.sln 32dbg
59 | inputs:
60 | solution: DirectXTK_Desktop_2019_Win10.sln
61 | msbuildArgs: /p:PreferredToolArchitecture=x64
62 | platform: x86
63 | configuration: Debug
64 | - task: VSBuild@1
65 | displayName: Build solution DirectXTK_Desktop_2019_Win10.sln 32rel
66 | inputs:
67 | solution: DirectXTK_Desktop_2019_Win10.sln
68 | msbuildArgs: /p:PreferredToolArchitecture=x64
69 | platform: x86
70 | configuration: Release
71 | - task: VSBuild@1
72 | displayName: Build solution DirectXTK_Desktop_2019_Win10.sln 64dbg
73 | inputs:
74 | solution: DirectXTK_Desktop_2019_Win10.sln
75 | msbuildArgs: /p:PreferredToolArchitecture=x64
76 | platform: x64
77 | configuration: Debug
78 | - task: VSBuild@1
79 | displayName: Build solution DirectXTK_Desktop_2019_Win10.sln 64rel
80 | inputs:
81 | solution: DirectXTK_Desktop_2019_Win10.sln
82 | msbuildArgs: /p:PreferredToolArchitecture=x64
83 | platform: x64
84 | configuration: Release
85 | # VS 2019 for Win32 on ARM64 is out of support.
86 | - task: VSBuild@1
87 | displayName: Build solution DirectXTK_Desktop_2022_Win10.sln arm64dbg
88 | inputs:
89 | solution: DirectXTK_Desktop_2022_Win10.sln
90 | msbuildArgs: /p:PreferredToolArchitecture=x64
91 | platform: ARM64
92 | configuration: Debug
93 | - task: VSBuild@1
94 | displayName: Build solution DirectXTK_Desktop_2022_Win10.sln arm64rel
95 | inputs:
96 | solution: DirectXTK_Desktop_2022_Win10.sln
97 | msbuildArgs: /p:PreferredToolArchitecture=x64
98 | platform: ARM64
99 | configuration: Release
100 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*.{yml}]
4 | indent_size = 2
5 | indent_style = space
6 | trim_trailing_whitespace = true
7 | insert_final_newline = true
8 | end_of_line = crlf
9 | charset = latin1
10 |
11 | [*.{fx,fxh,hlsl,hlsli}]
12 | indent_size = 4
13 | indent_style = space
14 | trim_trailing_whitespace = true
15 | insert_final_newline = true
16 | end_of_line = crlf
17 | charset = latin1
18 | cpp_space_before_function_open_parenthesis = remove
19 | cpp_space_around_binary_operator = ignore
20 | cpp_space_pointer_reference_alignment = ignore
21 |
22 | [*.{cpp,h,hpp,inl}]
23 | indent_size = 4
24 | indent_style = space
25 | trim_trailing_whitespace = true
26 | insert_final_newline = true
27 | end_of_line = crlf
28 | charset = latin1
29 | cpp_indent_braces = false
30 | cpp_indent_multi_line_relative_to = innermost_parenthesis
31 | cpp_indent_within_parentheses = indent
32 | cpp_indent_preserve_within_parentheses = false
33 | cpp_indent_case_contents = true
34 | cpp_indent_case_labels = false
35 | cpp_indent_case_contents_when_block = true
36 | cpp_indent_lambda_braces_when_parameter = true
37 | cpp_indent_preprocessor = one_left
38 | cpp_indent_access_specifiers = false
39 | cpp_indent_namespace_contents = true
40 | cpp_indent_preserve_comments = true
41 | cpp_new_line_before_open_brace_namespace = new_line
42 | cpp_new_line_before_open_brace_type = new_line
43 | cpp_new_line_before_open_brace_function = new_line
44 | cpp_new_line_before_open_brace_block = new_line
45 | cpp_new_line_before_open_brace_lambda = new_line
46 | cpp_new_line_scope_braces_on_separate_lines = true
47 | cpp_new_line_close_brace_same_line_empty_type = true
48 | cpp_new_line_close_brace_same_line_empty_function = true
49 | cpp_new_line_before_catch = true
50 | cpp_new_line_before_else = true
51 | cpp_new_line_before_while_in_do_while = true
52 | cpp_space_before_function_open_parenthesis = remove
53 | cpp_space_within_parameter_list_parentheses = false
54 | cpp_space_between_empty_parameter_list_parentheses = false
55 | cpp_space_after_keywords_in_control_flow_statements = true
56 | cpp_space_within_control_flow_statement_parentheses = false
57 | cpp_space_before_lambda_open_parenthesis = false
58 | cpp_space_within_cast_parentheses = false
59 | cpp_space_after_cast_close_parenthesis = false
60 | cpp_space_within_expression_parentheses = false
61 | cpp_space_before_initializer_list_open_brace = false
62 | cpp_space_within_initializer_list_braces = true
63 | cpp_space_before_open_square_bracket = false
64 | cpp_space_within_square_brackets = false
65 | cpp_space_before_empty_square_brackets = false
66 | cpp_space_between_empty_square_brackets = false
67 | cpp_space_group_square_brackets = true
68 | cpp_space_within_lambda_brackets = false
69 | cpp_space_between_empty_lambda_brackets = false
70 | cpp_space_before_comma = false
71 | cpp_space_after_comma = true
72 | cpp_space_remove_around_member_operators = true
73 | cpp_space_before_inheritance_colon = true
74 | cpp_space_before_constructor_colon = true
75 | cpp_space_remove_before_semicolon = true
76 | cpp_space_after_semicolon = false
77 | cpp_space_remove_around_unary_operator = false
78 | cpp_space_around_binary_operator = ignore
79 | cpp_space_around_assignment_operator = insert
80 | cpp_space_pointer_reference_alignment = ignore
81 | cpp_space_around_ternary_operator = insert
82 | cpp_wrap_preserve_blocks = one_liners
83 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Explicitly declare code/VS files as CRLF
5 | *.cs eol=crlf
6 | *.cpp eol=crlf
7 | *.cmd eol=crlf
8 | *.h eol=crlf
9 | *.hlsl eol=crlf
10 | *.hlsli eol=crlf
11 | *.fx eol=crlf
12 | *.fxh eol=crlf
13 | *.inc eol=crlf
14 | *.inl eol=crlf
15 | *.csproj eol=crlf
16 | *.vcxproj eol=crlf
17 | *.filters eol=crlf
18 | *.sln eol=crlf
19 | *.yml eol=crlf
20 |
21 | # Explicitly declare resource files as binary
22 | *.pdb binary
23 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: github-actions
4 | directory: /
5 | schedule:
6 | interval: monthly
7 |
--------------------------------------------------------------------------------
/.github/linters/.editorconfig-checker.json:
--------------------------------------------------------------------------------
1 | {
2 | "Format": "github-actions",
3 | "exclude": [
4 | ".git",
5 | "LICENSE",
6 | "Tests"
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/.github/linters/.markdown-lint.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | # line-length
5 | MD013: false
6 |
7 | # blanks-around-headings
8 | MD022: false
9 |
10 | # blanks-around-lists
11 | MD032: false
12 |
13 | # no-inline-html
14 | MD033: false
15 |
16 | # no-bare-urls
17 | MD034: false
18 |
19 | # first-line-heading
20 | MD041: false
21 |
--------------------------------------------------------------------------------
/.github/linters/.powershell-psscriptanalyzer.psd1:
--------------------------------------------------------------------------------
1 | # PSScriptAnalyzerSettings.psd1
2 | @{
3 | Severity=@('Error','Warning')
4 | ExcludeRules=@('PSAvoidUsingWriteHost')
5 | }
6 |
--------------------------------------------------------------------------------
/.github/linters/.yaml-lint.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | ignore-from-file: .gitignore
5 |
6 | extends: default
7 |
8 | rules:
9 | truthy:
10 | check-keys: false
11 | document-start: disable
12 | line-length:
13 | max: 160
14 | comments:
15 | min-spaces-from-content: 1
16 | new-lines:
17 | type: dos
18 |
--------------------------------------------------------------------------------
/.github/workflows/bvt.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | name: 'CTest (BVTs)'
7 |
8 | on:
9 | push:
10 | branches: "main"
11 | paths-ignore:
12 | - '*.md'
13 | - LICENSE
14 | - '.azuredevops/**'
15 | - '.nuget/*'
16 | - build/*.cmd
17 | - build/*.json
18 | - build/*.props
19 | - build/*.ps1
20 | - build/*.targets
21 | pull_request:
22 | branches: "main"
23 | paths-ignore:
24 | - '*.md'
25 | - LICENSE
26 | - '.azuredevops/**'
27 | - '.nuget/*'
28 | - build/*.cmd
29 | - build/*.json
30 | - build/*.props
31 | - build/*.ps1
32 | - build/*.targets
33 |
34 | permissions:
35 | contents: read
36 |
37 | jobs:
38 | build:
39 | runs-on: windows-2022
40 | timeout-minutes: 20
41 |
42 | strategy:
43 | fail-fast: false
44 |
45 | matrix:
46 | toolver: ['14.29', '14']
47 | build_type: [x64-Release]
48 | arch: [amd64]
49 |
50 | steps:
51 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
52 |
53 | - name: Clone test repository
54 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
55 | with:
56 | repository: walbourn/directxtktest
57 | path: Tests
58 | ref: main
59 |
60 | - name: 'Install Ninja'
61 | run: choco install ninja
62 |
63 | - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
64 | with:
65 | arch: ${{ matrix.arch }}
66 | toolset: ${{ matrix.toolver }}
67 |
68 | - name: 'Configure CMake'
69 | working-directory: ${{ github.workspace }}
70 | run: cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=ON -DBUILD_TOOLS=OFF -DBUILD_BVT=ON
71 |
72 | - name: 'Build'
73 | working-directory: ${{ github.workspace }}
74 | run: cmake --build out\build\${{ matrix.build_type }}
75 |
76 | - name: 'Run BVTs'
77 | working-directory: ${{ github.workspace }}
78 | run: ctest --preset=${{ matrix.build_type }} --output-on-failure
79 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | name: "CodeQL"
7 |
8 | on:
9 | push:
10 | branches: "main"
11 | paths-ignore:
12 | - '*.md'
13 | - LICENSE
14 | - '.azuredevops/**'
15 | - '.nuget/*'
16 | - build/*.cmd
17 | - build/*.json
18 | - build/*.props
19 | - build/*.ps1
20 | - build/*.targets
21 | pull_request:
22 | branches: "main"
23 | paths-ignore:
24 | - '*.md'
25 | - LICENSE
26 | - '.azuredevops/**'
27 | - '.nuget/*'
28 | - build/*.cmd
29 | - build/*.json
30 | - build/*.props
31 | - build/*.ps1
32 | - build/*.targets
33 | schedule:
34 | - cron: '31 2 * * 5'
35 |
36 | permissions:
37 | contents: read
38 |
39 | jobs:
40 | analyze:
41 | name: Analyze (${{ matrix.language }})
42 | runs-on: windows-latest
43 | timeout-minutes: 360
44 | permissions:
45 | actions: read # for github/codeql-action/init to get workflow details
46 | contents: read # for actions/checkout to fetch code
47 | security-events: write # for github/codeql-action/autobuild to send a status report
48 | packages: read
49 |
50 | strategy:
51 | fail-fast: false
52 | matrix:
53 | language: [c-cpp, csharp]
54 |
55 | steps:
56 | - name: Checkout repository
57 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
58 |
59 | - if: matrix.language == 'c-cpp'
60 | name: 'Install Ninja'
61 | run: choco install ninja
62 |
63 | - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
64 |
65 | - name: Initialize CodeQL
66 | uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
67 | with:
68 | languages: ${{ matrix.language }}
69 | build-mode: manual
70 |
71 | - if: matrix.language == 'c-cpp'
72 | name: 'Configure CMake (C/C++)'
73 | working-directory: ${{ github.workspace }}
74 | run: cmake --preset=x64-Debug
75 |
76 | - if: matrix.language == 'c-cpp'
77 | name: 'Build (C/C++)'
78 | working-directory: ${{ github.workspace }}
79 | run: cmake --build out\build\x64-Debug
80 |
81 | - if: matrix.language == 'csharp'
82 | name: 'Build (C#)'
83 | working-directory: ./MakeSpriteFont
84 | run: msbuild MakeSpriteFont.csproj /p:Configuration=Debug /p:Platform=AnyCPU
85 |
86 | - name: Perform CodeQL Analysis
87 | uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
88 | with:
89 | category: "/language:${{ matrix.language }}"
90 |
--------------------------------------------------------------------------------
/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | name: Lint
7 |
8 | on:
9 | pull_request:
10 | branches: "main"
11 | paths-ignore:
12 | - LICENSE
13 | - '.nuget/*'
14 | - build/*.in
15 |
16 | permissions: {}
17 |
18 | jobs:
19 | analyze:
20 | permissions:
21 | contents: read
22 | packages: read
23 | statuses: write
24 | name: Lint
25 | runs-on: ubuntu-latest
26 |
27 | steps:
28 | - name: Checkout repository
29 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30 | with:
31 | fetch-depth: 0
32 |
33 | - name: Lint Code Base
34 | uses: super-linter/super-linter@12150456a73e248bdc94d0794898f94e23127c88 # v7.4.0
35 | env:
36 | DEFAULT_BRANCH: origin/main
37 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 | IGNORE_GITIGNORED_FILES: true
39 | VALIDATE_ALL_CODEBASE: true
40 | VALIDATE_CHECKOV: true
41 | VALIDATE_EDITORCONFIG: true
42 | VALIDATE_CSHARP: true
43 | VALIDATE_GITHUB_ACTIONS: true
44 | VALIDATE_JSON: true
45 | VALIDATE_MARKDOWN: true
46 | VALIDATE_POWERSHELL: true
47 | VALIDATE_GITLEAKS: true
48 | VALIDATE_YAML: true
49 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | name: 'CMake (Windows 8.1)'
7 |
8 | on:
9 | push:
10 | branches: "main"
11 | paths-ignore:
12 | - '*.md'
13 | - LICENSE
14 | - '.azuredevops/**'
15 | - '.nuget/*'
16 | - build/*.cmd
17 | - build/*.json
18 | - build/*.props
19 | - build/*.ps1
20 | - build/*.targets
21 | pull_request:
22 | branches: "main"
23 | paths-ignore:
24 | - '*.md'
25 | - LICENSE
26 | - '.azuredevops/**'
27 | - '.nuget/*'
28 | - build/*.cmd
29 | - build/*.json
30 | - build/*.props
31 | - build/*.ps1
32 | - build/*.targets
33 |
34 | permissions:
35 | contents: read
36 |
37 | jobs:
38 | build:
39 | runs-on: windows-2022
40 |
41 | strategy:
42 | fail-fast: false
43 |
44 | matrix:
45 | toolver: ['14.29', '14']
46 | build_type: [x64-Debug, x64-Release]
47 | arch: [amd64]
48 | include:
49 | - toolver: '14.29'
50 | build_type: x86-Debug
51 | arch: amd64_x86
52 | - toolver: '14.29'
53 | build_type: x86-Release
54 | arch: amd64_x86
55 | - toolver: '14'
56 | build_type: x86-Debug
57 | arch: amd64_x86
58 | - toolver: '14'
59 | build_type: x86-Release
60 | arch: amd64_x86
61 | - toolver: '14'
62 | build_type: x64-Debug-Clang
63 | arch: amd64
64 | - toolver: '14'
65 | build_type: x64-Release-Clang
66 | arch: amd64
67 | - toolver: '14'
68 | build_type: x86-Debug-Clang
69 | arch: amd64_x86
70 | - toolver: '14'
71 | build_type: x86-Release-Clang
72 | arch: amd64_x86
73 |
74 | steps:
75 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
76 |
77 | - name: 'Install Ninja'
78 | run: choco install ninja
79 |
80 | - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
81 | with:
82 | arch: ${{ matrix.arch }}
83 | toolset: ${{ matrix.toolver }}
84 |
85 | - name: 'Configure CMake'
86 | working-directory: ${{ github.workspace }}
87 | run: cmake --preset=${{ matrix.build_type }}
88 |
89 | - name: 'Build'
90 | working-directory: ${{ github.workspace }}
91 | run: cmake --build out\build\${{ matrix.build_type }}
92 |
93 | - name: 'Clean up'
94 | working-directory: ${{ github.workspace }}
95 | run: Remove-Item -Path out -Recurse -Force
96 |
97 | - name: 'Configure CMake (Spectre)'
98 | working-directory: ${{ github.workspace }}
99 | run: cmake --preset=${{ matrix.build_type }} -DENABLE_SPECTRE_MITIGATION=ON
100 |
101 | - name: 'Build (Spectre)'
102 | working-directory: ${{ github.workspace }}
103 | run: cmake --build out\build\${{ matrix.build_type }}
104 |
105 | - name: 'Clean up'
106 | working-directory: ${{ github.workspace }}
107 | run: Remove-Item -Path out -Recurse -Force
108 |
109 | - name: 'Configure CMake (DLL)'
110 | working-directory: ${{ github.workspace }}
111 | run: cmake --preset=${{ matrix.build_type }} -DBUILD_SHARED_LIBS=ON
112 |
113 | - name: 'Build (DLL)'
114 | working-directory: ${{ github.workspace }}
115 | run: cmake --build out\build\${{ matrix.build_type }}
116 |
--------------------------------------------------------------------------------
/.github/workflows/msbuild.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | name: MSBuild
7 |
8 | on:
9 | push:
10 | branches: "main"
11 | paths-ignore:
12 | - '*.md'
13 | - LICENSE
14 | - '.azuredevops/**'
15 | - '.nuget/*'
16 | - build/*
17 | pull_request:
18 | branches: "main"
19 | paths-ignore:
20 | - '*.md'
21 | - LICENSE
22 | - '.azuredevops/**'
23 | - '.nuget/*'
24 | - build/*
25 |
26 | permissions:
27 | contents: read
28 |
29 | jobs:
30 | build:
31 | runs-on: windows-2022 # has v142 tools but not v142 spectre libs
32 |
33 | strategy:
34 | fail-fast: false
35 |
36 | matrix:
37 | vs: [2019, 2022]
38 | build_type: [Debug, Release]
39 | platform: [x86, x64, ARM64]
40 | exclude:
41 | - vs: 2019
42 | platform: ARM64
43 |
44 | steps:
45 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
46 |
47 | - name: Add MSBuild to PATH
48 | uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0
49 |
50 | - if: matrix.platform != 'ARM64'
51 | name: Build (Windows 8.1)
52 | working-directory: ${{ github.workspace }}
53 | run: >
54 | msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
55 | DirectXTK_Desktop_${{ matrix.vs }}.sln
56 |
57 | - name: 'Build (Windows 10)'
58 | working-directory: ${{ github.workspace }}
59 | run: >
60 | msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
61 | DirectXTK_Desktop_${{ matrix.vs }}_Win10.sln
62 |
63 | - if: matrix.vs == '2022'
64 | name: 'Build (UWP)'
65 | working-directory: ${{ github.workspace }}
66 | run: >
67 | msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
68 | DirectXTK_Windows10_2022.sln
69 |
70 | - if: matrix.platform != 'ARM64' && matrix.vs != '2019'
71 | name: 'Build (Windows 8.1 w/ Spectre)'
72 | working-directory: ${{ github.workspace }}
73 | run: >
74 | msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
75 | /p:SpectreMitigation=Spectre
76 | DirectXTK_Desktop_${{ matrix.vs }}.sln
77 |
78 | - if: matrix.platform != 'ARM64' && matrix.vs != '2019'
79 | name: 'Build (Spectre Windows 10)'
80 | working-directory: ${{ github.workspace }}
81 | run: >
82 | msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }}
83 | /p:SpectreMitigation=Spectre
84 | DirectXTK_Desktop_${{ matrix.vs }}_Win10.sln
85 |
--------------------------------------------------------------------------------
/.github/workflows/msvc.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | name: Microsoft C++ Code Analysis
7 |
8 | on:
9 | push:
10 | branches: "main"
11 | paths-ignore:
12 | - '*.md'
13 | - LICENSE
14 | - '.azuredevops/**'
15 | - '.nuget/*'
16 | - build/*.cmd
17 | - build/*.json
18 | - build/*.props
19 | - build/*.ps1
20 | - build/*.targets
21 | pull_request:
22 | branches: "main"
23 | paths-ignore:
24 | - '*.md'
25 | - LICENSE
26 | - '.azuredevops/**'
27 | - '.nuget/*'
28 | - build/*.cmd
29 | - build/*.json
30 | - build/*.props
31 | - build/*.ps1
32 | - build/*.targets
33 | schedule:
34 | - cron: '25 15 * * 5'
35 |
36 | permissions:
37 | contents: read
38 |
39 | jobs:
40 | analyze:
41 | permissions:
42 | contents: read
43 | security-events: write
44 | actions: read
45 | name: Analyze
46 | runs-on: windows-latest
47 |
48 | steps:
49 | - name: Checkout repository
50 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
51 |
52 | - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
53 | with:
54 | arch: amd64
55 |
56 | - name: Configure CMake
57 | working-directory: ${{ github.workspace }}
58 | run: cmake -B out -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON
59 |
60 | - name: 'Build Shaders'
61 | shell: cmd
62 | working-directory: ./Src/Shaders
63 | run: CompileShaders.cmd
64 | env:
65 | CompileShadersOutput: ${{ github.workspace }}/out/Shaders/Compiled
66 |
67 | - name: Initialize MSVC Code Analysis
68 | uses: microsoft/msvc-code-analysis-action@24c285ab36952c9e9182f4b78dfafbac38a7e5ee # v0.1.1
69 | id: run-analysis
70 | with:
71 | cmakeBuildDirectory: ./out
72 | buildConfiguration: Debug
73 | ruleset: NativeRecommendedRules.ruleset
74 |
75 | # Upload SARIF file to GitHub Code Scanning Alerts
76 | - name: Upload SARIF to GitHub
77 | uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
78 | with:
79 | sarif_file: ${{ steps.run-analysis.outputs.sarif }}
80 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | name: 'CTest (Windows)'
7 |
8 | on:
9 | push:
10 | branches: "main"
11 | paths-ignore:
12 | - '*.md'
13 | - LICENSE
14 | - '.azuredevops/**'
15 | - '.nuget/*'
16 | - build/*.cmd
17 | - build/*.json
18 | - build/*.props
19 | - build/*.ps1
20 | - build/*.targets
21 | pull_request:
22 | branches: "main"
23 | paths-ignore:
24 | - '*.md'
25 | - LICENSE
26 | - '.azuredevops/**'
27 | - '.nuget/*'
28 | - build/*.cmd
29 | - build/*.json
30 | - build/*.props
31 | - build/*.ps1
32 | - build/*.targets
33 |
34 | permissions:
35 | contents: read
36 |
37 | jobs:
38 | build:
39 | runs-on: windows-2022
40 | timeout-minutes: 20
41 |
42 | strategy:
43 | fail-fast: false
44 |
45 | matrix:
46 | toolver: ['14.29', '14']
47 | build_type: [x64-Debug, x64-Release]
48 | arch: [amd64]
49 | include:
50 | - toolver: '14.29'
51 | build_type: x86-Debug
52 | arch: amd64_x86
53 | - toolver: '14.29'
54 | build_type: x86-Release
55 | arch: amd64_x86
56 | - toolver: '14'
57 | build_type: x86-Debug
58 | arch: amd64_x86
59 | - toolver: '14'
60 | build_type: x86-Release
61 | arch: amd64_x86
62 | - toolver: '14'
63 | build_type: x64-Debug-Clang
64 | arch: amd64
65 | - toolver: '14'
66 | build_type: x64-Release-Clang
67 | arch: amd64
68 | - toolver: '14'
69 | build_type: x86-Debug-Clang
70 | arch: amd64_x86
71 | - toolver: '14'
72 | build_type: x86-Release-Clang
73 | arch: amd64_x86
74 | - toolver: '14'
75 | build_type: arm64-Debug
76 | arch: amd64_arm64
77 | - toolver: '14'
78 | build_type: arm64-Release
79 | arch: amd64_arm64
80 | - toolver: '14'
81 | build_type: arm64ec-Debug
82 | arch: amd64_arm64
83 | - toolver: '14'
84 | build_type: arm64ec-Release
85 | arch: amd64_arm64
86 |
87 | steps:
88 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
89 |
90 | - name: Clone test repository
91 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
92 | with:
93 | repository: walbourn/directxtktest
94 | path: Tests
95 | ref: main
96 |
97 | - name: 'Install Ninja'
98 | run: choco install ninja
99 |
100 | - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
101 | with:
102 | arch: ${{ matrix.arch }}
103 | toolset: ${{ matrix.toolver }}
104 |
105 | - name: 'Configure CMake'
106 | working-directory: ${{ github.workspace }}
107 | run: >
108 | cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=ON -DBUILD_TOOLS=OFF
109 |
110 | - name: 'Build'
111 | working-directory: ${{ github.workspace }}
112 | run: cmake --build out\build\${{ matrix.build_type }}
113 |
114 | - if: (matrix.build_type == 'x64-Release') || (matrix.build_type == 'x86-Release')
115 | timeout-minutes: 10
116 | name: 'Test (Math only)'
117 | working-directory: ${{ github.workspace }}
118 | run: ctest --preset=${{ matrix.build_type }} -L Math
119 |
120 | - name: 'Clean up'
121 | working-directory: ${{ github.workspace }}
122 | run: Remove-Item -Path out -Recurse -Force
123 |
124 | - name: 'Configure CMake (DLL)'
125 | working-directory: ${{ github.workspace }}
126 | run: >
127 | cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=ON -DBUILD_TOOLS=OFF
128 | -DBUILD_SHARED_LIBS=ON
129 |
130 | - name: 'Build (DLL)'
131 | working-directory: ${{ github.workspace }}
132 | run: cmake --build out\build\${{ matrix.build_type }}
133 |
--------------------------------------------------------------------------------
/.github/workflows/uwp.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | name: 'CMake (UWP)'
7 |
8 | on:
9 | push:
10 | branches: "main"
11 | paths-ignore:
12 | - '*.md'
13 | - LICENSE
14 | - '.azuredevops/**'
15 | - '.nuget/*'
16 | - build/*.cmd
17 | - build/*.json
18 | - build/*.props
19 | - build/*.ps1
20 | - build/*.targets
21 | pull_request:
22 | branches: "main"
23 | paths-ignore:
24 | - '*.md'
25 | - LICENSE
26 | - '.azuredevops/**'
27 | - '.nuget/*'
28 | - build/*.cmd
29 | - build/*.json
30 | - build/*.props
31 | - build/*.ps1
32 | - build/*.targets
33 |
34 | permissions:
35 | contents: read
36 |
37 | jobs:
38 | build:
39 | runs-on: windows-2022
40 |
41 | strategy:
42 | fail-fast: false
43 |
44 | matrix:
45 | build_type: [x64-Debug-UWP, x64-Release-UWP, x64-Debug-UWP-Clang, x64-Release-UWP-Clang]
46 | arch: [amd64]
47 | include:
48 | - build_type: x86-Debug-UWP
49 | arch: amd64_x86
50 | - build_type: x86-Release-UWP
51 | arch: amd64_x86
52 | - build_type: x86-Debug-UWP-Clang
53 | arch: amd64_x86
54 | - build_type: x86-Release-UWP-Clang
55 | arch: amd64_x86
56 | - build_type: arm64-Debug-UWP
57 | arch: amd64_arm64
58 | - build_type: arm64-Release-UWP
59 | arch: amd64_arm64
60 | - build_type: arm64-Debug-UWP-Clang
61 | arch: amd64_arm64
62 | - build_type: arm64-Release-UWP-Clang
63 | arch: amd64_arm64
64 |
65 | steps:
66 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
67 |
68 | - name: 'Install Ninja'
69 | run: choco install ninja
70 |
71 | - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
72 | with:
73 | arch: ${{ matrix.arch }}
74 | uwp: true
75 |
76 | - name: 'Configure CMake'
77 | working-directory: ${{ github.workspace }}
78 | run: cmake --preset=${{ matrix.build_type }}
79 |
80 | - name: 'Build'
81 | working-directory: ${{ github.workspace }}
82 | run: cmake --build out\build\${{ matrix.build_type }}
83 |
84 | - name: 'Clean up'
85 | working-directory: ${{ github.workspace }}
86 | run: Remove-Item -Path out -Recurse -Force
87 |
88 | - name: 'Configure CMake (DLL)'
89 | working-directory: ${{ github.workspace }}
90 | run: cmake --preset=${{ matrix.build_type }} -DBUILD_SHARED_LIBS=ON
91 |
92 | - name: 'Build (DLL)'
93 | working-directory: ${{ github.workspace }}
94 | run: cmake --build out\build\${{ matrix.build_type }}
95 |
--------------------------------------------------------------------------------
/.github/workflows/win10.yml:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 | #
4 | # http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | name: 'CMake (Windows 10/Windows 11)'
7 |
8 | on:
9 | push:
10 | branches: "main"
11 | paths-ignore:
12 | - '*.md'
13 | - LICENSE
14 | - '.azuredevops/**'
15 | - '.nuget/*'
16 | - build/*.cmd
17 | - build/*.json
18 | - build/*.props
19 | - build/*.ps1
20 | - build/*.targets
21 | pull_request:
22 | branches: "main"
23 | paths-ignore:
24 | - '*.md'
25 | - LICENSE
26 | - '.azuredevops/**'
27 | - '.nuget/*'
28 | - build/*.cmd
29 | - build/*.json
30 | - build/*.props
31 | - build/*.ps1
32 | - build/*.targets
33 |
34 | permissions:
35 | contents: read
36 |
37 | jobs:
38 | build:
39 | runs-on: windows-2022
40 |
41 | strategy:
42 | fail-fast: false
43 |
44 | matrix:
45 | toolver: ['14.29', '14']
46 | build_type: [x64-Debug-Win10, x64-Release-Win10]
47 | arch: [amd64]
48 | include:
49 | - toolver: '14.29'
50 | build_type: x86-Debug-Win10
51 | arch: amd64_x86
52 | - toolver: '14.29'
53 | build_type: x86-Release-Win10
54 | arch: amd64_x86
55 | - toolver: '14'
56 | build_type: x86-Debug-Win10
57 | arch: amd64_x86
58 | - toolver: '14'
59 | build_type: x86-Release-Win10
60 | arch: amd64_x86
61 | - toolver: '14'
62 | build_type: arm64-Debug
63 | arch: amd64_arm64
64 | - toolver: '14'
65 | build_type: arm64-Release
66 | arch: amd64_arm64
67 | - toolver: '14'
68 | build_type: arm64ec-Debug
69 | arch: amd64_arm64
70 | - toolver: '14'
71 | build_type: arm64ec-Release
72 | arch: amd64_arm64
73 | - toolver: '14'
74 | build_type: x64-Debug-Win10-Clang
75 | arch: amd64
76 | - toolver: '14'
77 | build_type: x64-Release-Win10-Clang
78 | arch: amd64
79 | - toolver: '14'
80 | build_type: x86-Debug-Win10-Clang
81 | arch: amd64_x86
82 | - toolver: '14'
83 | build_type: x86-Release-Win10-Clang
84 | arch: amd64_x86
85 | - toolver: '14'
86 | build_type: arm64-Debug-Clang
87 | arch: amd64_arm64
88 | - toolver: '14'
89 | build_type: arm64-Release-Clang
90 | arch: amd64_arm64
91 |
92 | steps:
93 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
94 |
95 | - name: 'Install Ninja'
96 | run: choco install ninja
97 |
98 | - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
99 | with:
100 | arch: ${{ matrix.arch }}
101 | toolset: ${{ matrix.toolver }}
102 |
103 | - name: 'Configure CMake'
104 | working-directory: ${{ github.workspace }}
105 | run: cmake --preset=${{ matrix.build_type }}
106 |
107 | - name: 'Build'
108 | working-directory: ${{ github.workspace }}
109 | run: cmake --build out\build\${{ matrix.build_type }}
110 |
111 | - name: 'Clean up'
112 | working-directory: ${{ github.workspace }}
113 | run: Remove-Item -Path out -Recurse -Force
114 |
115 | - if: matrix.arch != 'amd64_arm64'
116 | name: 'Configure CMake (Spectre)'
117 | working-directory: ${{ github.workspace }}
118 | run: cmake --preset=${{ matrix.build_type }} -DENABLE_SPECTRE_MITIGATION=ON
119 |
120 | - if: matrix.arch != 'amd64_arm64'
121 | name: 'Build (Spectre)'
122 | working-directory: ${{ github.workspace }}
123 | run: cmake --build out\build\${{ matrix.build_type }}
124 |
125 | - if: matrix.arch != 'amd64_arm64'
126 | name: 'Clean up'
127 | working-directory: ${{ github.workspace }}
128 | run: Remove-Item -Path out -Recurse -Force
129 |
130 | - name: 'Configure CMake (DLL)'
131 | working-directory: ${{ github.workspace }}
132 | run: cmake --preset=${{ matrix.build_type }} -DBUILD_SHARED_LIBS=ON
133 |
134 | - name: 'Build (DLL)'
135 | working-directory: ${{ github.workspace }}
136 | run: cmake --build out\build\${{ matrix.build_type }}
137 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.psess
2 | *.vsp
3 | *.log
4 | *.err
5 | *.wrn
6 | *.suo
7 | *.sdf
8 | *.user
9 | *.i
10 | *.vspscc
11 | *.opensdf
12 | *.opendb
13 | *.ipch
14 | *.cache
15 | *.tlog
16 | *.lastbuildstate
17 | *.ilk
18 | *.VC.db
19 | *.nupkg
20 | .vs
21 | Bin
22 | packages
23 | /Src/Shaders/Compiled/*.inc
24 | /Src/Shaders/Compiled/*.pdb
25 | /ipch
26 | /MakeSpriteFont/obj
27 | /Tests
28 | /Testing
29 | /wiki
30 | /out
31 | /CMakeUserPresets.json
32 | /build/vcpkg_installed
33 |
--------------------------------------------------------------------------------
/.nuget/directxtk_desktop_2019.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | directxtk_desktop_2019
5 | 0.0.0-SpecifyVersionOnCommandline
6 | DirectX Tool Kit for DirectX 11 (VS 2019/2022 Win32)
7 | Microsoft
8 | microsoft,directxtk
9 | The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing Direct3D 11.x code in C++.
10 | This version is for Windows desktop applications using Visual Studio 2019 (16.11) or Visual Studio 2022 on Windows 8.1 or later.
11 |
12 | Features:
13 | Audio - low-level audio API using XAudio2
14 | BufferHelpers - C++ helpers for creating D3D resources from CPU data
15 | CommonStates - factory providing commonly used D3D state objects
16 | DirectXHelpers - misc C++ helpers for D3D programming
17 | DDSTextureLoader - light-weight DDS file texture loader
18 | Effects - set of built-in shaders for common rendering tasks
19 | GamePad - gamepad controller helper using XInput
20 | GeometricPrimitive - draws basic shapes such as cubes and spheres
21 | GraphicsMemory - helper for managing dynamic graphics memory allocation
22 | Keyboard - keyboard state tracking helper
23 | Model - draws meshes loaded from .CMO, .SDKMESH, or .VBO files
24 | Mouse - mouse helper
25 | PostProcess - set of built-in shaders for common post-processing operations
26 | PrimitiveBatch - simple and efficient way to draw user primitives
27 | ScreenGrab - light-weight screen shot saver
28 | SimpleMath - simplified C++ wrapper for DirectXMath
29 | SpriteBatch - simple & efficient 2D sprite rendering
30 | SpriteFont - bitmap based text rendering
31 | VertexTypes - structures for commonly used vertex data formats
32 | WICTextureLoader - WIC-based image file texture loader
33 | Matches the March 20, 2025 release on GitHub.
34 |
35 | DirectX Tool Kit for Audio in this package uses XAudio 2.8 to support Windows 8.1.
36 | http://go.microsoft.com/fwlink/?LinkId=248929
37 |
38 | images\icon.jpg
39 | docs\README.md
40 | MIT
41 | false
42 | © Microsoft Corporation. All rights reserved.
43 | DirectX DirectXTK native nativepackage
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/.nuget/directxtk_desktop_2019.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 |
7 |
8 | Release
9 |
10 |
11 | Release
12 |
13 |
14 | Release
15 |
16 |
17 |
18 | $(MSBuildThisFileDirectory)..\..\native\lib\$(PlatformTarget)\$(NuGetConfiguration)
19 |
20 |
21 |
22 |
23 | $(directxtk-LibPath);%(AdditionalLibraryDirectories)
24 | DirectXTK.lib;%(AdditionalDependencies)
25 |
26 |
27 |
28 |
29 |
30 | HAS_DIRECTXTK;_WIN32_WINNT=0x0603;%(PreprocessorDefinitions)
31 | $(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories)
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.nuget/directxtk_desktop_win10.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | directxtk_desktop_win10
5 | 0.0.0-SpecifyVersionOnCommandline
6 | DirectX Tool Kit for DirectX 11 (VS 2022 Win32 for Windows 10/11)
7 | Microsoft
8 | microsoft,directxtk
9 | The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing Direct3D 11.x code in C++.
10 | This version is for Windows desktop applications using Visual Studio 2022 on Windows 10 / Windows 11.
11 |
12 | Features:
13 | Audio - low-level audio API using XAudio2
14 | BufferHelpers - C++ helpers for creating D3D resources from CPU data
15 | CommonStates - factory providing commonly used D3D state objects
16 | DirectXHelpers - misc C++ helpers for D3D programming
17 | DDSTextureLoader - light-weight DDS file texture loader
18 | Effects - set of built-in shaders for common rendering tasks
19 | GamePad - gamepad controller helper using Windows.Gaming.Input
20 | GeometricPrimitive - draws basic shapes such as cubes and spheres
21 | GraphicsMemory - helper for managing dynamic graphics memory allocation
22 | Keyboard - keyboard state tracking helper
23 | Model - draws meshes loaded from .CMO, .SDKMESH, or .VBO files
24 | Mouse - mouse helper
25 | PostProcess - set of built-in shaders for common post-processing operations
26 | PrimitiveBatch - simple and efficient way to draw user primitives
27 | ScreenGrab - light-weight screen shot saver
28 | SimpleMath - simplified C++ wrapper for DirectXMath
29 | SpriteBatch - simple & efficient 2D sprite rendering
30 | SpriteFont - bitmap based text rendering
31 | VertexTypes - structures for commonly used vertex data formats
32 | WICTextureLoader - WIC-based image file texture loader
33 | Matches the March 20, 2025 release on GitHub.
34 |
35 | DirectX Tool Kit for Audio in this package uses XAudio 2.9 which requires Windows 10 or later.
36 | http://go.microsoft.com/fwlink/?LinkId=248929
37 |
38 | images\icon.jpg
39 | docs\README.md
40 | MIT
41 | false
42 | © Microsoft Corporation. All rights reserved.
43 | DirectX DirectXTK native nativepackage ARM64
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/.nuget/directxtk_desktop_win10.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 |
7 |
8 | Release
9 |
10 |
11 | Release
12 |
13 |
14 | Release
15 |
16 |
17 |
18 | $(MSBuildThisFileDirectory)..\..\native\lib\$(PlatformTarget)\$(NuGetConfiguration)
19 |
20 |
21 |
22 |
23 | $(directxtk-LibPath);%(AdditionalLibraryDirectories)
24 | DirectXTK.lib;%(AdditionalDependencies)
25 |
26 |
27 |
28 |
29 |
30 | HAS_DIRECTXTK;_WIN32_WINNT=0x0A00;%(PreprocessorDefinitions)
31 | $(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories)
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.nuget/directxtk_uwp.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | directxtk_uwp
5 | 0.0.0-SpecifyVersionOnCommandline
6 | DirectX Tool Kit for DirectX 11 (UWP)
7 | Microsoft
8 | microsoft,directxtk
9 | The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing Direct3D 11.x code in C++.
10 | This version is for Universal Windows Platform apps on Windows 10 / Windows 11 using Visual Studio 2022.
11 |
12 | Features:
13 | Audio - low-level audio API using XAudio2
14 | BufferHelpers - C++ helpers for creating D3D resources from CPU data
15 | CommonStates - factory providing commonly used D3D state objects
16 | DirectXHelpers - misc C++ helpers for D3D programming
17 | DDSTextureLoader - light-weight DDS file texture loader
18 | Effects - set of built-in shaders for common rendering tasks
19 | GamePad - gamepad controller helper using Windows.Gaming.Input
20 | GeometricPrimitive - draws basic shapes such as cubes and spheres
21 | GraphicsMemory - helper for managing dynamic graphics memory allocation
22 | Keyboard - keyboard state tracking helper
23 | Model - draws meshes loaded from .CMO, .SDKMESH, or .VBO files
24 | Mouse - mouse helper
25 | PostProcess - set of built-in shaders for common post-processing operations
26 | PrimitiveBatch - simple and efficient way to draw user primitives
27 | ScreenGrab - light-weight screen shot saver
28 | SimpleMath - simplified C++ wrapper for DirectXMath
29 | SpriteBatch - simple & efficient 2D sprite rendering
30 | SpriteFont - bitmap based text rendering
31 | VertexTypes - structures for commonly used vertex data formats
32 | WICTextureLoader - WIC-based image file texture loader
33 | Matches the March 20, 2025 release on GitHub.
34 | http://go.microsoft.com/fwlink/?LinkId=248929
35 |
36 | images\icon.jpg
37 | docs\README.md
38 | MIT
39 | false
40 | © Microsoft Corporation. All rights reserved.
41 | DirectX DirectXTK native nativepackage ARM64
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/.nuget/directxtk_uwp.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 |
7 |
8 | Release
9 |
10 |
11 | Release
12 |
13 |
14 | Release
15 |
16 |
17 |
18 | $(MSBuildThisFileDirectory)..\..\native\lib\$(PlatformTarget)\$(NuGetConfiguration)
19 |
20 |
21 |
22 |
23 | $(directxtk-LibPath);%(AdditionalLibraryDirectories)
24 | DirectXTK.lib;%(AdditionalDependencies)
25 |
26 |
27 |
28 |
29 |
30 | HAS_DIRECTXTK;%(PreprocessorDefinitions)
31 | $(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories)
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.nuget/icon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/DirectXTK/c1f67a4846f9cfa0dd448a3173c831d277611c7e/.nuget/icon.jpg
--------------------------------------------------------------------------------
/.onefuzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/DirectXTK/c1f67a4846f9cfa0dd448a3173c831d277611c7e/.onefuzz
--------------------------------------------------------------------------------
/Audio/WAVFileReader.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: WAVFileReader.h
3 | //
4 | // Functions for loading WAV audio files
5 | //
6 | // Copyright (c) Microsoft Corporation.
7 | // Licensed under the MIT License.
8 | //
9 | // http://go.microsoft.com/fwlink/?LinkId=248929
10 | // http://go.microsoft.com/fwlink/?LinkID=615561
11 | //-------------------------------------------------------------------------------------
12 |
13 | #pragma once
14 |
15 | #include
16 |
17 | #include
18 | #include
19 | #include
20 |
21 |
22 | namespace DirectX
23 | {
24 | HRESULT LoadWAVAudioInMemory(
25 | _In_reads_bytes_(wavDataSize) const uint8_t* wavData,
26 | _In_ size_t wavDataSize,
27 | _Outptr_ const WAVEFORMATEX** wfx,
28 | _Outptr_ const uint8_t** startAudio,
29 | _Out_ uint32_t* audioBytes) noexcept;
30 |
31 | HRESULT LoadWAVAudioFromFile(
32 | _In_z_ const wchar_t* szFileName,
33 | _Inout_ std::unique_ptr& wavData,
34 | _Outptr_ const WAVEFORMATEX** wfx,
35 | _Outptr_ const uint8_t** startAudio,
36 | _Out_ uint32_t* audioBytes) noexcept;
37 |
38 | struct WAVData
39 | {
40 | const WAVEFORMATEX* wfx;
41 | const uint8_t* startAudio;
42 | uint32_t audioBytes;
43 | uint32_t loopStart;
44 | uint32_t loopLength;
45 | const uint32_t* seek; // Note: XMA Seek data is Big-Endian
46 | uint32_t seekCount;
47 | };
48 |
49 | HRESULT LoadWAVAudioInMemoryEx(
50 | _In_reads_bytes_(wavDataSize) const uint8_t* wavData,
51 | _In_ size_t wavDataSize,
52 | _Out_ WAVData& result) noexcept;
53 |
54 | HRESULT LoadWAVAudioFromFileEx(
55 | _In_z_ const wchar_t* szFileName,
56 | _Inout_ std::unique_ptr& wavData,
57 | _Out_ WAVData& result) noexcept;
58 | }
59 |
--------------------------------------------------------------------------------
/Audio/WaveBankReader.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: WaveBankReader.h
3 | //
4 | // Functions for loading audio data from Wave Banks
5 | //
6 | // Copyright (c) Microsoft Corporation.
7 | // Licensed under the MIT License.
8 | //
9 | // http://go.microsoft.com/fwlink/?LinkId=248929
10 | // http://go.microsoft.com/fwlink/?LinkID=615561
11 | //-------------------------------------------------------------------------------------
12 |
13 | #pragma once
14 |
15 | #include
16 | #include
17 |
18 | #include
19 | #include
20 |
21 |
22 | namespace DirectX
23 | {
24 | class WaveBankReader
25 | {
26 | public:
27 | WaveBankReader() noexcept(false);
28 |
29 | WaveBankReader(WaveBankReader&&) = default;
30 | WaveBankReader& operator= (WaveBankReader&&) = default;
31 |
32 | WaveBankReader(WaveBankReader const&) = delete;
33 | WaveBankReader& operator= (WaveBankReader const&) = delete;
34 |
35 | ~WaveBankReader();
36 |
37 | HRESULT Open(_In_z_ const wchar_t* szFileName) noexcept;
38 |
39 | uint32_t Find(_In_z_ const char* name) const;
40 |
41 | bool IsPrepared() noexcept;
42 | void WaitOnPrepare() noexcept;
43 |
44 | bool HasNames() const noexcept;
45 | bool IsStreamingBank() const noexcept;
46 |
47 | #if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
48 | bool HasXMA() const noexcept;
49 | #endif
50 |
51 | const char* BankName() const noexcept;
52 |
53 | uint32_t Count() const noexcept;
54 |
55 | uint32_t BankAudioSize() const noexcept;
56 |
57 | HRESULT GetFormat(_In_ uint32_t index, _Out_writes_bytes_(maxsize) WAVEFORMATEX* pFormat, _In_ size_t maxsize) const noexcept;
58 |
59 | HRESULT GetWaveData(_In_ uint32_t index, _Outptr_ const uint8_t** pData, _Out_ uint32_t& dataSize) const noexcept;
60 |
61 | HRESULT GetSeekTable(_In_ uint32_t index, _Out_ const uint32_t** pData, _Out_ uint32_t& dataCount, _Out_ uint32_t& tag) const noexcept;
62 |
63 | HANDLE GetAsyncHandle() const noexcept;
64 |
65 | uint32_t GetWaveAlignment() const noexcept;
66 |
67 | struct Metadata
68 | {
69 | uint32_t duration;
70 | uint32_t loopStart;
71 | uint32_t loopLength;
72 | uint32_t offsetBytes;
73 | uint32_t lengthBytes;
74 | };
75 | HRESULT GetMetadata(_In_ uint32_t index, _Out_ Metadata& metadata) const noexcept;
76 |
77 | private:
78 | // Private implementation.
79 | class Impl;
80 |
81 | std::unique_ptr pImpl;
82 | };
83 | }
84 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Microsoft Open Source Code of Conduct
2 |
3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4 |
5 | Resources:
6 |
7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10 | - Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support)
11 |
--------------------------------------------------------------------------------
/DirectXTK_Desktop_2019.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 15.0.27703.2000
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTK_Desktop_2019", "DirectXTK_Desktop_2019.vcxproj", "{E0B52AE7-E160-4D32-BF3F-910B785E5A8E}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeSpriteFont", "MakeSpriteFont\MakeSpriteFont.csproj", "{7329B02D-C504-482A-A156-181D48CE493C}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XWBTool_Desktop_2019", "XWBTool\XWBTool_Desktop_2019.vcxproj", "{C7AB4186-54B2-4244-A533-77494763EA1D}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0317D9F7-1BFB-4422-8B2F-670E7956F12D}"
13 | ProjectSection(SolutionItems) = preProject
14 | .editorconfig = .editorconfig
15 | EndProjectSection
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Mixed Platforms = Debug|Mixed Platforms
20 | Debug|x64 = Debug|x64
21 | Debug|x86 = Debug|x86
22 | Release|Mixed Platforms = Release|Mixed Platforms
23 | Release|x64 = Release|x64
24 | Release|x86 = Release|x86
25 | EndGlobalSection
26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
27 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
28 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|Mixed Platforms.Build.0 = Debug|Win32
29 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|x64.ActiveCfg = Debug|x64
30 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|x64.Build.0 = Debug|x64
31 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|x86.ActiveCfg = Debug|Win32
32 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|x86.Build.0 = Debug|Win32
33 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|Mixed Platforms.ActiveCfg = Release|Win32
34 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|Mixed Platforms.Build.0 = Release|Win32
35 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|x64.ActiveCfg = Release|x64
36 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|x64.Build.0 = Release|x64
37 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|x86.ActiveCfg = Release|Win32
38 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|x86.Build.0 = Release|Win32
39 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
40 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
41 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|x64.ActiveCfg = Debug|Any CPU
42 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|x64.Build.0 = Debug|Any CPU
43 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|x86.ActiveCfg = Debug|Any CPU
44 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|x86.Build.0 = Debug|Any CPU
45 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
46 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
47 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|x64.ActiveCfg = Release|Any CPU
48 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|x64.Build.0 = Release|Any CPU
49 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|x86.ActiveCfg = Release|Any CPU
50 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|x86.Build.0 = Release|Any CPU
51 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
52 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|Mixed Platforms.Build.0 = Debug|Win32
53 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|x64.ActiveCfg = Debug|x64
54 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|x64.Build.0 = Debug|x64
55 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|x86.ActiveCfg = Debug|Win32
56 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|x86.Build.0 = Debug|Win32
57 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|Mixed Platforms.ActiveCfg = Release|Win32
58 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|Mixed Platforms.Build.0 = Release|Win32
59 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|x64.ActiveCfg = Release|x64
60 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|x64.Build.0 = Release|x64
61 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|x86.ActiveCfg = Release|Win32
62 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|x86.Build.0 = Release|Win32
63 | EndGlobalSection
64 | GlobalSection(SolutionProperties) = preSolution
65 | HideSolutionNode = FALSE
66 | EndGlobalSection
67 | GlobalSection(ExtensibilityGlobals) = postSolution
68 | SolutionGuid = {A26A07B7-AF41-47A4-B21F-8C772153EAA4}
69 | EndGlobalSection
70 | EndGlobal
71 |
--------------------------------------------------------------------------------
/DirectXTK_Desktop_2022.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio Version 17
3 | VisualStudioVersion = 17.12.35514.174 d17.12
4 | MinimumVisualStudioVersion = 10.0.40219.1
5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTK_Desktop_2022", "DirectXTK_Desktop_2022.vcxproj", "{E0B52AE7-E160-4D32-BF3F-910B785E5A8E}"
6 | EndProject
7 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeSpriteFont", "MakeSpriteFont\MakeSpriteFont.csproj", "{7329B02D-C504-482A-A156-181D48CE493C}"
8 | EndProject
9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XWBTool_Desktop_2022", "XWBTool\XWBTool_Desktop_2022.vcxproj", "{C7AB4186-54B2-4244-A533-77494763EA1D}"
10 | EndProject
11 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0317D9F7-1BFB-4422-8B2F-670E7956F12D}"
12 | ProjectSection(SolutionItems) = preProject
13 | .editorconfig = .editorconfig
14 | EndProjectSection
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Mixed Platforms = Debug|Mixed Platforms
19 | Debug|x64 = Debug|x64
20 | Debug|x86 = Debug|x86
21 | Release|Mixed Platforms = Release|Mixed Platforms
22 | Release|x64 = Release|x64
23 | Release|x86 = Release|x86
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
27 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|Mixed Platforms.Build.0 = Debug|Win32
28 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|x64.ActiveCfg = Debug|x64
29 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|x64.Build.0 = Debug|x64
30 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|x86.ActiveCfg = Debug|Win32
31 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Debug|x86.Build.0 = Debug|Win32
32 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|Mixed Platforms.ActiveCfg = Release|Win32
33 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|Mixed Platforms.Build.0 = Release|Win32
34 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|x64.ActiveCfg = Release|x64
35 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|x64.Build.0 = Release|x64
36 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|x86.ActiveCfg = Release|Win32
37 | {E0B52AE7-E160-4D32-BF3F-910B785E5A8E}.Release|x86.Build.0 = Release|Win32
38 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
39 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
40 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|x64.ActiveCfg = Debug|Any CPU
41 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|x64.Build.0 = Debug|Any CPU
42 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|x86.ActiveCfg = Debug|Any CPU
43 | {7329B02D-C504-482A-A156-181D48CE493C}.Debug|x86.Build.0 = Debug|Any CPU
44 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
45 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
46 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|x64.ActiveCfg = Release|Any CPU
47 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|x64.Build.0 = Release|Any CPU
48 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|x86.ActiveCfg = Release|Any CPU
49 | {7329B02D-C504-482A-A156-181D48CE493C}.Release|x86.Build.0 = Release|Any CPU
50 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
51 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|Mixed Platforms.Build.0 = Debug|Win32
52 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|x64.ActiveCfg = Debug|x64
53 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|x64.Build.0 = Debug|x64
54 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|x86.ActiveCfg = Debug|Win32
55 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Debug|x86.Build.0 = Debug|Win32
56 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|Mixed Platforms.ActiveCfg = Release|Win32
57 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|Mixed Platforms.Build.0 = Release|Win32
58 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|x64.ActiveCfg = Release|x64
59 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|x64.Build.0 = Release|x64
60 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|x86.ActiveCfg = Release|Win32
61 | {C7AB4186-54B2-4244-A533-77494763EA1D}.Release|x86.Build.0 = Release|Win32
62 | EndGlobalSection
63 | GlobalSection(SolutionProperties) = preSolution
64 | HideSolutionNode = FALSE
65 | EndGlobalSection
66 | GlobalSection(ExtensibilityGlobals) = postSolution
67 | SolutionGuid = {A26A07B7-AF41-47A4-B21F-8C772153EAA4}
68 | EndGlobalSection
69 | EndGlobal
70 |
--------------------------------------------------------------------------------
/DirectXTK_GDK_2019.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32228.343
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTK", "DirectXTK_GDK_2019.vcxproj", "{26BE66BD-6E77-43BA-B363-725F9FC827C1}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CF6C2CB0-3CB2-42D3-AF77-EBEADDD4BEBF}"
9 | ProjectSection(SolutionItems) = preProject
10 | .editorconfig = .editorconfig
11 | EndProjectSection
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Gaming.Desktop.x64 = Debug|Gaming.Desktop.x64
16 | Profile|Gaming.Desktop.x64 = Profile|Gaming.Desktop.x64
17 | Release|Gaming.Desktop.x64 = Release|Gaming.Desktop.x64
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64
21 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64
22 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Profile|Gaming.Desktop.x64.ActiveCfg = Profile|Gaming.Desktop.x64
23 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Profile|Gaming.Desktop.x64.Build.0 = Profile|Gaming.Desktop.x64
24 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64
25 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64
26 | EndGlobalSection
27 | GlobalSection(SolutionProperties) = preSolution
28 | HideSolutionNode = FALSE
29 | EndGlobalSection
30 | GlobalSection(ExtensibilityGlobals) = postSolution
31 | SolutionGuid = {61313088-A570-4AE2-A5E4-1169FE8F2562}
32 | EndGlobalSection
33 | EndGlobal
34 |
--------------------------------------------------------------------------------
/DirectXTK_GDK_2022.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.32228.430
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTK", "DirectXTK_GDK_2022.vcxproj", "{26BE66BD-6E77-43BA-B363-725F9FC827C1}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8CD5AD55-FCE2-447A-B906-AA5764123738}"
9 | ProjectSection(SolutionItems) = preProject
10 | .editorconfig = .editorconfig
11 | EndProjectSection
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Gaming.Desktop.x64 = Debug|Gaming.Desktop.x64
16 | Profile|Gaming.Desktop.x64 = Profile|Gaming.Desktop.x64
17 | Release|Gaming.Desktop.x64 = Release|Gaming.Desktop.x64
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64
21 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64
22 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Profile|Gaming.Desktop.x64.ActiveCfg = Profile|Gaming.Desktop.x64
23 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Profile|Gaming.Desktop.x64.Build.0 = Profile|Gaming.Desktop.x64
24 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64
25 | {26BE66BD-6E77-43BA-B363-725F9FC827C1}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64
26 | EndGlobalSection
27 | GlobalSection(SolutionProperties) = preSolution
28 | HideSolutionNode = FALSE
29 | EndGlobalSection
30 | GlobalSection(ExtensibilityGlobals) = postSolution
31 | SolutionGuid = {61313088-A570-4AE2-A5E4-1169FE8F2562}
32 | EndGlobalSection
33 | EndGlobal
34 |
--------------------------------------------------------------------------------
/DirectXTK_Windows10_2022.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio Version 17
3 | VisualStudioVersion = 17.7.34009.444
4 | MinimumVisualStudioVersion = 10.0.40219.1
5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTK", "DirectXTK_Windows10_2022.vcxproj", "{F4776924-619C-42C7-88B2-82C947CCC9E7}"
6 | EndProject
7 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{88140C29-E1F8-41E0-9126-6912B6A713BA}"
8 | ProjectSection(SolutionItems) = preProject
9 | .editorconfig = .editorconfig
10 | EndProjectSection
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|ARM64 = Debug|ARM64
15 | Debug|x64 = Debug|x64
16 | Debug|x86 = Debug|x86
17 | Release|ARM64 = Release|ARM64
18 | Release|x64 = Release|x64
19 | Release|x86 = Release|x86
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|ARM64.ActiveCfg = Debug|ARM64
23 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|ARM64.Build.0 = Debug|ARM64
24 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|x64.ActiveCfg = Debug|x64
25 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|x64.Build.0 = Debug|x64
26 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|x86.ActiveCfg = Debug|Win32
27 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|x86.Build.0 = Debug|Win32
28 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|ARM64.ActiveCfg = Release|ARM64
29 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|ARM64.Build.0 = Release|ARM64
30 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|x64.ActiveCfg = Release|x64
31 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|x64.Build.0 = Release|x64
32 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|x86.ActiveCfg = Release|Win32
33 | {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|x86.Build.0 = Release|Win32
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | GlobalSection(ExtensibilityGlobals) = postSolution
39 | SolutionGuid = {FFD89A12-8620-47B9-A00E-6FD1824BFAC5}
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/Inc/CommonStates.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: CommonStates.h
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | //--------------------------------------------------------------------------------------
9 |
10 | #pragma once
11 |
12 | #if defined(_XBOX_ONE) && defined(_TITLE)
13 | #include
14 | #else
15 | #include
16 | #endif
17 |
18 | #include
19 |
20 | #ifndef DIRECTX_TOOLKIT_API
21 | #ifdef DIRECTX_TOOLKIT_EXPORT
22 | #ifdef __GNUC__
23 | #define DIRECTX_TOOLKIT_API __attribute__ ((dllexport))
24 | #else
25 | #define DIRECTX_TOOLKIT_API __declspec(dllexport)
26 | #endif
27 | #elif defined(DIRECTX_TOOLKIT_IMPORT)
28 | #ifdef __GNUC__
29 | #define DIRECTX_TOOLKIT_API __attribute__ ((dllimport))
30 | #else
31 | #define DIRECTX_TOOLKIT_API __declspec(dllimport)
32 | #endif
33 | #else
34 | #define DIRECTX_TOOLKIT_API
35 | #endif
36 | #endif
37 |
38 |
39 | namespace DirectX
40 | {
41 | inline namespace DX11
42 | {
43 | class CommonStates
44 | {
45 | public:
46 | DIRECTX_TOOLKIT_API explicit CommonStates(_In_ ID3D11Device* device);
47 |
48 | DIRECTX_TOOLKIT_API CommonStates(CommonStates&&) noexcept;
49 | DIRECTX_TOOLKIT_API CommonStates& operator= (CommonStates&&) noexcept;
50 |
51 | CommonStates(CommonStates const&) = delete;
52 | CommonStates& operator= (CommonStates const&) = delete;
53 |
54 | DIRECTX_TOOLKIT_API virtual ~CommonStates();
55 |
56 | // Blend states.
57 | DIRECTX_TOOLKIT_API ID3D11BlendState* __cdecl Opaque() const;
58 | DIRECTX_TOOLKIT_API ID3D11BlendState* __cdecl AlphaBlend() const;
59 | DIRECTX_TOOLKIT_API ID3D11BlendState* __cdecl Additive() const;
60 | DIRECTX_TOOLKIT_API ID3D11BlendState* __cdecl NonPremultiplied() const;
61 |
62 | // Depth stencil states.
63 | DIRECTX_TOOLKIT_API ID3D11DepthStencilState* __cdecl DepthNone() const;
64 | DIRECTX_TOOLKIT_API ID3D11DepthStencilState* __cdecl DepthDefault() const;
65 | DIRECTX_TOOLKIT_API ID3D11DepthStencilState* __cdecl DepthRead() const;
66 | DIRECTX_TOOLKIT_API ID3D11DepthStencilState* __cdecl DepthReverseZ() const;
67 | DIRECTX_TOOLKIT_API ID3D11DepthStencilState* __cdecl DepthReadReverseZ() const;
68 |
69 | // Rasterizer states.
70 | DIRECTX_TOOLKIT_API ID3D11RasterizerState* __cdecl CullNone() const;
71 | DIRECTX_TOOLKIT_API ID3D11RasterizerState* __cdecl CullClockwise() const;
72 | DIRECTX_TOOLKIT_API ID3D11RasterizerState* __cdecl CullCounterClockwise() const;
73 | DIRECTX_TOOLKIT_API ID3D11RasterizerState* __cdecl Wireframe() const;
74 |
75 | // Sampler states.
76 | DIRECTX_TOOLKIT_API ID3D11SamplerState* __cdecl PointWrap() const;
77 | DIRECTX_TOOLKIT_API ID3D11SamplerState* __cdecl PointClamp() const;
78 | DIRECTX_TOOLKIT_API ID3D11SamplerState* __cdecl LinearWrap() const;
79 | DIRECTX_TOOLKIT_API ID3D11SamplerState* __cdecl LinearClamp() const;
80 | DIRECTX_TOOLKIT_API ID3D11SamplerState* __cdecl AnisotropicWrap() const;
81 | DIRECTX_TOOLKIT_API ID3D11SamplerState* __cdecl AnisotropicClamp() const;
82 |
83 | private:
84 | // Private implementation.
85 | class Impl;
86 |
87 | std::shared_ptr pImpl;
88 | };
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/Inc/GraphicsMemory.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: GraphicsMemory.h
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | //--------------------------------------------------------------------------------------
9 |
10 | #pragma once
11 |
12 | #if defined(_XBOX_ONE) && defined(_TITLE)
13 | #include
14 | #else
15 | #include
16 | #endif
17 |
18 | #include
19 | #include
20 |
21 | #ifndef DIRECTX_TOOLKIT_API
22 | #ifdef DIRECTX_TOOLKIT_EXPORT
23 | #ifdef __GNUC__
24 | #define DIRECTX_TOOLKIT_API __attribute__ ((dllexport))
25 | #else
26 | #define DIRECTX_TOOLKIT_API __declspec(dllexport)
27 | #endif
28 | #elif defined(DIRECTX_TOOLKIT_IMPORT)
29 | #ifdef __GNUC__
30 | #define DIRECTX_TOOLKIT_API __attribute__ ((dllimport))
31 | #else
32 | #define DIRECTX_TOOLKIT_API __declspec(dllimport)
33 | #endif
34 | #else
35 | #define DIRECTX_TOOLKIT_API
36 | #endif
37 | #endif
38 |
39 |
40 | namespace DirectX
41 | {
42 | inline namespace DX11
43 | {
44 | class GraphicsMemory
45 | {
46 | public:
47 | DIRECTX_TOOLKIT_API
48 | #if defined(_XBOX_ONE) && defined(_TITLE)
49 | GraphicsMemory(
50 | _In_ ID3D11DeviceX* device,
51 | unsigned int backBufferCount = 2);
52 | #else
53 | GraphicsMemory(
54 | _In_ ID3D11Device* device,
55 | unsigned int backBufferCount = 2);
56 | #endif
57 |
58 | DIRECTX_TOOLKIT_API GraphicsMemory(GraphicsMemory&&) noexcept;
59 | DIRECTX_TOOLKIT_API GraphicsMemory& operator= (GraphicsMemory&&) noexcept;
60 |
61 | GraphicsMemory(GraphicsMemory const&) = delete;
62 | GraphicsMemory& operator=(GraphicsMemory const&) = delete;
63 |
64 | DIRECTX_TOOLKIT_API virtual ~GraphicsMemory();
65 |
66 | DIRECTX_TOOLKIT_API void* __cdecl Allocate(
67 | _In_opt_ ID3D11DeviceContext* context,
68 | size_t size,
69 | int alignment);
70 |
71 | DIRECTX_TOOLKIT_API void __cdecl Commit();
72 |
73 | // Singleton
74 | DIRECTX_TOOLKIT_API static GraphicsMemory& __cdecl Get();
75 |
76 | private:
77 | // Private implementation.
78 | class Impl;
79 |
80 | std::unique_ptr pImpl;
81 | };
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Inc/ScreenGrab.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: ScreenGrab.h
3 | //
4 | // Function for capturing a 2D texture and saving it to a file (aka a 'screenshot'
5 | // when used on a Direct3D Render Target).
6 | //
7 | // Note these functions are useful as a light-weight runtime screen grabber. For
8 | // full-featured texture capture, DDS writer, and texture processing pipeline,
9 | // see the 'Texconv' sample and the 'DirectXTex' library.
10 | //
11 | // Copyright (c) Microsoft Corporation.
12 | // Licensed under the MIT License.
13 | //
14 | // http://go.microsoft.com/fwlink/?LinkId=248926
15 | // http://go.microsoft.com/fwlink/?LinkId=248929
16 | //--------------------------------------------------------------------------------------
17 |
18 | #pragma once
19 |
20 | #if defined(_XBOX_ONE) && defined(_TITLE)
21 | #include
22 | #else
23 | #include
24 | #endif
25 |
26 | #include
27 |
28 | #if defined(NTDDI_WIN10_FE) || defined(__MINGW32__)
29 | #include
30 | #else
31 | #include
32 | #endif
33 |
34 | #ifdef _MSC_VER
35 | #pragma comment(lib,"uuid.lib")
36 | #endif
37 |
38 | #ifndef DIRECTX_TOOLKIT_API
39 | #ifdef DIRECTX_TOOLKIT_EXPORT
40 | #ifdef __GNUC__
41 | #define DIRECTX_TOOLKIT_API __attribute__ ((dllexport))
42 | #else
43 | #define DIRECTX_TOOLKIT_API __declspec(dllexport)
44 | #endif
45 | #elif defined(DIRECTX_TOOLKIT_IMPORT)
46 | #ifdef __GNUC__
47 | #define DIRECTX_TOOLKIT_API __attribute__ ((dllimport))
48 | #else
49 | #define DIRECTX_TOOLKIT_API __declspec(dllimport)
50 | #endif
51 | #else
52 | #define DIRECTX_TOOLKIT_API
53 | #endif
54 | #endif
55 |
56 |
57 | namespace DirectX
58 | {
59 | DIRECTX_TOOLKIT_API
60 | HRESULT __cdecl SaveDDSTextureToFile(
61 | _In_ ID3D11DeviceContext* pContext,
62 | _In_ ID3D11Resource* pSource,
63 | _In_z_ const wchar_t* fileName) noexcept;
64 |
65 | DIRECTX_TOOLKIT_API
66 | HRESULT __cdecl SaveWICTextureToFile(
67 | _In_ ID3D11DeviceContext* pContext,
68 | _In_ ID3D11Resource* pSource,
69 | _In_ REFGUID guidContainerFormat,
70 | _In_z_ const wchar_t* fileName,
71 | _In_opt_ const GUID* targetFormat = nullptr,
72 | _In_ std::function setCustomProps = nullptr,
73 | _In_ bool forceSRGB = false);
74 | }
75 |
--------------------------------------------------------------------------------
/Inc/XboxDDSTextureLoader.h:
--------------------------------------------------------------------------------
1 | s//--------------------------------------------------------------------------------------
2 | // File: XboxDDSTextureLoader.h
3 | //
4 | // Functions for loading a DDS texture using the XBOX extended header and creating a
5 | // Direct3D11.X runtime resource for it via the CreatePlacement APIs
6 | //
7 | // Note these functions will not load standard DDS files. Use the DDSTextureLoader
8 | // module in the DirectXTex package or as part of the DirectXTK library to load
9 | // these files which use standard Direct3D resource creation APIs.
10 | //
11 | // Copyright (c) Microsoft Corporation.
12 | // Licensed under the MIT License.
13 | //
14 | // http://go.microsoft.com/fwlink/?LinkId=248926
15 | // http://go.microsoft.com/fwlink/?LinkId=248929
16 | //--------------------------------------------------------------------------------------
17 |
18 | #pragma once
19 |
20 | #if !defined(_XBOX_ONE) || !defined(_TITLE)
21 | #error This module only supports Xbox One exclusive apps
22 | #endif
23 |
24 | #include
25 |
26 | #include
27 | #include
28 |
29 | #ifndef DIRECTX_TOOLKIT_API
30 | #ifdef DIRECTX_TOOLKIT_EXPORT
31 | #ifdef __GNUC__
32 | #define DIRECTX_TOOLKIT_API __attribute__ ((dllexport))
33 | #else
34 | #define DIRECTX_TOOLKIT_API __declspec(dllexport)
35 | #endif
36 | #elif defined(DIRECTX_TOOLKIT_IMPORT)
37 | #ifdef __GNUC__
38 | #define DIRECTX_TOOLKIT_API __attribute__ ((dllimport))
39 | #else
40 | #define DIRECTX_TOOLKIT_API __declspec(dllimport)
41 | #endif
42 | #else
43 | #define DIRECTX_TOOLKIT_API
44 | #endif
45 | #endif
46 |
47 | #ifndef DDS_ALPHA_MODE_DEFINED
48 | #define DDS_ALPHA_MODE_DEFINED
49 | namespace DirectX
50 | {
51 | enum DDS_ALPHA_MODE : uint32_t
52 | {
53 | DDS_ALPHA_MODE_UNKNOWN = 0,
54 | DDS_ALPHA_MODE_STRAIGHT = 1,
55 | DDS_ALPHA_MODE_PREMULTIPLIED = 2,
56 | DDS_ALPHA_MODE_OPAQUE = 3,
57 | DDS_ALPHA_MODE_CUSTOM = 4,
58 | };
59 | }
60 | #endif
61 |
62 |
63 | namespace Xbox
64 | {
65 | using DirectX::DDS_ALPHA_MODE;
66 |
67 | DIRECTX_TOOLKIT_API
68 | HRESULT __cdecl CreateDDSTextureFromMemory(
69 | _In_ ID3D11DeviceX* d3dDevice,
70 | _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
71 | _In_ size_t ddsDataSize,
72 | _Outptr_opt_ ID3D11Resource** texture,
73 | _Outptr_opt_ ID3D11ShaderResourceView** textureView,
74 | _Outptr_ void** grfxMemory,
75 | _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
76 | _In_ bool forceSRGB = false) noexcept;
77 |
78 | DIRECTX_TOOLKIT_API
79 | HRESULT __cdecl CreateDDSTextureFromFile(
80 | _In_ ID3D11DeviceX* d3dDevice,
81 | _In_z_ const wchar_t* szFileName,
82 | _Outptr_opt_ ID3D11Resource** texture,
83 | _Outptr_opt_ ID3D11ShaderResourceView** textureView,
84 | _Outptr_ void** grfxMemory,
85 | _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
86 | _In_ bool forceSRGB = false) noexcept;
87 |
88 | DIRECTX_TOOLKIT_API
89 | void FreeDDSTextureMemory(_In_opt_ void* grfxMemory) noexcept;
90 |
91 | #ifdef __cpp_lib_byte
92 | DIRECTX_TOOLKIT_API
93 | inline HRESULT __cdecl CreateDDSTextureFromMemory(
94 | _In_ ID3D11DeviceX* d3dDevice,
95 | _In_reads_bytes_(ddsDataSize) const std::byte* ddsData,
96 | _In_ size_t ddsDataSize,
97 | _Outptr_opt_ ID3D11Resource** texture,
98 | _Outptr_opt_ ID3D11ShaderResourceView** textureView,
99 | _Outptr_ void** grfxMemory,
100 | _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
101 | _In_ bool forceSRGB = false) noexcept
102 | {
103 | return CreateDDSTextureFromMemory(d3dDevice, reinterpret_cast(ddsData), ddsDataSize, texture, textureView, grfxMemory, alphaMode, forceSRGB);
104 | }
105 | #endif // __cpp_lib_byte
106 | }
107 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/MakeSpriteFont/BitmapImporter.cs:
--------------------------------------------------------------------------------
1 | // DirectXTK MakeSpriteFont tool
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // Licensed under the MIT License.
5 | //
6 | // http://go.microsoft.com/fwlink/?LinkId=248929
7 |
8 | using System;
9 | using System.Linq;
10 | using System.Collections.Generic;
11 | using System.Drawing;
12 | using System.Drawing.Imaging;
13 |
14 | namespace MakeSpriteFont
15 | {
16 | // Extracts font glyphs from a specially marked 2D bitmap. Characters should be
17 | // arranged in a grid ordered from top left to bottom right. Monochrome characters
18 | // should use white for solid areas and black for transparent areas. To include
19 | // multicolored characters, add an alpha channel to the bitmap and use that to
20 | // control which parts of the character are solid. The spaces between characters
21 | // and around the edges of the grid should be filled with bright pink (red=255,
22 | // green=0, blue=255). It doesn't matter if your grid includes lots of wasted space,
23 | // because the converter will rearrange characters, packing as tightly as possible.
24 | public class BitmapImporter : IFontImporter
25 | {
26 | // Properties hold the imported font data.
27 | public IEnumerable Glyphs { get; private set; }
28 |
29 | public float LineSpacing { get; private set; }
30 |
31 |
32 | public void Import(CommandLineOptions options)
33 | {
34 | // Load the source bitmap.
35 | Bitmap bitmap;
36 |
37 | try
38 | {
39 | bitmap = new Bitmap(options.SourceFont);
40 | }
41 | catch
42 | {
43 | throw new Exception(string.Format("Unable to load '{0}'.", options.SourceFont));
44 | }
45 |
46 | // Convert to our desired pixel format.
47 | bitmap = BitmapUtils.ChangePixelFormat(bitmap, PixelFormat.Format32bppArgb);
48 |
49 | // What characters are included in this font?
50 | var characters = CharacterRegion.Flatten(options.CharacterRegions).ToArray();
51 | int characterIndex = 0;
52 | char currentCharacter = '\0';
53 |
54 | // Split the source image into a list of individual glyphs.
55 | var glyphList = new List();
56 |
57 | Glyphs = glyphList;
58 | LineSpacing = 0;
59 |
60 | foreach (Rectangle rectangle in FindGlyphs(bitmap))
61 | {
62 | if (characterIndex < characters.Length)
63 | currentCharacter = characters[characterIndex++];
64 | else
65 | currentCharacter++;
66 |
67 | glyphList.Add(new Glyph(currentCharacter, bitmap, rectangle));
68 |
69 | LineSpacing = Math.Max(LineSpacing, rectangle.Height);
70 | }
71 |
72 | // If the bitmap doesn't already have an alpha channel, create one now.
73 | if (BitmapUtils.IsAlphaEntirely(255, bitmap))
74 | {
75 | BitmapUtils.ConvertGreyToAlpha(bitmap);
76 | }
77 | }
78 |
79 |
80 | // Searches a 2D bitmap for characters that are surrounded by a marker pink color.
81 | static IEnumerable FindGlyphs(Bitmap bitmap)
82 | {
83 | using (var bitmapData = new BitmapUtils.PixelAccessor(bitmap, ImageLockMode.ReadOnly))
84 | {
85 | for (int y = 1; y < bitmap.Height; y++)
86 | {
87 | for (int x = 1; x < bitmap.Width; x++)
88 | {
89 | // Look for the top left corner of a character (a pixel that is not pink, but was pink immediately to the left and above it)
90 | if (!IsMarkerColor(bitmapData[x, y]) &&
91 | IsMarkerColor(bitmapData[x - 1, y]) &&
92 | IsMarkerColor(bitmapData[x, y - 1]))
93 | {
94 | // Measure the size of this character.
95 | int w = 1, h = 1;
96 |
97 | while ((x + w < bitmap.Width) && !IsMarkerColor(bitmapData[x + w, y]))
98 | {
99 | w++;
100 | }
101 |
102 | while ((y + h < bitmap.Height) && !IsMarkerColor(bitmapData[x, y + h]))
103 | {
104 | h++;
105 | }
106 |
107 | yield return new Rectangle(x, y, w, h);
108 | }
109 | }
110 | }
111 | }
112 | }
113 |
114 |
115 | // Checks whether a color is the magic magenta marker value.
116 | static bool IsMarkerColor(Color color)
117 | {
118 | return color.ToArgb() == Color.Magenta.ToArgb();
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/MakeSpriteFont/CharacterRegion.cs:
--------------------------------------------------------------------------------
1 | // DirectXTK MakeSpriteFont tool
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // Licensed under the MIT License.
5 | //
6 | // http://go.microsoft.com/fwlink/?LinkId=248929
7 |
8 | using System;
9 | using System.Linq;
10 | using System.ComponentModel;
11 | using System.Globalization;
12 | using System.Collections.Generic;
13 |
14 | namespace MakeSpriteFont
15 | {
16 | // Describes a range of consecutive characters that should be included in the font.
17 | [TypeConverter(typeof(CharacterRegionTypeConverter))]
18 | public class CharacterRegion
19 | {
20 | // Constructor.
21 | public CharacterRegion(char start, char end)
22 | {
23 | if (start > end)
24 | throw new ArgumentException();
25 |
26 | this.Start = start;
27 | this.End = end;
28 | }
29 |
30 |
31 | // Fields.
32 | public char Start;
33 | public char End;
34 |
35 |
36 | // Enumerates all characters within the region.
37 | public IEnumerable Characters
38 | {
39 | get
40 | {
41 | for (char c = Start; c <= End; c++)
42 | {
43 | yield return c;
44 | }
45 | }
46 | }
47 |
48 |
49 | // Flattens a list of character regions into a combined list of individual characters.
50 | public static IEnumerable Flatten(IEnumerable regions)
51 | {
52 | if (regions.Any())
53 | {
54 | // If we have any regions, flatten them and remove duplicates.
55 | return regions.SelectMany(region => region.Characters).Distinct();
56 | }
57 | else
58 | {
59 | // If no regions were specified, use the default.
60 | return defaultRegion.Characters;
61 | }
62 | }
63 |
64 |
65 | // Default to just the base ASCII character set.
66 | static CharacterRegion defaultRegion = new CharacterRegion(' ', '~');
67 | }
68 |
69 |
70 |
71 | // Custom type converter enables CommandLineParser to parse CharacterRegion command line options.
72 | public class CharacterRegionTypeConverter : TypeConverter
73 | {
74 | public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
75 | {
76 | return sourceType == typeof(string);
77 | }
78 |
79 |
80 | public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
81 | {
82 | // Input must be a string.
83 | string source = value as string;
84 |
85 | if (string.IsNullOrEmpty(source))
86 | {
87 | throw new ArgumentException();
88 | }
89 |
90 | // Supported input formats:
91 | // A
92 | // A-Z
93 | // 32-127
94 | // 0x20-0x7F
95 |
96 | char[] split = source.Split('-')
97 | .Select(ConvertCharacter)
98 | .ToArray();
99 |
100 | switch (split.Length)
101 | {
102 | case 1:
103 | // Only a single character (eg. "a").
104 | return new CharacterRegion(split[0], split[0]);
105 |
106 | case 2:
107 | // Range of characters (eg. "a-z").
108 | return new CharacterRegion(split[0], split[1]);
109 |
110 | default:
111 | throw new ArgumentException();
112 | }
113 | }
114 |
115 |
116 | static char ConvertCharacter(string value)
117 | {
118 | if (value.Length == 1)
119 | {
120 | // Single character directly specifies a codepoint.
121 | return value[0];
122 | }
123 | else
124 | {
125 | // Otherwise it must be an integer (eg. "32" or "0x20").
126 | return (char)(int)intConverter.ConvertFromInvariantString(value);
127 | }
128 | }
129 |
130 |
131 | static TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/MakeSpriteFont/CommandLineOptions.cs:
--------------------------------------------------------------------------------
1 | // DirectXTK MakeSpriteFont tool
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // Licensed under the MIT License.
5 | //
6 | // http://go.microsoft.com/fwlink/?LinkId=248929
7 |
8 | using System.Collections.Generic;
9 | using System.Drawing;
10 |
11 | namespace MakeSpriteFont
12 | {
13 | // Available output texture formats.
14 | public enum TextureFormat
15 | {
16 | Auto,
17 | Rgba32,
18 | Bgra4444,
19 | CompressedMono,
20 | }
21 |
22 |
23 | // Feature levels
24 | public enum FeatureLevel
25 | {
26 | FL9_1,
27 | FL9_2,
28 | FL9_3,
29 | FL10_0,
30 | FL10_1,
31 | FL11_0,
32 | FL11_1,
33 | FL12_0,
34 | FL12_1,
35 | FL12_2,
36 | }
37 |
38 |
39 | // Options telling the tool what to do.
40 | public class CommandLineOptions
41 | {
42 | // Input can be either a system (TrueType) font or a specially marked bitmap file.
43 | [CommandLineParser.Required]
44 | public string SourceFont;
45 |
46 |
47 | // Output spritefont binary.
48 | [CommandLineParser.Required]
49 | public string OutputFile;
50 |
51 |
52 | // Which characters to include in the font (eg. "/CharacterRegion:0x20-0x7F /CharacterRegion:0x123")
53 | [CommandLineParser.Name("CharacterRegion")]
54 | public readonly List CharacterRegions = new List();
55 |
56 |
57 | // Fallback character used when asked to render a codepoint that is not
58 | // included in the font. If zero, missing characters throw exceptions.
59 | public readonly int DefaultCharacter = 0;
60 |
61 |
62 | // Size and style for TrueType fonts (ignored when converting a bitmap font).
63 | public float FontSize = 23;
64 |
65 | public FontStyle FontStyle = FontStyle.Regular;
66 |
67 |
68 | // Spacing overrides. Zero is default spacing, negative closer together, positive further apart.
69 | public float LineSpacing = 0;
70 | public float CharacterSpacing = 0;
71 |
72 |
73 | // Use smooth or sharp antialiasing mode for TrueType rasterization?
74 | public bool Sharp = false;
75 |
76 |
77 | // What format should the output texture be?
78 | public TextureFormat TextureFormat = TextureFormat.Auto;
79 |
80 |
81 | // By default, font textures use premultiplied alpha format. Set this if you want interpolative alpha instead.
82 | public bool NoPremultiply = false;
83 |
84 |
85 | // Dumps the generated sprite texture to a bitmap file (useful for debugging).
86 | public string DebugOutputSpriteSheet = null;
87 |
88 |
89 | // Controls texture-size based warnings
90 | public FeatureLevel FeatureLevel = FeatureLevel.FL9_1;
91 |
92 |
93 | // For large fonts, the default tightest pack is too slow
94 | public bool FastPack = false;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/MakeSpriteFont/Glyph.cs:
--------------------------------------------------------------------------------
1 | // DirectXTK MakeSpriteFont tool
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // Licensed under the MIT License.
5 | //
6 | // http://go.microsoft.com/fwlink/?LinkId=248929
7 |
8 | using System.Drawing;
9 |
10 | namespace MakeSpriteFont
11 | {
12 | // Represents a single character within a font.
13 | public class Glyph
14 | {
15 | // Constructor.
16 | public Glyph(char character, Bitmap bitmap, Rectangle? subrect = null)
17 | {
18 | this.Character = character;
19 | this.Bitmap = bitmap;
20 | this.Subrect = subrect.GetValueOrDefault(new Rectangle(0, 0, bitmap.Width, bitmap.Height));
21 | }
22 |
23 |
24 | // Unicode codepoint.
25 | public char Character;
26 |
27 |
28 | // Glyph image data (may only use a portion of a larger bitmap).
29 | public Bitmap Bitmap;
30 | public Rectangle Subrect;
31 |
32 |
33 | // Layout information.
34 | public float XOffset;
35 | public float YOffset;
36 |
37 | public float XAdvance;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/MakeSpriteFont/GlyphCropper.cs:
--------------------------------------------------------------------------------
1 | // DirectXTK MakeSpriteFont tool
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // Licensed under the MIT License.
5 | //
6 | // http://go.microsoft.com/fwlink/?LinkId=248929
7 |
8 | using System.Drawing;
9 |
10 | namespace MakeSpriteFont
11 | {
12 | // Crops unused space from around the edge of a glyph bitmap.
13 | public static class GlyphCropper
14 | {
15 | public static void Crop(Glyph glyph)
16 | {
17 | // Crop the top.
18 | while ((glyph.Subrect.Height > 1) && BitmapUtils.IsAlphaEntirely(0, glyph.Bitmap, new Rectangle(glyph.Subrect.X, glyph.Subrect.Y, glyph.Subrect.Width, 1)))
19 | {
20 | glyph.Subrect.Y++;
21 | glyph.Subrect.Height--;
22 |
23 | glyph.YOffset++;
24 | }
25 |
26 | // Crop the bottom.
27 | while ((glyph.Subrect.Height > 1) && BitmapUtils.IsAlphaEntirely(0, glyph.Bitmap, new Rectangle(glyph.Subrect.X, glyph.Subrect.Bottom - 1, glyph.Subrect.Width, 1)))
28 | {
29 | glyph.Subrect.Height--;
30 | }
31 |
32 | // Crop the left.
33 | while ((glyph.Subrect.Width > 1) && BitmapUtils.IsAlphaEntirely(0, glyph.Bitmap, new Rectangle(glyph.Subrect.X, glyph.Subrect.Y, 1, glyph.Subrect.Height)))
34 | {
35 | glyph.Subrect.X++;
36 | glyph.Subrect.Width--;
37 |
38 | glyph.XOffset++;
39 | }
40 |
41 | // Crop the right.
42 | while ((glyph.Subrect.Width > 1) && BitmapUtils.IsAlphaEntirely(0, glyph.Bitmap, new Rectangle(glyph.Subrect.Right - 1, glyph.Subrect.Y, 1, glyph.Subrect.Height)))
43 | {
44 | glyph.Subrect.Width--;
45 |
46 | glyph.XAdvance++;
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/MakeSpriteFont/IFontImporter.cs:
--------------------------------------------------------------------------------
1 | // DirectXTK MakeSpriteFont tool
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // Licensed under the MIT License.
5 | //
6 | // http://go.microsoft.com/fwlink/?LinkId=248929
7 |
8 | using System.Collections.Generic;
9 |
10 | namespace MakeSpriteFont
11 | {
12 | // Importer interface allows the conversion tool to support multiple source font formats.
13 | public interface IFontImporter
14 | {
15 | void Import(CommandLineOptions options);
16 |
17 | IEnumerable Glyphs { get; }
18 |
19 | float LineSpacing { get; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/MakeSpriteFont/MakeSpriteFont.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {7329B02D-C504-482A-A156-181D48CE493C}
9 | Exe
10 | Properties
11 | MakeSpriteFont
12 | MakeSpriteFont
13 | v4.7.2
14 |
15 | 512
16 |
17 |
18 | true
19 | bin\Debug\
20 | DEBUG;TRACE
21 | full
22 | AnyCPU
23 | prompt
24 |
25 |
26 | bin\Release\
27 | TRACE
28 | true
29 | pdbonly
30 | AnyCPU
31 | prompt
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
60 |
--------------------------------------------------------------------------------
/MakeSpriteFont/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | //
4 | // http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 | using System.Reflection;
7 | using System.Runtime.CompilerServices;
8 | using System.Runtime.InteropServices;
9 |
10 | [assembly: AssemblyTitle("MakeSpriteFont")]
11 | [assembly: AssemblyDescription(".spritefont creator command-line tool")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("Microsoft Corporation")]
14 | [assembly: AssemblyProduct("DirectX Tool Kit")]
15 | [assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation.")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 | [assembly: ComVisible(false)]
19 | [assembly: Guid("12c0da00-f622-41f2-ab8f-1b4e19aa2a6f")]
20 | [assembly: AssemblyVersion("1.0.0.0")]
21 | [assembly: AssemblyFileVersion("1.0.0.0")]
22 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Security
4 |
5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin).
6 |
7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
8 |
9 | ## Reporting Security Issues
10 |
11 | **Please do not report security vulnerabilities through public GitHub issues.**
12 |
13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
14 |
15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
16 |
17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
18 |
19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20 |
21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22 | * Full paths of source file(s) related to the manifestation of the issue
23 | * The location of the affected source code (tag/branch/commit or direct URL)
24 | * Any special configuration required to reproduce the issue
25 | * Step-by-step instructions to reproduce the issue
26 | * Proof-of-concept or exploit code (if possible)
27 | * Impact of the issue, including how an attacker might exploit the issue
28 |
29 | This information will help us triage your report more quickly.
30 |
31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
32 |
33 | ## Preferred Languages
34 |
35 | We prefer all communications to be in English.
36 |
37 | ## Policy
38 |
39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Src/AlignedNew.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: AlignedNew.h
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | // http://go.microsoft.com/fwlink/?LinkID=615561
9 | //--------------------------------------------------------------------------------------
10 |
11 | #pragma once
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | #ifdef _WIN32
18 | #include
19 | #endif
20 |
21 |
22 | namespace DirectX
23 | {
24 | // Derive from this to customize operator new and delete for
25 | // types that have special heap alignment requirements.
26 | //
27 | // Example usage:
28 | //
29 | // XM_ALIGNED_STRUCT(16) MyAlignedType : public AlignedNew
30 |
31 | template
32 | struct AlignedNew
33 | {
34 | // Allocate aligned memory.
35 | static void* operator new (size_t size)
36 | {
37 | const size_t alignment = alignof(TDerived);
38 |
39 | static_assert(alignment > 8, "AlignedNew is only useful for types with > 8 byte alignment. Did you forget a __declspec(align) on TDerived?");
40 | static_assert(((alignment - 1) & alignment) == 0, "AlignedNew only works with power of two alignment");
41 |
42 | #ifdef _WIN32
43 | void* ptr = _aligned_malloc(size, alignment);
44 | #else
45 | // This C++17 Standard Library function is currently NOT
46 | // implemented for the Microsoft Standard C++ Library.
47 | void* ptr = aligned_alloc(alignment, size);
48 | #endif
49 | if (!ptr)
50 | throw std::bad_alloc();
51 |
52 | return ptr;
53 | }
54 |
55 |
56 | // Free aligned memory.
57 | static void operator delete (void* ptr)
58 | {
59 | #ifdef _WIN32
60 | _aligned_free(ptr);
61 | #else
62 | free(ptr);
63 | #endif
64 | }
65 |
66 |
67 | // Array overloads.
68 | static void* operator new[](size_t size)
69 | {
70 | static_assert((sizeof(TDerived) % alignof(TDerived) == 0), "AlignedNew expects type to be padded to the alignment");
71 |
72 | return operator new(size);
73 | }
74 |
75 |
76 | static void operator delete[](void* ptr)
77 | {
78 | operator delete(ptr);
79 | }
80 | };
81 | }
82 |
--------------------------------------------------------------------------------
/Src/BinaryReader.cpp:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: BinaryReader.cpp
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | // http://go.microsoft.com/fwlink/?LinkID=615561
9 | //--------------------------------------------------------------------------------------
10 |
11 | #include "pch.h"
12 |
13 | #include "BinaryReader.h"
14 |
15 | using namespace DirectX;
16 |
17 |
18 | // Constructor reads from the filesystem.
19 | BinaryReader::BinaryReader(_In_z_ wchar_t const* fileName) noexcept(false) :
20 | mPos(nullptr),
21 | mEnd(nullptr)
22 | {
23 | size_t dataSize;
24 |
25 | HRESULT hr = ReadEntireFile(fileName, mOwnedData, &dataSize);
26 | if (FAILED(hr))
27 | {
28 | DebugTrace("ERROR: BinaryReader failed (%08X) to load '%ls'\n",
29 | static_cast(hr), fileName);
30 | throw std::runtime_error("BinaryReader");
31 | }
32 |
33 | mPos = mOwnedData.get();
34 | mEnd = mOwnedData.get() + dataSize;
35 | }
36 |
37 |
38 | // Constructor reads from an existing memory buffer.
39 | BinaryReader::BinaryReader(_In_reads_bytes_(dataSize) uint8_t const* dataBlob, size_t dataSize) noexcept :
40 | mPos(dataBlob),
41 | mEnd(dataBlob + dataSize)
42 | {}
43 |
44 |
45 | // Reads from the filesystem into memory.
46 | HRESULT BinaryReader::ReadEntireFile(
47 | _In_z_ wchar_t const* fileName,
48 | _Inout_ std::unique_ptr& data,
49 | _Out_ size_t* dataSize)
50 | {
51 | if (!fileName || !dataSize)
52 | return E_INVALIDARG;
53 |
54 | *dataSize = 0;
55 |
56 | // Open the file.
57 | ScopedHandle hFile(safe_handle(CreateFile2(
58 | fileName,
59 | GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING,
60 | nullptr)));
61 | if (!hFile)
62 | return HRESULT_FROM_WIN32(GetLastError());
63 |
64 | // Get the file size.
65 | FILE_STANDARD_INFO fileInfo;
66 | if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo)))
67 | {
68 | return HRESULT_FROM_WIN32(GetLastError());
69 | }
70 |
71 | // File is too big for 32-bit allocation, so reject read.
72 | if (fileInfo.EndOfFile.HighPart > 0)
73 | return E_FAIL;
74 |
75 | // Create enough space for the file data.
76 | data.reset(new uint8_t[fileInfo.EndOfFile.LowPart]);
77 |
78 | if (!data)
79 | return E_OUTOFMEMORY;
80 |
81 | // Read the data in.
82 | DWORD bytesRead = 0;
83 |
84 | if (!ReadFile(hFile.get(), data.get(), fileInfo.EndOfFile.LowPart, &bytesRead, nullptr))
85 | {
86 | return HRESULT_FROM_WIN32(GetLastError());
87 | }
88 |
89 | if (bytesRead < fileInfo.EndOfFile.LowPart)
90 | return E_FAIL;
91 |
92 | *dataSize = bytesRead;
93 |
94 | return S_OK;
95 | }
96 |
--------------------------------------------------------------------------------
/Src/BinaryReader.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: BinaryReader.h
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | // http://go.microsoft.com/fwlink/?LinkID=615561
9 | //--------------------------------------------------------------------------------------
10 |
11 | #pragma once
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 | #include "PlatformHelpers.h"
19 |
20 |
21 | namespace DirectX
22 | {
23 | // Helper for reading binary data, either from the filesystem a memory buffer.
24 | class BinaryReader
25 | {
26 | public:
27 | explicit BinaryReader(_In_z_ wchar_t const* fileName) noexcept(false);
28 | BinaryReader(_In_reads_bytes_(dataSize) uint8_t const* dataBlob, size_t dataSize) noexcept;
29 |
30 | BinaryReader(BinaryReader const&) = delete;
31 | BinaryReader& operator= (BinaryReader const&) = delete;
32 |
33 | // Reads a single value.
34 | template T const& Read()
35 | {
36 | return *ReadArray(1);
37 | }
38 |
39 |
40 | // Reads an array of values.
41 | template T const* ReadArray(size_t elementCount)
42 | {
43 | static_assert(std::is_standard_layout::value, "Can only read plain-old-data types");
44 |
45 | uint8_t const* newPos = mPos + sizeof(T) * elementCount;
46 |
47 | if (newPos < mPos)
48 | throw std::overflow_error("ReadArray");
49 |
50 | if (newPos > mEnd)
51 | throw std::runtime_error("End of file");
52 |
53 | auto result = reinterpret_cast(mPos);
54 |
55 | mPos = newPos;
56 |
57 | return result;
58 | }
59 |
60 |
61 | // Lower level helper reads directly from the filesystem into memory.
62 | static HRESULT ReadEntireFile(_In_z_ wchar_t const* fileName, _Inout_ std::unique_ptr& data, _Out_ size_t* dataSize);
63 |
64 |
65 | private:
66 | // The data currently being read.
67 | uint8_t const* mPos;
68 | uint8_t const* mEnd;
69 |
70 | std::unique_ptr mOwnedData;
71 | };
72 | }
73 |
--------------------------------------------------------------------------------
/Src/DemandCreate.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: DemandCreate.h
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | // http://go.microsoft.com/fwlink/?LinkID=615561
9 | //--------------------------------------------------------------------------------------
10 |
11 | #pragma once
12 |
13 | #include "PlatformHelpers.h"
14 |
15 |
16 | namespace DirectX
17 | {
18 | // Helper for lazily creating a D3D resource.
19 | template
20 | inline T* DemandCreate(Microsoft::WRL::ComPtr& comPtr, std::mutex& mutex, TCreateFunc createFunc)
21 | {
22 | T* result = comPtr.Get();
23 |
24 | // Double-checked lock pattern.
25 | #ifdef _MSC_VER
26 | MemoryBarrier();
27 | #elif defined(__GNUC__)
28 | __sync_synchronize();
29 | #else
30 | #error Unknown memory barrier syntax
31 | #endif
32 |
33 | if (!result)
34 | {
35 | std::lock_guard lock(mutex);
36 |
37 | result = comPtr.Get();
38 |
39 | if (!result)
40 | {
41 | // Create the new object.
42 | ThrowIfFailed(
43 | createFunc(&result)
44 | );
45 |
46 | #ifdef _MSC_VER
47 | MemoryBarrier();
48 | #elif defined(__GNUC__)
49 | __sync_synchronize();
50 | #endif
51 |
52 | comPtr.Attach(result);
53 | }
54 | }
55 |
56 | return result;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Src/DirectXHelpers.cpp:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: DirectXHelpers.cpp
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | //--------------------------------------------------------------------------------------
9 |
10 | #include "pch.h"
11 | #include "DirectXHelpers.h"
12 | #include "Effects.h"
13 | #include "PlatformHelpers.h"
14 |
15 |
16 | using namespace DirectX;
17 |
18 | _Use_decl_annotations_
19 | HRESULT DirectX::CreateInputLayoutFromEffect(
20 | ID3D11Device* device,
21 | IEffect* effect,
22 | const D3D11_INPUT_ELEMENT_DESC* desc,
23 | size_t count,
24 | ID3D11InputLayout** pInputLayout) noexcept
25 | {
26 | if (!pInputLayout)
27 | return E_INVALIDARG;
28 |
29 | *pInputLayout = nullptr;
30 |
31 | if (!device || !effect || !desc || !count)
32 | return E_INVALIDARG;
33 |
34 | void const* shaderByteCode;
35 | size_t byteCodeLength;
36 |
37 | try
38 | {
39 | effect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength);
40 | }
41 | catch (com_exception e)
42 | {
43 | return e.get_result();
44 | }
45 | catch (...)
46 | {
47 | return E_FAIL;
48 | }
49 |
50 | return device->CreateInputLayout(
51 | desc, static_cast(count),
52 | shaderByteCode, byteCodeLength,
53 | pInputLayout);
54 | }
55 |
--------------------------------------------------------------------------------
/Src/Geometry.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: Geometry.h
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | // http://go.microsoft.com/fwlink/?LinkID=615561
9 | //--------------------------------------------------------------------------------------
10 |
11 | #include "VertexTypes.h"
12 |
13 | namespace DirectX
14 | {
15 | using VertexCollection = std::vector;
16 | using IndexCollection = std::vector;
17 |
18 | void ComputeBox(VertexCollection& vertices, IndexCollection& indices, const XMFLOAT3& size, bool rhcoords, bool invertn);
19 | void ComputeSphere(VertexCollection& vertices, IndexCollection& indices, float diameter, size_t tessellation, bool rhcoords, bool invertn);
20 | void ComputeGeoSphere(VertexCollection& vertices, IndexCollection& indices, float diameter, size_t tessellation, bool rhcoords);
21 | void ComputeCylinder(VertexCollection& vertices, IndexCollection& indices, float height, float diameter, size_t tessellation, bool rhcoords);
22 | void ComputeCone(VertexCollection& vertices, IndexCollection& indices, float diameter, float height, size_t tessellation, bool rhcoords);
23 | void ComputeTorus(VertexCollection& vertices, IndexCollection& indices, float diameter, float thickness, size_t tessellation, bool rhcoords);
24 | void ComputeTetrahedron(VertexCollection& vertices, IndexCollection& indices, float size, bool rhcoords);
25 | void ComputeOctahedron(VertexCollection& vertices, IndexCollection& indices, float size, bool rhcoords);
26 | void ComputeDodecahedron(VertexCollection& vertices, IndexCollection& indices, float size, bool rhcoords);
27 | void ComputeIcosahedron(VertexCollection& vertices, IndexCollection& indices, float size, bool rhcoords);
28 | void ComputeTeapot(VertexCollection& vertices, IndexCollection& indices, float size, size_t tessellation, bool rhcoords);
29 | }
30 |
--------------------------------------------------------------------------------
/Src/PlatformHelpers.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: PlatformHelpers.h
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | // http://go.microsoft.com/fwlink/?LinkID=615561
9 | //--------------------------------------------------------------------------------------
10 |
11 | #pragma once
12 |
13 | #ifdef _MSC_VER
14 | #pragma warning(disable : 4324)
15 | #endif
16 |
17 | #include
18 | #include
19 |
20 | #ifndef MAKEFOURCC
21 | #define MAKEFOURCC(ch0, ch1, ch2, ch3) \
22 | (static_cast(static_cast(ch0)) \
23 | | (static_cast(static_cast(ch1)) << 8) \
24 | | (static_cast(static_cast(ch2)) << 16) \
25 | | (static_cast(static_cast(ch3)) << 24))
26 | #endif /* defined(MAKEFOURCC) */
27 |
28 | // See https://walbourn.github.io/modern-c++-bitmask-types/
29 | #ifndef ENUM_FLAGS_CONSTEXPR
30 | #if defined(NTDDI_WIN10_RS1) && !defined(__MINGW32__)
31 | #define ENUM_FLAGS_CONSTEXPR constexpr
32 | #else
33 | #define ENUM_FLAGS_CONSTEXPR const
34 | #endif
35 | #endif
36 |
37 | namespace DirectX
38 | {
39 | // Helper class for COM exceptions
40 | class com_exception : public std::exception
41 | {
42 | public:
43 | com_exception(HRESULT hr) noexcept : result(hr) {}
44 |
45 | const char* what() const noexcept override
46 | {
47 | static char s_str[64] = {};
48 | sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast(result));
49 | return s_str;
50 | }
51 |
52 | HRESULT get_result() const noexcept { return result; }
53 |
54 | private:
55 | HRESULT result;
56 | };
57 |
58 | // Helper utility converts D3D API failures into exceptions.
59 | inline void ThrowIfFailed(HRESULT hr) noexcept(false)
60 | {
61 | if (FAILED(hr))
62 | {
63 | throw com_exception(hr);
64 | }
65 | }
66 |
67 |
68 | // Helper for output debug tracing
69 | inline void DebugTrace(_In_z_ _Printf_format_string_ const char* format, ...) noexcept
70 | {
71 | #ifdef _DEBUG
72 | va_list args;
73 | va_start(args, format);
74 |
75 | char buff[1024] = {};
76 | vsprintf_s(buff, format, args);
77 | OutputDebugStringA(buff);
78 | va_end(args);
79 | #else
80 | UNREFERENCED_PARAMETER(format);
81 | #endif
82 | }
83 |
84 | // Helper smart-pointers
85 | #if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) || (defined(_XBOX_ONE) && defined(_TITLE)) || !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
86 | struct virtual_deleter { void operator()(void* p) noexcept { if (p) VirtualFree(p, 0, MEM_RELEASE); } };
87 | #endif
88 |
89 | struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } };
90 |
91 | using ScopedHandle = std::unique_ptr;
92 |
93 | inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
94 | }
95 |
--------------------------------------------------------------------------------
/Src/Shaders/AlphaTestEffect.fx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | //
4 | // http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 |
7 | Texture2D Texture : register(t0);
8 | sampler Sampler : register(s0);
9 |
10 |
11 | cbuffer Parameters : register(b0)
12 | {
13 | float4 DiffuseColor : packoffset(c0);
14 | float4 AlphaTest : packoffset(c1);
15 | float3 FogColor : packoffset(c2);
16 | float4 FogVector : packoffset(c3);
17 | float4x4 WorldViewProj : packoffset(c4);
18 | };
19 |
20 |
21 | #include "Structures.fxh"
22 | #include "Common.fxh"
23 |
24 |
25 | // Vertex shader: basic.
26 | VSOutputTx VSAlphaTest(VSInputTx vin)
27 | {
28 | VSOutputTx vout;
29 |
30 | CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
31 | SetCommonVSOutputParams;
32 |
33 | vout.TexCoord = vin.TexCoord;
34 |
35 | return vout;
36 | }
37 |
38 |
39 | // Vertex shader: no fog.
40 | VSOutputTxNoFog VSAlphaTestNoFog(VSInputTx vin)
41 | {
42 | VSOutputTxNoFog vout;
43 |
44 | CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
45 | SetCommonVSOutputParamsNoFog;
46 |
47 | vout.TexCoord = vin.TexCoord;
48 |
49 | return vout;
50 | }
51 |
52 |
53 | // Vertex shader: vertex color.
54 | VSOutputTx VSAlphaTestVc(VSInputTxVc vin)
55 | {
56 | VSOutputTx vout;
57 |
58 | CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
59 | SetCommonVSOutputParams;
60 |
61 | vout.TexCoord = vin.TexCoord;
62 | vout.Diffuse *= vin.Color;
63 |
64 | return vout;
65 | }
66 |
67 |
68 | // Vertex shader: vertex color, no fog.
69 | VSOutputTxNoFog VSAlphaTestVcNoFog(VSInputTxVc vin)
70 | {
71 | VSOutputTxNoFog vout;
72 |
73 | CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
74 | SetCommonVSOutputParamsNoFog;
75 |
76 | vout.TexCoord = vin.TexCoord;
77 | vout.Diffuse *= vin.Color;
78 |
79 | return vout;
80 | }
81 |
82 |
83 | // Pixel shader: less/greater compare function.
84 | float4 PSAlphaTestLtGt(PSInputTx pin) : SV_Target0
85 | {
86 | float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse;
87 |
88 | clip((color.a < AlphaTest.x) ? AlphaTest.z : AlphaTest.w);
89 |
90 | ApplyFog(color, pin.Specular.w);
91 |
92 | return color;
93 | }
94 |
95 |
96 | // Pixel shader: less/greater compare function, no fog.
97 | float4 PSAlphaTestLtGtNoFog(PSInputTxNoFog pin) : SV_Target0
98 | {
99 | float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse;
100 |
101 | clip((color.a < AlphaTest.x) ? AlphaTest.z : AlphaTest.w);
102 |
103 | return color;
104 | }
105 |
106 |
107 | // Pixel shader: equal/notequal compare function.
108 | float4 PSAlphaTestEqNe(PSInputTx pin) : SV_Target0
109 | {
110 | float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse;
111 |
112 | clip((abs(color.a - AlphaTest.x) < AlphaTest.y) ? AlphaTest.z : AlphaTest.w);
113 |
114 | ApplyFog(color, pin.Specular.w);
115 |
116 | return color;
117 | }
118 |
119 |
120 | // Pixel shader: equal/notequal compare function, no fog.
121 | float4 PSAlphaTestEqNeNoFog(PSInputTxNoFog pin) : SV_Target0
122 | {
123 | float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse;
124 |
125 | clip((abs(color.a - AlphaTest.x) < AlphaTest.y) ? AlphaTest.z : AlphaTest.w);
126 |
127 | return color;
128 | }
129 |
--------------------------------------------------------------------------------
/Src/Shaders/Common.fxh:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | //
4 | // http://go.microsoft.com/fwlink/?LinkId=248926
5 | // http://go.microsoft.com/fwlink/?LinkId=248929
6 | // http://go.microsoft.com/fwlink/?LinkID=615561
7 |
8 |
9 | float ComputeFogFactor(float4 position)
10 | {
11 | return saturate(dot(position, FogVector));
12 | }
13 |
14 |
15 | void ApplyFog(inout float4 color, float fogFactor)
16 | {
17 | color.rgb = lerp(color.rgb, FogColor * color.a, fogFactor);
18 | }
19 |
20 |
21 | void AddSpecular(inout float4 color, float3 specular)
22 | {
23 | color.rgb += specular * color.a;
24 | }
25 |
26 |
27 | struct CommonVSOutput
28 | {
29 | float4 Pos_ps;
30 | float4 Diffuse;
31 | float3 Specular;
32 | float FogFactor;
33 | };
34 |
35 |
36 | CommonVSOutput ComputeCommonVSOutput(float4 position)
37 | {
38 | CommonVSOutput vout;
39 |
40 | vout.Pos_ps = mul(position, WorldViewProj);
41 | vout.Diffuse = DiffuseColor;
42 | vout.Specular = 0;
43 | vout.FogFactor = ComputeFogFactor(position);
44 |
45 | return vout;
46 | }
47 |
48 |
49 | #define SetCommonVSOutputParams \
50 | vout.PositionPS = cout.Pos_ps; \
51 | vout.Diffuse = cout.Diffuse; \
52 | vout.Specular = float4(cout.Specular, cout.FogFactor);
53 |
54 |
55 | #define SetCommonVSOutputParamsNoFog \
56 | vout.PositionPS = cout.Pos_ps; \
57 | vout.Diffuse = cout.Diffuse;
58 |
--------------------------------------------------------------------------------
/Src/Shaders/DGSLLambert.hlsl:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | //
5 | // This file was generated by exporting HLSL from Visual Studio's default "Lambert" material, and then modified to handle both texture scenarios, multiple lights, and work with FL 9.x
6 | // \Common7\IDE\Extensions\Microsoft\VsGraphics\Assets\Effects\Lambert.dgsl
7 | //
8 |
9 | Texture2D Texture1 : register(t0);
10 |
11 | SamplerState TexSampler : register(s0);
12 |
13 | cbuffer MaterialVars : register (b0)
14 | {
15 | float4 MaterialAmbient;
16 | float4 MaterialDiffuse;
17 | float4 MaterialSpecular;
18 | float4 MaterialEmissive;
19 | float MaterialSpecularPower;
20 | };
21 |
22 | cbuffer LightVars : register (b1)
23 | {
24 | float4 AmbientLight;
25 | float4 LightColor[4];
26 | float4 LightAttenuation[4];
27 | float3 LightDirection[4];
28 | float LightSpecularIntensity[4];
29 | uint IsPointLight[4];
30 | uint ActiveLights;
31 | }
32 |
33 | cbuffer ObjectVars : register(b2)
34 | {
35 | float4x4 LocalToWorld4x4;
36 | float4x4 LocalToProjected4x4;
37 | float4x4 WorldToLocal4x4;
38 | float4x4 WorldToView4x4;
39 | float4x4 UVTransform4x4;
40 | float3 EyePosition;
41 | };
42 |
43 | cbuffer MiscVars : register(b3)
44 | {
45 | float ViewportWidth;
46 | float ViewportHeight;
47 | float Time;
48 | };
49 |
50 | struct V2P
51 | {
52 | float4 pos : SV_POSITION;
53 | float4 diffuse : COLOR;
54 | float2 uv : TEXCOORD0;
55 | float3 worldNorm : TEXCOORD1;
56 | float3 worldPos : TEXCOORD2;
57 | float3 toEye : TEXCOORD3;
58 | float4 tangent : TEXCOORD4;
59 | float3 normal : TEXCOORD5;
60 | };
61 |
62 | struct P2F
63 | {
64 | float4 fragment : SV_Target;
65 | };
66 |
67 | //
68 | // lambert lighting function
69 | //
70 | float3 LambertLighting(
71 | float3 lightNormal,
72 | float3 surfaceNormal,
73 | float3 lightColor,
74 | float3 pixelColor
75 | )
76 | {
77 | // compute amount of contribution per light
78 | float diffuseAmount = saturate(dot(lightNormal, surfaceNormal));
79 | float3 diffuse = diffuseAmount * lightColor * pixelColor;
80 | return diffuse;
81 | }
82 |
83 | //
84 | // combines a float3 RGB value with an alpha value into a float4
85 | //
86 | float4 CombineRGBWithAlpha(float3 rgb, float a)
87 | {
88 | return float4(rgb.r, rgb.g, rgb.b, a);
89 | }
90 |
91 | P2F main(V2P pixel)
92 | {
93 | P2F result;
94 |
95 | float3 worldNormal = normalize(pixel.worldNorm);
96 |
97 | float3 local3 = MaterialAmbient.rgb * AmbientLight.rgb;
98 | [unroll]
99 | for (int i = 0; i < 4; i++)
100 | {
101 | local3 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb);
102 | }
103 |
104 | local3 = saturate(local3);
105 | result.fragment = CombineRGBWithAlpha(local3, pixel.diffuse.a);
106 |
107 | return result;
108 | }
109 |
110 | P2F mainTk(V2P pixel)
111 | {
112 | P2F result;
113 |
114 | float3 worldNormal = normalize(pixel.worldNorm);
115 |
116 | float3 local3 = MaterialAmbient.rgb * AmbientLight.rgb;
117 | [unroll]
118 | for (int i = 0; i < 4; i++)
119 | {
120 | local3 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb);
121 | }
122 |
123 | local3 = saturate(local3);
124 | result.fragment = CombineRGBWithAlpha(local3, pixel.diffuse.a);
125 |
126 | if (result.fragment.a == 0.0f) discard;
127 |
128 | return result;
129 | }
130 |
131 | P2F mainTx(V2P pixel)
132 | {
133 | P2F result;
134 |
135 | float3 worldNormal = normalize(pixel.worldNorm);
136 |
137 | float3 local3 = MaterialAmbient.rgb * AmbientLight.rgb;
138 | [unroll]
139 | for (int i = 0; i < 4; i++)
140 | {
141 | local3 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb);
142 | }
143 |
144 | local3 = saturate(local3);
145 | float3 local4 = Texture1.Sample(TexSampler, pixel.uv).rgb * local3;
146 | float local5 = Texture1.Sample(TexSampler, pixel.uv).a * pixel.diffuse.a;
147 | result.fragment = CombineRGBWithAlpha(local4, local5);
148 |
149 | return result;
150 | }
151 |
152 | P2F mainTxTk(V2P pixel)
153 | {
154 | P2F result;
155 |
156 | float3 worldNormal = normalize(pixel.worldNorm);
157 |
158 | float3 local3 = MaterialAmbient.rgb * AmbientLight.rgb;
159 | [unroll]
160 | for (int i = 0; i < 4; i++)
161 | {
162 | local3 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb);
163 | }
164 |
165 | local3 = saturate(local3);
166 | float3 local4 = Texture1.Sample(TexSampler, pixel.uv).rgb * local3;
167 | float local5 = Texture1.Sample(TexSampler, pixel.uv).a * pixel.diffuse.a;
168 | result.fragment = CombineRGBWithAlpha(local4, local5);
169 |
170 | if (result.fragment.a == 0.0f) discard;
171 |
172 | return result;
173 | }
174 |
175 |
--------------------------------------------------------------------------------
/Src/Shaders/DGSLUnlit.hlsl:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | //
5 | // This file was generated by exporting HLSL from Visual Studio's default "Unlit" material, and then modified to handle both texture scenarios
6 | // \Common7\IDE\Extensions\Microsoft\VsGraphics\Assets\Effects\Unlit.dgsl
7 | //
8 |
9 | Texture2D Texture1 : register(t0);
10 |
11 | SamplerState TexSampler : register(s0);
12 |
13 | cbuffer MaterialVars : register (b0)
14 | {
15 | float4 MaterialAmbient;
16 | float4 MaterialDiffuse;
17 | float4 MaterialSpecular;
18 | float4 MaterialEmissive;
19 | float MaterialSpecularPower;
20 | };
21 |
22 | cbuffer LightVars : register (b1)
23 | {
24 | float4 AmbientLight;
25 | float4 LightColor[4];
26 | float4 LightAttenuation[4];
27 | float3 LightDirection[4];
28 | float LightSpecularIntensity[4];
29 | uint IsPointLight[4];
30 | uint ActiveLights;
31 | }
32 |
33 | cbuffer ObjectVars : register(b2)
34 | {
35 | float4x4 LocalToWorld4x4;
36 | float4x4 LocalToProjected4x4;
37 | float4x4 WorldToLocal4x4;
38 | float4x4 WorldToView4x4;
39 | float4x4 UVTransform4x4;
40 | float3 EyePosition;
41 | };
42 |
43 | cbuffer MiscVars : register(b3)
44 | {
45 | float ViewportWidth;
46 | float ViewportHeight;
47 | float Time;
48 | };
49 |
50 | struct V2P
51 | {
52 | float4 pos : SV_POSITION;
53 | float4 diffuse : COLOR;
54 | float2 uv : TEXCOORD0;
55 | float3 worldNorm : TEXCOORD1;
56 | float3 worldPos : TEXCOORD2;
57 | float3 toEye : TEXCOORD3;
58 | float4 tangent : TEXCOORD4;
59 | float3 normal : TEXCOORD5;
60 | };
61 |
62 | struct P2F
63 | {
64 | float4 fragment : SV_Target;
65 | };
66 |
67 | //
68 | // combines a float3 RGB value with an alpha value into a float4
69 | //
70 | float4 CombineRGBWithAlpha(float3 rgb, float a)
71 | {
72 | return float4(rgb.r, rgb.g, rgb.b, a);
73 | }
74 |
75 | P2F main(V2P pixel)
76 | {
77 | P2F result;
78 |
79 | result.fragment = pixel.diffuse;
80 |
81 | return result;
82 | }
83 |
84 | P2F mainTk(V2P pixel)
85 | {
86 | P2F result;
87 |
88 | result.fragment = pixel.diffuse;
89 | if (result.fragment.a == 0.0f) discard;
90 |
91 | return result;
92 | }
93 |
94 | P2F mainTx(V2P pixel)
95 | {
96 | P2F result;
97 |
98 | // we need to normalize incoming vectors
99 | float3 surfaceNormal = normalize(pixel.normal);
100 | float3 surfaceTangent = normalize(pixel.tangent.xyz);
101 | float3 worldNormal = normalize(pixel.worldNorm);
102 | float3 toEyeVector = normalize(pixel.toEye);
103 |
104 | // construct tangent matrix
105 | float3x3 localToTangent = transpose(float3x3(surfaceTangent, cross(surfaceNormal, surfaceTangent) * pixel.tangent.w, surfaceNormal));
106 | float3x3 worldToTangent = mul((float3x3)WorldToLocal4x4, localToTangent);
107 |
108 | // transform some vectors into tangent space
109 | float3 tangentLightDir = normalize(mul(LightDirection[0], worldToTangent));
110 | float3 tangentToEyeVec = normalize(mul(toEyeVector, worldToTangent));
111 |
112 | // BEGIN GENERATED CODE
113 | float3 local3 = pixel.diffuse.rgb * Texture1.Sample(TexSampler, pixel.uv).rgb;
114 | float local4 = pixel.diffuse.a * Texture1.Sample(TexSampler, pixel.uv).a;
115 | result.fragment = CombineRGBWithAlpha(local3, local4);
116 | // END GENERATED CODE
117 |
118 | return result;
119 | }
120 |
121 | P2F mainTxTk(V2P pixel)
122 | {
123 | P2F result;
124 |
125 | // we need to normalize incoming vectors
126 | float3 surfaceNormal = normalize(pixel.normal);
127 | float3 surfaceTangent = normalize(pixel.tangent.xyz);
128 | float3 worldNormal = normalize(pixel.worldNorm);
129 | float3 toEyeVector = normalize(pixel.toEye);
130 |
131 | // construct tangent matrix
132 | float3x3 localToTangent = transpose(float3x3(surfaceTangent, cross(surfaceNormal, surfaceTangent) * pixel.tangent.w, surfaceNormal));
133 | float3x3 worldToTangent = mul((float3x3)WorldToLocal4x4, localToTangent);
134 |
135 | // transform some vectors into tangent space
136 | float3 tangentLightDir = normalize(mul(LightDirection[0], worldToTangent));
137 | float3 tangentToEyeVec = normalize(mul(toEyeVector, worldToTangent));
138 |
139 | // BEGIN GENERATED CODE
140 | float3 local3 = pixel.diffuse.rgb * Texture1.Sample(TexSampler, pixel.uv).rgb;
141 | float local4 = pixel.diffuse.a * Texture1.Sample(TexSampler, pixel.uv).a;
142 | result.fragment = CombineRGBWithAlpha(local3, local4);
143 | // END GENERATED CODE
144 |
145 | if (result.fragment.a == 0.0f) discard;
146 |
147 | return result;
148 | }
149 |
150 |
--------------------------------------------------------------------------------
/Src/Shaders/DualTextureEffect.fx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | //
4 | // http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 |
7 | Texture2D Texture : register(t0);
8 | Texture2D Texture2 : register(t1);
9 |
10 | sampler Sampler : register(s0);
11 | sampler Sampler2 : register(s1);
12 |
13 |
14 | cbuffer Parameters : register(b0)
15 | {
16 | float4 DiffuseColor : packoffset(c0);
17 | float3 FogColor : packoffset(c1);
18 | float4 FogVector : packoffset(c2);
19 | float4x4 WorldViewProj : packoffset(c3);
20 | };
21 |
22 |
23 | #include "Structures.fxh"
24 | #include "Common.fxh"
25 |
26 |
27 | // Vertex shader: basic.
28 | VSOutputTx2 VSDualTexture(VSInputTx2 vin)
29 | {
30 | VSOutputTx2 vout;
31 |
32 | CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
33 | SetCommonVSOutputParams;
34 |
35 | vout.TexCoord = vin.TexCoord;
36 | vout.TexCoord2 = vin.TexCoord2;
37 |
38 | return vout;
39 | }
40 |
41 |
42 | // Vertex shader: no fog.
43 | VSOutputTx2NoFog VSDualTextureNoFog(VSInputTx2 vin)
44 | {
45 | VSOutputTx2NoFog vout;
46 |
47 | CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
48 | SetCommonVSOutputParamsNoFog;
49 |
50 | vout.TexCoord = vin.TexCoord;
51 | vout.TexCoord2 = vin.TexCoord2;
52 |
53 | return vout;
54 | }
55 |
56 |
57 | // Vertex shader: vertex color.
58 | VSOutputTx2 VSDualTextureVc(VSInputTx2Vc vin)
59 | {
60 | VSOutputTx2 vout;
61 |
62 | CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
63 | SetCommonVSOutputParams;
64 |
65 | vout.TexCoord = vin.TexCoord;
66 | vout.TexCoord2 = vin.TexCoord2;
67 | vout.Diffuse *= vin.Color;
68 |
69 | return vout;
70 | }
71 |
72 |
73 | // Vertex shader: vertex color, no fog.
74 | VSOutputTx2NoFog VSDualTextureVcNoFog(VSInputTx2Vc vin)
75 | {
76 | VSOutputTx2NoFog vout;
77 |
78 | CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
79 | SetCommonVSOutputParamsNoFog;
80 |
81 | vout.TexCoord = vin.TexCoord;
82 | vout.TexCoord2 = vin.TexCoord2;
83 | vout.Diffuse *= vin.Color;
84 |
85 | return vout;
86 | }
87 |
88 |
89 | // Pixel shader: basic.
90 | float4 PSDualTexture(PSInputTx2 pin) : SV_Target0
91 | {
92 | float4 color = Texture.Sample(Sampler, pin.TexCoord);
93 | float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2);
94 |
95 | color.rgb *= 2;
96 | color *= overlay * pin.Diffuse;
97 |
98 | ApplyFog(color, pin.Specular.w);
99 |
100 | return color;
101 | }
102 |
103 |
104 | // Pixel shader: no fog.
105 | float4 PSDualTextureNoFog(PSInputTx2NoFog pin) : SV_Target0
106 | {
107 | float4 color = Texture.Sample(Sampler, pin.TexCoord);
108 | float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2);
109 |
110 | color.rgb *= 2;
111 | color *= overlay * pin.Diffuse;
112 |
113 | return color;
114 | }
115 |
--------------------------------------------------------------------------------
/Src/Shaders/Lighting.fxh:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | //
4 | // http://go.microsoft.com/fwlink/?LinkId=248926
5 | // http://go.microsoft.com/fwlink/?LinkId=248929
6 | // http://go.microsoft.com/fwlink/?LinkID=615561
7 |
8 |
9 | struct ColorPair
10 | {
11 | float3 Diffuse;
12 | float3 Specular;
13 | };
14 |
15 |
16 | ColorPair ComputeLights(float3 eyeVector, float3 worldNormal, uniform int numLights)
17 | {
18 | float3x3 lightDirections = 0;
19 | float3x3 lightDiffuse = 0;
20 | float3x3 lightSpecular = 0;
21 | float3x3 halfVectors = 0;
22 |
23 | [unroll]
24 | for (int i = 0; i < numLights; i++)
25 | {
26 | lightDirections[i] = LightDirection[i];
27 | lightDiffuse[i] = LightDiffuseColor[i];
28 | lightSpecular[i] = LightSpecularColor[i];
29 |
30 | halfVectors[i] = normalize(eyeVector - lightDirections[i]);
31 | }
32 |
33 | float3 dotL = mul(-lightDirections, worldNormal);
34 | float3 dotH = mul(halfVectors, worldNormal);
35 |
36 | float3 zeroL = step(0, dotL);
37 |
38 | float3 diffuse = zeroL * dotL;
39 | float3 specular = pow(max(dotH, 0) * zeroL, SpecularPower) * dotL;
40 |
41 | ColorPair result;
42 |
43 | result.Diffuse = mul(diffuse, lightDiffuse) * DiffuseColor.rgb + EmissiveColor;
44 | result.Specular = mul(specular, lightSpecular) * SpecularColor;
45 |
46 | return result;
47 | }
48 |
49 |
50 | CommonVSOutput ComputeCommonVSOutputWithLighting(float4 position, float3 normal, uniform int numLights)
51 | {
52 | CommonVSOutput vout;
53 |
54 | float4 pos_ws = mul(position, World);
55 | float3 eyeVector = normalize(EyePosition - pos_ws.xyz);
56 | float3 worldNormal = normalize(mul(normal, WorldInverseTranspose));
57 |
58 | ColorPair lightResult = ComputeLights(eyeVector, worldNormal, numLights);
59 |
60 | vout.Pos_ps = mul(position, WorldViewProj);
61 | vout.Diffuse = float4(lightResult.Diffuse, DiffuseColor.a);
62 | vout.Specular = lightResult.Specular;
63 | vout.FogFactor = ComputeFogFactor(position);
64 |
65 | return vout;
66 | }
67 |
68 |
69 | struct CommonVSOutputPixelLighting
70 | {
71 | float4 Pos_ps;
72 | float3 Pos_ws;
73 | float3 Normal_ws;
74 | float FogFactor;
75 | };
76 |
77 |
78 | CommonVSOutputPixelLighting ComputeCommonVSOutputPixelLighting(float4 position, float3 normal)
79 | {
80 | CommonVSOutputPixelLighting vout;
81 |
82 | vout.Pos_ps = mul(position, WorldViewProj);
83 | vout.Pos_ws = mul(position, World).xyz;
84 | vout.Normal_ws = normalize(mul(normal, WorldInverseTranspose));
85 | vout.FogFactor = ComputeFogFactor(position);
86 |
87 | return vout;
88 | }
89 |
90 |
91 | #define SetCommonVSOutputParamsPixelLighting \
92 | vout.PositionPS = cout.Pos_ps; \
93 | vout.PositionWS = float4(cout.Pos_ws, cout.FogFactor); \
94 | vout.NormalWS = cout.Normal_ws;
95 |
96 |
--------------------------------------------------------------------------------
/Src/Shaders/PixelPacking_Velocity.hlsli:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // This code is licensed under the MIT License (MIT).
4 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
5 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
6 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
7 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
8 | //
9 | // Developed by Minigraph
10 | //
11 | // Author: James Stanard
12 | //
13 |
14 | #ifndef __PIXEL_PACKING_VELOCITY_HLSLI__
15 | #define __PIXEL_PACKING_VELOCITY_HLSLI__
16 |
17 | #if 1
18 | // This is a custom packing that devotes 10 bits each to X and Y velocity but 12 bits to Z velocity. Floats
19 | // are used instead of SNORM to increase precision around small deltas, which are the majority of deltas.
20 | // With TAA and Motion Blur, velocities are clamped, giving little reason to express them precisely in terms
21 | // of the size of the screen.
22 | #define packed_velocity_t uint
23 |
24 | // Designed to compress (-256.0, +256.0) with a signed 6e3 float
25 | uint PackXY(float x)
26 | {
27 | uint signbit = asuint(x) >> 31;
28 | x = clamp(abs(x / 32768.0), 0, asfloat(0x3BFFE000));
29 | return (f32tof16(x) + 8) >> 4 | signbit << 9;
30 | }
31 |
32 | float UnpackXY(uint x)
33 | {
34 | return f16tof32((x & 0x1FF) << 4 | (x >> 9) << 15) * 32768.0;
35 | }
36 |
37 | // Designed to compress (-1.0, 1.0) with a signed 8e3 float
38 | uint PackZ(float x)
39 | {
40 | uint signbit = asuint(x) >> 31;
41 | x = clamp(abs(x / 128.0), 0, asfloat(0x3BFFE000));
42 | return (f32tof16(x) + 2) >> 2 | signbit << 11;
43 | }
44 |
45 | float UnpackZ(uint x)
46 | {
47 | return f16tof32((x & 0x7FF) << 2 | (x >> 11) << 15) * 128.0;
48 | }
49 |
50 | // Pack the velocity to write to R10G10B10A2_UNORM
51 | packed_velocity_t PackVelocity(float3 Velocity)
52 | {
53 | return PackXY(Velocity.x) | PackXY(Velocity.y) << 10 | PackZ(Velocity.z) << 20;
54 | }
55 |
56 | // Unpack the velocity from R10G10B10A2_UNORM
57 | float3 UnpackVelocity(packed_velocity_t Velocity)
58 | {
59 | return float3(UnpackXY(Velocity & 0x3FF), UnpackXY((Velocity >> 10) & 0x3FF), UnpackZ(Velocity >> 20));
60 | }
61 |
62 | #elif 1
63 | #define packed_velocity_t float4
64 |
65 | // Pack the velocity to write to R10G10B10A2_UNORM
66 | packed_velocity_t PackVelocity(float3 Velocity)
67 | {
68 | // Stretch dx,dy from [-64, 63.875] to [-512, 511] to [-0.5, 0.5) to [0, 1)
69 | // Velocity.xy = (0,0) must be representable.
70 | return float4(Velocity * float3(8, 8, 4096) / 1024.0 + 512 / 1023.0, 0);
71 | }
72 |
73 | // Unpack the velocity from R10G10B10A2_UNORM
74 | float3 UnpackVelocity(packed_velocity_t Velocity)
75 | {
76 | return (Velocity.xyz - 512.0 / 1023.0) * float3(1024, 1024, 2) / 8.0;
77 | }
78 | #else
79 | #define packed_velocity_t float4
80 |
81 | // Pack the velocity to write to R16G16B16A16_FLOAT
82 | packed_velocity_t PackVelocity(float3 Velocity)
83 | {
84 | return float4(Velocity * float3(16, 16, 32*1024), 0);
85 | }
86 |
87 | // Unpack the velocity from R10G10B10A2_UNORM
88 | float3 UnpackVelocity(packed_velocity_t Velocity)
89 | {
90 | return Velocity.xyz / float3(16, 16, 32*1024);
91 | }
92 |
93 | #endif
94 |
95 | #endif // __PIXEL_PACKING_HLSLI__
96 |
--------------------------------------------------------------------------------
/Src/Shaders/Skinning.fxh:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | //
4 | // http://go.microsoft.com/fwlink/?LinkId=248929
5 | // http://go.microsoft.com/fwlink/?LinkID=615561
6 |
7 |
8 | float3 Skin(inout VSInputNmTxWeights vin, float3 normal, uniform int boneCount)
9 | {
10 | float4x3 skinning = 0;
11 |
12 | [unroll]
13 | for (int i = 0; i < boneCount; i++)
14 | {
15 | skinning += Bones[vin.Indices[i]] * vin.Weights[i];
16 | }
17 |
18 | vin.Position.xyz = mul(vin.Position, skinning);
19 | return mul(normal, (float3x3) skinning);
20 | }
21 |
--------------------------------------------------------------------------------
/Src/Shaders/SpriteEffect.fx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | //
4 | // http://go.microsoft.com/fwlink/?LinkId=248929
5 |
6 |
7 | Texture2D Texture : register(t0);
8 | sampler TextureSampler : register(s0);
9 |
10 |
11 | cbuffer Parameters : register(b0)
12 | {
13 | row_major float4x4 MatrixTransform;
14 | };
15 |
16 |
17 | void SpriteVertexShader(inout float4 color : COLOR0,
18 | inout float2 texCoord : TEXCOORD0,
19 | inout float4 position : SV_Position)
20 | {
21 | position = mul(position, MatrixTransform);
22 | }
23 |
24 |
25 | float4 SpritePixelShader(float4 color : COLOR0,
26 | float2 texCoord : TEXCOORD0) : SV_Target0
27 | {
28 | return Texture.Sample(TextureSampler, texCoord) * color;
29 | }
30 |
--------------------------------------------------------------------------------
/Src/Shaders/Utilities.fxh:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | //
4 | // http://go.microsoft.com/fwlink/?LinkId=248926
5 | // http://go.microsoft.com/fwlink/?LinkId=248929
6 | // http://go.microsoft.com/fwlink/?LinkID=615561
7 |
8 |
9 | float3 BiasX2(float3 x)
10 | {
11 | return 2.0f * x - 1.0f;
12 | }
13 |
14 | float3 BiasD2(float3 x)
15 | {
16 | return 0.5f * x + 0.5f;
17 | }
18 |
19 |
20 | // Christian Schuler, "Normal Mapping without Precomputed Tangents", ShaderX 5, Chapter 2.6, pp. 131-140
21 | // See also follow-up blog post: http://www.thetenthplanet.de/archives/1180
22 | float3x3 CalculateTBN(float3 p, float3 n, float2 tex)
23 | {
24 | float3 dp1 = ddx(p);
25 | float3 dp2 = ddy(p);
26 | float2 duv1 = ddx(tex);
27 | float2 duv2 = ddy(tex);
28 |
29 | float3x3 M = float3x3(dp1, dp2, cross(dp1, dp2));
30 | float2x3 inverseM = float2x3(cross(M[1], M[2]), cross(M[2], M[0]));
31 | float3 t = normalize(mul(float2(duv1.x, duv2.x), inverseM));
32 | float3 b = normalize(mul(float2(duv1.y, duv2.y), inverseM));
33 | return float3x3(t, b, n);
34 | }
35 |
36 | float3 PeturbNormal(float3 localNormal, float3 position, float3 normal, float2 texCoord)
37 | {
38 | const float3x3 TBN = CalculateTBN(position, normal, texCoord);
39 | return normalize(mul(localNormal, TBN));
40 | }
41 |
42 | float3 TwoChannelNormalX2(float2 normal)
43 | {
44 | float2 xy = 2.0f * normal - 1.0f;
45 | float z = sqrt(1 - dot(xy, xy));
46 | return float3(xy.x, xy.y, z);
47 | }
48 |
49 |
50 | // sRGB
51 | // https://en.wikipedia.org/wiki/SRGB
52 |
53 | // Apply the (approximate) sRGB curve to linear values
54 | float3 LinearToSRGBEst(float3 color)
55 | {
56 | return pow(abs(color), 1/2.2f);
57 | }
58 |
59 |
60 | // (Approximate) sRGB to linear
61 | float3 SRGBToLinearEst(float3 srgb)
62 | {
63 | return pow(abs(srgb), 2.2f);
64 | }
65 |
66 |
67 | // HDR10 Media Profile
68 | // https://en.wikipedia.org/wiki/High-dynamic-range_video#HDR10
69 |
70 |
71 | // Apply the ST.2084 curve to normalized linear values and outputs normalized non-linear values
72 | float3 LinearToST2084(float3 normalizedLinearValue)
73 | {
74 | return pow((0.8359375f + 18.8515625f * pow(abs(normalizedLinearValue), 0.1593017578f)) / (1.0f + 18.6875f * pow(abs(normalizedLinearValue), 0.1593017578f)), 78.84375f);
75 | }
76 |
77 |
78 | // ST.2084 to linear, resulting in a linear normalized value
79 | float3 ST2084ToLinear(float3 ST2084)
80 | {
81 | return pow(max(pow(abs(ST2084), 1.0f / 78.84375f) - 0.8359375f, 0.0f) / (18.8515625f - 18.6875f * pow(abs(ST2084), 1.0f / 78.84375f)), 1.0f / 0.1593017578f);
82 | }
83 |
84 |
85 | // Reinhard tonemap operator
86 | // Reinhard et al. "Photographic tone reproduction for digital images." ACM Transactions on Graphics. 21. 2002.
87 | // http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
88 | float3 ToneMapReinhard(float3 color)
89 | {
90 | return color / (1.0f + color);
91 | }
92 |
93 |
94 | // ACES Filmic tonemap operator
95 | // https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
96 | float3 ToneMapACESFilmic(float3 x)
97 | {
98 | float a = 2.51f;
99 | float b = 0.03f;
100 | float c = 2.43f;
101 | float d = 0.59f;
102 | float e = 0.14f;
103 | return saturate((x*(a*x+b))/(x*(c*x+d)+e));
104 | }
105 |
106 |
107 | // Instancing
108 | struct CommonInstancing
109 | {
110 | float4 Position;
111 | float3 Normal;
112 | };
113 |
114 |
115 | CommonInstancing ComputeCommonInstancing(float4 position, float3 normal, float4x3 itransform)
116 | {
117 | CommonInstancing vout;
118 |
119 | vout.Position = float4(mul(position, itransform), position.w);
120 | vout.Normal = mul(normal, (float3x3)itransform);
121 |
122 | return vout;
123 | }
124 |
--------------------------------------------------------------------------------
/Src/SharedResourcePool.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: SharedResourcePool.h
3 | //
4 | // Copyright (c) Microsoft Corporation.
5 | // Licensed under the MIT License.
6 | //
7 | // http://go.microsoft.com/fwlink/?LinkId=248929
8 | // http://go.microsoft.com/fwlink/?LinkID=615561
9 | //--------------------------------------------------------------------------------------
10 |
11 | #pragma once
12 |
13 | #include