25 #ifndef OSD_OMP_COMPUTE_CONTROLLER_H
26 #define OSD_OMP_COMPUTE_CONTROLLER_H
28 #include "../version.h"
30 #include "../far/kernelBatchDispatcher.h"
31 #include "../osd/cpuComputeContext.h"
32 #include "../osd/vertexDescriptor.h"
34 #ifdef OPENSUBDIV_HAS_OPENMP
38 namespace OpenSubdiv {
39 namespace OPENSUBDIV_VERSION {
84 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
87 VERTEX_BUFFER * vertexBuffer,
88 VARYING_BUFFER * varyingBuffer,
92 if (batches.empty())
return;
94 omp_set_num_threads(_numThreads);
96 bind(vertexBuffer, varyingBuffer, vertexDesc, varyingDesc);
112 template<
class VERTEX_BUFFER>
115 VERTEX_BUFFER *vertexBuffer) {
117 Compute<VERTEX_BUFFER>(context, batches, vertexBuffer, (VERTEX_BUFFER*)0);
130 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
131 void bind( VERTEX_BUFFER * vertexBuffer,
132 VARYING_BUFFER * varyingBuffer,
139 _currentBindState.vertexDesc = *vertexDesc;
141 int numElements = vertexBuffer ? vertexBuffer->GetNumElements() : 0;
142 _currentBindState.vertexDesc =
147 _currentBindState.varyingDesc = *varyingDesc;
149 int numElements = varyingBuffer ? varyingBuffer->GetNumElements() : 0;
150 _currentBindState.varyingDesc =
154 _currentBindState.vertexBuffer = vertexBuffer ?
155 vertexBuffer->BindCpuBuffer() : 0;
157 _currentBindState.varyingBuffer = varyingBuffer ?
158 varyingBuffer->BindCpuBuffer() : 0;
163 _currentBindState.Reset();
172 BindState() : vertexBuffer(0), varyingBuffer(0) { }
175 vertexBuffer = varyingBuffer = 0;
180 float * vertexBuffer,
183 VertexBufferDescriptor vertexDesc,
187 BindState _currentBindState;
194 using namespace OPENSUBDIV_VERSION;
198 #endif // OSD_OMP_COMPUTE_CONTROLLER_H
CpuComputeContext ComputeContext
A GP Compute Kernel descriptor.
void Compute(CpuComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer)
Describes vertex elements in interleaved data buffers.
std::vector< KernelBatch > KernelBatchVector
void Compute(CpuComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer, VARYING_BUFFER *varyingBuffer, VertexBufferDescriptor const *vertexDesc=NULL, VertexBufferDescriptor const *varyingDesc=NULL)
void bind(VERTEX_BUFFER *vertexBuffer, VARYING_BUFFER *varyingBuffer, VertexBufferDescriptor const *vertexDesc, VertexBufferDescriptor const *varyingDesc)
void Synchronize()
Waits until all running subdivision kernels finish.
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 ...
void ApplyStencilTableKernel(Far::KernelBatch const &batch, ComputeContext const *context) const
Subdivision refinement encapsulation layer.
Compute controller for launching OpenMP subdivision kernels.
OmpComputeController(int numThreads=-1)