@@ -79,7 +79,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
7979 };
8080
8181 //
82- static inline core::smart_refctd_ptr<CSimpleDebugRenderer> create (asset::IAssetManager* assMan, video::IGPURenderpass* renderpass, const uint32_t subpassIX, const CGeometryCreatorScene* scene )
82+ static inline core::smart_refctd_ptr<CSimpleDebugRenderer> create (asset::IAssetManager* assMan, video::IGPURenderpass* renderpass, const uint32_t subpassIX, const std::span< const video::IGPUPolygonGeometry* const > geometries )
8383 {
8484 EXPOSE_NABLA_NAMESPACES;
8585
@@ -88,10 +88,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
8888 auto device = const_cast <ILogicalDevice*>(renderpass->getOriginDevice ());
8989 auto logger = device->getLogger ();
9090
91- if (!assMan || !scene)
92- return nullptr ;
93- const auto namedGeoms = scene->getGeometries ();
94- if (namedGeoms.empty ())
91+ if (!assMan || geometries.empty ())
9592 return nullptr ;
9693
9794 // load shader
@@ -154,33 +151,26 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
154151 init.layout = device->createPipelineLayout (ranges,smart_refctd_ptr<const IGPUDescriptorSetLayout>(init.ds ->getLayout ()));
155152
156153 // create pipelines
157- enum PipelineType : uint8_t
158- {
159- BasicTriangleList,
160- BasicTriangleFan,
161- Cone,
162- Count
163- };
164- smart_refctd_ptr<IGPUGraphicsPipeline> pipelines[PipelineType::Count] = {};
154+ using pipeline_e = SInitParams::PipelineType;
165155 {
166- IGPUGraphicsPipeline::SCreationParams params[PipelineType ::Count] = {};
167- params[PipelineType ::BasicTriangleList].vertexShader = {.shader =shader.get (),.entryPoint =" BasicVS" };
168- params[PipelineType ::BasicTriangleList].fragmentShader = {.shader =shader.get (),.entryPoint =" BasicFS" };
169- params[PipelineType ::BasicTriangleFan].vertexShader = {.shader =shader.get (),.entryPoint =" BasicVS" };
170- params[PipelineType ::BasicTriangleFan].fragmentShader = {.shader =shader.get (),.entryPoint =" BasicFS" };
171- params[PipelineType ::Cone].vertexShader = {.shader =shader.get (),.entryPoint =" ConeVS" };
172- params[PipelineType ::Cone].fragmentShader = {.shader =shader.get (),.entryPoint =" ConeFS" };
173- for (auto i=0 ; i< PipelineType ::Count; i++)
156+ IGPUGraphicsPipeline::SCreationParams params[pipeline_e ::Count] = {};
157+ params[pipeline_e ::BasicTriangleList].vertexShader = {.shader =shader.get (),.entryPoint =" BasicVS" };
158+ params[pipeline_e ::BasicTriangleList].fragmentShader = {.shader =shader.get (),.entryPoint =" BasicFS" };
159+ params[pipeline_e ::BasicTriangleFan].vertexShader = {.shader =shader.get (),.entryPoint =" BasicVS" };
160+ params[pipeline_e ::BasicTriangleFan].fragmentShader = {.shader =shader.get (),.entryPoint =" BasicFS" };
161+ params[pipeline_e ::Cone].vertexShader = {.shader =shader.get (),.entryPoint =" ConeVS" };
162+ params[pipeline_e ::Cone].fragmentShader = {.shader =shader.get (),.entryPoint =" ConeFS" };
163+ for (auto i=0 ; i<pipeline_e ::Count; i++)
174164 {
175165 params[i].layout = init.layout .get ();
176166 // no vertex input
177167 auto & primitiveAssembly = params[i].cached .primitiveAssembly ;
178168 auto & rasterization = params[i].cached .rasterization ;
179169 auto & blend = params[i].cached .blend ;
180- const auto type = static_cast <PipelineType >(i);
170+ const auto type = static_cast <pipeline_e >(i);
181171 switch (type)
182172 {
183- case PipelineType ::BasicTriangleFan:
173+ case pipeline_e ::BasicTriangleFan:
184174 primitiveAssembly.primitiveType = E_PRIMITIVE_TOPOLOGY::EPT_TRIANGLE_FAN;
185175 break ;
186176 default :
@@ -193,7 +183,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
193183 params[i].cached .subpassIx = subpassIX;
194184 params[i].renderpass = renderpass;
195185 }
196- if (!device->createGraphicsPipelines (nullptr ,params,pipelines))
186+ if (!device->createGraphicsPipelines (nullptr ,params,init. pipelines ))
197187 {
198188 logger->log (" Could not create Graphics Pipelines!" ,ILogger::ELL_ERROR);
199189 return nullptr ;
@@ -212,25 +202,21 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
212202 return retval;
213203 };
214204
215- for (const auto & entry : namedGeoms )
205+ for (const auto geom : geometries )
216206 {
217- const auto * geom = entry.geom .get ();
218207 // could also check device origin on all buffers
219208 if (!geom->valid ())
220209 continue ;
221210 auto & out = init.geoms .emplace_back ();
222211 switch (geom->getIndexingCallback ()->knownTopology ())
223212 {
224213 case E_PRIMITIVE_TOPOLOGY::EPT_TRIANGLE_FAN:
225- out.pipeline = pipelines[PipelineType ::BasicTriangleFan];
214+ out.pipeline = init. pipelines [pipeline_e ::BasicTriangleFan];
226215 break ;
227216 default :
228- out.pipeline = pipelines[PipelineType ::BasicTriangleList];
217+ out.pipeline = init. pipelines [pipeline_e ::BasicTriangleList];
229218 break ;
230219 }
231- // special case
232- if (entry.name ==" Cone" )
233- out.pipeline = pipelines[PipelineType::Cone];
234220 if (const auto & view=geom->getIndexView (); view)
235221 {
236222 out.indexBuffer .offset = view.src .offset ;
@@ -275,12 +261,25 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
275261 //
276262 struct SInitParams
277263 {
264+ enum PipelineType : uint8_t
265+ {
266+ BasicTriangleList,
267+ BasicTriangleFan,
268+ Cone, // special case
269+ Count
270+ };
271+
278272 core::smart_refctd_ptr<video::IGPUDescriptorSet> ds;
279273 core::smart_refctd_ptr<video::IGPUPipelineLayout> layout;
274+ core::smart_refctd_ptr<video::IGPUGraphicsPipeline> pipelines[PipelineType::Count];
280275 core::vector<SPackedGeometry> geoms;
281276 };
282277 inline const SInitParams& getInitParams () const {return m_params;}
283278
279+ //
280+ inline auto & getGeometry (const uint32_t ix) {return m_params.geoms [ix];}
281+ inline const auto & getGeometry (const uint32_t ix) const {return m_params.geoms [ix];}
282+
284283 //
285284 inline void render (video::IGPUCommandBuffer* cmdbuf, const SViewParams& viewParams) const
286285 {
0 commit comments