25 #ifndef OSD_CPU_COMPUTE_CONTROLLER_H
26 #define OSD_CPU_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 {
82 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
85 VERTEX_BUFFER * vertexBuffer,
86 VARYING_BUFFER * varyingBuffer,
90 if (batches.empty())
return;
92 bind(vertexBuffer, varyingBuffer, vertexDesc, varyingDesc);
108 template<
class VERTEX_BUFFER>
111 VERTEX_BUFFER *vertexBuffer) {
113 Compute<VERTEX_BUFFER>(context, batches, vertexBuffer, (VERTEX_BUFFER*)0);
127 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
128 void bind( VERTEX_BUFFER * vertexBuffer,
129 VARYING_BUFFER * varyingBuffer,
136 _currentBindState.vertexDesc = *vertexDesc;
138 int numElements = vertexBuffer ? vertexBuffer->GetNumElements() : 0;
139 _currentBindState.vertexDesc =
144 _currentBindState.varyingDesc = *varyingDesc;
146 int numElements = varyingBuffer ? varyingBuffer->GetNumElements() : 0;
147 _currentBindState.varyingDesc =
151 _currentBindState.vertexBuffer = vertexBuffer ?
152 vertexBuffer->BindCpuBuffer() : 0;
154 _currentBindState.varyingBuffer = varyingBuffer ?
155 varyingBuffer->BindCpuBuffer() : 0;
159 _currentBindState.Reset();
168 BindState() : vertexBuffer(0), varyingBuffer(0) { }
171 vertexBuffer = varyingBuffer = 0;
176 float * vertexBuffer,
179 VertexBufferDescriptor vertexDesc,
183 BindState _currentBindState;
189 using namespace OPENSUBDIV_VERSION;
193 #endif // OSD_CPU_COMPUTE_CONTROLLER_H
void Compute(CpuComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer)
A GP Compute Kernel descriptor.
void ApplyStencilTableKernel(Far::KernelBatch const &batch, ComputeContext const *context) const
Describes vertex elements in interleaved data buffers.
std::vector< KernelBatch > KernelBatchVector
CpuComputeContext ComputeContext
void Synchronize()
Waits until all running subdivision kernels finish.
Compute controller for launching CPU subdivision kernels.
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 ...
CpuComputeController()
Constructor.
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)
Subdivision refinement encapsulation layer.
~CpuComputeController()
Destructor.