All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawingCoord.h
1 //
2 // Copyright 2016 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 #ifndef HD_DRAWING_COORD_H
25 #define HD_DRAWING_COORD_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/base/tf/diagnostic.h"
31 #include <stdint.h>
32 
33 PXR_NAMESPACE_OPEN_SCOPE
34 
82 public:
83  static const int CustomSlotsBegin = 7;
84  static const int DefaultNumSlots = 3; /* Constant, Vertex, Topology */
85  static const int Unassigned = -1;
86 
87  HdDrawingCoord() :
88  // default slots:
89  _constantPrimvar(0),
90  _vertexPrimvar(1),
91  _topology(2),
92  _elementPrimvar(3),
93  _instanceIndex(4),
94  _faceVaryingPrimvar(5),
95  _topologyVisibility(6),
96  _instancePrimvar(Unassigned) {
97  }
98 
99  int GetConstantPrimvarIndex() const { return _constantPrimvar; }
100  void SetConstantPrimvarIndex(int slot) { _constantPrimvar = slot; }
101  int GetVertexPrimvarIndex() const { return _vertexPrimvar; }
102  void SetVertexPrimvarIndex(int slot) { _vertexPrimvar = slot; }
103  int GetTopologyIndex() const { return _topology; }
104  void SetTopologyIndex(int slot) { _topology = slot; }
105  int GetElementPrimvarIndex() const { return _elementPrimvar; }
106  void SetElementPrimvarIndex(int slot) { _elementPrimvar = slot; }
107  int GetInstanceIndexIndex() const { return _instanceIndex; }
108  void SetInstanceIndexIndex(int slot) { _instanceIndex = slot; }
109  int GetFaceVaryingPrimvarIndex() const { return _faceVaryingPrimvar; }
110  void SetFaceVaryingPrimvarIndex(int slot) { _faceVaryingPrimvar = slot; }
111  int GetTopologyVisibilityIndex() const { return _topologyVisibility; }
112  void SetTopologyVisibilityIndex(int slot) { _topologyVisibility = slot; }
113 
114  // instance primvars take up a range of slots.
115  void SetInstancePrimvarBaseIndex(int slot) { _instancePrimvar = slot; }
116  int GetInstancePrimvarIndex(int level) const {
117  TF_VERIFY(_instancePrimvar != Unassigned);
118  return _instancePrimvar + level;
119  }
120 
121 private:
122  int8_t _constantPrimvar;
123  int8_t _vertexPrimvar;
124  int8_t _topology;
125  int8_t _elementPrimvar;
126  int8_t _instanceIndex;
127  int8_t _faceVaryingPrimvar;
128  int8_t _topologyVisibility;
129  int8_t _instancePrimvar;
130 };
131 
132 
133 PXR_NAMESPACE_CLOSE_SCOPE
134 
135 #endif // HD_DRAWING_COORD_H
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition: diagnostic.h:289
A tiny set of integers, which provides an indirection mapping from the conceptual space of an HdRprim...
Definition: drawingCoord.h:81