How do I remove all deprecated GL functions from OpenTK.dll to reduce the size?
OpenTK.Platform.Windows.WinGLContext.LoadAll() takes some considerable time at startup. How to filter out and prevent loading any deprecated functionality?
Posted Thursday, 24 February, 2011 - 12:37 by the Fiddler
I have spent a lot of time researching this, to no obvious solution. Potential solutions:
Modify the binding generator to ignore deprecated functions (Source/Bind/CSharpSpecWriter.cs lines 179, 210 and 301, add something like (if(f.Deprecated)return;). Run it and recompile OpenTK (the examples will fail to compile, ignore them).
Modify GraphicsContext to avoid calling LoadAll() automatically. In this case, you will have to load all OpenGL functions you use manually.
Find a way to load entry points lazily (on first use). I've been able to do this with C# 3, but the setting up the process took more time than loading the entry points anyway.
Find a way to postprocess OpenTK.dll to replace Marshal.GetDelegateForFunctionPointer() with calli instructions. This way we could completely avoid the delegates/dllimports separation and the entry-point-to-delegate conversion code.
Posted Thursday, 24 February, 2011 - 13:54 by tksuoran
I was looking at binding generator but I have no idea how to actually use it. The documentation is out of date, there is no more build exe in SVN and so on.
I'd like to get as close as possible instant startup but on some system getting GameWindow open takes around a second (Asus Eeebox that has GL3 NVIDIA Ion as GPU but poor Atom CPU..)
Posted Thursday, 24 February, 2011 - 14:13 by the Fiddler
I'm at work now, but IIRC you can run the generator directly through the solution (right click -> "set as startup project" -> F5). It should output the results directly into Source/OpenTK/Graphics/OpenGL, so you can rebuild the solution directly.
Posted Thursday, 24 February, 2011 - 16:18 by the Fiddler
You can use f.Extension in a similar fashion to remove the extensions you don't need. (Core functions return f.Extension = "" or "Core", can't remember off-hand).
Posted Thursday, 24 February, 2011 - 17:41 by tksuoran
Oh yes, that worked well.
Is GLCore.cs also generated by something? It still has all deprecated and extension stuff. I commented out a lot of stuff that I don't need and my application still works, and it helped to get OpenTK.dll smaller.
I am now down to 1168 kb OpenTK.dll, which is almost there; I think I could live with it being 1MB or less :)
Comments
Re: slim OpenTK version?
I have spent a lot of time researching this, to no obvious solution. Potential solutions:
if (f.Deprecated) return;). Run it and recompile OpenTK (the examples will fail to compile, ignore them).Marshal.GetDelegateForFunctionPointer()withcalliinstructions. This way we could completely avoid the delegates/dllimports separation and the entry-point-to-delegate conversion code.How much time does LoadAll() take on your system?
Re: slim OpenTK version?
I was looking at binding generator but I have no idea how to actually use it. The documentation is out of date, there is no more build exe in SVN and so on.
I'd like to get as close as possible instant startup but on some system getting GameWindow open takes around a second (Asus Eeebox that has GL3 NVIDIA Ion as GPU but poor Atom CPU..)
Re: slim OpenTK version?
I'm at work now, but IIRC you can run the generator directly through the solution (right click -> "set as startup project" -> F5). It should output the results directly into Source/OpenTK/Graphics/OpenGL, so you can rebuild the solution directly.
Re: slim OpenTK version?
Thanks, I will give it a try. Do I need both Generator.Bind and Generator.Convert?
Edit: Simply running Generator.Bind() is enough. I also had to remove stuff from GLHelper.
Can I somehow also remove extensions, like, all non-ARB extensions?
Re: slim OpenTK version?
You can use
f.Extensionin a similar fashion to remove the extensions you don't need. (Core functions return f.Extension = "" or "Core", can't remember off-hand).Re: slim OpenTK version?
Oh yes, that worked well.
Is GLCore.cs also generated by something? It still has all deprecated and extension stuff. I commented out a lot of stuff that I don't need and my application still works, and it helped to get OpenTK.dll smaller.
I am now down to 1168 kb OpenTK.dll, which is almost there; I think I could live with it being 1MB or less :)
Re: slim OpenTK version?
GLCore.cs is generated in the WriteImports() method. Just give it the same treatment.
One final thing you can do is comment out the [AutoGenerated] attributes in WriteMethod().