25 #ifndef OPENSUBDIV3_OSD_GL_COMPUTE_EVALUATOR_H
26 #define OPENSUBDIV3_OSD_GL_COMPUTE_EVALUATOR_H
28 #include "../version.h"
30 #include "../osd/opengl.h"
31 #include "../osd/types.h"
32 #include "../osd/bufferDescriptor.h"
35 namespace OPENSUBDIV_VERSION {
40 class LimitStencilTable;
54 void *deviceContext = NULL) {
60 void *deviceContext = NULL) {
97 void * deviceContext = NULL) {
100 if (instance->
Compile(srcDesc, dstDesc, duDesc, dvDesc))
return instance;
144 template <
typename SRC_BUFFER,
typename DST_BUFFER,
typename STENCIL_TABLE>
148 STENCIL_TABLE
const *stencilTable,
150 void * deviceContext = NULL) {
159 instance =
Create(srcDesc, dstDesc,
212 template <
typename SRC_BUFFER,
typename DST_BUFFER,
typename STENCIL_TABLE>
218 STENCIL_TABLE
const *stencilTable,
220 void * deviceContext = NULL) {
231 instance =
Create(srcDesc, dstDesc, duDesc, dvDesc);
247 template <
typename SRC_BUFFER,
typename DST_BUFFER,
typename STENCIL_TABLE>
251 STENCIL_TABLE
const *stencilTable)
const {
253 dstBuffer->BindVBO(), dstDesc,
256 stencilTable->GetSizesBuffer(),
257 stencilTable->GetOffsetsBuffer(),
258 stencilTable->GetIndicesBuffer(),
259 stencilTable->GetWeightsBuffer(),
263 stencilTable->GetNumStencils());
268 template <
typename SRC_BUFFER,
typename DST_BUFFER,
typename STENCIL_TABLE>
274 STENCIL_TABLE
const *stencilTable)
const {
276 dstBuffer->BindVBO(), dstDesc,
277 duBuffer->BindVBO(), duDesc,
278 dvBuffer->BindVBO(), dvDesc,
279 stencilTable->GetSizesBuffer(),
280 stencilTable->GetOffsetsBuffer(),
281 stencilTable->GetIndicesBuffer(),
282 stencilTable->GetWeightsBuffer(),
283 stencilTable->GetDuWeightsBuffer(),
284 stencilTable->GetDvWeightsBuffer(),
286 stencilTable->GetNumStencils());
296 GLuint offsetsBuffer,
297 GLuint indicesBuffer,
298 GLuint weightsBuffer,
299 GLuint duWeightsBuffer,
300 GLuint dvWeightsBuffer,
342 template <
typename SRC_BUFFER,
typename DST_BUFFER,
343 typename PATCHCOORD_BUFFER,
typename PATCH_TABLE>
348 PATCHCOORD_BUFFER *patchCoords,
349 PATCH_TABLE *patchTable,
351 void * deviceContext = NULL) {
356 numPatchCoords, patchCoords,
361 instance =
Create(srcDesc, dstDesc,
367 numPatchCoords, patchCoords,
416 template <
typename SRC_BUFFER,
typename DST_BUFFER,
417 typename PATCHCOORD_BUFFER,
typename PATCH_TABLE>
424 PATCHCOORD_BUFFER *patchCoords,
425 PATCH_TABLE *patchTable,
427 void * deviceContext = NULL) {
434 numPatchCoords, patchCoords,
439 instance =
Create(srcDesc, dstDesc, duDesc, dvDesc);
445 numPatchCoords, patchCoords,
478 template <
typename SRC_BUFFER,
typename DST_BUFFER,
479 typename PATCHCOORD_BUFFER,
typename PATCH_TABLE>
484 PATCHCOORD_BUFFER *patchCoords,
485 PATCH_TABLE *patchTable)
const {
488 dstBuffer->BindVBO(), dstDesc,
492 patchCoords->BindVBO(),
493 patchTable->GetPatchArrays(),
494 patchTable->GetPatchIndexBuffer(),
495 patchTable->GetPatchParamBuffer());
532 template <
typename SRC_BUFFER,
typename DST_BUFFER,
533 typename PATCHCOORD_BUFFER,
typename PATCH_TABLE>
540 PATCHCOORD_BUFFER *patchCoords,
541 PATCH_TABLE *patchTable)
const {
544 dstBuffer->BindVBO(), dstDesc,
545 duBuffer->BindVBO(), duDesc,
546 dvBuffer->BindVBO(), dvDesc,
548 patchCoords->BindVBO(),
549 patchTable->GetPatchArrays(),
550 patchTable->GetPatchIndexBuffer(),
551 patchTable->GetPatchParamBuffer());
559 GLuint patchCoordsBuffer,
561 GLuint patchIndexBuffer,
562 GLuint patchParamsBuffer)
const;
581 struct _StencilKernel {
592 GLuint uniformSrcOffset;
593 GLuint uniformDstOffset;
594 GLuint uniformDuDesc;
595 GLuint uniformDvDesc;
598 struct _PatchKernel {
601 bool Compile(BufferDescriptor
const &srcDesc,
602 BufferDescriptor
const &dstDesc,
603 BufferDescriptor
const &duDesc,
604 BufferDescriptor
const &dvDesc,
607 GLuint uniformSrcOffset;
608 GLuint uniformDstOffset;
609 GLuint uniformPatchArray;
610 GLuint uniformDuDesc;
611 GLuint uniformDvDesc;
621 using namespace OPENSUBDIV_VERSION;
626 #endif // OPENSUBDIV3_OSD_GL_COMPUTE_EVALUATOR_H
bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
GLuint GetDuWeightsBuffer() const
static GLStencilTableSSBO * Create(Far::LimitStencilTable const *limitStencilTable, void *deviceContext=NULL)
BufferDescriptor is a struct which describes buffer elements in interleaved data buffers. Almost all Osd Evaluator APIs take BufferDescriptors along with device-specific buffer objects.
GLuint GetSizesBuffer() const
GLStencilTableSSBO(Far::StencilTable const *stencilTable)
std::vector< PatchArray > PatchArrayVector
bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, STENCIL_TABLE const *stencilTable) const
static bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, GLComputeEvaluator const *instance, void *deviceContext=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
static GLComputeEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, void *deviceContext=NULL)
static void Synchronize(void *deviceContext)
Wait the dispatched kernel finishes.
GL stencil table (Shader Storage buffer)
static GLStencilTableSSBO * Create(Far::StencilTable const *stencilTable, void *deviceContext=NULL)
GLuint GetOffsetsBuffer() const
bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable) const
bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable) const
Generic limit eval function with derivatives. This function has a same signature as other device kern...
static bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable, GLComputeEvaluator const *instance, void *deviceContext=NULL)
Generic static compute function. This function has a same signature as other device kernels have so t...
int GetNumStencils() const
GLuint GetDvWeightsBuffer() const
Table of subdivision stencils.
GLuint GetIndicesBuffer() const
bool Compile(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc)
static bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, STENCIL_TABLE const *stencilTable, GLComputeEvaluator const *instance, void *deviceContext=NULL)
Generic static compute function. This function has a same signature as other device kernels have so t...
~GLComputeEvaluator()
Destructor. note that the GL context must be made current.
GLuint GetWeightsBuffer() const
Table of limit subdivision stencils.
GLComputeEvaluator()
Constructor.
static bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, GLComputeEvaluator const *instance, void *deviceContext=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...