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 
24 // indices for specific Descriptor Sets
25 // must match shaders
27 {
34 };
35 
36 
38 {
41 
45 
49 
54 
55  // These can only be used in the context of a GLSL shader.
59 
61 
62 };
63 
65 {
66  // Currently this is a pretty trivial transform.
67  return RV_GPUType(t);
68 }
69 
71 {
72  // Currently this is a pretty trivial transform.
73  return RE_GPUType(t);
74 }
75 
77 {
79 
82  RV_DEVICE_INTEL_GMA = 0x4, // Intel GMA (not supported)
83  RV_DEVICE_INTEL_HD = 0x8, // Intel HD graphics
84  RV_DEVICE_GDI = 0x10, // Software OGL on Windows
86 
87  RV_DEVICE_PRO = 0x100, // Professional series
88  RV_DEVICE_MAC = 0x200, // Mac versions of drivers
89  RV_DEVICE_MAC_SILICON = 0x600, // ARM-based Macs
90 
94 };
95 
97 {
101  // RV_ATTRIBUTE_INSTANCE,
103  RV_ATTRIBUTE_RANDOM, // randomly sampled NOTE: also used for INSTANCE-level
105 };
106 
107 
109 {
115 };
116 
118 {
129 
131 };
132 
134 {
135  RV_FILTER_NEAREST, // no filtering
136  RV_FILTER_LINEAR, // bi-linear filtering
137  RV_FILTER_CUBIC, // bi-cubic filtering NOTE: requires extension
138 };
139 
141 {
142  RV_MIPMAP_DISABLED, // No Mip filtering
143  RV_MIPMAP_NEAREST, // nearest mip level
144  RV_MIPMAP_LINEAR // linear blending
145 };
146 
148 {
149  RV_TEX_WRAP_REPEAT, // texture repeats, tiling
150  RV_TEX_WRAP_CLAMP, // edge pixel is stretched
151  RV_TEX_WRAP_BORDER, // outside pixels are a const colour
152  RV_TEX_WRAP_MIRROR // texture repeats, mirrored tiling
153 };
154 
156 {
157 public:
158  UT_StringHolder Layer; // Layer name within a deep raster file. C if ""
159  UT_StringHolder ColorSpace; // OCIO colorspace of the source, auto if ""
160  fpreal ImageScale = 1.0; // Scale to apply to loaded images
161  exint MaxWidth = 0; // 0 = no limit
165  bool MipMap = false;
166  fpreal MinLOD = 0.0;
167  fpreal MaxLOD = -1.0; // Default no limit to mip levels
168  bool LinearInterp = true; // Use bilinear or trilinear interpolation
169  bool IntTexture = false; // If INT/UINT 8/16 is normalized or as-is
170  bool SampleTexels = false; // if UV is [0,1] (false) or [0,res) (true).
171  bool CheckAlpha = false; // check for detailed info about alpha
172  int Anisotropy = 4;
173  RV_TextureWrap WrapU = RV_TEX_WRAP_REPEAT; // behaviour outside (0,1) uv
176  fpreal32 BorderColor[4] = { 0.0, 0.0, 0.0, 0.0 };
177  bool IsData = false;
178 };
179 
180 
181 /// Opaque reference to a texture stored in the RV_TextureCache
183 {
184 public:
185  /// Reference to a valid texture
186  bool isValid() const
187  { return myTexID != -1 && !myIsMissingTex; }
188 
189  /// Texture is missing; a default color used instead
190  bool isPlaceholder() const
191  { return myIsPlaceholder; }
192  /// Texture couldn't be found or resolved
193  bool isMissingTex() const
194  { return myIsMissingTex; }
195  /// Texture is currently loading in the background
196  bool isLoading() const
197  { return myIsLoading; }
198  /// Texture has been changed since last check
199  bool isDirty() const
200  { return myIsDirty; }
201 
202  /// Reset the reference to a null handle.
203  void reset()
204  {
205  myTexID = -1;
206  myIsMissingTex = false;
207  myIsPlaceholder = false;
208  myIsDirty = true;
209  myIsLoading = false;
210  myCacheVersion = 0;
211  myCacheRefresh = 0;
212  }
213 
214  /// Returns true if the reference is to a series of UDIM texture files
215  bool isUDIM() const { return myUDIMW > 0; }
216  /// Returns the UDIM range of the texture files (eg. (0,0) -> (3,2))
217  void getUDIMParms(int &x, int &y, int &w, int &h) const
218  {
219  x = myUDIMX;
220  y = myUDIMY;
221  w = myUDIMW;
222  h = myUDIMH;
223  }
224 
225  /// Returns texture dimension
226  RV_ImageDim getImageDim() const { return myTexType; }
227 
228 private:
229  exint myTexID = -1;
230  exint myCacheVersion = 0;
231  exint myCacheRefresh = 0;
232  bool myIsMissingTex = false;
233  bool myIsPlaceholder = false;
234  bool myIsLoading = false;
235  bool myIsDirty = false;
236 
237  int8 myUDIMX = 0;
238  int8 myUDIMY = 0;
239  int8 myUDIMW = 0;
240  int8 myUDIMH = 0;
241 
242  RV_ImageDim myTexType = RV_IMAGE_UNKNOWN;
243 
244  friend class RV_TextureCache;
245 };
246 
248 {
257 };
258 
260 {
267  //RV_UNIFORM_IMAGE_UNTYPED, // for `shaderStorageImageReadWithoutFormat`
271 };
272 
273 // Testing using a struct type instead of giant enum
274 // -- worried the helper functions for the giant enum
275 // will be fragile when we want to add new types
277 {
278  unsigned int vecsize : 2;
282 };
283 
285 {
363 
365 };
366 
368 {
371 
373 
376  RV_PRIM_LINE_LOOPS, // NOTE: no direct Vk analogue
377 
381 
382  RV_PRIM_LINES_ADJACENT, // for geometry shaders; includes
383  RV_PRIM_LINE_STRIP_ADJACENT, // extra vertices outside the primitive
384  RV_PRIM_TRIANGLES_ADJACENT, // for curvature
386 
387  RV_PRIM_POLYGONS, // NOTE: no direct Vk analogue
388 
389  RV_PRIM_PATCHES, // Patches sent to tessellation shaders
390 
392 };
393 
395 {
402 };
403 
405 {
409  // RV_RESOLVE_BUFFER, // for now uneeded; we handle resolve in shader
410 };
411 
413 {
417 };
418 
420 {
425 };
426 
428 {
433 };
434 
436 {
440 };
441 
443 {
449 };
450 
452 {
454  RV_STAGE_ANY = 0, // ALWAYS need to be execute
459  RV_STAGE_ANY_SHADER, // will be run for UBOs/SSBOs which can be consumed by compute or graphics pipelines
461 };
462 
464 
467  RV_GPUType &out_type,
468  int &out_vecsize);
470 
471 inline bool RVisUIntGPUType(RV_GPUType gpu_type)
472 {
473  return gpu_type >= RV_GPU_UINT8 && gpu_type <= RV_GPU_UINT32;
474 }
475 
476 inline bool RVisIntGPUType(RV_GPUType gpu_type)
477 {
478  return gpu_type >= RV_GPU_INT8 && gpu_type <= RV_GPU_INT32;
479 }
480 
481 inline bool RVisFloatGPUType(RV_GPUType gpu_type)
482 {
483  return gpu_type >= RV_GPU_FLOAT16 && gpu_type <= RV_GPU_FLOAT64;
484 }
485 
486 inline bool RVisMatrixGPUType(RV_GPUType gpu_type)
487 {
488  return gpu_type >= RV_GPU_MATRIX2 && gpu_type <= RV_GPU_MATRIX4;
489 }
490 
491 inline uint32_t RVsizeOfGPUType(RV_GPUType gpu_type)
492 {
493  int bpp = 32;
494 
495  switch (gpu_type)
496  {
497  // NOTE: that int-1 and int-4 don't correspond to
498  // actual Vulkan types
499  case RV_GPU_UINT1:
500  bpp = 1; break;
501  case RV_GPU_UINT4:
502  bpp = 4; break;
503 
504  case RV_GPU_INT8:
505  case RV_GPU_UINT8:
506  bpp = 8; break;
507 
508  case RV_GPU_INT16:
509  case RV_GPU_UINT16:
510  case RV_GPU_FLOAT16:
511  bpp = 16; break;
512 
513  case RV_GPU_INT32:
514  case RV_GPU_UINT32:
515  case RV_GPU_FLOAT32:
516  case RV_GPU_FLOAT24:
517  bpp = 32; break;
518 
519  case RV_GPU_FLOAT64:
520  bpp = 64; break;
521 
522  case RV_GPU_MATRIX2:
523  bpp = 32 * 4; break;
524  case RV_GPU_MATRIX3:
525  bpp = 32 * 9; break;
526  case RV_GPU_MATRIX4:
527  bpp = 32 * 16; break;
528  default:
529  bpp = 32;
530  UT_ASSERT_MSG(0, "RVsizeOfGPUType(): Unrecognized RV_GPUType");
531  }
532 
533  return bpp;
534 }
535 
537 {
538  switch(type)
539  {
540  case RE_CLAMP_REPEAT : return RV_TEX_WRAP_REPEAT;
541  case RE_CLAMP_BORDER : return RV_TEX_WRAP_BORDER;
542  case RE_CLAMP_EDGE : return RV_TEX_WRAP_CLAMP;
543  case RE_CLAMP_MIRROR : return RV_TEX_WRAP_MIRROR;
544  }
545  return RV_TEX_WRAP_REPEAT;
546 }
547 
549 {
550  switch (t)
551  {
552  case RV_PRIM_POINTS :
553  return RV_TOPOLOGY_POINT;
554  case RV_PRIM_LINES:
555  case RV_PRIM_LINE_STRIP:
558  return RV_TOPOLOGY_LINE;
559  case RV_PRIM_TRIANGLES:
564  return RV_TOPOLOGY_TRIANGLE;
565  case RV_PRIM_PATCHES:
566  return RV_TOPOLOGY_PATCH;
567  default: break;
568  }
569  UT_ASSERT(false && "Unrecognized Topology Type used for Pipeline");
570  return RV_TOPOLOGY_UNKNOWN;
571 }
572 
574 {
575  switch(type)
576  {
577  case RE_PRIM_POINTS : return RV_PRIM_POINTS;
578  case RE_PRIM_LINES : return RV_PRIM_LINES;
580  case RE_PRIM_TRIANGLES : return RV_PRIM_TRIANGLES;
587  case RE_PRIM_POLYGONS : return RV_PRIM_POLYGONS;
588  case RE_PRIM_PATCHES : return RV_PRIM_PATCHES;
589  case RE_PRIM_NONE :
590  case RE_NUM_PRIM_TYPES :
591  case RE_PRIM_LINE_LOOP :
592  default : break;
593  }
594  return RV_PRIM_NONE;
595 }
596 
597 const char *RVgetTypeName(RV_GPUType t);
598 
599 const char *RVgetPrimName(RV_PrimType p);
600 
602 
604 
605 int RVgetNumberOfPrim(RV_PrimType p, int num_verts);
606 
607 #endif
RV_TextureSwizzle
Definition: RV_Type.h:247
RV_TextureWrap WrapW
Definition: RV_Type.h:175
RV_UniformVarType
Definition: RV_Type.h:259
bool CheckAlpha
Definition: RV_Type.h:171
RE_GPUType RVgetREType(RV_GPUType t)
Definition: RV_Type.h:70
RV_ImageOp
Definition: RV_Type.h:412
exint MaxWidth
Definition: RV_Type.h:161
RV_ImageDim image_dim
Definition: RV_Type.h:281
RV_PrimType RVconvertToRVPrim(RE_PrimType type)
Definition: RV_Type.h:573
bool IntTexture
Definition: RV_Type.h:169
bool RVisFloatGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:481
bool isDirty() const
Texture has been changed since last check.
Definition: RV_Type.h:199
bool LinearInterp
Definition: RV_Type.h:168
bool isValid() const
Reference to a valid texture.
Definition: RV_Type.h:186
RV_GPUType data_type
Definition: RV_Type.h:279
int64 exint
Definition: SYS_Types.h:125
RV_StageGroup
Definition: RV_Type.h:451
UT_StringHolder Layer
Definition: RV_Type.h:158
bool RVisIntGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:476
Opaque reference to a texture stored in the RV_TextureCache.
Definition: RV_Type.h:182
int RVgetPointsPerPrim(RV_PrimType p)
const char * RVgetTypeName(RV_GPUType t)
GLint y
Definition: glcorearb.h:103
void getUDIMParms(int &x, int &y, int &w, int &h) const
Returns the UDIM range of the texture files (eg. (0,0) -> (3,2))
Definition: RV_Type.h:217
RV_API RV_ImageDim RVgetUniformTypeImageDim(RV_UniformType t)
float fpreal32
Definition: SYS_Types.h:200
RV_TextureMipMode
Definition: RV_Type.h:140
fpreal ImageScale
Definition: RV_Type.h:160
UT_StringArray RV_OverrideList
Definition: RV_Type.h:463
exint MaxMemoryMB
Definition: RV_Type.h:164
#define UT_ASSERT_MSG(ZZ,...)
Definition: UT_Assert.h:159
RV_AttachmentType
Definition: RV_Type.h:404
RE_GPUType
Definition: RE_Types.h:44
UT_StringHolder ColorSpace
Definition: RV_Type.h:159
RV_SetType
Definition: RV_Type.h:26
RV_TextureWrap WrapU
Definition: RV_Type.h:173
RV_GraphicsDevice
Definition: RV_Type.h:76
RV_AttributeType
Definition: RV_Type.h:96
RV_UniformVarType var_type
Definition: RV_Type.h:280
RV_UniformType
Definition: RV_Type.h:284
void reset()
Reset the reference to a null handle.
Definition: RV_Type.h:203
bool isMissingTex() const
Texture couldn't be found or resolved.
Definition: RV_Type.h:193
RV_PolygonMode
Definition: RV_Type.h:435
RE_TexClampType
RV_TextureWrap RVconvertToTextureWrap(RE_TexClampType type)
Definition: RV_Type.h:536
#define RV_API
Definition: RV_API.h:10
bool isUDIM() const
Returns true if the reference is to a series of UDIM texture files.
Definition: RV_Type.h:215
RV_TextureWrap
Definition: RV_Type.h:147
const char * RVgetPrimName(RV_PrimType p)
int RVgetNumberOfPrim(RV_PrimType p, int num_verts)
fpreal MinLOD
Definition: RV_Type.h:166
signed char int8
Definition: SYS_Types.h:35
bool RVisUIntGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:471
GLint GLenum GLint x
Definition: glcorearb.h:409
RV_TextureFilter
Definition: RV_Type.h:133
bool SampleTexels
Definition: RV_Type.h:170
RV_ImageDim getImageDim() const
Returns texture dimension.
Definition: RV_Type.h:226
GLdouble t
Definition: glad.h:2397
RV_GPUType RVgetFromREType(RE_GPUType t)
Definition: RV_Type.h:64
RV_ShaderType
Definition: RV_Type.h:427
RV_TextureWrap WrapV
Definition: RV_Type.h:174
bool isPlaceholder() const
Texture is missing; a default color used instead.
Definition: RV_Type.h:190
RV_PrimType
Definition: RV_Type.h:367
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
uint32_t RVsizeOfGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:491
Global cache of vulkan textures sourced from files.
const char * RVgetUniformTypeName(RV_UniformType t)
RV_TopologyClass RVgetTopologyClass(RV_PrimType t)
Definition: RV_Type.h:548
bool RVisMatrixGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:486
bool isLoading() const
Texture is currently loading in the background.
Definition: RV_Type.h:196
exint MaxDepth
Definition: RV_Type.h:163
RV_TopologyClass
Definition: RV_Type.h:394
RV_GPUType
Definition: RV_Type.h:37
fpreal64 fpreal
Definition: SYS_Types.h:277
RV_LogicOp
Definition: RV_Type.h:442
RV_MemType
Definition: RV_Type.h:108
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
RV_RenderPassType
Definition: RV_Type.h:419
unsigned int vecsize
Definition: RV_Type.h:278
RV_ImageDim
Definition: RV_Type.h:117
type
Definition: core.h:1059
RE_PrimType
Definition: RE_Types.h:193
fpreal32 BorderColor[4]
Definition: RV_Type.h:176
RV_API bool RVgetUniformFormat(RV_UniformType t, RV_GPUType &out_type, int &out_vecsize)
fpreal MaxLOD
Definition: RV_Type.h:167
exint MaxHeight
Definition: RV_Type.h:162