Skip to content

Commit 34aa1c0

Browse files
committed
Triangle with Silk.NET.Windowing 3.0
1 parent 0bd60d8 commit 34aa1c0

26 files changed

+741
-156
lines changed

.gitattributes

Lines changed: 30 additions & 0 deletions
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,6 +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
66+
*.so binary
67+
*.dll binary
68+
*.xcscheme binary
69+
*.xcworkspacedata binary
70+
*.pdf binary
71+
*.pfx binary
72+
*.metal binary
73+
*.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
5686

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

sources/Core/Core/Abstractions/Version32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public readonly struct Version32
2020
/// <param name="minor">The minor value.</param>
2121
/// <param name="patch">The patch value.</param>
2222
/// <param name="variant">The variant value.</param>
23-
public Version32(uint major, uint minor, uint patch, uint variant = 0) =>
23+
public Version32(uint major, uint minor, uint patch = 0, uint variant = 0) =>
2424
Value = (variant << 29) | (major << 22) | (minor << 12) | patch;
2525

2626
/// <summary>

sources/Core/Core/Pointers/Ptr.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public T[] ToArray<T>(int length)
102102
[MethodImpl(
103103
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
104104
)]
105+
// TODO analyzer to ensure ptr is on stack or otherwise pinned
105106
public static bool operator ==(Ref lh, Ptr rh) => (void*)lh == rh.Native;
106107

107108
/// <summary>

sources/Core/Core/Pointers/Ptr.generic.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ public unsafe struct Ptr<T>(T* ptr)
327327
[MethodImpl(
328328
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
329329
)]
330+
// TODO analyzer to ensure ptr is on stack or otherwise pinned
330331
public static explicit operator Ptr<T>(Ref<T> ptr) => (T*)ptr;
331332

332333
/// <summary>
@@ -338,6 +339,15 @@ public unsafe struct Ptr<T>(T* ptr)
338339
)]
339340
public static implicit operator Ptr(Ptr<T> ptr) => new Ptr(ptr.Native);
340341

342+
/// <summary>
343+
/// Creates a <see cref="Ref"/> from a <see cref="Ptr{T}"/>
344+
/// </summary>
345+
/// <param name="ptr"></param>
346+
[MethodImpl(
347+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
348+
)]
349+
public static implicit operator Ref(Ptr<T> ptr) => ptr.Native;
350+
341351
/// <summary>
342352
/// Creates a <see cref="Ptr{T}"/> from a <see cref="Ptr"/>
343353
/// </summary>

sources/Core/Core/Pointers/Ptr2D.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,33 @@ public T[][] ToArray<T>(int length, int[] lengths)
353353
[MethodImpl(
354354
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
355355
)]
356+
// TODO analyzer to ensure ptr is on stack or otherwise pinned
356357
public static explicit operator Ptr2D(Ref2D ptr) => (void**)ptr;
357358

359+
/// <summary>
360+
/// Expresses this <see cref="Ptr2D" /> as a <see cref="Ref"/>. Note that this does not index the
361+
/// <see cref="Ptr2D"/>'s dimensions, and is effectively equivalent to converting a <c>void**</c> to a
362+
/// <c>void*</c>.
363+
/// </summary>
364+
/// <param name="ptr">The <see cref="Ptr2D"/>.</param>
365+
/// <returns>The <see cref="Ref"/>.</returns>
366+
[MethodImpl(
367+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
368+
)]
369+
public static implicit operator Ref(Ptr2D ptr) => ptr.Native;
370+
371+
/// <summary>
372+
/// Expresses this <see cref="Ptr2D" /> as a <see cref="Ptr"/>. Note that this does not index the
373+
/// <see cref="Ptr2D"/>'s dimensions, and is effectively equivalent to converting a <c>void**</c> to a
374+
/// <c>void*</c>.
375+
/// </summary>
376+
/// <param name="ptr">The <see cref="Ptr2D"/>.</param>
377+
/// <returns>The <see cref="Ptr"/>.</returns>
378+
[MethodImpl(
379+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
380+
)]
381+
public static implicit operator Ptr(Ptr2D ptr) => ptr.Native;
382+
358383
/// <summary>
359384
/// Creates a null ptr
360385
/// </summary>

sources/Core/Core/Pointers/Ptr2D.generic.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ public T[][] ToArray(int length, int[] lengths) =>
515515
[MethodImpl(
516516
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
517517
)]
518-
public static implicit operator Ptr2D<T>(Ref2D ptr) => (void**)ptr;
518+
// TODO analyzer to ensure ptr is on stack or otherwise pinned
519+
public static explicit operator Ptr2D<T>(Ref2D ptr) => (void**)ptr;
519520

