HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_ImageVK.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_ImageVK ( GR Library, C++)
7  *
8  * COMMENTS:
9  * Simple renderer class for a 2D image
10  */
11 #ifndef GR_ImageVK_h
12 #define GR_ImageVK_h
13 
14 #include "GR_GeoRenderVK.h"
15 
16 #include <GA/GA_Names.h>
17 #include <RV/RV_Type.h>
18 
19 #include <UT/UT_Vector4.h>
20 #include <UT/UT_UniquePtr.h>
21 
22 class RV_Geometry;
23 class GEO_PrimVolume;
24 class GT_PrimVolume;
25 
26 class RV_Render;
27 class RV_ShaderBlock;
29 class RV_VKImage;
30 
32 {
33 public:
34  GR_ImageVK(GR_Primitive *prim);
35  ~GR_ImageVK() override;
36 
37  const char *className() const override { return "GR_ImageVK"; }
38 
39  RV_Geometry *getVkPickGeometry(unsigned int pick_mode) override;
40 
41  // Rebuilds the geometry bounds and UV coordinates for the image quad.
42  // remove_padding determines whether or not to inset by half a voxel in
43  // each dimension to avoid having to extrapolate when using bilinear
44  // interpolation.
45  void updateUVsAndBounds(RV_Render *r,
46  GT_PrimVolume *volume,
47  bool remove_padding);
48 
49  void update(RE_RenderContext rc,
50  const GT_PrimitiveHandle &primh,
51  const GR_UpdateParms &parms,
52  const char *cache_name) override;
53 
54  void draw(RE_RenderContext rc,
57  GR_DrawParms dp) override;
58 
59  exint getNumGLPrimitives() const override { return 1; }
60  bool hasTransparency() const override { return myHasAlpha; }
61 
62  static bool initShaders(RV_Instance* inst);
63  static void cleanupShaders();
64 
65 private:
66  void fillImageFromImage(RV_Render *r,
67  const GEO_PrimVolume *vol);
68  void fillImageFromVolume(RV_Render *r,
69  const GT_PrimVolume *vol,
70  const GR_UpdateParms &p);
71  /// Allocate a new image if necessary.
72  void allocateImage(RV_Render *r, VkFormat format,
73  RV_TextureWrap wrap,
74  int w, int h,
75  RV_TextureSwizzle* swizzle = nullptr,
76  bool is_int = false);
77  UT_UniquePtr<RV_Geometry> myDisplayWinVk;
78  UT_UniquePtr<RV_VKImage> myColorImage;
79  //UT_UniquePtr<RV_VKImage *> myDepthImage; // TODO: for COPs
81  UT_UniquePtr<RV_ShaderVariableSet> myDisplayHullSet;
82  UT_UniquePtr<RV_ShaderBlock> myDisplayHullBlock;
83  bool myHasAlpha = false;
84  bool myHasImage = false;
85  bool myHasDisplayWin = false;
86  int myChannels = 4;
87  int myTypeInfo = 0;
88  bool myDrawHullOnly = false;
89  UT_Vector4 myDisplayWinColor = {0.1f, 0.1f, 1.0f, 1.0f};
90  int myPostPassID = -1;
91  bool myInterpolateLayers = 0;
92  GT_PrimVolume *myVolume = nullptr;
93 };
94 
95 #endif
A collection of Vulkan UBO, SSBO, and Image shader bindings (descriptor set)
RV_TextureSwizzle
Definition: RV_Type.h:203
GLbitfield flags
Definition: glcorearb.h:1596
virtual void draw(RE_RenderContext r, GR_RenderMode mode, GR_RenderFlags flags, GR_DrawParms draw_parms)=0
Normal drawing method. Only issue rendering commands.
static bool initShaders(RV_Instance *inst)
int64 exint
Definition: SYS_Types.h:125
GT_API const UT_StringHolder cache_name
Object that represents drawable geometry. This object holds vertex, instancing and index buffers for ...
Definition: RV_Geometry.h:165
Temporary container for either a RV_Render and an RE_Render.
virtual RV_Geometry * getVkPickGeometry(unsigned int pick_mode)
Definition: GR_GeoRender.h:128
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()
bool hasTransparency() const override
returns true if this drawable renders some transparent elements
Definition: GR_ImageVK.h:60
GR_RenderMode
Definition: GR_Defines.h:48
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
#define GR_API
Definition: GR_API.h:10
RV_TextureWrap
Definition: RV_Type.h:150
GR_RenderFlags
Definition: GR_Defines.h:88
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:48
GLenum mode
Definition: glcorearb.h:99
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
GA_API const UT_StringHolder parms
VkFormat
Definition: vulkan_core.h:1386
const char * className() const override
Definition: GR_ImageVK.h:37
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
virtual void update(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p, const char *cache_name)=0
exint getNumGLPrimitives() const override
Definition: GR_ImageVK.h:59
GLboolean r
Definition: glcorearb.h:1222
static void cleanupShaders()