Commit Graph

234 Commits

Author SHA1 Message Date
Michael Meeks
1479ad1c63 vcl: opengl - Kill the last glErrors on common paths.
Re-work the makeSomeOpenGLContextCurrent logic into a shared function
with the existing AcquireContext logic in the SalOpenGLGraphics impl.
Use an OpenGLVCLContextZone placeholder to do both context and zone
management - to include destructors into the zone.

Fix a number of error cases around SalBitmaps where we did not have
a GL context associated when allocating, and/or freeing textures..

Don't drag a (potentially) slower context around in the
OpenGLSalBitmap when we're going to check / fetch a better VCL
context anyway.

Change-Id: Ibbb2358c47156cd078ad28b6aad4f03af36aaf23
Reviewed-on: https://gerrit.libreoffice.org/21127
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-01-06 09:17:16 +00:00
Tor Lillqvist
1fd7994a4e Fix dbgutil build in case GL_DEBUG_SEVERITY_NOTIFICATION_ARB is undefined
Change-Id: I14628e9dee8651e87b4782057c4681fded5e4643
2016-01-05 16:19:29 +02:00
Emmanuel Gil Peyrot
928fe134ff vcl: Ignore i965’s shader compiler debug
Change-Id: I94c5759d47a17e93f0614bfd95b52d64f9d2d896
2016-01-05 15:05:48 +01:00
Michael Meeks
370199fa0f vcl: improve OpenGL debugging variously.
Change-Id: I097f1c1fb7fb505b6859289997bff3562fc06ba6
Reviewed-on: https://gerrit.libreoffice.org/21027
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-01-01 10:07:06 +00:00
Tor Lillqvist
b716be0c06 Initialise bArbMultisampleSupported as false
Otherwise the code doesn't make sense; InitMultisample() would return
true even if no pixel format was chosen. Found by code reading by me
and Emmanuel, not actually verified on non-multi-sample-capable
hardware.

Change-Id: I7197a1c72768bbf2c928193582104a82808ea53c
2015-12-15 19:46:06 +02:00
Michael Meeks
6c68b71058 vcl: use a custom tag for VCL OpenGLContext's to avoid re-use.
Other code is out of legacy mode now, so can't legacy as a proxy.

Change-Id: Ie3807a3af680b707f2f08d058db955bc9cae6c2b
Reviewed-on: https://gerrit.libreoffice.org/20647
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2015-12-11 20:39:15 +00:00
Michael Meeks
7bc1f1285e tdf#93529 - move to a Mac-like double-buffered OpenGL model.
This moves us to always rendering to an off-screen texture, and then
(at idle) blitting this to the screen & swapping buffers. Ideally we
should never see any rendering, or flicker again with this approach.

Several fixes are included:
   + avoid multiple OpenGL contexts being created for the same window,
     created excessive flicker problems.
   + de-virtualize UseContext - which context we use is less critical.
   + kill 'mbOffscreen' distinction - all VCL rendering is offscreen.
   + implement 'doFlush' and high priority idle flushing.
   + bind stencil buffer for clipping vs. textures - fixing complex
     clopping when rendering to virtual-devices, and off-screen.
   + document environment. variables.
   + use white as default background glClear color, but red or
     random color for DBGUTIL.

Change-Id: I6be08595b6c8deb7e6db0dbd81308b2c97d2b4ff
2015-12-11 11:39:55 +00:00
Michael Meeks
93185f720a Get Double-buffered context creation working on linux.
Change-Id: I3db1d6792fcd51577f047b82029124ec825ea319
2015-12-11 11:39:55 +00:00
Tor Lillqvist
dff18c2be9 Bin the pointless and thin OS X specific wrapper namespace 'OpenGLWrapper'
Besides, the namespace was confusingly named the same as the public
cross-platform OpenGLWrapper struct (which is effectively just a
namespace, too).

Change-Id: I9a5255ec446dcdb5086d92a742f29327d0780685
2015-12-08 14:03:33 +02:00
Stephan Bergmann
ab9add5c96 loplugin:sallogareas
Change-Id: Ib1f06cb5f925535858bc14aab6f59ad7fd2a3a8d
2015-11-20 10:14:49 +01:00
Stephan Bergmann
5bf3daf9cb loplugin:nullptr
Change-Id: Ie461bc10ee2f7d2329a23c86bdc922839bea7974
2015-11-19 14:15:35 +01:00
Tor Lillqvist
0e6e0cea8f Add OpenGLContext::UseNoProgram()
Will be useful in cases where there is some external library code that uses
shaders outside of our OpenGLContext.

