25 #ifndef OSD_GLSL_COMPUTE_CONTROLLER_H
26 #define OSD_GLSL_COMPUTE_CONTROLLER_H
28 #include "../version.h"
30 #include "../far/kernelBatchDispatcher.h"
31 #include "../osd/glslComputeContext.h"
32 #include "../osd/vertexDescriptor.h"
36 namespace OpenSubdiv {
37 namespace OPENSUBDIV_VERSION {
80 template<
class VERTEX_BUFFER,
class VARYING_BUFFER>
83 VERTEX_BUFFER * vertexBuffer,
84 VARYING_BUFFER * varyingBuffer,
88 if (batches.empty())
return;
91 bind(vertexBuffer, vertexDesc);
99 bind(varyingBuffer, varyingDesc);
120 template<
class VERTEX_BUFFER>
123 VERTEX_BUFFER *vertexBuffer) {
125 Compute<VERTEX_BUFFER>(context, batches, vertexBuffer, (VERTEX_BUFFER*)0);
138 template<
class BUFFER>
147 _currentBindState.desc = *desc;
149 int numElements = buffer ? buffer->GetNumElements() : 0;
150 _currentBindState.desc =
154 _currentBindState.buffer = buffer->BindVBO();
156 _currentBindState.kernelBundle = getKernel(_currentBindState.desc);
164 _currentBindState.Reset();
183 BindState() : buffer(0), kernelBundle(0) { }
193 VertexBufferDescriptor desc;
195 KernelBundle
const * kernelBundle;
198 BindState _currentBindState;
200 typedef std::vector<KernelBundle *> KernelRegistry;
202 KernelBundle
const * getKernel(VertexBufferDescriptor
const &desc);
204 KernelRegistry _kernelRegistry;
210 using namespace OPENSUBDIV_VERSION;
214 #endif // OSD_GLSL_COMPUTE_CONTROLLER_H
A GP Compute Kernel descriptor.
void Synchronize()
Waits until all running subdivision kernels finish.
GLSL-Compute Refine Context.
Describes vertex elements in interleaved data buffers.
void ApplyStencilTableKernel(Far::KernelBatch const &batch, ComputeContext const *context) const
void bindBufferAndProgram()
void unbindBufferAndProgram()
void BindVaryingStencilTables() const
Binds GL buffers containing stencils for 'varying' interpolation.
std::vector< KernelBatch > KernelBatchVector
GLSLComputeController()
Constructor.
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 Compute(GLSLComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer)
GLSLComputeContext ComputeContext
void BindVertexStencilTables() const
Binds GL buffers containing stencils for 'vertex' interpolation.
void bind(BUFFER *buffer, VertexBufferDescriptor const *desc)
Compute controller for launching GLSL Compute subdivision kernels.
void Compute(GLSLComputeContext const *context, Far::KernelBatchVector const &batches, VERTEX_BUFFER *vertexBuffer, VARYING_BUFFER *varyingBuffer, VertexBufferDescriptor const *vertexDesc=NULL, VertexBufferDescriptor const *varyingDesc=NULL)
~GLSLComputeController()
Destructor.
Subdivision refinement encapsulation layer.
void UnbindStencilTables() const
Unbinds GL stencil buffers.