Changed to a fixed-size occlusion buffer
This commit is contained in:
@@ -217,7 +217,7 @@ namespace AZ
|
||||
void SetOcclusionCullingPlanes(const AZStd::vector<AZ::Transform>& occlusionCullingPlanes) { m_occlusionCullingPlanes = occlusionCullingPlanes; }
|
||||
|
||||
//! Notifies the CullingScene that culling will begin for this frame.
|
||||
void BeginCulling(const AZStd::vector<ViewPtr>& views, const AZStd::vector<RenderPipelinePtr>& activePipelines);
|
||||
void BeginCulling(const AZStd::vector<ViewPtr>& views);
|
||||
|
||||
//! Notifies the CullingScene that the culling is done for this frame.
|
||||
void EndCulling();
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace AZ
|
||||
void ConnectWorldToClipMatrixChangedHandler(MatrixChangedEvent::Handler& handler);
|
||||
|
||||
//! Prepare for view culling
|
||||
void BeginCulling(const AZStd::vector<RenderPipelinePtr>& activePipelines);
|
||||
void BeginCulling();
|
||||
|
||||
//! Returns the masked occlusion culling interface
|
||||
MaskedOcclusionCulling* GetMaskedOcclusionCulling();
|
||||
|
||||
@@ -643,7 +643,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void CullingScene::BeginCulling(const AZStd::vector<ViewPtr>& views, const AZStd::vector<RenderPipelinePtr>& activePipelines)
|
||||
void CullingScene::BeginCulling(const AZStd::vector<ViewPtr>& views)
|
||||
{
|
||||
m_cullDataConcurrencyCheck.soft_lock();
|
||||
|
||||
@@ -652,7 +652,7 @@ namespace AZ
|
||||
|
||||
for (auto& view : views)
|
||||
{
|
||||
view->BeginCulling(activePipelines);
|
||||
view->BeginCulling();
|
||||
}
|
||||
|
||||
AuxGeomDrawPtr auxGeom;
|
||||
|
||||
@@ -500,7 +500,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
// Launch CullingSystem::ProcessCullables() jobs (will run concurrently with FeatureProcessor::Render() jobs)
|
||||
m_cullingScene->BeginCulling(m_renderPacket.m_views, activePipelines);
|
||||
m_cullingScene->BeginCulling(m_renderPacket.m_views);
|
||||
for (ViewPtr& viewPtr : m_renderPacket.m_views)
|
||||
{
|
||||
AZ::Job* processCullablesJob = AZ::CreateJobFunction([this, &viewPtr](AZ::Job& thisJob)
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
m_maskedOcclusionCulling = MaskedOcclusionCulling::Create();
|
||||
m_maskedOcclusionCulling->SetNearClipPlane(0.1f);
|
||||
m_maskedOcclusionCulling->SetResolution(1920, 1080);
|
||||
}
|
||||
|
||||
View::~View()
|
||||
@@ -388,56 +388,14 @@ namespace AZ
|
||||
m_needBuildSrg = false;
|
||||
}
|
||||
|
||||
void View::BeginCulling(const AZStd::vector<RenderPipelinePtr>& activePipelines)
|
||||
void View::BeginCulling()
|
||||
{
|
||||
// retrieve current resolution
|
||||
Vector2 resolution(0.0f, 0.0f);
|
||||
for (auto& pipeline : activePipelines)
|
||||
{
|
||||
ViewPtr pipelineView = pipeline->GetDefaultView();
|
||||
if (pipelineView.get() == this)
|
||||
{
|
||||
RPI::SwapChainPass* pass = AZ::RPI::PassSystemInterface::Get()->FindSwapChainPass(pipeline->GetWindowHandle());
|
||||
if (pass)
|
||||
{
|
||||
const RHI::Viewport& viewport = pass->GetViewport();
|
||||
resolution.SetX(viewport.m_maxX);
|
||||
resolution.SetY(viewport.m_maxY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// calculate culling resolution based on required tile size for MaskedOcclusionCulling
|
||||
static const uint32_t MaskedOcclusionCullingSubTileWidth = 8;
|
||||
static const uint32_t MaskedOcclusionCullingSubTileHeight = 4;
|
||||
|
||||
uint32_t cullingWidth = RHI::AlignUp(resolution.GetX(), MaskedOcclusionCullingSubTileWidth);
|
||||
uint32_t cullingHeight = RHI::AlignUp(resolution.GetY(), MaskedOcclusionCullingSubTileHeight);
|
||||
|
||||
m_maskedOcclusionCulling->SetResolution(cullingWidth, cullingHeight);
|
||||
|
||||
if (cullingWidth > 0 && cullingHeight > 0)
|
||||
{
|
||||
m_maskedOcclusionCulling->ClearBuffer();
|
||||
}
|
||||
m_maskedOcclusionCulling->ClearBuffer();
|
||||
}
|
||||
|
||||
MaskedOcclusionCulling* View::GetMaskedOcclusionCulling()
|
||||
{
|
||||
if (m_maskedOcclusionCulling)
|
||||
{
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
|
||||
m_maskedOcclusionCulling->GetResolution(width, height);
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
return m_maskedOcclusionCulling;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return m_maskedOcclusionCulling;
|
||||
}
|
||||
|
||||
} // namespace RPI
|
||||
|
||||
Reference in New Issue
Block a user