Hi,
I would like to understand more about the concept of "Exclusive Context Thread", I read this but I didnt the concept very well Could someone please elaborate and explain better what this is? Basically the idea to to dedicates the glcontext to the animator, right? Reading here, it says: "Abstraction for an OpenGL rendering context. In order to perform OpenGL rendering, a context must be "made current" on the current thread. OpenGL rendering semantics specify that only one context may be current on the current thread at any given time, and also that a given context may be current on only one thread at any given time. Because components can be added to and removed from the component hierarchy at any time, it is possible that the underlying OpenGL context may need to be destroyed and recreated multiple times over the lifetime of a given component. This process is handled by the implementation, and the GLContext abstraction provides a stable object which clients can use to refer to a given context." So, in order to perform rendering, the thread animator needs the glContext to be made current.. right? Now, according to sven, when he tested the nv driver, it was slow switching glContext... I dont understand, why it is being switched? And who is owning the glContext between these switches other then the animator? |
Administrator
|
Hi
Actually, numerous drivers don't behave correctly especially under Windows when you drive the OpenGL context current on another thread that the one on which the window was created, especially with Intel drivers. In my humble opinion, you should avoid useless context switches. I didn't do it carefully in JogAmp's Ardor3D Continuation and I got a huge boost (frame rate 12 times bigger) when I fixed it. It's possible to drive the context current at the beginning of the rendering and release it at the end of the rendering, it is typically done before and after calling GLEventListener.display() but if you don't need to make it current on several threads (even though you use GLAutoDrawable.invoke()), you just need to make it current once and release it only when you destroy your drawable. Note that as stated in the doc, it's particularly suitable when using NEWT. GLContext is just an abstraction. Look at the unit tests and use setExclusiveContextThread only if you use an animator and if you don't call GLContext.makeCurrent().
Julien Gouesse | Personal blog | Website
|
Hi Gouessej,
may you elaborate further? Because I am really struggling here I looked at the ExclusiveContextBase00 unit case and this is how I copied the workflow animator = new Animator(); animator.setRunAsFastAsPossible(true); animator.setModeBits(false, AnimatorBase.MODE_EXPECT_AWT_RENDERING_THREAD); animator.add(glWindow); animator.setExclusiveContext(true); glWindow.setExclusiveContextThread(animator.getExclusiveContextThread()); animator.start(); but I don't see any improving... And one think that suggests me my animator could run so much faster is this: 0 s: 40 f / 337 ms, 118.6 fps, 8 ms/f; total: 40 f, 118.6 fps, 8 ms/f 0 s: 40 f / 481 ms, 83.1 fps, 12 ms/f; total: 80 f, 97.7 fps, 10 ms/f 1 s: 40 f / 788 ms, 50.7 fps, 19 ms/f; total: 120 f, 74.7 fps, 13 ms/f 2 s: 40 f / 682 ms, 58.6 fps, 17 ms/f; total: 160 f, 69.9 fps, 14 ms/f 3 s: 40 f / 754 ms, 53.0 fps, 18 ms/f; total: 200 f, 65.7 fps, 15 ms/f 3 s: 40 f / 862 ms, 46.4 fps, 21 ms/f; total: 240 f, 61.4 fps, 16 ms/f 4 s: 40 f / 939 ms, 42.5 fps, 23 ms/f; total: 280 f, 57.8 fps, 17 ms/f 5 s: 40 f / 861 ms, 46.4 fps, 21 ms/f; total: 320 f, 56.1 fps, 17 ms/f 6 s: 40 f / 929 ms, 43.0 fps, 23 ms/f; total: 360 f, 54.2 fps, 18 ms/f 7 s: 40 f / 955 ms, 41.8 fps, 23 ms/f; total: 400 f, 52.7 fps, 18 ms/f 8 s: 40 f / 932 ms, 42.9 fps, 23 ms/f; total: 440 f, 51.6 fps, 19 ms/f 9 s: 40 f / 857 ms, 46.6 fps, 21 ms/f; total: 480 f, 51.1 fps, 19 ms/f 10 s: 40 f / 933 ms, 42.8 fps, 23 ms/f; total: 520 f, 50.4 fps, 19 ms/f 11 s: 40 f / 950 ms, 42.1 fps, 23 ms/f; total: 560 f, 49.7 fps, 20 ms/f 12 s: 40 f / 927 ms, 43.1 fps, 23 ms/f; total: 600 f, 49.2 fps, 20 ms/f 12 s: 40 f / 531 ms, 75.3 fps, 13 ms/f; total: 640 f, 50.3 fps, 19 ms/f 13 s: 40 f / 296 ms, 135.1 fps, 7 ms/f; total: 680 f, 52.2 fps, 19 ms/f 13 s: 40 f / 597 ms, 67.0 fps, 14 ms/f; total: 720 f, 52.8 fps, 18 ms/f 14 s: 40 f / 753 ms, 53.1 fps, 18 ms/f; total: 760 f, 52.9 fps, 18 ms/f 15 s: 40 f / 680 ms, 58.8 fps, 17 ms/f; total: 800 f, 53.1 fps, 18 ms/f 15 s: 40 f / 777 ms, 51.4 fps, 19 ms/f; total: 840 f, 53.0 fps, 18 ms/f 16 s: 40 f / 901 ms, 44.3 fps, 22 ms/f; total: 880 f, 52.6 fps, 19 ms/f 17 s: 40 f / 914 ms, 43.7 fps, 22 ms/f; total: 920 f, 52.1 fps, 19 ms/f 18 s: 40 f / 864 ms, 46.2 fps, 21 ms/f; total: 960 f, 51.8 fps, 19 ms/f 19 s: 40 f / 950 ms, 42.1 fps, 23 ms/f; total: 1000 f, 51.4 fps, 19 ms/f 20 s: 40 f / 952 ms, 42.0 fps, 23 ms/f; total: 1040 f, 50.9 fps, 19 ms/f 21 s: 40 f / 903 ms, 44.2 fps, 22 ms/f; total: 1080 f, 50.6 fps, 19 ms/f 22 s: 40 f / 859 ms, 46.5 fps, 21 ms/f; total: 1120 f, 50.5 fps, 19 ms/f 23 s: 40 f / 952 ms, 42.0 fps, 23 ms/f; total: 1160 f, 50.1 fps, 19 ms/f 24 s: 40 f / 941 ms, 42.5 fps, 23 ms/f; total: 1200 f, 49.8 fps, 20 ms/f 24 s: 40 f / 888 ms, 45.0 fps, 22 ms/f; total: 1240 f, 49.7 fps, 20 ms/f 25 s: 40 f / 466 ms, 85.8 fps, 11 ms/f; total: 1280 f, 50.3 fps, 19 ms/f 25 s: 40 f / 331 ms, 120.8 fps, 8 ms/f; total: 1320 f, 51.2 fps, 19 ms/f 26 s: 40 f / 721 ms, 55.4 fps, 18 ms/f; total: 1360 f, 51.3 fps, 19 ms/f 27 s: 40 f / 727 ms, 55.0 fps, 18 ms/f; total: 1400 f, 51.4 fps, 19 ms/f 27 s: 40 f / 704 ms, 56.8 fps, 17 ms/f; total: 1440 f, 51.6 fps, 19 ms/f 28 s: 40 f / 803 ms, 49.8 fps, 20 ms/f; total: 1480 f, 51.5 fps, 19 ms/f 29 s: 40 f / 952 ms, 42.0 fps, 23 ms/f; total: 1520 f, 51.2 fps, 19 ms/f 30 s: 40 f / 904 ms, 44.2 fps, 22 ms/f; total: 1560 f, 51.0 fps, 19 ms/f 31 s: 40 f / 881 ms, 45.4 fps, 22 ms/f; total: 1600 f, 50.9 fps, 19 ms/f 32 s: 40 f / 977 ms, 40.9 fps, 24 ms/f; total: 1640 f, 50.6 fps, 19 ms/f 33 s: 40 f / 948 ms, 42.1 fps, 23 ms/f; total: 1680 f, 50.3 fps, 19 ms/f 34 s: 40 f / 881 ms, 45.4 fps, 22 ms/f; total: 1720 f, 50.2 fps, 19 ms/f 35 s: 40 f / 900 ms, 44.4 fps, 22 ms/f; total: 1760 f, 50.0 fps, 19 ms/f 36 s: 40 f / 988 ms, 40.4 fps, 24 ms/f; total: 1800 f, 49.8 fps, 20 ms/f 37 s: 40 f / 976 ms, 40.9 fps, 24 ms/f; total: 1840 f, 49.5 fps, 20 ms/f 37 s: 40 f / 845 ms, 47.3 fps, 21 ms/f; total: 1880 f, 49.5 fps, 20 ms/f 38 s: 40 f / 298 ms, 134.2 fps, 7 ms/f; total: 1920 f, 50.2 fps, 19 ms/f 38 s: 40 f / 354 ms, 112.9 fps, 8 ms/f; total: 1960 f, 50.7 fps, 19 ms/f 39 s: 40 f / 814 ms, 49.1 fps, 20 ms/f; total: 2000 f, 50.7 fps, 19 ms/f 40 s: 40 f / 702 ms, 56.9 fps, 17 ms/f; total: 2040 f, 50.8 fps, 19 ms/f 40 s: 40 f / 720 ms, 55.5 fps, 18 ms/f; total: 2080 f, 50.9 fps, 19 ms/f 41 s: 40 f / 822 ms, 48.6 fps, 20 ms/f; total: 2120 f, 50.8 fps, 19 ms/f 42 s: 40 f / 966 ms, 41.4 fps, 24 ms/f; total: 2160 f, 50.6 fps, 19 ms/f 43 s: 40 f / 893 ms, 44.7 fps, 22 ms/f; total: 2200 f, 50.5 fps, 19 ms/f 44 s: 40 f / 911 ms, 43.9 fps, 22 ms/f; total: 2240 f, 50.4 fps, 19 ms/f 45 s: 40 f / 975 ms, 41.0 fps, 24 ms/f; total: 2280 f, 50.2 fps, 19 ms/f 46 s: 40 f / 957 ms, 41.7 fps, 23 ms/f; total: 2320 f, 50.0 fps, 19 ms/f 47 s: 40 f / 875 ms, 45.7 fps, 21 ms/f; total: 2360 f, 49.9 fps, 20 ms/f 48 s: 40 f / 917 ms, 43.6 fps, 22 ms/f; total: 2400 f, 49.8 fps, 20 ms/f 49 s: 40 f / 950 ms, 42.1 fps, 23 ms/f; total: 2440 f, 49.6 fps, 20 ms/f 50 s: 40 f / 949 ms, 42.1 fps, 23 ms/f; total: 2480 f, 49.5 fps, 20 ms/f 50 s: 40 f / 693 ms, 57.7 fps, 17 ms/f; total: 2520 f, 49.6 fps, 20 ms/f 51 s: 40 f / 305 ms, 131.1 fps, 7 ms/f; total: 2560 f, 50.1 fps, 19 ms/f 51 s: 40 f / 472 ms, 84.7 fps, 11 ms/f; total: 2600 f, 50.4 fps, 19 ms/f 52 s: 40 f / 787 ms, 50.8 fps, 19 ms/f; total: 2640 f, 50.4 fps, 19 ms/f 53 s: 40 f / 692 ms, 57.8 fps, 17 ms/f; total: 2680 f, 50.5 fps, 19 ms/f |
Administrator
|
In some situations, it leads to no measurable improvements, I'm not surprised by your results. I obtained a speedup thanks to several improvements, not only thanks to the exclusive context thread.
Julien Gouesse | Personal blog | Website
|
Did you experience also something similar? Like what for example? |
Administrator
|
Yes I did but you could obtain different results under Android.
Reread one of my previous posts about carefully managing the OpenGL context, queuing, avoiding useless makeCurrent() calls...
Julien Gouesse | Personal blog | Website
|
Where? Could you link it? Or do you mean the previous ones in this thread? |
Free forum by Nabble | Edit this page |