25 #ifndef OSD_CL_COMPUTE_CONTROLLER_H
26 #define OSD_CL_COMPUTE_CONTROLLER_H
28 #include "../version.h"
30 #include "../far/kernelBatchDispatcher.h"
31 #include "../osd/clComputeContext.h"
32 #include "../osd/vertexDescriptor.h"
33 #include "../osd/opencl.h"
37 namespace OpenSubdiv {
38 namespace OPENSUBDIV_VERSION {
88 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
91 VERTEX_BUFFER * vertexBuffer,
92 VARYING_BUFFER * varyingBuffer,
96 if (batches.empty())
return;
98 bind(vertexBuffer, varyingBuffer, vertexDesc, varyingDesc);
114 template<
class VERTEX_BUFFER>
117 VERTEX_BUFFER *vertexBuffer) {
119 Compute<VERTEX_BUFFER>(context, batches, vertexBuffer, (VERTEX_BUFFER*)0);
138 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
139 void bind( VERTEX_BUFFER * vertexBuffer,
140 VARYING_BUFFER * varyingBuffer,
147 _currentBindState.vertexDesc = *vertexDesc;
149 int numElements = vertexBuffer ? vertexBuffer->GetNumElements() : 0;
150 _currentBindState.vertexDesc =
155 _currentBindState.varyingDesc = *varyingDesc;
157 int numElements = varyingBuffer ? varyingBuffer->GetNumElements() : 0;
158 _currentBindState.varyingDesc =
162 _currentBindState.vertexBuffer = vertexBuffer ?
163 vertexBuffer->BindCLBuffer(_clQueue) : 0;
164 _currentBindState.varyingBuffer = varyingBuffer ?
165 varyingBuffer->BindCLBuffer(_clQueue) : 0;
169 _currentBindState.Reset();
181 BindState() : vertexBuffer(0), varyingBuffer(0) { }
184 vertexBuffer = varyingBuffer = NULL;
192 VertexBufferDescriptor vertexDesc,
196 BindState _currentBindState;
198 KernelBundle
const * getKernel(VertexBufferDescriptor
const &desc);
200 typedef std::vector<KernelBundle *> KernelRegistry;
202 KernelRegistry _kernelRegistry;
204 cl_context _clContext;
205 cl_command_queue _clQueue;
211 using namespace OPENSUBDIV_VERSION;
215 #endif // OSD_COMPUTE_CONTROLLER_H
A GP Compute Kernel descriptor.
void ApplyStencilTableKernel(Far::KernelBatch const &batch, ComputeContext const *context)
void bind(VERTEX_BUFFER *vertexBuffer, VARYING_BUFFER *varyingBuffer, VertexBufferDescriptor const *vertexDesc, VertexBufferDescriptor const *varyingDesc)
Describes vertex elements in interleaved data buffers.
std::vector< KernelBatch > KernelBatchVector
CLComputeContext ComputeContext
void Compute(CLComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer, VARYING_BUFFER *varyingBuffer, VertexBufferDescriptor const *vertexDesc=NULL, VertexBufferDescriptor const *varyingDesc=NULL)
void Synchronize()
Waits until all running subdivision kernels finish.
cl_context GetContext() const
Returns CL context.
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 ...
Compute controller for launching OpenCL Compute subdivision kernels.
~CLComputeController()
Destructor.
void Compute(CLComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer)
cl_command_queue GetCommandQueue() const
Returns CL command queue.
Subdivision refinement encapsulation layer.
CLComputeController(cl_context clContext, cl_command_queue queue)