25 #ifndef OSD_TBB_COMPUTE_CONTROLLER_H
26 #define OSD_TBB_COMPUTE_CONTROLLER_H
28 #include "../version.h"
30 #include "../far/kernelBatchDispatcher.h"
31 #include "../osd/cpuComputeContext.h"
32 #include "../osd/vertexDescriptor.h"
34 namespace OpenSubdiv {
35 namespace OPENSUBDIV_VERSION {
80 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
83 VERTEX_BUFFER * vertexBuffer,
84 VARYING_BUFFER * varyingBuffer,
88 if (batches.empty())
return;
90 bind(vertexBuffer, varyingBuffer, vertexDesc, varyingDesc);
106 template<
class VERTEX_BUFFER>
109 VERTEX_BUFFER *vertexBuffer) {
111 Compute<VERTEX_BUFFER>(context, batches, vertexBuffer, (VERTEX_BUFFER*)0);
124 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
125 void bind( VERTEX_BUFFER * vertexBuffer,
126 VARYING_BUFFER * varyingBuffer,
133 _currentBindState.vertexDesc = *vertexDesc;
135 int numElements = vertexBuffer ? vertexBuffer->GetNumElements() : 0;
136 _currentBindState.vertexDesc =
141 _currentBindState.varyingDesc = *varyingDesc;
143 int numElements = varyingBuffer ? varyingBuffer->GetNumElements() : 0;
144 _currentBindState.varyingDesc =
148 _currentBindState.vertexBuffer = vertexBuffer ?
149 vertexBuffer->BindCpuBuffer(): 0;
151 _currentBindState.varyingBuffer = varyingBuffer ?
152 varyingBuffer->BindCpuBuffer() : 0;
156 _currentBindState.Reset();
165 BindState() : vertexBuffer(0), varyingBuffer(0) { }
168 vertexBuffer = varyingBuffer = 0;
173 float * vertexBuffer,
176 VertexBufferDescriptor vertexDesc,
180 BindState _currentBindState;
187 using namespace OPENSUBDIV_VERSION;
191 #endif // OSD_TBB_COMPUTE_CONTROLLER_H
A GP Compute Kernel descriptor.
Describes vertex elements in interleaved data buffers.
void Compute(CpuComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer, VARYING_BUFFER *varyingBuffer, VertexBufferDescriptor const *vertexDesc=NULL, VertexBufferDescriptor const *varyingDesc=NULL)
std::vector< KernelBatch > KernelBatchVector
void bind(VERTEX_BUFFER *vertexBuffer, VARYING_BUFFER *varyingBuffer, VertexBufferDescriptor const *vertexDesc, VertexBufferDescriptor const *varyingDesc)
static void Apply(CONTROLLER *controller, CONTEXT *context, KernelBatchVector const &batches, int maxlevel)
Launches the processing of a vector of kernel batches this is a convenient API for controllers which ...
TbbComputeController(int numThreads=-1)
void ApplyStencilTableKernel(Far::KernelBatch const &batch, ComputeContext const *context) const
Compute controller for launching TBB subdivision kernels.
CpuComputeContext ComputeContext
void Synchronize()
Waits until all running subdivision kernels finish.
Subdivision refinement encapsulation layer.
void Compute(CpuComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer)