@@ -2449,6 +2449,86 @@ namespace Lux {
24492449 addPass (" DOF" , compositeOutputs, addRenderPassResources (" DOF" , m_DOFPass));
24502450 }
24512451
2452+ SceneRenderer::RenderGraphDebugSnapshot SceneRenderer::GetRenderGraphDebugSnapshot ()
2453+ {
2454+ BuildRenderGraph ();
2455+
2456+ RenderGraphDebugSnapshot snapshot;
2457+ const auto lifetimes = m_RenderGraph.BuildAliasPlan ();
2458+ const auto & textures = m_RenderGraph.GetTextures ();
2459+ const auto & passes = m_RenderGraph.GetPasses ();
2460+
2461+ snapshot.Textures .reserve (textures.size ());
2462+ for (uint32_t resource = 0 ; resource < textures.size (); resource++)
2463+ {
2464+ const RenderGraph::TextureDesc& texture = textures[resource];
2465+ RenderGraphTextureDebugInfo& textureInfo = snapshot.Textures .emplace_back ();
2466+ textureInfo.Resource = resource;
2467+ textureInfo.Name = texture.Name ;
2468+ textureInfo.Format = texture.Format ;
2469+ textureInfo.Usage = texture.Usage ;
2470+ textureInfo.Dimension = texture.Dimension ;
2471+ textureInfo.Width = texture.Width ;
2472+ textureInfo.Height = texture.Height ;
2473+ textureInfo.Mips = texture.Mips ;
2474+ textureInfo.Layers = texture.Layers ;
2475+ textureInfo.EstimatedBytes = Utils::GetImageMemorySize (texture.Format , texture.Width , texture.Height , texture.Mips , texture.Layers );
2476+ textureInfo.Transient = texture.Transient ;
2477+ textureInfo.AllowAlias = texture.AllowAlias ;
2478+
2479+ if (resource < lifetimes.size ())
2480+ {
2481+ const RenderGraph::ResourceLifetime& lifetime = lifetimes[resource];
2482+ textureInfo.FirstPass = lifetime.FirstPass ;
2483+ textureInfo.LastPass = lifetime.LastPass ;
2484+ textureInfo.AliasGroup = lifetime.AliasIndex ;
2485+ }
2486+
2487+ if (texture.Image )
2488+ {
2489+ textureInfo.AliasedNow = texture.Image ->IsTransientAlias ();
2490+ textureInfo.CurrentState = texture.Image ->GetImageInfo ().State ;
2491+ }
2492+ }
2493+
2494+ auto containsResource = [](const std::vector<RenderGraph::ResourceHandle>& resources, RenderGraph::ResourceHandle resource)
2495+ {
2496+ return std::find (resources.begin (), resources.end (), resource) != resources.end ();
2497+ };
2498+
2499+ auto accessState = [&](const RenderGraph::PassDesc& pass, RenderGraph::ResourceHandle resource, bool asInput)
2500+ {
2501+ const bool read = containsResource (pass.Reads , resource);
2502+ const bool write = containsResource (pass.Writes , resource);
2503+ if (read && write)
2504+ return std::string (" ReadWrite" );
2505+ return std::string (asInput ? " Read" : " Write" );
2506+ };
2507+
2508+ snapshot.Passes .reserve (passes.size ());
2509+ for (const RenderGraph::PassDesc& pass : passes)
2510+ {
2511+ RenderGraphPassDebugInfo& passInfo = snapshot.Passes .emplace_back ();
2512+ passInfo.Name = pass.Name ;
2513+
2514+ for (RenderGraph::ResourceHandle resource : pass.Reads )
2515+ {
2516+ if (resource >= textures.size ())
2517+ continue ;
2518+ passInfo.Inputs .push_back ({ resource, accessState (pass, resource, true ) });
2519+ }
2520+
2521+ for (RenderGraph::ResourceHandle resource : pass.Writes )
2522+ {
2523+ if (resource >= textures.size ())
2524+ continue ;
2525+ passInfo.Outputs .push_back ({ resource, accessState (pass, resource, false ) });
2526+ }
2527+ }
2528+
2529+ return snapshot;
2530+ }
2531+
24522532 void SceneRenderer::UpdateRenderGraphStatistics ()
24532533 {
24542534 auto & memoryStats = m_Statistics.MemoryStats ;
@@ -4085,6 +4165,17 @@ namespace Lux {
40854165
40864166 BeginProfiledGPU (" LightCullingPass" );
40874167 Renderer::LightCulling (m_CommandBuffer, m_LightCullingPass, nullptr , { m_LightTilesCountX, m_LightTilesCountY, 1 });
4168+
4169+ Ref<RenderCommandBuffer> commandBuffer = m_CommandBuffer;
4170+ Ref<StorageBufferSet> visiblePointLightIndices = m_SBSVisiblePointLightIndices;
4171+ Ref<StorageBufferSet> visibleSpotLightIndices = m_SBSVisibleSpotLightIndices;
4172+ Renderer::Submit ([commandBuffer, visiblePointLightIndices, visibleSpotLightIndices]() mutable
4173+ {
4174+ nvrhi::CommandListHandle commandList = commandBuffer->GetActive ();
4175+ commandList->setBufferState (visiblePointLightIndices->RT_Get ()->GetHandle (), nvrhi::ResourceStates::ShaderResource);
4176+ commandList->setBufferState (visibleSpotLightIndices->RT_Get ()->GetHandle (), nvrhi::ResourceStates::ShaderResource);
4177+ });
4178+
40884179 EndProfiledGPU ();
40894180 }
40904181
0 commit comments