HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_Type.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: RV_Type.h ( RV Library, C++)
7  *
8  * COMMENTS:
9  * shared types for RV library
10  */
11 
12 #ifndef RV_Type_h
13 #define RV_Type_h
14 
15 #include "RV_API.h"
16 
17 #include <RE/RE_Types.h>
18 #include <RE/RE_TextureTypes.h>
19 
20 #include <UT/UT_ComputeGPU.h>
21 #include <UT/UT_Matrix4.h>
22 #include <UT/UT_StringArray.h>
23 #include <UT/UT_SharedPtr.h>
24 
25 #include <SYS/SYS_AtomicInt.h>
26 
27 // indices for specific Descriptor Sets
28 // must match shaders
30 {
37 };
38 
39 
41 {
44 
48 
52 
57 
58  // These can only be used in the context of a GLSL shader.
62 
64 
65 };
66 
68 {
69  // Currently this is a pretty trivial transform.
70  return RV_GPUType(t);
71 }
72 
74 {
75  // Currently this is a pretty trivial transform.
76  return RE_GPUType(t);
77 }
78 
80 {
82 
85  RV_DEVICE_INTEL_GMA = 0x4, // Intel GMA (not supported)
86  RV_DEVICE_INTEL_HD = 0x8, // Intel HD graphics
87  RV_DEVICE_GDI = 0x10, // Software OGL on Windows
89 
90  RV_DEVICE_PRO = 0x100, // Professional series
91  RV_DEVICE_MAC = 0x200, // Mac versions of drivers
92  RV_DEVICE_MAC_SILICON = 0x600, // ARM-based Macs
93 
97 };
98 
100 {
104  // RV_ATTRIBUTE_INSTANCE,
106  RV_ATTRIBUTE_RANDOM, // randomly sampled NOTE: also used for INSTANCE-level
108 };
109 
110 
112 {
118 };
119 
121 {
132 
134 };
135 
137 {
138  RV_FILTER_NEAREST, // no filtering
139  RV_FILTER_LINEAR, // bi-linear filtering
140  RV_FILTER_CUBIC, // bi-cubic filtering NOTE: requires extension
141 };
142 
144 {
145  RV_MIPMAP_DISABLED, // No Mip filtering
146  RV_MIPMAP_NEAREST, // nearest mip level
147  RV_MIPMAP_LINEAR // linear blending
148 };
149 
151 {
152  RV_TEX_WRAP_REPEAT, // texture repeats, tiling
153  RV_TEX_WRAP_CLAMP, // edge pixel is stretched
154  RV_TEX_WRAP_BORDER, // outside pixels are a const colour
155  RV_TEX_WRAP_MIRROR // texture repeats, mirrored tiling
156 };
157 
159 {
160 public:
161  UT_StringHolder Layer; // Layer name within a deep raster file. C if ""
162  UT_StringHolder ColorSpace; // OCIO colorspace of the source, auto if ""
163  fpreal ImageScale = 1.0; // Scale to apply to loaded images
164  exint MaxWidth = 0; // 0 = no limit
169  bool MipMap = false;
170  fpreal MinLOD = 0.0;
171  fpreal MaxLOD = -1.0; // Default no limit to mip levels
172  bool LinearInterp = true; // Use bilinear or trilinear interpolation
173  bool IntTexture = false; // If INT/UINT 8/16 is normalized or as-is
174  bool SampleTexels = false; // if UV is [0,1] (false) or [0,res) (true).
175  bool CheckAlpha = false; // check for detailed info about alpha
176  int Anisotropy = 4;
177  RV_TextureWrap WrapU = RV_TEX_WRAP_REPEAT; // behaviour outside (0,1) uv
181  fpreal32 BorderColor[4] = { 0.0, 0.0, 0.0, 0.0 };
182  bool IsData = false;
183 };
184 
185 /// ID used to individually identify Vulkan Resources, and an
186 /// index used for fast-lookup inside RV_Instance
188 {
189  exint id = 0;
191 
192  operator bool() const
193  { return id != 0; }
194 
195  bool operator==(const RV_ResourceID &other) const
196  { return other.id == id; }
197 
198  RV_ResourceID() = default;
199  RV_ResourceID& operator=(const RV_ResourceID &other) = default;
200  RV_ResourceID(const RV_ResourceID &other) = default;
201 };
202 
204 {
213 };
214 
216 {
223  //RV_UNIFORM_IMAGE_UNTYPED, // for `shaderStorageImageReadWithoutFormat`
227 };
228 
229 // Testing using a struct type instead of giant enum
230 // -- worried the helper functions for the giant enum
231 // will be fragile when we want to add new types
233 {
234  unsigned int vecsize : 2;
238 };
239 
241 {
244 
298 
301 
348 
350 
352 
354 };
355 
357 {
360 
362 
365  RV_PRIM_LINE_LOOPS, // NOTE: no direct Vk analogue
366 
370 
371  RV_PRIM_LINES_ADJACENT, // for geometry shaders; includes
372  RV_PRIM_LINE_STRIP_ADJACENT, // extra vertices outside the primitive
373  RV_PRIM_TRIANGLES_ADJACENT, // for curvature
375 
376  RV_PRIM_POLYGONS, // NOTE: no direct Vk analogue
377 
378  RV_PRIM_PATCHES, // Patches sent to tessellation shaders
379 
381 };
382 
384 {
391 };
392 
394 {
398  // RV_RESOLVE_BUFFER, // for now uneeded; we handle resolve in shader
399 };
400 
402 {
408 };
409 
411 {
416 };
417 
419 {
424 };
425 
427 {
431 };
432 
434 {
440 };
441 
443 {
445  RV_STAGE_ANY = 0, // ALWAYS need to be execute
450  RV_STAGE_ANY_SHADER, // will be run for UBOs/SSBOs which can be consumed by compute or graphics pipelines
452 };
453 
455 {
459 };
460 
462 {
465 };
466 
468 {
471 
473 };
474 
476 
479  RV_GPUType &out_type,
480  int &out_vecsize);
482 
483 inline bool RVisUIntGPUType(RV_GPUType gpu_type)
484 {
485  return gpu_type >= RV_GPU_UINT8 && gpu_type <= RV_GPU_UINT32;
486 }
487 
488 inline bool RVisIntGPUType(RV_GPUType gpu_type)
489 {
490  return gpu_type >= RV_GPU_INT8 && gpu_type <= RV_GPU_INT32;
491 }
492 
493 inline bool RVisFloatGPUType(RV_GPUType gpu_type)
494 {
495  return gpu_type >= RV_GPU_FLOAT16 && gpu_type <= RV_GPU_FLOAT64;
496 }
497 
498 inline bool RVisMatrixGPUType(RV_GPUType gpu_type)
499 {
500  return gpu_type >= RV_GPU_MATRIX2 && gpu_type <= RV_GPU_MATRIX4;
501 }
502 
503 inline uint32_t RVsizeOfGPUType(RV_GPUType gpu_type)
504 {
505  int bpp = 32;
506 
507  switch (gpu_type)
508  {
509  // NOTE: that int-1 and int-4 don't correspond to
510  // actual Vulkan types
511  case RV_GPU_UINT1:
512  bpp = 1; break;
513  case RV_GPU_UINT4:
514  bpp = 4; break;
515 
516  case RV_GPU_INT8:
517  case RV_GPU_UINT8:
518  bpp = 8; break;
519 
520  case RV_GPU_INT16:
521  case RV_GPU_UINT16:
522  case RV_GPU_FLOAT16:
523  bpp = 16; break;
524 
525  case RV_GPU_INT32:
526  case RV_GPU_UINT32:
527  case RV_GPU_FLOAT32:
528  case RV_GPU_FLOAT24:
529  bpp = 32; break;
530 
531  case RV_GPU_FLOAT64:
532  bpp = 64; break;
533 
534  case RV_GPU_MATRIX2:
535  bpp = 32 * 4; break;
536  case RV_GPU_MATRIX3:
537  bpp = 32 * 9; break;
538  case RV_GPU_MATRIX4:
539  bpp = 32 * 16; break;
540  default:
541  bpp = 32;
542  UT_ASSERT_MSG(0, "RVsizeOfGPUType(): Unrecognized RV_GPUType");
543  }
544 
545  return bpp;
546 }
547 
549 {
550  switch(type)
551  {
552  case RE_CLAMP_REPEAT : return RV_TEX_WRAP_REPEAT;
553  case RE_CLAMP_BORDER : return RV_TEX_WRAP_BORDER;
554  case RE_CLAMP_EDGE : return RV_TEX_WRAP_CLAMP;
555  case RE_CLAMP_MIRROR : return RV_TEX_WRAP_MIRROR;
556  }
557  return RV_TEX_WRAP_REPEAT;
558 }
559 
561 {
562  switch (t)
563  {
564  case RV_PRIM_POINTS :
565  return RV_TOPOLOGY_POINT;
566  case RV_PRIM_LINES:
567  case RV_PRIM_LINE_STRIP:
570  return RV_TOPOLOGY_LINE;
571  case RV_PRIM_TRIANGLES:
576  return RV_TOPOLOGY_TRIANGLE;
577  case RV_PRIM_PATCHES:
578  return RV_TOPOLOGY_PATCH;
579  default: break;
580  }
581  UT_ASSERT(false && "Unrecognized Topology Type used for Pipeline");
582  return RV_TOPOLOGY_UNKNOWN;
583 }
584 
586 {
587  switch(type)
588  {
589  case RE_PRIM_POINTS : return RV_PRIM_POINTS;
590  case RE_PRIM_LINES : return RV_PRIM_LINES;
592  case RE_PRIM_TRIANGLES : return RV_PRIM_TRIANGLES;
599  case RE_PRIM_POLYGONS : return RV_PRIM_POLYGONS;
600  case RE_PRIM_PATCHES : return RV_PRIM_PATCHES;
601  case RE_PRIM_NONE :
602  case RE_NUM_PRIM_TYPES :
603  case RE_PRIM_LINE_LOOP :
604  default : break;
605  }
606  return RV_PRIM_NONE;
607 }
608 
609 const char *RVgetTypeName(RV_GPUType t);
610 
611 const char *RVgetPrimName(RV_PrimType p);
612 
614 
616 {
618 }
619 
621 {
623 }
624 
626 
627 int RVgetNumberOfPrim(RV_PrimType p, int num_verts);
628 
629 #endif
RV_TextureSwizzle
Definition: RV_Type.h:203
RV_TextureWrap WrapW
Definition: RV_Type.h:179
RV_UniformVarType
Definition: RV_Type.h:215
bool CheckAlpha
Definition: RV_Type.h:175
RE_GPUType RVgetREType(RV_GPUType t)
Definition: RV_Type.h:73
RV_ImageOp
Definition: RV_Type.h:401
exint MaxWidth
Definition: RV_Type.h:164
RV_ImageDim image_dim
Definition: RV_Type.h:237
RV_PrimType RVconvertToRVPrim(RE_PrimType type)
Definition: RV_Type.h:585
bool IntTexture
Definition: RV_Type.h:173
bool RVisFloatGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:493
bool LinearInterp
Definition: RV_Type.h:172
exint id
Definition: RV_Type.h:189
RV_GPUType data_type
Definition: RV_Type.h:235
int64 exint
Definition: SYS_Types.h:125
RV_StageGroup
Definition: RV_Type.h:442
UT_StringHolder Layer
Definition: RV_Type.h:161
bool RVisIntGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:488
int RVgetPointsPerPrim(RV_PrimType p)
const char * RVgetTypeName(RV_GPUType t)
RV_API RV_ImageDim RVgetUniformTypeImageDim(RV_UniformType t)
float fpreal32
Definition: SYS_Types.h:200
RV_TextureMipMode
Definition: RV_Type.h:143
OutGridT const XformOp bool bool
fpreal ImageScale
Definition: RV_Type.h:163
UT_StringArray RV_OverrideList
Definition: RV_Type.h:475
exint MaxMemoryMB
Definition: RV_Type.h:168
#define UT_ASSERT_MSG(ZZ,...)
Definition: UT_Assert.h:168
RV_AttachmentType
Definition: RV_Type.h:393
exint MaxComponents
Definition: RV_Type.h:167
RE_GPUType
Definition: RE_Types.h:52
UT_StringHolder ColorSpace
Definition: RV_Type.h:162
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
RV_SetType
Definition: RV_Type.h:29
RV_ResourceID()=default
RV_TextureWrap WrapU
Definition: RV_Type.h:177
RV_GraphicsDevice
Definition: RV_Type.h:79
RV_AccelStructTag
Definition: RV_Type.h:461
RV_AttributeType
Definition: RV_Type.h:99
RV_UniformVarType var_type
Definition: RV_Type.h:236
RV_UniformType
Definition: RV_Type.h:240
RV_PolygonMode
Definition: RV_Type.h:426
RE_TexClampType
RV_TextureWrap RVconvertToTextureWrap(RE_TexClampType type)
Definition: RV_Type.h:548
#define RV_API
Definition: RV_API.h:10
bool RVisBasicType(RV_UniformType t)
Definition: RV_Type.h:615
RV_TextureWrap
Definition: RV_Type.h:150
RV_AccelStructBuildPref
Definition: RV_Type.h:454
const char * RVgetPrimName(RV_PrimType p)
int RVgetNumberOfPrim(RV_PrimType p, int num_verts)
fpreal MinLOD
Definition: RV_Type.h:170
bool RVisUIntGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:483
RV_TextureFilter
Definition: RV_Type.h:136
bool SampleTexels
Definition: RV_Type.h:174
GLdouble t
Definition: glad.h:2397
RV_GPUType RVgetFromREType(RE_GPUType t)
Definition: RV_Type.h:67
RV_ShaderType
Definition: RV_Type.h:418
RV_TextureWrap WrapV
Definition: RV_Type.h:178
RV_PrimType
Definition: RV_Type.h:356
uint32_t RVsizeOfGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:503
const char * RVgetUniformTypeName(RV_UniformType t)
RV_TopologyClass RVgetTopologyClass(RV_PrimType t)
Definition: RV_Type.h:560
bool RVisMatrixGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:498
exint MaxDepth
Definition: RV_Type.h:166
RV_TopologyClass
Definition: RV_Type.h:383
RV_GPUType
Definition: RV_Type.h:40
fpreal64 fpreal
Definition: SYS_Types.h:283
RV_LogicOp
Definition: RV_Type.h:433
GLuint index
Definition: glcorearb.h:786
RV_MemType
Definition: RV_Type.h:111
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:165
bool RVisOpaqueType(RV_UniformType t)
Definition: RV_Type.h:620
RV_RenderPassType
Definition: RV_Type.h:410
bool operator==(const RV_ResourceID &other) const
Definition: RV_Type.h:195
unsigned int vecsize
Definition: RV_Type.h:234
RV_ResourceID & operator=(const RV_ResourceID &other)=default
RV_ImageDim
Definition: RV_Type.h:120
RE_PrimType
Definition: RE_Types.h:199
fpreal32 BorderColor[4]
Definition: RV_Type.h:181
RV_TextureFilter Filter
Definition: RV_Type.h:180
RV_API bool RVgetUniformFormat(RV_UniformType t, RV_GPUType &out_type, int &out_vecsize)
fpreal MaxLOD
Definition: RV_Type.h:171
exint MaxHeight
Definition: RV_Type.h:165
RV_AccelStructVisibility
Definition: RV_Type.h:467