25 #ifndef OSD_CUDA_COMPUTE_CONTROLLER_H
26 #define OSD_CUDA_COMPUTE_CONTROLLER_H
28 #include "../version.h"
30 #include "../far/kernelBatchDispatcher.h"
31 #include "../osd/cudaComputeContext.h"
32 #include "../osd/vertexDescriptor.h"
34 namespace OpenSubdiv {
35 namespace OPENSUBDIV_VERSION {
78 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
81 VERTEX_BUFFER * vertexBuffer,
82 VARYING_BUFFER * varyingBuffer,
86 if (batches.empty())
return;
88 bind(vertexBuffer, varyingBuffer, vertexDesc, varyingDesc);
104 template<
class VERTEX_BUFFER>
107 VERTEX_BUFFER *vertexBuffer) {
109 Compute<VERTEX_BUFFER>(context, batches, vertexBuffer, (VERTEX_BUFFER*)0);
122 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
123 void bind( VERTEX_BUFFER * vertexBuffer,
124 VARYING_BUFFER * varyingBuffer,
131 _currentBindState.vertexDesc = *vertexDesc;
133 int numElements = vertexBuffer ? vertexBuffer->GetNumElements() : 0;
134 _currentBindState.vertexDesc =
139 _currentBindState.varyingDesc = *varyingDesc;
141 int numElements = varyingBuffer ? varyingBuffer->GetNumElements() : 0;
142 _currentBindState.varyingDesc =
146 _currentBindState.vertexBuffer = vertexBuffer ?
147 static_cast<float*
>(vertexBuffer->BindCudaBuffer()) : 0;
148 _currentBindState.varyingBuffer = varyingBuffer ?
149 static_cast<float*
>(varyingBuffer->BindCudaBuffer()) : 0;
154 _currentBindState.Reset();
163 BindState() : vertexBuffer(NULL), varyingBuffer(NULL) {}
166 vertexBuffer = varyingBuffer = NULL;
171 float *GetVertexBufferAtOffset()
const {
172 return vertexBuffer ? vertexBuffer + vertexDesc.offset : 0;
175 float *GetVaryingBufferAtOffset()
const {
176 return varyingBuffer ? varyingBuffer + varyingDesc.offset : 0;
179 float * vertexBuffer,
182 VertexBufferDescriptor vertexDesc,
186 BindState _currentBindState;
192 using namespace OPENSUBDIV_VERSION;
196 #endif // OSD_CUDA_COMPUTE_CONTROLLER_H
Compute controller for launching CUDA subdivision kernels.
A GP Compute Kernel descriptor.
void bind(VERTEX_BUFFER *vertexBuffer, VARYING_BUFFER *varyingBuffer, VertexBufferDescriptor const *vertexDesc, VertexBufferDescriptor const *varyingDesc)
void Compute(CudaComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer, VARYING_BUFFER *varyingBuffer, VertexBufferDescriptor const *vertexDesc=NULL, VertexBufferDescriptor const *varyingDesc=NULL)
Describes vertex elements in interleaved data buffers.
void unbind()
Unbinds any previously bound vertex and varying data buffers.
std::vector< KernelBatch > KernelBatchVector
CudaComputeController()
Constructor.
void ApplyStencilTableKernel(Far::KernelBatch const &batch, ComputeContext const *context) const
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 ...
~CudaComputeController()
Destructor.
CudaComputeContext ComputeContext
void Compute(CudaComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer)
Subdivision refinement encapsulation layer.
void Synchronize()
Waits until all running subdivision kernels finish.