mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-03-29 07:26:53 +00:00
Implemented new loading mechanism
This commit is contained in:
parent
7a57c9c3d2
commit
825ed3621f
|
@ -35,6 +35,18 @@ namespace OpenTK.Graphics
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class GraphicsBindingsBase : BindingsBase
|
public abstract class GraphicsBindingsBase : BindingsBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains the list of API entry points (function pointers).
|
||||||
|
/// This field must be set by an inheriting class.
|
||||||
|
/// </summary>
|
||||||
|
protected IntPtr[] EntryPointsInstance;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains the list of API entry point names.
|
||||||
|
/// This field must be set by an inheriting class.
|
||||||
|
/// </summary>
|
||||||
|
protected string[] EntryPointNamesInstance;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves an unmanaged function pointer to the specified function.
|
/// Retrieves an unmanaged function pointer to the specified function.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -58,22 +70,20 @@ namespace OpenTK.Graphics
|
||||||
return context != null ? context.GetAddress(funcname) : IntPtr.Zero;
|
return context != null ? context.GetAddress(funcname) : IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Delegate GetExtensionDelegateStatic(string funcname, Type signature)
|
// Loads all available entry points for the current API.
|
||||||
|
// Note: we prefer IGraphicsContextInternal.GetAddress over
|
||||||
|
// this.GetAddress to improve loading performance (less
|
||||||
|
// validation necessary.)
|
||||||
|
internal override void LoadEntryPoints()
|
||||||
{
|
{
|
||||||
var context = GraphicsContext.CurrentContext as IGraphicsContextInternal;
|
IGraphicsContext context = GraphicsContext.CurrentContext;
|
||||||
if (context == null)
|
if (context == null)
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
|
||||||
IntPtr address = context.GetAddress(funcname);
|
IGraphicsContextInternal context_internal = context as IGraphicsContextInternal;
|
||||||
if (address == IntPtr.Zero ||
|
for (int i = 0; i < EntryPointsInstance.Length; i++)
|
||||||
address == new IntPtr(1) || // Workaround for buggy nvidia drivers which return
|
|
||||||
address == new IntPtr(2)) // 1 or 2 instead of IntPtr.Zero for some extensions.
|
|
||||||
{
|
{
|
||||||
return null;
|
EntryPointsInstance[i] = context_internal.GetAddress(EntryPointNamesInstance[i]);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Marshal.GetDelegateForFunctionPointer(address, signature);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue