OpenSubdiv
Loading...
Searching...
No Matches
clVertexBuffer.h
Go to the documentation of this file.
1//
2// Copyright 2013 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_CL_VERTEX_BUFFER_H
9#define OPENSUBDIV3_OSD_CL_VERTEX_BUFFER_H
10
11#include "../version.h"
12#include "../osd/opencl.h"
13
14namespace OpenSubdiv {
15namespace OPENSUBDIV_VERSION {
16
17namespace Osd {
18
26
27public:
29 static CLVertexBuffer * Create(int numElements, int numVertices, cl_context clContext);
30
31 template <typename DEVICE_CONTEXT>
32 static CLVertexBuffer * Create(int numElements, int numVertices,
33 DEVICE_CONTEXT context) {
34 return Create(numElements, numVertices, context->GetContext());
35 }
36
39
42 void UpdateData(const float *src, int startVertex, int numVertices, cl_command_queue clQueue,
43 cl_event* startEvents = NULL, unsigned int numStartEvents = 0, cl_event* endEvent = NULL);
44
45 template<typename DEVICE_CONTEXT>
46 void UpdateData(const float *src, int startVertex, int numVertices,
47 DEVICE_CONTEXT context,
48 cl_event* startEvents = NULL, unsigned int numStartEvents = 0, cl_event* endEvent = NULL) {
49 UpdateData(src, startVertex, numVertices, context->GetCommandQueue(), startEvents, numStartEvents, endEvent);
50 }
51
53 int GetNumElements() const;
54
56 int GetNumVertices() const;
57
59 cl_mem BindCLBuffer(cl_command_queue queue);
60
61protected:
63 CLVertexBuffer(int numElements, int numVertices, cl_context clContext);
64
67 bool allocate(cl_context clContext);
68
69private:
70 int _numElements;
71 int _numVertices;
72 cl_mem _clMemory;
73};
74
75} // end namespace Osd
76
77} // end namespace OPENSUBDIV_VERSION
78using namespace OPENSUBDIV_VERSION;
79
80} // end namespace OpenSubdiv
81
82#endif // OPENSUBDIV3_OSD_CL_VERTEX_BUFFER_H
Concrete vertex buffer class for OpenCL subdivision.
void UpdateData(const float *src, int startVertex, int numVertices, DEVICE_CONTEXT context, cl_event *startEvents=NULL, unsigned int numStartEvents=0, cl_event *endEvent=NULL)
CLVertexBuffer(int numElements, int numVertices, cl_context clContext)
Constructor.
void UpdateData(const float *src, int startVertex, int numVertices, cl_command_queue clQueue, cl_event *startEvents=NULL, unsigned int numStartEvents=0, cl_event *endEvent=NULL)
int GetNumElements() const
Returns how many elements defined in this vertex buffer.
int GetNumVertices() const
Returns how many vertices allocated in this vertex buffer.
static CLVertexBuffer * Create(int numElements, int numVertices, cl_context clContext)
Creator. Returns NULL if error.
static CLVertexBuffer * Create(int numElements, int numVertices, DEVICE_CONTEXT context)
cl_mem BindCLBuffer(cl_command_queue queue)
Returns the CL memory object.