OpenSubdiv
Loading...
Searching...
No Matches
mesh.h
Go to the documentation of this file.
1//
2// Copyright 2013 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_MESH_H
9#define OPENSUBDIV3_OSD_MESH_H
10
11#include "../version.h"
12
13#include <bitset>
14#include <cassert>
15#include <cstring>
16#include <vector>
17
18#include "../far/topologyRefiner.h"
19#include "../far/patchTableFactory.h"
20#include "../far/stencilTable.h"
21#include "../far/stencilTableFactory.h"
22
23#include "../osd/bufferDescriptor.h"
24
25struct ID3D11DeviceContext;
26
27namespace OpenSubdiv {
28namespace OPENSUBDIV_VERSION {
29
30namespace Osd {
31
40 MeshEndCapBilinearBasis = 7, // exclusive
41 MeshEndCapBSplineBasis = 8, // exclusive
42 MeshEndCapGregoryBasis = 9, // exclusive
43 MeshEndCapLegacyGregory = 10, // exclusive
45};
46typedef std::bitset<NUM_MESH_BITS> MeshBitset;
47
48// ---------------------------------------------------------------------------
49
50template <class PATCH_TABLE>
52public:
53 typedef PATCH_TABLE PatchTable;
54 typedef typename PatchTable::VertexBufferBinding VertexBufferBinding;
55
56public:
58
59 virtual ~MeshInterface() { }
60
61 virtual int GetNumVertices() const = 0;
62
63 virtual int GetMaxValence() const = 0;
64
65 virtual void UpdateVertexBuffer(float const *vertexData,
66 int startVertex, int numVerts) = 0;
67
68 virtual void UpdateVaryingBuffer(float const *varyingData,
69 int startVertex, int numVerts) = 0;
70
71 virtual void Refine() = 0;
72
73 virtual void Synchronize() = 0;
74
75 virtual PatchTable * GetPatchTable() const = 0;
76
77 virtual Far::PatchTable const *GetFarPatchTable() const = 0;
78
80
82
83protected:
84 static inline void refineMesh(Far::TopologyRefiner & refiner,
85 int level, bool adaptive,
86 bool singleCreasePatch) {
87 if (adaptive) {
89 options.useSingleCreasePatch = singleCreasePatch;
90 refiner.RefineAdaptive(options);
91 } else {
92 // This dependency on FVar channels should not be necessary
93 bool fullTopologyInLastLevel = refiner.GetNumFVarChannels()>0;
94
96 options.fullTopologyInLastLevel = fullTopologyInLastLevel;
97 refiner.RefineUniform(options);
98 }
99 }
100 static inline void refineMesh(Far::TopologyRefiner & refiner,
101 int level, MeshBitset bits) {
102 if (bits.test(MeshAdaptive)) {
105 options.useInfSharpPatch = bits.test(MeshUseInfSharpPatch);
106 options.considerFVarChannels = bits.test(MeshFVarAdaptive);
107 refiner.RefineAdaptive(options);
108 } else {
109 // This dependency on FVar channels should not be necessary
110 bool fullTopologyInLastLevel = refiner.GetNumFVarChannels()>0;
111
113 options.fullTopologyInLastLevel = fullTopologyInLastLevel;
114 refiner.RefineUniform(options);
115 }
116 }
117};
118
119// ---------------------------------------------------------------------------
120
121template <typename STENCIL_TABLE, typename SRC_STENCIL_TABLE,
122 typename DEVICE_CONTEXT>
123STENCIL_TABLE const *
125 SRC_STENCIL_TABLE const *table, DEVICE_CONTEXT *context) {
126 if (! table) return NULL;
127 return STENCIL_TABLE::Create(table, context);
128}
129
130template <>
131inline Far::StencilTable const *
133 Far::StencilTable const *table, void * /*context*/) {
134 // no need for conversion
135 // XXX: We don't want to even copy.
136 if (! table) return NULL;
137 return new Far::StencilTable(*table);
138}
139
140template <>
143 Far::LimitStencilTable const *table, void * /*context*/) {
144 // no need for conversion
145 // XXX: We don't want to even copy.
146 if (! table) return NULL;
147 return new Far::LimitStencilTable(*table);
148}
149
150template <>
151inline Far::StencilTable const *
153 Far::StencilTable const *table, ID3D11DeviceContext * /*context*/) {
154 // no need for conversion
155 // XXX: We don't want to even copy.
156 if (! table) return NULL;
157 return new Far::StencilTable(*table);
158}
159
160// ---------------------------------------------------------------------------
161
162// Osd evaluator cache: for the GPU backends require compiled instance
163// (GLXFB, GLCompute, CL)
164//
165// note: this is just an example usage and client applications are supposed
166// to implement their own structure for Evaluator instance.
167//
168template <typename EVALUATOR>
170public:
172 for(typename Evaluators::iterator it = _evaluators.begin();
173 it != _evaluators.end(); ++it) {
174 delete it->evaluator;
175 }
176 }
177
178 // XXX: FIXME, linear search
179 struct Entry {
180 Entry(BufferDescriptor const &srcDescArg,
181 BufferDescriptor const &dstDescArg,
182 BufferDescriptor const &duDescArg,
183 BufferDescriptor const &dvDescArg,
184 EVALUATOR *evalArg) : srcDesc(srcDescArg), dstDesc(dstDescArg),
185 duDesc(duDescArg), dvDesc(dvDescArg),
189 evaluator(evalArg) {}
190 Entry(BufferDescriptor const &srcDescArg,
191 BufferDescriptor const &dstDescArg,
192 BufferDescriptor const &duDescArg,
193 BufferDescriptor const &dvDescArg,
194 BufferDescriptor const &duuDescArg,
195 BufferDescriptor const &duvDescArg,
196 BufferDescriptor const &dvvDescArg,
197 EVALUATOR *evalArg) : srcDesc(srcDescArg), dstDesc(dstDescArg),
198 duDesc(duDescArg), dvDesc(dvDescArg),
199 duuDesc(duuDescArg),
200 duvDesc(duvDescArg),
201 dvvDesc(dvvDescArg),
202 evaluator(evalArg) {}
206 EVALUATOR *evaluator;
207 };
208 typedef std::vector<Entry> Evaluators;
209
210 template <typename DEVICE_CONTEXT>
211 EVALUATOR *GetEvaluator(BufferDescriptor const &srcDesc,
212 BufferDescriptor const &dstDesc,
213 DEVICE_CONTEXT *deviceContext) {
214 return GetEvaluator(srcDesc, dstDesc,
220 deviceContext);
221 }
222
223 template <typename DEVICE_CONTEXT>
224 EVALUATOR *GetEvaluator(BufferDescriptor const &srcDesc,
225 BufferDescriptor const &dstDesc,
226 BufferDescriptor const &duDesc,
227 BufferDescriptor const &dvDesc,
228 DEVICE_CONTEXT *deviceContext) {
229 return GetEvaluator(srcDesc, dstDesc,
230 duDesc, dvDesc,
234 deviceContext);
235 }
236
237 template <typename DEVICE_CONTEXT>
238 EVALUATOR *GetEvaluator(BufferDescriptor const &srcDesc,
239 BufferDescriptor const &dstDesc,
240 BufferDescriptor const &duDesc,
241 BufferDescriptor const &dvDesc,
242 BufferDescriptor const &duuDesc,
243 BufferDescriptor const &duvDesc,
244 BufferDescriptor const &dvvDesc,
245 DEVICE_CONTEXT *deviceContext) {
246
247 for(typename Evaluators::iterator it = _evaluators.begin();
248 it != _evaluators.end(); ++it) {
249 if (isEqual(srcDesc, it->srcDesc) &&
250 isEqual(dstDesc, it->dstDesc) &&
251 isEqual(duDesc, it->duDesc) &&
252 isEqual(dvDesc, it->dvDesc) &&
253 isEqual(duuDesc, it->duuDesc) &&
254 isEqual(duvDesc, it->duvDesc) &&
255 isEqual(dvvDesc, it->dvvDesc)) {
256 return it->evaluator;
257 }
258 }
259 EVALUATOR *e = EVALUATOR::Create(srcDesc, dstDesc,
260 duDesc, dvDesc,
261 duuDesc, duvDesc, dvvDesc,
262 deviceContext);
263 _evaluators.push_back(Entry(srcDesc, dstDesc,
264 duDesc, dvDesc,
265 duuDesc, duvDesc, dvvDesc, e));
266 return e;
267 }
268
269private:
270 static bool isEqual(BufferDescriptor const &a,
271 BufferDescriptor const &b) {
272 int offsetA = a.stride ? (a.offset % a.stride) : 0;
273 int offsetB = b.stride ? (b.offset % b.stride) : 0;
274
275 // Note: XFB kernel needs to be configured with the local offset
276 // of the dstDesc to skip preceding primvars.
277 return (offsetA == offsetB &&
278 a.length == b.length &&
279 a.stride == b.stride);
280 }
281
282 Evaluators _evaluators;
283};
284
286
287// template helpers to see if the evaluator is instantiatable or not.
288template <typename EVALUATOR>
289struct instantiatable
290{
291 typedef char yes[1];
292 typedef char no[2];
293 template <typename C> static yes &chk(typename C::Instantiatable *t=0);
294 template <typename C> static no &chk(...);
295 static bool const value = sizeof(chk<EVALUATOR>(0)) == sizeof(yes);
296};
297template <bool C, typename T=void>
298struct enable_if { typedef T type; };
299template <typename T>
300struct enable_if<false, T> { };
301
303
304// extract a kernel from cache if available
305template <typename EVALUATOR, typename DEVICE_CONTEXT>
306static EVALUATOR *GetEvaluator(
307 EvaluatorCacheT<EVALUATOR> *cache,
308 BufferDescriptor const &srcDesc,
309 BufferDescriptor const &dstDesc,
310 BufferDescriptor const &duDesc,
311 BufferDescriptor const &dvDesc,
312 BufferDescriptor const &duuDesc,
313 BufferDescriptor const &duvDesc,
314 BufferDescriptor const &dvvDesc,
315 DEVICE_CONTEXT deviceContext,
316 typename enable_if<instantiatable<EVALUATOR>::value, void>::type*t=0) {
317 (void)t;
318 if (cache == NULL) return NULL;
319 return cache->GetEvaluator(srcDesc, dstDesc,
320 duDesc, dvDesc, duuDesc, duvDesc, dvvDesc,
321 deviceContext);
322}
323
324template <typename EVALUATOR, typename DEVICE_CONTEXT>
325static EVALUATOR *GetEvaluator(
326 EvaluatorCacheT<EVALUATOR> *cache,
327 BufferDescriptor const &srcDesc,
328 BufferDescriptor const &dstDesc,
329 BufferDescriptor const &duDesc,
330 BufferDescriptor const &dvDesc,
331 DEVICE_CONTEXT deviceContext,
332 typename enable_if<instantiatable<EVALUATOR>::value, void>::type*t=0) {
333 (void)t;
334 if (cache == NULL) return NULL;
335 return cache->GetEvaluator(srcDesc, dstDesc, duDesc, dvDesc, deviceContext);
336}
337
338template <typename EVALUATOR, typename DEVICE_CONTEXT>
339static EVALUATOR *GetEvaluator(
340 EvaluatorCacheT<EVALUATOR> *cache,
341 BufferDescriptor const &srcDesc,
342 BufferDescriptor const &dstDesc,
343 DEVICE_CONTEXT deviceContext,
344 typename enable_if<instantiatable<EVALUATOR>::value, void>::type*t=0) {
345 (void)t;
346 if (cache == NULL) return NULL;
347 return cache->GetEvaluator(srcDesc, dstDesc,
348 BufferDescriptor(),
349 BufferDescriptor(),
350 deviceContext);
351}
352
353// fallback
354template <typename EVALUATOR, typename DEVICE_CONTEXT>
355static EVALUATOR *GetEvaluator(
356 EvaluatorCacheT<EVALUATOR> *,
357 BufferDescriptor const &,
358 BufferDescriptor const &,
359 BufferDescriptor const &,
360 BufferDescriptor const &,
361 BufferDescriptor const &,
362 BufferDescriptor const &,
363 BufferDescriptor const &,
364 DEVICE_CONTEXT,
365 typename enable_if<!instantiatable<EVALUATOR>::value, void>::type*t=0) {
366 (void)t;
367 return NULL;
368}
369
370template <typename EVALUATOR, typename DEVICE_CONTEXT>
371static EVALUATOR *GetEvaluator(
372 EvaluatorCacheT<EVALUATOR> *,
373 BufferDescriptor const &,
374 BufferDescriptor const &,
375 BufferDescriptor const &,
376 BufferDescriptor const &,
377 DEVICE_CONTEXT,
378 typename enable_if<!instantiatable<EVALUATOR>::value, void>::type*t=0) {
379 (void)t;
380 return NULL;
381}
382
383template <typename EVALUATOR, typename DEVICE_CONTEXT>
384static EVALUATOR *GetEvaluator(
385 EvaluatorCacheT<EVALUATOR> *,
386 BufferDescriptor const &,
387 BufferDescriptor const &,
388 DEVICE_CONTEXT,
389 typename enable_if<!instantiatable<EVALUATOR>::value, void>::type*t=0) {
390 (void)t;
391 return NULL;
392}
393
394// ---------------------------------------------------------------------------
395
396template <typename VERTEX_BUFFER,
397 typename STENCIL_TABLE,
398 typename EVALUATOR,
399 typename PATCH_TABLE,
400 typename DEVICE_CONTEXT = void>
401class Mesh : public MeshInterface<PATCH_TABLE> {
402public:
403 typedef VERTEX_BUFFER VertexBuffer;
404 typedef EVALUATOR Evaluator;
405 typedef STENCIL_TABLE StencilTable;
406 typedef PATCH_TABLE PatchTable;
407 typedef DEVICE_CONTEXT DeviceContext;
409 typedef typename PatchTable::VertexBufferBinding VertexBufferBinding;
410
412 int numVertexElements,
413 int numVaryingElements,
414 int level,
415 MeshBitset bits = MeshBitset(),
416 EvaluatorCache * evaluatorCache = NULL,
417 DeviceContext * deviceContext = NULL) :
418
419 _refiner(refiner),
420 _farPatchTable(NULL),
421 _numVertices(0),
422 _maxValence(0),
423 _vertexBuffer(NULL),
424 _varyingBuffer(NULL),
425 _vertexStencilTable(NULL),
426 _varyingStencilTable(NULL),
427 _evaluatorCache(evaluatorCache),
428 _patchTable(NULL),
429 _deviceContext(deviceContext) {
430
431 assert(_refiner);
432
434 *_refiner, level, bits);
435
436 int vertexBufferStride = numVertexElements +
437 (bits.test(MeshInterleaveVarying) ? numVaryingElements : 0);
438 int varyingBufferStride =
439 (bits.test(MeshInterleaveVarying) ? 0 : numVaryingElements);
440
441 initializeContext(numVertexElements,
442 numVaryingElements,
443 level, bits);
444
445 initializeVertexBuffers(_numVertices,
446 vertexBufferStride,
447 varyingBufferStride);
448
449 // configure vertex buffer descriptor
450 _vertexDesc =
451 BufferDescriptor(0, numVertexElements, vertexBufferStride);
452 if (bits.test(MeshInterleaveVarying)) {
453 _varyingDesc = BufferDescriptor(
454 numVertexElements, numVaryingElements, vertexBufferStride);
455 } else {
456 _varyingDesc = BufferDescriptor(
457 0, numVaryingElements, varyingBufferStride);
458 }
459 }
460
461 virtual ~Mesh() {
462 delete _refiner;
463 delete _farPatchTable;
464 delete _vertexBuffer;
465 delete _varyingBuffer;
466 delete _vertexStencilTable;
467 delete _varyingStencilTable;
468 delete _patchTable;
469 // deviceContext and evaluatorCache are not owned by this class.
470 }
471
472 virtual void UpdateVertexBuffer(float const *vertexData,
473 int startVertex, int numVerts) {
474 _vertexBuffer->UpdateData(vertexData, startVertex, numVerts,
475 _deviceContext);
476 }
477
478 virtual void UpdateVaryingBuffer(float const *varyingData,
479 int startVertex, int numVerts) {
480 _varyingBuffer->UpdateData(varyingData, startVertex, numVerts,
481 _deviceContext);
482 }
483
484 virtual void Refine() {
485
486 int numControlVertices = _refiner->GetLevel(0).GetNumVertices();
487
488 BufferDescriptor srcDesc = _vertexDesc;
489 BufferDescriptor dstDesc(srcDesc);
490 dstDesc.offset += numControlVertices * dstDesc.stride;
491
492 // note that the _evaluatorCache can be NULL and thus
493 // the evaluatorInstance can be NULL
494 // (for uninstantiatable kernels CPU,TBB etc)
495 Evaluator const *instance = GetEvaluator<Evaluator>(
496 _evaluatorCache, srcDesc, dstDesc,
497 _deviceContext);
498
499 Evaluator::EvalStencils(_vertexBuffer, srcDesc,
500 _vertexBuffer, dstDesc,
501 _vertexStencilTable,
502 instance, _deviceContext);
503
504 if (_varyingDesc.length > 0) {
505 BufferDescriptor vSrcDesc = _varyingDesc;
506 BufferDescriptor vDstDesc(vSrcDesc);
507 vDstDesc.offset += numControlVertices * vDstDesc.stride;
508
509 instance = GetEvaluator<Evaluator>(
510 _evaluatorCache, vSrcDesc, vDstDesc,
511 _deviceContext);
512
513 if (_varyingBuffer) {
514 // non-interleaved
515 Evaluator::EvalStencils(_varyingBuffer, vSrcDesc,
516 _varyingBuffer, vDstDesc,
517 _varyingStencilTable,
518 instance, _deviceContext);
519 } else {
520 // interleaved
521 Evaluator::EvalStencils(_vertexBuffer, vSrcDesc,
522 _vertexBuffer, vDstDesc,
523 _varyingStencilTable,
524 instance, _deviceContext);
525 }
526 }
527 }
528
529 virtual void Synchronize() {
530 Evaluator::Synchronize(_deviceContext);
531 }
532
533 virtual PatchTable * GetPatchTable() const {
534 return _patchTable;
535 }
536
537 virtual Far::PatchTable const *GetFarPatchTable() const {
538 return _farPatchTable;
539 }
540
541 virtual int GetNumVertices() const { return _numVertices; }
542
543 virtual int GetMaxValence() const { return _maxValence; }
544
546 return _vertexBuffer->BindVBO(_deviceContext);
547 }
548
550 return _varyingBuffer->BindVBO(_deviceContext);
551 }
552
554 return _vertexBuffer;
555 }
556
558 return _varyingBuffer;
559 }
560
561 virtual Far::TopologyRefiner const * GetTopologyRefiner() const {
562 return _refiner;
563 }
564
565private:
566 void initializeContext(int numVertexElements,
567 int numVaryingElements,
568 int level, MeshBitset bits) {
569 assert(_refiner);
570
571 Far::StencilTableFactory::Options options;
572 options.generateOffsets = true;
573 options.generateIntermediateLevels =
574 _refiner->IsUniform() ? false : true;
575
576 Far::StencilTable const * vertexStencils = NULL;
577 Far::StencilTable const * varyingStencils = NULL;
578
579 if (numVertexElements>0) {
580
581 vertexStencils = Far::StencilTableFactory::Create(*_refiner,
582 options);
583 }
584
585 if (numVaryingElements>0) {
586
587 options.interpolationMode =
589
590 varyingStencils = Far::StencilTableFactory::Create(*_refiner,
591 options);
592 }
593
594 Far::PatchTableFactory::Options poptions(level);
595 poptions.generateFVarTables = bits.test(MeshFVarData);
596 poptions.generateFVarLegacyLinearPatches = !bits.test(MeshFVarAdaptive);
597 poptions.generateLegacySharpCornerPatches = !bits.test(MeshUseSmoothCornerPatch);
598 poptions.useSingleCreasePatch = bits.test(MeshUseSingleCreasePatch);
599 poptions.useInfSharpPatch = bits.test(MeshUseInfSharpPatch);
600
601 // points on bilinear and gregory basis endcap boundaries can be
602 // shared among adjacent patches to save some stencils.
603 if (bits.test(MeshEndCapBilinearBasis)) {
604 poptions.SetEndCapType(
606 poptions.shareEndCapPatchPoints = true;
607 } else if (bits.test(MeshEndCapBSplineBasis)) {
608 poptions.SetEndCapType(
610 } else if (bits.test(MeshEndCapGregoryBasis)) {
611 poptions.SetEndCapType(
613 poptions.shareEndCapPatchPoints = true;
614 } else if (bits.test(MeshEndCapLegacyGregory)) {
615 poptions.SetEndCapType(
617 }
618
619 _farPatchTable = Far::PatchTableFactory::Create(*_refiner, poptions);
620
621 // if there's endcap stencils, merge it into regular stencils.
622 if (_farPatchTable->GetLocalPointStencilTable()) {
623 // append stencils
624 if (Far::StencilTable const *vertexStencilsWithLocalPoints =
626 *_refiner,
627 vertexStencils,
628 _farPatchTable->GetLocalPointStencilTable())) {
629 delete vertexStencils;
630 vertexStencils = vertexStencilsWithLocalPoints;
631 }
632 if (varyingStencils) {
633 if (Far::StencilTable const *varyingStencilsWithLocalPoints =
635 *_refiner,
636 varyingStencils,
637 _farPatchTable->GetLocalPointVaryingStencilTable())) {
638 delete varyingStencils;
639 varyingStencils = varyingStencilsWithLocalPoints;
640 }
641 }
642 }
643
644 _maxValence = _farPatchTable->GetMaxValence();
645 _patchTable = PatchTable::Create(_farPatchTable, _deviceContext);
646
647 // numvertices = coarse verts + refined verts + gregory basis verts
648 _numVertices = vertexStencils->GetNumControlVertices()
649 + vertexStencils->GetNumStencils();
650
651 // convert to device stenciltable if necessary.
652 _vertexStencilTable =
653 convertToCompatibleStencilTable<StencilTable>(
654 vertexStencils, _deviceContext);
655 _varyingStencilTable =
656 convertToCompatibleStencilTable<StencilTable>(
657 varyingStencils, _deviceContext);
658
659 // FIXME: we do extra copyings for Far::Stencils.
660 delete vertexStencils;
661 delete varyingStencils;
662 }
663
664 void initializeVertexBuffers(int numVertices,
665 int numVertexElements,
666 int numVaryingElements) {
667
668 if (numVertexElements) {
669 _vertexBuffer = VertexBuffer::Create(numVertexElements,
670 numVertices, _deviceContext);
671 }
672
673 if (numVaryingElements) {
674 _varyingBuffer = VertexBuffer::Create(numVaryingElements,
675 numVertices, _deviceContext);
676 }
677 }
678
679 Far::TopologyRefiner * _refiner;
680 Far::PatchTable * _farPatchTable;
681
682 int _numVertices;
683 int _maxValence;
684
685 VertexBuffer * _vertexBuffer;
686 VertexBuffer * _varyingBuffer;
687
688 BufferDescriptor _vertexDesc;
689 BufferDescriptor _varyingDesc;
690
691 StencilTable const * _vertexStencilTable;
692 StencilTable const * _varyingStencilTable;
693 EvaluatorCache * _evaluatorCache;
694
695 PatchTable *_patchTable;
696 DeviceContext *_deviceContext;
697};
698
699} // end namespace Osd
700
701} // end namespace OPENSUBDIV_VERSION
702using namespace OPENSUBDIV_VERSION;
703
704} // end namespace OpenSubdiv
705
706#endif // OPENSUBDIV3_OSD_MESH_H
STENCIL_TABLE const * convertToCompatibleStencilTable(SRC_STENCIL_TABLE const *table, DEVICE_CONTEXT *context)
Definition: mesh.h:124
Far::StencilTable const * convertToCompatibleStencilTable< Far::StencilTable, Far::StencilTable, void >(Far::StencilTable const *table, void *)
Definition: mesh.h:132
Far::LimitStencilTable const * convertToCompatibleStencilTable< Far::LimitStencilTable, Far::LimitStencilTable, void >(Far::LimitStencilTable const *table, void *)
Definition: mesh.h:142
std::bitset< NUM_MESH_BITS > MeshBitset
Definition: mesh.h:46
Far::StencilTable const * convertToCompatibleStencilTable< Far::StencilTable, Far::StencilTable, ID3D11DeviceContext >(Far::StencilTable const *table, ID3D11DeviceContext *)
Definition: mesh.h:152
Container for arrays of parametric patches.
Definition: patchTable.h:38
int GetMaxValence() const
Returns max vertex valence.
Definition: patchTable.h:75
StencilTable const * GetLocalPointStencilTable() const
Returns the stencil table to compute local point vertex values.
Definition: patchTable.h:761
StencilTable const * GetLocalPointVaryingStencilTable() const
Returns the stencil table to compute local point varying values.
Definition: patchTable.h:766
static PatchTable * Create(TopologyRefiner const &refiner, Options options=Options(), ConstIndexArray selectedFaces=ConstIndexArray())
Instantiates a PatchTable from a client-provided TopologyRefiner.
@ ENDCAP_LEGACY_GREGORY
legacy option for 2.x style Gregory patches (Catmark only)
@ ENDCAP_GREGORY_BASIS
use Gregory patches (highest quality, recommended default)
@ ENDCAP_BILINEAR_BASIS
use linear patches (simple quads or tris)
@ ENDCAP_BSPLINE_BASIS
use BSpline-like patches (same patch type as regular)
int GetNumControlVertices() const
Returns the number of control vertices indexed in the table.
Definition: stencilTable.h:144
int GetNumStencils() const
Returns the number of stencils in the table.
Definition: stencilTable.h:139
Stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:256
Limit stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:566
static StencilTable const * Create(TopologyRefiner const &refiner, Options options=Options())
static StencilTable const * AppendLocalPointStencilTable(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
int GetNumVertices() const
Return the number of vertices in this level.
Definition: topologyLevel.h:45
Stores topology data for a specified set of refinement options.
bool IsUniform() const
Returns true if uniform refinement has been applied.
int GetNumFVarChannels() const
Returns the number of face-varying channels in the tables.
void RefineUniform(UniformOptions options)
Refine the topology uniformly.
TopologyLevel const & GetLevel(int level) const
Returns a handle to access data specific to a particular level.
void RefineAdaptive(AdaptiveOptions options, ConstIndexArray selectedFaces=ConstIndexArray())
Feature Adaptive topology refinement.
BufferDescriptor is a struct which describes buffer elements in interleaved data buffers....
virtual Far::PatchTable const * GetFarPatchTable() const =0
static void refineMesh(Far::TopologyRefiner &refiner, int level, MeshBitset bits)
Definition: mesh.h:100
virtual void UpdateVaryingBuffer(float const *varyingData, int startVertex, int numVerts)=0
static void refineMesh(Far::TopologyRefiner &refiner, int level, bool adaptive, bool singleCreasePatch)
Definition: mesh.h:84
virtual void UpdateVertexBuffer(float const *vertexData, int startVertex, int numVerts)=0
virtual PatchTable * GetPatchTable() const =0
PatchTable::VertexBufferBinding VertexBufferBinding
Definition: mesh.h:54
virtual VertexBufferBinding BindVertexBuffer()=0
virtual VertexBufferBinding BindVaryingBuffer()=0
EVALUATOR * GetEvaluator(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, DEVICE_CONTEXT *deviceContext)
Definition: mesh.h:224
EVALUATOR * GetEvaluator(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, BufferDescriptor const &duuDesc, BufferDescriptor const &duvDesc, BufferDescriptor const &dvvDesc, DEVICE_CONTEXT *deviceContext)
Definition: mesh.h:238
EVALUATOR * GetEvaluator(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, DEVICE_CONTEXT *deviceContext)
Definition: mesh.h:211
Entry(BufferDescriptor const &srcDescArg, BufferDescriptor const &dstDescArg, BufferDescriptor const &duDescArg, BufferDescriptor const &dvDescArg, BufferDescriptor const &duuDescArg, BufferDescriptor const &duvDescArg, BufferDescriptor const &dvvDescArg, EVALUATOR *evalArg)
Definition: mesh.h:190
Entry(BufferDescriptor const &srcDescArg, BufferDescriptor const &dstDescArg, BufferDescriptor const &duDescArg, BufferDescriptor const &dvDescArg, EVALUATOR *evalArg)
Definition: mesh.h:180
virtual Far::TopologyRefiner const * GetTopologyRefiner() const
Definition: mesh.h:561
virtual VertexBuffer * GetVertexBuffer()
Definition: mesh.h:553
virtual void UpdateVaryingBuffer(float const *varyingData, int startVertex, int numVerts)
Definition: mesh.h:478
virtual VertexBuffer * GetVaryingBuffer()
Definition: mesh.h:557
virtual VertexBufferBinding BindVertexBuffer()
Definition: mesh.h:545
virtual int GetNumVertices() const
Definition: mesh.h:541
Mesh(Far::TopologyRefiner *refiner, int numVertexElements, int numVaryingElements, int level, MeshBitset bits=MeshBitset(), EvaluatorCache *evaluatorCache=NULL, DeviceContext *deviceContext=NULL)
Definition: mesh.h:411
EvaluatorCacheT< Evaluator > EvaluatorCache
Definition: mesh.h:408
virtual VertexBufferBinding BindVaryingBuffer()
Definition: mesh.h:549
PatchTable::VertexBufferBinding VertexBufferBinding
Definition: mesh.h:409
virtual void UpdateVertexBuffer(float const *vertexData, int startVertex, int numVerts)
Definition: mesh.h:472
virtual PatchTable * GetPatchTable() const
Definition: mesh.h:533
virtual Far::PatchTable const * GetFarPatchTable() const
Definition: mesh.h:537
virtual int GetMaxValence() const
Definition: mesh.h:543