HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_UtilsVK.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_UtilsVK.h ( GR Library, C++)
7  *
8  * COMMENTS:
9  * Utility functions for Vulkan GR_GeoRenders.
10  */
11 
12 #ifndef GR_UtilsVK_h
13 #define GR_UtilsVK_h
14 
15 #include "GR_API.h"
16 #include "GR_Defines.h"
17 
18 #include <UT/UT_Map.h>
19 #include <UT/UT_StringHolder.h>
20 #include <UT/UT_UniquePtr.h>
21 #include <UT/UT_VectorTypes.h>
22 #include <GT/GT_Primitive.h>
23 #include <GT/GT_Types.h>
24 
25 #include <RV/RV_Type.h>
26 
27 class GR_DisplayOption;
28 class GR_GeoRender;
29 class GR_UpdateParms;
30 
31 class GT_PrimCurveMesh;
32 
33 class RV_Instance;
34 class RV_Geometry;
35 class RV_Render;
36 class RV_ShaderAtlas;
37 class RV_ShaderBlock;
38 class RV_ShaderProgram;
41 class RV_VKBuffer;
42 
43 
44 class RE_CacheVersion;
45 
46 namespace GR_Utils
47 {
49 {
50  switch(s)
51  {
52  case GT_STORE_UINT8: return RV_GPU_UINT8;
53  case GT_STORE_INT8: return RV_GPU_INT8;
54  case GT_STORE_INT32: return RV_GPU_INT32;
55  case GT_STORE_INT64: return RV_GPU_INT32; // no such 64b type
56  case GT_STORE_REAL16: return RV_GPU_FLOAT16;
57  case GT_STORE_REAL32: return RV_GPU_FLOAT32;
58  case GT_STORE_REAL64: return RV_GPU_FLOAT64;
59  case GT_STORE_STRING: return RV_GPU_INT32; // string indices
60  default:
61  UT_ASSERT(!"No available RV type");
62  return RV_GPU_UINT1;
63  break;
64  }
65 }
66 
67 
68 /// Returns the GPU type and vector size of the attribute based on the
69 /// data array, display option settings and supported Vulkan capabilities.
71  const char *attrib_name,
72  const GT_DataArrayHandle &pa,
73  const GR_DisplayOption &opts,
74  RV_AttributeType array_type,
75  int &out_vsize,
76  bool &out_isnormalized);
77 
78 // Allocate a CPU buffer, convert the data from the GT_Data into the correct
79 // format for upload, and place it in the new buffer
80 GR_API extern void * fillAttribData(RV_Render *r,
81  const char *attrib_name,
82  const GT_DataArrayHandle &pa,
83  const GR_DisplayOption &opts,
84  RV_AttributeType array,
85  bool build_string_tables = true);
86 
87 
89  RV_Geometry *geo,
90  const GR_UpdateParms &p,
91  RE_CacheVersion top_ver,
92  GT_DataArrayHandle prim_id,
93  GT_DataArrayHandle pnt_id,
94  GT_DataArrayHandle vert_id,
95  bool is_offset = true,
96  int inst_per_prim = 1,
97  UT_Array<uint8> *selected = nullptr);
98 
99 GR_API extern bool createOrReuseSet(RV_Render* r,
101  int set_num,
103  bool* created = nullptr,
104  const char* name = nullptr);
105 GR_API extern bool initBuiltinBlock(RV_Render* r,
107  const char* name,
110 GR_API extern void loadAtlas(RV_Instance *inst,
111  RV_ShaderAtlas &atlas,
112  UT_Map<exint,RV_ShaderProgram*> &programmap);
113 
114 
115 GR_API extern void buildCurvePrimInfo(const GT_PrimCurveMesh *cmesh,
116  const GR_UpdateParms &p,
117  RV_Geometry* geo,
118  GR_GeoRender* gr,
119  RE_CacheVersion geo_version,
121  UT_Int32Array* opt_curve_oder = nullptr);
122 
123 }
124 
126 {
127 public:
128  GR_InstanceBuffer(const char *name,
130  int vsize,
131  int ninstances,
132  int step = 1,
133  bool normalized = true)
134  : AttribName(name),
135  Type(type),
136  VectorSize(vsize),
137  NumInstances(ninstances),
138  InstanceStep(step),
140  {}
141 
142  void init(RV_Render *r, int entries);
143  void initCPUMapped(RV_Render *r, int entries, bool cpu_mapped = true);
144 
148  int VectorSize = 4;
149  int NumInstances = 1;
150  int InstanceStep = 1;
151  bool NormalizedFormat = true;
152 
154 };
155 
156 #endif
A collection of Vulkan UBO, SSBO, and Image shader bindings (descriptor set)
GT_Storage
Definition: GT_Types.h:19
void init(RV_Render *r, int entries)
GR_API void loadAtlas(RV_Instance *inst, RV_ShaderAtlas &atlas, UT_Map< exint, RV_ShaderProgram * > &programmap)
RV_GPUType getRVType(GT_Storage s)
Definition: GR_UtilsVK.h:48
GR_API void buildCurvePrimInfo(const GT_PrimCurveMesh *cmesh, const GR_UpdateParms &p, RV_Geometry *geo, GR_GeoRender *gr, RE_CacheVersion geo_version, UT_Vector4iArray &data, UT_Int32Array *opt_curve_oder=nullptr)
Object that represents drawable geometry. This object holds vertex, instancing and index buffers for ...
Definition: RV_Geometry.h:165
GLdouble s
Definition: glad.h:3009
GR_API bool createOrReuseSet(RV_Render *r, UT_UniquePtr< RV_ShaderVariableSet > &set, int set_num, const RV_ShaderProgramBase *shader, bool *created=nullptr, const char *name=nullptr)
A mesh of curves.
GR_API void * fillAttribData(RE_Render *r, const char *attrib_name, const GT_DataArrayHandle &pa, const GR_DisplayOption &opts, RE_ArrayType array, bool build_string_tables=true)
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()
UT_UniquePtr< RV_VKBuffer > Buffer
Definition: GR_UtilsVK.h:145
RV_AttributeType
Definition: RV_Type.h:96
#define GR_API
Definition: GR_API.h:10
GLuint const GLchar * name
Definition: glcorearb.h:786
GLint GLenum GLboolean normalized
Definition: glcorearb.h:872
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:38
GR_InstanceBuffer(const char *name, RV_GPUType type, int vsize, int ninstances, int step=1, bool normalized=true)
Definition: GR_UtilsVK.h:128
GLuint shader
Definition: glcorearb.h:785
RV_GPUType
Definition: RV_Type.h:37
RV_GPUType Type
Definition: GR_UtilsVK.h:147
GR_API RE_GPUType getAttributeType(RE_Render *r, const char *attrib_name, int &vsize, const GT_DataArrayHandle &pa, const GR_DisplayOption &opts, RE_ArrayType array_type)
GR_API GR_SelectMode buildInstSelectInfo(RE_Render *r, RE_Geometry *geo, const GR_UpdateParms &p, RE_CacheVersion top_ver, GT_DataArrayHandle primid, GT_DataArrayHandle vtxid, GT_DataArrayHandle vertid, bool is_offsets=true, int instances_per_prim=1, UT_Array< uint8 > *result=NULL)
UT_StringHolder AttribName
Definition: GR_UtilsVK.h:146
Simple class for a mutli-integer cache tag.
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
GR_API bool initBuiltinBlock(RV_Render *r, UT_UniquePtr< RV_ShaderBlock > &block, const char *name, RV_ShaderVariableSet *set, const RV_ShaderProgramBase *shader)
GLboolean r
Definition: glcorearb.h:1222
A vulkan buffer object.
Definition: RV_VKBuffer.h:81
void initCPUMapped(RV_Render *r, int entries, bool cpu_mapped=true)
type
Definition: core.h:1059
UT_NON_COPYABLE(GR_InstanceBuffer)
Definition: format.h:895
GR_SelectMode
Definition: GR_Defines.h:241