Change-Id: I59c57e3225f55d13e69b6a9b7c0db1a7487c586d
2015-11-19 14:05:29 +02:00
Tor Lillqvist
c8a7887846 Improve SAL_WARN message readability
Change-Id: Ia9e1ea7a69e372725a4239fad2630b6f8bcb52e2
2015-11-19 10:54:38 +02:00
Tor Lillqvist
da11e33744 Check for OpenGL errors right where an error might be generated
CHECK_GL_ERROR() is now zero-cost in a production build, so no reason
to avoid it.

Don't check for OpenGL errors after glX or wgl calls. They don't
generate OpenGL errors but use the X and Win32 error mechanisms, as
far as I see.

Change-Id: I8f97ef434cbdc89d6e345a247456cfc4a1a82bb6
2015-11-17 09:28:02 +02:00
Michael Meeks
9801b2c24c opengl: remove unused mbPixmap & glPix members.
We use textures bound to FBO's for everything in recent times.

Change-Id: I7c9068d75b3653a2ceff0056e2ade1f27955422f
Reviewed-on: https://gerrit.libreoffice.org/19995
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2015-11-16 17:24:59 +00:00
Michael Meeks
4ad05823f6 Add comment to 'direct' parameter: un-related to double-buffering.
Change-Id: I07002fd73fc004439aea75c5aca8ca3700ec1079
Reviewed-on: https://gerrit.libreoffice.org/19996
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
2015-11-16 17:18:29 +00:00
Tor Lillqvist
bb34de0189 Move checkExtension() to a more private location
Change-Id: I9f8a4ca0991b59bb9b6af4d40e3136ce5c986731
2015-11-11 18:06:42 +02:00
Stephan Bergmann
d3b6cb7ec2 loplugin:nullptr (automatic rewrite)
Change-Id: I05e89f9896170d4df3d1377549ea074f06b884a0
2015-11-10 10:32:00 +01:00
Tor Lillqvist
3decb561ea Surely a 24-bit depth buffer is enough
We asked for a 64-bit one, which is rather preposterous. And the
comment claimed we asked for a 32-bit one. Funnily, this same odd code
and comment is found in half a dozen code samples on the
Internet... Copy pasta rules.

Change-Id: Ie54a7b75e07cfe0ffd98ec330ce63158d2d15415
2015-11-10 11:08:02 +02:00
Tor Lillqvist
ecc421cab9 Add some assertions and improve comments
Make sure the hardcoded indexes into the iAttributes array that we use
mean what they are supposed to.

Add comments about that, and fix one misleading comment.

Change-Id: Ibb748b00782db4fcaf34f6c717075f6aff50651e
2015-11-10 10:58:31 +02:00
Tor Lillqvist
7d84e3e08b Speed up in-process caching of OpenGL shader programs
It seems to be fairly CPU intensive to calculate the MD5 digest of
shader program source code. But we don't need to use that to look up a
corrresponding program in the run-time in-process cache anyway. The
shader names are unique, so it is enough to use that as key.

Change-Id: I8fd9f5f875be14a82cd53daf8a2ca72bfd23beb6
2015-10-19 17:53:13 +03:00
Michael Stahl
5efad73918 vcl: clean up before error returns in OpenGLContext::ImplInit()
JunitTest_chart_unoapi fails here with "assert(!hasCurrent())" because
the initialization apparently fails due to lack of a
wglCreateContextAttribsARB in the VM, so ensure that the hTempRC is not
active and also deleted in all cases.

Change-Id: I7e03b95d1146af48a24e34692c3c2827298fccee
2015-09-30 18:28:22 +02:00
Michael Meeks
6f0f4ee720 tdf#94213 - release offscreen texture properly on re-size.
We need to ensure that we use an initialized context, and that
(when we re-parent) we DeInit and so reset the previous OpenGLContext.
Make UseContext more paranoid as well for good measure.

Change-Id: Ia45334222045e5d2f48da47560fab8511223a9a5
Reviewed-on: https://gerrit.libreoffice.org/18601
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2015-09-16 02:00:16 +00:00
Marco Cecchetti
d8f78d624b tdf#93814: Added support for caching shader program binaries.
Change-Id: I21c844b47282f6b3eec443933a86421a074e24df
Reviewed-on: https://gerrit.libreoffice.org/18555
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2015-09-15 15:08:01 +00:00
Caolán McNamara
47d3e82e4f boost->std
Change-Id: I9b4f884c6313a53fea543ea6f93175205351ad14
Reviewed-on: https://gerrit.libreoffice.org/18517
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2015-09-13 19:38:08 +00:00
Miklos Vajna
29ec512e8c windows opengl: make sure mpLastContext is indeed the current context
There were two problems here:

