Cogs.Core
RenderTask.h
1#pragma once
2
3#include "Renderer/RenderResource.h"
4
5#include "Rendering/Common.h"
6
7#include "Foundation/StringView.h"
8#include "Foundation/Reflection/Type.h"
9
10#include <string>
11#include <vector>
12#include <functional>
13
14namespace Cogs
15{
16 class IGraphicsDevice;
17
18 namespace Core
19 {
20 struct COGSCORE_DLL_API RenderTaskResource
21 {
22 std::string key;
23 std::string name;
24
25 RenderResourceType type;
26
27 union
28 {
29 RenderResource * resource;
30 struct RenderTarget * renderTarget;
31 struct RenderBuffer * renderBuffer;
32 struct RenderList * renderList;
33 struct RenderTexture * renderTexure;
34 };
35 };
36
37 struct COGSCORE_DLL_API RenderTaskResources
38 {
39 void add(RenderResource * resource, const StringView & key = "");
40 void add(RenderTaskResource * resource, const StringView & key = "");
41 void addResource(RenderResource * resource, const StringView & name);
42
43 RenderTaskResource * get(RenderResourceType type);
44 RenderTaskResource * get(RenderResourceType type, const StringView & key);
45 RenderTaskResource * get(const StringView & name);
46
47 const RenderTaskResource * get(const StringView & name) const;
48
49 std::vector<RenderTaskResource> resources;
50 };
51
53 {
54 class Context* context = nullptr;
55 class Renderer* renderer = nullptr;
56 IGraphicsDevice* device = nullptr;
57 class RenderResources* resources = nullptr;
58 struct RenderStates* states = nullptr;
59 const struct CameraData* cameraData = nullptr;
60 struct EngineBuffers* engineBuffers = nullptr;
61 struct RenderTarget* defaultRenderTarget = nullptr;
62 struct ExpressionContext* expressionContext = nullptr;
63 };
64
65 typedef std::vector<std::pair<std::string, std::string>> PipelineOptions;
66
68 {
69 enum ERenderTaskFlags
70 {
71 None = 0,
72 Persistent = 1,
73 Static = 2,
74 };
75 };
76
77 struct COGSCORE_DLL_API RenderTask
78 {
79 virtual ~RenderTask() {}
80 virtual void initialize(RenderTaskContext *) {};
81 virtual void cleanup(RenderTaskContext *) {};
82
83 virtual void apply(RenderTaskContext *) = 0;
84
85 bool isStatic() const { return (flags & RenderTaskFlags::Static) != 0; }
86
89
90 std::string name;
91 std::vector<std::string> dependencies;
92
93 PipelineOptions options;
94 RenderTaskFlags::ERenderTaskFlags flags = RenderTaskFlags::None;
95 bool allowSelfDependency = false;
96
97 size_t frameMod = 0;
98 size_t frameOffset = 0;
99
100 std::function<void(void)> deleter;
101 };
102
103 typedef std::vector<RenderTask *> RenderTaskList;
104 }
105}
106
107template<> inline Cogs::StringView getName<Cogs::Core::RenderTaskFlags::ERenderTaskFlags>() { return "RenderTaskFlags"; }
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Contains render resources used by the renderer.
Core renderer system.
Definition: Renderer.h:28
Represents a graphics device used to manage graphics resources and issue drawing commands.
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Contains data describing a Camera instance and its derived data structured such as matrix data and vi...
Definition: CameraSystem.h:67
Provides a context for evaluation of expressions.
Definition: Expressions.h:54