HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawingCoord.h
Go to the documentation of this file.
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 PXR_IMAGING_HD_DRAWING_COORD_H
25 #define PXR_IMAGING_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 
34 
35 /// \class HdDrawingCoord
36 ///
37 /// A tiny set of integers, which provides an indirection mapping from the
38 /// conceptual space of an HdRprim's resources (topological, primvar &
39 /// instancing) to the index within HdBufferArrayRangeContainer, where the
40 /// resource is stored.
41 ///
42 /// Each HdDrawItem contains a HdDrawingCoord, with the relevant compositional
43 /// hierarchy being:
44 ///
45 /// HdRprim
46 /// |
47 /// +--HdRepr(s)
48 /// | |
49 /// | +--HdDrawItem(s)----------.
50 /// | | |
51 /// | +--HdDrawingCoord |
52 /// | | (mapping provided by HdDrawingCoord)
53 /// +--HdRprimSharedData |
54 /// | |
55 /// +--HdBARContainer <--------+
56 ///
57 ///
58 /// Having this indirection provides a recipe for how to configure
59 /// a drawing coordinate, which is a bundle of HdBufferArrayRanges, while
60 /// they are shared or not shared across different representations
61 /// constructed on the same prim.
62 ///
63 /// HullRepr --------- Rprim --------- RefinedRepr
64 /// | | |
65 /// DrawItem | DrawItem
66 /// | | |
67 /// DrawingCoord Container DrawingCoord
68 /// constant -------> [ 0 ] <------ constant
69 /// vertex -------> [ 1 ]
70 /// topology -------> [ 2 ]
71 /// [ 3 ]
72 /// [ 4 ]
73 /// [ 5 ]
74 /// [ 6 ]
75 /// [ 7 ]
76 /// [ 8 ] <------ vertex (refined)
77 /// [ 9 ] <------ topology (refined)
78 /// ...
79 /// instance level=0 ---> [ k ]
80 /// instance level=1 ---> [k+1]
81 /// instance level=2 ---> [k+2]
82 ///
84 public:
85  static const int CustomSlotsBegin = 8;
86  static const int DefaultNumSlots = 3; /* Constant, Vertex, Topology */
87  static const int Unassigned = -1;
88 
90  // default slots:
91  _topology(2),
92  _instancePrimvar(Unassigned),
93  _constantPrimvar(0),
94  _vertexPrimvar(1),
95  _elementPrimvar(3),
96  _instanceIndex(4),
97  _faceVaryingPrimvar(5),
98  _topologyVisibility(6),
99  _varyingPrimvar(7) {
100  }
101 
102  int GetConstantPrimvarIndex() const { return _constantPrimvar; }
103  void SetConstantPrimvarIndex(int slot) { _constantPrimvar = slot; }
104  int GetVertexPrimvarIndex() const { return _vertexPrimvar; }
105  void SetVertexPrimvarIndex(int slot) { _vertexPrimvar = slot; }
106  int GetTopologyIndex() const { return _topology; }
107  void SetTopologyIndex(int slot) { _topology = slot; }
108  int GetElementPrimvarIndex() const { return _elementPrimvar; }
109  void SetElementPrimvarIndex(int slot) { _elementPrimvar = slot; }
110  int GetInstanceIndexIndex() const { return _instanceIndex; }
111  void SetInstanceIndexIndex(int slot) { _instanceIndex = slot; }
112  int GetFaceVaryingPrimvarIndex() const { return _faceVaryingPrimvar; }
113  void SetFaceVaryingPrimvarIndex(int slot) { _faceVaryingPrimvar = slot; }
114  int GetTopologyVisibilityIndex() const { return _topologyVisibility; }
115  void SetTopologyVisibilityIndex(int slot) { _topologyVisibility = slot; }
116  int GetVaryingPrimvarIndex() const { return _varyingPrimvar; }
117  void SetVaryingPrimvarIndex(int slot) { _varyingPrimvar = slot; }
118 
119  // instance primvars take up a range of slots.
120  void SetInstancePrimvarBaseIndex(int slot) { _instancePrimvar = slot; }
122  TF_VERIFY(_instancePrimvar != Unassigned);
123  return _instancePrimvar + level;
124  }
125 
126 private:
127  int16_t _topology;
128  int16_t _instancePrimvar;
129  int8_t _constantPrimvar;
130  int8_t _vertexPrimvar;
131  int8_t _elementPrimvar;
132  int8_t _instanceIndex;
133  int8_t _faceVaryingPrimvar;
134  int8_t _topologyVisibility;
135  int8_t _varyingPrimvar;
136 };
137 
138 
140 
141 #endif // PXR_IMAGING_HD_DRAWING_COORD_H
void SetElementPrimvarIndex(int slot)
Definition: drawingCoord.h:109
static const int CustomSlotsBegin
Definition: drawingCoord.h:85
void SetVertexPrimvarIndex(int slot)
Definition: drawingCoord.h:105
GLint level
Definition: glcorearb.h:108
int GetConstantPrimvarIndex() const
Definition: drawingCoord.h:102
void SetTopologyIndex(int slot)
Definition: drawingCoord.h:107
void SetFaceVaryingPrimvarIndex(int slot)
Definition: drawingCoord.h:113
static const int Unassigned
Definition: drawingCoord.h:87
static const int DefaultNumSlots
Definition: drawingCoord.h:86
void SetTopologyVisibilityIndex(int slot)
Definition: drawingCoord.h:115
int GetTopologyVisibilityIndex() const
Definition: drawingCoord.h:114
int GetFaceVaryingPrimvarIndex() const
Definition: drawingCoord.h:112
void SetVaryingPrimvarIndex(int slot)
Definition: drawingCoord.h:117
int GetTopologyIndex() const
Definition: drawingCoord.h:106
int GetInstancePrimvarIndex(int level) const
Definition: drawingCoord.h:121
int GetVaryingPrimvarIndex() const
Definition: drawingCoord.h:116
void SetConstantPrimvarIndex(int slot)
Definition: drawingCoord.h:103
int GetVertexPrimvarIndex() const
Definition: drawingCoord.h:104
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
void SetInstanceIndexIndex(int slot)
Definition: drawingCoord.h:111
void SetInstancePrimvarBaseIndex(int slot)
Definition: drawingCoord.h:120
int GetElementPrimvarIndex() const
Definition: drawingCoord.h:108
int GetInstanceIndexIndex() const
Definition: drawingCoord.h:110