1
- #ifndef _EXTRA_CRAP_INCLUDED_
2
- #define _EXTRA_CRAP_INCLUDED_
1
+ #ifndef _RENDERER_INCLUDED_
2
+ #define _RENDERER_INCLUDED_
3
3
4
4
#include " nabla.h"
5
5
@@ -20,7 +20,9 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
20
20
{
21
21
public:
22
22
#include " ../drawCommon.glsl"
23
+ #include " ../raytraceCommon.glsl"
23
24
#ifdef __cplusplus
25
+ #undef uint
24
26
#undef mat4
25
27
#undef mat4x3
26
28
#endif
@@ -29,24 +31,25 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
29
31
_NBL_STATIC_INLINE_CONSTEXPR uint32_t MaxResolution[2 ] = {7680 /2 ,4320 /2 };
30
32
31
33
32
- Renderer (nbl::video::IVideoDriver* _driver, nbl::asset::IAssetManager* _assetManager, nbl::scene::ISceneManager* _smgr, nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet>&& globalBackendDataDS, bool useDenoiser = true );
34
+ Renderer (nbl::video::IVideoDriver* _driver, nbl::asset::IAssetManager* _assetManager, nbl::scene::ISceneManager* _smgr, bool useDenoiser = true );
33
35
34
- void init ( const nbl::asset::SAssetBundle& meshes,
35
- bool isCameraRightHanded,
36
- nbl::core::smart_refctd_ptr<nbl::asset::ICPUBuffer>&& sampleSequence,
37
- uint32_t rayBufferSize=(sizeof (::RadeonRays::ray)*2u+sizeof(uint32_t )*2u)*MaxResolution[0]*MaxResolution[1]); // 2 samples for MIS, TODO: compute default buffer size
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
38
38
39
39
void deinit ();
40
40
41
41
void render (nbl::ITimer* timer);
42
42
43
- bool isRightHanded () { return m_rightHanded; }
44
-
45
43
auto * getColorBuffer () { return m_colorBuffer; }
46
44
47
45
const auto & getSceneBound () const { return m_sceneBound; }
48
46
49
- uint64_t getTotalSamplesComputed () const { return static_cast <uint64_t >(m_samplesComputedPerPixel)*static_cast <uint64_t >(m_rayCountPerDispatch)/m_samplesPerPixelPerDispatch; }
47
+ uint64_t getTotalSamplesComputed () const
48
+ {
49
+ 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 );
51
+ return framesDispatched*samplesPerDispatch;
52
+ }
50
53
51
54
52
55
_NBL_STATIC_INLINE_CONSTEXPR uint32_t MaxDimensions = 6u ;
@@ -87,108 +90,81 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
87
90
88
91
nbl::core::smart_refctd_ptr<nbl::video::IGPUImageView> createScreenSizedTexture (nbl::asset::E_FORMAT format);
89
92
90
- #if TODO
91
- core::smart_refctd_ptr<video::IGPUDescriptorSetLayout> createDS2layoutCompost (bool useDenoiser, core::smart_refctd_ptr<video::IGPUSampler>& nearstSampler);
92
- core::smart_refctd_ptr<video::IGPUDescriptorSet> createDS2Compost (bool useDenoiser,
93
- core::smart_refctd_ptr<video::IGPUSampler>& nearestSampler
94
- );
95
- core::smart_refctd_ptr<video::IGPUPipelineLayout> createLayoutCompost ();
96
93
97
- core::smart_refctd_ptr<video::IGPUDescriptorSetLayout> createDS2layoutRaygen (core::smart_refctd_ptr<video::IGPUSampler>& nearstSampler);
98
- core::smart_refctd_ptr<video::IGPUDescriptorSet> createDS2Raygen (core::smart_refctd_ptr<video::IGPUSampler>& nearstSampler);
99
- core::smart_refctd_ptr<video::IGPUPipelineLayout> createLayoutRaygen ();
100
- #endif
101
-
102
- const bool m_useDenoiser;
94
+ // "constants"
95
+ bool m_useDenoiser;
103
96
97
+ // managers
104
98
nbl::video::IVideoDriver* m_driver;
105
99
106
100
nbl::asset::IAssetManager* m_assetManager;
107
101
nbl::scene::ISceneManager* m_smgr;
108
102
109
103
nbl::core::smart_refctd_ptr<nbl::ext::RadeonRays::Manager> m_rrManager;
104
+ #ifdef _IRR_BUILD_OPTIX_
105
+ nbl::core::smart_refctd_ptr<nbl::ext::OptiX::Manager> m_optixManager;
106
+ CUstream m_cudaStream;
107
+ nbl::core::smart_refctd_ptr<nbl::ext::OptiX::IContext> m_optixContext;
108
+ #endif
110
109
111
- nbl::core::smart_refctd_ptr<nbl::asset::ICPUSpecializedShader> m_visibilityBufferFillShaders[2 ];
112
- nbl::core::smart_refctd_ptr<nbl::asset::ICPUPipelineLayout> m_visibilityBufferFillPipelineLayoutCPU;
113
- nbl::core::smart_refctd_ptr<nbl::video::IGPUPipelineLayout> m_visibilityBufferFillPipelineLayoutGPU;
114
- nbl::core::smart_refctd_ptr<const nbl::video::IGPUDescriptorSetLayout> m_perCameraRasterDSLayout;
115
110
111
+ // persistent (intialized in constructor
116
112
nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSetLayout> m_cullDSLayout;
117
113
nbl::core::smart_refctd_ptr<nbl::video::IGPUPipelineLayout> m_cullPipelineLayout;
118
114
nbl::core::smart_refctd_ptr<nbl::video::IGPUComputePipeline> m_cullPipeline;
119
-
120
- nbl::core::smart_refctd_ptr<nbl::video::IGPUComputePipeline> m_raygenPipeline,m_resolvePipeline;
121
115
116
+ nbl::core::smart_refctd_ptr<nbl::asset::ICPUSpecializedShader> m_visibilityBufferFillShaders[2 ];
117
+ nbl::core::smart_refctd_ptr<nbl::asset::ICPUPipelineLayout> m_visibilityBufferFillPipelineLayoutCPU;
118
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUPipelineLayout> m_visibilityBufferFillPipelineLayoutGPU;
119
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSetLayout> m_perCameraRasterDSLayout;
120
+
121
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSetLayout> m_commonRaytracingDSLayout, m_raygenDSLayout, m_resolveDSLayout;
122
+
123
+
124
+ // scene specific data
125
+ nbl::ext::RadeonRays::MockSceneManager m_mock_smgr;
126
+ nbl::ext::RadeonRays::Manager::MeshBufferRRShapeCache rrShapeCache;
127
+ nbl::ext::RadeonRays::Manager::NblInstanceRRInstanceCache rrInstances;
122
128
123
- nbl::core::vectorSIMDf baseEnvColor;
124
129
nbl::core::aabbox3df m_sceneBound;
125
- uint32_t m_renderSize[2u ];
126
- bool m_rightHanded;
130
+ uint32_t m_maxRaysPerDispatch;
131
+ StaticViewData_t m_staticViewData;
132
+ RaytraceShaderCommonData_t m_raytraceCommonData;
127
133
128
134
nbl::core::smart_refctd_ptr<nbl::video::IGPUBuffer> m_indirectDrawBuffers[2 ];
129
135
struct MDICall
130
136
{
131
137
nbl::asset::SBufferBinding<nbl::video::IGPUBuffer> vertexBindings[nbl::video::IGPUMeshBuffer::MAX_ATTR_BUF_BINDING_COUNT];
132
138
nbl::core::smart_refctd_ptr<nbl::video::IGPUBuffer> indexBuffer;
133
139
nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpassIndependentPipeline> pipeline;
134
- uint32_t mdiOffset,mdiCount;
140
+ uint32_t mdiOffset, mdiCount;
135
141
};
136
142
nbl::core::vector<MDICall> m_mdiDrawCalls;
143
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_cullDS;
137
144
CullShaderData_t m_cullPushConstants;
145
+ uint32_t m_cullWorkGroups;
138
146
139
- uint32_t m_lightCount;
140
- nbl::core::smart_refctd_ptr<nbl::video::IGPUBuffer> m_lightCDFBuffer;
141
- nbl::core::smart_refctd_ptr<nbl::video::IGPUBuffer> m_lightBuffer;
142
- nbl::core::smart_refctd_ptr<nbl::video::IGPUBuffer> m_lightRadianceBuffer;
143
-
144
- nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_globalBackendDataDS,m_cullDS,m_perCameraRasterDS; // TODO: do we need to keep track of this?
145
-
146
-
147
- nbl::ext::RadeonRays::Manager::MeshBufferRRShapeCache rrShapeCache;
148
- #if TODO
149
- nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_compostDS2;
150
- nbl::core::smart_refctd_ptr<nbl::video::IGPUPipelineLayout> m_compostLayout;
151
- nbl::core::smart_refctd_ptr<nbl::video::IGPUComputePipeline> m_compostPipeline;
152
-
147
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_perCameraRasterDS;
148
+
149
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUPipelineLayout> m_raygenPipelineLayout, m_resolvePipelineLayout;
150
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUComputePipeline> m_raygenPipeline, m_resolvePipeline;
151
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_globalBackendDataDS,m_commonRaytracingDS,m_raygenDS;
153
152
uint32_t m_raygenWorkGroups[2 ];
154
- uint32_t m_resolveWorkGroups[2 ];
155
-
156
- nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_raygenDS2;
157
- nbl::core::smart_refctd_ptr<nbl::video::IGPUPipelineLayout> m_raygenLayout;
158
153
159
- nbl::ext::RadeonRays::Manager::MeshNodeRRInstanceCache rrInstances;
160
- #endif
161
154
struct InteropBuffer
162
155
{
163
156
nbl::core::smart_refctd_ptr<nbl::video::IGPUBuffer> buffer;
164
- std::pair<::RadeonRays::Buffer*,cl_mem> asRRBuffer;
157
+ std::pair<::RadeonRays::Buffer*, cl_mem> asRRBuffer = { nullptr , 0u } ;
165
158
};
166
159
InteropBuffer m_rayCountBuffer,m_rayBuffer,m_intersectionBuffer;
167
160
161
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUDescriptorSet> m_resolveDS;
162
+ uint32_t m_resolveWorkGroups[2 ];
168
163
169
- enum E_VISIBILITY_BUFFER_ATTACHMENT
170
- {
171
- EVBA_DEPTH,
172
- EVBA_OBJECTID_AND_TRIANGLEID_AND_FRONTFACING,
173
- // TODO: Once we get geometry packer V2 (virtual geometry) no need for these buffers actually (might want/need a barycentric buffer)
174
- EVBA_NORMALS,
175
- EVBA_UV_COORDINATES,
176
- EVBA_COUNT
177
- };
178
- nbl::core::smart_refctd_ptr<nbl::video::IGPUImageView> m_visibilityBufferAttachments[EVBA_COUNT];
179
-
180
- uint32_t m_maxSamples, m_samplesPerPixelPerDispatch, m_rayCountPerDispatch;
181
- uint32_t m_framesDone, m_samplesComputedPerPixel;
182
- nbl::core::smart_refctd_ptr<nbl::video::IGPUBufferView> m_sampleSequence;
183
- nbl::core::smart_refctd_ptr<nbl::video::IGPUImageView> m_scrambleTexture;
184
-
185
- nbl::core::smart_refctd_ptr<nbl::video::IGPUImageView> m_accumulation, m_tonemapOutput;
164
+ nbl::core::smart_refctd_ptr<nbl::video::IGPUImageView> m_accumulation,m_tonemapOutput;
186
165
nbl::video::IFrameBuffer* m_visibilityBuffer,* m_colorBuffer,* tmpTonemapBuffer;
187
166
188
- #ifdef _NBL_BUILD_OPTIX_
189
- nbl::core::smart_refctd_ptr<nbl::ext::OptiX::Manager> m_optixManager;
190
- CUstream m_cudaStream;
191
- nbl::core::smart_refctd_ptr<nbl::ext::OptiX::IContext> m_optixContext;
167
+ #ifdef _IRR_BUILD_OPTIX_
192
168
nbl::core::smart_refctd_ptr<nbl::ext::OptiX::IDenoiser> m_denoiser;
193
169
OptixDenoiserSizes m_denoiserMemReqs;
194
170
nbl::cuda::CCUDAHandler::GraphicsAPIObjLink<nbl::video::IGPUBuffer> m_denoiserInputBuffer,m_denoiserStateBuffer,m_denoisedBuffer,m_denoiserScratchBuffer;
0 commit comments