Activate nVIDIA Optimus under Java/OpenGL? -
i know it's asked several times no clear answer , filed bug nvidia. however, i'm still seeking better workaround starting javafx in prism-d3d engine (which allows subsequent opengl context created via nvidia).
environment:
- nvidia 860m, driver 337.88, 340.43, 340.66 (quadro driver)
- java 8u11 (tested x86/x64 & java 7 well)
tested , failed:
- nvidia profile
- nvoptimusenablement (custom launcher written in c)
- calling opencl first (custom launcher written in c)
- calling cuda first (jcuda, shows nvidia name opengl remains unaffected)
failed apis:
- javafx8 es2 pipeline (it function, see https://github.com/aqd/jogl-fx )
- jogl 2.1.5
workarounds:
- javafx8 d3d pipeline. glcontext created after d3d initialization work.
i nailed problem simple sample, calling realtech-vr opengl extension viewer (written in .net). inside there native "infogl.dll" reads gl information , apparently activates optimus right after oevclientinitialize.
the weirdness that, simplest console program calling infogl.dll works:
win32.oevsetdriverversion("10.18.10.3621", 2176); win32.oevclientloaddatabase(file.readalltext("c:\\program files (x86)\\realtech vr\\opengl extensions viewer 4.1\\extensions.xml")); win32.oevclientinitialize(); (var = 0; <= 9; i++) { var tree = marshal.ptrtostringansi(win32.oevclientgetcapsandexttree(i)); console.writeline(tree.split('\n').first(ln => ln.contains("text_id=\"357\""))); } console.readline();
but same code in java jna doesn't:
infogl.instance.oevsetdriverversion("10.18.10.3621", 2176); string extxml = null; try { extxml = new string( files.readallbytes(paths.get("c:\\program files (x86)\\realtech vr\\opengl extensions viewer 4.1\\extensions.xml")), "utf-8"); } catch (ioexception e) { throw new runtimeexception(e); } infogl.instance.oevclientloaddatabase(extxml); infogl.instance.oevclientinitialize(); (int = 0; <= 9; i++) { string tree = infogl.instance.oevclientgetcapsandexttree(i); system.out.println(arrays.aslist(tree.split("\\n")).first(ln -> ln.contains("text_id=\"357\""))); }
and it's unrelated executable name "java" - have tried.
the javafx d3d solution unsuitable because reduces opengl fps half on amd radeon chips - assume must bad on nvidia ones, , that's why seek work es2 pipeline.
launching jvm .net apparently works (via jni4net). crashes in nvoglv64.dll @ end of javafx finalization through.
using net.sf.jni4net; using net.sf.jni4net.utils; ... public static void main(string[] args) { initializeopengl(); var setup = new bridgesetup(); setup.addclasspath(@"c:\program files\java\jdk1.8.0_11\demo\javafx_samples\modena.jar"); setup.addjvmoption("-dprism.order=es2"); setup.addjvmoption("-dprism.verbose=true"); var env = bridge.createjvm(setup); java.lang.system.@out.println("greetings c# java world!"); console.writeline("initializing..."); var klass = env.findclass("modena/modena"); console.writeline("finding main()..."); var mainmethodid = klass.getmethods().first(m => m.getname().equals("main")).getmethodid(); console.writeline("calling main()..."); env.callstaticvoidmethod(klass, mainmethodid, convertor.pararraystrongc2jstring(env, new string[0])); console.writeline("ended, press enter"); console.readline(); } protected static void initializeopengl() { win32.oevsetdriverversion("10.18.10.3621", 2176); win32.oevclientloaddatabase(file.readalltext("c:\\program files (x86)\\realtech vr\\opengl extensions viewer 4.1\\extensions.xml")); win32.oevclientinitialize(); (var = 0; <= 9; i++) { var tree = marshal.ptrtostringansi(win32.oevclientgetcapsandexttree(i)); console.writeline(tree.split('\n').first(ln => ln.contains("text_id=\"357\""))); } // optimus should activated now! }
i have yet found real reason optimus activated under .net...... it's c/c++ of same code wouldn't work, since it's java version (jni calls)
ps: verified "opentk" (.net wrapper of opengl) cannot activate optimus either. i'm totally confused.....
Comments
Post a Comment