Added loading code for OpenCL entry points.
This commit is contained in:
parent
ea6a4479e5
commit
1df3101a47
1 changed files with 27 additions and 0 deletions
|
@ -1,11 +1,38 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace OpenTK.Compute.CL10
|
namespace OpenTK.Compute.CL10
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the OpenCL 1.0 flat API.
|
||||||
|
/// </summary>
|
||||||
public partial class CL
|
public partial class CL
|
||||||
{
|
{
|
||||||
|
#region Private Members
|
||||||
|
|
||||||
const string Library = "opencl.dll";
|
const string Library = "opencl.dll";
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
static CL()
|
||||||
|
{
|
||||||
|
Type imports = typeof(CL).GetNestedType("Core", BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
|
FieldInfo[] delegates = typeof(CL).GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic).GetFields(BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
|
if (delegates == null || imports == null)
|
||||||
|
throw new Exception("[Internal Error] Failed to locate CL.Delegates. Please file a bug report at http://www.opentk.com/issues");
|
||||||
|
|
||||||
|
for (int i = 0; i < delegates.Length; i++)
|
||||||
|
{
|
||||||
|
MethodInfo method = imports.GetMethod(delegates[i].Name.Substring(2), BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
|
Delegate @new = Delegate.CreateDelegate(delegates[i].FieldType, method);
|
||||||
|
delegates[i].SetValue(null, @new);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue