Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
09b79eb
Add Vulkan-Docs submodule
Exanite May 23, 2025
7a14974
Create Vulkan bindings project
Exanite May 23, 2025
a420fa4
Fix typo
Exanite May 23, 2025
0b9d036
Add base case for FindCommonPrefix for when names.Count is 0
Exanite May 23, 2025
3725f9b
Add all mods up to and including MixKhronosData
Exanite May 23, 2025
f9d72f3
Remove assert
Exanite May 23, 2025
d7fc141
Add another base case for FindCommonPrefix for when names.Count is 0
Exanite May 23, 2025
cfeaddc
Add TransformFunctions and PrettifyNames mods to Vulkan generator config
Exanite May 23, 2025
2002947
Add DllImport VTable config to Vulkan
Exanite May 24, 2025
59dc770
Add initial RSP files and empty vulkan-vulkan.h header
Exanite May 26, 2025
9323632
Remove vulkansc profile from AddApiProfiles
Exanite May 26, 2025
dd1d1ef
Add Vulkan-Headers repo as submodule
Exanite May 26, 2025
4e75295
Use Vulkan headers from Vulkan-Headers repo
Exanite May 26, 2025
e3383cc
Add traverse argument for Vulkan generate.rsp
Exanite May 26, 2025
6858647
Add Vulkan specific header.txt
Exanite May 26, 2025
06a8680
Also traverse vulkan_core
Exanite May 26, 2025
1798e32
Remove BakeSourceSets mod since there is only 1 source set
Exanite May 26, 2025
f7c38b0
Commit generated Vulkan bindings
Exanite May 26, 2025
20ef463
Generate on Linux (differs slightly from Windows)
Exanite May 26, 2025
6f59005
Add remap-stdint.rsp for Vulkan
Exanite May 27, 2025
57bde07
Exclude VK_NULL_HANDLE from being generated
Exanite May 27, 2025
6190d6f
Add TransformHandles mod
Exanite May 27, 2025
0be14bc
Add TransformProperties mod
Exanite May 27, 2025
4453712
Add ExtractNestedTyping mod
Exanite May 27, 2025
3b0a190
Trim _T from _THandle types
Exanite May 27, 2025
609cd21
Rename FlagBits enums to Flags
Exanite May 27, 2025
e692059
Slight optimization/simplication
Exanite May 27, 2025
e5f1edd
Add mappings from FlagBits to Flags types
Exanite May 28, 2025
b2c2338
Remove code that Perksey said was obsolete
Exanite Jun 2, 2025
5f64399
Add comments on how TransformHandle works at a high level
Exanite Jun 2, 2025
fbe1e44
Add example to TransformHandle docs
Exanite Jun 2, 2025
2a5694d
Add comments to ExtractNestedTyping
Exanite Jun 2, 2025
6e03d3c
Generate bindings on Windows
Exanite Jun 2, 2025
9fcfdc3
Edit xml docs
Exanite Jun 3, 2025
a4b3cf9
Move TransformHandles mod's TypeDiscover into new Scraping namespace
Exanite Jun 3, 2025
475f6c3
ExtractNestedTyping can now generate empty handle structs
Exanite Jun 3, 2025
e2f818e
Change MixKhronosData to only look for _T instead of _THandle
Exanite Jun 3, 2025
d38e2b1
Copy NameUtils from curin's branch to get access to RenameAllAsync
Exanite Jun 7, 2025
2ef78eb
Disable all mods after ExtractNestedTyping and regenerate
Exanite Jun 8, 2025
9ff8016
Change MSBuildModContext to only remove project documents that are pa…
Exanite Jun 8, 2025
b78306f
Implement symbol based handle type discoverer
Exanite Jun 8, 2025
ad94e2d
Refactor code related to missing handle discovery
Exanite Jun 8, 2025
b65b4b6
Remove temporary Linux-specific workaround
Exanite Jun 8, 2025
abba2c8
Add MissingHandleTypeGenerator class and implement handle type genera…
Exanite Jun 8, 2025
1183f17
Cleanup
Exanite Jun 8, 2025
b3f1be8
Rename MissingHandleTypeGenerator and some other things to better rep…
Exanite Jun 8, 2025
d83369a
Reapply a few changes related to FindCommonPrefix
Exanite Jun 8, 2025
a73e98f
Revert "Remove temporary Linux-specific workaround"
Exanite Jun 8, 2025
a3f9cdb
Regenerate bindings on Linux
Exanite Jun 9, 2025
8e26633
Prepare to rewrite TransformHandles; regenerate Vulkan bindings
Exanite Jun 9, 2025
243fe93
Update SDL generator config to use ExtractNestedTyping.GenerateEmptyS…
Exanite Jun 9, 2025
ef03001
Remove old TransformsHandle code that won't be used by rewrite
Exanite Jun 9, 2025
826476c
Edit doc comment for ExtractNestedTyping
Exanite Jun 9, 2025
679ab18
Implement symbol-based handle type discovery for TransformHandles
Exanite Jun 9, 2025
1cfdede
Add -Handle suffix to Handle documents
Exanite Jun 9, 2025
a7946e5
Remove handle document renaming for now; Reimplement handle struct me…
Exanite Jun 9, 2025
ff2eb75
Edit todo comments
Exanite Jun 9, 2025
c87277b
NameUtils.RenameAllAsync now works alongside document renaming in Tra…
Exanite Jun 10, 2025
b67724a
Change the gatherer/rewriter classes I wrote to be only designed to b…
Exanite Jun 11, 2025
776a9ad
Implement pointer dimension reduction
Exanite Jun 11, 2025
b228927
Fix PointerDimensionReducer accidentally overwriting its own changes
Exanite Jun 11, 2025
9dd3b92
Cleanup
Exanite Jun 11, 2025
34cadfd
Add LocationTransformer class
Exanite Jun 11, 2025
8a4e93a
Add parallelization
Exanite Jun 11, 2025
11dff8b
Reorder code
Exanite Jun 11, 2025
8557c7b
Attempt to implement renaming functionality with LocationTransformers
Exanite Jun 11, 2025
6336a6b
Fix IdentifierRenamingTransformer not working
Exanite Jun 11, 2025
3f93134
Split LocationTransformer code into multiple files
Exanite Jun 11, 2025
cea55da
Fix ArgumentOutOfRangeException and replace old renamer
Exanite Jun 11, 2025
4434164
Remove unused code
Exanite Jun 11, 2025
7ec8f84
Add todos
Exanite Jun 12, 2025
cd27ba8
Ignore AttributeSyntaxes when looking for handles because handles wil…
Exanite Jun 13, 2025
400cb18
Cleanup
Exanite Jun 13, 2025
17c551c
Edit comment for clarity
Exanite Jul 5, 2025
c0c3425
Change ModCSharpSyntaxRewriter to exclude global usings
Exanite Jul 5, 2025
d1fa402
Fix typo
Exanite Jul 8, 2025
78bbb4d
Fix Vulkan enum constants not being identified properly
Exanite Jul 9, 2025
b2d8acc
Exclude deprecated Vulkan aliases that are causing compile errors
Exanite Jul 10, 2025
d8986f0
Add Vulkan Video to Vulkan bindings generation
Exanite Jul 10, 2025
d86e127
Exclude vendors that only have disabled extensions
Exanite Jul 10, 2025
d22529c
Generate bindings
Exanite Jul 10, 2025
1e44902
Exclude a few more deprecated aliases that cause compile errors due t…
Exanite Jul 10, 2025
42750b8
Manually fix bitshifts
Exanite Jul 10, 2025
0dace6d
Rename Vulkan class to Vk to match Silk 2
Exanite Jul 11, 2025
d64b198
Fix the bitshifts again
Exanite Jul 11, 2025
4d2a162
Add StaticWrapper VTable
Exanite Jul 11, 2025
4c68768
Fix missing API constants
Exanite Jul 11, 2025
9bf1427
Remove manually added type mappings
Exanite Jul 11, 2025
407acae
Simplify code
Exanite Jul 11, 2025
360b77c
Rename FlagBits enums using MixKhronosData instead of through INameTr…
Exanite Jul 11, 2025
21df0a8
Globally replace FlagBits with Flags in identifier names
Exanite Jul 11, 2025
565810e
Add Flags attribute to "KnownBitmask" enums
Exanite Jul 11, 2025
b5dc97c
Split MixKhronosData.Rewriter into two phases
Exanite Jul 11, 2025
5c499a4
Fix Flags types being typed as uint/ulong instead of the proper enum …
Exanite Jul 11, 2025
744d86d
Fix Flags uint/ulong type replacement being too eager and replacing u…
Exanite Jul 11, 2025
650cc97
Edit doc comment
Exanite Jul 13, 2025
cf87296
Add new TransformFlags mod
Exanite Jul 13, 2025
81ba841
Attempt to find and add Clang include directory in UnixStdIncludeReso…
Exanite Jul 13, 2025
86e998d
Fix AccessFlags3KHR.None being added even when it already has a membe…
Exanite Jul 13, 2025
ca98d81
Remove MaxEnum members from enums
Exanite Jul 13, 2025
daa3d18
Add early exit optimization
Exanite Jul 16, 2025
d795e5f
Check if string is length 0 and throw instead of stack overflowing
Exanite Jul 16, 2025
8e1e2ad
Reorder code
Exanite Jul 16, 2025
cfdb477
Change Vulkan _T suffix trimming to be more specific
Exanite Jul 16, 2025
d168396
Improve MixKhronosData name trimming rewind condition
Exanite Jul 16, 2025
1a3bc51
Edit comment
Exanite Jul 16, 2025
29f96b3
Add prefix overrides for manually identified cases where trimming has…
Exanite Jul 16, 2025
8ab8550
Rename TransformFlags mod to TransformEnums; Move MaxEnum member remo…
Exanite Jul 17, 2025
1350a08
Update vulkan-headers because apparently they are out-of-date enough …
Exanite Jul 17, 2025
b44ebea
Remove debug code
Exanite Jul 17, 2025
bdfd3c8
Fix missing enum group data when the enum group is empty
Exanite Jul 17, 2025
d73aade
Remove constants that are marked as deprecated aliases
Exanite Jul 18, 2025
70d1279
Add remapping for VkBool32 to MaybeBool<uint>
Exanite Jul 18, 2025
060e3cc
Add new Vulkan video headers
Exanite Jul 18, 2025
64cbea3
Edit doc comment
Exanite Jul 21, 2025
2188fcd
Use GetNativeElementTypeName in order to simplify code
Exanite Jul 21, 2025
b187f27
Implement most of TransformVulkan mod
Exanite Jul 21, 2025
0d6b402
Finish implementing TransformVulkan
Exanite Jul 22, 2025
031e28c
Don't strip attributes for explicitly implemented interface methods
Exanite Jul 23, 2025
4c89e4e
Finish implementing logic for wrapping the vkCreateInstance/Device me…
Exanite Jul 23, 2025
ae30d31
Fix missing private modifier
Exanite Jul 23, 2025
44356f1
Add manual Vk file with Create and Clone methods
Exanite Jul 23, 2025
821a7e3
Fix typo in docs
Exanite May 23, 2025
cc53cf4
Update location transformation code with the Microsoft job changes
Exanite Jul 26, 2025
54322bf
Add DllImport vtable
Exanite Jul 26, 2025
35fd9e2
Add UnmanagedCallersOnly ProcAddr methods
Exanite Jul 26, 2025
fb7bba2
Fix edge case where Flags types were being output as uint instead of …
Exanite Jul 27, 2025
cc7088f
Add alternative library names for Vulkan
Exanite Jul 28, 2025
ead8e31
Hack: Fix missing type cast
Exanite Jul 28, 2025
6f4d856
Add StaticWrapper vtable
Exanite Jul 28, 2025
d05e91a
Cleanup
Exanite Jul 29, 2025
a32b33e
Generate on Windows
Exanite Jul 29, 2025
0dcfda6
Empty commit (to trigger CI build)
Exanite Jul 31, 2025
6129ba7
Generate again on Linux
Exanite Nov 11, 2025
7deff18
Update Vulkan submodules
Exanite Nov 11, 2025
467f2e1
Add prefix override for VkPipelineCreateFlags2 to avoid issue where a…
Exanite Nov 11, 2025
affb38e
Update Vulkan branch with changes from OpenAL branch (#15)
Exanite Nov 12, 2025
4c07392
Update to .NET 10 and DISABLE TreatWarningsAsErrors in Silk.Net.Core.…
Exanite Nov 12, 2025
b6a33c9
Regenerate Vulkan bindings (yay, the bitshifts are fixed)
Exanite Nov 12, 2025
4eae792
Remove now unnecessary hack
Exanite Nov 12, 2025
3ccd55c
Remove handle struct handling code from ExtractNestedTyping and tempo…
Exanite Nov 12, 2025
15b8ce1
Update ExtractNestedTyping doc comment
Exanite Nov 12, 2025
205bf61
Cleanup
Exanite Nov 12, 2025
5c491d4
Get TransformHandles working again
Exanite Nov 12, 2025
aa7f39a
Allow callers of GetAllMetadata to filter by metadata source
Exanite Nov 12, 2025
8595555
Fix incorrect file name for OpenALException
Exanite Nov 12, 2025
d3ecce0
Move PrettifyNames closer to end of mod order
Exanite Nov 12, 2025
6ca8a20
Update Vulkan bindings to use InterceptNativeFunctions
Exanite Nov 12, 2025
e92714e
Cleanup
Exanite Nov 12, 2025
09abf5e
Use null op if setting CurrentDevice with its current value
Exanite Nov 12, 2025
fa4963a
Add CurrentInstance/CurrentDevice/Clone to IVk interface and update V…
Exanite Nov 12, 2025
79aa5de
Add context factory for Vulkan ThisThread VTable
Exanite Nov 13, 2025
143cd79
Add my new renamer with Curin's modifications
Exanite Nov 13, 2025
7ea3608
Change RenameAllAsync to use new renamer (pure syntax rewriter instea…
Exanite Nov 13, 2025
7a88bb1
Create a copy of the original LocationTransformation code for runtime…
Exanite Nov 13, 2025
8d0bb38
Work on new location transformer implementation
Exanite Nov 13, 2025
f2fb4b0
Edit documentation to match new expectations for LocationTransformer.…
Exanite Nov 13, 2025
9e12e38
Use location transformer based renamer
Exanite Nov 13, 2025
2c080b0
Remove old location transformer
Exanite Nov 13, 2025
56a3c49
Improve IdentifierRenamingTransformer constructor API
Exanite Nov 13, 2025
dda4c28
Remove Renamer since it has been replaced
Exanite Nov 13, 2025
54b7bd0
Implement working version of the non-FindReferencesAsync + SyntaxRewr…
Exanite Nov 14, 2025
b2581ed
Cleanup
Exanite Nov 14, 2025
1141e99
Remove the .stout files I committed
Exanite Nov 14, 2025
f1ce4b1
Use TryParse instead of Parse in UnixStdIncludeResolver
Exanite Nov 14, 2025
32faef0
Cleanup using statements in NameUtils
Exanite Nov 14, 2025
9897d80
Restore comment I removed when removing the handle struct functionali…
Exanite Nov 14, 2025
2b04df7
Cleanup use of ctx.SourceProject in ExtractNestedTyping
Exanite Nov 14, 2025
fa449be
Remove unused GetCompilationAsync
Exanite Nov 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 6 additions & 4 deletions .github/workflows/native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ permissions:
contents: write
env:
# A space-separated list of paths to native libraries to build.
NATIVE_LIBRARY_PATHS: "sources/SDL/Native"
NATIVE_LIBRARY_PATHS: "sources/SDL/Native sources/OpenAL/Soft.Native"
# A space-separated list of submodule paths for each native library path. Use _ if a submodule is not used - this must
# match the number of spaces in NATIVE_LIBRARY_PATHS.
NATIVE_LIBRARY_SUBMODULE_PATHS: "eng/submodules/sdl"
NATIVE_LIBRARY_SUBMODULE_PATHS: "eng/submodules/sdl eng/submodules/openal-soft"
# A space-separated list of shorthands to the native library paths that will build the native library for each native
# library path. This must match the number of spaces in NATIVE_LIBRARY_PATHS. If a shorthand builds multiple native
# binary paths, these will be deduplicated.
NATIVE_LIBRARY_SHORTHANDS: "SDL"
NATIVE_LIBRARY_SHORTHANDS: "SDL OpenAL-Soft"
jobs:
prerequisites:
name: PR Check
Expand Down Expand Up @@ -61,13 +61,15 @@ jobs:
build:
needs: [prerequisites]
strategy:
fail-fast: false
matrix:
flat: ${{ fromJSON(needs.prerequisites.outputs.matrix_strategy) }}
runs-on: ${{ (startsWith(matrix.flat.runtime, 'osx') || startsWith(matrix.flat.runtime, 'ios') || startsWith(matrix.flat.runtime, 'tvos')) && 'macos-latest' || startsWith(matrix.flat.runtime, 'win') && 'windows-latest' || 'ubuntu-latest' }}
name: ${{ matrix.flat.target }} / ${{ matrix.flat.runtime }}
steps:
- uses: actions/checkout@v3
- run: |
- name: Build
run: |
echo "https://github.com/actions/upload-artifact/issues/174" > .workaround-${{ matrix.flat.target }}-${{ matrix.flat.runtime }}.txt
${{ format('.{0}{1}', startsWith(matrix.flat.runtime, 'win') && '\' || '/', matrix.flat.exec) }}
working-directory: ${{ matrix.flat.dir }}
Expand Down
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@
[submodule "eng/submodules/silk.net-2.x"]
path = eng/submodules/silk.net-2.x
url = https://github.com/dotnet/Silk.NET
[submodule "eng/submodules/openal-soft"]
path = eng/submodules/openal-soft
url = https://github.com/kcat/openal-soft
[submodule "eng/submodules/vulkan"]
path = eng/submodules/vulkan
url = https://github.com/KhronosGroup/Vulkan-Docs.git
[submodule "eng/submodules/vulkan-headers"]
path = eng/submodules/vulkan-headers
url = https://github.com/KhronosGroup/Vulkan-Headers.git
Binary file modified .silktouch/c8c046b328b09d23.stout
Binary file not shown.
3 changes: 3 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,7 @@
</ItemGroup>
<Copy SourceFiles="@(SilkThisRidItems)" DestinationFiles="@(SilkThisRidItems->'$(OutDir)%(TargetPath)')" />
</Target>

<!-- DSL dogfooding -->
<Import Project="$(MSBuildThisFileDirectory)sources/Core/Core/Silk.NET.Core.targets" Condition="'$(SilkDSLExempt)' != 'true' and '$(SilkNativePackage)' != 'true' and '$(SilkMetapackage)' != 'true'" />
</Project>
68 changes: 31 additions & 37 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
<Project>
<ItemGroup>
<!-- Common -->
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.1.1" />
<PackageVersion Include="DotNet.ReproducibleBuilds.Isolated" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.4.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="NUnit" Version="4.2.2" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />

<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.2.39" />
<PackageVersion Include="DotNet.ReproducibleBuilds.Isolated" Version="1.2.39" />
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="17.14.28" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="NAudio.Core" Version="2.2.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="5.2.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.11.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="NUnit" Version="4.4.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<!-- eng/benchmarks -->
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />

<PackageVersion Include="BenchmarkDotNet" Version="0.15.6" />
<!-- Silk.NET.Core -->
<PackageVersion Include="Fody" Version="6.8.2" PrivateAssets="all" />
<PackageVersion Include="InlineIL.Fody" Version="1.9.0" PrivateAssets="all" />

<PackageVersion Include="Fody" Version="6.9.3" PrivateAssets="all" />
<PackageVersion Include="InlineIL.Fody" Version="1.10.1" PrivateAssets="all" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="5.0.0-1.25277.114" />
<!-- Analyzers -->
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />

<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.12.0-beta1.25218.8" />
<!-- SilkTouch -->
<PackageVersion Include="ClangSharp.PInvokeGenerator" Version="18.1.0.2" />
<PackageVersion Include="ClangSharp.PInvokeGenerator" Version="20.1.2.4" />
<PackageVersion Include="CSharpier.Core" Version="0.30.2" />
<PackageVersion Include="Humanizer.Core" Version="2.14.1" />
<PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.11.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.12.2149" />
<PackageVersion Include="Microsoft.Build.Locator" Version="1.10.12" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.14.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.CommandLine" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="10.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.14.2075" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.IO.Hashing" Version="9.0.0" />

<!-- This is not used but it is used transitively and the version pulled in has a vulnerability -->
<PackageVersion Include="System.Formats.Asn1" Version="9.0.0" />

<PackageVersion Include="System.IO.Hashing" Version="10.0.0" />
<!-- SilkTouch Unit Tests -->
<PackageVersion Include="Silk.NET.BuildTools" Version="2.22.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.3" />
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
<PackageVersion Include="Verify.NUnit" Version="28.3.2" />
<PackageVersion Include="Verify.NUnit" Version="31.6.0" />
</ItemGroup>
</Project>
37 changes: 36 additions & 1 deletion Silk.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Windowing", "Windowing", "{
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Windowing", "sources\Windowing\Windowing\Silk.NET.Windowing.csproj", "{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Vulkan", "Vulkan", "{5E20252F-E2A0-46C9-BBEF-4CE5C96D0E07}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan", "sources\Vulkan\Vulkan\Silk.NET.Vulkan.csproj", "{E5E8FFBF-1319-4D33-B084-E732656E8A04}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenAL", "OpenAL", "{AF13F7C9-4EE2-403E-B3D2-C4C2E45D9EF3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenAL", "sources\OpenAL\OpenAL\Silk.NET.OpenAL.csproj", "{1FFFDD72-D023-441C-AF49-F1EA78FF7DE9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{6077EDD4-F16F-4CA4-B72E-E4627D64B104}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "CSharp", "{12B4D1CB-8938-4EC4-8895-79C4E6ABD1E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenAL", "OpenAL", "{662A1AEC-91F2-48FA-AA29-6F27038D30F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tutorial001.HelloSound", "examples\CSharp\OpenAL\Tutorial001.HelloSound\Tutorial001.HelloSound.csproj", "{946C912C-5BBB-446A-A566-0D1696D19F59}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -168,7 +184,19 @@ Global
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
{E5E8FFBF-1319-4D33-B084-E732656E8A04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5E8FFBF-1319-4D33-B084-E732656E8A04}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5E8FFBF-1319-4D33-B084-E732656E8A04}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5E8FFBF-1319-4D33-B084-E732656E8A04}.Release|Any CPU.Build.0 = Release|Any CPU
{1FFFDD72-D023-441C-AF49-F1EA78FF7DE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1FFFDD72-D023-441C-AF49-F1EA78FF7DE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1FFFDD72-D023-441C-AF49-F1EA78FF7DE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1FFFDD72-D023-441C-AF49-F1EA78FF7DE9}.Release|Any CPU.Build.0 = Release|Any CPU
{946C912C-5BBB-446A-A566-0D1696D19F59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{946C912C-5BBB-446A-A566-0D1696D19F59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{946C912C-5BBB-446A-A566-0D1696D19F59}.Release|Any CPU.ActiveCfg = Release|Any CPU
{946C912C-5BBB-446A-A566-0D1696D19F59}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
Expand Down Expand Up @@ -200,6 +228,13 @@ Global
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6} = {EC4D7B06-D277-4411-BD7B-71A6D37683F0}
{FE4414F8-5370-445D-9F24-C3AD3223F299} = {DD29EA8F-B1A6-45AA-8D2E-B38DA56D9EF6}
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E} = {FE4414F8-5370-445D-9F24-C3AD3223F299}
{AF13F7C9-4EE2-403E-B3D2-C4C2E45D9EF3} = {DD29EA8F-B1A6-45AA-8D2E-B38DA56D9EF6}
{1FFFDD72-D023-441C-AF49-F1EA78FF7DE9} = {AF13F7C9-4EE2-403E-B3D2-C4C2E45D9EF3}
{12B4D1CB-8938-4EC4-8895-79C4E6ABD1E8} = {6077EDD4-F16F-4CA4-B72E-E4627D64B104}
{662A1AEC-91F2-48FA-AA29-6F27038D30F2} = {12B4D1CB-8938-4EC4-8895-79C4E6ABD1E8}
{946C912C-5BBB-446A-A566-0D1696D19F59} = {662A1AEC-91F2-48FA-AA29-6F27038D30F2}
{5E20252F-E2A0-46C9-BBEF-4CE5C96D0E07} = {DD29EA8F-B1A6-45AA-8D2E-B38DA56D9EF6}
{E5E8FFBF-1319-4D33-B084-E732656E8A04} = {5E20252F-E2A0-46C9-BBEF-4CE5C96D0E07}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {78D2CF6A-60A1-43E3-837B-00B73C9DA384}
Expand Down
2 changes: 1 addition & 1 deletion docs/for-contributors/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ command like
where the values for the `-s` arguments are replaced with the job names (the keys of the `Jobs` dictionary in
`generator.json` e.g. `SDL`, `OpenGL`, etc).

For more information on SilkTocuh arguments, consult the [SilkTouch User Guide](../silktouch) or use
For more information on SilkTouch arguments, consult the [SilkTouch User Guide](../silktouch) or use
`dotnet run --project sources/SilkTouch/SilkTouch/Silk.NET.SilkTouch.csproj -- --help`.

<DocCardList items={useCurrentSidebarCategory().items.filter((e) => e.label != "Overview")} />
131 changes: 131 additions & 0 deletions docs/silk.net/static-vs-instance-bindings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Static vs Input Bindings

## Overview

Silk.NET has multiple ways to access the underlying APIs, either through a static method (e.g. `GL.GenBuffers`) or
through an "API object" (e.g. created with `GL.Create` and then accessed as `gl.GenBuffers`). Not all APIs are the
same, and some are better accessed through one method or the other. Note that Silk.NET does make both available however,
so if you're prefer consistency feel free to pick one method and stick to it, though you may result in some minor
inefficiencies.

All native APIs are accessed using a "function pointer" - a location in memory at which the native code resides.
This is typically fetched using `DllImport`, but some APIs require custom mechanisms. An example in OpenGL, where you
must use a "context API" (e.g. WGL, GLX, EGL, etc) to create a context and, after setting up that context state, use a
function provided by that context API to get the function pointers for OpenGL (e.g. `wglGetProcAddress`). We refer to
these as "stateful APIs" in this document. Note that OpenGL is not the only stateful API, this will be elaborated later.

Stateless APIs are those where the function pointers aren't contingent on any other state, and they're effectively
accessed as if they were static functions. For these, the function pointers are typically retrieved through `DllImport`,
but this needn't preclude other APIs from having bespoke mechanisms to statelessly retrieve function pointers (though,
there are no examples of this today).

When using a stateful API, you should use API objects if possible i.e. `API.Create`, and dispose of that object when you
are done using that API. When using a stateless API, you should use the static functions exposed directly on the API
class.

> [!NOTE]
> Future releases of Silk.NET are intended to contain analysers to indicate the correct access method.

Below is a description of the stateful APIs. All other APIs not listed here are, or can be treated as, stateless.

## OpenGL

OpenGL is a stateful API because it requires a context to be created and "made current" on that thread before function
pointers can be retrieved. Typically, this context is created using Silk.NET.Windowing, and the functions would be
retrieved using `surface.OpenGL.GetProcAddress` in that example.

To create an API object, our OpenGL bindings provide a utility function `CreateOpenGL`:
```csharp
IGL gl = null!;
surface.Created += _ =>
{
gl = surface.CreateOpenGL();
// Use gl functions here...
gl.Flush();
}
surface.Render += _ =>
{
// Use gl functions here...
gl.Clear(ClearBufferMask.ColorBufferBit);
}
```

If you'd prefer to use static methods despite OpenGL being stateful, the static functions on `GL` will forward to
`GL.ThisThread`, which essentially forwards to a thread-specific `IGL` instance. You can change the `IGL` instance used
by a thread using `GL.ThisThread.MakeCurrent`, which will also implicitly make the `IGLContext` you pass it current
(if applicable). Note that Silk.NET.Windowing will implicitly call this, so you can use the static OpenGL functions in
the obvious way, albeit with the implied indirection through `GL.ThisThread`:
```csharp
surface.Created += _ =>
{
GL.Flush();
}
surface.Render += _ =>
{
GL.Clear(ClearBufferMask.ColorBufferBit);
}
```

> [!CAUTION]
> TODO: Silk.NET.Windowing does not currently do this! `surface.MakeCurrent()` must be used in `surface.Created` to make
> this happen.

## Vulkan

Vulkan is a stateful API because its function pointers are dependent on the `InstanceHandle` and `DeviceHandle` being
used. Our Vulkan bindings intercept calls to `Vk.CreateInstance` and `Vk.CreateDevice`, and set `CurrentInstance` and
`CurrentDevice` respectively on the Vulkan API object for later use with `Vk.GetDeviceProcAddr` and
`Vk.GetInstanceProcAddr`.

The Vulkan API object will first try `vkGetDeviceProcAddr` to load a function pointer (where the value for `device` is
as in `CurrentDevice`), followed by `vkGetInstanceProcAddr` (where the value for `instance` is as in `CurrentInstance`).
For `vkGetInstanceProcAddr` itself, `DllImport` is used.

`CurrentInstance` is set upon a successful call to `vkCreateInstance`, and `CurrentDevice` is set upon a successful call
to `vkCreateDevice`. Note that it is illegal to change these values on an API object if they're already set, if you have
scenarios requiring multiple instance-device combinations you must create multiple API objects.

> [!TIP]
> In cases where you have one instance from which multiple devices are created, simply clone the `IVk` object using
> `IVk.Clone()` prior to **any device** being created. This will reuse the function pointers already loaded for that
> instance.

If you'd prefer to use static methods despite Vulkan being stateful, the static functions on `Vk` will forward to
`Vk.ThisThread`, which essentially forwards to a thread-specific `IVk` instance. You can change the `IVk` instance used
by a thread using `Vk.ThisThread.MakeCurrent`. The static functions, much like using a single `IVk` instance, will throw
if multiple instance-device combinations are used on the same thread without changing the `IVk` object being used.

## OpenXR

OpenXR has the same caveats as Vulkan but with `CurrentInstance` only.

## OpenAL

OpenAL has the same caveats as OpenGL, with the exception that `alGetProcAddress` is made available to retrieve the
function pointers. This still has the requirement of a thread-specific context, however, which can be made current using
`AL.ThisThread.MakeCurrent`.

Unlike OpenGL, OpenAL has an official context API: OpenAL Context (ALC). `alcMakeContextCurrent` will implicitly call
`AL.ThisThread.MakeCurrent` meaning that the static OpenAL functions are made available in the obvious way:

```csharp
// NOTE: We are making use of ALContext's static functions here as well.
// The same applies as if `ALContext.Create` were used.
DeviceHandle device = ALContext.OpenDevice("");
if (device == nullptr) throw new("failed to create device");

ContextHandle context = ALContext.CreateContext(device, nullptr);
if (context == nullptr) throw new("failed to create context");

// Now make the context current. This implicitly calls AL.ThisThread.MakeCurrent
ALContext.MakeContextCurrent(context);

// Static functions now just work.
var source = AL.GenSource();
```

## OpenAL Context (ALContext/ALC)

ALC has the same caveats as Vulkan, given that the ALC function pointers are tied to a specific device. As a result,
`alcOpenDevice` is intercepted to set the value of `CurrentDevice` to then be fed into `alcGetProcAddress` (or
`alcGetProcAddress2` if available).
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<DefineConstants>$(DefineConstants);MATHF</DefineConstants>
</PropertyGroup>

Expand Down
Loading