vsg: include/vsg/app/CompileTraversal.h Source File

vsg 1.1.8 VulkanSceneGraph library

Loading...
Searching...
No Matches
CompileTraversal.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/app/Window.h>
16#include <vsg/core/Object.h>
17#include <vsg/nodes/Bin.h>
18#include <vsg/nodes/Group.h>
19#include <vsg/state/BufferInfo.h>
20#include <vsg/state/Descriptor.h>
21#include <vsg/state/ResourceHints.h>
22#include <vsg/utils/Instrumentation.h>
23#include <vsg/vk/CommandPool.h>
24#include <vsg/vk/Context.h>
25#include <vsg/vk/DescriptorPool.h>
26#include <vsg/vk/Fence.h>
27#include <vsg/vk/ResourceRequirements.h>
28
29namespace vsg
30{
31
33 class VSG_DECLSPEC CompileTraversal : public Inherit<Visitor, CompileTraversal>
34 {
35 public:
36 CompileTraversal() { overrideMask = vsg::MASK_ALL; }
37 CompileTraversal(const CompileTraversal& ct);
38 explicit CompileTraversal(ref_ptr<Device> device, const ResourceRequirements& resourceRequirements = {});
39 explicit CompileTraversal(Window& window, ref_ptr<ViewportState> viewport = {}, const ResourceRequirements& resourceRequirements = {});
40 explicit CompileTraversal(const Viewer& viewer, const ResourceRequirements& resourceRequirements = {});
41
43 VkQueueFlags queueFlags = VK_QUEUE_GRAPHICS_BIT;
44 uint32_t queueFamilyIndex = 1;
45
47 std::list<ref_ptr<Context>> contexts;
48
50 ref_ptr<Instrumentation> instrumentation;
51
53 void add(ref_ptr<Device> device, ref_ptr<TransferTask> transferTask, const ResourceRequirements& resourceRequirements = {});
54
56 void add(ref_ptr<Device> device, const ResourceRequirements& resourceRequirements = {});
57
59 void add(Window& window, ref_ptr<TransferTask> transferTask, ref_ptr<ViewportState> viewport = {}, const ResourceRequirements& resourceRequirements = {});
60
62 void add(Window& window, ref_ptr<ViewportState> viewport = {}, const ResourceRequirements& resourceRequirements = {});
63
65 void add(Window& window, ref_ptr<TransferTask> transferTask, ref_ptr<View> view, const ResourceRequirements& resourceRequirements = {});
66
68 void add(Window& window, ref_ptr<View> view, const ResourceRequirements& resourceRequirements = {});
69
71 void add(Framebuffer& framebuffer, ref_ptr<TransferTask> transferTask, ref_ptr<View> view, const ResourceRequirements& resourceRequirements = {});
72
74 void add(Framebuffer& framebuffer, ref_ptr<View> view, const ResourceRequirements& resourceRequirements = {});
75
77 void add(const Viewer& viewer, const ResourceRequirements& resourceRequirements = {});
78
80 void assignInstrumentation(ref_ptr<Instrumentation> in_instrumentation);
81
82 Instrumentation* getInstrumentation() override { return instrumentation.get(); }
83
84 virtual bool record();
85 virtual void waitForCompletion();
86
88 template<typename T>
89 void compile(T object, bool wait = true)
90 {
91 object->accept(*this);
92 if (record() && wait) waitForCompletion();
93 }
94
95 // implement compile of relevant nodes in the scene graph
96 void apply(Object& object) override;
97 void apply(Compilable& node) override;
98 void apply(Commands& commands) override;
99 void apply(Geometry& geometry) override;
100 void apply(CommandGraph& commandGraph) override;
101 void apply(SecondaryCommandGraph& secondaryCommandGraph) override;
102 void apply(RenderGraph& renderGraph) override;
103 void apply(View& view) override;
104
105 protected:
106 ~CompileTraversal();
107
108 void add(ref_ptr<Context> context, Framebuffer& framebuffer, ref_ptr<TransferTask> transferTask, ref_ptr<View> view, const ResourceRequirements& resourceRequirements);
109 void addViewDependentState(ViewDependentState& viewDependentState, ref_ptr<Device> device, ref_ptr<TransferTask> transferTask, const ResourceRequirements& resourceRequirements);
110 };
111 VSG_type_name(vsg::CompileTraversal);
112
113} // namespace vsg
vsg::CommandGraph
CommandGraph is a group node that sits at the top of the scene graph and manages the recording of its...
Definition CommandGraph.h:28
vsg::Commands
Definition Commands.h:29
vsg::Compilable
Base class for encapsulating nodes that have Vulkan objects associated with them that will need compi...
Definition Compilable.h:23
vsg::CompileTraversal
CompileTraversal traverses a scene graph and invokes all the StateCommand/Commandcompile(....
Definition CompileTraversal.h:34
vsg::CompileTraversal::add
void add(Window &window, ref_ptr< TransferTask > transferTask, ref_ptr< ViewportState > viewport={}, const ResourceRequirements &resourceRequirements={})
add a compile Context for Window and associated viewport.
vsg::CompileTraversal::add
void add(Framebuffer &framebuffer, ref_ptr< View > view, const ResourceRequirements &resourceRequirements={})
add a compile Context for Framebuffer and associated View
vsg::CompileTraversal::compile
void compile(T object, bool wait=true)
convenience method that compiles an object/subgraph
Definition CompileTraversal.h:89
vsg::CompileTraversal::add
void add(ref_ptr< Device > device, ref_ptr< TransferTask > transferTask, const ResourceRequirements &resourceRequirements={})
add a compile Context for device
vsg::CompileTraversal::add
void add(const Viewer &viewer, const ResourceRequirements &resourceRequirements={})
add a compile Context for all the Views assigned to a Viewer
vsg::CompileTraversal::add
void add(Framebuffer &framebuffer, ref_ptr< TransferTask > transferTask, ref_ptr< View > view, const ResourceRequirements &resourceRequirements={})
add a compile Context for Framebuffer and associated View
vsg::CompileTraversal::contexts
std::list< ref_ptr< Context > > contexts
list of Context that Vulkan objects should be compiled for.
Definition CompileTraversal.h:47
vsg::CompileTraversal::instrumentation
ref_ptr< Instrumentation > instrumentation
Hook for assigning Instrumentation to enable profiling.
Definition CompileTraversal.h:50
vsg::CompileTraversal::add
void add(Window &window, ref_ptr< TransferTask > transferTask, ref_ptr< View > view, const ResourceRequirements &resourceRequirements={})
add a compile Context for Window and associated View
vsg::CompileTraversal::add
void add(Window &window, ref_ptr< ViewportState > viewport={}, const ResourceRequirements &resourceRequirements={})
add a compile Context for Window and associated viewport.
vsg::CompileTraversal::assignInstrumentation
void assignInstrumentation(ref_ptr< Instrumentation > in_instrumentation)
assign Instrumentation to all Context
vsg::CompileTraversal::add
void add(Window &window, ref_ptr< View > view, const ResourceRequirements &resourceRequirements={})
add a compile Context for Window and associated View
vsg::CompileTraversal::add
void add(ref_ptr< Device > device, const ResourceRequirements &resourceRequirements={})
add a compile Context for device
vsg::Framebuffer
Framebuffer encapsulates VkFramebuffer, used as a rendering target associated with a Window or for re...
Definition Framebuffer.h:23
vsg::Geometry
Definition Geometry.h:30
vsg::Inherit
Definition Inherit.h:28
vsg::Instrumentation
base class for Instrumentation implentations
Definition Instrumentation.h:51
vsg::Object
Definition Object.h:60
vsg::RenderGraph
Definition RenderGraph.h:28
vsg::ResourceRequirements
ResourceRequirements provides a container for various Vulkan resource requirements that can be used t...
Definition ResourceRequirements.h:30
vsg::SecondaryCommandGraph
SecondaryCommandGraph is a specialization of CommandGraph that provides Vulkan secondary command buff...
Definition SecondaryCommandGraph.h:25
vsg::ViewDependentState
Definition ViewDependentState.h:106
vsg::View
View is a Group class that pairs a Camera that defines the view with a subgraph that defines the scen...
Definition View.h:36
vsg::Viewer
Definition Viewer.h:33
vsg::Window
Definition Window.h:31
vsg::ref_ptr
Definition ref_ptr.h:22