1) The OpenGLContext ctor registered the instance on the list of
contexts, but platform-specific call (e.g. wglMakeCurrent()) was only
made later. Add a registerAsCurrent() member function that helps
ensuring that the last item in the context list is indeed the current
context.

2) OpenGLContext::prepareForYield() is called without the solar mutex
being locked, but it still assumes that the last context in the context
list is the thread's current context, which may not be true.  The result
is that during JunitTest_sd_unoapi, we end up in a situation like:

debug:4640:5240: OpenGLContext::registerAsCurrent: wglGetCurrentContext() is 00010001, pSVData->maGDIData.mpLastContext is 00FA65F8
debug:4640:7944: OpenGLContext::registerAsCurrent: wglGetCurrentContext() is 000D0003, pSVData->maGDIData.mpLastContext is 00FA6C70
debug:4640:5240: OpenGLContext::prepareForYield: start, wglGetCurrentContext() is 00010001, pSVData->maGDIData.mpLastContext is 00FA6C70

I.e. one thread registers as current, an other registers as current, too (while
the other thread has the solar mutex), then once the original thread wants to
release the solar mutex, the real current context and the last item in the
context list won't match, so the assert at the end of prepareForYield() will
fail.

Fix this by releasing the GL context in WinSalInstance::DestroyFrame().

With this, JunitTest_sd_unoapi passes on Windows with GL enabled.

Change-Id: Icfb9c65c871586b5df69b5a2ab3aa91843dfc799
Reviewed-on: https://gerrit.libreoffice.org/18473
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2015-09-11 06:55:54 +00:00
Caolán McNamara
5094b783fa coverity#1323759 Uninitialized pointer field
Change-Id: I9fca8838beb1c2f6db8a9f1c9b6fe77f247b847c
2015-09-10 21:10:10 +01:00
Miklos Vajna
57fc41adc9 windows opengl: mpCurrentProgram seen as 0
in JunitTest_sc_unoapi_3.

Change-Id: Ibe12a31c1158f782bd7df115171b07e1843d025c
2015-09-10 13:51:49 +02:00
Michael Meeks
82d25c02f8 tdf#94006 - need an explicit dispose for GLContext's SystemChildWindow.
Previously we would get an explicit ~OpenGLContext - and potentially
leave FMR's around for other OGC users, now we treat the other users
properly - we need an explicit dispose() to get Window::dispose ordering
right.

Change-Id: I5edcbd73399b6db3dbcfb391570f364f9ab0c70d
Reviewed-on: https://gerrit.libreoffice.org/18412
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
2015-09-08 15:47:49 +00:00
Michael Meeks
56900a441d tdf#94006 - fix OpenGLContext mis-use in several places.
gltf rendering, OpenGL canvas, GL transitions & GL capable (charts)
Avoid GLX operations on un-initialized contexts.

Change-Id: I7f523640f66ab656896181e5c865879234f6640e
2015-09-08 13:04:02 +01:00
Michael Meeks
2456cf8306 tdf#94006 - re-factor to use rtl::Reference for OpenGLContexts.
Don't use rtl::Reference for the global / list state, so the
ref-count reflects the number of real users.
Hold a reference during ~OpenGLContext.

Change-Id: I4e57a7246159acd58ae7d5a0dfc8704b9795c894
2015-09-08 13:04:02 +01:00
Markus Mohrhard
c94d60d6c1 don't use a null display
Change-Id: Iab0a53abd723f0309f40742636315079a4b2c532
2015-09-07 22:33:56 +02:00
Markus Mohrhard
4ff0032528 avoid some OpenGL calls when vcl OpenGL is not enabled
There are even more and it is causing a number of performance issues.
This just fixes the most obvious place.

Change-Id: Id85c13b5b7f4bb0bc077e62c39258067e17c0094
2015-09-07 21:15:51 +02:00
Markus Mohrhard
7ce77fcfce prevent crash with non-vcl OpenGL contexts
Change-Id: Ia829b0f723c8ded1237e52d48f034da3c1ac249e
2015-09-07 16:41:11 +02:00
Tor Lillqvist
091723f7fd Avoid a SAL_INFO about OpenGL when not using OpenGL
Change-Id: Ia066c240776cecc855b59ab0ccc84e7fdcbf4b79
2015-09-04 16:58:16 +03:00
Michael Meeks
16b0e217c1 tdf#93867 - clear current GL context before thread switch.
Fixes regression from otherwise a nice cleanup in:
    d20092259c

