Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ShaderComputeQueue.h
Go to the documentation of this file.
1/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30*/
31
32#pragma once
33#ifndef DVD_SHADER_COMPUTE_QUEUE_H_
34#define DVD_SHADER_COMPUTE_QUEUE_H_
35
36#include "ShaderProgramInfo.h"
38
39namespace Divide {
40
41namespace Time {
42 class ProfileTimer;
43};
44
45class PlatformContext;
46
48public:
50 {
53 };
54
55public:
56 explicit ShaderComputeQueue();
57
58 // This is the main loop that steps through the queue and processes each entry
59 void idle();
60 // Processes a queue element on the spot
61 void process(ShaderQueueElement& element);
62 // Push a process request at the front of the queue
63 void addToQueueFront(const ShaderQueueElement& element);
64 // Push a process request at the end of the queue
65 void addToQueueBack(const ShaderQueueElement& element);
66 // Process the first entry in the queue immediately.
67 // This is called in a loop in the 'update' call, but can be user called as well if the shader is needed immediately
68 // Return true if the queue wasn't empty
69 [[nodiscard]] bool stepQueue();
70
71private:
72 [[nodiscard]] bool stepQueueLocked();
73
74private:
75
77
79 std::deque<ShaderQueueElement> _shaderComputeQueue;
80 std::atomic_uint _maxShaderLoadsInFlight{0u};
81};
82
83}; //namespace Divide
84
85#endif //DVD_SHADER_COMPUTE_QUEUE_H_
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
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::shared_mutex SharedMutex
Definition: SharedMutex.h:43