OpenSubdiv: opensubdiv/osd/mtlPatchTable.h Source File

| 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"
12#include "../far/patchDescriptor.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
29 class MTLPatchTable : private NonCopyable<MTLPatchTable> {
30public:
31 using VertexBufferBinding = id<MTLBuffer>; // buffer binding type
32
33 MTLPatchTable();
34 ~MTLPatchTable();
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
48 PatchArrayVector const &GetVaryingPatchArrays() const { return _varyingPatchArrays; }
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
59 PatchArrayVector _patchArrays;
60
61 id<MTLBuffer> _indexBuffer;
62 id<MTLBuffer> _patchParamBuffer;
63
64 PatchArrayVector _varyingPatchArrays;
65
66 id<MTLBuffer> _varyingPatchIndexBuffer;
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
mtlCommon.h
patchDescriptor.h
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:19
OpenSubdiv::OPENSUBDIV_VERSION::Osd
Definition bufferDescriptor.h:17
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArrayVector
std::vector< PatchArray > PatchArrayVector
Definition types.h:115
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition patchTable.h:38
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLContext
Definition mtlCommon.h:23
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable
Definition mtlPatchTable.h:29
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::GetPatchArrays
PatchArrayVector const & GetPatchArrays() const
Definition mtlPatchTable.h:44
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::allocate
bool allocate(Far::PatchTable const *farPatchTable, MTLContext *context)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::Create
static MTLPatchTable * Create(Far::PatchTable const *farPatchTable, MTLContext *context)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::GetVaryingPatchIndexBuffer
id< MTLBuffer > GetVaryingPatchIndexBuffer() const
Definition mtlPatchTable.h:49
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::VertexBufferBinding
id< MTLBuffer > VertexBufferBinding
Definition mtlPatchTable.h:31
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::_fvarIndexBuffers
std::vector< id< MTLBuffer > > _fvarIndexBuffers
Definition mtlPatchTable.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::GetFVarPatchParamBuffer
id< MTLBuffer > GetFVarPatchParamBuffer(int fvarChannel=0) const
Definition mtlPatchTable.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::MTLPatchTable
MTLPatchTable()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::GetPatchParamBuffer
id< MTLBuffer > GetPatchParamBuffer() const
Definition mtlPatchTable.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::GetPatchIndexBuffer
id< MTLBuffer > GetPatchIndexBuffer() const
Definition mtlPatchTable.h:45
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::_patchArrays
PatchArrayVector _patchArrays
Definition mtlPatchTable.h:59
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::GetNumFVarChannels
int GetNumFVarChannels() const
Definition mtlPatchTable.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::GetFVarPatchArrays
PatchArrayVector const & GetFVarPatchArrays(int fvarChannel=0) const
Definition mtlPatchTable.h:52
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::_varyingPatchIndexBuffer
id< MTLBuffer > _varyingPatchIndexBuffer
Definition mtlPatchTable.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::_fvarParamBuffers
std::vector< id< MTLBuffer > > _fvarParamBuffers
Definition mtlPatchTable.h:70
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::_fvarPatchArrays
std::vector< PatchArrayVector > _fvarPatchArrays
Definition mtlPatchTable.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::_patchParamBuffer
id< MTLBuffer > _patchParamBuffer
Definition mtlPatchTable.h:62
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::_varyingPatchArrays
PatchArrayVector _varyingPatchArrays
Definition mtlPatchTable.h:64
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::Create
static MTLPatchTable * Create(Far::PatchTable const *farPatchTable, DEVICE_CONTEXT context)
Definition mtlPatchTable.h:37
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::~MTLPatchTable
~MTLPatchTable()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::GetFVarPatchIndexBuffer
id< MTLBuffer > GetFVarPatchIndexBuffer(int fvarChannel=0) const
Definition mtlPatchTable.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::GetVaryingPatchArrays
PatchArrayVector const & GetVaryingPatchArrays() const
Definition mtlPatchTable.h:48
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLPatchTable::_indexBuffer
id< MTLBuffer > _indexBuffer
Definition mtlPatchTable.h:61
types.h