Blender V5.0
evaluator_capi.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2015 Blender Foundation
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 *
5 * Author: Sergey Sharybin. */
6
8
9#ifdef __APPLE__
10# include <opensubdiv/osd/mtlPatchShaderSource.h>
11#else
12# include <opensubdiv/osd/glslPatchShaderSource.h>
13#endif
14
15#include "MEM_guardedalloc.h"
16
18
20{
21 OpenSubdiv_EvaluatorCache *evaluator_cache = MEM_new<OpenSubdiv_EvaluatorCache>(__func__);
22 evaluator_cache->impl = openSubdiv_createEvaluatorCacheInternal(evaluator_type);
23 return evaluator_cache;
24}
25
27{
28 if (!evaluator_cache) {
29 return;
30 }
31
33 MEM_delete(evaluator_cache);
34}
35
37{
38 /* Using a global string to avoid dealing with memory allocation/ownership. */
39 static std::string patch_basis_source;
40 if (patch_basis_source.empty()) {
41#ifdef __APPLE__
42 patch_basis_source = OpenSubdiv::Osd::MTLPatchShaderSource::GetPatchBasisShaderSource();
43#else
44 patch_basis_source = OpenSubdiv::Osd::GLSLPatchShaderSource::GetPatchBasisShaderSource();
45#endif
46 }
47 return patch_basis_source.c_str();
48}
Read Guarded memory(de)allocation.
OpenSubdiv_EvaluatorCacheImpl * openSubdiv_createEvaluatorCacheInternal(eOpenSubdivEvaluator evaluator_type)
void openSubdiv_deleteEvaluatorCacheInternal(OpenSubdiv_EvaluatorCacheImpl *evaluator_cache)
void openSubdiv_deleteEvaluatorCache(OpenSubdiv_EvaluatorCache *evaluator_cache)
const char * openSubdiv_getGLSLPatchBasisSource()
OpenSubdiv_EvaluatorCache * openSubdiv_createEvaluatorCache(eOpenSubdivEvaluator evaluator_type)
eOpenSubdivEvaluator
OpenSubdiv_EvaluatorCacheImpl * impl