Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ShaderComputeQueue.cpp
Go to the documentation of this file.
1
2
4
7
8namespace Divide
9{
10
12 : _queueComputeTimer( Time::ADD_TIMER( "Shader Queue Timer" ) )
13 {
14 }
15
17 {
19
20 {
22 if ( _shaderComputeQueue.empty() )
23 {
24 return;
25 }
26 }
27
29 if ( !stepQueue() )
30 {
31 NOP();
32 }
33 }
34
35 // Processes a queue element on the spot
37 {
40 resDescriptor._propertyDescriptor = element._shaderDescriptor;
41 resDescriptor.waitForReady( false );
42 *element._shaderRef = CreateResource( resDescriptor, _maxShaderLoadsInFlight );
43 }
44
46 {
48 return stepQueueLocked();
49 }
50
52 {
54
55 constexpr U8 MAX_STEP_PER_FRAME = 15u;
56
57 if ( _shaderComputeQueue.empty() )
58 {
59 return false;
60 }
61
62 if ( _maxShaderLoadsInFlight.load() >= MAX_STEP_PER_FRAME )
63 {
64 return false;
65 }
66
67 while ( !_shaderComputeQueue.empty() )
68 {
70 _shaderComputeQueue.pop_front();
71 }
72 return true;
73 }
74
76 {
78 _shaderComputeQueue.push_front( element );
79 }
80
82 {
84 _shaderComputeQueue.push_back( element );
85 }
86
87} //namespace Divide
#define NOP()
#define PROFILE_SCOPE_AUTO(CATEGORY)
Definition: Profiler.h:87
void addToQueueBack(const ShaderQueueElement &element)
void addToQueueFront(const ShaderQueueElement &element)
Time::ProfileTimer & _queueComputeTimer
std::deque< ShaderQueueElement > _shaderComputeQueue
void process(ShaderQueueElement &element)
std::atomic_uint _maxShaderLoadsInFlight
constexpr Optick::Category::Type Streaming
Definition: Profiler.h:65
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::lock_guard< mutex > LockGuard
Definition: SharedMutex.h:55
uint8_t U8
std::shared_lock< mutex > SharedLock
Definition: SharedMutex.h:49
FORCE_INLINE Handle< T > CreateResource(const ResourceDescriptor< T > &descriptor, bool &wasInCache, std::atomic_uint &taskCounter)
PropertyDescriptor< T > _propertyDescriptor
Definition: Resource.h:151