OpenSubdiv: opensubdiv/osd/cudaVertexBuffer.h Source File

| OpenSubdiv

Loading...
Searching...
No Matches
cudaVertexBuffer.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_CUDA_VERTEX_BUFFER_H
9#define OPENSUBDIV3_OSD_CUDA_VERTEX_BUFFER_H
10
11#include "../version.h"
12
13#include <cstddef>
14
15namespace OpenSubdiv {
16namespace OPENSUBDIV_VERSION {
17
18namespace Osd {
19
25 class CudaVertexBuffer {
26
27public:
29 static CudaVertexBuffer * Create(int numElements, int numVertices,
30 void *deviceContext = NULL);
31
33 ~CudaVertexBuffer();
34
37 void UpdateData(const float *src, int startVertex, int numVertices,
38 void *deviceContext=NULL);
39
41 int GetNumElements() const;
42
44 int GetNumVertices() const;
45
47 float * BindCudaBuffer();
48
49protected:
51 CudaVertexBuffer(int numElements, int numVertices);
52
55 bool allocate();
56
57private:
58 int _numElements;
59 int _numVertices;
60 void *_cudaMem;
61
62};
63
64} // end namespace Osd
65
66} // end namespace OPENSUBDIV_VERSION
67using namespace OPENSUBDIV_VERSION;
68
69} // end namespace OpenSubdiv
70
71#endif // OPENSUBDIV3_OSD_CUDA_VERTEX_BUFFER_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::CudaVertexBuffer::BindCudaBuffer
float * BindCudaBuffer()
Returns cuda memory.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CudaVertexBuffer::~CudaVertexBuffer
~CudaVertexBuffer()
Destructor.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CudaVertexBuffer::GetNumElements
int GetNumElements() const
Returns how many elements defined in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CudaVertexBuffer::UpdateData
void UpdateData(const float *src, int startVertex, int numVertices, void *deviceContext=NULL)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CudaVertexBuffer::GetNumVertices
int GetNumVertices() const
Returns how many vertices allocated in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CudaVertexBuffer::Create
static CudaVertexBuffer * Create(int numElements, int numVertices, void *deviceContext=NULL)
Creator. Returns NULL if error.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CudaVertexBuffer::allocate
bool allocate()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CudaVertexBuffer::CudaVertexBuffer
CudaVertexBuffer(int numElements, int numVertices)
Constructor.