@@ -14,11 +14,7 @@ using namespace core;
14
14
const char * vertexSource = R"===(
15
15
#version 430 core
16
16
17
- #define NBL_GLSL_TRANSFORM_TREE_POOL_NODE_PARENT_DESCRIPTOR_DECLARED
18
- #define NBL_GLSL_TRANSFORM_TREE_POOL_NODE_RELATIVE_TRANSFORM_DESCRIPTOR_DECLARED
19
- #define NBL_GLSL_TRANSFORM_TREE_POOL_NODE_MODIFIED_TIMESTAMP_DESCRIPTOR_DECLARED
20
- #define NBL_GLSL_TRANSFORM_TREE_POOL_NODE_RECOMPUTED_TIMESTAMP_DESCRIPTOR_DECLARED
21
- #include "nbl/builtin/glsl/transform_tree/pool_descriptor_set.glsl"
17
+ #include "nbl/builtin/glsl/transform_tree/render_descriptor_set.glsl"
22
18
23
19
layout(location = 0) in vec3 vPos;
24
20
layout(location = 3) in vec3 vNormal;
@@ -274,7 +270,8 @@ class TransformationApp : public ApplicationBase
274
270
if (!ttm.get ())
275
271
return ;
276
272
277
- ttDS = tt->getNodePropertyDescriptorSet ();
273
+ debugDrawPipeline = ttm->createDebugPipeline <transform_tree_t >(renderpass);
274
+ ttRenderDS = tt->getRenderDescriptorSet ();
278
275
279
276
auto ppHandler = core::make_smart_refctd_ptr<video::CPropertyPoolHandler>(core::smart_refctd_ptr (device));
280
277
@@ -547,7 +544,7 @@ class TransformationApp : public ApplicationBase
547
544
}
548
545
549
546
asset::SPushConstantRange range[1 ] = { asset::IShader::ESS_VERTEX,0u ,sizeof (core::matrix4SIMD) };
550
- auto gfxLayout = core::make_smart_refctd_ptr<asset::ICPUPipelineLayout>(range,range+1u ,scene::ITransformTreeWithNormalMatrices::createDescriptorSetLayout ());
547
+ auto gfxLayout = core::make_smart_refctd_ptr<asset::ICPUPipelineLayout>(range,range+1u ,scene::ITransformTreeWithNormalMatrices::createRenderDescriptorSetLayout ());
551
548
pipeline->setLayout (core::smart_refctd_ptr (gfxLayout));
552
549
553
550
core::smart_refctd_ptr<video::IGPURenderpassIndependentPipeline> rpIndependentPipeline = CPU2GPU.getGPUObjectsFromAssets (&pipeline, &pipeline + 1 , cpu2gpuParams)->front ();
@@ -611,7 +608,15 @@ class TransformationApp : public ApplicationBase
611
608
ttmDescriptorSets = ttm->createAllDescriptorSets (device.get ());
612
609
ttm->updateUpdateLocalTransformsDescriptorSet (device.get (),ttmDescriptorSets.updateLocal .get (),{0ull ,modRangesBuf},{0ull ,relTformModsBuf});
613
610
ttm->updateRecomputeGlobalTransformsDescriptorSet (device.get (),ttmDescriptorSets.recomputeGlobal .get (),{0ull ,nodeIdsBuf});
614
- // ttm->updateDebugDrawDescriptorSet(device.get(),ttmDescriptorSets.debugDraw.get(),{}); // TODO
611
+ core::vector<CompressedAABB> aabbs;
612
+ for (auto obj : solarSystemObjectsData)
613
+ {
614
+ auto aabb = cpuMeshPlanets->getBoundingBox ();
615
+ aabb.MinEdge *= obj.scale ;
616
+ aabb.MaxEdge *= obj.scale ;
617
+ aabbs.emplace_back () = aabb;
618
+ }
619
+ ttm->updateDebugDrawDescriptorSet (device.get (),ttmDescriptorSets.debugDraw .get (),{0ull ,utils->createFilledDeviceLocalGPUBufferOnDedMem (device->getQueue (0 ,0 ),sizeof (core::CompressedAABB)*aabbs.size (),aabbs.data ())});
615
620
}
616
621
617
622
void onAppTerminated_impl () override
@@ -819,9 +824,17 @@ class TransformationApp : public ApplicationBase
819
824
820
825
cb->bindGraphicsPipeline (gpuObject.graphicsPipeline .get ());
821
826
cb->pushConstants (gpuObject.graphicsPipeline ->getRenderpassIndependentPipeline ()->getLayout (), asset::IShader::ESS_VERTEX, 0u , sizeof (core::matrix4SIMD), viewProj.pointer ());
822
- cb->bindDescriptorSets (asset::EPBP_GRAPHICS, gpuObject.graphicsPipeline ->getRenderpassIndependentPipeline ()->getLayout (), 0u , 1u , &ttDS );
827
+ cb->bindDescriptorSets (asset::EPBP_GRAPHICS, gpuObject.graphicsPipeline ->getRenderpassIndependentPipeline ()->getLayout (), 0u , 1u , &ttRenderDS );
823
828
cb->drawMeshBuffer (gpuObject.gpuMesh .get ());
824
829
}
830
+ {
831
+ asset::SBufferBinding<video::IGPUBuffer> nodeAndAABBList = {sizeof (uint32_t ),nodeIdsBuf};
832
+ scene::ITransformTreeManager::DebugPushConstants pushConstants;
833
+ pushConstants.viewProjectionMatrix = viewProj;
834
+ pushConstants.lineColor = core::vectorSIMDf (1 .f ,0 .f ,0 .f ,1 .f );
835
+ pushConstants.aabbColor = core::vectorSIMDf (0 .f ,1 .f ,0 .f ,1 .f );
836
+ ttm->debugDraw (cb.get (),debugDrawPipeline.get (),tt.get (),ttmDescriptorSets.debugDraw .get (),nodeAndAABBList,nodeAndAABBList,pushConstants,ObjectCount);
837
+ }
825
838
}
826
839
// TODO: debug draw
827
840
cb->endRenderPass ();
@@ -830,8 +843,8 @@ class TransformationApp : public ApplicationBase
830
843
// acquires and presents
831
844
uint32_t imgnum = 0u ;
832
845
swapchain->acquireNextImage (MAX_TIMEOUT, imageAcquire[resourceIx].get (), nullptr , &imgnum);
833
- CommonAPI::Submit (device.get (), swapchain.get (), cb.get (), queues[decltype (initOutput) ::EQT_GRAPHICS], imageAcquire[resourceIx].get (), renderFinished[resourceIx].get (), fence.get ());
834
- CommonAPI::Present (device.get (), swapchain.get (), queues[decltype (initOutput) ::EQT_GRAPHICS], renderFinished[resourceIx].get (), imgnum);
846
+ CommonAPI::Submit (device.get (), swapchain.get (), cb.get (), queues[CommonAPI::InitOutput ::EQT_GRAPHICS], imageAcquire[resourceIx].get (), renderFinished[resourceIx].get (), fence.get ());
847
+ CommonAPI::Present (device.get (), swapchain.get (), queues[CommonAPI::InitOutput ::EQT_GRAPHICS], renderFinished[resourceIx].get (), imgnum);
835
848
}
836
849
837
850
bool keepRunning () override
@@ -865,8 +878,9 @@ class TransformationApp : public ApplicationBase
865
878
core::smart_refctd_ptr<video::IGPUBuffer> modRangesBuf;
866
879
core::smart_refctd_ptr<video::IGPUBuffer> relTformModsBuf;
867
880
core::smart_refctd_ptr<video::IGPUBuffer> nodeIdsBuf;
868
- const video::IGPUDescriptorSet* ttDS ;
881
+ const video::IGPUDescriptorSet* ttRenderDS ;
869
882
scene::ITransformTreeManager::DescriptorSets ttmDescriptorSets;
883
+ core::smart_refctd_ptr<video::IGPUGraphicsPipeline> debugDrawPipeline;
870
884
871
885
core::smart_refctd_ptr<nbl::video::IGPUCommandBuffer> cmdbuf[FRAMES_IN_FLIGHT];
872
886
core::smart_refctd_ptr<video::IGPUFence> frameComplete[FRAMES_IN_FLIGHT] = { nullptr };
0 commit comments