520521
/// <summary>
521522
/// Creates a <see cref="Ref"/> from a <see cref="Ptr2D{T}"/>
@@ -524,7 +525,32 @@ public T[][] ToArray(int length, int[] lengths) =>
524525
[MethodImpl(
525526
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
526527
)]
527-
public static implicit operator Ptr2D<T>(Ref2D<T> ptr) => (T**)ptr;
528+
// TODO analyzer to ensure ptr is on stack or otherwise pinned
529+
public static explicit operator Ptr2D<T>(Ref2D<T> ptr) => (T**)ptr;
530+
531+
/// <summary>
532+
/// Expresses this <see cref="Ptr2D{T}" /> as a <see cref="Ref"/>. Note that this does not index the
533+
/// <see cref="Ptr2D{T}"/>'s dimensions, and is effectively equivalent to converting a <c>void**</c> to a
534+
/// <c>void*</c>.
535+
/// </summary>
536+
/// <param name="ptr">The <see cref="Ptr2D{T}"/>.</param>
537+
/// <returns>The <see cref="Ref"/>.</returns>
538+
[MethodImpl(
539+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
540+
)]
541+
public static implicit operator Ref(Ptr2D<T> ptr) => ptr.Native;
542+
543+
/// <summary>
544+
/// Expresses this <see cref="Ptr2D{T}" /> as a <see cref="Ptr"/>. Note that this does not index the
545+
/// <see cref="Ptr2D{T}"/>'s dimensions, and is effectively equivalent to converting a <c>void**</c> to a
546+
/// <c>void*</c>.
547+
/// </summary>
548+
/// <param name="ptr">The <see cref="Ptr2D{T}"/>.</param>
549+
/// <returns>The <see cref="Ptr"/>.</returns>
550+
[MethodImpl(
551+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
552+
)]
553+
public static implicit operator Ptr(Ptr2D<T> ptr) => ptr.Native;
528554

529555
/// <summary>
530556
/// Creates a <see cref="Ptr"/> from a <see cref="Ptr2D{T}"/>

sources/Core/Core/Pointers/Ptr3D.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,37 @@ ptr.Native is not null && ptr.Native->Native is not null
370370
public static implicit operator void***(Ptr3D ptr) => (void***)ptr.Native;
371371

372372
/// <summary>
373-
/// Creates a <see cref="Ref2D"/> from a <see cref="Ptr3D"/>
373+
/// Creates a <see cref="Ref3D"/> from a <see cref="Ptr3D"/>
374374
/// </summary>
375375
/// <param name="ptr"></param>
376376
[MethodImpl(
377377
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
378378
)]
379-
public static implicit operator Ref2D(Ptr3D ptr) => ptr.Native;
379+
public static implicit operator Ref3D(Ptr3D ptr) => ptr.Native;
380+
381+
/// <summary>
382+
/// Expresses this <see cref="Ptr3D" /> as a <see cref="Ref"/>. Note that this does not index the
383+
/// <see cref="Ptr3D"/>'s dimensions, and is effectively equivalent to converting a <c>void***</c> to a
384+
/// <c>void*</c>.
385+
/// </summary>
386+
/// <param name="ptr">The <see cref="Ptr3D"/>.</param>
387+
/// <returns>The <see cref="Ref"/>.</returns>
388+
[MethodImpl(
389+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
390+
)]
391+
public static implicit operator Ref(Ptr3D ptr) => ptr.Native;
392+
393+
/// <summary>
394+
/// Expresses this <see cref="Ptr3D" /> as a <see cref="Ptr"/>. Note that this does not index the
395+
/// <see cref="Ptr3D"/>'s dimensions, and is effectively equivalent to converting a <c>void***</c> to a
396+
/// <c>void*</c>.
397+
/// </summary>
398+
/// <param name="ptr">The <see cref="Ptr3D"/>.</param>
399+
/// <returns>The <see cref="Ptr"/>.</returns>
400+
[MethodImpl(
401+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
402+
)]
403+
public static implicit operator Ptr(Ptr3D ptr) => ptr.Native;
380404

381405
/// <summary>
382406
/// Creates a <see cref="Ptr3D"/> from a <see cref="Ref2D"/>
@@ -385,6 +409,7 @@ ptr.Native is not null && ptr.Native->Native is not null
385409
[MethodImpl(
386410
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
387411
)]
412+
// TODO analyzer to ensure ptr is on stack or otherwise pinned
388413
public static explicit operator Ptr3D(Ref2D ptr) => (void**)ptr;
389414

390415
/// <summary>

sources/Core/Core/Pointers/Ptr3D.generic.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,14 +534,39 @@ ptr.Native is not null && ptr.Native->Native is not null
534534
)]
535535
public static implicit operator Ref3D<T>(Ptr3D<T> ptr) => ptr.Native;
536536

