19
19
class Renderer : public nbl ::core::IReferenceCounted, public nbl::core::InterfaceUnmovable
20
20
{
21
21
public:
22
- #include " drawCommon.glsl "
23
- #include " raytraceCommon.glsl "
22
+ #include " rasterizationCommon.h "
23
+ #include " raytraceCommon.h "
24
24
#ifdef __cplusplus
25
25
#undef uint
26
+ #undef vec4
26
27
#undef mat4
27
28
#undef mat4x3
28
29
#endif
29
30
30
- // No 8k yet, too many rays to store
31
- _NBL_STATIC_INLINE_CONSTEXPR uint32_t MaxResolution[2 ] = {7680 /2 ,4320 /2 };
32
-
33
-
34
31
Renderer (nbl::video::IVideoDriver* _driver, nbl::asset::IAssetManager* _assetManager, nbl::scene::ISceneManager* _smgr, bool useDenoiser = true );
35
32
36
- void init ( const nbl::asset::SAssetBundle& meshes, nbl::core::smart_refctd_ptr<nbl::asset::ICPUBuffer>&& sampleSequence,
37
- uint32_t rayBufferSize=(sizeof (::RadeonRays::ray)+sizeof(::RadeonRays::Intersection))*2u*MaxResolution[0]*MaxResolution[1]); // 2 samples for MIS, TODO: compute default buffer size
33
+ void init (const nbl::asset::SAssetBundle& meshes, nbl::core::smart_refctd_ptr<nbl::asset::ICPUBuffer>&& sampleSequence);
38
34
39
35
void deinit ();
40
36
@@ -47,7 +43,7 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
47
43
uint64_t getTotalSamplesComputed () const
48
44
{
49
45
const auto samplesPerDispatch = static_cast <uint64_t >(m_staticViewData.samplesPerRowPerDispatch *m_staticViewData.imageDimensions .y );
50
- const auto framesDispatched = static_cast <uint64_t >(m_raytraceCommonData. framesDispatched );
46
+ const auto framesDispatched = static_cast <uint64_t >(m_framesDispatched );
51
47
return framesDispatched*samplesPerDispatch;
52
48
}
53
49
@@ -59,7 +55,7 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
59
55
60
56
struct InitializationData
61
57
{
62
- InitializationData () : lights(),lightRadiances(),lightCDF(),globalMeta(nullptr ) {}
58
+ InitializationData () : mdiFirstIndices(), lights(),lightRadiances(),lightCDF(),globalMeta(nullptr ) {}
63
59
InitializationData (InitializationData&& other) : InitializationData()
64
60
{
65
61
operator =(std::move (other));
@@ -68,14 +64,15 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
68
64
69
65
inline InitializationData& operator =(InitializationData&& other)
70
66
{
67
+ mdiFirstIndices = std::move (other.mdiFirstIndices );
71
68
lights = std::move (other.lights );
72
69
lightRadiances = std::move (other.lightRadiances );
73
70
lightCDF = std::move (other.lightCDF );
74
71
globalMeta = other.globalMeta ;
75
72
return *this ;
76
73
}
77
74
78
-
75
+ nbl::core::vector< uint32_t > mdiFirstIndices;
79
76
nbl::core::vector<SLight> lights;
80
77
nbl::core::vector<nbl::core::vectorSIMDf> lightRadiances;
81
78
union
@@ -89,7 +86,9 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
89
86
void initSceneNonAreaLights (InitializationData& initData);
90
87
void finalizeScene (InitializationData& initData);
91
88
92
- nbl::core::smart_refctd_ptr<nbl::video::IGPUImageView> createScreenSizedTexture (nbl::asset::E_FORMAT format);
89
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUImageView> createScreenSizedTexture (nbl::asset::E_FORMAT format, uint32_t layers = 0u );
90
+
91
+ void traceBounce ();
93
92
94
93
95
94
// "constants"
@@ -111,33 +110,27 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
111
110
112
111
// persistent (intialized in constructor
113
112
nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSetLayout> m_cullDSLayout;
114
-
115
- nbl::core::smart_refctd_ptr<nbl::asset::ICPUSpecializedShader> m_visibilityBufferFillShaders[2 ];
116
- nbl::core::smart_refctd_ptr<nbl::asset::ICPUPipelineLayout> m_visibilityBufferFillPipelineLayoutCPU;
117
- nbl::core::smart_refctd_ptr<nbl::video::IGPUPipelineLayout> m_visibilityBufferFillPipelineLayoutGPU;
118
- nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSetLayout> m_perCameraRasterDSLayout;
119
-
120
- nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSetLayout> m_commonRaytracingDSLayout, m_raygenDSLayout, m_resolveDSLayout;
113
+ nbl::core::smart_refctd_ptr<const nbl::video::IGPUDescriptorSetLayout> m_perCameraRasterDSLayout;
114
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSetLayout> m_rasterInstanceDataDSLayout,m_additionalGlobalDSLayout,m_commonRaytracingDSLayout,m_raygenDSLayout,m_resolveDSLayout;
115
+ nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpassIndependentPipeline> m_visibilityBufferFillPipeline;
121
116
122
117
123
118
// scene specific data
124
- nbl::ext::RadeonRays::MockSceneManager m_mock_smgr;
125
- nbl::ext::RadeonRays::Manager::MeshBufferRRShapeCache rrShapeCache;
126
- nbl::ext::RadeonRays::Manager::NblInstanceRRInstanceCache rrInstances;
119
+ nbl::core::vector<::RadeonRays::Shape*> rrShapes;
120
+ nbl::core::vector<::RadeonRays::Shape*> rrInstances;
127
121
128
122
nbl::core::matrix3x4SIMD m_prevView;
129
123
nbl::core::aabbox3df m_sceneBound;
130
124
uint32_t m_maxRaysPerDispatch;
125
+ uint32_t m_framesDispatched;
131
126
StaticViewData_t m_staticViewData;
132
127
RaytraceShaderCommonData_t m_raytraceCommonData;
133
128
129
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUBuffer> m_indexBuffer;
134
130
nbl::core::smart_refctd_ptr<nbl::video::IGPUBuffer> m_indirectDrawBuffers[2 ];
135
131
struct MDICall
136
132
{
137
- nbl::asset::SBufferBinding<const nbl::video::IGPUBuffer> vertexBindings[nbl::video::IGPUMeshBuffer::MAX_ATTR_BUF_BINDING_COUNT];
138
- nbl::core::smart_refctd_ptr<const nbl::video::IGPUBuffer> indexBuffer;
139
- nbl::core::smart_refctd_ptr<const nbl::video::IGPURenderpassIndependentPipeline> pipeline;
140
- uint32_t mdiOffset, mdiCount;
133
+ uint32_t mdiOffset,mdiCount;
141
134
};
142
135
nbl::core::vector<MDICall> m_mdiDrawCalls;
143
136
nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_cullDS;
@@ -148,21 +141,21 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
148
141
149
142
nbl::core::smart_refctd_ptr<nbl::video::IGPUPipelineLayout> m_cullPipelineLayout, m_raygenPipelineLayout, m_resolvePipelineLayout;
150
143
nbl::core::smart_refctd_ptr<nbl::video::IGPUComputePipeline> m_cullPipeline, m_raygenPipeline, m_resolvePipeline;
151
- nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_globalBackendDataDS,m_commonRaytracingDS,m_raygenDS;
144
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_globalBackendDataDS,m_rasterInstanceDataDS,m_additionalGlobalDS, m_commonRaytracingDS,m_raygenDS;
152
145
uint32_t m_raygenWorkGroups[2 ];
153
146
154
147
struct InteropBuffer
155
148
{
156
149
nbl::core::smart_refctd_ptr<nbl::video::IGPUBuffer> buffer;
157
150
std::pair<::RadeonRays::Buffer*, cl_mem> asRRBuffer = { nullptr ,0u };
158
151
};
159
- InteropBuffer m_rayCountBuffer,m_rayBuffer,m_intersectionBuffer;
152
+ InteropBuffer m_rayCountBuffer[2 ];
153
+ InteropBuffer m_rayBuffer,m_intersectionBuffer;
160
154
161
155
nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_resolveDS;
162
- uint32_t m_resolveWorkGroups[2 ];
163
156
164
157
nbl::core::smart_refctd_ptr<nbl::video::IGPUImageView> m_accumulation,m_tonemapOutput;
165
- nbl::video::IFrameBuffer* m_visibilityBuffer,* m_colorBuffer,* tmpTonemapBuffer ;
158
+ nbl::video::IFrameBuffer* m_visibilityBuffer,* m_colorBuffer;
166
159
167
160
#ifdef _NBL_BUILD_OPTIX_
168
161
nbl::core::smart_refctd_ptr<nbl::ext::OptiX::IDenoiser> m_denoiser;
0 commit comments