Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / opencl / source / OpenCLZone.cxx
blobf7c8e961364d6bb5281bd87a3c28732fe686beea
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <opencl/openclwrapper.hxx>
11 #include <opencl/OpenCLZone.hxx>
12 #include <opencl_device.hxx>
14 #include <memory>
16 #include <officecfg/Office/Common.hxx>
17 #include <com/sun/star/util/XFlushable.hpp>
18 #include <com/sun/star/configuration/theDefaultProvider.hpp>
20 // FIXME: templatize me vs. OpenGLZone.
22 std::sig_atomic_t volatile OpenCLZone::gnEnterCount = 0;
23 bool volatile OpenCLZone::gbInInitialTest = false;
25 /**
26 * Called from a signal handler if we get
27 * a crash or hang in some CL code.
29 void OpenCLZone::hardDisable()
31 // protect ourselves from double calling etc.
32 static bool bDisabled = false;
33 if (!bDisabled)
35 bDisabled = true;
37 std::shared_ptr<comphelper::ConfigurationChanges> xChanges(comphelper::ConfigurationChanges::create());
38 officecfg::Office::Common::Misc::UseOpenCL::set(false, xChanges);
39 xChanges->commit();
41 // Force synchronous config write
42 auto xConfProvider = css::configuration::theDefaultProvider::get(comphelper::getProcessComponentContext());
43 css::uno::Reference<css::util::XFlushable> xFlushable(xConfProvider, css::uno::UNO_QUERY_THROW);
44 xFlushable->flush();
46 releaseOpenCLEnv(&openclwrapper::gpuEnv);
50 void OpenCLZone::enterInitialTest()
52 gbInInitialTest = true;
55 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */