Blender V5.3
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 WITH_METAL_BACKEND
10# include <opensubdiv/osd/mtlPatchShaderSource.h>
11#endif
12#if defined(WITH_VULKAN_BACKEND) || defined(WITH_OPENGL_BACKEND)
13# include <opensubdiv/osd/glslPatchShaderSource.h>
14#endif
15
16#include "MEM_guardedalloc.h"
17
18#include "GPU_context.hh"
19
21
23{
24 OpenSubdiv_EvaluatorCache *evaluator_cache = MEM_new<OpenSubdiv_EvaluatorCache>(__func__);
25 evaluator_cache->impl = openSubdiv_createEvaluatorCacheInternal(evaluator_type);
26 return evaluator_cache;
27}
28
30{
31 if (!evaluator_cache) {
32 return;
33 }
34
36 MEM_delete(evaluator_cache);
37}
38
40{
41 /* Using a global string to avoid dealing with memory allocation/ownership. */
42 static std::string patch_basis_source;
43 if (patch_basis_source.empty()) {
44 patch_basis_source =
45 "#define OsdPatchParam_host_shared_ OsdPatchParam\n"
46 "#define OsdPatchArray_host_shared_ OsdPatchArray\n"
47 "#define OsdPatchCoord_host_shared_ OsdPatchCoord\n";
48
49#ifdef WITH_METAL_BACKEND
50 patch_basis_source += OpenSubdiv::Osd::MTLPatchShaderSource::GetPatchBasisShaderSource();
51#endif
52#if defined(WITH_OPENGL_BACKEND) || defined(WITH_VULKAN_BACKEND)
53 patch_basis_source += OpenSubdiv::Osd::GLSLPatchShaderSource::GetPatchBasisShaderSource();
54#endif
55 }
56 return patch_basis_source.c_str();
57}
Read Blender memory allocation and freeing.
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