HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_Utils.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_Utils.h ( RV Library, C++)
7  *
8  * COMMENTS:
9  * Utility functions for RV.
10  */
11 #ifndef RV_Utils_h
12 #define RV_Utils_h
13 
14 #include "RV_API.h"
15 
16 #include "RV_Type.h"
17 #include "RV_TypePtrs.h"
18 
19 #include <UT/UT_Rect.h>
20 #include <UT/UT_Vector3.h>
21 #include <UT/UT_Matrix4.h>
22 #include <UT/UT_UniquePtr.h>
23 #include <SYS/SYS_Types.h>
24 
25 class RV_Render;
26 class RV_ShaderBlock;
27 class RV_ShaderProgram;
29 class RV_VKImage;
30 class PXL_Lookup;
31 class PXL_Raster;
32 class UI_Icon;
33 
35 
36 namespace RV_Utils
37 {
38 /// Returns an 8b RGBA 64x64 texture with 0-1 random values in all comps.
40  unsigned int seed,
41  bool interp,
42  int size = 64);
43 /// Returns an 8b RGBA size^3 3D texture with 0-1 random values
45  unsigned int seed,
46  bool interp,
47  int size = 32);
48 /// Returns an 8b RGBA size^2 2D texture array of size 'num_layers'
50  unsigned int seed,
51  bool interp,
52  int num_layers,
53  int size = 64 );
54 /// Create a new 2D image from a 2D multisample image by increasing the
55 /// resolution of the 2D image to show all samples.
57  RV_VKImage *ms_image);
58 
59 /// Create resources for color correction in HOUcolorCorrect().
61  RV_ShaderProgram *sh,
62  int set_number,
63  const PXL_Lookup *lut,
64  fpreal brightness,
65  fpreal bright_shift,
66  fpreal gamma,
67  fpreal alpha_scale,
68  exint &lut_version,
71  UT_UniquePtr<RV_VKImage> &main_lut_image,
72  UT_UniquePtr<RV_VKImage> &pre_lut_image);
73 
74 extern RV_API bool matchesRaster(const RV_VKImage &img,
75  const PXL_Raster &raster);
76 
77 extern RV_API void setupRaster(RV_VKImage &img,
78  PXL_Raster &raster,
79  bool alloc = true);
80 
81 extern RV_API RV_VKImagePtr
82 imageFromRaster(RV_Render *r, const PXL_Raster *raster);
83 
84 extern RV_API void
86  const PXL_Lookup *lut,
87  UT_UniquePtr<RV_VKImage> &main_lut,
88  UT_UniquePtr<RV_VKImage> &pre); // optionally generated prelut
89 
91  fpreal b, fpreal t,
92  fpreal n, fpreal f);
93 /// Pixel-space ortho projection for a viewport rect
95  bool reverse_depth);
96 /// Remap a GL-style projection's clip depth from [-1,1] to Vulkan's [0,1].
98 
99 /// Create lower mipmaps for a cubemap texture. image must be a latlong map
100 extern RV_API void
102  RV_VKImage *tex, RV_GPUType format_type, int vsize);
103 
104 /// Copy a 2D image sphere map into a cubemap
105 extern RV_API void
106 copySphereMap(RV_Render *r, RV_VKImage *dst_cubemap, RV_VKImage *src_image);
107 
108 /// Copy depth value from src into dst. src and dst may be depth textures
109 /// or single component color textures and must be single-sample
111 
112 extern RV_API void drawRaster(
113  RV_Render *r,
114  PXL_Raster *rst,
115  const UT_DimRect &area,
116  const UT_Vector2F &uv_min,
117  const UT_Vector2F &uv_max,
118  const UT_DimRect &screen_area,
119  fpreal32 alpha);
120 
121 extern RV_API bool initShaders(RV_Instance* inst);
122 extern RV_API void cleanupShaders();
123 };
124 
125 #endif
A collection of Vulkan UBO, SSBO, and Image shader bindings (descriptor set)
RV_API RV_VKImagePtr getRandomTextureArray(RV_Render *r, unsigned int seed, bool interp, int num_layers, int size=64)
Returns an 8b RGBA size^2 2D texture array of size 'num_layers'.
RV_API UT_Matrix4F convertProjectionToVK(const UT_Matrix4D &proj)
Remap a GL-style projection's clip depth from [-1,1] to Vulkan's [0,1].
RV_API UT_Matrix4D getOrthoProjection(fpreal l, fpreal r, fpreal b, fpreal t, fpreal n, fpreal f)
RV_API void generateCubeMips(RV_Render *r, UT_UniquePtr< PXL_Raster > &latlong_image, RV_VKImage *tex, RV_GPUType format_type, int vsize)
Create lower mipmaps for a cubemap texture. image must be a latlong map.
RV_API void copyDepth(RV_Render *r, RV_VKImage *dst, RV_VKImage *src)
RV_API void drawRaster(RV_Render *r, PXL_Raster *rst, const UT_DimRect &area, const UT_Vector2F &uv_min, const UT_Vector2F &uv_max, const UT_DimRect &screen_area, fpreal32 alpha)
int64 exint
Definition: SYS_Types.h:125
UT_UniquePtr< RV_VKImage > RV_VKImagePtr
Definition: RV_TypePtrs.h:59
RV_API void createLUTTexture(RV_Render *r, const PXL_Lookup *lut, UT_UniquePtr< RV_VKImage > &main_lut, UT_UniquePtr< RV_VKImage > &pre)
float fpreal32
Definition: SYS_Types.h:200
RV_API UT_UniquePtr< RV_VKImage > resolveMSTexture(RV_Render *r, RV_VKImage *ms_image)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
GLdouble n
Definition: glcorearb.h:2008
GLfloat f
Definition: glcorearb.h:1926
RV_API void setupRaster(RV_VKImage &img, PXL_Raster &raster, bool alloc=true)
RV_API bool matchesRaster(const RV_VKImage &img, const PXL_Raster &raster)
RV_API void copySphereMap(RV_Render *r, RV_VKImage *dst_cubemap, RV_VKImage *src_image)
Copy a 2D image sphere map into a cubemap.
constexpr auto set(type rhs) -> int
Definition: core.h:610
RV_API bool setupColorCorrection(RV_Render *r, RV_ShaderProgram *sh, int set_number, const PXL_Lookup *lut, fpreal brightness, fpreal bright_shift, fpreal gamma, fpreal alpha_scale, exint &lut_version, UT_UniquePtr< RV_ShaderVariableSet > &set, UT_UniquePtr< RV_ShaderBlock > &block, UT_UniquePtr< RV_VKImage > &main_lut_image, UT_UniquePtr< RV_VKImage > &pre_lut_image)
Create resources for color correction in HOUcolorCorrect().
RV_API void cleanupShaders()
#define RV_API
Definition: RV_API.h:10
HUSD_API const char * raster()
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:112
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:50
GLint void * img
Definition: glcorearb.h:556
GLdouble t
Definition: glad.h:2397
RV_API bool initShaders(RV_Instance *inst)
GLsizeiptr size
Definition: glcorearb.h:664
GLenum GLenum dst
Definition: glcorearb.h:1793
UT_UniquePtr< RV_VKImage > RV_VKImagePtr
Definition: RV_Utils.h:32
RV_GPUType
Definition: RV_Type.h:40
fpreal64 fpreal
Definition: SYS_Types.h:283
RV_API RV_VKImagePtr imageFromRaster(RV_Render *r, const PXL_Raster *raster)
RV_API RV_VKImagePtr getRandomTexture(RV_Render *r, unsigned int seed, bool interp, int size=64)
Returns an 8b RGBA 64x64 texture with 0-1 random values in all comps.
GLboolean r
Definition: glcorearb.h:1222
RV_API RV_VKImagePtr getRandomTexture3D(RV_Render *r, unsigned int seed, bool interp, int size=32)
Returns an 8b RGBA size^3 3D texture with 0-1 random values.
GA_API const UT_StringHolder area
GLenum src
Definition: glcorearb.h:1793