SpiecsEngine
 
Loading...
Searching...
No Matches
PreRenderer.cpp
Go to the documentation of this file.
1/**
2* @file PreRenderer.h.
3* @brief The PreRenderer Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
8#include "PreRenderer.h"
9
10namespace Spices {
11
13 {
15
16 RendererPassBuilder{ "PreRenderer", this }
17 .AddSubPass("PreRenderer", Querier::None)
20 }
21
23 {
25
26 DescriptorSetBuilder{ "PreRenderer", this }
27 .AddUniformBuffer(0, 0, sizeof(SpicesShader::View), VK_SHADER_STAGE_ALL)
28 .AddUniformBuffer(0, 1, sizeof(SpicesShader::Input), VK_SHADER_STAGE_ALL)
29 .AddBindLessTexture<Texture2D>(SpicesShader::BINDLESS_TEXTURE_SET, SpicesShader::BINDLESS_TEXTURE_BINDING, VK_SHADER_STAGE_ALL, { "default.jpg" })
30 .Build();
31 }
32
34 std::shared_ptr<Material> material ,
35 VkPipelineLayout& layout ,
36 std::shared_ptr<RendererSubPass> subPass
37 )
38 {}
39
41 {
43 }
44
45 void PreRenderer::Render(TimeStep& ts, FrameInfo& frameInfo)
46 {
48
49 RenderBehaveBuilder builder{ this ,frameInfo.m_FrameIndex, frameInfo.m_ImageIndex };
50
51 builder.BeginRenderPass();
52
53 builder.UpdateUniformBuffer<SpicesShader::View>(0, 0, [&](auto& ubo) {
54 auto [ invViewMatrix, projectionMatrix, stableFrames, fov ] = GetActiveCameraMatrix(frameInfo);
55 ImVec2 sceneTextureSize = SlateSystem::GetRegister()->GetViewPort()->GetPanelSize();
56 const VkExtent2D windowSize = m_Device->GetSwapChainSupport().surfaceSize;
57
58 ubo.projection = projectionMatrix;
59
60 ubo.nprojection = projectionMatrix;
61 ubo.nprojection[1][1] *= -1.0f;
62
63 ubo.view = glm::inverse(invViewMatrix);
64
65 ubo.inView = invViewMatrix;
66
67 ubo.sceneTextureSize = {
68 sceneTextureSize.x,
69 sceneTextureSize.y,
70 1.0f / sceneTextureSize.x,
71 1.0f / sceneTextureSize.y
72 };
73
74 ubo.windowSize = {
75 static_cast<float>(windowSize.width),
76 static_cast<float>(windowSize.height),
77 1.0f / static_cast<float>(windowSize.width),
78 1.0f / static_cast<float>(windowSize.height)
79 };
80
81 ubo.stableFrames = stableFrames;
82
83 ubo.fov = fov;
84 });
85
86 builder.UpdateUniformBuffer<SpicesShader::Input>(0, 1, [&](auto& ubo) {
87 auto [x, y] = SlateSystem::GetRegister()->GetViewPort()->GetMousePosInViewport();
88
89 ubo.gameTime = ts.gt();
90 ubo.frameTime = ts.ft();
91 ubo.mousePos = glm::vec4(
92 static_cast<float>(x),
93 static_cast<float>(y),
94 1.0f / static_cast<float>(x),
95 1.0f / static_cast<float>(y)
96 );
97 });
98
99 builder.EndRenderPass();
100 }
101}
#define SPICES_PROFILE_ZONE
static void UnLoadForce(const std::string &name)
Forcing UnLoad a VulkanDescriptorSet.
This Class manages all descriptor sets this project.
uint32_t m_FrameIndex
FrameIndex, varying during 0 - (MaxFrameInFlight - 1). Used almost anywhere.
Definition FrameInfo.h:69
uint32_t m_ImageIndex
ImageIndex, varying during 0 - (MaxFrameInFlight - 1). Used in swapchain index and framebuffer index.
Definition FrameInfo.h:75
FrameInfo Class. This class defines the FrameInfo data.
Definition FrameInfo.h:32
Material Class. This class contains a branch of parameter and shader, also descriptor.
Definition Material.h:62
virtual void CreateRendererPass() override
The interface is inherited from Renderer. Create specific render pass.
virtual ~PreRenderer() override
Destructor Function.
virtual void Render(TimeStep &ts, FrameInfo &frameInfo) override
The interface is inherited from Renderer.
virtual void CreateDescriptorSet() override
The interface is inherited from Renderer. Create specific descriptor set for sub pass.
virtual void CreatePipeline(std::shared_ptr< Material > material, VkPipelineLayout &layout, std::shared_ptr< RendererSubPass > subPass) override
The interface is inherited from Renderer. Create Material Specific Pipeline.
PreRenderer Class. This class defines the global descriptor set.
Definition PreRenderer.h:19
Basic interface of Queries.
Definition Querier.h:17
This Class Combines some data relative to sub pass. Usually as a member variable of RendererPass.
virtual void BeginRenderPass()
Begin this Renderer's RenderPass.
Definition Renderer.cpp:840
virtual void EndRenderPass()
End this Renderer's RenderPass.
Definition Renderer.cpp:981
This class helps to bind pipeline and bind buffer. Only instanced during Render().
Definition Renderer.h:985
RendererPassBuilder & EndSubPass()
End recording a sub pass.
void Build() const
Build the RendererPass.
RendererPassBuilder & AddSubPass(const std::string &subPassName, Querier::StatisticsFlags flags=Querier::ALL)
Add a new SubPass to Renderer Pass.
std::string m_RendererName
Specific renderer name, Passed by instanced.
Definition Renderer.h:2017
const float & ft() const
Get time step during frames.
Definition TimeStep.h:51
const float & gt() const
Get time step since Engine Start.
Definition TimeStep.h:57
This Class handles our engine time step during frames. Global Unique.
Definition TimeStep.h:22