vsg  1.1.0
VulkanSceneGraph library
CompileManager.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2022 Robert Osfield
6 
7 Permission 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 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE 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 
18 namespace vsg
19 {
20 
23  struct VSG_DECLSPEC CompileResult
24  {
25  int result = VK_INCOMPLETE;
26  std::string message;
27  uint32_t maxSlot = 0;
28  bool containsPagedLOD = false;
29  ResourceRequirements::Views views;
30  ResourceRequirements::DynamicData earlyDynamicData;
31  ResourceRequirements::DynamicData lateDynamicData;
32 
33  explicit operator bool() const noexcept { return result == VK_SUCCESS; }
34 
35  void reset();
36  void add(const CompileResult& cr);
37  bool requiresViewerUpdate() const;
38  };
39 
41  class VSG_DECLSPEC CompileManager : public Inherit<Object, CompileManager>
42  {
43  public:
45 
47  void add(ref_ptr<Device> device, const ResourceRequirements& resourceRequirements = {});
48 
50  void add(Window& window, ref_ptr<ViewportState> viewport = {}, const ResourceRequirements& resourceRequirements = {});
51 
53  void add(Window& window, ref_ptr<View> view, const ResourceRequirements& resourceRequirements = {});
54 
56  void add(Framebuffer& framebuffer, ref_ptr<View> view, const ResourceRequirements& resourceRequirements = {});
57 
59  void add(const Viewer& viewer, const ResourceRequirements& resourceRequirements = {});
60 
61  using ContextSelectionFunction = std::function<bool(vsg::Context&)>;
62 
64  CompileResult compile(ref_ptr<Object> object, ContextSelectionFunction contextSelection = {});
65 
66  protected:
67  using CompileTraversals = ThreadSafeQueue<ref_ptr<CompileTraversal>>;
68  size_t numCompileTraversals = 0;
69  ref_ptr<CompileTraversals> compileTraversals;
70 
71  CompileTraversals::container_type takeCompileTraversals(size_t count);
72  };
73  VSG_type_name(vsg::CompileManager);
74 
75 } // namespace vsg
CompileManager is a helper class that compiles subgraphs for the windows/framebuffers associated with...
Definition: CompileManager.h:42
void add(ref_ptr< Device > device, const ResourceRequirements &resourceRequirements={})
add a compile Context for device
CompileResult compile(ref_ptr< Object > object, ContextSelectionFunction contextSelection={})
compile object
void add(Framebuffer &framebuffer, ref_ptr< View > view, const ResourceRequirements &resourceRequirements={})
add a compile Context for Framebuffer and associated View
void add(Window &window, ref_ptr< ViewportState > viewport={}, const ResourceRequirements &resourceRequirements={})
add a compile Context for Window and associated viewport.
void add(Window &window, ref_ptr< View > view, const ResourceRequirements &resourceRequirements={})
add a compile Context for View
void add(const Viewer &viewer, const ResourceRequirements &resourceRequirements={})
add a compile Context for all the Views assigned to a Viewer
Definition: Context.h:67
Framebuffer encapsulates VkFramebuffer, used as a rendering target associated with a Window or for re...
Definition: Framebuffer.h:23
Definition: Inherit.h:28
ResourceRequirements provides a container for various Vulkan resource requirements that can be used t...
Definition: ResourceRequirements.h:30
Template thread safe queue.
Definition: OperationQueue.h:27
Definition: Viewer.h:31
Definition: Window.h:31
Definition: ref_ptr.h:22
Definition: CompileManager.h:24
Definition: ResourceRequirements.h:56