| 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
14 namespace OpenSubdiv {
15 namespace OPENSUBDIV_VERSION {
16
17 namespace Osd {
18
25 class CLVertexBuffer {
26
27 public:
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
38 ~CLVertexBuffer();
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
61 protected:
63 CLVertexBuffer(int numElements, int numVertices, cl_context clContext);
64
67 bool allocate(cl_context clContext);
68
69 private:
70 int _numElements;
71 int _numVertices;
72 cl_mem _clMemory;
73};
74
75} // end namespace Osd
76
77} // end namespace OPENSUBDIV_VERSION
78 using namespace OPENSUBDIV_VERSION;
79
80} // end namespace OpenSubdiv
81
82#endif // OPENSUBDIV3_OSD_CL_VERTEX_BUFFER_H
opencl.h
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Osd
Definition bufferDescriptor.h:17
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::UpdateData
void UpdateData(const float *src, int startVertex, int numVertices, DEVICE_CONTEXT context, cl_event *startEvents=NULL, unsigned int numStartEvents=0, cl_event *endEvent=NULL)
Definition clVertexBuffer.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::~CLVertexBuffer
~CLVertexBuffer()
Destructor.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::CLVertexBuffer
CLVertexBuffer(int numElements, int numVertices, cl_context clContext)
Constructor.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::UpdateData
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)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::GetNumElements
int GetNumElements() const
Returns how many elements defined in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::allocate
bool allocate(cl_context clContext)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::GetNumVertices
int GetNumVertices() const
Returns how many vertices allocated in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::Create
static CLVertexBuffer * Create(int numElements, int numVertices, cl_context clContext)
Creator. Returns NULL if error.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::Create
static CLVertexBuffer * Create(int numElements, int numVertices, DEVICE_CONTEXT context)
Definition clVertexBuffer.h:32
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CLVertexBuffer::BindCLBuffer
cl_mem BindCLBuffer(cl_command_queue queue)
Returns the CL memory object.