Blender  V3.3
opensubdiv_evaluator_capi.h
Go to the documentation of this file.
1 // Copyright 2013 Blender Foundation. All rights reserved.
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software Foundation,
15 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 //
17 // Author: Sergey Sharybin
18 
19 #ifndef OPENSUBDIV_EVALUATOR_CAPI_H_
20 #define OPENSUBDIV_EVALUATOR_CAPI_H_
21 
22 #include <stdint.h> // for uint64_t
23 
24 #include "opensubdiv_capi_type.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 struct OpenSubdiv_EvaluatorInternal;
33 
35  // Number of smoothly interpolated vertex data channels.
38 
39 // Callback type for doing input/output operations on buffers.
40 // Useful to abstract GPU buffers.
41 typedef struct OpenSubdiv_Buffer {
42  // Bind the buffer to the GPU.
44 
45  // Allocate the buffer directly on the host for the given size in bytes. This has to return
46  // a pointer to the newly allocated memory.
47  void *(*alloc)(const struct OpenSubdiv_Buffer *buffer, const unsigned int size);
48 
49  // Allocate the buffer directly on the device for the given size in bytes.
50  void (*device_alloc)(const struct OpenSubdiv_Buffer *buffer, const unsigned int size);
51 
52  // Update the given range of the buffer with new data.
54  unsigned int start,
55  unsigned int len,
56  const void *data);
57 
58  // Wrap an existing GPU buffer, given its device handle, into the client's buffer type for
59  // read-only use.
61 
62  // Offset in the buffer where the data starts, if a single buffer is used for multiple data
63  // channels.
65 
66  // Pointer to the client buffer data, which is modified or initialized through the various
67  // callbacks.
68  void *data;
70 
71 typedef struct OpenSubdiv_Evaluator {
72  // Set settings for data buffers used.
73  void (*setSettings)(struct OpenSubdiv_Evaluator *evaluator,
74  const OpenSubdiv_EvaluatorSettings *settings);
75 
76  // Set coarse positions from a continuous array of coordinates.
78  const float *positions,
79  const int start_vertex_index,
80  const int num_vertices);
81  // Set vertex data from a continuous array of coordinates.
82  void (*setVertexData)(struct OpenSubdiv_Evaluator *evaluator,
83  const float *data,
84  const int start_vertex_index,
85  const int num_vertices);
86  // Set varying data from a continuous array of data.
88  const float *varying_data,
89  const int start_vertex_index,
90  const int num_vertices);
91  // Set face varying data from a continuous array of data.
92  //
93  // TODO(sergey): Find a better name for vertex here. It is not the vertex of
94  // geometry, but a vertex of UV map.
96  const int face_varying_channel,
97  const float *face_varying_data,
98  const int start_vertex_index,
99  const int num_vertices);
100 
101  // Set coarse vertex position from a continuous memory buffer where
102  // first coordinate starts at offset of `start_offset` and there is `stride`
103  // bytes between adjacent vertex coordinates.
105  const void *buffer,
106  const int start_offset,
107  const int stride,
108  const int start_vertex_index,
109  const int num_vertices);
110  // Set varying data from a continuous memory buffer where
111  // first coordinate starts at offset of `start_offset` and there is `stride`
112  // bytes between adjacent vertex coordinates.
114  const void *buffer,
115  const int start_offset,
116  const int stride,
117  const int start_vertex_index,
118  const int num_vertices);
119  // Set face varying data from a continuous memory buffer where
120  // first coordinate starts at offset of `start_offset` and there is `stride`
121  // bytes between adjacent vertex coordinates.
122  //
123  // TODO(sergey): Find a better name for vertex here. It is not the vertex of
124  // geometry, but a vertex of UV map.
126  const int face_varying_channel,
127  const void *buffer,
128  const int start_offset,
129  const int stride,
130  const int start_vertex_index,
131  const int num_vertices);
132 
133  // Refine after coarse positions update.
134  void (*refine)(struct OpenSubdiv_Evaluator *evaluator);
135 
136  // Evaluate given ptex face at given bilinear coordinate.
137  // If derivatives are NULL, they will not be evaluated.
139  const int ptex_face_index,
140  float face_u,
141  float face_v,
142  float P[3],
143  float dPdu[3],
144  float dPdv[3]);
145 
146  // Evaluate vertex data at a given bilinear coordinate of given ptex face.
148  const int ptex_face_index,
149  float face_u,
150  float face_v,
151  float data[]);
152 
153  // Evaluate varying data at a given bilinear coordinate of given ptex face.
155  const int ptex_face_index,
156  float face_u,
157  float face_v,
158  float varying[3]);
159 
160  // Evaluate face-varying data at a given bilinear coordinate of given
161  // ptex face.
163  const int face_varying_channel,
164  const int ptex_face_index,
165  float face_u,
166  float face_v,
167  float face_varying[2]);
168 
169  // Batched evaluation of multiple input coordinates.
170 
171  // Evaluate limit surface.
172  // If derivatives are NULL, they will not be evaluated.
173  //
174  // NOTE: Output arrays must point to a memory of size float[3]*num_patch_coords.
176  const struct OpenSubdiv_PatchCoord *patch_coords,
177  const int num_patch_coords,
178  float *P,
179  float *dPdu,
180  float *dPdv);
181 
182  // Copy the patch map to the given buffers, and output some topology information.
183  void (*getPatchMap)(struct OpenSubdiv_Evaluator *evaluator,
184  struct OpenSubdiv_Buffer *patch_map_handles,
185  struct OpenSubdiv_Buffer *patch_map_quadtree,
186  int *min_patch_face,
187  int *max_patch_face,
188  int *max_depth,
189  int *patches_are_triangular);
190 
191  // Fill the given buffer with data from the evaluator's patch array buffer.
193  struct OpenSubdiv_Buffer *patch_array_buffer);
194 
195  // Fill the given buffer with data from the evaluator's patch index buffer.
197  struct OpenSubdiv_Buffer *patch_index_buffer);
198 
199  // Fill the given buffer with data from the evaluator's patch parameter buffer.
201  struct OpenSubdiv_Buffer *patch_param_buffer);
202 
203  // Fill the given buffer with data from the evaluator's source buffer.
205  struct OpenSubdiv_Buffer *src_buffer);
206 
207  // Fill the given buffer with data from the evaluator's extra source buffer.
209  struct OpenSubdiv_Buffer *src_buffer);
210 
211  // Fill the given buffer with data from the evaluator's face varying patch array buffer.
213  const int face_varying_channel,
214  struct OpenSubdiv_Buffer *patch_array_buffer);
215 
216  // Fill the given buffer with data from the evaluator's face varying patch index buffer.
218  const int face_varying_channel,
219  struct OpenSubdiv_Buffer *patch_index_buffer);
220 
221  // Fill the given buffer with data from the evaluator's face varying patch parameter buffer.
223  const int face_varying_channel,
224  struct OpenSubdiv_Buffer *patch_param_buffer);
225 
226  // Fill the given buffer with data from the evaluator's face varying source buffer.
228  const int face_varying_channel,
229  struct OpenSubdiv_Buffer *src_buffer);
230 
231  // Return true if the evaluator has source vertex data set.
232  bool (*hasVertexData)(struct OpenSubdiv_Evaluator *evaluator);
233 
234  // Implementation of the evaluator.
236 
237  // Type of the evaluator.
240 
242  // Implementation of the evaluator cache.
245 
247  struct OpenSubdiv_TopologyRefiner *topology_refiner,
248  eOpenSubdivEvaluator evaluator_type,
249  OpenSubdiv_EvaluatorCache *evaluator_cache);
250 
252 
254 
256 
257 // Return the GLSL source code from the OpenSubDiv library used for patch evaluation.
258 // This function is not thread-safe.
259 const char *openSubdiv_getGLSLPatchBasisSource(void);
260 
261 #ifdef __cplusplus
262 }
263 #endif
264 
265 #endif // OPENSUBDIV_EVALUATOR_CAPI_H_
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SyclQueue void void size_t num_bytes void
int len
Definition: draw_manager.c:108
ccl_global float * buffer
static float P(float k)
Definition: math_interp.c:25
MutableSpan< float3 > positions
eOpenSubdivEvaluator
void openSubdiv_deleteEvaluatorCache(OpenSubdiv_EvaluatorCache *evaluator_cache)
struct OpenSubdiv_Buffer OpenSubdiv_Buffer
struct OpenSubdiv_EvaluatorCache OpenSubdiv_EvaluatorCache
struct OpenSubdiv_Evaluator OpenSubdiv_Evaluator
OpenSubdiv_Evaluator * openSubdiv_createEvaluatorFromTopologyRefiner(struct OpenSubdiv_TopologyRefiner *topology_refiner, eOpenSubdivEvaluator evaluator_type, OpenSubdiv_EvaluatorCache *evaluator_cache)
const char * openSubdiv_getGLSLPatchBasisSource(void)
struct OpenSubdiv_EvaluatorSettings OpenSubdiv_EvaluatorSettings
void openSubdiv_deleteEvaluator(OpenSubdiv_Evaluator *evaluator)
OpenSubdiv_EvaluatorCache * openSubdiv_createEvaluatorCache(eOpenSubdivEvaluator evaluator_type)
unsigned __int64 uint64_t
Definition: stdint.h:90
void(* wrap_device_handle)(const struct OpenSubdiv_Buffer *buffer, uint64_t device_ptr)
void(* bind_gpu)(const struct OpenSubdiv_Buffer *buffer)
void(* device_update)(const struct OpenSubdiv_Buffer *buffer, unsigned int start, unsigned int len, const void *data)
void(* device_alloc)(const struct OpenSubdiv_Buffer *buffer, const unsigned int size)
struct OpenSubdiv_EvaluatorCacheImpl * impl
void(* wrapSrcVertexDataBuffer)(struct OpenSubdiv_Evaluator *evaluator, struct OpenSubdiv_Buffer *src_buffer)
bool(* hasVertexData)(struct OpenSubdiv_Evaluator *evaluator)
void(* fillFVarPatchArraysBuffer)(struct OpenSubdiv_Evaluator *evaluator, const int face_varying_channel, struct OpenSubdiv_Buffer *patch_array_buffer)
void(* setVertexData)(struct OpenSubdiv_Evaluator *evaluator, const float *data, const int start_vertex_index, const int num_vertices)
void(* setVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator *evaluator, const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
void(* getPatchMap)(struct OpenSubdiv_Evaluator *evaluator, struct OpenSubdiv_Buffer *patch_map_handles, struct OpenSubdiv_Buffer *patch_map_quadtree, int *min_patch_face, int *max_patch_face, int *max_depth, int *patches_are_triangular)
void(* setVaryingData)(struct OpenSubdiv_Evaluator *evaluator, const float *varying_data, const int start_vertex_index, const int num_vertices)
void(* setCoarsePositionsFromBuffer)(struct OpenSubdiv_Evaluator *evaluator, const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
void(* setCoarsePositions)(struct OpenSubdiv_Evaluator *evaluator, const float *positions, const int start_vertex_index, const int num_vertices)
void(* evaluateLimit)(struct OpenSubdiv_Evaluator *evaluator, const int ptex_face_index, float face_u, float face_v, float P[3], float dPdu[3], float dPdv[3])
void(* wrapPatchIndexBuffer)(struct OpenSubdiv_Evaluator *evaluator, struct OpenSubdiv_Buffer *patch_index_buffer)
void(* setFaceVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator *evaluator, const int face_varying_channel, const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
void(* setFaceVaryingData)(struct OpenSubdiv_Evaluator *evaluator, const int face_varying_channel, const float *face_varying_data, const int start_vertex_index, const int num_vertices)
void(* fillPatchArraysBuffer)(struct OpenSubdiv_Evaluator *evaluator, struct OpenSubdiv_Buffer *patch_array_buffer)
struct OpenSubdiv_EvaluatorImpl * impl
void(* wrapFVarSrcBuffer)(struct OpenSubdiv_Evaluator *evaluator, const int face_varying_channel, struct OpenSubdiv_Buffer *src_buffer)
void(* wrapPatchParamBuffer)(struct OpenSubdiv_Evaluator *evaluator, struct OpenSubdiv_Buffer *patch_param_buffer)
void(* evaluateVertexData)(struct OpenSubdiv_Evaluator *evaluator, const int ptex_face_index, float face_u, float face_v, float data[])
void(* wrapFVarPatchParamBuffer)(struct OpenSubdiv_Evaluator *evaluator, const int face_varying_channel, struct OpenSubdiv_Buffer *patch_param_buffer)
void(* evaluateFaceVarying)(struct OpenSubdiv_Evaluator *evaluator, const int face_varying_channel, const int ptex_face_index, float face_u, float face_v, float face_varying[2])
void(* wrapFVarPatchIndexBuffer)(struct OpenSubdiv_Evaluator *evaluator, const int face_varying_channel, struct OpenSubdiv_Buffer *patch_index_buffer)
void(* wrapSrcBuffer)(struct OpenSubdiv_Evaluator *evaluator, struct OpenSubdiv_Buffer *src_buffer)
void(* evaluateVarying)(struct OpenSubdiv_Evaluator *evaluator, const int ptex_face_index, float face_u, float face_v, float varying[3])
void(* evaluatePatchesLimit)(struct OpenSubdiv_Evaluator *evaluator, const struct OpenSubdiv_PatchCoord *patch_coords, const int num_patch_coords, float *P, float *dPdu, float *dPdv)
void(* refine)(struct OpenSubdiv_Evaluator *evaluator)
void(* setSettings)(struct OpenSubdiv_Evaluator *evaluator, const OpenSubdiv_EvaluatorSettings *settings)
uint64_t device_ptr
Definition: util/types.h:43