Optimize some code by manual inlining
This commit is contained in:
@@ -54,16 +54,6 @@ public:
|
|||||||
return _loadedLODs;
|
return _loadedLODs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determines whether the specified index is a valid LOD index.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="index">The index.</param>
|
|
||||||
/// <returns>True if the specified index is a valid LOD index, otherwise false.</returns>
|
|
||||||
FORCE_INLINE bool IsValidLODIndex(int32 index) const
|
|
||||||
{
|
|
||||||
return Math::IsInRange(index, 0, LODs.Count() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clamps the index of the LOD to be valid for rendering (only loaded LODs).
|
/// Clamps the index of the LOD to be valid for rendering (only loaded LODs).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -79,7 +69,7 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
FORCE_INLINE int32 HighestResidentLODIndex() const
|
FORCE_INLINE int32 HighestResidentLODIndex() const
|
||||||
{
|
{
|
||||||
return GetLODsCount() - _loadedLODs;
|
return LODs.Count() - _loadedLODs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -55,16 +55,6 @@ public:
|
|||||||
return _loadedLODs;
|
return _loadedLODs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determines whether the specified index is a valid LOD index.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="index">The index.</param>
|
|
||||||
/// <returns>True if the specified index is a valid LOD index, otherwise false.</returns>
|
|
||||||
FORCE_INLINE bool IsValidLODIndex(int32 index) const
|
|
||||||
{
|
|
||||||
return Math::IsInRange(index, 0, LODs.Count() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clamps the index of the LOD to be valid for rendering (only loaded LODs).
|
/// Clamps the index of the LOD to be valid for rendering (only loaded LODs).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -80,7 +70,7 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
FORCE_INLINE int32 HighestResidentLODIndex() const
|
FORCE_INLINE int32 HighestResidentLODIndex() const
|
||||||
{
|
{
|
||||||
return GetLODsCount() - _loadedLODs;
|
return LODs.Count() - _loadedLODs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -188,23 +188,6 @@ void RenderView::CopyFrom(Camera* camera, Viewport* viewport)
|
|||||||
RenderLayersMask = camera->RenderLayersMask;
|
RenderLayersMask = camera->RenderLayersMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawPass RenderView::GetShadowsDrawPassMask(ShadowsCastingMode shadowsMode) const
|
|
||||||
{
|
|
||||||
switch (shadowsMode)
|
|
||||||
{
|
|
||||||
case ShadowsCastingMode::All:
|
|
||||||
return DrawPass::All;
|
|
||||||
case ShadowsCastingMode::DynamicOnly:
|
|
||||||
return IsOfflinePass ? ~DrawPass::Depth : DrawPass::All;
|
|
||||||
case ShadowsCastingMode::StaticOnly:
|
|
||||||
return IsOfflinePass ? DrawPass::All : ~DrawPass::Depth;
|
|
||||||
case ShadowsCastingMode::None:
|
|
||||||
return ~DrawPass::Depth;
|
|
||||||
default:
|
|
||||||
return DrawPass::All;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderView::GetWorldMatrix(const Transform& transform, Matrix& world) const
|
void RenderView::GetWorldMatrix(const Transform& transform, Matrix& world) const
|
||||||
{
|
{
|
||||||
const Float3 translation = transform.Translation - Origin;
|
const Float3 translation = transform.Translation - Origin;
|
||||||
|
|||||||
@@ -296,7 +296,22 @@ public:
|
|||||||
void CopyFrom(Camera* camera, Viewport* viewport = nullptr);
|
void CopyFrom(Camera* camera, Viewport* viewport = nullptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DrawPass GetShadowsDrawPassMask(ShadowsCastingMode shadowsMode) const;
|
FORCE_INLINE DrawPass GetShadowsDrawPassMask(ShadowsCastingMode shadowsMode) const
|
||||||
|
{
|
||||||
|
switch (shadowsMode)
|
||||||
|
{
|
||||||
|
case ShadowsCastingMode::All:
|
||||||
|
return DrawPass::All;
|
||||||
|
case ShadowsCastingMode::DynamicOnly:
|
||||||
|
return IsOfflinePass ? ~DrawPass::Depth : DrawPass::All;
|
||||||
|
case ShadowsCastingMode::StaticOnly:
|
||||||
|
return IsOfflinePass ? DrawPass::All : ~DrawPass::Depth;
|
||||||
|
case ShadowsCastingMode::None:
|
||||||
|
return ~DrawPass::Depth;
|
||||||
|
default:
|
||||||
|
return DrawPass::All;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Camera's View * Projection matrix
|
// Camera's View * Projection matrix
|
||||||
|
|||||||
@@ -41,12 +41,26 @@ void SceneRendering::Draw(RenderContext& renderContext)
|
|||||||
{
|
{
|
||||||
for (int32 i = 0; i < Actors.Count(); i++)
|
for (int32 i = 0; i < Actors.Count(); i++)
|
||||||
{
|
{
|
||||||
auto e = Actors[i];
|
auto e = Actors.Get()[i];
|
||||||
e.Bounds.Center -= origin;
|
e.Bounds.Center -= origin;
|
||||||
if (view.RenderLayersMask.Mask & e.LayerMask && (e.NoCulling || frustum.Intersects(e.Bounds)) && e.Actor->GetStaticFlags() & view.StaticFlagsMask)
|
if (view.RenderLayersMask.Mask & e.LayerMask && (e.NoCulling || frustum.Intersects(e.Bounds)) && e.Actor->GetStaticFlags() & view.StaticFlagsMask)
|
||||||
{
|
{
|
||||||
#if SCENE_RENDERING_USE_PROFILER
|
#if SCENE_RENDERING_USE_PROFILER
|
||||||
PROFILE_CPU_ACTOR(e.Actor);
|
PROFILE_CPU_ACTOR(e.Actor);
|
||||||
|
#endif
|
||||||
|
e.Actor->Draw(renderContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (origin.IsZero())
|
||||||
|
{
|
||||||
|
for (int32 i = 0; i < Actors.Count(); i++)
|
||||||
|
{
|
||||||
|
auto e = Actors.Get()[i];
|
||||||
|
if (view.RenderLayersMask.Mask & e.LayerMask && (e.NoCulling || frustum.Intersects(e.Bounds)))
|
||||||
|
{
|
||||||
|
#if SCENE_RENDERING_USE_PROFILER
|
||||||
|
PROFILE_CPU_ACTOR(e.Actor);
|
||||||
#endif
|
#endif
|
||||||
e.Actor->Draw(renderContext);
|
e.Actor->Draw(renderContext);
|
||||||
}
|
}
|
||||||
@@ -56,7 +70,7 @@ void SceneRendering::Draw(RenderContext& renderContext)
|
|||||||
{
|
{
|
||||||
for (int32 i = 0; i < Actors.Count(); i++)
|
for (int32 i = 0; i < Actors.Count(); i++)
|
||||||
{
|
{
|
||||||
auto e = Actors[i];
|
auto e = Actors.Get()[i];
|
||||||
e.Bounds.Center -= origin;
|
e.Bounds.Center -= origin;
|
||||||
if (view.RenderLayersMask.Mask & e.LayerMask && (e.NoCulling || frustum.Intersects(e.Bounds)))
|
if (view.RenderLayersMask.Mask & e.LayerMask && (e.NoCulling || frustum.Intersects(e.Bounds)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -104,22 +104,20 @@ int32 ModelsStreamingHandler::CalculateResidency(StreamableResource* resource, f
|
|||||||
if (quality < ZeroTolerance)
|
if (quality < ZeroTolerance)
|
||||||
return 0;
|
return 0;
|
||||||
ASSERT(resource);
|
ASSERT(resource);
|
||||||
auto& model = *(Model*)resource;
|
const auto& model = *(Model*)resource;
|
||||||
|
|
||||||
const int32 lodCount = model.GetLODsCount();
|
const int32 lodCount = model.GetLODsCount();
|
||||||
int32 lods = Math::CeilToInt(quality * (float)lodCount);
|
const int32 lods = Math::CeilToInt(quality * (float)lodCount);
|
||||||
ASSERT(model.IsValidLODIndex(lods - 1));
|
|
||||||
return lods;
|
return lods;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 ModelsStreamingHandler::CalculateRequestedResidency(StreamableResource* resource, int32 targetResidency)
|
int32 ModelsStreamingHandler::CalculateRequestedResidency(StreamableResource* resource, int32 targetResidency)
|
||||||
{
|
{
|
||||||
ASSERT(resource);
|
ASSERT(resource);
|
||||||
auto& model = *(Model*)resource;
|
const auto& model = *(Model*)resource;
|
||||||
|
|
||||||
// Always load only single LOD at once
|
// Always load only single LOD at once
|
||||||
int32 residency = targetResidency;
|
int32 residency = targetResidency;
|
||||||
int32 currentResidency = model.GetCurrentResidency();
|
const int32 currentResidency = model.GetCurrentResidency();
|
||||||
if (currentResidency < targetResidency)
|
if (currentResidency < targetResidency)
|
||||||
{
|
{
|
||||||
// Up
|
// Up
|
||||||
@@ -145,22 +143,20 @@ int32 SkinnedModelsStreamingHandler::CalculateResidency(StreamableResource* reso
|
|||||||
if (quality < ZeroTolerance)
|
if (quality < ZeroTolerance)
|
||||||
return 0;
|
return 0;
|
||||||
ASSERT(resource);
|
ASSERT(resource);
|
||||||
auto& model = *(SkinnedModel*)resource;
|
const auto& model = *(SkinnedModel*)resource;
|
||||||
|
|
||||||
const int32 lodCount = model.GetLODsCount();
|
const int32 lodCount = model.GetLODsCount();
|
||||||
int32 lods = Math::CeilToInt(quality * (float)lodCount);
|
const int32 lods = Math::CeilToInt(quality * (float)lodCount);
|
||||||
ASSERT(model.IsValidLODIndex(lods - 1));
|
|
||||||
return lods;
|
return lods;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 SkinnedModelsStreamingHandler::CalculateRequestedResidency(StreamableResource* resource, int32 targetResidency)
|
int32 SkinnedModelsStreamingHandler::CalculateRequestedResidency(StreamableResource* resource, int32 targetResidency)
|
||||||
{
|
{
|
||||||
ASSERT(resource);
|
ASSERT(resource);
|
||||||
auto& model = *(SkinnedModel*)resource;
|
const auto& model = *(SkinnedModel*)resource;
|
||||||
|
|
||||||
// Always load only single LOD at once
|
// Always load only single LOD at once
|
||||||
int32 residency = targetResidency;
|
int32 residency = targetResidency;
|
||||||
int32 currentResidency = model.GetCurrentResidency();
|
const int32 currentResidency = model.GetCurrentResidency();
|
||||||
if (currentResidency < targetResidency)
|
if (currentResidency < targetResidency)
|
||||||
{
|
{
|
||||||
// Up
|
// Up
|
||||||
|
|||||||
Reference in New Issue
Block a user