API Documentation
Loading...
Searching...
No Matches
GraphicsUpdater.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Graphics
28File: GraphicsUpdater
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
38#include "Base/Headers/Thread.h"
39namespace NDEVR
40{
41 class Exception;
42 class CheckoutLock;
43 class Renderer;
44 class GraphicsSession;
46 {
47 friend class CheckoutLock;
48 public:
51 void update(DesignObjectLookup* lookup, Time time) override;
53 {
54 m_args.log = log;
55 }
57 {
58 m_args.lookup = lookup;
59 }
61 {
62 return m_last_update_time;
63 }
64 bool hasManager(const UUID& id);
65 void addManager(const UUID& id, Renderer* renderer);
66 void removeManager(const UUID& id);
67 CheckoutLock tryCheckout(const UUID& id, bool wait_until_ready);
68 CheckoutLock checkout(const UUID& id, bool wait_until_ready);
69 const DynamicPointer<GraphicsDevice>& device() const { return m_device; };
71 {
72 WLock lock(this);
73 m_pipelines.add(pipline);
74 }
75 void removePipeline(GraphicsPipeline* pipline);
76 GraphicsUpdateArguments& args() { return m_args; }
77 void recreate();
78 //void recoverFromDeviceLost();
79 static GraphicsUpdater* DefaultUpdater(DesignObjectLookup* lookup, ProgressInfo* log, DynamicPointer<GraphicsDevice> device);
80 void setExceptionCallback(const std::function<void(const Exception&)>& callback) { m_exception_callback = callback; };
81 void setIsGrabSetup(bool grab_setup);
82 void update();
83 void update(GraphicsUpdateArguments& args);
84 protected:
85 RLock _checkout(const UUID& id, bool wait_until_ready);
86 void checkin(const UUID& id);
87 bool renderNeedsUpdate() const;
88 bool createPipeline(GraphicsUpdateArguments& args);
89 void updateUniformBuffer(GraphicsUpdateArguments& args);
90 protected:
92 std::function<void(const Exception&)> m_exception_callback;
99 std::mutex m_critical_section;//critical section for this object only
101 };
102
104 {
105 public:
106 CheckoutLock(GraphicsUpdater* updater, bool wait_until_ready, UUID id = Constant<UUID>::NaN)
107 : m_updater(updater)
108 , m_id(id)
109 , m_lock(!isNaN(m_id) ? m_updater->_checkout(m_id, wait_until_ready) : RLock(&m_id))
110 {}
111 CheckoutLock(const CheckoutLock& checkout) = delete;
113 : m_updater(checkout.m_updater)
114 , m_id(checkout.m_id)
115 , m_lock(std::move(checkout.m_lock))
116 {
117 checkout.m_id = Constant<UUID>::NaN;
118 }
120 {
121 if(!isNaN(m_id))
123 }
125 {
126 return (!isNaN(m_id));
127 }
128 protected:
132 };
133}
#define NDEVR_GRAPHICS_API
Definition DLLInfo.h:74
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
Definition GraphicsUpdater.h:104
GraphicsUpdater * m_updater
Definition GraphicsUpdater.h:129
CheckoutLock(const CheckoutLock &checkout)=delete
~CheckoutLock()
Definition GraphicsUpdater.h:119
CheckoutLock(GraphicsUpdater *updater, bool wait_until_ready, UUID id=Constant< UUID >::NaN)
Definition GraphicsUpdater.h:106
UUID m_id
Definition GraphicsUpdater.h:130
RLock m_lock
Definition GraphicsUpdater.h:131
CheckoutLock(CheckoutLock &&checkout)
Definition GraphicsUpdater.h:112
bool isCheckedOut()
Definition GraphicsUpdater.h:124
A core class where all Design Objects including models, materials, and geometries are stored.
Definition DesignObjectLookup.h:65
An object that will be call update, each time the lookup is updated.
Definition DesignObjectUpdateTarget.h:10
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:59
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:319
Definition Exception.hpp:52
Definition GraphicsPipeline.h:45
Definition GraphicsUpdateArguments.h:40
Definition GraphicsUpdater.h:46
void addPipeline(GraphicsPipeline *pipline)
Definition GraphicsUpdater.h:70
void setExceptionCallback(const std::function< void(const Exception &)> &callback)
Definition GraphicsUpdater.h:80
void checkin(const UUID &id)
Definition GraphicsUpdater.cpp:180
std::function< void(const Exception &)> m_exception_callback
Definition GraphicsUpdater.h:92
bool m_grab_setup
Definition GraphicsUpdater.h:100
GraphicsUpdateArguments m_args
Definition GraphicsUpdater.h:97
Dictionary< UUID, bool > needs_update
Definition GraphicsUpdater.h:94
void setLog(ProgressInfo *log)
Definition GraphicsUpdater.h:52
Buffer< GraphicsPipeline * > m_pipelines
Definition GraphicsUpdater.h:98
DynamicPointer< GraphicsDevice > m_device
Definition GraphicsUpdater.h:91
void setLookup(DesignObjectLookup *lookup)
Definition GraphicsUpdater.h:56
volatile uint04 m_total_checked_out_count
Definition GraphicsUpdater.h:93
std::mutex m_critical_section
Definition GraphicsUpdater.h:99
Time lastUpdateTime() const
Definition GraphicsUpdater.h:60
Time m_last_update_time
Definition GraphicsUpdater.h:96
Dictionary< UUID, Renderer * > m_renderers
Definition GraphicsUpdater.h:95
GraphicsUpdateArguments & args()
Definition GraphicsUpdater.h:76
const DynamicPointer< GraphicsDevice > & device() const
Definition GraphicsUpdater.h:69
A light-weight base class for Log that allows processes to update, without the need for.
Definition ProgressInfo.hpp:48
Used to lock a particular variable for reading. Any number of readers can be created when no write lo...
Definition RWLock.h:91
Definition Renderer.h:47
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:62
Used to lock a particular variable for writing. Only one write lock can be created when no read locks...
Definition RWLock.h:115
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:115
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:195
Definition File.h:210
Definition BaseValues.hpp:267