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

vsg 1.1.13 VulkanSceneGraph library

Loading...
Searching...
No Matches
CompileManager.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2022 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/CompileTraversal.h>
16#include <vsg/threading/OperationQueue.h>
17
18namespace vsg
19{
20
21 // forward declare
22 class RecordAndSubmitTask;
23
26 struct VSG_DECLSPEC CompileResult
27 {
28 int result = VK_INCOMPLETE;
29 std::string message;
30 Slots maxSlots;
31 bool containsPagedLOD = false;
32 ResourceRequirements::Views views;
33 ResourceRequirements::DynamicData dynamicData;
34
35 explicit operator bool() const noexcept { return result == VK_SUCCESS; }
36
37 void reset();
38 void add(const CompileResult& cr);
39 bool requiresViewerUpdate() const;
40 };
41
43 class VSG_DECLSPEC CompileManager : public Inherit<Object, CompileManager>
44 {
45 public:
46 CompileManager(Viewer& viewer, ref_ptr<ResourceHints> hints);
47
49 void add(ref_ptr<Device> device, const ResourceRequirements& resourceRequirements = {});
50
52 void add(Window& window, ref_ptr<ViewportState> viewport = {}, const ResourceRequirements& resourceRequirements = {});
53
55 void add(Window& window, ref_ptr<View> view, const ResourceRequirements& resourceRequirements = {});
56
58 void add(Framebuffer& framebuffer, ref_ptr<View> view, const ResourceRequirements& resourceRequirements = {});
59
61 void add(const Viewer& viewer, const ResourceRequirements& resourceRequirements = {});
62
64 void assignInstrumentation(ref_ptr<Instrumentation> in_instrumentation);
65
66 using ContextSelectionFunction = std::function<bool(vsg::Context&)>;
67
69 CompileResult compile(ref_ptr<Object> object, ContextSelectionFunction contextSelection = {});
70
72 CompileResult compileTask(ref_ptr<RecordAndSubmitTask> task, const ResourceRequirements& resourceRequirements = {});
73
74 protected:
75 using CompileTraversals = ThreadSafeQueue<ref_ptr<CompileTraversal>>;
76 size_t numCompileTraversals = 0;
77 ref_ptr<CompileTraversals> compileTraversals;
78
79 CompileTraversals::container_type takeCompileTraversals(size_t count);
80 };
81 VSG_type_name(vsg::CompileManager);
82
83} // namespace vsg
vsg::CompileManager
CompileManager is a helper class that compiles subgraphs for the windows/framebuffers associated with...
Definition CompileManager.h:44
vsg::CompileManager::add
void add(ref_ptr< Device > device, const ResourceRequirements &resourceRequirements={})
add a compile Context for device
vsg::CompileManager::compile
CompileResult compile(ref_ptr< Object > object, ContextSelectionFunction contextSelection={})
compile object
vsg::CompileManager::compileTask
CompileResult compileTask(ref_ptr< RecordAndSubmitTask > task, const ResourceRequirements &resourceRequirements={})
compile all the command graphs in a task
vsg::CompileManager::add
void add(Framebuffer &framebuffer, ref_ptr< View > view, const ResourceRequirements &resourceRequirements={})
add a compile Context for Framebuffer and associated View
vsg::CompileManager::add
void add(Window &window, ref_ptr< ViewportState > viewport={}, const ResourceRequirements &resourceRequirements={})
add a compile Context for Window and associated viewport.
vsg::CompileManager::add
void add(Window &window, ref_ptr< View > view, const ResourceRequirements &resourceRequirements={})
add a compile Context for View
vsg::CompileManager::assignInstrumentation
void assignInstrumentation(ref_ptr< Instrumentation > in_instrumentation)
assign Instrumentation to all CompileTraversal and their associated Context
vsg::CompileManager::add
void add(const Viewer &viewer, const ResourceRequirements &resourceRequirements={})
add a compile Context for all the Views assigned to a Viewer
vsg::Context
Definition Context.h:67
vsg::Framebuffer
Framebuffer encapsulates VkFramebuffer, used as a rendering target associated with a Window or for re...
Definition Framebuffer.h:23
vsg::RecordAndSubmitTask
RecordAndSubmitTask manages the recording of its list of CommandGraph to CommandBuffer which are then...
Definition RecordAndSubmitTask.h:28
vsg::ResourceRequirements
ResourceRequirements provides a container for various Vulkan resource requirements that can be used t...
Definition ResourceRequirements.h:30
vsg::ThreadSafeQueue
Template thread safe queue.
Definition OperationQueue.h:32
vsg::Viewer
Definition Viewer.h:33
vsg::Window
Definition Window.h:31
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::CompileResult
Definition CompileManager.h:27
vsg::ResourceRequirements::DynamicData
Definition ResourceRequirements.h:64
vsg::Slots
max slot values used for general state and view state related State::stateStacks
Definition Slots.h:22