Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
VulkanTexture.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #ifdef USING_VULKAN
9 
10 #include <ThirdParty/Vulkan/Include/vulkan/vulkan.h>
11 #include <ThirdParty/EASTL-master/include/EASTL/vector.h>
12 
13 namespace Engine
14 {
15  class ResourceManager;
16  class VulkanRenderer;
17 
18  class ENGINE_API VulkanTexture : public Texture
19  {
20  friend class ResourceManager;
21  friend class VulkanRenderer;
22 
23  static void InitTextureSystem(VulkanRenderer* renderer, VulkanLogicalDevice* device, VulkanDescriptorPool* descriptorPool, VmaAllocator allocator, VkCommandPool commandPool);
24 
25  public:
26  ~VulkanTexture() override;
27  void CreateTextureWithData(stbi_uc* data, bool genMipMaps, TextureDataSize bytes = TextureDataSize::U_CHAR, bool storage = false) override;
28 
29  void SetSampler(VkSamplerCreateInfo samplerInfo);
30 
31  VulkanTexture(int width, int height);
32 
33  VkImage GetImage() const;
34  VkImageView GetImageView() const;
35  VkSampler GetSampler() const;
36 
37  VkDescriptorSet CreateDescriptorSet(size_t threadID, size_t pipelineID, size_t set,
38  VkDescriptorSetLayout layout);
39 
40  VkDescriptorSet GetDescriptorSet(size_t threadID, size_t pipelineID, size_t set);
41 
42  private:
43  friend class VulkanRenderer;
44 
45  VulkanTexture(const eastl::string& filename, int desiredChannels = 4);
46 
47  VkImage image;
48  VmaAllocation allocation;
49  VmaAllocationInfo allocationInfo;
50 
51  VkImageView imageView;
52 
53  VkSampler sampler;
54 
55  bool storage;
56 
57  eastl::vector<eastl::vector<eastl::vector<VkDescriptorSet>>> descriptorSets;
58 
59  static VulkanRenderer* renderer;
60  static VulkanLogicalDevice* device;
61  static VulkanDescriptorPool* descriptorPool;
62  static VmaAllocator allocator;
63  static VkCommandPool commandPool;
64 
65  };
66 } //namespace Engine
67 #endif
#define ENGINE_API
Definition: api.hpp:25
TextureDataSize
Definition: Texture.hpp:11