OpenSubdiv
Loading...
Searching...
No Matches
mtlPatchTable.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_PATCH_TABLE_H
9#define OPENSUBDIV3_OSD_MTL_PATCH_TABLE_H
10
11#include "../version.h"
13#include "../osd/nonCopyable.h"
14#include "../osd/types.h"
15#include "../osd/mtlCommon.h"
16
17@protocol MTLDevice;
18@protocol MTLBuffer;
19
20namespace OpenSubdiv {
21namespace OPENSUBDIV_VERSION {
22
23namespace Far {
24 class PatchTable;
25};
26
27namespace Osd {
28
29class MTLPatchTable : private NonCopyable<MTLPatchTable> {
30public:
31 using VertexBufferBinding = id<MTLBuffer>; // buffer binding type
32
35
36 template<typename DEVICE_CONTEXT>
37 static MTLPatchTable *Create(Far::PatchTable const *farPatchTable, DEVICE_CONTEXT context)
38 {
39 return Create(farPatchTable, context);
40 }
41
42 static MTLPatchTable *Create(Far::PatchTable const *farPatchTable, MTLContext* context);
43
44 PatchArrayVector const &GetPatchArrays() const { return _patchArrays; }
45 id<MTLBuffer> GetPatchIndexBuffer() const { return _indexBuffer; }
46 id<MTLBuffer> GetPatchParamBuffer() const { return _patchParamBuffer; }
47
49 id<MTLBuffer> GetVaryingPatchIndexBuffer() const { return _varyingPatchIndexBuffer; }
50
51 int GetNumFVarChannels() const { return (int)_fvarPatchArrays.size(); }
52 PatchArrayVector const &GetFVarPatchArrays(int fvarChannel = 0) const { return _fvarPatchArrays[fvarChannel]; }
53 id<MTLBuffer> GetFVarPatchIndexBuffer(int fvarChannel = 0) const { return _fvarIndexBuffers[fvarChannel]; }
54 id<MTLBuffer> GetFVarPatchParamBuffer(int fvarChannel = 0) const { return _fvarParamBuffers[fvarChannel]; }
55
56protected:
57 bool allocate(Far::PatchTable const *farPatchTable, MTLContext* context);
58
60
61 id<MTLBuffer> _indexBuffer;
62 id<MTLBuffer> _patchParamBuffer;
63
65
67
68 std::vector<PatchArrayVector> _fvarPatchArrays;
69 std::vector<id<MTLBuffer>> _fvarIndexBuffers;
70 std::vector<id<MTLBuffer>> _fvarParamBuffers;
71};
72
73} // end namespace Osd
74
75} //end namespace OPENSUBDIV_VERSION
76using namespace OPENSUBDIV_VERSION;
77
78} //end namespace OpenSubdiv
79
80#endif //end OPENSUBDIV3_OSD_MTL_PATCH_TABLE_H
std::vector< PatchArray > PatchArrayVector
Definition types.h:115
Container for arrays of parametric patches.
Definition patchTable.h:38
PatchArrayVector const & GetPatchArrays() const
bool allocate(Far::PatchTable const *farPatchTable, MTLContext *context)
static MTLPatchTable * Create(Far::PatchTable const *farPatchTable, MTLContext *context)
std::vector< id< MTLBuffer > > _fvarIndexBuffers
id< MTLBuffer > GetFVarPatchParamBuffer(int fvarChannel=0) const
PatchArrayVector const & GetFVarPatchArrays(int fvarChannel=0) const
std::vector< id< MTLBuffer > > _fvarParamBuffers
std::vector< PatchArrayVector > _fvarPatchArrays
static MTLPatchTable * Create(Far::PatchTable const *farPatchTable, DEVICE_CONTEXT context)
id< MTLBuffer > GetFVarPatchIndexBuffer(int fvarChannel=0) const
PatchArrayVector const & GetVaryingPatchArrays() const