Bump version to 6.0-14
[LibreOffice.git] / opencl / source / OpenCLZone.cxx
blobe4e3ff08fff4bdb64fc0320869cb9947c681e766
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 sal_uInt64 volatile OpenCLZone::gnEnterCount = 0;
23 sal_uInt64 volatile OpenCLZone::gnLeaveCount = 0;
24 bool volatile OpenCLZone::gbInInitialTest = false;
26 /**
27 * Called from a signal handler if we get
28 * a crash or hang in some CL code.
30 void OpenCLZone::hardDisable()
32 // protect ourselves from double calling etc.
33 static bool bDisabled = false;
34 if (!bDisabled)
36 bDisabled = true;
38 std::shared_ptr<comphelper::ConfigurationChanges> xChanges(comphelper::ConfigurationChanges::create());
39 officecfg::Office::Common::Misc::UseOpenCL::set(false, xChanges);
40 xChanges->commit();
42 // Force synchronous config write
43 auto xConfProvider = css::configuration::theDefaultProvider::get(comphelper::getProcessComponentContext());
44 css::uno::Reference<css::util::XFlushable> xFlushable(xConfProvider, css::uno::UNO_QUERY_THROW);
45 xFlushable->flush();
47 releaseOpenCLEnv(&openclwrapper::gpuEnv);
51 void OpenCLZone::enterInitialTest()
53 gbInInitialTest = true;
56 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */