Blender  V2.93
opensubdiv_capi.cc
Go to the documentation of this file.
1 // Copyright 2013 Blender Foundation. All rights reserved.
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software Foundation,
15 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 
17 #include "opensubdiv_capi.h"
18 
19 #ifdef _MSC_VER
20 # include <iso646.h>
21 #endif
22 
23 #include "internal/base/util.h"
29 
35 
36 void openSubdiv_init(void)
37 {
38  // Ensure all OpenGL strings are cached.
40 }
41 
43 {
44 }
45 
47 {
48  int flags = OPENSUBDIV_EVALUATOR_CPU;
49 
50  if (OpenMPDeviceContext::isSupported()) {
52  }
53 
54  if (OpenCLDeviceContext::isSupported()) {
56  }
57 
58  if (CUDADeviceContext::isSupported()) {
60  }
61 
62  if (GLSLTransformFeedbackDeviceContext::isSupported()) {
64  }
65 
66  if (GLSLComputeDeviceContext::isSupported()) {
68  }
69 
70  return flags;
71 }
72 
74 {
75 #if defined(OPENSUBDIV_VERSION_NUMBER)
76  return OPENSUBDIV_VERSION_NUMBER;
77 #elif defined(OPENSUBDIV_VERSION_MAJOR)
78  return OPENSUBDIV_VERSION_MAJOR * 10000 + OPENSUBDIV_VERSION_MINOR * 100 +
79  OPENSUBDIV_VERSION_PATCH;
80 #elif defined(OPENSUBDIV_VERSION)
81  const char *version = STRINGIFY(OPENSUBDIV_VERSION);
82  if (version[0] == 'v') {
83  version += 1;
84  }
85  int major = 0, minor = 0, patch = 0;
86  vector<string> tokens;
87  blender::opensubdiv::stringSplit(&tokens, version, "_", true);
88  if (tokens.size() == 3) {
89  major = atoi(tokens[0].c_str());
90  minor = atoi(tokens[1].c_str());
91  patch = atoi(tokens[2].c_str());
92  }
93  return major * 10000 + minor * 100 + patch;
94 #else
95  return 0;
96 #endif
97 }
#define STRINGIFY(x)
void stringSplit(vector< string > *tokens, const string &str, const string &separators, bool skip_empty)
Definition: util.cc:22
int openSubdiv_getVersionHex(void)
void openSubdiv_init(void)
void openSubdiv_cleanup(void)
int openSubdiv_getAvailableEvaluators(void)
@ OPENSUBDIV_EVALUATOR_CUDA
@ OPENSUBDIV_EVALUATOR_OPENMP
@ OPENSUBDIV_EVALUATOR_CPU
@ OPENSUBDIV_EVALUATOR_OPENCL
@ OPENSUBDIV_EVALUATOR_GLSL_COMPUTE
@ OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK