2021-09-23 10:10:39 +02:00
|
|
|
#pragma once
|
2024-06-09 12:20:04 +02:00
|
|
|
#include "Graphics/Shader.h"
|
2021-09-23 10:10:39 +02:00
|
|
|
#include "RenderPass.h"
|
2025-01-08 19:15:12 +01:00
|
|
|
#include "Asset/FontAsset.h"
|
|
|
|
|
#include "UI/System.h"
|
2024-06-09 12:20:04 +02:00
|
|
|
|
|
|
|
|
namespace Seele {
|
2021-09-23 10:10:39 +02:00
|
|
|
DECLARE_NAME_REF(Gfx, Texture2D)
|
|
|
|
|
DECLARE_NAME_REF(Gfx, RenderTargetAttachment)
|
2024-06-09 12:20:04 +02:00
|
|
|
class UIPass : public RenderPass {
|
|
|
|
|
public:
|
2025-01-08 19:15:12 +01:00
|
|
|
UIPass(Gfx::PGraphics graphics, UI::PSystem system);
|
2023-11-05 10:36:01 +01:00
|
|
|
UIPass(UIPass&&) = default;
|
|
|
|
|
UIPass& operator=(UIPass&&) = default;
|
2021-09-23 10:10:39 +02:00
|
|
|
virtual ~UIPass();
|
2025-04-11 23:13:19 +02:00
|
|
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
|
2022-04-15 23:45:44 +02:00
|
|
|
virtual void render() override;
|
|
|
|
|
virtual void endFrame() override;
|
2021-09-23 10:10:39 +02:00
|
|
|
virtual void publishOutputs() override;
|
|
|
|
|
virtual void createRenderPass() override;
|
2024-06-09 12:20:04 +02:00
|
|
|
|
|
|
|
|
private:
|
2025-01-08 19:15:12 +01:00
|
|
|
struct GlyphData {
|
|
|
|
|
Vector2 bearing;
|
|
|
|
|
Vector2 size;
|
|
|
|
|
uint32 advance;
|
|
|
|
|
};
|
|
|
|
|
struct GlyphInstanceData {
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
2025-01-12 11:26:52 +01:00
|
|
|
float z;
|
2025-01-08 19:15:12 +01:00
|
|
|
float width;
|
|
|
|
|
float height;
|
|
|
|
|
uint32 glyphIndex;
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-12 11:26:52 +01:00
|
|
|
struct RenderElementStyle {
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
float w;
|
|
|
|
|
float h;
|
|
|
|
|
Vector color;
|
|
|
|
|
float opacity = 1;
|
|
|
|
|
float z = 0;
|
2025-03-20 20:15:38 +01:00
|
|
|
uint32 textureIndex = std::numeric_limits<uint32>::max();
|
2025-01-12 11:26:52 +01:00
|
|
|
uint32 pad0;
|
|
|
|
|
uint32 pad1;
|
2025-01-08 19:15:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Gfx::RenderTargetAttachment colorAttachment;
|
2024-02-01 10:21:36 +01:00
|
|
|
Gfx::RenderTargetAttachment depthAttachment;
|
2023-11-01 23:12:30 +01:00
|
|
|
Gfx::OTexture2D depthBuffer;
|
2021-09-23 10:10:39 +02:00
|
|
|
|
2025-01-08 19:15:12 +01:00
|
|
|
Gfx::ODescriptorLayout textDescriptorLayout;
|
2025-08-10 19:16:55 +02:00
|
|
|
Gfx::ODescriptorSet textDescriptorSet;
|
2022-04-18 18:08:38 +02:00
|
|
|
|
2025-01-08 19:15:12 +01:00
|
|
|
Gfx::OVertexShader textVertexShader;
|
|
|
|
|
Gfx::OFragmentShader textFragmentShader;
|
|
|
|
|
Gfx::OPipelineLayout textPipelineLayout;
|
|
|
|
|
Gfx::PGraphicsPipeline textPipeline;
|
2022-04-18 18:08:38 +02:00
|
|
|
|
2025-01-08 19:15:12 +01:00
|
|
|
Gfx::ODescriptorLayout uiDescriptorLayout;
|
2025-08-10 19:16:55 +02:00
|
|
|
Gfx::ODescriptorSet uiDescriptorSet;
|
2023-10-26 18:37:29 +02:00
|
|
|
|
2025-08-10 19:16:55 +02:00
|
|
|
Gfx::ODescriptorSet viewParamsSet;
|
2025-05-06 19:36:43 +02:00
|
|
|
|
2025-01-08 19:15:12 +01:00
|
|
|
Gfx::OVertexShader uiVertexShader;
|
|
|
|
|
Gfx::OFragmentShader uiFragmentShader;
|
|
|
|
|
Gfx::OPipelineLayout uiPipelineLayout;
|
|
|
|
|
Gfx::PGraphicsPipeline uiPipeline;
|
|
|
|
|
|
2025-01-12 11:26:52 +01:00
|
|
|
UI::PSystem system;
|
|
|
|
|
Array<UI::UIRender> renderElements;
|
2025-01-08 19:15:12 +01:00
|
|
|
Array<GlyphInstanceData> glyphs;
|
2025-01-12 11:26:52 +01:00
|
|
|
Array<RenderElementStyle> elements;
|
2025-01-08 19:15:12 +01:00
|
|
|
Gfx::OShaderBuffer glyphInstanceBuffer;
|
2025-03-07 21:48:27 +01:00
|
|
|
constexpr static const char* GLYPHINSTANCE_NAME = "glyphData";
|
2025-01-12 11:26:52 +01:00
|
|
|
Gfx::OShaderBuffer elementBuffer;
|
2025-03-07 21:48:27 +01:00
|
|
|
constexpr static const char* ELEMENT_NAME = "elements";
|
2025-01-08 19:15:12 +01:00
|
|
|
Gfx::OSampler glyphSampler;
|
2025-03-07 21:48:27 +01:00
|
|
|
constexpr static const char* GLYPHSAMPLER_NAME = "glyphSampler";
|
2024-06-20 21:57:26 +02:00
|
|
|
Array<Gfx::PTexture2D> usedTextures;
|
2025-03-07 21:48:27 +01:00
|
|
|
constexpr static const char* TEXTURES_NAME = "textures";
|
2021-09-23 10:10:39 +02:00
|
|
|
};
|
|
|
|
|
DEFINE_REF(UIPass);
|
|
|
|
|
} // namespace Seele
|