Also get polarity of debug logging only with a context right.

Change-Id: Id322471f01e5656e758aefc57b0d4d5ad073ec54
2015-09-02 22:46:48 +01:00
Michael Meeks
7164ec07ca Don't call GL debugging methods if there is no context.
Change-Id: Ie6b824953b8ad19fd1b6a146cb6bf52bbb152ef7
Reviewed-on: https://gerrit.libreoffice.org/18276
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2015-09-02 17:37:11 +00:00
Jan Holesovsky
3c046ac76f windows opengl: Avoid an unnecessary wglMakeCurrent() call.
Change-Id: I1c1287a29067c053565c49c0ce96918a2d27d87f
2015-09-02 11:37:17 +02:00
Jan Holesovsky
fec95ebb06 windows opengl: When the 2nd param is NULL, the 1st is ignored anyway.
Change-Id: I840e8bb2d2ccae869c330bb32dba484b4a835a51
2015-09-01 18:38:27 +02:00
Michael Meeks
6a12aecf6f tdf#93839 - Encourage vdevs to pick up new GL Contexts when they go invalid.
Change-Id: I21726d0dd052fdc87e8dd36ff7122518325f6313
2015-09-01 15:16:08 +01:00
Jan Holesovsky
aefb3d973c windows opengl: Call InitGLEWDebugging() after we have the context.
Change-Id: I1582443cf6799dd73a3909660d524eaacbc2d909
2015-09-01 14:50:19 +02:00
Miklos Vajna
dbf5882af3 Revert "windows opengl: Set PFD_DOUBLEBUFFER even for single buffer rendering"
This reverts commit 6fd7199230. Kendy says the
original problem can't be reproduced anymore, and most unexpected flickering
goes away with this for my nvidia card.

Also, it's a good idea in general to keep PFD_DOUBLEBUFFER and
WGL_DOUBLE_BUFFER_ARB in sync, which is now the case.

Change-Id: I7a809d1c85be4206c01720d5de9b0a5617a59c87
2015-09-01 09:40:15 +02:00
Michael Meeks
b27b9084c5 tdf#93772 - handle framebuffer unbinding on GL context switch.
Also start gl tests in vcldemo:
    $ SAL_FORCEGL=1 vcldemo --gltests

Change-Id: I8f0022770d57cd60c830659e3f7fcc0721320a10
Reviewed-on: https://gerrit.libreoffice.org/18132
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2015-08-31 19:48:14 +00:00
Michael Meeks
18dd07ba4f tdf#93751 - ensure textures are unbound from framebuffers post destroy.
Change-Id: I81aec0e6f8db57905826c54c3442528be6068700
2015-08-31 20:18:54 +01:00
Thorsten Behrens
751c5f5b75 Revert "werror: fix build in vcl"
This reverts commit 5191fcb116.
Earlier, better fix was 831c69f939
2015-08-31 15:49:17 +02:00
Thorsten Behrens
5191fcb116 werror: fix build in vcl
Change-Id: I30f9e1858c90943e1d369aeea02e10d8037a4ca8
2015-08-30 00:35:44 +02:00
Michael Meeks
d421ba3b66 Add missing helpful GL trace messages outside of the impl. itself.
Change-Id: I5b71e3c9edc3e1e89e52c2e17b5fe0a025ac66ea
2015-08-28 17:33:32 +01:00
Michael Meeks
b051c3716a tdf#93529 - add glDebugMessageInsert wrappers to help with API tracing.
Change-Id: Icf75e0e477be1b2bbbe5095aee33e681d212be0b
2015-08-28 11:31:38 +01:00
Michael Meeks
098f9189c6 tdf#93530 - glClear our depth, stencil and buffer contents on init.
Change-Id: I117fd5f5fd12fd6534b9d10532a39807ad82ce71
Reviewed-on: https://gerrit.libreoffice.org/18069
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
2015-08-28 00:18:59 +00:00
Michael Meeks
d20e7e3864 tdf#93547 - Disable OpenGL if we have a SEGV on windows in that code.
Annotate when we are in an OpenGL rendering zone.
Check for this in the VCL signal handler, and force OpenGL off here
if exception occurred inside an OpenGL code-path.

Change-Id: I85a4b3d4a374593dc55d01a39ec4c7c3c262c332
Reviewed-on: https://gerrit.libreoffice.org/17881
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2015-08-21 06:43:48 +00:00