Skip to content

Commit 1b87a6b

Browse files
Perkseydotnet-bot
andauthored
[3.0] Windowing Rewrite (#2278)
* Initial group codegen * Fix some trimming oddities * Fix HintTargetPGI and others similarly situated * Base typing and namespacing * Cast enum members, fix stray semicolons, Silk.NET.OpenGL builds again * Group and bool transformations * Fix erroneous cast order * Add Delete(singular) overloads (ArrayParameterOverloader) * Add SAL object model & Khronos length metadata parsing * ArrayParameterTransformer w/ tests * Integrate ArrayParameterTransformer * Support SupportedApiProfileAttribute generation with metadata * PrettifyNames conflict resolution now actually works * Fix casting transformation ambiguity bugs * Fix metadata retrieval for reserved identifiers * Fix unit tests * Fixup for all caps names * Fix naive trimming bug * More self-review comments * SDL bindings * Fix naming regression * Prettify & extract the nested _e__{Union,Struct,FixedBuffer} structs * Function pointer generation * Add a second pass to name delegates based on usage! * Fixes from self-review * Windowing 3.0 Iteration 1 with Dependency Injection - scrapped * WIP Windowing 3.0 for real this time * Some more work Will be pausing here as I need to change the bindings, and to be honest I don't want to do that without doing the SilkTouch refactor first. * Rejig the repo structure * Save progress, as I am deleting the progress * Create a Roslyn compilation & workspace * Bugfixes, generation runs with renaming but is slow and outputs wrong * Some more bugfixes * Fix mods not saving outputs, unnecessary subdirs, filenames, and other renamer issues * Add IResponseFileMod, fix EntryPoint not in DllImport, and other fixes & improvements * Delete some stray files * Minor nits * Initial commit of the SymbolFinder rename experiment * This is the new renamer * Fix ctors and dtors, stop using `using static`s * Regenerate bindings * Use public Roslyn APIs and parallelise * Fix buidl * Add ISurfaceProvider * Add a write-up on the PAL HLU concepts/status for the future * Remove the hosting API * Start on a more clean sheet and conservative implementation * Separate files * Lay out impl, add new APIs from proposal * Add a Utf8String helper type, and transform string constants to use it * Move bakery functionality into a mod separate from SupportedApiProfiles * Rename GetTypeDeclaration to BakeMember * Cache the result of function pointer loading * Fix vulnerability? * Recognise some #define enums, improve pfn type gen, update SDL, more fixes * Update ClangSharp (with no changes!!!!1111!1!!!111 🎉) * Commit cache files too * Add SDL_gpu (and other missing headers such as SDL_vulkan) * Check-in rsp changes, add namespace for windowing, add SDL_main bindings * Work on more of the implementation * Triangle with Silk.NET.Windowing 3.0 * Implement all APIs * Wire up all relevant events * Sweep a macOS deficiency under the rug * Apply initial configuration, surprisingly little code... * Initial work on native build workflow * Stop using YAML for GITHUB_OUTPUT * Add GH_TOKEN env var to stage2 * Use an action for comment writing instead * Fix permissions, try to fix expr issue * Same again * Fix PR comment location * Replace the comment rather than append to it * Start of native build job * Attempt to fix matrix * Add a job name, fix build script permissions issues * Add OSX build for SDL * Start of commit job * Add missing checkout * Use official action to checkout PR * Fix permissions issues * Update native binaries for bc82423 * Start of linux-x64 SDL build * Sudo for apt * apt-get update * Checkout submodule * Fix path error * Update native binaries for ece2459 * Add linux-arm and linux-arm64 * Use glibc 2.34 on linux-arm for Y2038 support * Update native binaries for 3e3df2c * Add win-arm, win-arm64, win-x64 * Fix dir structure * Attempt to keep win-arm support, may be on the chopping block though * Fix batch script error * Use curl instead of wget? * Fix winsdk install? * Remove 32-bit Windows on Arm support * Use a Microsoft Developer Command Prompt * Fix vcvarsall path * Use Ninja - libsdl-org/SDL##11487 * Update native binaries for 601bb66 * Fix artifact download path * Fix the fix * Update native binaries for 4630438 * Add iOS and tvOS for SDL * Fix file permissions * Update native binaries for 45f36d0 * Add Android build for SDL * Apparently sdkmanager is not in PATH * Install Python 3.11 * Install Ninja * Update native binaries for d7d3c69 * Try to ungitignore the Android jar * Update native binaries for f79ad90 * Add an easy update script * Include org.libsdl.app bindings with the aar, working package now * Update native binaries for 8cf95c2 * Some cleanup, and add docs * Fix build * Install workloads in test too * Update native binaries for 186f907 * Fix build (not ideally) * Update native binaries for 44b9933 * Dummy commit to run Test/Build again * Remove old code * Fix it * Stop downloading previews? * Add dependency to native package for SDL * Fix build * Only duplicate the VersionSuffix for natives * Add SilkActivity * WG comments * Fix build? * More build fix attempts * Use the condition guards for xplat builds * Fix csproj * Clear locals to try and fix weird .NET SDK bug * Add workaround from dotnet/maui#27215 * Fixes from self review * Rectify remaining self-review comments * nit --------- Co-authored-by: The Silk.NET Automaton <[email protected]>
1 parent 9bf9279 commit 1b87a6b

File tree

243 files changed

+75435
-37459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

243 files changed

+75435
-37459
lines changed

.gitattributes

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*.sln text eol=lf
2424
*.targets text eol=lf
2525
*.yml text eol=lf
26+
*.hlsl text eof=lf
2627

2728
###############################################################################
2829
# Set explicit file behavior to:
@@ -53,10 +54,35 @@
5354
*.7z binary
5455
*.ttf binary
5556
*.stout binary
57+
*.p7s binary
58+
*.sample binary
59+
*.nupkg binary
60+
*.exe binary
61+
*.idx binary
62+
*.pack binary
63+
*.spv binary
64+
*.lib binary
65+
*.dylib binary
5666
*.so binary
5767
*.dll binary
58-
*.dylib binary
68+
*.xcscheme binary
69+
*.xcworkspacedata binary
70+
*.pdf binary
71+
*.pfx binary
72+
*.metal binary
5973
*.jar binary
74+
*.apk binary
75+
*.aar binary
76+
*.aidl binary
77+
*.flata binary
78+
*.metallib binary
79+
*.items binary
80+
*.stamp binary
81+
*.icns binary
82+
*.mdb binary
83+
*.pdb binary
84+
*.bmp binary
85+
*.dat binary
6086

6187
# Verify
6288
*.verified.txt text eol=lf working-tree-encoding=UTF-8

.github/workflows/publish-site.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ jobs:
1313
Build:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
17+
- name: Setup .NET 8
18+
uses: actions/setup-dotnet@v3
19+
with:
20+
dotnet-version: '8.0.x'
21+
- name: Setup .NET 9
22+
uses: actions/setup-dotnet@v3
23+
with:
24+
dotnet-version: '9.0.102'
1725
- name: Build Website
1826
run: |
1927
git submodule update --init eng/submodules/silk.net-2.x

.silktouch/0afb5dc84012c2fa.stout

-154 KB
Binary file not shown.

.silktouch/91c9aa14a031651f.stout

215 KB
Binary file not shown.

.silktouch/c8c046b328b09d23.stout

0 Bytes
Binary file not shown.

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<PackageVersionDependsOn>SilkShippingControl;$(PackageVersionDependsOn)</PackageVersionDependsOn>
6868
<TargetsForTfmSpecificContentInPackage>SilkNativePackaging;$(TargetsForTfmSpecificContentInPackage)</TargetsForTfmSpecificContentInPackage>
6969
<GenerateNuspecDependsOn>SilkShippingControl;$(GenerateNuspecDependsOn)</GenerateNuspecDependsOn>
70+
<UseMonoRuntime>false</UseMonoRuntime>
7071
</PropertyGroup>
7172

7273
<!-- SourceLink -->

Directory.Packages.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<PackageVersion Include="Fody" Version="6.8.2" PrivateAssets="all" />
2020
<PackageVersion Include="InlineIL.Fody" Version="1.9.0" PrivateAssets="all" />
2121

22+
<!-- Analyzers -->
23+
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
24+
2225
<!-- SilkTouch -->
2326
<PackageVersion Include="ClangSharp.PInvokeGenerator" Version="18.1.0.2" />
2427
<PackageVersion Include="CSharpier.Core" Version="0.30.2" />

Silk.NET.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1313
LICENSE.md = LICENSE.md
1414
generator.json = generator.json
1515
Silk.NET.sln.DotSettings = Silk.NET.sln.DotSettings
16+
Directory.Packages.props = Directory.Packages.props
1617
EndProjectSection
1718
EndProject
1819
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{9DB0EA3E-7216-4F9C-98F5-8A7483E9F083}"
@@ -97,6 +98,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Win32", "Win32", "{6E739132
9798
EndProject
9899
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.SDL.Native", "sources\SDL\Native\Silk.NET.SDL.Native.csproj", "{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}"
99100
EndProject
101+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Windowing", "Windowing", "{FE4414F8-5370-445D-9F24-C3AD3223F299}"
102+
EndProject
103+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Windowing", "sources\Windowing\Windowing\Silk.NET.Windowing.csproj", "{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}"
104+
EndProject
100105
Global
101106
GlobalSection(SolutionConfigurationPlatforms) = preSolution
102107
Debug|Any CPU = Debug|Any CPU
@@ -159,6 +164,10 @@ Global
159164
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
160165
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
161166
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Release|Any CPU.Build.0 = Release|Any CPU
167+
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
168+
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
169+
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
170+
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Release|Any CPU.Build.0 = Release|Any CPU
162171
EndGlobalSection
163172
GlobalSection(SolutionProperties) = preSolution
164173
HideSolutionNode = FALSE
@@ -189,6 +198,8 @@ Global
189198
{6FA628B8-9696-4847-89F9-E58F470AF4FB} = {5CD096DB-6C44-48F1-9093-AD4C84B6B7EC}
190199
{6E739132-EEAB-43A5-83C7-EB58C50D03A1} = {DD29EA8F-B1A6-45AA-8D2E-B38DA56D9EF6}
191200
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6} = {EC4D7B06-D277-4411-BD7B-71A6D37683F0}
201+
{FE4414F8-5370-445D-9F24-C3AD3223F299} = {DD29EA8F-B1A6-45AA-8D2E-B38DA56D9EF6}
202+
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E} = {FE4414F8-5370-445D-9F24-C3AD3223F299}
192203
EndGlobalSection
193204
GlobalSection(ExtensibilityGlobals) = postSolution
194205
SolutionGuid = {78D2CF6A-60A1-43E3-837B-00B73C9DA384}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# The Event Pump
2+
3+
The largest influence in the `ISurfaceApplication` design is the fact that for many platforms only the entry thread is
4+
allowed to interact with the window manager (e.g. for the purposes of events). This creates a problem because rendering
5+
is very much not single-threaded, nor are most use cases where the user has multiple windows. As such,
6+
`ISurfaceApplication` gives the implementation freedom to decide what the most appropriate thread is to call into the
7+
surface to raise events. This is further emphasised by the definition of `ISurfaceChildren` where the user can only
8+
`Spawn` a surface, and not have a blocking call they can send off to their own thread. This allows the child windows to
9+
use the same event thread and synchronization. This is likely inconvenient for rendering scenarios though
10+
(e.g. for OpenGL where it's one thread per context/window, but all surfaces use the same thread by default...), for
11+
which I expect that we'll add the ability to multithread for certain events in `SurfaceTimingOptions` or
12+
`SurfaceTickOptions`. This however has been excluded from the initial 3.0 proposal.
13+
14+
Note that `SDL_AppEvent` is only guaranteed to be called on the event thread for events raised by the window
15+
manager/operating system. As such, we always assume that those events are on the event thread when received and invoke
16+
the window directly. For other events, we should be wary of concurrency. Note that I have absolutely no idea what this
17+
means for things like our `Surface.Continue` method for `IsEventDriven` - right now this isn't implemented. Read more
18+
here: https://github.com/libsdl-org/SDL/issues/11387
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Silk.NET.Windowing
2+
3+
Silk.NET.Windowing is our cross-platform windowing abstraction. For more information about what it is, see the [proposal](../../proposals/Proposal%20-%20Windowing%203.0.md).
4+
5+
As per the proposal, Windowing is implemented in exactly one project/assembly containing the abstractions and one
6+
"reference implementation" given available target information (e.g. TFM). Today, this includes:
7+
- SDL3, used for every platform.
8+
9+
If the user doesn't want to use our reference implementation, it is expected that they use the trimmer to make its
10+
presence benign.
11+
12+
Note that for each "reference implementation" it is expected that there shall be a matching Silk.NET.Input "reference
13+
implementation" capable of receiving an `INativeWindow` from the Silk.NET.Windowing implementation in use. How you
14+
interpret this requirement is up to you, e.g. we could have a Silk.NET.Input Win32-specific implementation that uses
15+
`Win32PlatformInfo` for our SDL3 surface, likewise we could have a Silk.NET.Input SDL3 implementation that receives a
16+
`Win32PlatformInfo` from a Silk.NET.Windowing implementation and automatically creates a wrapping window - this is up to
17+
you (but try to keep it sane please, that last one sounded extremely cursed). Ultimately, the goal is the user being
18+
able to pull in `Silk.NET.Windowing` and `Silk.NET.Input`, create a surface, be able to do `surface.CreateInput()` and
19+
it all Just Work. Right now, this equates to a 1:1 match of Silk.NET.Windowing/Silk.NET.Input implementations, and is
20+
not expected to change.
21+
22+
Silk.NET.Input is completely independent from Silk.NET.Windowing this time around, unlike 1.X/2.X. This is because we
23+
believe the Input HLU can target wider applicability beyond just receiving input for a window, with VR being the
24+
principal use case in mind when making this decision. For more information, read the [Multi-Backend Input proposal](../../proposals/Proposal%20-%20Multi-Backend%20Input.md).
25+
26+
Most of the files within the top-level Windowing directory are exactly as proposed. The exception is the `Surface`
27+
class, which seeks to make as much common as humanly possible (this includes the Render/Update timing logic and some
28+
other auxiliary functions). Beyond that, this is functionally an interface. The actual entry-points into the Windowing
29+
API, `ISurfaceApplication.Run` and `IDetachedSurfaceLifecycle.TryCreate`, are defined `partial`ly with matching
30+
implementation parts in the `Implementations` subdirectories.
31+
32+
To find out more about the implementation details, see the `Implementations` directory.

0 commit comments

Comments
 (0)