49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#pragma once
|
|
#include <vulkan/vulkan.hpp>
|
|
|
|
#include "render_resource.h"
|
|
|
|
enum class lock_state {
|
|
NONE,
|
|
WRITE,
|
|
READ,
|
|
READ_WRITE
|
|
};
|
|
|
|
class render_target : public render_resource {
|
|
public:
|
|
[[nodiscard]] int get_height() const override { return height_; }
|
|
[[nodiscard]] int get_width() const override { return width_; }
|
|
[[nodiscard]] ImTextureID get_texture_id() override { return descriptor_set; }
|
|
|
|
void init(const int width, const int height, const vk::Format in_format);
|
|
|
|
void resize(const int width, const int height) {
|
|
if (width_ == width && height_ == height)
|
|
return;
|
|
|
|
width_ = width;
|
|
height_ = height;
|
|
on_resize(width, height);
|
|
if (on_resize_callback)
|
|
on_resize_callback(shared_from_this());
|
|
}
|
|
|
|
void* lock(lock_state state) const;
|
|
void unlock();
|
|
|
|
std::function<void(std::shared_ptr<render_resource>)> on_resize_callback;
|
|
vk::Image image;
|
|
vk::ImageView image_view;
|
|
vk::DeviceMemory memory;
|
|
vk::Framebuffer framebuffer;
|
|
vk::Format format;
|
|
vk::DescriptorSet descriptor_set;
|
|
protected:
|
|
void create(int width, int height);
|
|
void on_resize(int width, int height);
|
|
|
|
int width_ = 0;
|
|
int height_ = 0;
|
|
};
|