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>
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
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
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
Will be useful in cases where there is some external library code that uses
shaders outside of our OpenGLContext.
Change-Id: I59c57e3225f55d13e69b6a9b7c0db1a7487c586d
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
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
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
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
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
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>
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>
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>
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
There are even more and it is causing a number of performance issues.
This just fixes the most obvious place.
Change-Id: Id85c13b5b7f4bb0bc077e62c39258067e17c0094
Fixes regression from otherwise a nice cleanup in:
d20092259c
Also get polarity of debug logging only with a context right.
Change-Id: Id322471f01e5656e758aefc57b0d4d5ad073ec54
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
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>