Skip to content

Commit

Permalink
Fix cluster system adapting after viewport size
Browse files Browse the repository at this point in the history
  • Loading branch information
Duttenheim committed Nov 11, 2024
1 parent 6edd937 commit b0f8f9b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions code/render/clustering/clustercontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ClusterContext::~ClusterContext()
//------------------------------------------------------------------------------
/**
*/
void
void
ClusterContext::Create(float ZNear, float ZFar, const CoreGraphics::WindowId window)
{
#ifndef PUBLIC_BUILD
Expand Down Expand Up @@ -115,6 +115,11 @@ ClusterContext::Create(float ZNear, float ZFar, const CoreGraphics::WindowId win
{
CmdSetShaderProgram(cmdBuf, state.clusterGenerateProgram);

state.xResolution = viewport.width();
state.yResolution = viewport.height();
state.invXResolution = 1.0f / state.xResolution;
state.invYResolution = 1.0f / state.yResolution;

// Run the job as series of 1024 clusters at a time
CmdDispatch(cmdBuf, Math::ceil((state.clusterDimensions[0] * state.clusterDimensions[1] * state.clusterDimensions[2]) / 64.0f), 1, 1);
}, {
Expand All @@ -125,7 +130,7 @@ ClusterContext::Create(float ZNear, float ZFar, const CoreGraphics::WindowId win
//------------------------------------------------------------------------------
/**
*/
const SizeT
const SizeT
ClusterContext::GetNumClusters()
{
return state.clusterDimensions[0] * state.clusterDimensions[1] * state.clusterDimensions[2];
Expand All @@ -134,7 +139,7 @@ ClusterContext::GetNumClusters()
//------------------------------------------------------------------------------
/**
*/
const std::array<SizeT, 3>
const std::array<SizeT, 3>
ClusterContext::GetClusterDimensions()
{
return std::array<SizeT, 3> { state.clusterDimensions[0], state.clusterDimensions[1], state.clusterDimensions[2] };
Expand All @@ -143,7 +148,7 @@ ClusterContext::GetClusterDimensions()
//------------------------------------------------------------------------------
/**
*/
void
void
ClusterContext::UpdateResources(const Graphics::FrameContext& ctx)
{
using namespace CoreGraphics;
Expand All @@ -169,7 +174,7 @@ ClusterContext::UpdateResources(const Graphics::FrameContext& ctx)
//------------------------------------------------------------------------------
/**
*/
void
void
ClusterContext::OnRenderDebug(uint32_t flags)
{
}
Expand Down

0 comments on commit b0f8f9b

Please sign in to comment.