Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
foray_gbuffer.hpp
Go to the documentation of this file.
1#pragma once
2#include "../bench/foray_bench_declares.hpp"
3#include "../core/foray_context.hpp"
4#include "../core/foray_shadermodule.hpp"
5#include "../scene/foray_scene.hpp"
7#include <array>
8
9namespace foray::stages {
22 {
23 public:
24 GBufferStage() = default;
25
30 virtual void Init(core::Context* context, scene::Scene* scene, std::string_view vertexShaderPath = "", std::string_view fragmentShaderPath = "", bench::DeviceBenchmark* benchmark = nullptr);
31
32 virtual void RecordFrame(VkCommandBuffer cmdBuffer, base::FrameRenderInfo& renderInfo) override;
33
34 virtual void Resize(const VkExtent2D& extent) override;
35
36 virtual void Destroy() override;
37
38 enum class EOutput
39 {
41 Normal,
42 Albedo,
43 Motion,
46 LinearZ,
47 Depth,
49 };
50
51 inline static constexpr std::string_view PositionOutputName = "Gbuf.Position";
52 inline static constexpr std::string_view NormalOutputName = "Gbuf.Normal";
53 inline static constexpr std::string_view AlbedoOutputName = "Gbuf.Albedo";
54 inline static constexpr std::string_view MotionOutputName = "Gbuf.Motion";
55 inline static constexpr std::string_view MaterialIdxOutputName = "Gbuf.MaterialIdx";
56 inline static constexpr std::string_view MeshInstanceIdOutputName = "Gbuf.MeshInstanceIdx";
57 inline static constexpr std::string_view LinearZOutputName = "Gbuf.LinearZ";
58 inline static constexpr std::string_view DepthOutputName = "Gbuf.Depth";
59
60 core::ManagedImage* GetImageEOutput(EOutput output, bool noThrow = false);
61
62 FORAY_GETTER_CR(Benchmark)
63 protected:
65
72
74
75 std::string mVertexShaderPath = "";
76 std::string mFragmentShaderPath = "";
77
80
82
83
86 virtual void SetupDescriptors() override;
87 virtual void CreateDescriptorSets() override;
88 virtual void CreatePipelineLayout() override;
90
92
93 inline static const char* TIMESTAMP_VERT_BEGIN = "Vertex Begin";
94 inline static const char* TIMESTAMP_VERT_END = "Vertex End";
95 inline static const char* TIMESTAMP_FRAG_BEGIN = "Fragment Begin";
96 inline static const char* TIMESTAMP_FRAG_END = "Fragment End";
97 };
98} // namespace foray::stages
Context used for render processes. This object is rebuilt for every frame. /.
Definition foray_framerenderinfo.hpp:14
A device benchmark based on Vulkans DeviceQuery Api. Timestamps are recorded in milliseconds....
Definition foray_devicebenchmark.hpp:13
Wraps allocation and lifetime functionality of VkImage.
Definition foray_managedimage.hpp:13
Wraps shader code driver handle (VkShaderModule). See ShaderManager for compiling shaders dynamically...
Definition foray_shadermodule.hpp:11
Provides registries and methods as the anchor of a component based scene.
Definition foray_scene.hpp:17
Utilizes rasterization to render a GBuffer output.
Definition foray_gbuffer.hpp:22
virtual void RecordFrame(VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo) override
Records a frame to cmdBuffer.
static const char * TIMESTAMP_FRAG_BEGIN
Definition foray_gbuffer.hpp:95
static const char * TIMESTAMP_FRAG_END
Definition foray_gbuffer.hpp:96
static const char * TIMESTAMP_VERT_END
Definition foray_gbuffer.hpp:94
bench::DeviceBenchmark * mBenchmark
Definition foray_gbuffer.hpp:91
static constexpr std::string_view NormalOutputName
Definition foray_gbuffer.hpp:52
static constexpr std::string_view LinearZOutputName
Definition foray_gbuffer.hpp:57
std::string mVertexShaderPath
Definition foray_gbuffer.hpp:75
virtual void Resize(const VkExtent2D &extent) override
Default implementation accesses mImageOutputs and calls ManagedImage::Resize(extent) on any set image...
static constexpr std::string_view MaterialIdxOutputName
Definition foray_gbuffer.hpp:55
static constexpr std::string_view PositionOutputName
Definition foray_gbuffer.hpp:51
virtual void Destroy() override
Destroy the render stage. Finalizes all components.
core::ShaderModule mVertexShaderModule
Definition foray_gbuffer.hpp:78
core::ManagedImage * GetImageEOutput(EOutput output, bool noThrow=false)
static constexpr std::string_view AlbedoOutputName
Definition foray_gbuffer.hpp:53
static constexpr std::string_view MotionOutputName
Definition foray_gbuffer.hpp:54
virtual void CreateDescriptorSets() override
virtual void CreatePipelineLayout() override
EOutput
Definition foray_gbuffer.hpp:39
virtual void Init(core::Context *context, scene::Scene *scene, std::string_view vertexShaderPath="", std::string_view fragmentShaderPath="", bench::DeviceBenchmark *benchmark=nullptr)
std::string mFragmentShaderPath
Definition foray_gbuffer.hpp:76
std::array< PerImageInfo,(size_t) EOutput::MaxEnum > mImageInfos
Definition foray_gbuffer.hpp:73
virtual void SetupDescriptors() override
core::ShaderModule mFragmentShaderModule
Definition foray_gbuffer.hpp:79
virtual void DestroyFrameBufferAndRenderpass()
static constexpr std::string_view DepthOutputName
Definition foray_gbuffer.hpp:58
static constexpr std::string_view MeshInstanceIdOutputName
Definition foray_gbuffer.hpp:56
static const char * TIMESTAMP_VERT_BEGIN
Definition foray_gbuffer.hpp:93
scene::Scene * mScene
Definition foray_gbuffer.hpp:64
Base class for rasterized render stages (no built-in functionality)
Definition foray_rasterizedRenderStage.hpp:9
#define FORAY_GETTER_CR(member)
Return constant reference.
Definition foray_basics.hpp:60
Definition foray_blitstage.hpp:4
Non owning context object.
Definition foray_context.hpp:16
Definition foray_gbuffer.hpp:67
VkClearValue ClearValue
Definition foray_gbuffer.hpp:70
EOutput Output
Definition foray_gbuffer.hpp:68
core::ManagedImage Image
Definition foray_gbuffer.hpp:69