537+
/// <summary>
538+
/// Expresses this <see cref="Ptr3D{T}" /> as a <see cref="Ref"/>. Note that this does not index the
539+
/// <see cref="Ptr3D{T}"/>'s dimensions, and is effectively equivalent to converting a <c>void***</c> to a
540+
/// <c>void*</c>.
541+
/// </summary>
542+
/// <param name="ptr">The <see cref="Ptr3D{T}"/>.</param>
543+
/// <returns>The <see cref="Ref"/>.</returns>
544+
[MethodImpl(
545+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
546+
)]
547+
public static implicit operator Ref(Ptr3D<T> ptr) => ptr.Native;
548+
549+
/// <summary>
550+
/// Expresses this <see cref="Ptr3D{T}" /> as a <see cref="Ptr"/>. Note that this does not index the
551+
/// <see cref="Ptr3D{T}"/>'s dimensions, and is effectively equivalent to converting a <c>void***</c> to a
552+
/// <c>void*</c>.
553+
/// </summary>
554+
/// <param name="ptr">The <see cref="Ptr3D{T}"/>.</param>
555+
/// <returns>The <see cref="Ptr"/>.</returns>
556+
[MethodImpl(
557+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
558+
)]
559+
public static implicit operator Ptr(Ptr3D<T> ptr) => ptr.Native;
560+
537561
/// <summary>
538562
/// Creates a <see cref="Ref"/> from a <see cref="Ptr3D{T}"/>
539563
/// </summary>
540564
/// <param name="ptr"></param>
541565
[MethodImpl(
542566
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
543567
)]
544-
public static implicit operator Ptr3D<T>(Ref3D ptr) => (void***)ptr;
568+
// TODO analyzer to ensure ptr is on stack or otherwise pinned
569+
public static explicit operator Ptr3D<T>(Ref3D ptr) => (void***)ptr;
545570

546571
/// <summary>
547572
/// Creates a <see cref="Ref"/> from a <see cref="Ptr3D{T}"/>
@@ -550,7 +575,8 @@ ptr.Native is not null && ptr.Native->Native is not null
550575
[MethodImpl(
551576
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
552577
)]
553-
public static implicit operator Ptr3D<T>(Ref3D<T> ptr) => (T***)ptr;
578+
// TODO analyzer to ensure ptr is on stack or otherwise pinned
579+
public static explicit operator Ptr3D<T>(Ref3D<T> ptr) => (T***)ptr;
554580

555581
/// <summary>
556582
/// Creates a <see cref="Ptr"/> from a <see cref="Ptr3D{T}"/>

sources/Core/Core/Pointers/Ref2D.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ public ref Ref this[nuint index]
210210
public static implicit operator Ref2D(byte[][] array) =>
211211
SilkMarshal.JaggedArrayToPointerArray<byte>(array);
212212

213+
/// <summary>
214+
/// Expresses this <see cref="Ref2D" /> as a <see cref="Ref"/>. Note that this does not index the
215+
/// <see cref="Ref2D"/>'s dimensions, and is effectively equivalent to converting a <c>void**</c> to a
216+
/// <c>void*</c>.
217+
/// </summary>
218+
/// <param name="ptr">The <see cref="Ref2D"/>.</param>
219+
/// <returns>The <see cref="Ref"/>.</returns>
220+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
221+
public static implicit operator Ref(Ref2D ptr) => new(ref ptr.InteriorRef);
222+
213223
/// <summary>
214224
/// creates a <see cref="Ref2D"/> from a reference array
215225
/// </summary>

sources/Core/Core/Pointers/Ref2D.generic.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ public ref Ref<T> this[nuint index]
230230
public static implicit operator Ref2D<T>(T[][] array) =>
231231
SilkMarshal.JaggedArrayToPointerArray<T>(array);
232232

233+
/// <summary>
234+
/// Expresses this <see cref="Ref2D{T}" /> as a <see cref="Ref"/>. Note that this does not index the
235+
/// <see cref="Ref2D{T}"/>'s dimensions, and is effectively equivalent to converting a <c>void**</c> to a
236+
/// <c>void*</c>.
237+
/// </summary>
238+
/// <param name="ptr">The <see cref="Ref2D{T}"/>.</param>
239+
/// <returns>The <see cref="Ref"/>.</returns>
240+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
241+
public static implicit operator Ref(Ref2D<T> ptr) => new(ref ptr.InteriorRef);
242+
233243
/// <summary>
234244
/// creates a <see cref="Ref2D{T}"/> from a reference array
235245
/// </summary>

0 commit comments

Comments
 (0)