Skip to content

Commit 7bc7516

Browse files
committed
simplified render pipline api
1 parent 9201924 commit 7bc7516

File tree

10 files changed

+330
-395
lines changed

10 files changed

+330
-395
lines changed

sources/include/cage-engine/renderPipeline.h

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,34 @@ namespace cage
1313
class ProvisionalGraphics;
1414
class AssetsOnDemand;
1515

16-
struct LodSelection
16+
struct CAGE_ENGINE_API LodSelection
1717
{
1818
Vec3 center; // center of camera
1919
Real screenSize = 0; // vertical size of screen in pixels, one meter in front of the camera
2020
bool orthographic = false;
2121
};
2222

23-
struct CAGE_ENGINE_API RenderPipelineCamera
23+
struct CAGE_ENGINE_API RenderPipelineConfig
2424
{
25-
CameraCommonProperties camera;
26-
ScreenSpaceEffectsComponent effects;
27-
LodSelection lodSelection;
2825
String name;
26+
ScreenSpaceEffectsComponent effects;
2927
Mat4 projection;
3028
Transform transform;
3129
TextureHandle target;
32-
Vec2i resolution;
33-
};
34-
35-
struct CAGE_ENGINE_API RenderPipelineDebugVisualization
36-
{
37-
TextureHandle texture;
38-
Holder<ShaderProgram> shader;
39-
};
40-
41-
struct CAGE_ENGINE_API RenderPipelineResult
42-
{
43-
Holder<PointerRange<RenderPipelineDebugVisualization>> debugVisualizations;
44-
Holder<RenderQueue> renderQueue;
45-
};
46-
47-
class CAGE_ENGINE_API RenderPipeline : private Immovable
48-
{
49-
public:
30+
CameraCommonProperties camera;
31+
LodSelection lodSelection;
5032
uint64 currentTime = 0;
5133
uint64 elapsedTime = 1000000 / 60; // microseconds since last frame
52-
uint32 frameIndex = 0;
53-
Real interpolationFactor = 1;
54-
55-
bool reinitialize();
56-
57-
// thread-safe: you may render multiple cameras simultaneously in threads
58-
RenderPipelineResult render(const RenderPipelineCamera &camera);
59-
};
60-
61-
struct CAGE_ENGINE_API RenderPipelineCreateConfig
62-
{
34+
Vec2i resolution;
6335
AssetsManager *assets = nullptr;
6436
ProvisionalGraphics *provisionalGraphics = nullptr;
6537
EntityManager *scene = nullptr;
6638
AssetsOnDemand *onDemand = nullptr;
39+
uint32 frameIndex = 0;
40+
Real interpolationFactor = 1;
6741
};
6842

69-
CAGE_ENGINE_API Holder<RenderPipeline> newRenderPipeline(const RenderPipelineCreateConfig &config);
43+
CAGE_ENGINE_API Holder<RenderQueue> renderPipeline(const RenderPipelineConfig &config);
7044
}
7145

7246
#endif // guard_renderPipeline_h_4hg1s8596drfh4

sources/include/cage-engine/renderQueue.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ namespace cage
109109
void genericEnable(uint32 key, bool enable);
110110
void resetAllState(); // set viewport, scissors, culling, depth, blend etc all to default values
111111

112+
template<class T>
113+
void customCommand(Holder<T> data)
114+
{
115+
using Fnc = void(void *);
116+
static Fnc *fnc = +[](void *d) { (*(T *)d)(); };
117+
_customCommand(std::move(data).cast<void>(), fnc);
118+
}
119+
template<class T>
120+
void customCommand(Holder<T> data, void fnc(T *))
121+
{
122+
using Fnc = void(void *);
123+
_customCommand(std::move(data).cast<void>(), (Fnc *)fnc);
124+
}
125+
112126
[[nodiscard]] struct RenderQueueNamedScope namedScope(StringPointer name);
113127

114128
// dispatch another queue as part of this queue
@@ -129,6 +143,9 @@ namespace cage
129143
uint32 commandsCount() const;
130144
uint32 drawsCount() const;
131145
uint32 primitivesCount() const;
146+
147+
private:
148+
void _customCommand(Holder<void> data, void (*fnc)(void *));
132149
};
133150

134151
CAGE_ENGINE_API Holder<RenderQueue> newRenderQueue(const String &name, ProvisionalGraphics *provisionalGraphics);

sources/include/cage-engine/virtualReality.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ namespace cage
5757
// also submits acquired textures to the device
5858
// requires opengl context
5959
void renderCommit();
60+
61+
// requires opengl context
62+
void renderCancel();
6063
};
6164

6265
class CAGE_ENGINE_API VirtualReality : private Immovable

sources/include/cage-simple/statisticsGui.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ namespace cage
4343
uint32 keyToggleStatisticsScope = 290; // f1
4444
uint32 keyToggleStatisticsMode = 291; // f2
4545
uint32 keyToggleProfilingEnabled = 292; // f3
46-
uint32 keyVisualizeBufferPrev = 294; // f5
47-
uint32 keyVisualizeBufferNext = 295; // f6
48-
uint32 keyToggleRenderMissingModels = 296; // f7
49-
uint32 keyToggleRenderSkeletonBones = 297; // f8
46+
uint32 keyToggleRenderMissingModels = 294; // f5
47+
uint32 keyToggleRenderSkeletonBones = 295; // f6
5048
uint32 keyDecreaseGamma = 298; // f9
5149
uint32 keyIncreaseGamma = 299; // f10
5250
ModifiersFlags keyModifiers = ModifiersFlags::Ctrl;

sources/libcore/memory/memoryArena.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <atomic>
21
#include <cstdlib>
32

43
#include <cage-core/memoryArena.h>
@@ -76,7 +75,6 @@ namespace cage
7675
void *tmp = malloca(size, alignment);
7776
if (!tmp)
7877
CAGE_THROW_ERROR(OutOfMemory, "system memory arena out of memory", size);
79-
allocations++;
8078
return tmp;
8179
}
8280

@@ -85,15 +83,11 @@ namespace cage
8583
if (!ptr)
8684
return;
8785
freea(ptr);
88-
if (allocations-- == 0)
89-
CAGE_THROW_CRITICAL(Exception, "memory corruption - double deallocation detected");
9086
}
9187

9288
void flush() { CAGE_THROW_CRITICAL(Exception, "invalid operation - deallocate must be used"); }
9389

9490
MemoryArena arena = MemoryArena(this);
95-
96-
std::atomic<uint32> allocations = 0;
9791
};
9892
}
9993

0 commit comments

Comments
 (0)