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 [[nodiscard]] auto render_finished_semaphore() const {
55 }
56
57 private:
58 RenderTarget() = default;
59
60 std::function<expected<void>(const RenderTarget*)> transition_fn_;
61
62 // TODO This might not be necessary, the size can stay in the render pass
64
66
67 ::vk::SampleCountFlagBits sample_count_;
68
69 ::vk::Format format_;
70
71 std::optional<vk::Image> image_;
72 ::vk::ImageView view_;
73
74 ::vk::ImageUsageFlags image_usage_;
75
76 ::vk::ImageLayout final_layout_ = ::vk::ImageLayout::ePresentSrcKHR;
77 ::vk::ImageAspectFlags aspect_;
78};
79
80} // namespace wren
auto final_layout(const ::vk::ImageLayout &layout)
Definition render_target.hpp:49
::vk::Semaphore render_finished_semaphore_
Definition render_target.hpp:65
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:74
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:69
auto usage() const
Definition render_target.hpp:51
::vk::ImageLayout final_layout_
Definition render_target.hpp:76
::vk::ImageAspectFlags aspect_
Definition render_target.hpp:77
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:71
auto final_layout() const
Definition render_target.hpp:48
::vk::SampleCountFlagBits sample_count_
Definition render_target.hpp:67
::vk::ImageView view_
Definition render_target.hpp:72
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:63
std::function< expected< void >(const RenderTarget *)> transition_fn_
Definition render_target.hpp:60
auto view() const
Definition render_target.hpp:37
auto render_finished_semaphore() const
Definition render_target.hpp:53
auto size(const math::Vec2f &size)
Definition render_target.hpp:44
Definition editor_scene.hpp:5
std::expected< T, Err > expected
Definition result.hpp:43
Definition vector.hpp:161