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 RE_GPUType(t);
68 }
69 
71 {
73 
76  RV_DEVICE_INTEL_GMA = 0x4, // Intel GMA (not supported)
77  RV_DEVICE_INTEL_HD = 0x8, // Intel HD graphics
78  RV_DEVICE_GDI = 0x10, // Software OGL on Windows
80 
81  RV_DEVICE_PRO = 0x100, // Professional series
82  RV_DEVICE_MAC = 0x200, // Mac versions of drivers
83  RV_DEVICE_MAC_SILICON = 0x600, // ARM-based Macs
84 
88 };
89 
91 {
95  // RV_ATTRIBUTE_INSTANCE,
97  RV_ATTRIBUTE_RANDOM, // randomly sampled NOTE: also used for INSTANCE-level
99 };
100 
101 
103 {
109 };
110 
112 {
123 
125 };
126 
128 {
129  RV_FILTER_NEAREST, // no filtering
130  RV_FILTER_LINEAR, // bi-linear filtering
131  RV_FILTER_CUBIC, // bi-cubic filtering NOTE: requires extension
132 };
133 
135 {
136  RV_MIPMAP_DISABLED, // No Mip filtering
137  RV_MIPMAP_NEAREST, // nearest mip level
138  RV_MIPMAP_LINEAR // linear blending
139 };
140 
142 {
143  RV_TEX_WRAP_REPEAT, // texture repeats, tiling
144  RV_TEX_WRAP_CLAMP, // edge pixel is stretched
145  RV_TEX_WRAP_BORDER, // outside pixels are a const colour
146  RV_TEX_WRAP_MIRROR // texture repeats, mirrored tiling
147 };
148 
150 {
151 public:
152  UT_StringHolder Layer; // Layer name within a deep raster file. C if ""
153  UT_StringHolder ColorSpace; // OCIO colorspace of the source, auto if ""
154  fpreal ImageScale = 1.0; // Scale to apply to loaded images
155  exint MaxWidth = 0; // 0 = no limit
158  bool MipMap = false;
159  fpreal MinLOD = 0.0;
160  fpreal MaxLOD = -1.0; // Default no limit to mip levels
161  bool LinearInterp = true; // Use bilinear or trilinear interpolation
162  bool IntTexture = false; // If INT/UINT 8/16 is normalized or as-is
163  bool SampleTexels = false; // if UV is [0,1] (false) or [0,res) (true).
164  bool CheckAlpha = false; // check for detailed info about alpha
165  int Anisotropy = 4;
166  RV_TextureWrap WrapU = RV_TEX_WRAP_REPEAT; // behaviour outside (0,1) uv
169  fpreal32 BorderColor[4] = { 0.0, 0.0, 0.0, 0.0 };
170  bool IsData = false;
171 };
172 
173 
174 /// Opaque reference to a texture stored in the RV_TextureCache
176 {
177 public:
178  /// Reference to a valid texture
179  bool isValid() const
180  { return myTexID != -1 && !myIsMissingTex; }
181 
182  /// Texture is missing; a default color used instead
183  bool isPlaceholder() const
184  { return myIsPlaceholder; }
185  /// Texture couldn't be found or resolved
186  bool isMissingTex() const
187  { return myIsMissingTex; }
188  /// Texture is currently loading in the background
189  bool isLoading() const
190  { return myIsLoading; }
191  /// Texture has been changed since last check
192  bool isDirty() const
193  { return myIsDirty; }
194 
195  /// Reset the reference to a null handle.
196  void reset()
197  {
198  myTexID = -1;
199  myIsMissingTex = false;
200  myIsPlaceholder = false;
201  myIsDirty = true;
202  myIsLoading = false;
203  myCacheVersion = 0;
204  myCacheRefresh = 0;
205  }
206 
207  /// Returns true if the reference is to a series of UDIM texture files
208  bool isUDIM() const { return myUDIMW > 0; }
209  /// Returns the UDIM range of the texture files (eg. (0,0) -> (3,2))
210  void getUDIMParms(int &x, int &y, int &w, int &h) const
211  {
212  x = myUDIMX;
213  y = myUDIMY;
214  w = myUDIMW;
215  h = myUDIMH;
216  }
217 
218 private:
219  exint myTexID = -1;
220  exint myCacheVersion = 0;
221  exint myCacheRefresh = 0;
222  bool myIsMissingTex = false;
223  bool myIsPlaceholder = false;
224  bool myIsLoading = false;
225  bool myIsDirty = false;
226 
227  int8 myUDIMX = 0;
228  int8 myUDIMY = 0;
229  int8 myUDIMW = 0;
230  int8 myUDIMH = 0;
231 
232  RV_ImageDim myTexType;
233 
234  friend class RV_TextureCache;
235 };
236 
238 {
245  //RV_UNIFORM_IMAGE_UNTYPED, // for `shaderStorageImageReadWithoutFormat`
249 };
250 
251 // Testing using a struct type instead of giant enum
252 // -- worried the helper functions for the giant enum
253 // will be fragile when we want to add new types
255 {
256  unsigned int vecsize : 2;
260 };
261 
263 {
341 
343 };
344 
346 {
349 
351 
354  RV_PRIM_LINE_LOOPS, // NOTE: no direct Vk analogue
355 
359 
360  RV_PRIM_LINES_ADJACENT, // for geometry shaders; includes
361  RV_PRIM_LINE_STRIP_ADJACENT, // extra vertices outside the primitive
362  RV_PRIM_TRIANGLES_ADJACENT, // for curvature
364 
365  RV_PRIM_POLYGONS, // NOTE: no direct Vk analogue
366 
367  RV_PRIM_PATCHES, // Patches sent to tessellation shaders
368 
370 };
371 
373 {
380 };
381 
383 {
387  // RV_RESOLVE_BUFFER, // for now uneeded; we handle resolve in shader
388 };
389 
391 {
395 };
396 
398 {
403 };
404 
406 {
411 };
412 
414 {
418 };
419 
421 {
427 };
428 
430 {
432  RV_STAGE_ANY = 0, // ALWAYS need to be execute
437  RV_STAGE_ANY_SHADER, // will be run for UBOs/SSBOs which can be consumed by compute or graphics pipelines
439 };
440 
442 
445  RV_GPUType &out_type,
446  int &out_vecsize);
448 
449 inline bool RVisUIntGPUType(RV_GPUType gpu_type)
450 {
451  return gpu_type >= RV_GPU_UINT8 && gpu_type <= RV_GPU_UINT32;
452 }
453 
454 inline bool RVisIntGPUType(RV_GPUType gpu_type)
455 {
456  return gpu_type >= RV_GPU_INT8 && gpu_type <= RV_GPU_INT32;
457 }
458 
459 inline bool RVisFloatGPUType(RV_GPUType gpu_type)
460 {
461  return gpu_type >= RV_GPU_FLOAT16 && gpu_type <= RV_GPU_FLOAT64;
462 }
463 
464 inline bool RVisMatrixGPUType(RV_GPUType gpu_type)
465 {
466  return gpu_type >= RV_GPU_MATRIX2 && gpu_type <= RV_GPU_MATRIX4;
467 }
468 
469 inline uint32_t RVsizeOfGPUType(RV_GPUType gpu_type)
470 {
471  int bpp = 32;
472 
473  switch (gpu_type)
474  {
475  // NOTE: that int-1 and int-4 don't correspond to
476  // actual Vulkan types
477  case RV_GPU_UINT1:
478  bpp = 1; break;
479  case RV_GPU_UINT4:
480  bpp = 4; break;
481 
482  case RV_GPU_INT8:
483  case RV_GPU_UINT8:
484  bpp = 8; break;
485 
486  case RV_GPU_INT16:
487  case RV_GPU_UINT16:
488  case RV_GPU_FLOAT16:
489  bpp = 16; break;
490 
491  case RV_GPU_INT32:
492  case RV_GPU_UINT32:
493  case RV_GPU_FLOAT32:
494  case RV_GPU_FLOAT24:
495  bpp = 32; break;
496 
497  case RV_GPU_FLOAT64:
498  bpp = 64; break;
499 
500  case RV_GPU_MATRIX2:
501  bpp = 32 * 4; break;
502  case RV_GPU_MATRIX3:
503  bpp = 32 * 9; break;
504  case RV_GPU_MATRIX4:
505  bpp = 32 * 16; break;
506  default:
507  bpp = 32;
508  UT_ASSERT_MSG(0, "RVsizeOfGPUType(): Unrecognized RV_GPUType");
509  }
510 
511  return bpp;
512 }
513 
515 {
516  switch(type)
517  {
518  case RE_CLAMP_REPEAT : return RV_TEX_WRAP_REPEAT;
519  case RE_CLAMP_BORDER : return RV_TEX_WRAP_BORDER;
520  case RE_CLAMP_EDGE : return RV_TEX_WRAP_CLAMP;
521  case RE_CLAMP_MIRROR : return RV_TEX_WRAP_MIRROR;
522  }
523  return RV_TEX_WRAP_REPEAT;
524 }
525 
527 {
528  switch (t)
529  {
530  case RV_PRIM_POINTS :
531  return RV_TOPOLOGY_POINT;
532  case RV_PRIM_LINES:
533  case RV_PRIM_LINE_STRIP:
536  return RV_TOPOLOGY_LINE;
537  case RV_PRIM_TRIANGLES:
542  return RV_TOPOLOGY_TRIANGLE;
543  case RV_PRIM_PATCHES:
544  return RV_TOPOLOGY_PATCH;
545  default: break;
546  }
547  UT_ASSERT(false && "Unrecognized Topology Type used for Pipeline");
548  return RV_TOPOLOGY_UNKNOWN;
549 }
550 
552 {
553  switch(type)
554  {
555  case RE_PRIM_POINTS : return RV_PRIM_POINTS;
556  case RE_PRIM_LINES : return RV_PRIM_LINES;
558  case RE_PRIM_TRIANGLES : return RV_PRIM_TRIANGLES;
565  case RE_PRIM_POLYGONS : return RV_PRIM_POLYGONS;
566  case RE_PRIM_PATCHES : return RV_PRIM_PATCHES;
567  case RE_PRIM_NONE :
568  case RE_NUM_PRIM_TYPES :
569  case RE_PRIM_LINE_LOOP :
570  default : break;
571  }
572  return RV_PRIM_NONE;
573 }
574 
575 const char *RVgetTypeName(RV_GPUType t);
576 
577 const char *RVgetPrimName(RV_PrimType p);
578 
580 
582 
583 int RVgetNumberOfPrim(RV_PrimType p, int num_verts);
584 
585 #endif
RV_TextureWrap WrapW
Definition: RV_Type.h:168
RV_UniformVarType
Definition: RV_Type.h:237
bool CheckAlpha
Definition: RV_Type.h:164
RE_GPUType RVgetREType(RV_GPUType t)
Definition: RV_Type.h:64
RV_ImageOp
Definition: RV_Type.h:390
exint MaxWidth
Definition: RV_Type.h:155
RV_ImageDim image_dim
Definition: RV_Type.h:259
RV_PrimType RVconvertToRVPrim(RE_PrimType type)
Definition: RV_Type.h:551
bool IntTexture
Definition: RV_Type.h:162
bool RVisFloatGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:459
bool isDirty() const
Texture has been changed since last check.
Definition: RV_Type.h:192
bool LinearInterp
Definition: RV_Type.h:161
bool isValid() const
Reference to a valid texture.
Definition: RV_Type.h:179
RV_GPUType data_type
Definition: RV_Type.h:257
int64 exint
Definition: SYS_Types.h:125
RV_StageGroup
Definition: RV_Type.h:429
UT_StringHolder Layer
Definition: RV_Type.h:152
bool RVisIntGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:454
Opaque reference to a texture stored in the RV_TextureCache.
Definition: RV_Type.h:175
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:210
RV_API RV_ImageDim RVgetUniformTypeImageDim(RV_UniformType t)
float fpreal32
Definition: SYS_Types.h:200
RV_TextureMipMode
Definition: RV_Type.h:134
fpreal ImageScale
Definition: RV_Type.h:154
UT_StringArray RV_OverrideList
Definition: RV_Type.h:441
#define UT_ASSERT_MSG(ZZ,...)
Definition: UT_Assert.h:159
RV_AttachmentType
Definition: RV_Type.h:382
RE_GPUType
Definition: RE_Types.h:44
UT_StringHolder ColorSpace
Definition: RV_Type.h:153
RV_SetType
Definition: RV_Type.h:26
RV_TextureWrap WrapU
Definition: RV_Type.h:166
RV_GraphicsDevice
Definition: RV_Type.h:70
RV_AttributeType
Definition: RV_Type.h:90
RV_UniformVarType var_type
Definition: RV_Type.h:258
RV_UniformType
Definition: RV_Type.h:262
void reset()
Reset the reference to a null handle.
Definition: RV_Type.h:196
bool isMissingTex() const
Texture couldn't be found or resolved.
Definition: RV_Type.h:186
RV_PolygonMode
Definition: RV_Type.h:413
RE_TexClampType
RV_TextureWrap RVconvertToTextureWrap(RE_TexClampType type)
Definition: RV_Type.h:514
#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:208
RV_TextureWrap
Definition: RV_Type.h:141
const char * RVgetPrimName(RV_PrimType p)
int RVgetNumberOfPrim(RV_PrimType p, int num_verts)
fpreal MinLOD
Definition: RV_Type.h:159
signed char int8
Definition: SYS_Types.h:35
bool RVisUIntGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:449
GLint GLenum GLint x
Definition: glcorearb.h:409
RV_TextureFilter
Definition: RV_Type.h:127
bool SampleTexels
Definition: RV_Type.h:163
GLdouble t
Definition: glad.h:2397
RV_ShaderType
Definition: RV_Type.h:405
RV_TextureWrap WrapV
Definition: RV_Type.h:167
bool isPlaceholder() const
Texture is missing; a default color used instead.
Definition: RV_Type.h:183
RV_PrimType
Definition: RV_Type.h:345
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
uint32_t RVsizeOfGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:469
Global cache of vulkan textures sourced from files.
const char * RVgetUniformTypeName(RV_UniformType t)
RV_TopologyClass RVgetTopologyClass(RV_PrimType t)
Definition: RV_Type.h:526
bool RVisMatrixGPUType(RV_GPUType gpu_type)
Definition: RV_Type.h:464
bool isLoading() const
Texture is currently loading in the background.
Definition: RV_Type.h:189
exint MaxDepth
Definition: RV_Type.h:157
RV_TopologyClass
Definition: RV_Type.h:372
RV_GPUType
Definition: RV_Type.h:37
fpreal64 fpreal
Definition: SYS_Types.h:277
RV_LogicOp
Definition: RV_Type.h:420
RV_MemType
Definition: RV_Type.h:102
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
RV_RenderPassType
Definition: RV_Type.h:397
unsigned int vecsize
Definition: RV_Type.h:256
RV_ImageDim
Definition: RV_Type.h:111
type
Definition: core.h:1059
RE_PrimType
Definition: RE_Types.h:193
fpreal32 BorderColor[4]
Definition: RV_Type.h:169
RV_API bool RVgetUniformFormat(RV_UniformType t, RV_GPUType &out_type, int &out_vecsize)
fpreal MaxLOD
Definition: RV_Type.h:160
exint MaxHeight
Definition: RV_Type.h:156