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 
77 // Allocate a CPU buffer, convert the data from the GT_Data into the correct
78 // format for upload, and place it in the new buffer
79 GR_API extern void * fillAttribData(RV_Render *r,
80  const char *attrib_name,
81  const GT_DataArrayHandle &pa,
82  const GR_DisplayOption &opts,
83  RV_AttributeType array,
84  bool build_string_tables = true);
85 
86 
88  RV_Geometry *geo,
89  const GR_UpdateParms &p,
90  RE_CacheVersion top_ver,
91  GT_DataArrayHandle prim_id,
92  GT_DataArrayHandle pnt_id,
93  GT_DataArrayHandle vert_id,
94  bool is_offset = true,
95  int inst_per_prim = 1,
96  UT_Array<uint8> *selected = nullptr);
97 
98 GR_API extern bool createOrReuseSet(RV_Render* r,
100  int set_num,
102  bool* created = nullptr,
103  const char* name = nullptr);
104 GR_API extern bool initBuiltinBlock(RV_Render* r,
106  const char* name,
109 GR_API extern void loadAtlas(RV_Instance *inst,
110  RV_ShaderAtlas &atlas,
111  UT_Map<exint,RV_ShaderProgram*> &programmap);
112 
113 
114 GR_API extern void buildCurvePrimInfo(const GT_PrimCurveMesh *cmesh,
115  const GR_UpdateParms &p,
116  RV_Geometry* geo,
117  GR_GeoRender* gr,
118  RE_CacheVersion geo_version,
120  UT_Int32Array* opt_curve_oder = nullptr);
121 
122 }
123 
125 {
126 public:
127  GR_InstanceBuffer(const char *name,
129  int vsize,
130  int ninstances,
131  int step = 1)
132  : AttribName(name),
133  Type(type),
134  VectorSize(vsize),
135  NumInstances(ninstances),
136  InstanceStep(step)
137  {}
138 
139  void init(RV_Render *r, int entries);
140 
144  int VectorSize = 4;
145  int NumInstances = 1;
146  int InstanceStep = 1;
147 
149 };
150 
151 #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:164
GLdouble s
Definition: glad.h:3009
GR_InstanceBuffer(const char *name, RV_GPUType type, int vsize, int ninstances, int step=1)
Definition: GR_UtilsVK.h:127
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:141
RV_AttributeType
Definition: RV_Type.h:90
#define GR_API
Definition: GR_API.h:10
GLuint const GLchar * name
Definition: glcorearb.h:786
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:36
GLuint shader
Definition: glcorearb.h:785
RV_GPUType
Definition: RV_Type.h:37
RV_GPUType Type
Definition: GR_UtilsVK.h:143
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:142
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:80
type
Definition: core.h:1059
UT_NON_COPYABLE(GR_InstanceBuffer)
Definition: format.h:895
GR_SelectMode
Definition: GR_Defines.h:229