HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_VKShaderModule.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_VKShaderModule.h ( RV Library, C++)
7  *
8  * COMMENTS:
9  * Shader Modules for Vulkan Pipelines
10  */
11 
12 #ifndef RV_VKShaderModule_h
13 #define RV_VKShaderModule_h
14 
15 #include "RV_API.h"
16 
17 #include <UT/UT_String.h>
18 
19 #include <VE/VE_VK.h>
20 #include "RV_Instance.h"
21 #include "RV_TypePtrs.h"
22 #include "RV_VKEnum.h"
23 
24 #include <UT/UT_NonCopyable.h>
25 
27 class RV_VKShaderModule;
28 class RV_VKShaderReflect;
29 
30 /// RAII wrapper class for Vk Shader Module
32 {
33 public:
36 
37  /// create a shader module with an info struct. Allows safety checks to
38  /// be done before creation loaded
39  static RV_VKShaderModulePtr create(
40  RV_Instance* inst,
41  const RV_VKShaderModuleInfo *info);
42 
43  /// create a module from raw binary. Must be valid SPIR-V binary for the instance,
44  /// or will get undefined behavior
45  static RV_VKShaderModulePtr create(
46  RV_Instance* inst,
47  const UT_Array<uint8>& binary,
48  VkShaderStageFlagBits stage);
49 
50  VkShaderModule getVkShaderModule() const { return myVkModule; }
51  VkShaderStageFlagBits getStage() const { return myStage; }
52 
54  RV_Instance* inst,
56  VkShaderModule vk_module);
57 
58  RV_Instance* myInst = nullptr;
59  VkShaderModule myVkModule = VK_NULL_HANDLE;
61 };
62 
63 /// Info loaded from file, used to create VK Shader Module
65 {
66 public:
69 
70  static RV_VKShaderModuleInfoPtr create(
71  RV_Instance* inst,
72  const UT_String &name,
74  const UT_Array<uint8>& src);
75 
77  { return myStage; }
78 
80  {
81  UT_ASSERT(myReflection);
82  return *myReflection;
83  }
84 
85  const UT_Array<uint8>& getBinary() const
86  {
87  UT_ASSERT(myBinary.size() > 0);
88  return myBinary;
89  }
90 
92  const UT_String &name,
94  const UT_Array<uint8>& binary,
96 protected:
101 
102  friend class RV_VKShaderReflect;
103 };
104 
106  RV_Instance* inst,
107  const UT_StringHolder& name,
108  VkShaderStageFlagBits stage,
109  const char* filename);
110 
111 #endif
UT_UniquePtr< RV_VKShaderReflect > myReflection
UT_UniquePtr< RV_VKShaderModule > RV_VKShaderModulePtr
Definition: RV_TypePtrs.h:70
GT_API const UT_StringHolder filename
#define VK_NULL_HANDLE
Definition: vulkan_core.h:45
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
VkShaderStageFlagBits getStage() const
UT_Array< uint8 > myBinary
VkShaderStageFlagBits getStage() const
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
RV_API RV_VKShaderModuleInfoPtr RVloadShaderFileSource(RV_Instance *inst, const UT_StringHolder &name, VkShaderStageFlagBits stage, const char *filename)
RV_VKShaderReflect & getReflection() const
UT_UniquePtr< RV_VKShaderModuleInfo > RV_VKShaderModuleInfoPtr
Definition: RV_TypePtrs.h:71
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
#define RV_API
Definition: RV_API.h:10
VkShaderStageFlagBits
Definition: vulkan_core.h:2594
GLuint const GLchar * name
Definition: glcorearb.h:786
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:48
RAII wrapper class for Vk Shader Module.
VkShaderModule getVkShaderModule() const
Info loaded from file, used to create VK Shader Module.
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:165
const UT_Array< uint8 > & getBinary() const
GLenum src
Definition: glcorearb.h:1793