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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_DRAWING_COORD_H
8 #define PXR_IMAGING_HD_DRAWING_COORD_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/version.h"
13 #include "pxr/base/tf/diagnostic.h"
14 #include <stdint.h>
15 
17 
18 /// \class HdDrawingCoord
19 ///
20 /// A tiny set of integers, which provides an indirection mapping from the
21 /// conceptual space of an HdRprim's resources (topological, primvar &
22 /// instancing) to the index within HdBufferArrayRangeContainer, where the
23 /// resource is stored.
24 ///
25 /// Each HdDrawItem contains a HdDrawingCoord, with the relevant compositional
26 /// hierarchy being:
27 ///
28 /// HdRprim
29 /// |
30 /// +--HdRepr(s)
31 /// | |
32 /// | +--HdDrawItem(s)----------.
33 /// | | |
34 /// | +--HdDrawingCoord |
35 /// | | (mapping provided by HdDrawingCoord)
36 /// +--HdRprimSharedData |
37 /// | |
38 /// +--HdBARContainer <--------+
39 ///
40 ///
41 /// Having this indirection provides a recipe for how to configure
42 /// a drawing coordinate, which is a bundle of HdBufferArrayRanges, while
43 /// they are shared or not shared across different representations
44 /// constructed on the same prim.
45 ///
46 /// HullRepr --------- Rprim --------- RefinedRepr
47 /// | | |
48 /// DrawItem | DrawItem
49 /// | | |
50 /// DrawingCoord Container DrawingCoord
51 /// constant -------> [ 0 ] <------ constant
52 /// vertex -------> [ 1 ]
53 /// topology -------> [ 2 ]
54 /// [ 3 ]
55 /// [ 4 ]
56 /// [ 5 ]
57 /// [ 6 ]
58 /// [ 7 ]
59 /// [ 8 ] <------ vertex (refined)
60 /// [ 9 ] <------ topology (refined)
61 /// ...
62 /// instance level=0 ---> [ k ]
63 /// instance level=1 ---> [k+1]
64 /// instance level=2 ---> [k+2]
65 ///
67 public:
68  static const int CustomSlotsBegin = 8;
69  static const int DefaultNumSlots = 3; /* Constant, Vertex, Topology */
70  static const int Unassigned = -1;
71 
73  // default slots:
74  _topology(2),
75  _instancePrimvar(Unassigned),
76  _constantPrimvar(0),
77  _vertexPrimvar(1),
78  _elementPrimvar(3),
79  _instanceIndex(4),
80  _faceVaryingPrimvar(5),
81  _topologyVisibility(6),
82  _varyingPrimvar(7) {
83  }
84 
85  int GetConstantPrimvarIndex() const { return _constantPrimvar; }
86  void SetConstantPrimvarIndex(int slot) { _constantPrimvar = slot; }
87  int GetVertexPrimvarIndex() const { return _vertexPrimvar; }
88  void SetVertexPrimvarIndex(int slot) { _vertexPrimvar = slot; }
89  int GetTopologyIndex() const { return _topology; }
90  void SetTopologyIndex(int slot) { _topology = slot; }
91  int GetElementPrimvarIndex() const { return _elementPrimvar; }
92  void SetElementPrimvarIndex(int slot) { _elementPrimvar = slot; }
93  int GetInstanceIndexIndex() const { return _instanceIndex; }
94  void SetInstanceIndexIndex(int slot) { _instanceIndex = slot; }
95  int GetFaceVaryingPrimvarIndex() const { return _faceVaryingPrimvar; }
96  void SetFaceVaryingPrimvarIndex(int slot) { _faceVaryingPrimvar = slot; }
97  int GetTopologyVisibilityIndex() const { return _topologyVisibility; }
98  void SetTopologyVisibilityIndex(int slot) { _topologyVisibility = slot; }
99  int GetVaryingPrimvarIndex() const { return _varyingPrimvar; }
100  void SetVaryingPrimvarIndex(int slot) { _varyingPrimvar = slot; }
101 
102  // instance primvars take up a range of slots.
103  void SetInstancePrimvarBaseIndex(int slot) { _instancePrimvar = slot; }
105  TF_VERIFY(_instancePrimvar != Unassigned);
106  return _instancePrimvar + level;
107  }
108 
109 private:
110  int16_t _topology;
111  int16_t _instancePrimvar;
112  int8_t _constantPrimvar;
113  int8_t _vertexPrimvar;
114  int8_t _elementPrimvar;
115  int8_t _instanceIndex;
116  int8_t _faceVaryingPrimvar;
117  int8_t _topologyVisibility;
118  int8_t _varyingPrimvar;
119 };
120 
121 
123 
124 #endif // PXR_IMAGING_HD_DRAWING_COORD_H
void SetElementPrimvarIndex(int slot)
Definition: drawingCoord.h:92
static const int CustomSlotsBegin
Definition: drawingCoord.h:68
void SetVertexPrimvarIndex(int slot)
Definition: drawingCoord.h:88
GLint level
Definition: glcorearb.h:108
int GetConstantPrimvarIndex() const
Definition: drawingCoord.h:85
void SetTopologyIndex(int slot)
Definition: drawingCoord.h:90
void SetFaceVaryingPrimvarIndex(int slot)
Definition: drawingCoord.h:96
static const int Unassigned
Definition: drawingCoord.h:70
static const int DefaultNumSlots
Definition: drawingCoord.h:69
void SetTopologyVisibilityIndex(int slot)
Definition: drawingCoord.h:98
int GetTopologyVisibilityIndex() const
Definition: drawingCoord.h:97
int GetFaceVaryingPrimvarIndex() const
Definition: drawingCoord.h:95
void SetVaryingPrimvarIndex(int slot)
Definition: drawingCoord.h:100
int GetTopologyIndex() const
Definition: drawingCoord.h:89
int GetInstancePrimvarIndex(int level) const
Definition: drawingCoord.h:104
int GetVaryingPrimvarIndex() const
Definition: drawingCoord.h:99
void SetConstantPrimvarIndex(int slot)
Definition: drawingCoord.h:86
int GetVertexPrimvarIndex() const
Definition: drawingCoord.h:87
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
void SetInstanceIndexIndex(int slot)
Definition: drawingCoord.h:94
void SetInstancePrimvarBaseIndex(int slot)
Definition: drawingCoord.h:103
int GetElementPrimvarIndex() const
Definition: drawingCoord.h:91
int GetInstanceIndexIndex() const
Definition: drawingCoord.h:93