CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
RenderGraph.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
12
16
17namespace CeresEngine {
18
20
21 template<typename T> using RenderGraphVector = Vector<T>;
22
24 private:
25 struct Step;
26 friend class RenderResource;
27
29
33
34 public:
36
37 RenderGraph(const RenderGraph&) = delete;
39
41
42 public:
48 template<typename T, typename... Args> T& addTask(Args&&... args) {
49 T* const ptr = new T(*this, std::forward<Args>(args)...);
50 mTasks.emplace_back(ptr);
51 return *ptr;
52 }
53
58
63
68
73
79 template<typename T, typename... Args> T& createResource(Args&&... args) {
80 T* const ptr = new T(*this, std::forward<Args>(args)...);
81 mResources.emplace_back(ptr);
82 return *ptr;
83 }
84
85 private: // Internal API
86 template<typename T, typename... Args> T* allocate(Args&&... args) {
88 return new(allocator.allocate()) T(std::forward<Args>(args)...);
89 }
90
91 template<typename T> void deallocate(T* ptr) {
93 allocator.deallocate(ptr);
94 }
95
96 public:
97 void compile();
98 void compile2();
99
100 void execute(Renderer& renderer, GPUDevice& device);
101
102 void reset();
103 };
104
107
108 explicit Step(RenderTask* task) : task(task) {}
109 };
110
111} // namespace CeresEngine
Definition RenderResource.hpp:193
Definition GPUBuffer.hpp:124
Definition GPUDevice.hpp:357
Definition GPUImage.hpp:331
Definition RenderResource.hpp:114
Definition RenderGraph.hpp:23
ImageRenderResource & createResource(const GPUImageDescriptor &descriptor)
Creates a new transient image resource using the given descriptor.
T * allocate(Args &&... args)
Definition RenderGraph.hpp:86
RenderGraph & operator=(const RenderGraph &)=delete
T & createResource(Args &&... args)
Creates a new resource type of a custom type.
Definition RenderGraph.hpp:79
void deallocate(T *ptr)
Definition RenderGraph.hpp:91
void execute(Renderer &renderer, GPUDevice &device)
RenderGraphVector< RenderResourcePtr > mResources
Definition RenderGraph.hpp:30
BufferRenderResource & createResource(const GPUBufferDescriptor &descriptor)
Creates a new transient buffer resource using the given descriptor.
BufferRenderResource & createResource(GPUBuffer &buffer)
Creates a new external buffer resource using the given buffer.
RenderGraphAllocator mAllocator
Definition RenderGraph.hpp:28
RenderGraphVector< RenderTaskPtr > mTasks
Definition RenderGraph.hpp:31
RenderGraph(const RenderGraph &)=delete
RenderGraphVector< Step > mTimeline
Definition RenderGraph.hpp:32
ImageRenderResource & createResource(GPUImage &image)
Creates a new external image resource using the given image.
T & addTask(Args &&... args)
Adds a new task by creating a task of type T with by passing the given args to it's constructor.
Definition RenderGraph.hpp:48
Definition RenderResource.hpp:27
Definition RenderTask.hpp:164
The CeresEngine renderer.
Definition Renderer.hpp:35
Definition Application.hpp:19
foonathan::memory::std_allocator< T, RawAllocator > StdAllocator
Definition Allocator.hpp:225
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
Vector< T > RenderGraphVector
Definition RenderGraph.hpp:21
Definition Allocator.hpp:66
Hardware buffer descriptor structure.
Definition GPUBuffer.hpp:92
Definition GPUImage.hpp:247
Definition RenderGraph.hpp:105
Step(RenderTask *task)
Definition RenderGraph.hpp:108
RenderTask * task
Definition RenderGraph.hpp:106