[Libreoffice-commits] core.git: Branch 'feature/fixes22' - desktop/source desktop/unx desktop/win32 include/desktop vcl/source
Tor Lillqvist
tml at collabora.com
Mon May 30 14:14:19 UTC 2016
desktop/source/app/app.cxx | 2
desktop/source/app/sofficemain.cxx | 2
desktop/source/inc/exithelper.h | 38 -------
desktop/unx/source/start.c | 2
desktop/win32/source/officeloader/officeloader.cxx | 2
include/desktop/exithelper.h | 38 +++++++
vcl/source/opengl/OpenGLContext.cxx | 105 +++++++++++++++++++++
vcl/source/opengl/OpenGLHelper.cxx | 9 -
8 files changed, 151 insertions(+), 47 deletions(-)
New commits:
commit 45683b62a696302da5fa9a6f26adad561125b338
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed May 25 15:23:22 2016 +0300
On Windows, compile OpenGL shaders in advance and disable on failure
This is a combination of multiple commits:
Don't claim to be reading a file before trying to open it
Avoid redundancy: The same information was logged in readProgramBinary()
Use VCL_GL_INFO here
Failing to open a cached shader binary is a no reason for a
SAL_WARN. It is normal that they don't exist when first trying, that
is the very nature of a 'cache'.
Move exithelper.h to include
We will want to use EXITHELPER_CRASH_WITH_RESTART in vcl, too.
If the shader compilation or loading of an already compiled shader
fails, disable OpenGL in the registry and exit with the
EXITHELPER_CRASH_WITH_RESTART status. The wrapper process will thus
run soffice.bin once more, and this time OpenGL will not be used.
Change-Id: I3cc4a615f00a8a1adb584493861e4956c83cec32
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 3927840..958ca8a 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -35,7 +35,6 @@
#include "lockfile.hxx"
#include "userinstall.hxx"
#include "desktopcontext.hxx"
-#include "exithelper.h"
#include "migration.hxx"
#include <svl/languageoptions.hxx>
@@ -78,6 +77,7 @@
#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
#include <com/sun/star/office/Quickstart.hpp>
+#include <desktop/exithelper.h>
#include <sal/log.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <comphelper/configuration.hxx>
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index c94d5f14..28296ee 100644
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -22,10 +22,10 @@
#include "desktopdllapi.h"
#include "app.hxx"
-#include "exithelper.h"
#include "cmdlineargs.hxx"
#include "cmdlinehelp.hxx"
+#include <desktop/exithelper.h>
#include <osl/file.hxx>
#include <rtl/bootstrap.hxx>
#include <sal/log.hxx>
diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index b072f0f..8583f5b 100644
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <errno.h>
+#include <desktop/exithelper.h>
#include <osl/process.h>
#include <osl/thread.h>
#include <rtl/bootstrap.h>
@@ -34,7 +35,6 @@
#include <sal/main.h>
#include "args.h"
-#include "../../source/inc/exithelper.h"
#include "pagein.h"
#include "splashx.h"
diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx
index e782c90..81be532 100644
--- a/desktop/win32/source/officeloader/officeloader.cxx
+++ b/desktop/win32/source/officeloader/officeloader.cxx
@@ -40,10 +40,10 @@
#include <stdlib.h>
#include <systools/win32/uwinapi.h>
+#include <desktop/exithelper.h>
#include <rtl/string.h>
#include <sal/macros.h>
-#include "../../../source/inc/exithelper.h"
#include "../loader.hxx"
#include <config_version.h>
diff --git a/desktop/source/inc/exithelper.h b/include/desktop/exithelper.h
similarity index 90%
rename from desktop/source/inc/exithelper.h
rename to include/desktop/exithelper.h
index f92f1a8..51175fa 100644
--- a/desktop/source/inc/exithelper.h
+++ b/include/desktop/exithelper.h
@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_DESKTOP_SOURCE_INC_EXITHELPER_H
-#define INCLUDED_DESKTOP_SOURCE_INC_EXITHELPER_H
+#ifndef INCLUDED_DESKTOP_EXITHELPER_H
+#define INCLUDED_DESKTOP_EXITHELPER_H
enum EExitCodes {
/* e.g. used to force showing of the command line help */
@@ -33,6 +33,6 @@ enum EExitCodes {
EXITHELPER_NORMAL_RESTART = 81
};
-#endif // INCLUDED_DESKTOP_SOURCE_INC_EXITHELPER_H
+#endif // INCLUDED_DESKTOP_EXITHELPER_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 03d0a5d..1e59d37 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -9,6 +9,7 @@
#include <config_opengl.h>
+#include <desktop/exithelper.h>
#include <vcl/opengl/OpenGLContext.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
#include <vcl/opengl/OpenGLWrapper.hxx>
@@ -713,6 +714,101 @@ bool GLWindow::HasGLXExtension( const char* name ) const
return checkExtension( reinterpret_cast<const GLubyte*>(name), reinterpret_cast<const GLubyte*>(GLXExtensions) );
}
+#ifdef WNT
+
+namespace
+{
+
+bool tryShaders(const OUString& rVertexShader, const OUString& rFragmentShader, const OUString& rGeometryShader = "")
+{
+ GLint nId;
+
+ // Somewhat mysteriously, the OpenGLHelper::LoadShaders() API saves a compiled binary of the
+ // shader only if you give it the digest of the shaders. We have API to calculate the digest
+ // only of the combination of vertex and fragment (but not geometry) shader. So if we have a
+ // geometry shader, we should not save the binary.
+ if (rGeometryShader.isEmpty())
+ nId = OpenGLHelper::LoadShaders(rVertexShader, rFragmentShader, rGeometryShader, "", OpenGLHelper::GetDigest( rVertexShader, rFragmentShader, ""));
+ else
+ nId = OpenGLHelper::LoadShaders(rVertexShader, rFragmentShader, rGeometryShader);
+ if (!nId)
+ return false;
+ glDeleteProgram(nId);
+ return glGetError() == GL_NO_ERROR;
+}
+
+bool compiledShaderBinariesWork()
+{
+ static bool bBeenHere = false;
+ static bool bResult;
+
+ if (bBeenHere)
+ return bResult;
+
+ bBeenHere = true;
+
+ bResult =
+ (
+#if 0 // Only look at shaders used by vcl for now
+ // canvas
+ tryShaders("dummyVertexShader", "linearMultiColorGradientFragmentShader") &&
+ tryShaders("dummyVertexShader", "linearTwoColorGradientFragmentShader") &&
+ tryShaders("dummyVertexShader", "radialMultiColorGradientFragmentShader") &&
+ tryShaders("dummyVertexShader", "radialTwoColorGradientFragmentShader") &&
+ tryShaders("dummyVertexShader", "rectangularMultiColorGradientFragmentShader") &&
+ tryShaders("dummyVertexShader", "rectangularTwoColorGradientFragmentShader") &&
+ // chart2
+ (GLEW_VERSION_3_3 ?
+ (tryShaders("shape3DVertexShader", "shape3DFragmentShader") &&
+ tryShaders("shape3DVertexShaderBatchScroll", "shape3DFragmentShaderBatchScroll") &&
+ tryShaders("shape3DVertexShaderBatch", "shape3DFragmentShaderBatch") &&
+ tryShaders("textVertexShaderBatch", "textFragmentShaderBatch")) :
+ (tryShaders("shape3DVertexShaderV300", "shape3DFragmentShaderV300"))) &&
+ tryShaders("textVertexShader", "textFragmentShader") &&
+ tryShaders("screenTextVertexShader", "screenTextFragmentShader") &&
+ tryShaders("commonVertexShader", "commonFragmentShader") &&
+ tryShaders("pickingVertexShader", "pickingFragmentShader") &&
+ tryShaders("backgroundVertexShader", "backgroundFragmentShader") &&
+ tryShaders("symbolVertexShader", "symbolFragmentShader") &&
+ tryShaders("symbolVertexShader", "symbolFragmentShader") &&
+ // slideshow
+ tryShaders("reflectionVertexShader", "reflectionFragmentShader") &&
+ tryShaders("basicVertexShader", "basicFragmentShader") &&
+ tryShaders("vortexVertexShader", "vortexFragmentShader", "vortexGeometryShader") &&
+ tryShaders("basicVertexShader", "rippleFragmentShader") &&
+ tryShaders("glitterVertexShader", "glitterFragmentShader") &&
+ tryShaders("honeycombVertexShader", "honeycombFragmentShader", "honeycombGeometryShader") &&
+#endif
+ // vcl
+ tryShaders("combinedVertexShader", "combinedFragmentShader") &&
+ tryShaders("dumbVertexShader", "invert50FragmentShader") &&
+ tryShaders("combinedTextureVertexShader", "combinedTextureFragmentShader") &&
+ tryShaders("textureVertexShader", "areaScaleFragmentShader") &&
+ tryShaders("transformedTextureVertexShader", "maskedTextureFragmentShader") &&
+ tryShaders("transformedTextureVertexShader", "areaScaleFastFragmentShader") &&
+ tryShaders("transformedTextureVertexShader", "areaScaleFragmentShader") &&
+ tryShaders("transformedTextureVertexShader", "textureFragmentShader") &&
+ tryShaders("combinedTextureVertexShader", "combinedTextureFragmentShader") &&
+ tryShaders("textureVertexShader", "linearGradientFragmentShader") &&
+ tryShaders("textureVertexShader", "radialGradientFragmentShader") &&
+ tryShaders("textureVertexShader", "textureFragmentShader") &&
+ tryShaders("textureVertexShader", "convolutionFragmentShader") &&
+ tryShaders("textureVertexShader", "areaScaleFastFragmentShader") &&
+ tryShaders("textureVertexShader", "areaScaleFragmentShader"));
+
+ if (!bResult)
+ {
+ OpenGLZone::hardDisable();
+ TerminateProcess(GetCurrentProcess(), EXITHELPER_CRASH_WITH_RESTART);
+ }
+
+ return bResult;
+}
+
+} // unnamed namespace
+
+#endif // WNT
+
bool OpenGLContext::ImplInit()
{
if (!m_aGLWin.dpy)
@@ -964,6 +1060,15 @@ bool OpenGLContext::ImplInit()
return false;
}
+#ifdef WNT
+ if (!compiledShaderBinariesWork())
+ {
+ wglMakeCurrent(NULL, NULL);
+ wglDeleteContext(hTempRC);
+ return false;
+ }
+#endif
+
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hTempRC);
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 8418706..5892a62 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -66,7 +66,6 @@ OString loadShader(const OUString& rFilename)
{
OUString aFileURL = getShaderFolder() + rFilename +".glsl";
osl::File aFile(aFileURL);
- SAL_INFO("vcl.opengl", "Reading " << aFileURL);
if(aFile.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None)
{
sal_uInt64 nSize = 0;
@@ -76,11 +75,12 @@ OString loadShader(const OUString& rFilename)
aFile.read(content.get(), nSize, nBytesRead);
assert(nSize == nBytesRead);
content.get()[nBytesRead] = 0;
+ SAL_INFO("vcl.opengl", "Read " << nBytesRead << " bytes from " << aFileURL);
return OString(content.get());
}
else
{
- SAL_WARN("vcl.opengl", "could not load the file: " << aFileURL);
+ SAL_WARN("vcl.opengl", "Could not open " << aFileURL);
}
return OString();
@@ -289,12 +289,12 @@ namespace
sal_uInt64 nBytesRead = 0;
aFile.read( rBinary.data(), nSize, nBytesRead );
assert( nSize == nBytesRead );
- SAL_INFO("vcl.opengl", "Loading file: '" << rBinaryFileName << "': success" );
+ VCL_GL_INFO("Loading file: '" << rBinaryFileName << "': success" );
return true;
}
else
{
- SAL_WARN("vcl.opengl", "Loading file: '" << rBinaryFileName << "': FAIL");
+ VCL_GL_INFO("Loading file: '" << rBinaryFileName << "': FAIL");
}
return false;
@@ -405,7 +405,6 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,
OString aFileName =
createFileName(rVertexShaderName, rFragmentShaderName, rGeometryShaderName, rDigest);
bBinaryResult = loadProgramBinary(ProgramID, aFileName);
- VCL_GL_INFO("Load binary shader from '" << aFileName << "'" << bBinaryResult);
CHECK_GL_ERROR();
}
More information about the Libreoffice-commits
mailing list