All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
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 namespace OPENSUBDIV_VERSION {
38 
39 namespace Osd {
40 
41 class MTLLegacyGregoryPatchTable
42 : private NonCopyable<MTLLegacyGregoryPatchTable>
43 {
44 public:
45  ~MTLLegacyGregoryPatchTable();
46 
47  template<typename DEVICE_CONTEXT>
48  static MTLLegacyGregoryPatchTable* Create(Far::PatchTable const* farPatchTable, DEVICE_CONTEXT context) {
49  return Create(farPatchTable, context);
50  }
51 
52  static MTLLegacyGregoryPatchTable* Create(Far::PatchTable const* farPatchTable, MTLContext* context);
53 
54  void UpdateVertexBuffer(id<MTLBuffer> vbo, int numVertices, int numVertexElements, MTLContext* context);
55 
56  id<MTLBuffer> GetVertexBuffer() const
57  {
58  return _vertexBuffer;
59  }
60 
61  id<MTLBuffer> GetVertexValenceBuffer() const
62  {
63  return _vertexValenceBuffer;
64  }
65 
66  id<MTLBuffer> GetQuadOffsetsBuffer() const
67  {
68  return _quadOffsetsBuffer;
69  }
70 
71  int GetQuadOffsetsBase(Far::PatchDescriptor::Type type)
72  {
74  return _quadOffsetsBase[1];
75  return _quadOffsetsBase[0];
76  }
77 
78 private:
79  id<MTLBuffer> _vertexBuffer;
80  id<MTLBuffer> _vertexValenceBuffer;
81  id<MTLBuffer> _quadOffsetsBuffer;
82  int _quadOffsetsBase[2];
83 };
84 
85 } //end namespace Osd
86 
87 } //end namespace OPENSUBDIV_VERSION
88 using namespace OPENSUBDIV_VERSION;
89 
90 } //end namespace OpenSuddiv
91 
92 #endif // OPENSUBDIV3_OSD_MTL_LEGACY_GREGORY_PATCH_TABLE_H