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_VKEnum.h"
22 #include "RV_VKShaderReflect.h"
23 
24 #include <UT/UT_NonCopyable.h>
25 
27 class RV_VKShaderModule;
28 
29 /// RAII wrapper class for Vk Shader Module
31 {
32 public:
35 
36  /// create a shader module with an info struct. Allows safety checks to
37  /// be done before creation loaded
38  static RV_VKShaderModulePtr create(
39  RV_Instance* inst,
40  const RV_VKShaderModuleInfo *info);
41 
42  /// create a module from raw binary. Must be valid SPIR-V binary for the instance,
43  /// or will get undefined behavior
44  static RV_VKShaderModulePtr create(
45  RV_Instance* inst,
46  const UT_Array<uint8>& binary,
47  VkShaderStageFlagBits stage);
48 
49  VkShaderModule getVkShaderModule() const { return myVkModule; }
50  VkShaderStageFlagBits getStage() const { return myStage; }
51 
53  RV_Instance* inst,
55  VkShaderModule vk_module);
56 
57  RV_Instance* myInst = nullptr;
58  VkShaderModule myVkModule = VK_NULL_HANDLE;
60 };
61 
62 /// Info loaded from file, used to create VK Shader Module
64 {
65 public:
68 
69  static RV_VKShaderModuleInfoPtr create(
70  RV_Instance* inst,
71  const UT_String &name,
73  const UT_Array<uint8>& src);
74 
76  { return myStage; }
77 
79  {
80  UT_ASSERT(myReflection);
81  return *myReflection;
82  }
83 
84  const UT_Array<uint8>& getBinary() const
85  {
86  UT_ASSERT(myBinary.size() > 0);
87  return myBinary;
88  }
89 
91  const UT_String &name,
93  const UT_Array<uint8>& binary,
95 protected:
100 
101  friend class RV_VKShaderReflect;
102 };
103 
105  RV_Instance* inst,
106  const UT_StringHolder& name,
107  VkShaderStageFlagBits stage,
108  const char* filename);
109 
110 #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:44
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:156
const UT_Array< uint8 > & getBinary() const
GLenum src
Definition: glcorearb.h:1793