luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lockup on start with Nvidia GTX 1070

antoinecla opened this issue · comments

Step to reproduce:

  • On Visual Studio 2015
  • Create new Windows Forms application, .NET 4.6.1
  • Add reference to: OpenGL.Net\OpenGL.Net.WinForms\bin\net461\Debug\OpenGL.Net.WinForms.dll OpenGL.Net.WInforms
  • Open Form1
  • Add GlControl
  • Build
  • Run on dedicated gpu

Result:
On start, application lockup with high CPU usage.

Attaching with debugger and breaking shows that the application is stuck in:
GetGLProcAddressWGL.GetProcAddress(string function)
Argument function is "wglGetGPUIDsAMD"

This was tested on a laptop with an Intel GPU and dedicated Nvidia GPU (GTX 1070). By default, the application uses the Intel GPU and runs without issues.

Stack Trace:

 	[Managed to Native Transition]	
>	OpenGL.Net.dll!OpenGL.GetGLProcAddressWGL.GetProcAddress(string function) Line 124	C#
 	OpenGL.Net.dll!OpenGL.GetProcAddressGL.GetProcAddress(string function) Line 66	C#
 	OpenGL.Net.dll!OpenGL.KhronosApi.GetProcAddressGLOS(string path, string function) Line 129	C#
 	OpenGL.Net.dll!Khronos.KhronosApi.BindAPIFunction(string path, Khronos.KhronosApi.GetAddressDelegate getAddress, Khronos.KhronosApi.FunctionContext functionContext, System.Reflection.FieldInfo function, Khronos.KhronosVersion version, Khronos.KhronosApi.ExtensionsCollection extensions) Line 301	C#
 	OpenGL.Net.dll!Khronos.KhronosApi.BindAPI<OpenGL.Wgl>(string path, Khronos.KhronosApi.GetAddressDelegate getAddress, Khronos.KhronosVersion version, Khronos.KhronosApi.ExtensionsCollection extensions) Line 188	C#
 	OpenGL.Net.dll!Khronos.KhronosApi.BindAPI<OpenGL.Wgl>(string path, Khronos.KhronosApi.GetAddressDelegate getAddress, Khronos.KhronosVersion version) Line 159	C#
 	OpenGL.Net.dll!OpenGL.Wgl.BindAPI() Line 83	C#
 	OpenGL.Net.dll!OpenGL.Wgl.Wgl() Line 47	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	OpenGL.Net.dll!OpenGL.DeviceContext.GetCurrentContext() Line 692	C#
 	OpenGL.Net.dll!OpenGL.DeviceContext.Dispose(bool disposing) Line 734	C#
 	OpenGL.Net.dll!OpenGL.DeviceContextEGL.Dispose(bool disposing) Line 1183	C#
 	OpenGL.Net.dll!OpenGL.DeviceContext.Dispose() Line 745	C#
 	OpenGL.Net.dll!OpenGL.Egl.Initialize() Line 149	C#
 	OpenGL.Net.dll!OpenGL.Egl.Egl() Line 54	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	OpenGL.Net.dll!OpenGL.DeviceContext.DeviceContext() Line 43	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	OpenGL.Net.WinForms.dll!OpenGL.GlControl.CreateDeviceContext(OpenGL.DevicePixelFormat controlReqFormat) Line 564	C#
 	OpenGL.Net.WinForms.dll!OpenGL.GlControl.CreateDeviceContext() Line 541	C#
 	OpenGL.Net.WinForms.dll!OpenGL.GlControl.OnHandleCreated(System.EventArgs e) Line 1106	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WmCreate(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.UserControl.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	System.Windows.Forms.dll!System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(int dwExStyle, string lpszClassName, string lpszWindowName, int style, int x, int y, int width, int height, System.Runtime.InteropServices.HandleRef hWndParent, System.Runtime.InteropServices.HandleRef hMenu, System.Runtime.InteropServices.HandleRef hInst, object pvParam)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams cp)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.CreateHandle()	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.CreateControl(bool fIgnoreVisible)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.CreateControl(bool fIgnoreVisible)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.CreateControl()	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WmShowWindow(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Form.WmShowWindow(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	System.Windows.Forms.dll!System.Windows.Forms.Control.SetVisibleCore(bool value)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Form.SetVisibleCore(bool value)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.Visible.set(bool value)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)	Unknown
 	GlNetTestA.exe!GlNetTestA.Program.Main() Line 20	C#

I note that WGL functions are accessed on EGL context disposition. This issue should change due commit for #71.

This issue should be repeatable if you're running WGL.