-
-
Notifications
You must be signed in to change notification settings - Fork 146
/
Copy pathinit.cpp
83 lines (68 loc) · 2.79 KB
/
init.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/***************************************************************************
* Copyright 1998-2020 by authors (see AUTHORS.txt) *
* *
* This file is part of LuxCoreRender. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
#include <iostream>
#include <boost/filesystem.hpp>
#include "luxrays/luxrays.h"
#if !defined(LUXRAYS_DISABLE_OPENCL)
#include "luxrays/utils/ocl.h"
#endif
#if !defined(LUXRAYS_DISABLE_CUDA)
#include "luxrays/utils/cuda.h"
#endif
using namespace std;
using namespace luxrays;
//------------------------------------------------------------------------------
// Init()
//------------------------------------------------------------------------------
namespace luxrays {
bool isOpenCLAvilable = false;
bool isCudaAvilable = false;
bool isOptixAvilable = false;
std::locale cLocale("C");
void Init() {
#if defined(WIN32)
// Set locale for conversion from UTF-16 to UTF-8 on Windows. LuxRays/LuxCore assume
// all file names are UTF-8 encoded. This works fine on Linux/MacOS but
// requires a conversion to UTF-16 on Windows.
boost::filesystem::path::imbue(
std::locale(std::locale(), new std::codecvt_utf8_utf16<wchar_t>()));
#endif
#if !defined(LUXRAYS_DISABLE_OPENCL)
if (clewInit() == CLEW_SUCCESS) {
isOpenCLAvilable = true;
}
#endif
#if !defined(LUXRAYS_DISABLE_CUDA)
if (cuewInit(CUEW_INIT_CUDA|CUEW_INIT_NVRTC) == CUEW_SUCCESS) {
// Was:
//CHECK_CUDA_ERROR(cuInit(0));
const CUresult err = cuInit(0);
if (err == CUDA_ERROR_NO_DEVICE) {
// This handles the case when CUDA is installed but there are no
// NVIDIA GPUs installed.
} else {
CHECK_CUDA_ERROR(err);
isCudaAvilable = true;
// Try to initialize Optix too
if (optixInit() == OPTIX_SUCCESS)
isOptixAvilable = true;
}
}
#endif
}
}