wren
Vulkan-based game engine
Loading...
Searching...
No Matches
render_target.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vulkan/vulkan.hpp>
4#include <vulkan/vulkan_handles.hpp>
8#include <wren/vk/image.hpp>
9
10#include "context.hpp"
11
12namespace wren {
13
15 public:
18 static auto create(const std::shared_ptr<Context>& ctx)
20
25 static auto create_depth(const std::shared_ptr<Context>& ctx)
27
28 static auto create(const math::Vec2f& size, ::vk::Format format,
29 ::vk::SampleCountFlagBits sample_count,
30 ::vk::ImageView image_view,
31 ::vk::ImageUsageFlags image_usage)
33
34 auto resize(const std::shared_ptr<Context>& ctx, const math::Vec2f& new_size)
36
37 [[nodiscard]] auto view() const { return view_; }
38 auto view(const ::vk::ImageView& view) { view_ = view; }
39
40 [[nodiscard]] auto format() const { return format_; }
41 auto format(const ::vk::Format& format) { format_ = format; }
42
43 [[nodiscard]] auto size() const { return size_; }
44 auto size(const math::Vec2f& size) { size_ = size; }
45
46 [[nodiscard]] auto sample_count() const { return sample_count_; }
47
48 [[nodiscard]] auto final_layout() const { return final_layout_; }
49 auto final_layout(const ::vk::ImageLayout& layout) { final_layout_ = layout; }
50
51 [[nodiscard]] auto usage() const { return image_usage_; }
52
53 private:
54 RenderTarget() = default;
55
56 std::function<expected<void>()> transition_fn_;
57
58 // TODO This might not be necessary, the size can stay in the render pass
60
61 ::vk::SampleCountFlagBits sample_count_;
62
63 ::vk::Format format_;
64
65 std::optional<vk::Image> image_;
66 ::vk::ImageView view_;
67
68 ::vk::ImageUsageFlags image_usage_;
69
70 ::vk::ImageLayout final_layout_ = ::vk::ImageLayout::ePresentSrcKHR;
71 ::vk::ImageAspectFlags aspect_;
72};
73
74} // namespace wren
Definition render_target.hpp:14
auto final_layout(const ::vk::ImageLayout &layout)
Definition render_target.hpp:49
static auto create(const std::shared_ptr< Context > &ctx) -> expected< std::shared_ptr< RenderTarget > >
Craete a RenderTarget object with all defaults for a colour target.
Definition render_target.cpp:7
::vk::ImageUsageFlags image_usage_
Definition render_target.hpp:68
auto format() const
Definition render_target.hpp:40
static auto create_depth(const std::shared_ptr< Context > &ctx) -> expected< std::shared_ptr< RenderTarget > >
Create e render target to be used as a depth target.
Definition render_target.cpp:60
::vk::Format format_
Definition render_target.hpp:63
auto usage() const
Definition render_target.hpp:51
::vk::ImageLayout final_layout_
Definition render_target.hpp:70
::vk::ImageAspectFlags aspect_
Definition render_target.hpp:71
auto resize(const std::shared_ptr< Context > &ctx, const math::Vec2f &new_size) -> expected< void >
Definition render_target.cpp:130
RenderTarget()=default
std::optional< vk::Image > image_
Definition render_target.hpp:65
auto final_layout() const
Definition render_target.hpp:48
::vk::SampleCountFlagBits sample_count_
Definition render_target.hpp:61
std::function< expected< void >()> transition_fn_
Definition render_target.hpp:56
::vk::ImageView view_
Definition render_target.hpp:66
auto size() const
Definition render_target.hpp:43
auto sample_count() const
Definition render_target.hpp:46
auto view(const ::vk::ImageView &view)
Definition render_target.hpp:38
auto format(const ::vk::Format &format)
Definition render_target.hpp:41
math::Vec2f size_
Definition render_target.hpp:59
auto view() const
Definition render_target.hpp:37
auto size(const math::Vec2f &size)
Definition render_target.hpp:44
Definition editor_scene.hpp:5
std::expected< T, Err > expected
Definition result.hpp:49
Definition vector.hpp:124