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;
45 /**--------------------------------------------------------------------------------------------------
46 \brief Responsible for updating resources or layouts of data in-between calls to render.
47 **/
49 {
50 friend class CheckoutLock;
51 public:
54 void update(DesignObjectLookup* lookup, Time time) override;
56 {
57 m_args.log = log;
58 }
60 {
61 m_args.lookup = lookup;
62 }
64 {
65 return m_last_update_time;
66 }
67 bool hasManager(const UUID& id);
68 void addManager(const UUID& id, Renderer* renderer);
69 void removeManager(const UUID& id);
70 CheckoutLock tryCheckout(const UUID& id, bool wait_until_ready);
71 CheckoutLock checkout(const UUID& id, bool wait_until_ready);
72 const DynamicPointer<GraphicsDevice>& device() const { return m_device; };
74 {
75 WLock lock(this);
76 m_pipelines.add(pipline);
77 }
79 GraphicsUpdateArguments& args() { return m_args; }
80 void recreate();
81 //void recoverFromDeviceLost();
83 void setExceptionCallback(const std::function<void(const Exception&)>& callback) { m_exception_callback = callback; };
84 void setIsGrabSetup(bool grab_setup);
85 void update();
87 private:
88 RLock _checkout(const UUID& id, bool wait_until_ready);
89 void checkin(const UUID& id);
90 bool renderNeedsUpdate() const;
91 bool createPipeline(GraphicsUpdateArguments& args);
92 void updateUniformBuffer(GraphicsUpdateArguments& args);
93 protected:
95 std::function<void(const Exception&)> m_exception_callback;
102 std::mutex m_critical_section;//critical section for this object only
104 };
105 /**--------------------------------------------------------------------------------------------------
106 \brief Used by Viewports to signal they are rendering and we should not be performing an Update
107 **/
109 {
110 public:
111 CheckoutLock(GraphicsUpdater* updater, bool wait_until_ready, UUID id = Constant<UUID>::Invalid)
112 : m_updater(updater)
113 , m_id(id)
114 , m_lock(!IsInvalid(m_id) ? m_updater->_checkout(m_id, wait_until_ready) : RLock(&m_id))
115 {}
116 CheckoutLock(const CheckoutLock& checkout) = delete;
118 : m_updater(checkout.m_updater)
119 , m_id(checkout.m_id)
120 , m_lock(std::move(checkout.m_lock))
121 {
122 checkout.m_id = Constant<UUID>::Invalid;
123 }
125 {
126 if(!IsInvalid(m_id))
127 m_updater->checkin(m_id);
128 }
130 {
131 return (!IsInvalid(m_id));
132 }
133 protected:
137 };
138}
#define NDEVR_GRAPHICS_API
Definition DLLInfo.h:56
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Used by Viewports to signal they are rendering and we should not be performing an Update.
Definition GraphicsUpdater.h:109
GraphicsUpdater * m_updater
Definition GraphicsUpdater.h:134
CheckoutLock(const CheckoutLock &checkout)=delete
~CheckoutLock()
Definition GraphicsUpdater.h:124
UUID m_id
Definition GraphicsUpdater.h:135
RLock m_lock
Definition GraphicsUpdater.h:136
CheckoutLock(GraphicsUpdater *updater, bool wait_until_ready, UUID id=Constant< UUID >::Invalid)
Definition GraphicsUpdater.h:111
CheckoutLock(CheckoutLock &&checkout)
Definition GraphicsUpdater.h:117
bool isCheckedOut()
Definition GraphicsUpdater.h:129
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. Key features include:
Definition Dictionary.h:61
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
Provides consistent interface to handle errors through the throw expression. All exceptions generated...
Definition Exception.hpp:47
A GraphicsPipeline is a set of resources that are chained together to correctly render something.
Definition GraphicsPipeline.h:47
Options that are used for performing an update on a Graphics Engine call.
Definition GraphicsUpdateArguments.h:43
Responsible for updating resources or layouts of data in-between calls to render.
Definition GraphicsUpdater.h:49
void addPipeline(GraphicsPipeline *pipline)
Definition GraphicsUpdater.h:73
bool hasManager(const UUID &id)
void setExceptionCallback(const std::function< void(const Exception &)> &callback)
Definition GraphicsUpdater.h:83
void update(GraphicsUpdateArguments &args)
void addManager(const UUID &id, Renderer *renderer)
std::function< void(const Exception &)> m_exception_callback
Definition GraphicsUpdater.h:95
CheckoutLock checkout(const UUID &id, bool wait_until_ready)
GraphicsUpdater(DesignObjectLookup *lookup, const DynamicPointer< GraphicsDevice > &device, ProgressInfo *log=nullptr)
bool m_grab_setup
Definition GraphicsUpdater.h:103
void removePipeline(GraphicsPipeline *pipline)
GraphicsUpdateArguments m_args
Definition GraphicsUpdater.h:100
Dictionary< UUID, bool > needs_update
Definition GraphicsUpdater.h:97
void update(DesignObjectLookup *lookup, Time time) override
void setLog(ProgressInfo *log)
Definition GraphicsUpdater.h:55
Buffer< GraphicsPipeline * > m_pipelines
Definition GraphicsUpdater.h:101
DynamicPointer< GraphicsDevice > m_device
Definition GraphicsUpdater.h:94
void setLookup(DesignObjectLookup *lookup)
Definition GraphicsUpdater.h:59
volatile uint04 m_total_checked_out_count
Definition GraphicsUpdater.h:96
std::mutex m_critical_section
Definition GraphicsUpdater.h:102
void removeManager(const UUID &id)
static GraphicsUpdater * DefaultUpdater(DesignObjectLookup *lookup, ProgressInfo *log, DynamicPointer< GraphicsDevice > device)
Time lastUpdateTime() const
Definition GraphicsUpdater.h:63
void setIsGrabSetup(bool grab_setup)
Time m_last_update_time
Definition GraphicsUpdater.h:99
Dictionary< UUID, Renderer * > m_renderers
Definition GraphicsUpdater.h:98
CheckoutLock tryCheckout(const UUID &id, bool wait_until_ready)
GraphicsUpdateArguments & args()
Definition GraphicsUpdater.h:79
const DynamicPointer< GraphicsDevice > & device() const
Definition GraphicsUpdater.h:72
A light-weight base class for Log that allows processes to update, without the need for additional in...
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
An object that renders a specific Camera object, typically run on a different thread than the main UI...
Definition Renderer.h:52
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:60
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
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Definition File.h:211
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233