AronaCore/core/rhi/texture.h
2024-02-20 10:06:45 +08:00

41 lines
1.1 KiB
C++

#pragma once
#include "imgui.h"
#include <vulkan/vulkan.hpp>
#include "buffer_vk.h"
#include "render_resource.h"
class texture : public render_resource {
public:
texture();
~texture() override;
[[nodiscard]] int get_width() const override { return width_; }
[[nodiscard]] int get_height() const override { return height_; }
[[nodiscard]] ImTextureID get_texture_id() override { return descriptor_set; }
bool init_data(const uint8_t* data, int width, int height, vk::Format in_format);
bool is_valid() const { return image_view; }
operator vk::DescriptorImageInfo() const {
vk::DescriptorImageInfo info;
info.setImageLayout(vk::ImageLayout::eShaderReadOnlyOptimal);
info.setImageView(image_view);
info.setSampler(sampler);
return info;
}
void upload(const void* data, size_t size);
vk::Image image;
vk::ImageView image_view;
vk::Sampler sampler;
vk::DeviceMemory memory;
vk::DescriptorSet descriptor_set;
vk::Format format;
protected:
int width_;
int height_;
};