2
3
4
5
16 RendererPassBuilder{
"Sprite",
this }
18 .AddColorAttachment(
"SceneColor",
TextureType::Texture2D, [](
bool& isEnableBlend, VkAttachmentDescription& description) {
20 description.format = VK_FORMAT_R16G16B16A16_SFLOAT;
22 .AddColorAttachment(
"EntityID",
TextureType::Texture2D, [](
bool& isEnableBlend, VkAttachmentDescription& description) {
23 description.format = VK_FORMAT_R32_SFLOAT;
24 description.finalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
34 DescriptorSetBuilder{
"Sprite",
this }
41 VkPipelineLayout& layout ,
47 PipelineBuilder{ subPass, material,
this }
51 .SetPipelineLayout(layout)
52 .SetCullMode(VK_CULL_MODE_NONE)
53 .SetColorAttachments()
65 builder.BindDescriptorSet(DescriptorSetManager::GetByName(
"PreRenderer"));
67 builder.BindDescriptorSet(DescriptorSetManager::GetByName({ m_Pass->GetName(),
"Sprite" }));
69 auto [ invViewMatrix, projectionMatrix, stableFrames, fov ] = GetActiveCameraMatrix(frameInfo);
71 std::multimap<
float,
int> sortedEntity;
74 auto viewPos = glm::inverse(invViewMatrix) * glm::vec4(tranComp.GetPosition(), 0.0f);
76 sortedEntity.insert(std::pair(viewPos.z, entityId));
81 for (
auto it = sortedEntity.rbegin(); it != sortedEntity.rend(); ++it)
83 auto [transComp, spriteComp] = frameInfo.m_World->GetRegistry().get<TransformComponent, SpriteComponent>(
static_cast<entt::entity>(it->second));
85 spriteComp.GetMesh()->Draw(m_VulkanState.m_GraphicCommandBuffer[frameInfo.m_FrameIndex], [&](uint32_t meshPackId,
auto meshPack) {
87 builder.BindPipeline(meshPack->GetMaterial()->GetName());
89 builder.UpdatePushConstant<uint64_t>([&](
auto& push) {
90 push = meshPack->GetMeshDesc().GetBufferAddress();
#define SPICES_PROFILE_ZONE
uint32_t m_FrameIndex
FrameIndex, varying during 0 - (MaxFrameInFlight - 1). Used almost anywhere.
uint32_t m_ImageIndex
ImageIndex, varying during 0 - (MaxFrameInFlight - 1). Used in swapchain index and framebuffer index.
FrameInfo Class. This class defines the FrameInfo data.
Material Class. This class contains a branch of parameter and shader, also descriptor.
This Class Combines some data relative to sub pass. Usually as a member variable of RendererPass.
DescriptorSetBuilder & AddPushConstant(uint32_t size)
Set VkPushConstantRange by a specific push constant struct.
virtual void BeginRenderPass()
Begin this Renderer's RenderPass.
virtual void EndRenderPass()
End this Renderer's RenderPass.
This class helps to bind pipeline and bind buffer. Only instanced during Render().
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.
SpriteComponent Class. This class defines the specific behaves of SpriteComponent.
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.
virtual void Render(TimeStep &ts, FrameInfo &frameInfo) override
The interface is inherited from Renderer.
virtual void CreateRendererPass() override
The interface is inherited from Renderer. Create specific render pass.
virtual void CreateDescriptorSet() override
The interface is inherited from Renderer. Create specific descriptor set for sub pass.
SpriteRenderer Class. This class defines sprite render behaves.
This Class handles our engine time step during frames. Global Unique.
TextureType
The enum of all Texture Type.