]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/texture_backend.h
Support binding individual mipmap levels of textures
[libs/gl.git] / source / backends / vulkan / texture_backend.h
1 #ifndef MSP_GL_TEXTURE_BACKEND_H_
2 #define MSP_GL_TEXTURE_BACKEND_H_
3
4 #include <msp/core/noncopyable.h>
5 #include "handles.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Device;
11
12 class VulkanTexture: public NonCopyable
13 {
14         friend class VulkanFramebuffer;
15         friend class VulkanPipelineState;
16
17 protected:
18         Device &device;
19         VkImage handle = 0;
20         VkImageView view_handle = 0;
21         mutable std::vector<VkImageView> mip_view_handles;
22         unsigned memory_id = 0;
23         unsigned view_type;
24         std::string debug_name;
25
26         VulkanTexture(unsigned);
27         VulkanTexture(VulkanTexture &&);
28         ~VulkanTexture();
29
30         void allocate();
31         virtual void fill_image_info(void *) const = 0;
32         VkImageView create_view(int) const;
33         void create_mip_views() const;
34         void require_swizzle() { }
35
36         void stage_pixels(void *, const void *, size_t);
37
38         void generate_mipmap();
39         virtual void fill_mipmap_blit(unsigned, void *) = 0;
40
41         void change_layout(int, unsigned, bool) const;
42
43         void refresh_mip_views() const { if(mip_view_handles.empty()) create_mip_views(); }
44
45         void set_debug_name(const std::string &);
46         void set_vulkan_object_names() const;
47 };
48
49 using TextureBackend = VulkanTexture;
50
51 } // namespace GL
52 } // namespace Msp
53
54 #endif