Merge branch 'blender-v4.4-release'
[blender.git] / intern / opensubdiv / internal / evaluator / gl_compute_evaluator.h
blob40d6c73abf8c02c34e0fb7dcb0cbace5ecda7d4b
1 /* SPDX-FileCopyrightText: 2015 Pixar
3 * SPDX-License-Identifier: Apache-2.0 */
5 #ifndef OPENSUBDIV_GL_COMPUTE_EVALUATOR_H_
6 #define OPENSUBDIV_GL_COMPUTE_EVALUATOR_H_
8 #include <opensubdiv/osd/bufferDescriptor.h>
9 #include <opensubdiv/osd/opengl.h>
10 #include <opensubdiv/osd/types.h>
11 #include <opensubdiv/version.h>
13 namespace OpenSubdiv::OPENSUBDIV_VERSION::Far {
14 class LimitStencilTable;
15 class StencilTable;
16 } // namespace OpenSubdiv::OPENSUBDIV_VERSION::Far
17 // namespace OPENSUBDIV_VERSION
19 namespace blender::opensubdiv {
21 /// \brief GL stencil table (Shader Storage buffer)
22 ///
23 /// This class is a GLSL SSBO representation of OpenSubdiv::Far::StencilTable.
24 ///
25 /// GLSLComputeKernel consumes this table to apply stencils
26 ///
27 class GLStencilTableSSBO {
28 public:
29 static GLStencilTableSSBO *Create(OpenSubdiv::Far::StencilTable const *stencilTable,
30 void *deviceContext = nullptr)
32 (void)deviceContext; // unused
33 return new GLStencilTableSSBO(stencilTable);
35 static GLStencilTableSSBO *Create(OpenSubdiv::Far::LimitStencilTable const *limitStencilTable,
36 void *deviceContext = nullptr)
38 (void)deviceContext; // unused
39 return new GLStencilTableSSBO(limitStencilTable);
42 explicit GLStencilTableSSBO(OpenSubdiv::Far::StencilTable const *stencilTable);
43 explicit GLStencilTableSSBO(OpenSubdiv::Far::LimitStencilTable const *limitStencilTable);
44 ~GLStencilTableSSBO();
46 // interfaces needed for GLSLComputeKernel
47 GLuint GetSizesBuffer() const
49 return _sizes;
51 GLuint GetOffsetsBuffer() const
53 return _offsets;
55 GLuint GetIndicesBuffer() const
57 return _indices;
59 GLuint GetWeightsBuffer() const
61 return _weights;
63 GLuint GetDuWeightsBuffer() const
65 return _duWeights;
67 GLuint GetDvWeightsBuffer() const
69 return _dvWeights;
71 GLuint GetDuuWeightsBuffer() const
73 return _duuWeights;
75 GLuint GetDuvWeightsBuffer() const
77 return _duvWeights;
79 GLuint GetDvvWeightsBuffer() const
81 return _dvvWeights;
83 int GetNumStencils() const
85 return _numStencils;
88 private:
89 GLuint _sizes;
90 GLuint _offsets;
91 GLuint _indices;
92 GLuint _weights;
93 GLuint _duWeights;
94 GLuint _dvWeights;
95 GLuint _duuWeights;
96 GLuint _duvWeights;
97 GLuint _dvvWeights;
98 int _numStencils;
101 // ---------------------------------------------------------------------------
103 class GLComputeEvaluator {
104 public:
105 using Instantiatable = bool;
106 static GLComputeEvaluator *Create(OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
107 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
108 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
109 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
110 void *deviceContext = nullptr)
112 return Create(srcDesc,
113 dstDesc,
114 duDesc,
115 dvDesc,
116 OpenSubdiv::Osd::BufferDescriptor(),
117 OpenSubdiv::Osd::BufferDescriptor(),
118 OpenSubdiv::Osd::BufferDescriptor(),
119 deviceContext);
122 static GLComputeEvaluator *Create(OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
123 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
124 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
125 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
126 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
127 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
128 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
129 void *deviceContext = nullptr)
131 (void)deviceContext; // not used
132 GLComputeEvaluator *instance = new GLComputeEvaluator();
133 if (instance->Compile(srcDesc, dstDesc, duDesc, dvDesc, duuDesc, duvDesc, dvvDesc)) {
134 return instance;
136 delete instance;
137 return nullptr;
140 /// Constructor.
141 GLComputeEvaluator();
143 /// Destructor. note that the GL context must be made current.
144 ~GLComputeEvaluator();
146 /// ----------------------------------------------------------------------
148 /// Stencil evaluations with StencilTable
150 /// ----------------------------------------------------------------------
152 /// \brief Generic static stencil function. This function has a same
153 /// signature as other device kernels have so that it can be called
154 /// transparently from OsdMesh template interface.
156 /// @param srcBuffer Input primvar buffer.
157 /// must have BindVBO() method returning a GL
158 /// buffer object of source data
160 /// @param srcDesc vertex buffer descriptor for the input buffer
162 /// @param dstBuffer Output primvar buffer
163 /// must have BindVBO() method returning a GL
164 /// buffer object of destination data
166 /// @param dstDesc vertex buffer descriptor for the output buffer
168 /// @param stencilTable stencil table to be applied. The table must have
169 /// SSBO interfaces.
171 /// @param instance cached compiled instance. Clients are supposed to
172 /// pre-compile an instance of this class and provide
173 /// to this function. If it's null the kernel still
174 /// compute by instantiating on-demand kernel although
175 /// it may cause a performance problem.
177 /// @param deviceContext not used in the GLSL kernel
179 template<typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
180 static bool EvalStencils(SRC_BUFFER *srcBuffer,
181 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
182 DST_BUFFER *dstBuffer,
183 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
184 STENCIL_TABLE const *stencilTable,
185 GLComputeEvaluator const *instance,
186 void *deviceContext = nullptr)
189 if (instance) {
190 return instance->EvalStencils(srcBuffer, srcDesc, dstBuffer, dstDesc, stencilTable);
193 // Create an instance on demand (slow)
194 (void)deviceContext; // unused
195 instance = Create(srcDesc,
196 dstDesc,
197 OpenSubdiv::Osd::BufferDescriptor(),
198 OpenSubdiv::Osd::BufferDescriptor());
199 if (instance) {
200 bool r = instance->EvalStencils(srcBuffer, srcDesc, dstBuffer, dstDesc, stencilTable);
201 delete instance;
202 return r;
204 return false;
207 /// \brief Generic static stencil function. This function has a same
208 /// signature as other device kernels have so that it can be called
209 /// transparently from OsdMesh template interface.
211 /// @param srcBuffer Input primvar buffer.
212 /// must have BindVBO() method returning a GL
213 /// buffer object of source data
215 /// @param srcDesc vertex buffer descriptor for the input buffer
217 /// @param dstBuffer Output primvar buffer
218 /// must have BindVBO() method returning a GL
219 /// buffer object of destination data
221 /// @param dstDesc vertex buffer descriptor for the dstBuffer
223 /// @param duBuffer Output buffer derivative wrt u
224 /// must have BindVBO() method returning a GL
225 /// buffer object of destination data
227 /// @param duDesc vertex buffer descriptor for the duBuffer
229 /// @param dvBuffer Output buffer derivative wrt v
230 /// must have BindVBO() method returning a GL
231 /// buffer object of destination data
233 /// @param dvDesc vertex buffer descriptor for the dvBuffer
235 /// @param stencilTable stencil table to be applied. The table must have
236 /// SSBO interfaces.
238 /// @param instance cached compiled instance. Clients are supposed to
239 /// pre-compile an instance of this class and provide
240 /// to this function. If it's null the kernel still
241 /// compute by instantiating on-demand kernel although
242 /// it may cause a performance problem.
244 /// @param deviceContext not used in the GLSL kernel
246 template<typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
247 static bool EvalStencils(SRC_BUFFER *srcBuffer,
248 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
249 DST_BUFFER *dstBuffer,
250 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
251 DST_BUFFER *duBuffer,
252 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
253 DST_BUFFER *dvBuffer,
254 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
255 STENCIL_TABLE const *stencilTable,
256 GLComputeEvaluator const *instance,
257 void *deviceContext = nullptr)
260 if (instance) {
261 return instance->EvalStencils(srcBuffer,
262 srcDesc,
263 dstBuffer,
264 dstDesc,
265 duBuffer,
266 duDesc,
267 dvBuffer,
268 dvDesc,
269 stencilTable);
272 // Create an instance on demand (slow)
273 (void)deviceContext; // unused
274 instance = Create(srcDesc, dstDesc, duDesc, dvDesc);
275 if (instance) {
276 bool r = instance->EvalStencils(srcBuffer,
277 srcDesc,
278 dstBuffer,
279 dstDesc,
280 duBuffer,
281 duDesc,
282 dvBuffer,
283 dvDesc,
284 stencilTable);
285 delete instance;
286 return r;
288 return false;
291 /// \brief Generic static stencil function. This function has a same
292 /// signature as other device kernels have so that it can be called
293 /// transparently from OsdMesh template interface.
295 /// @param srcBuffer Input primvar buffer.
296 /// must have BindVBO() method returning a GL
297 /// buffer object of source data
299 /// @param srcDesc vertex buffer descriptor for the input buffer
301 /// @param dstBuffer Output primvar buffer
302 /// must have BindVBO() method returning a GL
303 /// buffer object of destination data
305 /// @param dstDesc vertex buffer descriptor for the dstBuffer
307 /// @param duBuffer Output buffer derivative wrt u
308 /// must have BindVBO() method returning a GL
309 /// buffer object of destination data
311 /// @param duDesc vertex buffer descriptor for the duBuffer
313 /// @param dvBuffer Output buffer derivative wrt v
314 /// must have BindVBO() method returning a GL
315 /// buffer object of destination data
317 /// @param dvDesc vertex buffer descriptor for the dvBuffer
319 /// @param duuBuffer Output buffer 2nd derivative wrt u
320 /// must have BindVBO() method returning a GL
321 /// buffer object of destination data
323 /// @param duuDesc vertex buffer descriptor for the duuBuffer
325 /// @param duvBuffer Output buffer 2nd derivative wrt u and v
326 /// must have BindVBO() method returning a GL
327 /// buffer object of destination data
329 /// @param duvDesc vertex buffer descriptor for the duvBuffer
331 /// @param dvvBuffer Output buffer 2nd derivative wrt v
332 /// must have BindVBO() method returning a GL
333 /// buffer object of destination data
335 /// @param dvvDesc vertex buffer descriptor for the dvvBuffer
337 /// @param stencilTable stencil table to be applied. The table must have
338 /// SSBO interfaces.
340 /// @param instance cached compiled instance. Clients are supposed to
341 /// pre-compile an instance of this class and provide
342 /// to this function. If it's null the kernel still
343 /// compute by instantiating on-demand kernel although
344 /// it may cause a performance problem.
346 /// @param deviceContext not used in the GLSL kernel
348 template<typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
349 static bool EvalStencils(SRC_BUFFER *srcBuffer,
350 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
351 DST_BUFFER *dstBuffer,
352 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
353 DST_BUFFER *duBuffer,
354 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
355 DST_BUFFER *dvBuffer,
356 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
357 DST_BUFFER *duuBuffer,
358 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
359 DST_BUFFER *duvBuffer,
360 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
361 DST_BUFFER *dvvBuffer,
362 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
363 STENCIL_TABLE const *stencilTable,
364 GLComputeEvaluator const *instance,
365 void *deviceContext = nullptr)
368 if (instance) {
369 return instance->EvalStencils(srcBuffer,
370 srcDesc,
371 dstBuffer,
372 dstDesc,
373 duBuffer,
374 duDesc,
375 dvBuffer,
376 dvDesc,
377 duuBuffer,
378 duuDesc,
379 duvBuffer,
380 duvDesc,
381 dvvBuffer,
382 dvvDesc,
383 stencilTable);
386 // Create an instance on demand (slow)
387 (void)deviceContext; // unused
388 instance = Create(srcDesc, dstDesc, duDesc, dvDesc, duuDesc, duvDesc, dvvDesc);
389 if (instance) {
390 bool r = instance->EvalStencils(srcBuffer,
391 srcDesc,
392 dstBuffer,
393 dstDesc,
394 duBuffer,
395 duDesc,
396 dvBuffer,
397 dvDesc,
398 duuBuffer,
399 duuDesc,
400 duvBuffer,
401 duvDesc,
402 dvvBuffer,
403 dvvDesc,
404 stencilTable);
405 delete instance;
406 return r;
408 return false;
411 /// \brief Generic stencil function.
413 /// @param srcBuffer Input primvar buffer.
414 /// must have BindVBO() method returning a GL
415 /// buffer object of source data
417 /// @param srcDesc vertex buffer descriptor for the input buffer
419 /// @param dstBuffer Output primvar buffer
420 /// must have BindVBO() method returning a GL
421 /// buffer object of destination data
423 /// @param dstDesc vertex buffer descriptor for the output buffer
425 /// @param stencilTable stencil table to be applied. The table must have
426 /// SSBO interfaces.
428 template<typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
429 bool EvalStencils(SRC_BUFFER *srcBuffer,
430 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
431 DST_BUFFER *dstBuffer,
432 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
433 STENCIL_TABLE const *stencilTable) const
435 return EvalStencils(srcBuffer->BindVBO(),
436 srcDesc,
437 dstBuffer->BindVBO(),
438 dstDesc,
440 OpenSubdiv::Osd::BufferDescriptor(),
442 OpenSubdiv::Osd::BufferDescriptor(),
443 stencilTable->GetSizesBuffer(),
444 stencilTable->GetOffsetsBuffer(),
445 stencilTable->GetIndicesBuffer(),
446 stencilTable->GetWeightsBuffer(),
449 /* start = */ 0,
450 /* end = */ stencilTable->GetNumStencils());
453 /// \brief Generic stencil function.
455 /// @param srcBuffer Input primvar buffer.
456 /// must have BindVBO() method returning a GL
457 /// buffer object of source data
459 /// @param srcDesc vertex buffer descriptor for the input buffer
461 /// @param dstBuffer Output primvar buffer
462 /// must have BindVBO() method returning a GL
463 /// buffer object of destination data
465 /// @param dstDesc vertex buffer descriptor for the dstBuffer
467 /// @param duBuffer Output buffer derivative wrt u
468 /// must have BindVBO() method returning a GL
469 /// buffer object of destination data
471 /// @param duDesc vertex buffer descriptor for the duBuffer
473 /// @param dvBuffer Output buffer derivative wrt v
474 /// must have BindVBO() method returning a GL
475 /// buffer object of destination data
477 /// @param dvDesc vertex buffer descriptor for the dvBuffer
479 /// @param stencilTable stencil table to be applied. The table must have
480 /// SSBO interfaces.
482 template<typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
483 bool EvalStencils(SRC_BUFFER *srcBuffer,
484 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
485 DST_BUFFER *dstBuffer,
486 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
487 DST_BUFFER *duBuffer,
488 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
489 DST_BUFFER *dvBuffer,
490 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
491 STENCIL_TABLE const *stencilTable) const
493 return EvalStencils(srcBuffer->BindVBO(),
494 srcDesc,
495 dstBuffer->BindVBO(),
496 dstDesc,
497 duBuffer->BindVBO(),
498 duDesc,
499 dvBuffer->BindVBO(),
500 dvDesc,
501 stencilTable->GetSizesBuffer(),
502 stencilTable->GetOffsetsBuffer(),
503 stencilTable->GetIndicesBuffer(),
504 stencilTable->GetWeightsBuffer(),
505 stencilTable->GetDuWeightsBuffer(),
506 stencilTable->GetDvWeightsBuffer(),
507 /* start = */ 0,
508 /* end = */ stencilTable->GetNumStencils());
511 /// \brief Generic stencil function.
513 /// @param srcBuffer Input primvar buffer.
514 /// must have BindVBO() method returning a GL
515 /// buffer object of source data
517 /// @param srcDesc vertex buffer descriptor for the input buffer
519 /// @param dstBuffer Output primvar buffer
520 /// must have BindVBO() method returning a GL
521 /// buffer object of destination data
523 /// @param dstDesc vertex buffer descriptor for the dstBuffer
525 /// @param duBuffer Output buffer derivative wrt u
526 /// must have BindVBO() method returning a GL
527 /// buffer object of destination data
529 /// @param duDesc vertex buffer descriptor for the duBuffer
531 /// @param dvBuffer Output buffer derivative wrt v
532 /// must have BindVBO() method returning a GL
533 /// buffer object of destination data
535 /// @param dvDesc vertex buffer descriptor for the dvBuffer
537 /// @param duuBuffer Output buffer 2nd derivative wrt u
538 /// must have BindVBO() method returning a GL
539 /// buffer object of destination data
541 /// @param duuDesc vertex buffer descriptor for the duuBuffer
543 /// @param duvBuffer Output buffer 2nd derivative wrt u and v
544 /// must have BindVBO() method returning a GL
545 /// buffer object of destination data
547 /// @param duvDesc vertex buffer descriptor for the duvBuffer
549 /// @param dvvBuffer Output buffer 2nd derivative wrt v
550 /// must have BindVBO() method returning a GL
551 /// buffer object of destination data
553 /// @param dvvDesc vertex buffer descriptor for the dvvBuffer
555 /// @param stencilTable stencil table to be applied. The table must have
556 /// SSBO interfaces.
558 template<typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
559 bool EvalStencils(SRC_BUFFER *srcBuffer,
560 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
561 DST_BUFFER *dstBuffer,
562 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
563 DST_BUFFER *duBuffer,
564 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
565 DST_BUFFER *dvBuffer,
566 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
567 DST_BUFFER *duuBuffer,
568 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
569 DST_BUFFER *duvBuffer,
570 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
571 DST_BUFFER *dvvBuffer,
572 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
573 STENCIL_TABLE const *stencilTable) const
575 return EvalStencils(srcBuffer->BindVBO(),
576 srcDesc,
577 dstBuffer->BindVBO(),
578 dstDesc,
579 duBuffer->BindVBO(),
580 duDesc,
581 dvBuffer->BindVBO(),
582 dvDesc,
583 duuBuffer->BindVBO(),
584 duuDesc,
585 duvBuffer->BindVBO(),
586 duvDesc,
587 dvvBuffer->BindVBO(),
588 dvvDesc,
589 stencilTable->GetSizesBuffer(),
590 stencilTable->GetOffsetsBuffer(),
591 stencilTable->GetIndicesBuffer(),
592 stencilTable->GetWeightsBuffer(),
593 stencilTable->GetDuWeightsBuffer(),
594 stencilTable->GetDvWeightsBuffer(),
595 stencilTable->GetDuuWeightsBuffer(),
596 stencilTable->GetDuvWeightsBuffer(),
597 stencilTable->GetDvvWeightsBuffer(),
598 /* start = */ 0,
599 /* end = */ stencilTable->GetNumStencils());
602 /// \brief Dispatch the GLSL compute kernel on GPU asynchronously
603 /// returns false if the kernel hasn't been compiled yet.
605 /// @param srcBuffer GL buffer of input primvar source data
607 /// @param srcDesc vertex buffer descriptor for the srcBuffer
609 /// @param dstBuffer GL buffer of output primvar destination data
611 /// @param dstDesc vertex buffer descriptor for the dstBuffer
613 /// @param duBuffer GL buffer of output derivative wrt u
615 /// @param duDesc vertex buffer descriptor for the duBuffer
617 /// @param dvBuffer GL buffer of output derivative wrt v
619 /// @param dvDesc vertex buffer descriptor for the dvBuffer
621 /// @param sizesBuffer GL buffer of the sizes in the stencil table
623 /// @param offsetsBuffer GL buffer of the offsets in the stencil table
625 /// @param indicesBuffer GL buffer of the indices in the stencil table
627 /// @param weightsBuffer GL buffer of the weights in the stencil table
629 /// @param duWeightsBuffer GL buffer of the du weights in the stencil table
631 /// @param dvWeightsBuffer GL buffer of the dv weights in the stencil table
633 /// @param start start index of stencil table
635 /// @param end end index of stencil table
637 bool EvalStencils(GLuint srcBuffer,
638 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
639 GLuint dstBuffer,
640 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
641 GLuint duBuffer,
642 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
643 GLuint dvBuffer,
644 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
645 GLuint sizesBuffer,
646 GLuint offsetsBuffer,
647 GLuint indicesBuffer,
648 GLuint weightsBuffer,
649 GLuint duWeightsBuffer,
650 GLuint dvWeightsBuffer,
651 int start,
652 int end) const;
654 /// \brief Dispatch the GLSL compute kernel on GPU asynchronously
655 /// returns false if the kernel hasn't been compiled yet.
657 /// @param srcBuffer GL buffer of input primvar source data
659 /// @param srcDesc vertex buffer descriptor for the srcBuffer
661 /// @param dstBuffer GL buffer of output primvar destination data
663 /// @param dstDesc vertex buffer descriptor for the dstBuffer
665 /// @param duBuffer GL buffer of output derivative wrt u
667 /// @param duDesc vertex buffer descriptor for the duBuffer
669 /// @param dvBuffer GL buffer of output derivative wrt v
671 /// @param dvDesc vertex buffer descriptor for the dvBuffer
673 /// @param duuBuffer GL buffer of output 2nd derivative wrt u
675 /// @param duuDesc vertex buffer descriptor for the duuBuffer
677 /// @param duvBuffer GL buffer of output 2nd derivative wrt u and v
679 /// @param duvDesc vertex buffer descriptor for the duvBuffer
681 /// @param dvvBuffer GL buffer of output 2nd derivative wrt v
683 /// @param dvvDesc vertex buffer descriptor for the dvvBuffer
685 /// @param sizesBuffer GL buffer of the sizes in the stencil table
687 /// @param offsetsBuffer GL buffer of the offsets in the stencil table
689 /// @param indicesBuffer GL buffer of the indices in the stencil table
691 /// @param weightsBuffer GL buffer of the weights in the stencil table
693 /// @param duWeightsBuffer GL buffer of the du weights in the stencil table
695 /// @param dvWeightsBuffer GL buffer of the dv weights in the stencil table
697 /// @param duuWeightsBuffer GL buffer of the duu weights in the stencil table
699 /// @param duvWeightsBuffer GL buffer of the duv weights in the stencil table
701 /// @param dvvWeightsBuffer GL buffer of the dvv weights in the stencil table
703 /// @param start start index of stencil table
705 /// @param end end index of stencil table
707 bool EvalStencils(GLuint srcBuffer,
708 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
709 GLuint dstBuffer,
710 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
711 GLuint duBuffer,
712 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
713 GLuint dvBuffer,
714 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
715 GLuint duuBuffer,
716 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
717 GLuint duvBuffer,
718 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
719 GLuint dvvBuffer,
720 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
721 GLuint sizesBuffer,
722 GLuint offsetsBuffer,
723 GLuint indicesBuffer,
724 GLuint weightsBuffer,
725 GLuint duWeightsBuffer,
726 GLuint dvWeightsBuffer,
727 GLuint duuWeightsBuffer,
728 GLuint duvWeightsBuffer,
729 GLuint dvvWeightsBuffer,
730 int start,
731 int end) const;
733 /// ----------------------------------------------------------------------
735 /// Limit evaluations with PatchTable
737 /// ----------------------------------------------------------------------
739 /// \brief Generic limit eval function. This function has a same
740 /// signature as other device kernels have so that it can be called
741 /// in the same way.
743 /// @param srcBuffer Input primvar buffer.
744 /// must have BindVBO() method returning a GL
745 /// buffer object of source data
747 /// @param srcDesc vertex buffer descriptor for the input buffer
749 /// @param dstBuffer Output primvar buffer
750 /// must have BindVBO() method returning a GL
751 /// buffer object of destination data
753 /// @param dstDesc vertex buffer descriptor for the output buffer
755 /// @param numPatchCoords number of patchCoords.
757 /// @param patchCoords array of locations to be evaluated.
758 /// must have BindVBO() method returning an
759 /// array of PatchCoord struct in VBO.
761 /// @param patchTable GLPatchTable or equivalent
763 /// @param instance cached compiled instance. Clients are supposed to
764 /// pre-compile an instance of this class and provide
765 /// to this function. If it's null the kernel still
766 /// compute by instantiating on-demand kernel although
767 /// it may cause a performance problem.
769 /// @param deviceContext not used in the GLXFB evaluator
771 template<typename SRC_BUFFER,
772 typename DST_BUFFER,
773 typename PATCHCOORD_BUFFER,
774 typename PATCH_TABLE>
775 static bool EvalPatches(SRC_BUFFER *srcBuffer,
776 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
777 DST_BUFFER *dstBuffer,
778 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
779 int numPatchCoords,
780 PATCHCOORD_BUFFER *patchCoords,
781 PATCH_TABLE *patchTable,
782 GLComputeEvaluator const *instance,
783 void *deviceContext = nullptr)
786 if (instance) {
787 return instance->EvalPatches(
788 srcBuffer, srcDesc, dstBuffer, dstDesc, numPatchCoords, patchCoords, patchTable);
790 // Create an instance on demand (slow)
791 (void)deviceContext; // unused
792 instance = Create(srcDesc,
793 dstDesc,
794 OpenSubdiv::Osd::BufferDescriptor(),
795 OpenSubdiv::Osd::BufferDescriptor());
796 if (instance) {
797 bool r = instance->EvalPatches(
798 srcBuffer, srcDesc, dstBuffer, dstDesc, numPatchCoords, patchCoords, patchTable);
799 delete instance;
800 return r;
802 return false;
805 /// \brief Generic limit eval function. This function has a same
806 /// signature as other device kernels have so that it can be called
807 /// in the same way.
809 /// @param srcBuffer Input primvar buffer.
810 /// must have BindVBO() method returning a GL
811 /// buffer object of source data
813 /// @param srcDesc vertex buffer descriptor for the input buffer
815 /// @param dstBuffer Output primvar buffer
816 /// must have BindVBO() method returning a GL
817 /// buffer object of destination data
819 /// @param dstDesc vertex buffer descriptor for the output buffer
821 /// @param duBuffer Output buffer derivative wrt u
822 /// must have BindVBO() method returning a GL
823 /// buffer object of destination data
825 /// @param duDesc vertex buffer descriptor for the duBuffer
827 /// @param dvBuffer Output buffer derivative wrt v
828 /// must have BindVBO() method returning a GL
829 /// buffer object of destination data
831 /// @param dvDesc vertex buffer descriptor for the dvBuffer
833 /// @param numPatchCoords number of patchCoords.
835 /// @param patchCoords array of locations to be evaluated.
836 /// must have BindVBO() method returning an
837 /// array of PatchCoord struct in VBO.
839 /// @param patchTable GLPatchTable or equivalent
841 /// @param instance cached compiled instance. Clients are supposed to
842 /// pre-compile an instance of this class and provide
843 /// to this function. If it's null the kernel still
844 /// compute by instantiating on-demand kernel although
845 /// it may cause a performance problem.
847 /// @param deviceContext not used in the GLXFB evaluator
849 template<typename SRC_BUFFER,
850 typename DST_BUFFER,
851 typename PATCHCOORD_BUFFER,
852 typename PATCH_TABLE>
853 static bool EvalPatches(SRC_BUFFER *srcBuffer,
854 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
855 DST_BUFFER *dstBuffer,
856 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
857 DST_BUFFER *duBuffer,
858 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
859 DST_BUFFER *dvBuffer,
860 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
861 int numPatchCoords,
862 PATCHCOORD_BUFFER *patchCoords,
863 PATCH_TABLE *patchTable,
864 GLComputeEvaluator const *instance,
865 void *deviceContext = nullptr)
867 if (instance) {
868 return instance->EvalPatches(srcBuffer,
869 srcDesc,
870 dstBuffer,
871 dstDesc,
872 duBuffer,
873 duDesc,
874 dvBuffer,
875 dvDesc,
876 numPatchCoords,
877 patchCoords,
878 patchTable);
881 // Create an instance on demand (slow)
882 (void)deviceContext; // unused
883 instance = Create(srcDesc, dstDesc, duDesc, dvDesc);
884 if (instance) {
885 bool r = instance->EvalPatches(srcBuffer,
886 srcDesc,
887 dstBuffer,
888 dstDesc,
889 duBuffer,
890 duDesc,
891 dvBuffer,
892 dvDesc,
893 numPatchCoords,
894 patchCoords,
895 patchTable);
896 delete instance;
897 return r;
899 return false;
902 /// \brief Generic limit eval function. This function has a same
903 /// signature as other device kernels have so that it can be called
904 /// in the same way.
906 /// @param srcBuffer Input primvar buffer.
907 /// must have BindVBO() method returning a GL
908 /// buffer object of source data
910 /// @param srcDesc vertex buffer descriptor for the input buffer
912 /// @param dstBuffer Output primvar buffer
913 /// must have BindVBO() method returning a GL
914 /// buffer object of destination data
916 /// @param dstDesc vertex buffer descriptor for the output buffer
918 /// @param duBuffer Output buffer derivative wrt u
919 /// must have BindVBO() method returning a GL
920 /// buffer object of destination data
922 /// @param duDesc vertex buffer descriptor for the duBuffer
924 /// @param dvBuffer Output buffer derivative wrt v
925 /// must have BindVBO() method returning a GL
926 /// buffer object of destination data
928 /// @param dvDesc vertex buffer descriptor for the dvBuffer
930 /// @param duuBuffer Output buffer 2nd derivative wrt u
931 /// must have BindVBO() method returning a GL
932 /// buffer object of destination data
934 /// @param duuDesc vertex buffer descriptor for the duuBuffer
936 /// @param duvBuffer Output buffer 2nd derivative wrt u and v
937 /// must have BindVBO() method returning a GL
938 /// buffer object of destination data
940 /// @param duvDesc vertex buffer descriptor for the duvBuffer
942 /// @param dvvBuffer Output buffer 2nd derivative wrt v
943 /// must have BindVBO() method returning a GL
944 /// buffer object of destination data
946 /// @param dvvDesc vertex buffer descriptor for the dvvBuffer
948 /// @param numPatchCoords number of patchCoords.
950 /// @param patchCoords array of locations to be evaluated.
951 /// must have BindVBO() method returning an
952 /// array of PatchCoord struct in VBO.
954 /// @param patchTable GLPatchTable or equivalent
956 /// @param instance cached compiled instance. Clients are supposed to
957 /// pre-compile an instance of this class and provide
958 /// to this function. If it's null the kernel still
959 /// compute by instantiating on-demand kernel although
960 /// it may cause a performance problem.
962 /// @param deviceContext not used in the GLXFB evaluator
964 template<typename SRC_BUFFER,
965 typename DST_BUFFER,
966 typename PATCHCOORD_BUFFER,
967 typename PATCH_TABLE>
968 static bool EvalPatches(SRC_BUFFER *srcBuffer,
969 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
970 DST_BUFFER *dstBuffer,
971 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
972 DST_BUFFER *duBuffer,
973 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
974 DST_BUFFER *dvBuffer,
975 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
976 DST_BUFFER *duuBuffer,
977 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
978 DST_BUFFER *duvBuffer,
979 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
980 DST_BUFFER *dvvBuffer,
981 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
982 int numPatchCoords,
983 PATCHCOORD_BUFFER *patchCoords,
984 PATCH_TABLE *patchTable,
985 GLComputeEvaluator const *instance,
986 void *deviceContext = nullptr)
988 if (instance) {
989 return instance->EvalPatches(srcBuffer,
990 srcDesc,
991 dstBuffer,
992 dstDesc,
993 duBuffer,
994 duDesc,
995 dvBuffer,
996 dvDesc,
997 duuBuffer,
998 duuDesc,
999 duvBuffer,
1000 duvDesc,
1001 dvvBuffer,
1002 dvvDesc,
1003 numPatchCoords,
1004 patchCoords,
1005 patchTable);
1008 // Create an instance on demand (slow)
1009 (void)deviceContext; // unused
1010 instance = Create(srcDesc, dstDesc, duDesc, dvDesc, duuDesc, duvDesc, dvvDesc);
1011 if (instance) {
1012 bool r = instance->EvalPatches(srcBuffer,
1013 srcDesc,
1014 dstBuffer,
1015 dstDesc,
1016 duBuffer,
1017 duDesc,
1018 dvBuffer,
1019 dvDesc,
1020 duuBuffer,
1021 duuDesc,
1022 duvBuffer,
1023 duvDesc,
1024 dvvBuffer,
1025 dvvDesc,
1026 numPatchCoords,
1027 patchCoords,
1028 patchTable);
1029 delete instance;
1030 return r;
1032 return false;
1035 /// \brief Generic limit eval function. This function has a same
1036 /// signature as other device kernels have so that it can be called
1037 /// in the same way.
1039 /// @param srcBuffer Input primvar buffer.
1040 /// must have BindVBO() method returning a GL
1041 /// buffer object of source data
1043 /// @param srcDesc vertex buffer descriptor for the input buffer
1045 /// @param dstBuffer Output primvar buffer
1046 /// must have BindVBO() method returning a GL
1047 /// buffer object of destination data
1049 /// @param dstDesc vertex buffer descriptor for the output buffer
1051 /// @param numPatchCoords number of patchCoords.
1053 /// @param patchCoords array of locations to be evaluated.
1054 /// must have BindVBO() method returning an
1055 /// array of PatchCoord struct in VBO.
1057 /// @param patchTable GLPatchTable or equivalent
1059 template<typename SRC_BUFFER,
1060 typename DST_BUFFER,
1061 typename PATCHCOORD_BUFFER,
1062 typename PATCH_TABLE>
1063 bool EvalPatches(SRC_BUFFER *srcBuffer,
1064 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1065 DST_BUFFER *dstBuffer,
1066 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1067 int numPatchCoords,
1068 PATCHCOORD_BUFFER *patchCoords,
1069 PATCH_TABLE *patchTable) const
1072 return EvalPatches(srcBuffer->BindVBO(),
1073 srcDesc,
1074 dstBuffer->BindVBO(),
1075 dstDesc,
1077 OpenSubdiv::Osd::BufferDescriptor(),
1079 OpenSubdiv::Osd::BufferDescriptor(),
1080 numPatchCoords,
1081 patchCoords->BindVBO(),
1082 patchTable->GetPatchArrays(),
1083 patchTable->GetPatchIndexBuffer(),
1084 patchTable->GetPatchParamBuffer());
1087 /// \brief Generic limit eval function with derivatives. This function has
1088 /// a same signature as other device kernels have so that it can be
1089 /// called in the same way.
1091 /// @param srcBuffer Input primvar buffer.
1092 /// must have BindVBO() method returning a GL
1093 /// buffer object of source data
1095 /// @param srcDesc vertex buffer descriptor for the input buffer
1097 /// @param dstBuffer Output primvar buffer
1098 /// must have BindVBO() method returning a GL
1099 /// buffer object of destination data
1101 /// @param dstDesc vertex buffer descriptor for the output buffer
1103 /// @param duBuffer Output buffer derivative wrt u
1104 /// must have BindVBO() method returning a GL
1105 /// buffer object of destination data
1107 /// @param duDesc vertex buffer descriptor for the duBuffer
1109 /// @param dvBuffer Output buffer derivative wrt v
1110 /// must have BindVBO() method returning a GL
1111 /// buffer object of destination data
1113 /// @param dvDesc vertex buffer descriptor for the dvBuffer
1115 /// @param numPatchCoords number of patchCoords.
1117 /// @param patchCoords array of locations to be evaluated.
1119 /// @param patchTable GLPatchTable or equivalent
1121 template<typename SRC_BUFFER,
1122 typename DST_BUFFER,
1123 typename PATCHCOORD_BUFFER,
1124 typename PATCH_TABLE>
1125 bool EvalPatches(SRC_BUFFER *srcBuffer,
1126 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1127 DST_BUFFER *dstBuffer,
1128 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1129 DST_BUFFER *duBuffer,
1130 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
1131 DST_BUFFER *dvBuffer,
1132 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
1133 int numPatchCoords,
1134 PATCHCOORD_BUFFER *patchCoords,
1135 PATCH_TABLE *patchTable) const
1138 return EvalPatches(srcBuffer->BindVBO(),
1139 srcDesc,
1140 dstBuffer->BindVBO(),
1141 dstDesc,
1142 duBuffer->BindVBO(),
1143 duDesc,
1144 dvBuffer->BindVBO(),
1145 dvDesc,
1146 numPatchCoords,
1147 patchCoords->BindVBO(),
1148 patchTable->GetPatchArrays(),
1149 patchTable->GetPatchIndexBuffer(),
1150 patchTable->GetPatchParamBuffer());
1153 /// \brief Generic limit eval function with derivatives. This function has
1154 /// a same signature as other device kernels have so that it can be
1155 /// called in the same way.
1157 /// @param srcBuffer Input primvar buffer.
1158 /// must have BindVBO() method returning a GL
1159 /// buffer object of source data
1161 /// @param srcDesc vertex buffer descriptor for the input buffer
1163 /// @param dstBuffer Output primvar buffer
1164 /// must have BindVBO() method returning a GL
1165 /// buffer object of destination data
1167 /// @param dstDesc vertex buffer descriptor for the output buffer
1169 /// @param duBuffer Output buffer derivative wrt u
1170 /// must have BindVBO() method returning a GL
1171 /// buffer object of destination data
1173 /// @param duDesc vertex buffer descriptor for the duBuffer
1175 /// @param dvBuffer Output buffer derivative wrt v
1176 /// must have BindVBO() method returning a GL
1177 /// buffer object of destination data
1179 /// @param dvDesc vertex buffer descriptor for the dvBuffer
1181 /// @param duuBuffer Output buffer 2nd derivative wrt u
1182 /// must have BindVBO() method returning a GL
1183 /// buffer object of destination data
1185 /// @param duuDesc vertex buffer descriptor for the duuBuffer
1187 /// @param duvBuffer Output buffer 2nd derivative wrt u and v
1188 /// must have BindVBO() method returning a GL
1189 /// buffer object of destination data
1191 /// @param duvDesc vertex buffer descriptor for the duvBuffer
1193 /// @param dvvBuffer Output buffer 2nd derivative wrt v
1194 /// must have BindVBO() method returning a GL
1195 /// buffer object of destination data
1197 /// @param dvvDesc vertex buffer descriptor for the dvvBuffer
1199 /// @param numPatchCoords number of patchCoords.
1201 /// @param patchCoords array of locations to be evaluated.
1203 /// @param patchTable GLPatchTable or equivalent
1205 template<typename SRC_BUFFER,
1206 typename DST_BUFFER,
1207 typename PATCHCOORD_BUFFER,
1208 typename PATCH_TABLE>
1209 bool EvalPatches(SRC_BUFFER *srcBuffer,
1210 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1211 DST_BUFFER *dstBuffer,
1212 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1213 DST_BUFFER *duBuffer,
1214 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
1215 DST_BUFFER *dvBuffer,
1216 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
1217 DST_BUFFER *duuBuffer,
1218 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
1219 DST_BUFFER *duvBuffer,
1220 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
1221 DST_BUFFER *dvvBuffer,
1222 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
1223 int numPatchCoords,
1224 PATCHCOORD_BUFFER *patchCoords,
1225 PATCH_TABLE *patchTable) const
1228 return EvalPatches(srcBuffer->BindVBO(),
1229 srcDesc,
1230 dstBuffer->BindVBO(),
1231 dstDesc,
1232 duBuffer->BindVBO(),
1233 duDesc,
1234 dvBuffer->BindVBO(),
1235 dvDesc,
1236 duuBuffer->BindVBO(),
1237 duuDesc,
1238 duvBuffer->BindVBO(),
1239 duvDesc,
1240 dvvBuffer->BindVBO(),
1241 dvvDesc,
1242 numPatchCoords,
1243 patchCoords->BindVBO(),
1244 patchTable->GetPatchArrays(),
1245 patchTable->GetPatchIndexBuffer(),
1246 patchTable->GetPatchParamBuffer());
1249 bool EvalPatches(GLuint srcBuffer,
1250 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1251 GLuint dstBuffer,
1252 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1253 GLuint duBuffer,
1254 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
1255 GLuint dvBuffer,
1256 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
1257 int numPatchCoords,
1258 GLuint patchCoordsBuffer,
1259 const OpenSubdiv::Osd::PatchArrayVector &patchArrays,
1260 GLuint patchIndexBuffer,
1261 GLuint patchParamsBuffer) const;
1263 bool EvalPatches(GLuint srcBuffer,
1264 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1265 GLuint dstBuffer,
1266 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1267 GLuint duBuffer,
1268 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
1269 GLuint dvBuffer,
1270 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
1271 GLuint duuBuffer,
1272 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
1273 GLuint duvBuffer,
1274 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
1275 GLuint dvvBuffer,
1276 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
1277 int numPatchCoords,
1278 GLuint patchCoordsBuffer,
1279 const OpenSubdiv::Osd::PatchArrayVector &patchArrays,
1280 GLuint patchIndexBuffer,
1281 GLuint patchParamsBuffer) const;
1283 /// \brief Generic limit eval function. This function has a same
1284 /// signature as other device kernels have so that it can be called
1285 /// in the same way.
1287 /// @param srcBuffer Input primvar buffer.
1288 /// must have BindVBO() method returning a GL
1289 /// buffer object of source data
1291 /// @param srcDesc vertex buffer descriptor for the input buffer
1293 /// @param dstBuffer Output primvar buffer
1294 /// must have BindVBO() method returning a GL
1295 /// buffer object of destination data
1297 /// @param dstDesc vertex buffer descriptor for the output buffer
1299 /// @param numPatchCoords number of patchCoords.
1301 /// @param patchCoords array of locations to be evaluated.
1302 /// must have BindVBO() method returning an
1303 /// array of PatchCoord struct in VBO.
1305 /// @param patchTable GLPatchTable or equivalent
1307 /// @param instance cached compiled instance. Clients are supposed to
1308 /// pre-compile an instance of this class and provide
1309 /// to this function. If it's null the kernel still
1310 /// compute by instantiating on-demand kernel although
1311 /// it may cause a performance problem.
1313 /// @param deviceContext not used in the GLXFB evaluator
1315 template<typename SRC_BUFFER,
1316 typename DST_BUFFER,
1317 typename PATCHCOORD_BUFFER,
1318 typename PATCH_TABLE>
1319 static bool EvalPatchesVarying(SRC_BUFFER *srcBuffer,
1320 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1321 DST_BUFFER *dstBuffer,
1322 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1323 int numPatchCoords,
1324 PATCHCOORD_BUFFER *patchCoords,
1325 PATCH_TABLE *patchTable,
1326 GLComputeEvaluator const *instance,
1327 void *deviceContext = nullptr)
1329 if (instance) {
1330 return instance->EvalPatchesVarying(
1331 srcBuffer, srcDesc, dstBuffer, dstDesc, numPatchCoords, patchCoords, patchTable);
1334 // Create an instance on demand (slow)
1335 (void)deviceContext; // unused
1336 instance = Create(srcDesc,
1337 dstDesc,
1338 OpenSubdiv::Osd::BufferDescriptor(),
1339 OpenSubdiv::Osd::BufferDescriptor());
1340 if (instance) {
1341 bool r = instance->EvalPatchesVarying(
1342 srcBuffer, srcDesc, dstBuffer, dstDesc, numPatchCoords, patchCoords, patchTable);
1343 delete instance;
1344 return r;
1346 return false;
1349 /// \brief Generic limit eval function. This function has a same
1350 /// signature as other device kernels have so that it can be called
1351 /// in the same way.
1353 /// @param srcBuffer Input primvar buffer.
1354 /// must have BindVBO() method returning a GL
1355 /// buffer object of source data
1357 /// @param srcDesc vertex buffer descriptor for the input buffer
1359 /// @param dstBuffer Output primvar buffer
1360 /// must have BindVBO() method returning a GL
1361 /// buffer object of destination data
1363 /// @param dstDesc vertex buffer descriptor for the output buffer
1365 /// @param numPatchCoords number of patchCoords.
1367 /// @param patchCoords array of locations to be evaluated.
1368 /// must have BindVBO() method returning an
1369 /// array of PatchCoord struct in VBO.
1371 /// @param patchTable GLPatchTable or equivalent
1373 template<typename SRC_BUFFER,
1374 typename DST_BUFFER,
1375 typename PATCHCOORD_BUFFER,
1376 typename PATCH_TABLE>
1377 bool EvalPatchesVarying(SRC_BUFFER *srcBuffer,
1378 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1379 DST_BUFFER *dstBuffer,
1380 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1381 int numPatchCoords,
1382 PATCHCOORD_BUFFER *patchCoords,
1383 PATCH_TABLE *patchTable) const
1386 return EvalPatches(srcBuffer->BindVBO(),
1387 srcDesc,
1388 dstBuffer->BindVBO(),
1389 dstDesc,
1391 OpenSubdiv::Osd::BufferDescriptor(),
1393 OpenSubdiv::Osd::BufferDescriptor(),
1394 numPatchCoords,
1395 patchCoords->BindVBO(),
1396 patchTable->GetVaryingPatchArrays(),
1397 patchTable->GetVaryingPatchIndexBuffer(),
1398 patchTable->GetPatchParamBuffer());
1401 /// \brief Generic limit eval function. This function has a same
1402 /// signature as other device kernels have so that it can be called
1403 /// in the same way.
1405 /// @param srcBuffer Input primvar buffer.
1406 /// must have BindVBO() method returning a GL
1407 /// buffer object of source data
1409 /// @param srcDesc vertex buffer descriptor for the input buffer
1411 /// @param dstBuffer Output primvar buffer
1412 /// must have BindVBO() method returning a GL
1413 /// buffer object of destination data
1415 /// @param dstDesc vertex buffer descriptor for the output buffer
1417 /// @param duBuffer Output buffer derivative wrt u
1418 /// must have BindVBO() method returning a GL
1419 /// buffer object of destination data
1421 /// @param duDesc vertex buffer descriptor for the duBuffer
1423 /// @param dvBuffer Output buffer derivative wrt v
1424 /// must have BindVBO() method returning a GL
1425 /// buffer object of destination data
1427 /// @param dvDesc vertex buffer descriptor for the dvBuffer
1429 /// @param numPatchCoords number of patchCoords.
1431 /// @param patchCoords array of locations to be evaluated.
1432 /// must have BindVBO() method returning an
1433 /// array of PatchCoord struct in VBO.
1435 /// @param patchTable GLPatchTable or equivalent
1437 /// @param instance cached compiled instance. Clients are supposed to
1438 /// pre-compile an instance of this class and provide
1439 /// to this function. If it's null the kernel still
1440 /// compute by instantiating on-demand kernel although
1441 /// it may cause a performance problem.
1443 /// @param deviceContext not used in the GLXFB evaluator
1445 template<typename SRC_BUFFER,
1446 typename DST_BUFFER,
1447 typename PATCHCOORD_BUFFER,
1448 typename PATCH_TABLE>
1449 static bool EvalPatchesVarying(SRC_BUFFER *srcBuffer,
1450 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1451 DST_BUFFER *dstBuffer,
1452 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1453 DST_BUFFER *duBuffer,
1454 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
1455 DST_BUFFER *dvBuffer,
1456 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
1457 int numPatchCoords,
1458 PATCHCOORD_BUFFER *patchCoords,
1459 PATCH_TABLE *patchTable,
1460 GLComputeEvaluator const *instance,
1461 void *deviceContext = nullptr)
1463 if (instance) {
1464 return instance->EvalPatchesVarying(srcBuffer,
1465 srcDesc,
1466 dstBuffer,
1467 dstDesc,
1468 duBuffer,
1469 duDesc,
1470 dvBuffer,
1471 dvDesc,
1472 numPatchCoords,
1473 patchCoords,
1474 patchTable);
1477 // Create an instance on demand (slow)
1478 (void)deviceContext; // unused
1479 instance = Create(srcDesc, dstDesc, duDesc, dvDesc);
1480 if (instance) {
1481 bool r = instance->EvalPatchesVarying(srcBuffer,
1482 srcDesc,
1483 dstBuffer,
1484 dstDesc,
1485 duBuffer,
1486 duDesc,
1487 dvBuffer,
1488 dvDesc,
1489 numPatchCoords,
1490 patchCoords,
1491 patchTable);
1492 delete instance;
1493 return r;
1495 return false;
1498 /// \brief Generic limit eval function. This function has a same
1499 /// signature as other device kernels have so that it can be called
1500 /// in the same way.
1502 /// @param srcBuffer Input primvar buffer.
1503 /// must have BindVBO() method returning a GL
1504 /// buffer object of source data
1506 /// @param srcDesc vertex buffer descriptor for the input buffer
1508 /// @param dstBuffer Output primvar buffer
1509 /// must have BindVBO() method returning a GL
1510 /// buffer object of destination data
1512 /// @param dstDesc vertex buffer descriptor for the output buffer
1514 /// @param duBuffer Output buffer derivative wrt u
1515 /// must have BindVBO() method returning a GL
1516 /// buffer object of destination data
1518 /// @param duDesc vertex buffer descriptor for the duBuffer
1520 /// @param dvBuffer Output buffer derivative wrt v
1521 /// must have BindVBO() method returning a GL
1522 /// buffer object of destination data
1524 /// @param dvDesc vertex buffer descriptor for the dvBuffer
1526 /// @param numPatchCoords number of patchCoords.
1528 /// @param patchCoords array of locations to be evaluated.
1529 /// must have BindVBO() method returning an
1530 /// array of PatchCoord struct in VBO.
1532 /// @param patchTable GLPatchTable or equivalent
1534 template<typename SRC_BUFFER,
1535 typename DST_BUFFER,
1536 typename PATCHCOORD_BUFFER,
1537 typename PATCH_TABLE>
1538 bool EvalPatchesVarying(SRC_BUFFER *srcBuffer,
1539 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1540 DST_BUFFER *dstBuffer,
1541 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1542 DST_BUFFER *duBuffer,
1543 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
1544 DST_BUFFER *dvBuffer,
1545 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
1546 int numPatchCoords,
1547 PATCHCOORD_BUFFER *patchCoords,
1548 PATCH_TABLE *patchTable) const
1551 return EvalPatches(srcBuffer->BindVBO(),
1552 srcDesc,
1553 dstBuffer->BindVBO(),
1554 dstDesc,
1555 duBuffer->BindVBO(),
1556 duDesc,
1557 dvBuffer->BindVBO(),
1558 dvDesc,
1559 numPatchCoords,
1560 patchCoords->BindVBO(),
1561 patchTable->GetVaryingPatchArrays(),
1562 patchTable->GetVaryingPatchIndexBuffer(),
1563 patchTable->GetPatchParamBuffer());
1566 /// \brief Generic limit eval function. This function has a same
1567 /// signature as other device kernels have so that it can be called
1568 /// in the same way.
1570 /// @param srcBuffer Input primvar buffer.
1571 /// must have BindVBO() method returning a GL
1572 /// buffer object of source data
1574 /// @param srcDesc vertex buffer descriptor for the input buffer
1576 /// @param dstBuffer Output primvar buffer
1577 /// must have BindVBO() method returning a GL
1578 /// buffer object of destination data
1580 /// @param dstDesc vertex buffer descriptor for the output buffer
1582 /// @param duBuffer Output buffer derivative wrt u
1583 /// must have BindVBO() method returning a GL
1584 /// buffer object of destination data
1586 /// @param duDesc vertex buffer descriptor for the duBuffer
1588 /// @param dvBuffer Output buffer derivative wrt v
1589 /// must have BindVBO() method returning a GL
1590 /// buffer object of destination data
1592 /// @param dvDesc vertex buffer descriptor for the dvBuffer
1594 /// @param duuBuffer Output buffer 2nd derivative wrt u
1595 /// must have BindVBO() method returning a GL
1596 /// buffer object of destination data
1598 /// @param duuDesc vertex buffer descriptor for the duuBuffer
1600 /// @param duvBuffer Output buffer 2nd derivative wrt u and v
1601 /// must have BindVBO() method returning a GL
1602 /// buffer object of destination data
1604 /// @param duvDesc vertex buffer descriptor for the duvBuffer
1606 /// @param dvvBuffer Output buffer 2nd derivative wrt v
1607 /// must have BindVBO() method returning a GL
1608 /// buffer object of destination data
1610 /// @param dvvDesc vertex buffer descriptor for the dvvBuffer
1612 /// @param numPatchCoords number of patchCoords.
1614 /// @param patchCoords array of locations to be evaluated.
1615 /// must have BindVBO() method returning an
1616 /// array of PatchCoord struct in VBO.
1618 /// @param patchTable GLPatchTable or equivalent
1620 /// @param instance cached compiled instance. Clients are supposed to
1621 /// pre-compile an instance of this class and provide
1622 /// to this function. If it's null the kernel still
1623 /// compute by instantiating on-demand kernel although
1624 /// it may cause a performance problem.
1626 /// @param deviceContext not used in the GLXFB evaluator
1628 template<typename SRC_BUFFER,
1629 typename DST_BUFFER,
1630 typename PATCHCOORD_BUFFER,
1631 typename PATCH_TABLE>
1632 static bool EvalPatchesVarying(SRC_BUFFER *srcBuffer,
1633 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1634 DST_BUFFER *dstBuffer,
1635 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1636 DST_BUFFER *duBuffer,
1637 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
1638 DST_BUFFER *dvBuffer,
1639 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
1640 DST_BUFFER *duuBuffer,
1641 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
1642 DST_BUFFER *duvBuffer,
1643 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
1644 DST_BUFFER *dvvBuffer,
1645 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
1646 int numPatchCoords,
1647 PATCHCOORD_BUFFER *patchCoords,
1648 PATCH_TABLE *patchTable,
1649 GLComputeEvaluator const *instance,
1650 void *deviceContext = nullptr)
1652 if (instance) {
1653 return instance->EvalPatchesVarying(srcBuffer,
1654 srcDesc,
1655 dstBuffer,
1656 dstDesc,
1657 duBuffer,
1658 duDesc,
1659 dvBuffer,
1660 dvDesc,
1661 duuBuffer,
1662 duuDesc,
1663 duvBuffer,
1664 duvDesc,
1665 dvvBuffer,
1666 dvvDesc,
1667 numPatchCoords,
1668 patchCoords,
1669 patchTable);
1672 // Create an instance on demand (slow)
1673 (void)deviceContext; // unused
1674 instance = Create(srcDesc, dstDesc, duDesc, dvDesc, duuDesc, duvDesc, dvvDesc);
1675 if (instance) {
1676 bool r = instance->EvalPatchesVarying(srcBuffer,
1677 srcDesc,
1678 dstBuffer,
1679 dstDesc,
1680 duBuffer,
1681 duDesc,
1682 dvBuffer,
1683 dvDesc,
1684 duuBuffer,
1685 duuDesc,
1686 duvBuffer,
1687 duvDesc,
1688 dvvBuffer,
1689 dvvDesc,
1690 numPatchCoords,
1691 patchCoords,
1692 patchTable);
1693 delete instance;
1694 return r;
1696 return false;
1699 /// \brief Generic limit eval function. This function has a same
1700 /// signature as other device kernels have so that it can be called
1701 /// in the same way.
1703 /// @param srcBuffer Input primvar buffer.
1704 /// must have BindVBO() method returning a GL
1705 /// buffer object of source data
1707 /// @param srcDesc vertex buffer descriptor for the input buffer
1709 /// @param dstBuffer Output primvar buffer
1710 /// must have BindVBO() method returning a GL
1711 /// buffer object of destination data
1713 /// @param dstDesc vertex buffer descriptor for the output buffer
1715 /// @param duBuffer Output buffer derivative wrt u
1716 /// must have BindVBO() method returning a GL
1717 /// buffer object of destination data
1719 /// @param duDesc vertex buffer descriptor for the duBuffer
1721 /// @param dvBuffer Output buffer derivative wrt v
1722 /// must have BindVBO() method returning a GL
1723 /// buffer object of destination data
1725 /// @param dvDesc vertex buffer descriptor for the dvBuffer
1727 /// @param duuBuffer Output buffer 2nd derivative wrt u
1728 /// must have BindVBO() method returning a GL
1729 /// buffer object of destination data
1731 /// @param duuDesc vertex buffer descriptor for the duuBuffer
1733 /// @param duvBuffer Output buffer 2nd derivative wrt u and v
1734 /// must have BindVBO() method returning a GL
1735 /// buffer object of destination data
1737 /// @param duvDesc vertex buffer descriptor for the duvBuffer
1739 /// @param dvvBuffer Output buffer 2nd derivative wrt v
1740 /// must have BindVBO() method returning a GL
1741 /// buffer object of destination data
1743 /// @param dvvDesc vertex buffer descriptor for the dvvBuffer
1745 /// @param numPatchCoords number of patchCoords.
1747 /// @param patchCoords array of locations to be evaluated.
1748 /// must have BindVBO() method returning an
1749 /// array of PatchCoord struct in VBO.
1751 /// @param patchTable GLPatchTable or equivalent
1753 template<typename SRC_BUFFER,
1754 typename DST_BUFFER,
1755 typename PATCHCOORD_BUFFER,
1756 typename PATCH_TABLE>
1757 bool EvalPatchesVarying(SRC_BUFFER *srcBuffer,
1758 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1759 DST_BUFFER *dstBuffer,
1760 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1761 DST_BUFFER *duBuffer,
1762 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
1763 DST_BUFFER *dvBuffer,
1764 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
1765 DST_BUFFER *duuBuffer,
1766 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
1767 DST_BUFFER *duvBuffer,
1768 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
1769 DST_BUFFER *dvvBuffer,
1770 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
1771 int numPatchCoords,
1772 PATCHCOORD_BUFFER *patchCoords,
1773 PATCH_TABLE *patchTable) const
1776 return EvalPatches(srcBuffer->BindVBO(),
1777 srcDesc,
1778 dstBuffer->BindVBO(),
1779 dstDesc,
1780 duBuffer->BindVBO(),
1781 duDesc,
1782 dvBuffer->BindVBO(),
1783 dvDesc,
1784 duuBuffer->BindVBO(),
1785 duuDesc,
1786 duvBuffer->BindVBO(),
1787 duvDesc,
1788 dvvBuffer->BindVBO(),
1789 dvvDesc,
1790 numPatchCoords,
1791 patchCoords->BindVBO(),
1792 patchTable->GetVaryingPatchArrays(),
1793 patchTable->GetVaryingPatchIndexBuffer(),
1794 patchTable->GetPatchParamBuffer());
1797 /// \brief Generic limit eval function. This function has a same
1798 /// signature as other device kernels have so that it can be called
1799 /// in the same way.
1801 /// @param srcBuffer Input primvar buffer.
1802 /// must have BindVBO() method returning a GL
1803 /// buffer object of source data
1805 /// @param srcDesc vertex buffer descriptor for the input buffer
1807 /// @param dstBuffer Output primvar buffer
1808 /// must have BindVBO() method returning a GL
1809 /// buffer object of destination data
1811 /// @param dstDesc vertex buffer descriptor for the output buffer
1813 /// @param numPatchCoords number of patchCoords.
1815 /// @param patchCoords array of locations to be evaluated.
1816 /// must have BindVBO() method returning an
1817 /// array of PatchCoord struct in VBO.
1819 /// @param patchTable GLPatchTable or equivalent
1821 /// @param fvarChannel face-varying channel
1823 /// @param instance cached compiled instance. Clients are supposed to
1824 /// pre-compile an instance of this class and provide
1825 /// to this function. If it's null the kernel still
1826 /// compute by instantiating on-demand kernel although
1827 /// it may cause a performance problem.
1829 /// @param deviceContext not used in the GLXFB evaluator
1831 template<typename SRC_BUFFER,
1832 typename DST_BUFFER,
1833 typename PATCHCOORD_BUFFER,
1834 typename PATCH_TABLE>
1835 static bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer,
1836 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1837 DST_BUFFER *dstBuffer,
1838 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1839 int numPatchCoords,
1840 PATCHCOORD_BUFFER *patchCoords,
1841 PATCH_TABLE *patchTable,
1842 int fvarChannel,
1843 GLComputeEvaluator const *instance,
1844 void *deviceContext = nullptr)
1846 if (instance) {
1847 return instance->EvalPatchesFaceVarying(srcBuffer,
1848 srcDesc,
1849 dstBuffer,
1850 dstDesc,
1851 numPatchCoords,
1852 patchCoords,
1853 patchTable,
1854 fvarChannel);
1857 // Create an instance on demand (slow)
1858 (void)deviceContext; // unused
1859 instance = Create(srcDesc,
1860 dstDesc,
1861 OpenSubdiv::Osd::BufferDescriptor(),
1862 OpenSubdiv::Osd::BufferDescriptor());
1863 if (instance) {
1864 bool r = instance->EvalPatchesFaceVarying(srcBuffer,
1865 srcDesc,
1866 dstBuffer,
1867 dstDesc,
1868 numPatchCoords,
1869 patchCoords,
1870 patchTable,
1871 fvarChannel);
1872 delete instance;
1873 return r;
1875 return false;
1878 /// \brief Generic limit eval function. This function has a same
1879 /// signature as other device kernels have so that it can be called
1880 /// in the same way.
1882 /// @param srcBuffer Input primvar buffer.
1883 /// must have BindVBO() method returning a GL
1884 /// buffer object of source data
1886 /// @param srcDesc vertex buffer descriptor for the input buffer
1888 /// @param dstBuffer Output primvar buffer
1889 /// must have BindVBO() method returning a GL
1890 /// buffer object of destination data
1892 /// @param dstDesc vertex buffer descriptor for the output buffer
1894 /// @param numPatchCoords number of patchCoords.
1896 /// @param patchCoords array of locations to be evaluated.
1897 /// must have BindVBO() method returning an
1898 /// array of PatchCoord struct in VBO.
1900 /// @param patchTable GLPatchTable or equivalent
1902 /// @param fvarChannel face-varying channel
1904 template<typename SRC_BUFFER,
1905 typename DST_BUFFER,
1906 typename PATCHCOORD_BUFFER,
1907 typename PATCH_TABLE>
1908 bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer,
1909 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1910 DST_BUFFER *dstBuffer,
1911 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1912 int numPatchCoords,
1913 PATCHCOORD_BUFFER *patchCoords,
1914 PATCH_TABLE *patchTable,
1915 int fvarChannel = 0) const
1918 return EvalPatches(srcBuffer->BindVBO(),
1919 srcDesc,
1920 dstBuffer->BindVBO(),
1921 dstDesc,
1923 OpenSubdiv::Osd::BufferDescriptor(),
1925 OpenSubdiv::Osd::BufferDescriptor(),
1926 numPatchCoords,
1927 patchCoords->BindVBO(),
1928 patchTable->GetFVarPatchArrays(fvarChannel),
1929 patchTable->GetFVarPatchIndexBuffer(fvarChannel),
1930 patchTable->GetFVarPatchParamBuffer(fvarChannel));
1933 /// \brief Generic limit eval function. This function has a same
1934 /// signature as other device kernels have so that it can be called
1935 /// in the same way.
1937 /// @param srcBuffer Input primvar buffer.
1938 /// must have BindVBO() method returning a GL
1939 /// buffer object of source data
1941 /// @param srcDesc vertex buffer descriptor for the input buffer
1943 /// @param dstBuffer Output primvar buffer
1944 /// must have BindVBO() method returning a GL
1945 /// buffer object of destination data
1947 /// @param dstDesc vertex buffer descriptor for the output buffer
1949 /// @param duBuffer Output buffer derivative wrt u
1950 /// must have BindVBO() method returning a GL
1951 /// buffer object of destination data
1953 /// @param duDesc vertex buffer descriptor for the duBuffer
1955 /// @param dvBuffer Output buffer derivative wrt v
1956 /// must have BindVBO() method returning a GL
1957 /// buffer object of destination data
1959 /// @param dvDesc vertex buffer descriptor for the dvBuffer
1961 /// @param numPatchCoords number of patchCoords.
1963 /// @param patchCoords array of locations to be evaluated.
1964 /// must have BindVBO() method returning an
1965 /// array of PatchCoord struct in VBO.
1967 /// @param patchTable GLPatchTable or equivalent
1969 /// @param fvarChannel face-varying channel
1971 /// @param instance cached compiled instance. Clients are supposed to
1972 /// pre-compile an instance of this class and provide
1973 /// to this function. If it's null the kernel still
1974 /// compute by instantiating on-demand kernel although
1975 /// it may cause a performance problem.
1977 /// @param deviceContext not used in the GLXFB evaluator
1979 template<typename SRC_BUFFER,
1980 typename DST_BUFFER,
1981 typename PATCHCOORD_BUFFER,
1982 typename PATCH_TABLE>
1983 static bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer,
1984 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
1985 DST_BUFFER *dstBuffer,
1986 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
1987 DST_BUFFER *duBuffer,
1988 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
1989 DST_BUFFER *dvBuffer,
1990 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
1991 int numPatchCoords,
1992 PATCHCOORD_BUFFER *patchCoords,
1993 PATCH_TABLE *patchTable,
1994 int fvarChannel,
1995 GLComputeEvaluator const *instance,
1996 void *deviceContext = nullptr)
1998 if (instance) {
1999 return instance->EvalPatchesFaceVarying(srcBuffer,
2000 srcDesc,
2001 dstBuffer,
2002 dstDesc,
2003 duBuffer,
2004 duDesc,
2005 dvBuffer,
2006 dvDesc,
2007 numPatchCoords,
2008 patchCoords,
2009 patchTable,
2010 fvarChannel);
2013 // Create an instance on demand (slow)
2014 (void)deviceContext; // unused
2015 instance = Create(srcDesc, dstDesc, duDesc, dvDesc);
2016 if (instance) {
2017 bool r = instance->EvalPatchesFaceVarying(srcBuffer,
2018 srcDesc,
2019 dstBuffer,
2020 dstDesc,
2021 duBuffer,
2022 duDesc,
2023 dvBuffer,
2024 dvDesc,
2025 numPatchCoords,
2026 patchCoords,
2027 patchTable,
2028 fvarChannel);
2029 delete instance;
2030 return r;
2032 return false;
2035 /// \brief Generic limit eval function. This function has a same
2036 /// signature as other device kernels have so that it can be called
2037 /// in the same way.
2039 /// @param srcBuffer Input primvar buffer.
2040 /// must have BindVBO() method returning a GL
2041 /// buffer object of source data
2043 /// @param srcDesc vertex buffer descriptor for the input buffer
2045 /// @param dstBuffer Output primvar buffer
2046 /// must have BindVBO() method returning a GL
2047 /// buffer object of destination data
2049 /// @param dstDesc vertex buffer descriptor for the output buffer
2051 /// @param duBuffer Output buffer derivative wrt u
2052 /// must have BindVBO() method returning a GL
2053 /// object of destination data
2055 /// @param duDesc vertex buffer descriptor for the duBuffer
2057 /// @param dvBuffer Output buffer derivative wrt v
2058 /// must have BindVBO() method returning a GL
2059 /// buffer object of destination data
2061 /// @param dvDesc vertex buffer descriptor for the dvBuffer
2063 /// @param numPatchCoords number of patchCoords.
2065 /// @param patchCoords array of locations to be evaluated.
2066 /// must have BindVBO() method returning an
2067 /// array of PatchCoord struct in VBO.
2069 /// @param patchTable GLPatchTable or equivalent
2071 /// @param fvarChannel face-varying channel
2073 template<typename SRC_BUFFER,
2074 typename DST_BUFFER,
2075 typename PATCHCOORD_BUFFER,
2076 typename PATCH_TABLE>
2077 bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer,
2078 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
2079 DST_BUFFER *dstBuffer,
2080 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
2081 DST_BUFFER *duBuffer,
2082 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
2083 DST_BUFFER *dvBuffer,
2084 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
2085 int numPatchCoords,
2086 PATCHCOORD_BUFFER *patchCoords,
2087 PATCH_TABLE *patchTable,
2088 int fvarChannel = 0) const
2091 return EvalPatches(srcBuffer->BindVBO(),
2092 srcDesc,
2093 dstBuffer->BindVBO(),
2094 dstDesc,
2095 duBuffer->BindVBO(),
2096 duDesc,
2097 dvBuffer->BindVBO(),
2098 dvDesc,
2099 numPatchCoords,
2100 patchCoords->BindVBO(),
2101 patchTable->GetFVarPatchArrays(fvarChannel),
2102 patchTable->GetFVarPatchIndexBuffer(fvarChannel),
2103 patchTable->GetFVarPatchParamBuffer(fvarChannel));
2106 /// \brief Generic limit eval function. This function has a same
2107 /// signature as other device kernels have so that it can be called
2108 /// in the same way.
2110 /// @param srcBuffer Input primvar buffer.
2111 /// must have BindVBO() method returning a GL
2112 /// buffer object of source data
2114 /// @param srcDesc vertex buffer descriptor for the input buffer
2116 /// @param dstBuffer Output primvar buffer
2117 /// must have BindVBO() method returning a GL
2118 /// buffer object of destination data
2120 /// @param dstDesc vertex buffer descriptor for the output buffer
2122 /// @param duBuffer Output buffer derivative wrt u
2123 /// must have BindVBO() method returning a GL
2124 /// buffer object of destination data
2126 /// @param duDesc vertex buffer descriptor for the duBuffer
2128 /// @param dvBuffer Output buffer derivative wrt v
2129 /// must have BindVBO() method returning a GL
2130 /// buffer object of destination data
2132 /// @param dvDesc vertex buffer descriptor for the dvBuffer
2134 /// @param duuBuffer Output buffer 2nd derivative wrt u
2135 /// must have BindVBO() method returning a GL
2136 /// buffer object of destination data
2138 /// @param duuDesc vertex buffer descriptor for the duuBuffer
2140 /// @param duvBuffer Output buffer 2nd derivative wrt u and v
2141 /// must have BindVBO() method returning a GL
2142 /// buffer object of destination data
2144 /// @param duvDesc vertex buffer descriptor for the duvBuffer
2146 /// @param dvvBuffer Output buffer 2nd derivative wrt v
2147 /// must have BindVBO() method returning a GL
2148 /// buffer object of destination data
2150 /// @param dvvDesc vertex buffer descriptor for the dvvBuffer
2152 /// @param numPatchCoords number of patchCoords.
2154 /// @param patchCoords array of locations to be evaluated.
2155 /// must have BindVBO() method returning an
2156 /// array of PatchCoord struct in VBO.
2158 /// @param patchTable GLPatchTable or equivalent
2160 /// @param fvarChannel face-varying channel
2162 /// @param instance cached compiled instance. Clients are supposed to
2163 /// pre-compile an instance of this class and provide
2164 /// to this function. If it's null the kernel still
2165 /// compute by instantiating on-demand kernel although
2166 /// it may cause a performance problem.
2168 /// @param deviceContext not used in the GLXFB evaluator
2170 template<typename SRC_BUFFER,
2171 typename DST_BUFFER,
2172 typename PATCHCOORD_BUFFER,
2173 typename PATCH_TABLE>
2174 static bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer,
2175 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
2176 DST_BUFFER *dstBuffer,
2177 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
2178 DST_BUFFER *duBuffer,
2179 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
2180 DST_BUFFER *dvBuffer,
2181 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
2182 DST_BUFFER *duuBuffer,
2183 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
2184 DST_BUFFER *duvBuffer,
2185 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
2186 DST_BUFFER *dvvBuffer,
2187 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
2188 int numPatchCoords,
2189 PATCHCOORD_BUFFER *patchCoords,
2190 PATCH_TABLE *patchTable,
2191 int fvarChannel,
2192 GLComputeEvaluator const *instance,
2193 void *deviceContext = nullptr)
2195 if (instance) {
2196 return instance->EvalPatchesFaceVarying(srcBuffer,
2197 srcDesc,
2198 dstBuffer,
2199 dstDesc,
2200 duBuffer,
2201 duDesc,
2202 dvBuffer,
2203 dvDesc,
2204 duuBuffer,
2205 duuDesc,
2206 duvBuffer,
2207 duvDesc,
2208 dvvBuffer,
2209 dvvDesc,
2210 numPatchCoords,
2211 patchCoords,
2212 patchTable,
2213 fvarChannel);
2216 // Create an instance on demand (slow)
2217 (void)deviceContext; // unused
2218 instance = Create(srcDesc, dstDesc, duDesc, dvDesc, duuDesc, duvDesc, dvvDesc);
2219 if (instance) {
2220 bool r = instance->EvalPatchesFaceVarying(srcBuffer,
2221 srcDesc,
2222 dstBuffer,
2223 dstDesc,
2224 duBuffer,
2225 duDesc,
2226 dvBuffer,
2227 dvDesc,
2228 duuBuffer,
2229 duuDesc,
2230 duvBuffer,
2231 duvDesc,
2232 dvvBuffer,
2233 dvvDesc,
2234 numPatchCoords,
2235 patchCoords,
2236 patchTable,
2237 fvarChannel);
2238 delete instance;
2239 return r;
2241 return false;
2244 /// \brief Generic limit eval function. This function has a same
2245 /// signature as other device kernels have so that it can be called
2246 /// in the same way.
2248 /// @param srcBuffer Input primvar buffer.
2249 /// must have BindVBO() method returning a GL
2250 /// buffer object of source data
2252 /// @param srcDesc vertex buffer descriptor for the input buffer
2254 /// @param dstBuffer Output primvar buffer
2255 /// must have BindVBO() method returning a GL
2256 /// buffer object of destination data
2258 /// @param dstDesc vertex buffer descriptor for the output buffer
2260 /// @param duBuffer Output buffer derivative wrt u
2261 /// must have BindVBO() method returning a GL
2262 /// buffer object of destination data
2264 /// @param duDesc vertex buffer descriptor for the duBuffer
2266 /// @param dvBuffer Output buffer derivative wrt v
2267 /// must have BindVBO() method returning a GL
2268 /// buffer object of destination data
2270 /// @param dvDesc vertex buffer descriptor for the dvBuffer
2272 /// @param duuBuffer Output buffer 2nd derivative wrt u
2273 /// must have BindVBO() method returning a GL
2274 /// buffer object of destination data
2276 /// @param duuDesc vertex buffer descriptor for the duuBuffer
2278 /// @param duvBuffer Output buffer 2nd derivative wrt u and v
2279 /// must have BindVBO() method returning a GL
2280 /// buffer object of destination data
2282 /// @param duvDesc vertex buffer descriptor for the duvBuffer
2284 /// @param dvvBuffer Output buffer 2nd derivative wrt v
2285 /// must have BindVBO() method returning a GL
2286 /// buffer object of destination data
2288 /// @param dvvDesc vertex buffer descriptor for the dvvBuffer
2290 /// @param numPatchCoords number of patchCoords.
2292 /// @param patchCoords array of locations to be evaluated.
2293 /// must have BindVBO() method returning an
2294 /// array of PatchCoord struct in VBO.
2296 /// @param patchTable GLPatchTable or equivalent
2298 /// @param fvarChannel face-varying channel
2300 template<typename SRC_BUFFER,
2301 typename DST_BUFFER,
2302 typename PATCHCOORD_BUFFER,
2303 typename PATCH_TABLE>
2304 bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer,
2305 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
2306 DST_BUFFER *dstBuffer,
2307 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
2308 DST_BUFFER *duBuffer,
2309 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
2310 DST_BUFFER *dvBuffer,
2311 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
2312 DST_BUFFER *duuBuffer,
2313 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
2314 DST_BUFFER *duvBuffer,
2315 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
2316 DST_BUFFER *dvvBuffer,
2317 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
2318 int numPatchCoords,
2319 PATCHCOORD_BUFFER *patchCoords,
2320 PATCH_TABLE *patchTable,
2321 int fvarChannel = 0) const
2324 return EvalPatches(srcBuffer->BindVBO(),
2325 srcDesc,
2326 dstBuffer->BindVBO(),
2327 dstDesc,
2328 duBuffer->BindVBO(),
2329 duDesc,
2330 dvBuffer->BindVBO(),
2331 dvDesc,
2332 duuBuffer->BindVBO(),
2333 duuDesc,
2334 duvBuffer->BindVBO(),
2335 duvDesc,
2336 dvvBuffer->BindVBO(),
2337 dvvDesc,
2338 numPatchCoords,
2339 patchCoords->BindVBO(),
2340 patchTable->GetFVarPatchArrays(fvarChannel),
2341 patchTable->GetFVarPatchIndexBuffer(fvarChannel),
2342 patchTable->GetFVarPatchParamBuffer(fvarChannel));
2345 /// ----------------------------------------------------------------------
2347 /// Other methods
2349 /// ----------------------------------------------------------------------
2351 /// Configure GLSL kernel. A valid GL context must be made current before
2352 /// calling this function. Returns false if it fails to compile the kernel.
2353 bool Compile(
2354 OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
2355 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
2356 OpenSubdiv::Osd::BufferDescriptor const &duDesc = OpenSubdiv::Osd::BufferDescriptor(),
2357 OpenSubdiv::Osd::BufferDescriptor const &dvDesc = OpenSubdiv::Osd::BufferDescriptor(),
2358 OpenSubdiv::Osd::BufferDescriptor const &duuDesc = OpenSubdiv::Osd::BufferDescriptor(),
2359 OpenSubdiv::Osd::BufferDescriptor const &duvDesc = OpenSubdiv::Osd::BufferDescriptor(),
2360 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc = OpenSubdiv::Osd::BufferDescriptor());
2362 /// Wait the dispatched kernel finishes.
2363 static void Synchronize(void *deviceContext);
2365 private:
2366 struct _StencilKernel {
2367 _StencilKernel();
2368 ~_StencilKernel();
2369 bool Compile(OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
2370 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
2371 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
2372 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
2373 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
2374 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
2375 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
2376 int workGroupSize);
2377 GLuint program;
2378 GLuint uniformStart;
2379 GLuint uniformEnd;
2380 GLuint uniformSrcOffset;
2381 GLuint uniformDstOffset;
2382 GLuint uniformDuDesc;
2383 GLuint uniformDvDesc;
2384 GLuint uniformDuuDesc;
2385 GLuint uniformDuvDesc;
2386 GLuint uniformDvvDesc;
2387 } _stencilKernel;
2389 struct _PatchKernel {
2390 _PatchKernel();
2391 ~_PatchKernel();
2392 bool Compile(OpenSubdiv::Osd::BufferDescriptor const &srcDesc,
2393 OpenSubdiv::Osd::BufferDescriptor const &dstDesc,
2394 OpenSubdiv::Osd::BufferDescriptor const &duDesc,
2395 OpenSubdiv::Osd::BufferDescriptor const &dvDesc,
2396 OpenSubdiv::Osd::BufferDescriptor const &duuDesc,
2397 OpenSubdiv::Osd::BufferDescriptor const &duvDesc,
2398 OpenSubdiv::Osd::BufferDescriptor const &dvvDesc,
2399 int workGroupSize);
2400 GLuint program;
2401 GLuint uniformSrcOffset;
2402 GLuint uniformDstOffset;
2403 GLuint uniformPatchArray;
2404 GLuint uniformDuDesc;
2405 GLuint uniformDvDesc;
2406 GLuint uniformDuuDesc;
2407 GLuint uniformDuvDesc;
2408 GLuint uniformDvvDesc;
2409 } _patchKernel;
2411 int _workGroupSize;
2412 GLuint _patchArraysSSBO;
2414 int GetDispatchSize(int count) const;
2416 void DispatchCompute(int totalDispatchSize) const;
2419 } // namespace blender::opensubdiv
2421 #endif // OPENSUBDIV_GL_COMPUTE_EVALUATOR_H_