OpenSubdiv: opensubdiv/osd/mtlVertexBuffer.h Source File

| OpenSubdiv

Loading...
Searching...
No Matches
mtlVertexBuffer.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_MTL_VERTEX_BUFFER_H
9#define OPENSUBDIV3_OSD_MTL_VERTEX_BUFFER_H
10
11#include "../version.h"
12#include "../osd/mtlCommon.h"
13
14@protocol MTLDevice;
15@protocol MTLBuffer;
16
17namespace OpenSubdiv {
18namespace OPENSUBDIV_VERSION {
19
20namespace Osd {
21
22 class CPUMTLVertexBuffer {
23public:
24 static CPUMTLVertexBuffer* Create(int numElements, int numVertices, MTLContext* context);
25
26 void UpdateData(const float* src, int startVertex, int numVertices, MTLContext* context);
27
28 int GetNumElements() const
29 {
30 return _numElements;
31 }
32
33 int GetNumVertices() const
34 {
35 return _numVertices;
36 }
37
38 float* BindCpuBuffer();
39 id<MTLBuffer> BindMTLBuffer(MTLContext* context);
40
41 id<MTLBuffer> BindVBO(MTLContext* context)
42 {
43 return BindMTLBuffer(context);
44 }
45
46protected:
47
48 CPUMTLVertexBuffer(int numElements, int numVertices);
49
50 bool allocate(MTLContext* context);
51
52private:
53 int _numElements;
54 int _numVertices;
55 id<MTLBuffer> _buffer;
56 bool _dirty;
57};
58
59} //end namespace Osd
60
61} //end namespace OPENSUBDIV_VERSION
62 using namespace OPENSUBDIV_VERSION;
63
64} //end namespace OpenSubdiv
65
66#endif // OPENSUBDIV3_OSD_MTL_VERTEX_BUFFER_H
mtlCommon.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::MTLContext
Definition mtlCommon.h:23
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CPUMTLVertexBuffer::BindVBO
id< MTLBuffer > BindVBO(MTLContext *context)
Definition mtlVertexBuffer.h:41
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CPUMTLVertexBuffer::CPUMTLVertexBuffer
CPUMTLVertexBuffer(int numElements, int numVertices)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CPUMTLVertexBuffer::Create
static CPUMTLVertexBuffer * Create(int numElements, int numVertices, MTLContext *context)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CPUMTLVertexBuffer::GetNumElements
int GetNumElements() const
Definition mtlVertexBuffer.h:28
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CPUMTLVertexBuffer::UpdateData
void UpdateData(const float *src, int startVertex, int numVertices, MTLContext *context)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CPUMTLVertexBuffer::GetNumVertices
int GetNumVertices() const
Definition mtlVertexBuffer.h:33
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CPUMTLVertexBuffer::BindMTLBuffer
id< MTLBuffer > BindMTLBuffer(MTLContext *context)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CPUMTLVertexBuffer::BindCpuBuffer
float * BindCpuBuffer()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CPUMTLVertexBuffer::allocate
bool allocate(MTLContext *context)