Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
foray_drawmanager.hpp
Go to the documentation of this file.
1#pragma once
2#include "../../util/foray_dualbuffer.hpp"
3#include "../foray_component.hpp"
4
5namespace foray::scene::gcomp {
6
8 struct DrawOp
9 {
10 public:
11 uint64_t Order = 0;
12 Mesh* Target = nullptr;
13 std::vector<ncomp::MeshInstance*> Instances = {};
14 uint32_t TransformOffset = 0;
15 };
16
19 {
20 public:
21 inline DrawDirector() {}
22
25
26 virtual int32_t GetOrder() const override { return ORDER_TRANSFORM; }
27
29 virtual void Update(SceneUpdateInfo&) override;
31 virtual void Draw(SceneDrawInfo&) override;
32
33 FORAY_GETTER_CR(CurrentTransformBuffer)
34 FORAY_GETTER_CR(PreviousTransformBuffer)
35
36 inline VkDescriptorBufferInfo GetCurrentTransformsDescriptorInfo() const { return mCurrentTransformBuffer.GetDeviceBuffer().GetVkDescriptorBufferInfo(); }
38 inline VkBuffer GetCurrentTransformsVkBuffer() const { return mCurrentTransformBuffer.GetDeviceBuffer().GetBuffer(); }
39 inline VkBuffer GetPreviousTransformsVkBuffer() const { return mPreviousTransformBuffer.GetBuffer(); }
40
41 FORAY_GETTER_V(TotalCount)
42
43 protected:
46
47 void CreateBuffers(size_t transformCount);
49
51 std::vector<DrawOp> mDrawOps = {};
52 bool mFirstSetup = true;
53 GeometryStore* mGeo = nullptr;
54 uint32_t mTotalCount = 0;
55 };
56} // namespace foray::scene::gcomp
Wraps allocation and lifetime functionality of a VkBuffer.
Definition foray_managedbuffer.hpp:12
VkDescriptorBufferInfo GetVkDescriptorBufferInfo() const
Fills VkDescriptorBufferInfo object with zero offset and full buffer size.
Definition foray_managedbuffer.hpp:93
Base class for implementing the draw callback.
Definition foray_component.hpp:36
Base class for implementing the update callback.
Definition foray_component.hpp:19
static const int32_t ORDER_TRANSFORM
Definition foray_component.hpp:28
Definition foray_component.hpp:95
Type describing a single mesh object, described by multiple Primitive objects.
Definition foray_mesh.hpp:49
Manages a collection of mesh instances, current and previous model matrices.
Definition foray_drawmanager.hpp:19
VkDescriptorBufferInfo GetPreviousTransformsDescriptorInfo() const
Definition foray_drawmanager.hpp:37
core::ManagedBuffer mPreviousTransformBuffer
Definition foray_drawmanager.hpp:45
void InitOrUpdate()
Collects mesh instances and rebuilds transform buffers.
VkBuffer GetPreviousTransformsVkBuffer() const
Definition foray_drawmanager.hpp:39
virtual void Update(SceneUpdateInfo &) override
Updates and uploads transform buffers.
virtual int32_t GetOrder() const override
Definition foray_drawmanager.hpp:26
void CreateBuffers(size_t transformCount)
VkDescriptorBufferInfo GetCurrentTransformsDescriptorInfo() const
Definition foray_drawmanager.hpp:36
uint32_t mTotalCount
Definition foray_drawmanager.hpp:54
util::DualBuffer mCurrentTransformBuffer
Definition foray_drawmanager.hpp:44
VkBuffer GetCurrentTransformsVkBuffer() const
Definition foray_drawmanager.hpp:38
virtual void Draw(SceneDrawInfo &) override
Draws the scene using the currently bound pipeline and renderpass. Vertex and Index buffers must be b...
std::vector< DrawOp > mDrawOps
Draw Op structs store draw operation.
Definition foray_drawmanager.hpp:51
GeometryStore * mGeo
Definition foray_drawmanager.hpp:53
bool mFirstSetup
Definition foray_drawmanager.hpp:52
DrawDirector()
Definition foray_drawmanager.hpp:21
Stores all geometry in a single set of index and vertex buffers.
Definition foray_geometrymanager.hpp:12
Helper class for organizing CPU -> GPU data synchronisation. In flight data is stored on host side,...
Definition foray_dualbuffer.hpp:18
#define FORAY_GETTER_V(member)
Return value.
Definition foray_basics.hpp:39
#define FORAY_GETTER_CR(member)
Return constant reference.
Definition foray_basics.hpp:60
Definition foray_scene_declares.hpp:16
Temporary type passed to components when drawing the scene.
Definition foray_scenedrawing.hpp:63
Temporary type passed to components when updating the scene.
Definition foray_scenedrawing.hpp:49
Represents instanced draw operation of a single mesh.
Definition foray_drawmanager.hpp:9
std::vector< ncomp::MeshInstance * > Instances
Definition foray_drawmanager.hpp:13
uint32_t TransformOffset
Definition foray_drawmanager.hpp:14
uint64_t Order
Definition foray_drawmanager.hpp:11
Mesh * Target
Definition foray_drawmanager.hpp:12