path: root/vcl/source/opengl
AgeCommit message (Collapse)AuthorFilesLines
2015-10-19Speed up in-process caching of OpenGL shader programsTor Lillqvist1-7/+15
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-18Success is no reason to be scaredTor Lillqvist1-3/+3
Change-Id: If7ad24bf1f7442e86d424188bd78f332b1a351ff
2015-10-11Moggi thinks this mutex is unnecessary and I trust himTor Lillqvist1-3/+0
"Is the mutex really necessary? Normally outside of the chart OpenGL only the thread that has taken the SolarMutex should access the OpenGL code. In general we have bigger problems if several threads start rendering in parallel." Change-Id: I5f8fa8c771d5e2e0df4cfe903b15d00e5cc162b1
2015-10-09clang-analyzer-deadcode.DeadStoresStephan Bergmann1-1/+0
Change-Id: I8a6ea395192d31391868f44152ab3b543a07aeaa
2015-10-08Don't re-read the same glsl files over and over againTor Lillqvist1-4/+20
Change-Id: I10b4badaba01630e1a054b3d4d9cc4720822511a
2015-09-30vcl: clean up before error returns in OpenGLContext::ImplInit()Michael Stahl1-0/+10
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-16Add debugging helpers to binary shader loading.Michael Meeks1-5/+4
Change-Id: I32b8d8ce0fbf824120c8afd288b728314cd74142 Reviewed-on: Tested-by: Jenkins <> Reviewed-by: Michael Meeks <>
2015-09-16GL paint-flushing guard re-work.Michael Meeks1-1/+45
Unfortunately, since we can have 2x SalGraphics' on a OutputDevice, and one of these can be a printer - things got very confused around which context to glFlush. This de-tangles the various reference-counts. Change-Id: I1062be0b02a91fc9009deaa3ec29c5dbb227df20 Reviewed-on: Reviewed-by: Michael Meeks <> Tested-by: Michael Meeks <>
2015-09-16tdf#94213 - release offscreen texture properly on re-size.Michael Meeks1-0/+3
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: Tested-by: Jenkins <> Reviewed-by: Michael Meeks <>
2015-09-15loplugin:cstylecastStephan Bergmann1-3/+3
Change-Id: Ib87c2d84bc954e768a9a5165f528936aafa94887
2015-09-15WaE: loplugin:cstylecastTor Lillqvist1-4/+4
Change-Id: I08c31a7e097464da5df4fcda6637f442d147230f
2015-09-15tdf#93814: Added support for caching shader program binaries.Marco Cecchetti2-29/+272
Change-Id: I21c844b47282f6b3eec443933a86421a074e24df Reviewed-on: Tested-by: Jenkins <> Reviewed-by: Tomaž Vajngerl <>
2015-09-13boost->stdCaolán McNamara1-4/+3
Change-Id: I9b4f884c6313a53fea543ea6f93175205351ad14 Reviewed-on: Tested-by: Jenkins <> Reviewed-by: Caolán McNamara <> Tested-by: Caolán McNamara <>
2015-09-11coverity#1323754 we apparently can survive std::abort for a whileCaolán McNamara1-0/+1
so try and suppress this warning Change-Id: I096352af0116f1ba0911cc201eb884267095a797
2015-09-11windows opengl: make sure mpLastContext is indeed the current contextMiklos Vajna1-2/+11
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: Reviewed-by: Michael Meeks <> Tested-by: Michael Meeks <>
2015-09-10coverity#1323759 Uninitialized pointer fieldCaolán McNamara1-2/+3
Change-Id: I9fca8838beb1c2f6db8a9f1c9b6fe77f247b847c
2015-09-10windows opengl: mpCurrentProgram seen as 0Miklos Vajna1-0/+7
in JunitTest_sc_unoapi_3. Change-Id: Ibe12a31c1158f782bd7df115171b07e1843d025c
2015-09-08tdf#94006 - need an explicit dispose for GLContext's SystemChildWindow.Michael Meeks1-0/+9
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: Tested-by: Jenkins <> Reviewed-by: Markus Mohrhard <>
2015-09-08tdf#94006 - fix OpenGLContext mis-use in several places.Michael Meeks1-4/+7
gltf rendering, OpenGL canvas, GL transitions & GL capable (charts) Avoid GLX operations on un-initialized contexts. Change-Id: I7f523640f66ab656896181e5c865879234f6640e
2015-09-08tdf#94006 - re-factor to use rtl::Reference for OpenGLContexts.Michael Meeks1-37/+11
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-07don't use a null displayMarkus Mohrhard1-8/+14
Change-Id: Iab0a53abd723f0309f40742636315079a4b2c532
2015-09-07avoid some OpenGL calls when vcl OpenGL is not enabledMarkus Mohrhard1-1/+1
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-07prevent crash with non-vcl OpenGL contextsMarkus Mohrhard1-1/+2
Change-Id: Ia829b0f723c8ded1237e52d48f034da3c1ac249e
2015-09-04Avoid a SAL_INFO about OpenGL when not using OpenGLTor Lillqvist1-2/+7
Change-Id: Ia066c240776cecc855b59ab0ccc84e7fdcbf4b79
2015-09-03tdf#93870 - GL accel. via VCL canvas for presentations when GL enabled.Michael Meeks1-0/+6
Change-Id: Ia31a88cb3d9e6baa987b22f77f407a3f592031f1 Reviewed-on: Tested-by: Jenkins <> Reviewed-by: Michael Meeks <> Tested-by: Michael Meeks <> Reviewed-by: Jan Holesovsky <>
2015-09-02tdf#93867 - clear current GL context before thread switch.Michael Meeks2-1/+15
Fixes regression from otherwise a nice cleanup in: d20092259c7ea63885a539f911788715f8147ee9 Also get polarity of debug logging only with a context right. Change-Id: Id322471f01e5656e758aefc57b0d4d5ad073ec54
2015-09-02Don't call GL debugging methods if there is no context.Michael Meeks2-15/+34
Change-Id: Ie6b824953b8ad19fd1b6a146cb6bf52bbb152ef7 Reviewed-on: Tested-by: Jenkins <> Reviewed-by: Michael Meeks <>
2015-09-02Add SAL_DISABLE_GL_WATCHDOG env. var for obvious reasons.Michael Meeks1-1/+2
Change-Id: Iec7cb6504a389972d8187954d5ed7aff94f2e01c
2015-09-02tdf#93850 - Defer watchdog during shader compiles.Michael Meeks1-16/+54
Shader compilation can take a while the first time; best not to disable GL at that point. Have more of a hair trigger at other times. Also explicitly exit if we appear to have hung in std::abort handling. Change-Id: I45f0873672f950fb3baba0ca859d854a0bb25064
2015-09-02windows opengl: Avoid an unnecessary wglMakeCurrent() call.Jan Holesovsky1-2/+2
Change-Id: I1c1287a29067c053565c49c0ce96918a2d27d87f
2015-09-01windows opengl: When the 2nd param is NULL, the 1st is ignored anyway.Jan Holesovsky1-2/+2
Change-Id: I840e8bb2d2ccae869c330bb32dba484b4a835a51
2015-09-01tdf#93839 - Encourage vdevs to pick up new GL Contexts when they go invalid.Michael Meeks1-0/+3
Change-Id: I21726d0dd052fdc87e8dd36ff7122518325f6313
2015-09-01windows opengl: Call InitGLEWDebugging() after we have the context.Jan Holesovsky1-1/+2
Change-Id: I1582443cf6799dd73a3909660d524eaacbc2d909
2015-09-01Revert "windows opengl: Set PFD_DOUBLEBUFFER even for single buffer rendering"Miklos Vajna1-3/+2
This reverts commit 6fd7199230bfc81d6aadf53b3c115def8caba90c. 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-08-31tdf#93822 - disable horror legacy menu background saving for OpenGL.Michael Meeks1-0/+5
Change-Id: Icaa5fb197f3fa234da4538a2a7b21131cab89277
2015-08-31tdf#93772 - handle framebuffer unbinding on GL context switch.Michael Meeks1-0/+5
Also start gl tests in vcldemo: $ SAL_FORCEGL=1 vcldemo --gltests Change-Id: I8f0022770d57cd60c830659e3f7fcc0721320a10 Reviewed-on: Reviewed-by: Michael Meeks <> Tested-by: Michael Meeks <>
2015-08-31tdf#93751 - ensure textures are unbound from framebuffers post destroy.Michael Meeks1-0/+20
Change-Id: I81aec0e6f8db57905826c54c3442528be6068700
2015-08-31Extended GL painting debug tracing.Michael Meeks1-0/+1
Change-Id: I52158729d240ca3cb9e7977bc6d1f5acb14437ad
2015-08-31Revert "werror: fix build in vcl"Thorsten Behrens1-5/+0
This reverts commit 5191fcb11688ef8f4ec312293e57e151762c6952. Earlier, better fix was 831c69f9397ed813364235dddf465996d361d0a8
2015-08-31tdf#93798 - avoid apitrace provoked infinite loop dumping errors.Michael Meeks1-0/+8
Change-Id: I6c42e6a9ead90ed6fad2f289cd686a72cffa0c2d
2015-08-30werror: fix build in vclThorsten Behrens1-0/+5
Change-Id: I30f9e1858c90943e1d369aeea02e10d8037a4ca8
2015-08-28Add missing helpful GL trace messages outside of the impl. itself.Michael Meeks1-12/+12
Change-Id: I5b71e3c9edc3e1e89e52c2e17b5fe0a025ac66ea
2015-08-28tdf#93529 - add glDebugMessageInsert wrappers to help with API tracing.Michael Meeks2-0/+40
Change-Id: Icf75e0e477be1b2bbbe5095aee33e681d212be0b
2015-08-28Revert "tdf#93530 - the VCL GDI flushing abstraction should glFlush too."Michael Meeks1-9/+0
This reverts commit e16e64dd862c8f386f80de43ad68e831e169d49d. I somehow forgot that glFlush is context specific, (gl always gets me that way).
2015-08-28tdf#93530 - glClear our depth, stencil and buffer contents on init.Michael Meeks1-0/+5
Change-Id: I117fd5f5fd12fd6534b9d10532a39807ad82ce71 Reviewed-on: Reviewed-by: Markus Mohrhard <> Tested-by: Markus Mohrhard <>
2015-08-27Fully drain glGetErrorStephan Bergmann1-4/+6
...according to <>: "To allow for distributed implementations, there may be several error flags. If any single error flag has recorded an error, the value of that flag is returned and that flag is reset to GL_NO_ERROR when glGetError is called. If more than one flag has recorded an error, glGetError returns and clears an arbitrary error flag value. Thus, glGetError should always be called in a loop, until it returns GL_NO_ERROR, if all error flags are to be reset." (The original code was flagged by clang-tidy's clang-analyzer-deadcode.DeadStores.) Change-Id: Ia64e2133b6a4581230b999d4b8b63aa59199ee32
2015-08-26tdf#93530 - the VCL GDI flushing abstraction should glFlush too.Michael Meeks1-0/+9
Change-Id: I45cb0e62278d8c3154ae8ad54ca4c93b3e177969 Reviewed-on: Reviewed-by: Michael Meeks <> Tested-by: Michael Meeks <>
2015-08-25tdf#93614 - detect hanging OpenGL drivers with a watchdog.Michael Meeks1-15/+112
If an OpenGL zone takes >2s to make progress, disable OpenGL. If an OpenGL zone takes >5s to make progress, abort the app. Change-Id: I776c06a3f8ba460ff9842a9130c21f9ee2147eee Reviewed-on: Tested-by: Jenkins <> Reviewed-by: Michael Meeks <> Tested-by: Michael Meeks <>
2015-08-21tdf#93547 - Disable OpenGL if we have a SEGV on windows in that code.Michael Meeks2-0/+102
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: Reviewed-by: Michael Meeks <> Tested-by: Michael Meeks <>
2015-08-14vcl opengl: fix setting up debug context on WindowsMiklos Vajna1-7/+22
At least with my AMD card, in case of SAL_FORCEGL=1 the startup crashes quite early. DrMemory says: ~~Dr.M~~ Error #1: UNADDRESSABLE ACCESS: writing 0x00001414-0x00001415 1 byte(s) ~~Dr.M~~ # 0 atioglxx.dll!DrvPresentBuffers +0xd6ea6 (0x09a248f6 <atioglxx.dll+0x1248f6>) ~~Dr.M~~ # 1 atioglxx.dll!DrvPresentBuffers +0x3c069c (0x09d0e0ed <atioglxx.dll+0x40e0ed>) ~~Dr.M~~ # 2 vcllo.dll!OpenGLContext::InitGLEW [c:\lo\master\vcl\source\opengl\openglcontext.cxx:949] ~~Dr.M~~ # 3 vcllo.dll!OpenGLContext::ImplInit [c:\lo\master\vcl\source\opengl\openglcontext.cxx:866] ~~Dr.M~~ # 4 vcllo.dll!OpenGLContext::init [c:\lo\master\vcl\source\opengl\openglcontext.cxx:786] ~~Dr.M~~ # 5 vcllo.dll!WinOpenGLSalGraphicsImpl::CreateWinContext [c:\lo\master\vcl\opengl\win\gdiimpl.cxx:36] Turns out that in order to enable the GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB extension, the GL context must be created with WGL_CONTEXT_DEBUG_BIT_ARB set. It seems that other drivers did not enforce this so far, but in this case the driver just crashes without this. Fix the problem by splitting out the debug setup part of InitGLEW() into a new InitGLEWDebugging(), and at least on Windows call it only after wglCreateContextAttribsARB() and wglMakeCurrent(). Additionally make sure that in the debug case the necessary flag is passed to wglCreateContextAttribsARB(). Change-Id: I6b77e0c06fd85fdae0386a0801f1de1838524586 Reviewed-on: Reviewed-by: Miklos Vajna <> Tested-by: Miklos Vajna <>