Various changes

This commit is contained in:
Wojtek Figat
2021-07-01 21:01:23 +02:00
parent d7332509f7
commit 2deac50c53
7 changed files with 180 additions and 394 deletions

View File

@@ -425,225 +425,6 @@ public:
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const bool value)
{
SetType(CommonType::Bool);
AsBool = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const int32 value)
{
SetType(CommonType::Integer);
AsInteger = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const float value)
{
SetType(CommonType::Float);
AsFloat = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Vector2& value)
{
SetType(CommonType::Vector2);
AsVector2 = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Vector3& value)
{
SetType(CommonType::Vector3);
AsVector3 = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Vector4& value)
{
SetType(CommonType::Vector4);
AsVector4 = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Color& value)
{
SetType(CommonType::Color);
AsColor = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Matrix& value)
{
SetType(CommonType::Matrix);
AsMatrix = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Guid& value)
{
SetType(CommonType::Guid);
AsGuid = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const String& value)
{
Set(value);
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const StringView& value)
{
Set(value);
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const BoundingBox& value)
{
SetType(CommonType::Box);
AsBox = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Quaternion& value)
{
SetType(CommonType::Rotation);
AsRotation = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Transform& value)
{
SetType(CommonType::Transform);
AsTransform = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const BoundingSphere& value)
{
SetType(CommonType::Sphere);
AsSphere = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Rectangle& value)
{
SetType(CommonType::Rectangle);
AsRectangle = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Ray& value)
{
SetType(CommonType::Ray);
AsRay = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(const Char* value)
{
Set(StringView(value));
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(void* value)
{
SetType(CommonType::Pointer);
AsPointer = value;
return *this;
}
/// <summary>
/// Assignment operator
/// </summary>
/// <param name="value">Value</param>
CommonValue& operator=(ScriptingObject* value)
{
SetType(CommonType::Object);
AsObject = value;
if (value)
LinkObject();
return *this;
}
public:
/// <summary>

View File

@@ -2,7 +2,6 @@
#pragma once
// Forward declarations
class Foliage;
class FoliageCluster;
class FoliageType;

View File

@@ -492,10 +492,8 @@ void Foliage::DrawCluster(RenderContext& renderContext, FoliageCluster* cluster,
// Draw visible children
if (cluster->Children[0])
{
#if BUILD_DEBUG
// Don't store instances in non-leaf nodes
ASSERT(cluster->Instances.IsEmpty());
#endif
ASSERT_LOW_LAYER(cluster->Instances.IsEmpty());
#define DRAW_CLUSTER(idx) \
if (renderContext.View.CullingFrustum.Intersects(cluster->Children[idx]->TotalBounds)) \

View File

@@ -64,7 +64,6 @@ public:
/// <summary>
/// Determines whether this foliage instance has valid lightmap data.
/// </summary>
/// <returns><c>true</c> if this foliage instance has valid lightmap data; otherwise, <c>false</c>.</returns>
FORCE_INLINE bool HasLightmap() const
{
return Lightmap.TextureIndex != INVALID_INDEX;

View File

@@ -206,7 +206,6 @@ public:
/// <summary>
/// Determines whether this instance is ready (model is loaded).
/// </summary>
/// <returns><c>true</c> if foliage type model is loaded and instance type is ready; otherwise, <c>false</c>.</returns>
FORCE_INLINE bool IsReady() const
{
return _isReady != 0;
@@ -215,7 +214,6 @@ public:
/// <summary>
/// Gets the random scale for the foliage instance of this type.
/// </summary>
/// <returns>The scale vector.</returns>
Vector3 GetRandomScale() const;
private:

View File

@@ -18,10 +18,10 @@
ALIGN_BEGIN(16) struct CullDataSIMD
{
float xs[8];
float ys[8];
float zs[8];
float ds[8];
float xs[8];
float ys[8];
float zs[8];
float ds[8];
} ALIGN_END(16);
#endif
@@ -70,100 +70,106 @@ void SceneRendering::DrawEntries::CullAndDraw(RenderContext& renderContext)
auto& view = renderContext.View;
const BoundingFrustum frustum = view.CullingFrustum;
#if SCENE_RENDERING_USE_SIMD
CullDataSIMD cullData;
{
// Near
auto plane = view.Frustum.GetNear();
cullData.xs[0] = plane.Normal.X;
cullData.ys[0] = plane.Normal.Y;
cullData.zs[0] = plane.Normal.Z;
cullData.ds[0] = plane.D;
CullDataSIMD cullData;
{
// Near
auto plane = view.Frustum.GetNear();
cullData.xs[0] = plane.Normal.X;
cullData.ys[0] = plane.Normal.Y;
cullData.zs[0] = plane.Normal.Z;
cullData.ds[0] = plane.D;
// Far
plane = view.Frustum.GetFar();
cullData.xs[1] = plane.Normal.X;
cullData.ys[1] = plane.Normal.Y;
cullData.zs[1] = plane.Normal.Z;
cullData.ds[1] = plane.D;
// Far
plane = view.Frustum.GetFar();
cullData.xs[1] = plane.Normal.X;
cullData.ys[1] = plane.Normal.Y;
cullData.zs[1] = plane.Normal.Z;
cullData.ds[1] = plane.D;
// Left
plane = view.Frustum.GetLeft();
cullData.xs[2] = plane.Normal.X;
cullData.ys[2] = plane.Normal.Y;
cullData.zs[2] = plane.Normal.Z;
cullData.ds[2] = plane.D;
// Left
plane = view.Frustum.GetLeft();
cullData.xs[2] = plane.Normal.X;
cullData.ys[2] = plane.Normal.Y;
cullData.zs[2] = plane.Normal.Z;
cullData.ds[2] = plane.D;
// Right
plane = view.Frustum.GetRight();
cullData.xs[3] = plane.Normal.X;
cullData.ys[3] = plane.Normal.Y;
cullData.zs[3] = plane.Normal.Z;
cullData.ds[3] = plane.D;
// Right
plane = view.Frustum.GetRight();
cullData.xs[3] = plane.Normal.X;
cullData.ys[3] = plane.Normal.Y;
cullData.zs[3] = plane.Normal.Z;
cullData.ds[3] = plane.D;
// Top
plane = view.Frustum.GetTop();
cullData.xs[4] = plane.Normal.X;
cullData.ys[4] = plane.Normal.Y;
cullData.zs[4] = plane.Normal.Z;
cullData.ds[4] = plane.D;
// Top
plane = view.Frustum.GetTop();
cullData.xs[4] = plane.Normal.X;
cullData.ys[4] = plane.Normal.Y;
cullData.zs[4] = plane.Normal.Z;
cullData.ds[4] = plane.D;
// Bottom
plane = view.Frustum.GetBottom();
cullData.xs[5] = plane.Normal.X;
cullData.ys[5] = plane.Normal.Y;
cullData.zs[5] = plane.Normal.Z;
cullData.ds[5] = plane.D;
// Bottom
plane = view.Frustum.GetBottom();
cullData.xs[5] = plane.Normal.X;
cullData.ys[5] = plane.Normal.Y;
cullData.zs[5] = plane.Normal.Z;
cullData.ds[5] = plane.D;
// Extra 0
cullData.xs[6] = 0;
cullData.ys[6] = 0;
cullData.zs[6] = 0;
cullData.ds[6] = 0;
// Extra 0
cullData.xs[6] = 0;
cullData.ys[6] = 0;
cullData.zs[6] = 0;
cullData.ds[6] = 0;
// Extra 1
cullData.xs[7] = 0;
cullData.ys[7] = 0;
cullData.zs[7] = 0;
cullData.ds[7] = 0;
}
// Extra 1
cullData.xs[7] = 0;
cullData.ys[7] = 0;
cullData.zs[7] = 0;
cullData.ds[7] = 0;
}
float4 px = SIMD::Load(cullData.xs);
float4 py = SIMD::Load(cullData.ys);
float4 pz = SIMD::Load(cullData.zs);
float4 pd = SIMD::Load(cullData.ds);
float4 px2 = SIMD::Load(&cullData.xs[4]);
float4 py2 = SIMD::Load(&cullData.ys[4]);
float4 pz2 = SIMD::Load(&cullData.zs[4]);
float4 pd2 = SIMD::Load(&cullData.ds[4]);
SimdVector4 px = SIMD::Load(cullData.xs);
SimdVector4 py = SIMD::Load(cullData.ys);
SimdVector4 pz = SIMD::Load(cullData.zs);
SimdVector4 pd = SIMD::Load(cullData.ds);
SimdVector4 px2 = SIMD::Load(&cullData.xs[4]);
SimdVector4 py2 = SIMD::Load(&cullData.ys[4]);
SimdVector4 pz2 = SIMD::Load(&cullData.zs[4]);
SimdVector4 pd2 = SIMD::Load(&cullData.ds[4]);
for (int32 i = 0; i < List.Count(); i++)
{
auto& e = List[i];
for (int32 i = 0; i < List.Count(); i++)
{
auto e = List[i];
const auto& sphere = actors[i]->GetSphere();
float4 cx = SIMD::Splat(sphere.Center.X);
float4 cy = SIMD::Splat(sphere.Center.Y);
float4 cz = SIMD::Splat(sphere.Center.Z);
float4 r = SIMD::Splat(-sphere.Radius);
SimdVector4 cx = SIMD::Splat(e.Bounds.Center.X);
SimdVector4 cy = SIMD::Splat(e.Bounds.Center.Y);
SimdVector4 cz = SIMD::Splat(e.Bounds.Center.Z);
SimdVector4 r = SIMD::Splat(-e.Bounds.Radius);
float4 t = SIMD::Mul(cx, px);
t = SIMD::Add(t, SIMD::Mul(cy, py));
t = SIMD::Add(t, SIMD::Mul(cz, pz));
t = SIMD::Add(t, pd);
t = SIMD::Sub(t, r);
if (SIMD::MoveMask(t))
continue;
SimdVector4 t = SIMD::Mul(cx, px);
t = SIMD::Add(t, SIMD::Mul(cy, py));
t = SIMD::Add(t, SIMD::Mul(cz, pz));
t = SIMD::Add(t, pd);
t = SIMD::Sub(t, r);
if (SIMD::MoveMask(t))
continue;
t = SIMD::Mul(cx, px2);
t = SIMD::Add(t, SIMD::Mul(cy, py2));
t = SIMD::Add(t, SIMD::Mul(cz, pz2));
t = SIMD::Add(t, pd2);
t = SIMD::Sub(t, r);
if (SIMD::MoveMask(t))
continue;
t = SIMD::Mul(cx, px2);
t = SIMD::Add(t, SIMD::Mul(cy, py2));
t = SIMD::Add(t, SIMD::Mul(cz, pz2));
t = SIMD::Add(t, pd2);
t = SIMD::Sub(t, r);
if (SIMD::MoveMask(t))
continue;
e.Actor->Draw(renderContext);
}
if (view.RenderLayersMask.Mask & e.LayerMask)
{
#if SCENE_RENDERING_USE_PROFILER
PROFILE_CPU();
___tracy_scoped_zone.Name(*e.Actor->GetName(), e.Actor->GetName().Length());
#endif
e.Actor->Draw(renderContext);
}
}
#else
for (int32 i = 0; i < List.Count(); i++)
{
@@ -185,99 +191,106 @@ void SceneRendering::DrawEntries::CullAndDrawOffline(RenderContext& renderContex
auto& view = renderContext.View;
const BoundingFrustum frustum = view.CullingFrustum;
#if SCENE_RENDERING_USE_SIMD
CullDataSIMD cullData;
{
// Near
auto plane = view.Frustum.GetNear();
cullData.xs[0] = plane.Normal.X;
cullData.ys[0] = plane.Normal.Y;
cullData.zs[0] = plane.Normal.Z;
cullData.ds[0] = plane.D;
CullDataSIMD cullData;
{
// Near
auto plane = view.Frustum.GetNear();
cullData.xs[0] = plane.Normal.X;
cullData.ys[0] = plane.Normal.Y;
cullData.zs[0] = plane.Normal.Z;
cullData.ds[0] = plane.D;
// Far
plane = view.Frustum.GetFar();
cullData.xs[1] = plane.Normal.X;
cullData.ys[1] = plane.Normal.Y;
cullData.zs[1] = plane.Normal.Z;
cullData.ds[1] = plane.D;
// Far
plane = view.Frustum.GetFar();
cullData.xs[1] = plane.Normal.X;
cullData.ys[1] = plane.Normal.Y;
cullData.zs[1] = plane.Normal.Z;
cullData.ds[1] = plane.D;
// Left
plane = view.Frustum.GetLeft();
cullData.xs[2] = plane.Normal.X;
cullData.ys[2] = plane.Normal.Y;
cullData.zs[2] = plane.Normal.Z;
cullData.ds[2] = plane.D;
// Left
plane = view.Frustum.GetLeft();
cullData.xs[2] = plane.Normal.X;
cullData.ys[2] = plane.Normal.Y;
cullData.zs[2] = plane.Normal.Z;
cullData.ds[2] = plane.D;
// Right
plane = view.Frustum.GetRight();
cullData.xs[3] = plane.Normal.X;
cullData.ys[3] = plane.Normal.Y;
cullData.zs[3] = plane.Normal.Z;
cullData.ds[3] = plane.D;
// Right
plane = view.Frustum.GetRight();
cullData.xs[3] = plane.Normal.X;
cullData.ys[3] = plane.Normal.Y;
cullData.zs[3] = plane.Normal.Z;
cullData.ds[3] = plane.D;
// Top
plane = view.Frustum.GetTop();
cullData.xs[4] = plane.Normal.X;
cullData.ys[4] = plane.Normal.Y;
cullData.zs[4] = plane.Normal.Z;
cullData.ds[4] = plane.D;
// Top
plane = view.Frustum.GetTop();
cullData.xs[4] = plane.Normal.X;
cullData.ys[4] = plane.Normal.Y;
cullData.zs[4] = plane.Normal.Z;
cullData.ds[4] = plane.D;
// Bottom
plane = view.Frustum.GetBottom();
cullData.xs[5] = plane.Normal.X;
cullData.ys[5] = plane.Normal.Y;
cullData.zs[5] = plane.Normal.Z;
cullData.ds[5] = plane.D;
// Bottom
plane = view.Frustum.GetBottom();
cullData.xs[5] = plane.Normal.X;
cullData.ys[5] = plane.Normal.Y;
cullData.zs[5] = plane.Normal.Z;
cullData.ds[5] = plane.D;
// Extra 0
cullData.xs[6] = 0;
cullData.ys[6] = 0;
cullData.zs[6] = 0;
cullData.ds[6] = 0;
// Extra 0
cullData.xs[6] = 0;
cullData.ys[6] = 0;
cullData.zs[6] = 0;
cullData.ds[6] = 0;
// Extra 1
cullData.xs[7] = 0;
cullData.ys[7] = 0;
cullData.zs[7] = 0;
cullData.ds[7] = 0;
}
// Extra 1
cullData.xs[7] = 0;
cullData.ys[7] = 0;
cullData.zs[7] = 0;
cullData.ds[7] = 0;
}
float4 px = SIMD::Load(cullData.xs);
float4 py = SIMD::Load(cullData.ys);
float4 pz = SIMD::Load(cullData.zs);
float4 pd = SIMD::Load(cullData.ds);
float4 px2 = SIMD::Load(&cullData.xs[4]);
float4 py2 = SIMD::Load(&cullData.ys[4]);
float4 pz2 = SIMD::Load(&cullData.zs[4]);
float4 pd2 = SIMD::Load(&cullData.ds[4]);
SimdVector4 px = SIMD::Load(cullData.xs);
SimdVector4 py = SIMD::Load(cullData.ys);
SimdVector4 pz = SIMD::Load(cullData.zs);
SimdVector4 pd = SIMD::Load(cullData.ds);
SimdVector4 px2 = SIMD::Load(&cullData.xs[4]);
SimdVector4 py2 = SIMD::Load(&cullData.ys[4]);
SimdVector4 pz2 = SIMD::Load(&cullData.zs[4]);
SimdVector4 pd2 = SIMD::Load(&cullData.ds[4]);
for (int32 i = 0; i < actors.Count(); i++)
{
const auto& sphere = actors[i]->GetSphere();
float4 cx = SIMD::Splat(sphere.Center.X);
float4 cy = SIMD::Splat(sphere.Center.Y);
float4 cz = SIMD::Splat(sphere.Center.Z);
float4 r = SIMD::Splat(-sphere.Radius);
for (int32 i = 0; i < List.Count(); i++)
{
auto e = List[i];
float4 t = SIMD::Mul(cx, px);
t = SIMD::Add(t, SIMD::Mul(cy, py));
t = SIMD::Add(t, SIMD::Mul(cz, pz));
t = SIMD::Add(t, pd);
t = SIMD::Sub(t, r);
if (SIMD::MoveMask(t))
continue;
SimdVector4 cx = SIMD::Splat(e.Bounds.Center.X);
SimdVector4 cy = SIMD::Splat(e.Bounds.Center.Y);
SimdVector4 cz = SIMD::Splat(e.Bounds.Center.Z);
SimdVector4 r = SIMD::Splat(-e.Bounds.Radius);
t = SIMD::Mul(cx, px2);
t = SIMD::Add(t, SIMD::Mul(cy, py2));
t = SIMD::Add(t, SIMD::Mul(cz, pz2));
t = SIMD::Add(t, pd2);
t = SIMD::Sub(t, r);
if (SIMD::MoveMask(t))
continue;
SimdVector4 t = SIMD::Mul(cx, px);
t = SIMD::Add(t, SIMD::Mul(cy, py));
t = SIMD::Add(t, SIMD::Mul(cz, pz));
t = SIMD::Add(t, pd);
t = SIMD::Sub(t, r);
if (SIMD::MoveMask(t))
continue;
if (actors[i]->GetStaticFlags() & renderContext.View.StaticFlagsMask)
actors[i]->Draw(renderContext);
}
t = SIMD::Mul(cx, px2);
t = SIMD::Add(t, SIMD::Mul(cy, py2));
t = SIMD::Add(t, SIMD::Mul(cz, pz2));
t = SIMD::Add(t, pd2);
t = SIMD::Sub(t, r);
if (SIMD::MoveMask(t))
continue;
if (view.RenderLayersMask.Mask & e.LayerMask && e.Actor->GetStaticFlags() & renderContext.View.StaticFlagsMask)
{
#if SCENE_RENDERING_USE_PROFILER
PROFILE_CPU();
___tracy_scoped_zone.Name(*e.Actor->GetName(), e.Actor->GetName().Length());
#endif
e.Actor->Draw(renderContext);
}
}
#else
for (int32 i = 0; i < List.Count(); i++)
{

View File

@@ -361,8 +361,6 @@ void RenderList::Clear()
void RenderList::AddDrawCall(DrawPass drawModes, StaticFlags staticFlags, DrawCall& drawCall, bool receivesDecals)
{
ASSERT_LOW_LAYER(drawCall.Geometry.IndexBuffer);
// Mix object mask with material mask
const auto mask = (DrawPass)(drawModes & drawCall.Material->GetDrawModes());
if (mask == DrawPass::None)