2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * The Original Code is Copyright (C) 2013 Blender Foundation.
17 * All rights reserved.
20 #include "opensubdiv_capi.h"
29 #ifdef OPENSUBDIV_HAS_OPENCL
30 # include "opensubdiv_device_context_opencl.h"
31 #endif /* OPENSUBDIV_HAS_OPENCL */
33 #ifdef OPENSUBDIV_HAS_CUDA
34 # include "opensubdiv_device_context_cuda.h"
35 #endif /* OPENSUBDIV_HAS_CUDA */
37 static bool gpu_legacy_support_global = false;
39 int openSubdiv_getAvailableEvaluators(void)
41 if (!openSubdiv_supportGPUDisplay()) {
45 int flags = OPENSUBDIV_EVALUATOR_CPU;
47 #ifdef OPENSUBDIV_HAS_OPENMP
48 flags |= OPENSUBDIV_EVALUATOR_OPENMP;
49 #endif /* OPENSUBDIV_HAS_OPENMP */
51 #ifdef OPENSUBDIV_HAS_OPENCL
52 if (CLDeviceContext::HAS_CL_VERSION_1_1()) {
53 flags |= OPENSUBDIV_EVALUATOR_OPENCL;
55 #endif /* OPENSUBDIV_HAS_OPENCL */
57 #ifdef OPENSUBDIV_HAS_CUDA
58 if (CudaDeviceContext::HAS_CUDA_VERSION_4_0()) {
59 flags |= OPENSUBDIV_EVALUATOR_CUDA;
61 #endif /* OPENSUBDIV_HAS_OPENCL */
63 #ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
64 if (GLEW_VERSION_4_1) {
65 flags |= OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK;
67 #endif /* OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK */
69 #ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
70 if (GLEW_VERSION_4_3 || GLEW_ARB_compute_shader) {
71 flags |= OPENSUBDIV_EVALUATOR_GLSL_COMPUTE;
73 #endif /* OPENSUBDIV_HAS_GLSL_COMPUTE */
78 void openSubdiv_init(bool gpu_legacy_support)
80 /* Ensure all OpenGL strings are cached. */
81 (void)openSubdiv_getAvailableEvaluators();
82 gpu_legacy_support_global = gpu_legacy_support;
85 void openSubdiv_cleanup(void)
87 openSubdiv_osdGLDisplayDeinit();
90 bool openSubdiv_gpu_legacy_support(void)
92 return gpu_legacy_support_global;