Renders the 2D "overhead" visualizer that shows per-cluster light/decal counts
| 2000 | |
| 2001 | // Renders the 2D "overhead" visualizer that shows per-cluster light/decal counts |
| 2002 | void BindlessDeferred::RenderClusterVisualizer() |
| 2003 | { |
| 2004 | if(AppSettings::ShowClusterVisualizer == false) |
| 2005 | return; |
| 2006 | |
| 2007 | ID3D12GraphicsCommandList* cmdList = DX12::CmdList; |
| 2008 | |
| 2009 | PIXMarker pixMarker(cmdList, "Cluster Visualizer"); |
| 2010 | |
| 2011 | Float2 displaySize = Float2(float(swapChain.Width()), float(swapChain.Height())); |
| 2012 | Float2 drawSize = displaySize * 0.375f; |
| 2013 | Float2 drawPos = displaySize * (0.5f + (0.5f - 0.375f) / 2.0f); |
| 2014 | |
| 2015 | D3D12_VIEWPORT viewport = { }; |
| 2016 | viewport.Width = drawSize.x; |
| 2017 | viewport.Height = drawSize.y; |
| 2018 | viewport.MinDepth = 0.0f; |
| 2019 | viewport.MaxDepth = 1.0f; |
| 2020 | viewport.TopLeftX = drawPos.x; |
| 2021 | viewport.TopLeftY = drawPos.y; |
| 2022 | |
| 2023 | D3D12_RECT scissorRect = { }; |
| 2024 | scissorRect.left = 0; |
| 2025 | scissorRect.top = 0; |
| 2026 | scissorRect.right = uint32(swapChain.Width()); |
| 2027 | scissorRect.bottom = uint32(swapChain.Height()); |
| 2028 | |
| 2029 | cmdList->RSSetViewports(1, &viewport); |
| 2030 | cmdList->RSSetScissorRects(1, &scissorRect); |
| 2031 | |
| 2032 | cmdList->SetGraphicsRootSignature(clusterVisRootSignature); |
| 2033 | cmdList->SetPipelineState(clusterVisPSO); |
| 2034 | |
| 2035 | Float4x4 invProjection = Float4x4::Invert(camera.ProjectionMatrix()); |
| 2036 | Float3 farTopRight = Float3::Transform(Float3(1.0f, 1.0f, 1.0f), invProjection); |
| 2037 | Float3 farBottomLeft = Float3::Transform(Float3(-1.0f, -1.0f, 1.0f), invProjection); |
| 2038 | |
| 2039 | clusterVisConstants.Data.Projection = camera.ProjectionMatrix(); |
| 2040 | clusterVisConstants.Data.ViewMin = Float3(farBottomLeft.x, farBottomLeft.y, camera.NearClip()); |
| 2041 | clusterVisConstants.Data.NearClip = camera.NearClip(); |
| 2042 | clusterVisConstants.Data.ViewMax = Float3(farTopRight.x, farTopRight.y, camera.FarClip()); |
| 2043 | clusterVisConstants.Data.InvClipRange = 1.0f / (camera.FarClip() - camera.NearClip()); |
| 2044 | clusterVisConstants.Data.DisplaySize = displaySize; |
| 2045 | clusterVisConstants.Data.NumXTiles = uint32(AppSettings::NumXTiles); |
| 2046 | clusterVisConstants.Data.NumXYTiles = uint32(AppSettings::NumXTiles * AppSettings::NumYTiles); |
| 2047 | clusterVisConstants.Upload(); |
| 2048 | clusterVisConstants.SetAsGfxRootParameter(cmdList, 0); |
| 2049 | |
| 2050 | AppSettings::BindCBufferGfx(cmdList, 1); |
| 2051 | |
| 2052 | D3D12_CPU_DESCRIPTOR_HANDLE srvs[] = { decalClusterBuffer.SRV(), spotLightClusterBuffer.SRV() }; |
| 2053 | DX12::BindShaderResources(cmdList, 2, ArraySize_(srvs), srvs); |
| 2054 | |
| 2055 | cmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); |
| 2056 | cmdList->IASetIndexBuffer(nullptr); |
| 2057 | cmdList->IASetVertexBuffers(0, 0, nullptr); |
| 2058 | |
| 2059 | cmdList->DrawInstanced(3, 1, 0, 0); |
nothing calls this directly
no test coverage detected