Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
WorldUiRenderer.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <unordered_map>
5#include <vector>
6#include <vk_mem_alloc.h>
7#include <vulkan/vulkan.h>
8
9struct ImGuiContext;
10
11namespace Engine::Components
12{
13 class WidgetComponent;
14} // namespace Engine::Components
15
16namespace Engine::Core
17{
19 class AssetManager;
20 class SceneManager;
21} // namespace Engine::Core
22
23namespace Engine::Rendering
24{
25 class RenderProcess;
26
28 {
29 public:
30 WorldUiRenderer() = default;
32
33 WorldUiRenderer( const WorldUiRenderer & ) = delete;
35
36 void init( Core::ApplicationContext * context, uint32_t framesInFlight );
37 void cleanup( Core::AssetManager * assetManager );
38
39 [[nodiscard]] uint32_t ensureWidgetTexture(
41 Core::AssetManager & assetManager
42 );
43
45 VkCommandBuffer commandBuffer,
46 uint32_t frameIndex,
47 RenderProcess & renderProcess,
48 Core::SceneManager * sceneManager,
49 Core::AssetManager * assetManager
50 );
51
52 private:
54 {
55 VkImage image = VK_NULL_HANDLE;
56 VmaAllocation allocation = VK_NULL_HANDLE;
57 VkImageView imageView = VK_NULL_HANDLE;
58 VkImageLayout currentLayout = VK_IMAGE_LAYOUT_UNDEFINED;
59 };
60
61 struct Target
62 {
64 uint32_t descriptorIndex = UINT32_MAX;
65 uint32_t width = 0;
66 uint32_t height = 0;
67 std::vector<TargetFrame> frames;
68 };
69
72 const std::vector<Components::WidgetComponent *> & activeWidgets,
73 Core::AssetManager & assetManager
74 );
75 void createTargetImages( Target & target ) const;
76 void destroyTarget( Target & target, Core::AssetManager * assetManager ) const;
77 void transitionTargetsToColorAttachment( VkCommandBuffer commandBuffer, uint32_t frameIndex );
78 void transitionTargetsToShaderRead( VkCommandBuffer commandBuffer, uint32_t frameIndex );
79 void renderTarget( VkCommandBuffer commandBuffer, Target & target, uint32_t frameIndex ) const;
80
82 ImGuiContext * imguiContext_ = nullptr;
83 VkDescriptorPool descriptorPool_ = VK_NULL_HANDLE;
84 VkSampler sampler_ = VK_NULL_HANDLE;
85 VkFormat format_ = VK_FORMAT_R8G8B8A8_UNORM;
86 uint32_t framesInFlight_ = 0;
87 bool initialized_ = false;
88
89 std::unordered_map<Components::WidgetComponent *, Target> targets_;
90 };
91} // namespace Engine::Rendering
The application context is the core class which stores the basic openxr and vulkan objects.
Manages game objects within a scene, handling registration, ID allocation, and GPU buffer synchroniza...
Target & ensureTarget(Components::WidgetComponent &widget, Core::AssetManager &assetManager)
std::unordered_map< Components::WidgetComponent *, Target > targets_
Core::ApplicationContext * context_
void cleanup(Core::AssetManager *assetManager)
void init(Core::ApplicationContext *context, uint32_t framesInFlight)
void pruneInactiveTargets(const std::vector< Components::WidgetComponent * > &activeWidgets, Core::AssetManager &assetManager)
void destroyTarget(Target &target, Core::AssetManager *assetManager) const
uint32_t ensureWidgetTexture(Components::WidgetComponent &widget, Core::AssetManager &assetManager)
void createTargetImages(Target &target) const
void renderWidgets(VkCommandBuffer commandBuffer, uint32_t frameIndex, RenderProcess &renderProcess, Core::SceneManager *sceneManager, Core::AssetManager *assetManager)
WorldUiRenderer & operator=(const WorldUiRenderer &)=delete
void transitionTargetsToShaderRead(VkCommandBuffer commandBuffer, uint32_t frameIndex)
void transitionTargetsToColorAttachment(VkCommandBuffer commandBuffer, uint32_t frameIndex)
WorldUiRenderer(const WorldUiRenderer &)=delete
void renderTarget(VkCommandBuffer commandBuffer, Target &target, uint32_t frameIndex) const
Manages IBL (Image-Based Lighting) resources for specular reflections.
Components::WidgetComponent * widget