Skip to content

Commit e40dbbf

Browse files
Galaxy Brain Rendering Idea
1 parent c489f5a commit e40dbbf

File tree

5 files changed

+130
-4
lines changed

5 files changed

+130
-4
lines changed

include/nbl/scene/IAnimationBlendManager.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class IAnimationBlendManager : public virtual core::IReferenceCounted
2121
using blend_t = uint32_t;
2222

2323
// creation (TODO: should we support adding and removing animation libraries at runtime?)
24-
static inline core::smart_refctd_ptr<ITransformTreeManager> create(video::IVideoDriver* _driver, core::smart_refctd_ptr<video::IGPUAnimationLibrary>&& _animationLibrary)
24+
static inline core::smart_refctd_ptr<IAnimationBlendManager> create(video::IVideoDriver* _driver, core::smart_refctd_ptr<video::IGPUAnimationLibrary>&& _animationLibrary)
2525
{
2626
if (true) // TODO: some checks and validation before creating?
2727
return nullptr;
@@ -39,11 +39,12 @@ class IAnimationBlendManager : public virtual core::IReferenceCounted
3939
// add to a contiguous list in GPU memory
4040
void startBlends(const blend_t* begin, const blend_t* end)
4141
{
42-
// easy enough, just add the uints to the back of a GPU buffer and increment the counter used in dispatch indirect buffer
42+
// easy enough, just push the `blend_t`s to a GPU `sparse_vector`
4343
}
4444
// remove from a contiguous list in GPU memory
4545
void pauseBlends(const blend_t* begin, const blend_t* end)
4646
{
47+
// easy enough, just erase the `blend_t`s from a GPU `sparse_vector`
4748
}
4849

4950
//
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright (C) 2019 - DevSH Graphics Programming Sp. z O.O.
2+
// For conditions of distribution and use, see copyright notice in nabla.h
3+
// See the original file in irrlicht source for authors
4+
5+
#ifndef __NBL_SCENE_I_LEVEL_OF_DETAIL_LIBRARY_H_INCLUDED__
6+
#define __NBL_SCENE_I_LEVEL_OF_DETAIL_LIBRARY_H_INCLUDED__
7+
8+
#include "nbl/core/core.h"
9+
#include "nbl/video/video.h"
10+
11+
namespace nbl
12+
{
13+
namespace scene
14+
{
15+
16+
class ILevelOfDetailLibrary : public virtual core::IReferenceCounted
17+
{
18+
public:
19+
// TODO: Drawcall struct?
20+
using draw_call_t = uint32_t;
21+
// LoD will store a contiguous list of draw_call_t inside itself (first uint is the count)
22+
using lod_t = uint32_t;
23+
struct CullParameters
24+
{
25+
float distanceSq;
26+
27+
inline bool operator<(const CullParameters& other) const
28+
{
29+
return distanceSq<other.distanceSq;
30+
}
31+
};
32+
// LoDTable will store a contiguous list of lod_t inside itself (first uint is the count)
33+
using lod_table_t = uint32_t;
34+
35+
static inline core::smart_refctd_ptr<ILevelOfDetailLibrary> create(video::IVideoDriver* _driver, const uint32_t tableCapacity, const uint32_t lodLevelsCapacity, const uint32_t drawCallCapacity)
36+
{
37+
if (true) // TODO: some checks and validation before creating?
38+
return nullptr;
39+
40+
auto* lodl = new ILevelOfDetailLibrary(_driver/*,std::move(),std::move(),std::move()*/);
41+
return core::smart_refctd_ptr<ILevelOfDetailLibrary>(lodl,core::dont_grab);
42+
}
43+
44+
// TODO: register/deregister drawcalls/lods/tables
45+
template<typename MeshIterator, typename CullParamsIterator>
46+
struct RegisterLoDTable
47+
{
48+
MeshIterator beginMeshes;
49+
MeshIterator endMeshes;
50+
CullParamsIterator beginCullParams;
51+
};
52+
template<typename MeshBufferIterator>
53+
struct RegisterLoD
54+
{
55+
MeshBufferIterator beginMeshBuffers;
56+
MeshBufferIterator endMeshBuffers;
57+
};
58+
59+
template<typename MeshBufferIterator>
60+
draw_call_t registerDrawcalls(MeshBufferIterator begin, MeshBufferIterator end)
61+
{
62+
assert(false); // TODO
63+
}
64+
template<typename MeshBufferIterator>
65+
draw_call_t deregisterDrawcalls(MeshBufferIterator begin, MeshBufferIterator end)
66+
{
67+
assert(false); // TODO
68+
}
69+
70+
protected:
71+
ILevelOfDetailLibrary(video::IVideoDriver* _driver) : m_driver(_driver)
72+
{
73+
}
74+
~ILevelOfDetailLibrary()
75+
{
76+
// everything drops itself automatically
77+
}
78+
79+
video::IVideoDriver* m_driver;
80+
};
81+
82+
83+
} // end namespace scene
84+
} // end namespace nbl
85+
86+
#endif
87+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (C) 2019 - DevSH Graphics Programming Sp. z O.O.
2+
// For conditions of distribution and use, see copyright notice in nabla.h
3+
// See the original file in irrlicht source for authors
4+
5+
#ifndef __NBL_SCENE_I_RENDERPASS_MANAGER_H_INCLUDED__
6+
#define __NBL_SCENE_I_RENDERPASS_MANAGER_H_INCLUDED__
7+
8+
#include "nbl/core/core.h"
9+
#include "nbl/video/video.h"
10+
11+
#include "nbl/scene/ITransformTreeManager.h"
12+
//#include "nbl/scene/IRenderpass.h"
13+
14+
namespace nbl
15+
{
16+
namespace scene
17+
{
18+
19+
// assign one <node_t,SensorProps> to be the camera of the renderpass
20+
// register <draw_call_t,draw_indirect_t> when building a renderpass and keep it sorted
21+
// when we want to translate draw_call_t to draw_indirect_t we just do a binary search
22+
23+
// register many <renderpass_t,node_t,lod_table_t> to be rendered
24+
// TODO: Make LoDTable entries contain pointers to bindpose matrices and joint AABBs (culling of skinned models can only occur after LoD choice)
25+
// SPECIAL: when registering skeletons, allocate the registrations contiguously to get a free translation table for skinning
26+
// but reserve a per_view_data_t=<MVP,chosen_lod_t> for the output
27+
// keep in `sparse_vector` to make contiguous
28+
// convert <renderpass_t,node_t,per_view_data_t> into properly set up MDI calls, and compacted subranges of <node_t,per_view_data_t> ordered by <renderpass_t,draw_indirect_t> for use as per-Instance vertex attributes
29+
class IRenderpassManager : public virtual core::IReferenceCounted
30+
{
31+
};
32+
33+
34+
} // end namespace scene
35+
} // end namespace nbl
36+
37+
#endif
38+

include/nbl/scene/ITransformTreeManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class ITransformTreeManager : public virtual core::IReferenceCounted
136136
// TODO: utilities for adding root nodes, adding skeleton node instances, etc.
137137
// should we just do it ourselves with a shader? (set correct timestamps so global gets recomputed)
138138
#endif
139+
139140
//
140141
inline void removeNodes(const node_t* begin, const node_t* end)
141142
{

include/nbl/scene/scene.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
//
1313
#include "nbl/scene/IAnimationBlendManager.h"
14-
//#include "nbl/scene/ILevelOfDetailLibrary.h"
14+
#include "nbl/scene/IRenderpassManager.h"
1515
//#include "nbl/scene/ISensor.h" or asset? or a struct?
1616
//#include "nbl/scene/ICamera.h" or do we stick it inside the renderpass?
17-
//#include "nbl/scene/IRenderpassManager.h"
1817
//#include "nbl/scene/ISceneManager.h" do we need this?
1918
//#include "nbl/scene/.h"
2019

0 commit comments

Comments
 (0)