Files
test2/intern/opensubdiv/opensubdiv_evaluator_capi.hh
Hans Goudey 509090e7c3 Subdiv: Remove evaluator C-API wrapper
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
2024-11-01 09:42:33 +01:00

66 lines
2.2 KiB
C++

/* SPDX-FileCopyrightText: 2013 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include <cstdint> // for uint64_t
#include "opensubdiv_capi_type.hh"
struct OpenSubdiv_EvaluatorCacheImpl;
struct OpenSubdiv_PatchCoord;
namespace blender::opensubdiv {
class TopologyRefinerImpl;
}
struct OpenSubdiv_EvaluatorSettings {
// Number of smoothly interpolated vertex data channels.
int num_vertex_data;
};
// Callback type for doing input/output operations on buffers.
// Useful to abstract GPU buffers.
struct OpenSubdiv_Buffer {
// Bind the buffer to the GPU.
void (*bind_gpu)(const OpenSubdiv_Buffer *buffer);
// Allocate the buffer directly on the host for the given size in bytes. This has to return
// a pointer to the newly allocated memory.
void *(*alloc)(const OpenSubdiv_Buffer *buffer, const unsigned int size);
// Allocate the buffer directly on the device for the given size in bytes.
void (*device_alloc)(const OpenSubdiv_Buffer *buffer, const unsigned int size);
// Update the given range of the buffer with new data.
void (*device_update)(const OpenSubdiv_Buffer *buffer,
unsigned int start,
unsigned int len,
const void *data);
// Wrap an existing GPU buffer, given its device handle, into the client's buffer type for
// read-only use.
void (*wrap_device_handle)(const OpenSubdiv_Buffer *buffer, uint64_t device_ptr);
// Offset in the buffer where the data starts, if a single buffer is used for multiple data
// channels.
int buffer_offset;
// Pointer to the client buffer data, which is modified or initialized through the various
// callbacks.
void *data;
};
struct OpenSubdiv_EvaluatorCache {
// Implementation of the evaluator cache.
OpenSubdiv_EvaluatorCacheImpl *impl;
};
OpenSubdiv_EvaluatorCache *openSubdiv_createEvaluatorCache(eOpenSubdivEvaluator evaluator_type);
void openSubdiv_deleteEvaluatorCache(OpenSubdiv_EvaluatorCache *evaluator_cache);
// Return the GLSL source code from the OpenSubDiv library used for patch evaluation.
// This function is not thread-safe.
const char *openSubdiv_getGLSLPatchBasisSource();