Cleanup: Move opensubdiv C-API headers to C++

All the relevant code is C++ now, so we don't need to complicate things
with the trip through C anymore. We will still need some wrappers, since
opensubdiv is an optional dependency though. The goal is to make it
simpler to remove the unnecessary/costly abstraction levels between
Blender mesh data and the opensubdiv code.
This commit is contained in:
Hans Goudey
2023-12-10 20:18:40 -05:00
parent 01eade9a02
commit 8157f33911
35 changed files with 191 additions and 263 deletions
+5 -5
View File
@@ -10,11 +10,11 @@ set(INC_SYS
)
set(SRC
opensubdiv_capi.h
opensubdiv_capi_type.h
opensubdiv_converter_capi.h
opensubdiv_evaluator_capi.h
opensubdiv_topology_refiner_capi.h
opensubdiv_capi.hh
opensubdiv_capi_type.hh
opensubdiv_converter_capi.hh
opensubdiv_evaluator_capi.hh
opensubdiv_topology_refiner_capi.hh
)
set(LIB
@@ -2,7 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "opensubdiv_capi.h"
#include "opensubdiv_capi.hh"
#include "opensubdiv/version.h"
#ifdef _MSC_VER
# include <iso646.h>
@@ -14,7 +14,7 @@
#include <opensubdiv/sdc/options.h>
#include <opensubdiv/sdc/types.h>
#include "opensubdiv_capi_type.h"
#include "opensubdiv_capi_type.hh"
struct OpenSubdiv_Converter;
@@ -15,7 +15,7 @@
#include "internal/base/type.h"
#include "internal/evaluator/evaluator_impl.h"
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_evaluator_capi.hh"
using OpenSubdiv::Far::PatchTable;
using OpenSubdiv::Far::StencilTable;
@@ -6,7 +6,7 @@
#include "internal/evaluator/eval_output_gpu.h"
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_evaluator_capi.hh"
using OpenSubdiv::Osd::PatchArray;
using OpenSubdiv::Osd::PatchArrayVector;
@@ -7,7 +7,7 @@
#include "internal/base/memory.h"
#include "opensubdiv_capi_type.h"
#include "opensubdiv_capi_type.hh"
struct OpenSubdiv_EvaluatorCacheImpl {
public:
@@ -4,7 +4,7 @@
*
* Author: Sergey Sharybin. */
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_evaluator_capi.hh"
#include <opensubdiv/osd/glslPatchShaderSource.h>
@@ -28,8 +28,8 @@
#include "internal/evaluator/evaluator_cache_impl.h"
#include "internal/evaluator/patch_map.h"
#include "internal/topology/topology_refiner_impl.h"
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_evaluator_capi.hh"
#include "opensubdiv_topology_refiner_capi.hh"
using OpenSubdiv::Far::PatchTable;
using OpenSubdiv::Far::PatchTableFactory;
@@ -16,7 +16,7 @@
#include "internal/base/memory.h"
#include "opensubdiv_capi_type.h"
#include "opensubdiv_capi_type.hh"
struct OpenSubdiv_Buffer;
struct OpenSubdiv_EvaluatorCacheImpl;
@@ -12,7 +12,7 @@
#include "internal/base/type.h"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_converter_capi.hh"
namespace blender {
namespace opensubdiv {
@@ -4,7 +4,7 @@
*
* Author: Sergey Sharybin. */
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_topology_refiner_capi.hh"
#include "MEM_guardedalloc.h"
#include "internal/base/type_convert.h"
@@ -19,7 +19,7 @@
#include "internal/base/type_convert.h"
#include "internal/topology/mesh_topology.h"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_converter_capi.hh"
using blender::opensubdiv::min;
using blender::opensubdiv::stack;
@@ -15,7 +15,7 @@
#include "internal/base/memory.h"
#include "internal/topology/mesh_topology.h"
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_topology_refiner_capi.hh"
struct OpenSubdiv_Converter;
@@ -11,7 +11,7 @@
#include "internal/topology/mesh_topology.h"
#include "internal/topology/topology_refiner_impl.h"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_converter_capi.hh"
namespace blender {
namespace opensubdiv {
-28
View File
@@ -1,28 +0,0 @@
/* SPDX-FileCopyrightText: 2013 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Author: Sergey Sharybin. */
#ifndef OPENSUBDIV_CAPI_H_
#define OPENSUBDIV_CAPI_H_
#include "opensubdiv_capi_type.h"
#ifdef __cplusplus
extern "C" {
#endif
// Global initialization/deinitialization.
//
// Supposed to be called from main thread.
void openSubdiv_init(void);
void openSubdiv_cleanup(void);
int openSubdiv_getVersionHex(void);
#ifdef __cplusplus
}
#endif
#endif // OPENSUBDIV_CAPI_H_
+15
View File
@@ -0,0 +1,15 @@
/* SPDX-FileCopyrightText: 2013 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "opensubdiv_capi_type.hh"
// Global initialization/deinitialization.
//
// Supposed to be called from main thread.
void openSubdiv_init();
void openSubdiv_cleanup();
int openSubdiv_getVersionHex();
@@ -1,54 +1,41 @@
/* SPDX-FileCopyrightText: 2013 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Author: Sergey Sharybin. */
* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef OPENSUBDIV_CAPI_TYPES_H_
#define OPENSUBDIV_CAPI_TYPES_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
typedef enum eOpenSubdivEvaluator {
enum eOpenSubdivEvaluator {
OPENSUBDIV_EVALUATOR_CPU = 0,
OPENSUBDIV_EVALUATOR_GPU = 1,
} eOpenSubdivEvaluator;
};
typedef enum OpenSubdiv_SchemeType {
enum OpenSubdiv_SchemeType {
OSD_SCHEME_BILINEAR,
OSD_SCHEME_CATMARK,
OSD_SCHEME_LOOP,
} OpenSubdiv_SchemeType;
};
typedef enum OpenSubdiv_VtxBoundaryInterpolation {
enum OpenSubdiv_VtxBoundaryInterpolation {
// Do not interpolate boundaries
OSD_VTX_BOUNDARY_NONE,
// Sharpen edges.
OSD_VTX_BOUNDARY_EDGE_ONLY,
// sharpen edges and corners,
OSD_VTX_BOUNDARY_EDGE_AND_CORNER,
} OpenSubdiv_VtxBoundaryInterpolation;
};
typedef enum OpenSubdiv_FVarLinearInterpolation {
enum OpenSubdiv_FVarLinearInterpolation {
OSD_FVAR_LINEAR_INTERPOLATION_NONE,
OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY,
OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1,
OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2,
OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES,
OSD_FVAR_LINEAR_INTERPOLATION_ALL,
} OpenSubdiv_FVarLinearInterpolation;
};
typedef struct OpenSubdiv_PatchCoord {
struct OpenSubdiv_PatchCoord {
int ptex_face;
// Parametric location on patch.
float u, v;
} OpenSubdiv_PatchCoord;
#ifdef __cplusplus
}
#endif
#endif // OPENSUBDIV_CAPI_TYPES_H_
};
@@ -1,27 +1,20 @@
/* SPDX-FileCopyrightText: 2015 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Author: Sergey Sharybin. */
* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef OPENSUBDIV_CONVERTER_CAPI_H_
#define OPENSUBDIV_CONVERTER_CAPI_H_
#pragma once
#include <stdint.h> // for bool
#include <cstdint> // for bool
#include "opensubdiv_capi_type.h"
#include "opensubdiv_capi_type.hh"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenSubdiv_Converter {
OpenSubdiv_SchemeType (*getSchemeType)(const struct OpenSubdiv_Converter *converter);
struct OpenSubdiv_Converter {
OpenSubdiv_SchemeType (*getSchemeType)(const OpenSubdiv_Converter *converter);
OpenSubdiv_VtxBoundaryInterpolation (*getVtxBoundaryInterpolation)(
const struct OpenSubdiv_Converter *converter);
const OpenSubdiv_Converter *converter);
OpenSubdiv_FVarLinearInterpolation (*getFVarLinearInterpolation)(
const struct OpenSubdiv_Converter *converter);
const OpenSubdiv_Converter *converter);
// Denotes whether this converter specifies full topology, which includes
// vertices, edges, faces, vertices+edges of a face and edges/faces of a
@@ -32,29 +25,29 @@ typedef struct OpenSubdiv_Converter {
// NOTE: Even if converter does not provide full topology, it still needs
// to provide number of edges and vertices-of-edge. Those are used to assign
// topology tags.
bool (*specifiesFullTopology)(const struct OpenSubdiv_Converter *converter);
bool (*specifiesFullTopology)(const OpenSubdiv_Converter *converter);
//////////////////////////////////////////////////////////////////////////////
// Global geometry counters.
// Number of faces/edges/vertices in the base mesh.
int (*getNumFaces)(const struct OpenSubdiv_Converter *converter);
int (*getNumEdges)(const struct OpenSubdiv_Converter *converter);
int (*getNumVertices)(const struct OpenSubdiv_Converter *converter);
int (*getNumFaces)(const OpenSubdiv_Converter *converter);
int (*getNumEdges)(const OpenSubdiv_Converter *converter);
int (*getNumVertices)(const OpenSubdiv_Converter *converter);
//////////////////////////////////////////////////////////////////////////////
// Face relationships.
// Number of vertices the face consists of.
int (*getNumFaceVertices)(const struct OpenSubdiv_Converter *converter, const int face_index);
int (*getNumFaceVertices)(const OpenSubdiv_Converter *converter, const int face_index);
// Array of vertex indices the face consists of.
void (*getFaceVertices)(const struct OpenSubdiv_Converter *converter,
void (*getFaceVertices)(const OpenSubdiv_Converter *converter,
const int face_index,
int *face_vertices);
// Array of edge indices the face consists of.
// Aligned with the vertex indices array, edge i connects face vertex i
// with face index i+1.
void (*getFaceEdges)(const struct OpenSubdiv_Converter *converter,
void (*getFaceEdges)(const OpenSubdiv_Converter *converter,
const int face_index,
int *face_edges);
@@ -62,42 +55,38 @@ typedef struct OpenSubdiv_Converter {
// Edge relationships.
// Vertices the edge consists of.
void (*getEdgeVertices)(const struct OpenSubdiv_Converter *converter,
void (*getEdgeVertices)(const OpenSubdiv_Converter *converter,
const int edge_index,
int edge_vertices[2]);
// Number of faces which are sharing the given edge.
int (*getNumEdgeFaces)(const struct OpenSubdiv_Converter *converter, const int edge_index);
int (*getNumEdgeFaces)(const OpenSubdiv_Converter *converter, const int edge_index);
// Array of face indices which are sharing the given edge.
void (*getEdgeFaces)(const struct OpenSubdiv_Converter *converter,
const int edge,
int *edge_faces);
void (*getEdgeFaces)(const OpenSubdiv_Converter *converter, const int edge, int *edge_faces);
// Edge sharpness (aka crease).
float (*getEdgeSharpness)(const struct OpenSubdiv_Converter *converter, const int edge_index);
float (*getEdgeSharpness)(const OpenSubdiv_Converter *converter, const int edge_index);
//////////////////////////////////////////////////////////////////////////////
// Vertex relationships.
// Number of edges which are adjacent to the given vertex.
int (*getNumVertexEdges)(const struct OpenSubdiv_Converter *converter, const int vertex_index);
int (*getNumVertexEdges)(const OpenSubdiv_Converter *converter, const int vertex_index);
// Array fo edge indices which are adjacent to the given vertex.
void (*getVertexEdges)(const struct OpenSubdiv_Converter *converter,
void (*getVertexEdges)(const OpenSubdiv_Converter *converter,
const int vertex_index,
int *vertex_edges);
// Number of faces which are adjacent to the given vertex.
int (*getNumVertexFaces)(const struct OpenSubdiv_Converter *converter, const int vertex_index);
int (*getNumVertexFaces)(const OpenSubdiv_Converter *converter, const int vertex_index);
// Array fo face indices which are adjacent to the given vertex.
void (*getVertexFaces)(const struct OpenSubdiv_Converter *converter,
void (*getVertexFaces)(const OpenSubdiv_Converter *converter,
const int vertex_index,
int *vertex_faces);
// Check whether vertex is to be marked as an infinite sharp.
// This is a way to make sharp vertices which are adjacent to a loose edges.
bool (*isInfiniteSharpVertex)(const struct OpenSubdiv_Converter *converter,
const int vertex_index);
bool (*isInfiniteSharpVertex)(const OpenSubdiv_Converter *converter, const int vertex_index);
// If vertex is not infinitely sharp, this is its actual sharpness.
float (*getVertexSharpness)(const struct OpenSubdiv_Converter *converter,
const int vertex_index);
float (*getVertexSharpness)(const OpenSubdiv_Converter *converter, const int vertex_index);
//////////////////////////////////////////////////////////////////////////////
// Face-varying data.
@@ -106,7 +95,7 @@ typedef struct OpenSubdiv_Converter {
// UV coordinates.
// Number of UV layers.
int (*getNumUVLayers)(const struct OpenSubdiv_Converter *converter);
int (*getNumUVLayers)(const OpenSubdiv_Converter *converter);
// We need some corner connectivity information, which might not be trivial
// to be gathered (might require multiple matching calculations per corver
@@ -116,27 +105,21 @@ typedef struct OpenSubdiv_Converter {
// complex complex-to-calculate information.
// finish() is called after converter is done porting UV layer to OpenSubdiv,
// allowing to free cached data.
void (*precalcUVLayer)(const struct OpenSubdiv_Converter *converter, const int layer_index);
void (*finishUVLayer)(const struct OpenSubdiv_Converter *converter);
void (*precalcUVLayer)(const OpenSubdiv_Converter *converter, const int layer_index);
void (*finishUVLayer)(const OpenSubdiv_Converter *converter);
// Get number of UV coordinates in the current layer (layer which was
// specified in precalcUVLayer().
int (*getNumUVCoordinates)(const struct OpenSubdiv_Converter *converter);
int (*getNumUVCoordinates)(const OpenSubdiv_Converter *converter);
// For the given face index and its corner (known as loop in Blender)
// get corresponding UV coordinate index.
int (*getFaceCornerUVIndex)(const struct OpenSubdiv_Converter *converter,
int (*getFaceCornerUVIndex)(const OpenSubdiv_Converter *converter,
const int face_index,
const int corner_index);
//////////////////////////////////////////////////////////////////////////////
// User data associated with this converter.
void (*freeUserData)(const struct OpenSubdiv_Converter *converter);
void (*freeUserData)(const OpenSubdiv_Converter *converter);
void *user_data;
} OpenSubdiv_Converter;
#ifdef __cplusplus
}
#endif
#endif /* OPENSUBDIV_CONVERTER_CAPI_H_ */
};
@@ -1,51 +1,46 @@
/* SPDX-FileCopyrightText: 2013 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Author: Sergey Sharybin. */
* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef OPENSUBDIV_EVALUATOR_CAPI_H_
#define OPENSUBDIV_EVALUATOR_CAPI_H_
#pragma once
#include <stdint.h> // for uint64_t
#include <cstdint> // for uint64_t
#include "opensubdiv_capi_type.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "opensubdiv_capi_type.hh"
struct OpenSubdiv_EvaluatorCacheImpl;
struct OpenSubdiv_EvaluatorImpl;
struct OpenSubdiv_EvaluatorInternal;
struct OpenSubdiv_PatchCoord;
struct OpenSubdiv_TopologyRefiner;
typedef struct OpenSubdiv_EvaluatorSettings {
struct OpenSubdiv_EvaluatorSettings {
// Number of smoothly interpolated vertex data channels.
int num_vertex_data;
} OpenSubdiv_EvaluatorSettings;
};
// Callback type for doing input/output operations on buffers.
// Useful to abstract GPU buffers.
typedef struct OpenSubdiv_Buffer {
struct OpenSubdiv_Buffer {
// Bind the buffer to the GPU.
void (*bind_gpu)(const struct OpenSubdiv_Buffer *buffer);
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 struct OpenSubdiv_Buffer *buffer, const unsigned int size);
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 struct OpenSubdiv_Buffer *buffer, const unsigned int size);
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 struct OpenSubdiv_Buffer *buffer,
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 struct OpenSubdiv_Buffer *buffer, uint64_t device_ptr);
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.
@@ -54,25 +49,25 @@ typedef struct OpenSubdiv_Buffer {
// Pointer to the client buffer data, which is modified or initialized through the various
// callbacks.
void *data;
} OpenSubdiv_Buffer;
};
typedef struct OpenSubdiv_Evaluator {
struct OpenSubdiv_Evaluator {
// Set settings for data buffers used.
void (*setSettings)(struct OpenSubdiv_Evaluator *evaluator,
void (*setSettings)(OpenSubdiv_Evaluator *evaluator,
const OpenSubdiv_EvaluatorSettings *settings);
// Set coarse positions from a continuous array of coordinates.
void (*setCoarsePositions)(struct OpenSubdiv_Evaluator *evaluator,
void (*setCoarsePositions)(OpenSubdiv_Evaluator *evaluator,
const float *positions,
const int start_vertex_index,
const int num_vertices);
// Set vertex data from a continuous array of coordinates.
void (*setVertexData)(struct OpenSubdiv_Evaluator *evaluator,
void (*setVertexData)(OpenSubdiv_Evaluator *evaluator,
const float *data,
const int start_vertex_index,
const int num_vertices);
// Set varying data from a continuous array of data.
void (*setVaryingData)(struct OpenSubdiv_Evaluator *evaluator,
void (*setVaryingData)(OpenSubdiv_Evaluator *evaluator,
const float *varying_data,
const int start_vertex_index,
const int num_vertices);
@@ -80,7 +75,7 @@ typedef struct OpenSubdiv_Evaluator {
//
// TODO(sergey): Find a better name for vertex here. It is not the vertex of
// geometry, but a vertex of UV map.
void (*setFaceVaryingData)(struct OpenSubdiv_Evaluator *evaluator,
void (*setFaceVaryingData)(OpenSubdiv_Evaluator *evaluator,
const int face_varying_channel,
const float *face_varying_data,
const int start_vertex_index,
@@ -89,7 +84,7 @@ typedef struct OpenSubdiv_Evaluator {
// Set coarse vertex position from a continuous memory buffer where
// first coordinate starts at offset of `start_offset` and there is `stride`
// bytes between adjacent vertex coordinates.
void (*setCoarsePositionsFromBuffer)(struct OpenSubdiv_Evaluator *evaluator,
void (*setCoarsePositionsFromBuffer)(OpenSubdiv_Evaluator *evaluator,
const void *buffer,
const int start_offset,
const int stride,
@@ -98,7 +93,7 @@ typedef struct OpenSubdiv_Evaluator {
// Set varying data from a continuous memory buffer where
// first coordinate starts at offset of `start_offset` and there is `stride`
// bytes between adjacent vertex coordinates.
void (*setVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator *evaluator,
void (*setVaryingDataFromBuffer)(OpenSubdiv_Evaluator *evaluator,
const void *buffer,
const int start_offset,
const int stride,
@@ -110,7 +105,7 @@ typedef struct OpenSubdiv_Evaluator {
//
// TODO(sergey): Find a better name for vertex here. It is not the vertex of
// geometry, but a vertex of UV map.
void (*setFaceVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator *evaluator,
void (*setFaceVaryingDataFromBuffer)(OpenSubdiv_Evaluator *evaluator,
const int face_varying_channel,
const void *buffer,
const int start_offset,
@@ -119,11 +114,11 @@ typedef struct OpenSubdiv_Evaluator {
const int num_vertices);
// Refine after coarse positions update.
void (*refine)(struct OpenSubdiv_Evaluator *evaluator);
void (*refine)(OpenSubdiv_Evaluator *evaluator);
// Evaluate given ptex face at given bilinear coordinate.
// If derivatives are NULL, they will not be evaluated.
void (*evaluateLimit)(struct OpenSubdiv_Evaluator *evaluator,
void (*evaluateLimit)(OpenSubdiv_Evaluator *evaluator,
const int ptex_face_index,
float face_u,
float face_v,
@@ -132,14 +127,14 @@ typedef struct OpenSubdiv_Evaluator {
float dPdv[3]);
// Evaluate vertex data at a given bilinear coordinate of given ptex face.
void (*evaluateVertexData)(struct OpenSubdiv_Evaluator *evaluator,
void (*evaluateVertexData)(OpenSubdiv_Evaluator *evaluator,
const int ptex_face_index,
float face_u,
float face_v,
float data[]);
// Evaluate varying data at a given bilinear coordinate of given ptex face.
void (*evaluateVarying)(struct OpenSubdiv_Evaluator *evaluator,
void (*evaluateVarying)(OpenSubdiv_Evaluator *evaluator,
const int ptex_face_index,
float face_u,
float face_v,
@@ -147,7 +142,7 @@ typedef struct OpenSubdiv_Evaluator {
// Evaluate face-varying data at a given bilinear coordinate of given
// ptex face.
void (*evaluateFaceVarying)(struct OpenSubdiv_Evaluator *evaluator,
void (*evaluateFaceVarying)(OpenSubdiv_Evaluator *evaluator,
const int face_varying_channel,
const int ptex_face_index,
float face_u,
@@ -160,79 +155,77 @@ typedef struct OpenSubdiv_Evaluator {
// If derivatives are NULL, they will not be evaluated.
//
// NOTE: Output arrays must point to a memory of size float[3]*num_patch_coords.
void (*evaluatePatchesLimit)(struct OpenSubdiv_Evaluator *evaluator,
const struct OpenSubdiv_PatchCoord *patch_coords,
void (*evaluatePatchesLimit)(OpenSubdiv_Evaluator *evaluator,
const OpenSubdiv_PatchCoord *patch_coords,
const int num_patch_coords,
float *P,
float *dPdu,
float *dPdv);
// Copy the patch map to the given buffers, and output some topology information.
void (*getPatchMap)(struct OpenSubdiv_Evaluator *evaluator,
struct OpenSubdiv_Buffer *patch_map_handles,
struct OpenSubdiv_Buffer *patch_map_quadtree,
void (*getPatchMap)(OpenSubdiv_Evaluator *evaluator,
OpenSubdiv_Buffer *patch_map_handles,
OpenSubdiv_Buffer *patch_map_quadtree,
int *min_patch_face,
int *max_patch_face,
int *max_depth,
int *patches_are_triangular);
// Fill the given buffer with data from the evaluator's patch array buffer.
void (*fillPatchArraysBuffer)(struct OpenSubdiv_Evaluator *evaluator,
struct OpenSubdiv_Buffer *patch_array_buffer);
void (*fillPatchArraysBuffer)(OpenSubdiv_Evaluator *evaluator,
OpenSubdiv_Buffer *patch_array_buffer);
// Fill the given buffer with data from the evaluator's patch index buffer.
void (*wrapPatchIndexBuffer)(struct OpenSubdiv_Evaluator *evaluator,
struct OpenSubdiv_Buffer *patch_index_buffer);
void (*wrapPatchIndexBuffer)(OpenSubdiv_Evaluator *evaluator,
OpenSubdiv_Buffer *patch_index_buffer);
// Fill the given buffer with data from the evaluator's patch parameter buffer.
void (*wrapPatchParamBuffer)(struct OpenSubdiv_Evaluator *evaluator,
struct OpenSubdiv_Buffer *patch_param_buffer);
void (*wrapPatchParamBuffer)(OpenSubdiv_Evaluator *evaluator,
OpenSubdiv_Buffer *patch_param_buffer);
// Fill the given buffer with data from the evaluator's source buffer.
void (*wrapSrcBuffer)(struct OpenSubdiv_Evaluator *evaluator,
struct OpenSubdiv_Buffer *src_buffer);
void (*wrapSrcBuffer)(OpenSubdiv_Evaluator *evaluator, OpenSubdiv_Buffer *src_buffer);
// Fill the given buffer with data from the evaluator's extra source buffer.
void (*wrapSrcVertexDataBuffer)(struct OpenSubdiv_Evaluator *evaluator,
struct OpenSubdiv_Buffer *src_buffer);
void (*wrapSrcVertexDataBuffer)(OpenSubdiv_Evaluator *evaluator, OpenSubdiv_Buffer *src_buffer);
// Fill the given buffer with data from the evaluator's face varying patch array buffer.
void (*fillFVarPatchArraysBuffer)(struct OpenSubdiv_Evaluator *evaluator,
void (*fillFVarPatchArraysBuffer)(OpenSubdiv_Evaluator *evaluator,
const int face_varying_channel,
struct OpenSubdiv_Buffer *patch_array_buffer);
OpenSubdiv_Buffer *patch_array_buffer);
// Fill the given buffer with data from the evaluator's face varying patch index buffer.
void (*wrapFVarPatchIndexBuffer)(struct OpenSubdiv_Evaluator *evaluator,
void (*wrapFVarPatchIndexBuffer)(OpenSubdiv_Evaluator *evaluator,
const int face_varying_channel,
struct OpenSubdiv_Buffer *patch_index_buffer);
OpenSubdiv_Buffer *patch_index_buffer);
// Fill the given buffer with data from the evaluator's face varying patch parameter buffer.
void (*wrapFVarPatchParamBuffer)(struct OpenSubdiv_Evaluator *evaluator,
void (*wrapFVarPatchParamBuffer)(OpenSubdiv_Evaluator *evaluator,
const int face_varying_channel,
struct OpenSubdiv_Buffer *patch_param_buffer);
OpenSubdiv_Buffer *patch_param_buffer);
// Fill the given buffer with data from the evaluator's face varying source buffer.
void (*wrapFVarSrcBuffer)(struct OpenSubdiv_Evaluator *evaluator,
void (*wrapFVarSrcBuffer)(OpenSubdiv_Evaluator *evaluator,
const int face_varying_channel,
struct OpenSubdiv_Buffer *src_buffer);
OpenSubdiv_Buffer *src_buffer);
// Return true if the evaluator has source vertex data set.
bool (*hasVertexData)(struct OpenSubdiv_Evaluator *evaluator);
bool (*hasVertexData)(OpenSubdiv_Evaluator *evaluator);
// Implementation of the evaluator.
struct OpenSubdiv_EvaluatorImpl *impl;
OpenSubdiv_EvaluatorImpl *impl;
// Type of the evaluator.
eOpenSubdivEvaluator type;
} OpenSubdiv_Evaluator;
};
typedef struct OpenSubdiv_EvaluatorCache {
struct OpenSubdiv_EvaluatorCache {
// Implementation of the evaluator cache.
struct OpenSubdiv_EvaluatorCacheImpl *impl;
} OpenSubdiv_EvaluatorCache;
OpenSubdiv_EvaluatorCacheImpl *impl;
};
OpenSubdiv_Evaluator *openSubdiv_createEvaluatorFromTopologyRefiner(
struct OpenSubdiv_TopologyRefiner *topology_refiner,
OpenSubdiv_TopologyRefiner *topology_refiner,
eOpenSubdivEvaluator evaluator_type,
OpenSubdiv_EvaluatorCache *evaluator_cache);
@@ -245,9 +238,3 @@ 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(void);
#ifdef __cplusplus
}
#endif
#endif // OPENSUBDIV_EVALUATOR_CAPI_H_
@@ -1,19 +1,12 @@
/* SPDX-FileCopyrightText: 2018 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Author: Sergey Sharybin. */
* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
#define OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
#pragma once
#include <stdint.h> // for bool
#include <cstdint> // for bool
#include "opensubdiv_capi_type.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "opensubdiv_capi_type.hh"
struct OpenSubdiv_Converter;
struct OpenSubdiv_TopologyRefinerImpl;
@@ -23,19 +16,19 @@ struct OpenSubdiv_TopologyRefinerImpl;
// make it possible to ensure we are not trying to abuse same OpenSubdiv's
// topology refiner with different subdivision levels or with different
// adaptive settings.
typedef struct OpenSubdiv_TopologyRefinerSettings {
struct OpenSubdiv_TopologyRefinerSettings {
bool is_adaptive;
int level;
} OpenSubdiv_TopologyRefinerSettings;
};
// C-style wrapper around actual topology refiner.
//
// The only purpose is to allow C-only code to access C++ implementation of the
// topology refiner.
typedef struct OpenSubdiv_TopologyRefiner {
struct OpenSubdiv_TopologyRefiner {
// Query subdivision level the refiner is created for.
int (*getSubdivisionLevel)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
bool (*getIsAdaptive)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
int (*getSubdivisionLevel)(const OpenSubdiv_TopologyRefiner *topology_refiner);
bool (*getIsAdaptive)(const OpenSubdiv_TopologyRefiner *topology_refiner);
// NOTE: All queries are querying base level.
//
@@ -47,28 +40,27 @@ typedef struct OpenSubdiv_TopologyRefiner {
//////////////////////////////////////////////////////////////////////////////
// Query basic topology information from base level.
int (*getNumVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
int (*getNumEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
int (*getNumFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
int (*getNumVertices)(const OpenSubdiv_TopologyRefiner *topology_refiner);
int (*getNumEdges)(const OpenSubdiv_TopologyRefiner *topology_refiner);
int (*getNumFaces)(const OpenSubdiv_TopologyRefiner *topology_refiner);
int (*getNumFaceVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
int (*getNumFaceVertices)(const OpenSubdiv_TopologyRefiner *topology_refiner,
const int face_index);
void (*getFaceVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
void (*getFaceVertices)(const OpenSubdiv_TopologyRefiner *topology_refiner,
const int face_index,
int *face_vertices_indices);
int (*getNumFaceEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
const int face_index);
void (*getFaceEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
int (*getNumFaceEdges)(const OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index);
void (*getFaceEdges)(const OpenSubdiv_TopologyRefiner *topology_refiner,
const int face_index,
int *face_edges_indices);
void (*getEdgeVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
void (*getEdgeVertices)(const OpenSubdiv_TopologyRefiner *topology_refiner,
const int edge_index,
int edge_vertices_indices[2]);
int (*getNumVertexEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
int (*getNumVertexEdges)(const OpenSubdiv_TopologyRefiner *topology_refiner,
const int vertex_index);
void (*getVertexEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
void (*getVertexEdges)(const OpenSubdiv_TopologyRefiner *topology_refiner,
const int vertex_index,
int *vertex_edges_indices);
@@ -82,9 +74,9 @@ typedef struct OpenSubdiv_TopologyRefiner {
// - Quad face consists of a single ptex face.
// - N-gons (similar to triangle) consists of N ptex faces, ordered same
// way as for triangle.
int (*getNumFacePtexFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
int (*getNumFacePtexFaces)(const OpenSubdiv_TopologyRefiner *topology_refiner,
const int face_index);
int (*getNumPtexFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
int (*getNumPtexFaces)(const OpenSubdiv_TopologyRefiner *topology_refiner);
// Initialize a per-base-face offset measured in ptex face indices.
//
@@ -92,25 +84,24 @@ typedef struct OpenSubdiv_TopologyRefiner {
// faces created for bases faces [0 .. base_face_index - 1].
//
// The array must contain at least total number of ptex faces elements.
void (*fillFacePtexIndexOffset)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
void (*fillFacePtexIndexOffset)(const OpenSubdiv_TopologyRefiner *topology_refiner,
int *face_ptex_index_offset);
//////////////////////////////////////////////////////////////////////////////
// Face-varying data.
// Number of face-varying channels (or how they are called in Blender layers).
int (*getNumFVarChannels)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
int (*getNumFVarChannels)(const OpenSubdiv_TopologyRefiner *topology_refiner);
// Get face-varying interpolation type.
OpenSubdiv_FVarLinearInterpolation (*getFVarLinearInterpolation)(
const struct OpenSubdiv_TopologyRefiner *topology_refiner);
const OpenSubdiv_TopologyRefiner *topology_refiner);
// Get total number of face-varying values in a particular channel.
int (*getNumFVarValues)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
const int channel);
int (*getNumFVarValues)(const OpenSubdiv_TopologyRefiner *topology_refiner, const int channel);
// Get face-varying value indices associated with a particular face.
//
// This is an array of indices inside of face-varying array, array elements
// are aligned with face corners (or loops in Blender terminology).
const int *(*getFaceFVarValueIndices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
const int *(*getFaceFVarValueIndices)(const OpenSubdiv_TopologyRefiner *topology_refiner,
const int face_index,
const int channel);
@@ -118,13 +109,13 @@ typedef struct OpenSubdiv_TopologyRefiner {
// Internal use.
// Implementation of the topology refiner.
struct OpenSubdiv_TopologyRefinerImpl *impl;
} OpenSubdiv_TopologyRefiner;
OpenSubdiv_TopologyRefinerImpl *impl;
};
// NOTE: Will return NULL in cases of bad topology.
// NOTE: Mesh without faces is considered a bad topology.
OpenSubdiv_TopologyRefiner *openSubdiv_createTopologyRefinerFromConverter(
struct OpenSubdiv_Converter *converter, const OpenSubdiv_TopologyRefinerSettings *settings);
OpenSubdiv_Converter *converter, const OpenSubdiv_TopologyRefinerSettings *settings);
void openSubdiv_deleteTopologyRefiner(OpenSubdiv_TopologyRefiner *topology_refiner);
@@ -135,11 +126,4 @@ void openSubdiv_deleteTopologyRefiner(OpenSubdiv_TopologyRefiner *topology_refin
// and compare with existing refiner before going into more computationally
// complicated parts of subdivision process.
bool openSubdiv_topologyRefinerCompareWithConverter(
const OpenSubdiv_TopologyRefiner *topology_refiner,
const struct OpenSubdiv_Converter *converter);
#ifdef __cplusplus
}
#endif
#endif // OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
const OpenSubdiv_TopologyRefiner *topology_refiner, const OpenSubdiv_Converter *converter);
@@ -4,7 +4,7 @@
*
* Author: Sergey Sharybin. */
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_evaluator_capi.hh"
#include <cstddef>
+1 -1
View File
@@ -4,7 +4,7 @@
*
* Author: Sergey Sharybin. */
#include "opensubdiv_capi.h"
#include "opensubdiv_capi.hh"
#include <cstddef>
@@ -4,7 +4,7 @@
*
* Author: Sergey Sharybin. */
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_topology_refiner_capi.hh"
#include <cstddef>
@@ -27,9 +27,9 @@
#include "BKE_subdiv_foreach.hh"
#include "BKE_subdiv_mesh.hh"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_converter_capi.hh"
#include "opensubdiv_evaluator_capi.hh"
#include "opensubdiv_topology_refiner_capi.hh"
#include "atomic_ops.h"
#include "subdiv_converter.hh"
@@ -16,7 +16,7 @@
#include "BKE_subdiv_eval.hh"
#include "multires_reshape.hh"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_converter_capi.hh"
#include "subdiv_converter.hh"
static float simple_to_catmull_clark_get_edge_sharpness(const OpenSubdiv_Converter * /*converter*/,
+4 -4
View File
@@ -21,10 +21,10 @@
#include "subdiv_converter.hh"
#include "opensubdiv_capi.h"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_capi.hh"
#include "opensubdiv_converter_capi.hh"
#include "opensubdiv_evaluator_capi.hh"
#include "opensubdiv_topology_refiner_capi.hh"
/* --------------------------------------------------------------------
* Module.
@@ -27,7 +27,7 @@
#include "BKE_subdiv.hh"
#include "BKE_subdiv_eval.hh"
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_topology_refiner_capi.hh"
using blender::Array;
using blender::float3;
@@ -10,7 +10,7 @@
#include "BLI_utildefines.h"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_converter_capi.hh"
void BKE_subdiv_converter_free(OpenSubdiv_Converter *converter)
{
@@ -12,7 +12,7 @@
/* NOTE: Was initially used to get proper enumerator types, but this makes
* it tricky to compile without OpenSubdiv. */
/* #include "opensubdiv_converter_capi.h" */
/* #include "opensubdiv_converter_capi.hh" */
struct Mesh;
struct OpenSubdiv_Converter;
@@ -22,8 +22,8 @@
#include "MEM_guardedalloc.h"
#include "opensubdiv_capi.h"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_capi.hh"
#include "opensubdiv_converter_capi.hh"
#include "bmesh_class.hh"
@@ -22,8 +22,8 @@
#include "MEM_guardedalloc.h"
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_evaluator_capi.hh"
#include "opensubdiv_topology_refiner_capi.hh"
/* --------------------------------------------------------------------
* Helper functions.
@@ -20,7 +20,7 @@
#include "GPU_capabilities.h"
#include "GPU_context.h"
#include "opensubdiv_capi.h"
#include "opensubdiv_capi.hh"
SubdivSettings BKE_subsurf_modifier_settings_init(const SubsurfModifierData *smd,
const bool use_render_params)
@@ -10,7 +10,7 @@
#include "BKE_subdiv.hh"
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_topology_refiner_capi.hh"
int BKE_subdiv_topology_num_fvar_layers_get(const Subdiv *subdiv)
{
@@ -37,11 +37,11 @@
#include "GPU_state.h"
#include "GPU_vertex_buffer.h"
#include "opensubdiv_capi.h"
#include "opensubdiv_capi_type.h"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_topology_refiner_capi.h"
#include "opensubdiv_capi.hh"
#include "opensubdiv_capi_type.hh"
#include "opensubdiv_converter_capi.hh"
#include "opensubdiv_evaluator_capi.hh"
#include "opensubdiv_topology_refiner_capi.hh"
#include "draw_cache_extract.hh"
#include "draw_cache_impl.hh"
@@ -14,7 +14,7 @@
#include "../generic/py_capi_utils.h"
#ifdef WITH_OPENSUBDIV
# include "opensubdiv_capi.h"
# include "opensubdiv_capi.hh"
#endif
static PyTypeObject BlenderAppOpenSubdivType;