-
-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathCL.cs
38 lines (34 loc) · 1.24 KB
/
CL.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.DependencyModel;
using Silk.NET.Core.Attributes;
using Silk.NET.Core.Contexts;
using Silk.NET.Core.Loader;
using Silk.NET.Core.Native;
namespace Silk.NET.OpenCL
{
public partial class CL
{
public static CL GetApi()
{
return new CL(CreateDefaultContext(new OpenCLLibraryNameContainer().GetLibraryNames()));
}
#if NET5_0_OR_GREATER
public bool TryGetExtension<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(out T ext)
#else
public bool TryGetExtension<T>(out T ext)
#endif
where T : NativeExtension<CL>
{
ext = IsExtensionPresent(ExtensionAttribute.GetExtensionAttribute(typeof(T)).Name)
? (T)Activator.CreateInstance(typeof(T), Context)
: null;
return ext != null;
}
public override bool IsExtensionPresent(string extension)
{
return true; // idk opencl doesn't define a default way for extension loading,
// nor is one ever defined on the internet so just assume that it's all good
}
}
}