1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <opencl/openclwrapper.hxx>
11 #include <opencl/OpenCLZone.hxx>
12 #include <opencl_device.hxx>
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;
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;
37 std::shared_ptr
<comphelper::ConfigurationChanges
> xChanges(comphelper::ConfigurationChanges::create());
38 officecfg::Office::Common::Misc::UseOpenCL::set(false, xChanges
);
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
);
46 releaseOpenCLEnv(&openclwrapper::gpuEnv
);
50 void OpenCLZone::enterInitialTest()
52 gbInInitialTest
= true;
55 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */