HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_PrimAgentShape.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GR_PrimAgentShape.h (GR Library, C++)
7  *
8  * COMMENTS:
9  */
10 #ifndef GR_PrimAgentShape_h
11 #define GR_PrimAgentShape_h
12 
13 #include "GR_PrimPacked.h"
14 #include <UT/UT_NonCopyable.h>
15 #include <GT/GT_PrimAgentShape.h>
16 #include <GT/GT_AgentSupport.h>
17 
18 #ifdef USE_VULKAN
19 #include "GR_UtilsVK.h"
20 class RV_ShaderBlock;
22 class GR_VulkanAgentData : public GT_VulkanAgentData
23 {
24 public:
25  GR_VulkanAgentData() {}
26 
27  UT_NON_COPYABLE(GR_VulkanAgentData);
28 
32  UT_Array<UT_UniquePtr<GR_InstanceBuffer>> InstanceTransforms;
36  UT_Array<RE_CacheVersion> SelVersion;
37 };
38 #endif
39 
40 
42 {
43 public:
44  GR_PrimAgentShape(const GR_RenderInfo *info,
45  const char *cache_name,
46  const GT_PrimitiveHandle &pack_prim,
47  const GT_PrimitiveHandle &shape_prim);
48  ~GR_PrimAgentShape() override;
49 
50  const char *className() const override { return "GR_PrimAgentShape"; }
51 
53  { return GR_BASE_PRIM_AGENT_SHAPE; }
54 
56  int geo_type,
57  const GT_PrimitiveHandle &ph,
58  const GEO_Primitive *prim) override;
59 
60  GR_DispOptChange displayOptionChange(const GR_DisplayOption &opt,
61  bool first_init) override;
62 
64  const GT_PrimitiveHandle &primh,
65  const GR_UpdateParms &p) override;
66 
68  GR_RenderMode render_mode,
70  GR_DrawParms dp) override;
71 
73  const GR_DisplayOption *opt,
74  unsigned int pick_type,
75  GR_PickStyle pick_style,
76  bool has_pick_map) override;
77 
79  const GR_DisplayOption &opt) const override
80  { return opt.shadingMode() >= GR_FLAT_SHADED; }
82  const GR_ViewUpdateParms &parms) override;
83 
85  const UT_Matrix4D &objviewprojj,
86  const UT_BoundingBoxD *bbox = nullptr) override
87  { return myVisibilityFlag; }
88 
89  bool requiresAlphaPass() const override { return false; }
90  bool getSingleTransform(UT_Matrix4D &mat) const override
91  { return false; }
92 
93 #ifdef USE_VULKAN
94  static bool initShaders(RV_Instance* inst);
95  static void cleanupShaders();
96 #endif
97 private:
98  const GT_PrimAgentShape &getShape() const
99  {
100  return *UTverify_cast<const GT_PrimAgentShape *>(myPackedPrim.get());
101  }
102 
103  void processVisibility(RE_RenderContext r,
104  const GR_DisplayOption &dopts);
105  void updateTransforms(RE_RenderContext r,
106  const GU_ConstDetailHandle &geo,
107  bool geo_changed);
108  void updateInstanceTransforms(RE_RenderContext r,
109  const GU_ConstDetailHandle &geo,
110  bool geo_changed);
111  void updateRigTransformsGL(RE_Render *r,
112  const GU_ConstDetailHandle &geo,
113  bool geo_changed);
114  void updateBlendWeightsGL(RE_Render *r,
115  const GU_ConstDetailHandle &geo,
116  bool geo_changed);
117  void processSelectionGL(RE_RenderContext r,
118  const RE_CacheVersion &select_ver);
119 
120 #ifdef USE_VULKAN
121  void updateRigTransforms(RV_Render *r,
122  const GU_ConstDetailHandle &geo,
123  bool geo_changed);
124  void updatePrimID(RV_Render *r, bool geo_changed);
125  void updateColor(RV_Render *r, bool geo_changed);
126  void processSelection(RV_Render *r,
127  const RE_CacheVersion &select_version);
128  void updateBlendWeights(RV_Render *r,
129  const GU_ConstDetailHandle &geo,
130  bool geo_changed);
131 #endif
132  void freeVertexArrays();
133  void updatePrimIDGL(RE_Render *r, bool geo_changed);
134  void updateColorGL(RE_Render *r, bool geo_changed);
135 
136  int myLODLevel;
137  int myTotalAgents;
138  int64 myLastInstVersion;
139  int myTransformSerial;
140  int mySelectionSerial;
141  int myRigSerial;
142  GT_ShapeLODGroupHandle myShapeGroup;
143  UT_IntArray myTransformIndexMap;
144  GR_UpdateReason myDeferredReason;
145  bool myDeformingShape;
146  bool myVisibilityFlag;
147  bool myLastWire;
148  bool myLastLODEnable;
149  fpreal myLastLODBias;
150  int myLastLODBase;
151 
152  // Only the primary LOD holds any of these.
153  UT_Array<RE_VertexArray *> myTransformVA;
154  UT_Array<RE_VertexArray *> myRigTransformVA;
155  UT_Array<RE_VertexArray *> myBlendWeightVA;
156  UT_Array<RE_VertexArray *> myShapeSelectionVA;
157  UT_Array<RE_VertexArray *> myPrimIDVA;
159 
160 #ifdef USE_VULKAN
162 #endif
163 };
164 
165 
166 
167 #endif
A collection of Vulkan UBO, SSBO, and Image shader bindings (descriptor set)
bool inViewFrustum(const UT_Matrix4D &objviewprojj, const UT_BoundingBoxD *bbox=nullptr) override
GLbitfield flags
Definition: glcorearb.h:1596
int renderPick(RE_RenderContext r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map) override
UT_NON_COPYABLE(GT_VulkanAgentData)
RE_VertexArray * myColorVA
void render(RE_RenderContext r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms dp) override
Set of parameters sent to GR_Primitive::viewUpdate().
void shadingMode(GR_ShadingMode shading_mode)
void viewUpdate(RE_RenderContext r, const GR_ViewUpdateParms &parms) override
GT_API const UT_StringHolder cache_name
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:229
Temporary container for either a RV_Render and an RE_Render.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
set of parameters sent to GR_Primitive::update()
GR_RenderMode
Definition: GR_Defines.h:48
GR_BasePrimType
Definition: GR_Defines.h:366
GR_PrimAcceptResult acceptPrimitive(GT_PrimitiveType t, int geo_type, const GT_PrimitiveHandle &ph, const GEO_Primitive *prim) override
#define GR_API
Definition: GR_API.h:10
GR_UpdateReason
Definition: GR_Defines.h:312
long long int64
Definition: SYS_Types.h:116
bool updateOnViewChange(const GR_DisplayOption &opt) const override
If this primitive requires an update when the view changes, return true.
GR_PrimAcceptResult
Definition: GR_Defines.h:359
GR_RenderFlags
Definition: GR_Defines.h:86
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:38
GLdouble t
Definition: glad.h:2397
const char * className() const override
Return a string version of this class's name.
GT_PrimitiveType
GR_DispOptChange displayOptionChange(const GR_DisplayOption &opts, bool first_init) override
fpreal64 fpreal
Definition: SYS_Types.h:277
A shape belonging to agents, instanced with material assignments.
void update(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p) override
GR_BasePrimType getBasePrimType() const override
The base primitive type is usually NORMAL unless this is a packed type.
bool requiresAlphaPass() const override
Return true if this primitive requires an alpha pass.
Simple class for a mutli-integer cache tag.
GLboolean r
Definition: glcorearb.h:1222
bool getSingleTransform(UT_Matrix4D &mat) const override
GR_PickStyle
Definition: GR_Defines.h:252