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
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
CPUMTLVertexBuffer(int numElements, int numVertices)
static CPUMTLVertexBuffer * Create(int numElements, int numVertices, MTLContext *context)
void UpdateData(const float *src, int startVertex, int numVertices, MTLContext *context)
id< MTLBuffer > BindMTLBuffer(MTLContext *context)