Similar to 5e46e3d28a.
This commit replaces the C-API version of `OpenSubdiv_Evaluator`
with direct calls to `EvalOutputAPI`. This removes a level of indirection,
theoretically reducing function call overhead, but also making the whole
system easier to understand and easier to modify. The downside is
further spread of `WITH_OPENSUBDIV` into the code, but I think that
can be improved in the future relatively easily once more of this sort
of change is finished.
Pull Request: https://projects.blender.org/blender/blender/pulls/128278
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
/* SPDX-FileCopyrightText: 2015 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*
|
|
* Author: Sergey Sharybin. */
|
|
|
|
#include "opensubdiv_evaluator_capi.hh"
|
|
|
|
#include <opensubdiv/osd/glslPatchShaderSource.h>
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
#include "internal/evaluator/evaluator_cache_impl.h"
|
|
|
|
OpenSubdiv_EvaluatorCache *openSubdiv_createEvaluatorCache(eOpenSubdivEvaluator evaluator_type)
|
|
{
|
|
OpenSubdiv_EvaluatorCache *evaluator_cache = MEM_new<OpenSubdiv_EvaluatorCache>(__func__);
|
|
evaluator_cache->impl = openSubdiv_createEvaluatorCacheInternal(evaluator_type);
|
|
return evaluator_cache;
|
|
}
|
|
|
|
void openSubdiv_deleteEvaluatorCache(OpenSubdiv_EvaluatorCache *evaluator_cache)
|
|
{
|
|
if (!evaluator_cache) {
|
|
return;
|
|
}
|
|
|
|
openSubdiv_deleteEvaluatorCacheInternal(evaluator_cache->impl);
|
|
MEM_delete(evaluator_cache);
|
|
}
|
|
|
|
const char *openSubdiv_getGLSLPatchBasisSource(void)
|
|
{
|
|
/* Using a global string to avoid dealing with memory allocation/ownership. */
|
|
static std::string patch_basis_source;
|
|
if (patch_basis_source.empty()) {
|
|
patch_basis_source = OpenSubdiv::Osd::GLSLPatchShaderSource::GetPatchBasisShaderSource();
|
|
}
|
|
return patch_basis_source.c_str();
|
|
}
|