1
0
Fork 0
Univerxel/src/client/render/vk/api/Images.hpp

67 lines
2.1 KiB
C++

#pragma once
#include "../../api/Images.hpp"
#include "Memory.hpp"
namespace render::vk {
class Image: public render::Image {
public:
virtual ~Image();
const VkImageView &getView() const { return view; }
static void MakeDefault();
struct info {
VkImage ref = NULL;
VkImageView view = NULL;
VkDeviceSize offset = 0;
};
static std::unique_ptr<Image> Create(const requirement &);
protected:
Image(VkImage ref, VkImageView view, memory::ptr mem):
ref(ref), view(view), memory(std::move(mem)) { }
VkImage ref;
VkImageView view;
memory::ptr memory;
};
class Texture: public render::Texture, Image {
public:
~Texture();
const VkDescriptorImageInfo &getDescriptor() const { return descriptor; }
static std::unique_ptr<Texture> LoadFromFile(const std::string&, const sampling&);
protected:
Texture(VkSampler sampler, VkImageView view, VkImageLayout layout, VkImage ref, memory::ptr memory):
vk::Image(ref, view, std::move(memory)), sampler(sampler), descriptor({sampler, view, layout}) { }
VkSampler sampler;
const VkDescriptorImageInfo descriptor;
};
class TextureCube: public render::TextureCube, public Texture {
public:
/// Looks for .right.dds, .left.dds, .top.dds, .bottom.dds, .front.dds, .back.dds
static std::unique_ptr<TextureCube> LoadFromFiles(const std::string& prefix, const sampling&);
static std::unique_ptr<TextureCube> LoadFromFiles(const std::array<std::string, 6>& paths, const sampling&);
protected:
TextureCube(VkSampler sampler, VkImageView view, VkImageLayout layout, VkImage ref, memory::ptr memory):
Texture(sampler, view, layout, ref, std::move(memory)) { }
};
class TextureArray: public render::TextureArray, public Texture {
public:
static std::unique_ptr<TextureArray> LoadFromFiles(const std::vector<std::string>&, const sampling&, bool srgb = true);
protected:
TextureArray(uint32_t size, VkSampler sampler, VkImageView view, VkImageLayout layout, VkImage ref, memory::ptr memory):
render::TextureArray(size), Texture(sampler, view, layout, ref, std::move(memory)) { }
};
}