mtlLegacyGregoryPatchTable.h
Go to the documentation of this file.
1 //
2 // Copyright 2013 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24
25 #ifndef OPENSUBDIV3_OSD_MTL_LEGACY_GREGORY_PATCH_TABLE_H
26 #define OPENSUBDIV3_OSD_MTL_LEGACY_GREGORY_PATCH_TABLE_H
27
28 #include "../version.h"
29 #include "../far/patchTable.h"
30 #include "../osd/nonCopyable.h"
31 #include "../osd/mtlCommon.h"
32
33 @protocol MTLDevice;
34 @protocol MTLBuffer;
35
36 namespace OpenSubdiv
37 {
38 namespace OPENSUBDIV_VERSION
39 {
40 namespace Osd
41 {
42 class MTLLegacyGregoryPatchTable
43 : private NonCopyable<MTLLegacyGregoryPatchTable>
44 {
45 public:
46 ~MTLLegacyGregoryPatchTable();
47
48 template<typename DEVICE_CONTEXT>
49 static MTLLegacyGregoryPatchTable* Create(Far::PatchTable const* farPatchTable, DEVICE_CONTEXT context) {
50 return Create(farPatchTable, context);
51 }
52
53 static MTLLegacyGregoryPatchTable* Create(Far::PatchTable const* farPatchTable, MTLContext* context);
54
55 void UpdateVertexBuffer(id<MTLBuffer> vbo, int numVertices, int numVertexElements, MTLContext* context);
56
57 id<MTLBuffer> GetVertexBuffer() const
58 {
59 return _vertexBuffer;
60 }
61
62 id<MTLBuffer> GetVertexValenceBuffer() const
63 {
64 return _vertexValenceBuffer;
65 }
66
67 id<MTLBuffer> GetQuadOffsetsBuffer() const
68 {
69 return _quadOffsetsBuffer;
70 }
71
72 int GetQuadOffsetsBase(Far::PatchDescriptor::Type type)
73 {
74 if(type == Far::PatchDescriptor::GREGORY_BOUNDARY)
75 return _quadOffsetsBase[1];
76 return _quadOffsetsBase[0];
77 }
78
79 private:
80 id<MTLBuffer> _vertexBuffer;
81 id<MTLBuffer> _vertexValenceBuffer;
82 id<MTLBuffer> _quadOffsetsBuffer;
83 int _quadOffsetsBase[2];
84 };
85 } //end namespace Osd
86 } //end namespace OPENSUBDIV_VERSION
87 using namespace OPENSUBDIV_VERSION;
88 } //end namespace OpenSuddiv
89
90 #endif // OPENSUBDIV3_OSD_MTL_LEGACY_GREGORY_PATCH_TABLE_H
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLLegacyGregoryPatchTable::GetQuadOffsetsBuffer
id< MTLBuffer > GetQuadOffsetsBuffer() const
Definition: mtlLegacyGregoryPatchTable.h:67
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition: patchTable.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Osd::NonCopyable< MTLLegacyGregoryPatchTable >
OpenSubdiv
Definition: error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLLegacyGregoryPatchTable
Definition: mtlLegacyGregoryPatchTable.h:42
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLLegacyGregoryPatchTable::GetVertexBuffer
id< MTLBuffer > GetVertexBuffer() const
Definition: mtlLegacyGregoryPatchTable.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLLegacyGregoryPatchTable::GetVertexValenceBuffer
id< MTLBuffer > GetVertexValenceBuffer() const
Definition: mtlLegacyGregoryPatchTable.h:62
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLContext
Definition: mtlCommon.h:41
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::Type
Type
Definition: patchDescriptor.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLLegacyGregoryPatchTable::Create
static MTLLegacyGregoryPatchTable * Create(Far::PatchTable const *farPatchTable, DEVICE_CONTEXT context)
Definition: mtlLegacyGregoryPatchTable.h:49
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLLegacyGregoryPatchTable::GetQuadOffsetsBase
int GetQuadOffsetsBase(Far::PatchDescriptor::Type type)
Definition: mtlLegacyGregoryPatchTable.h:72