Merge remote-tracking branch 'origin/master' into 1.13
# Conflicts: # Flax.flaxproj # Source/Engine/Level/Actors/StaticModel.cpp # Source/Engine/Level/Prefabs/Prefab.cpp # Source/Engine/Tools/ModelTool/ModelTool.cpp
This commit is contained in:
@@ -76,9 +76,10 @@ void GPUTasksContext::OnFrameBegin()
|
||||
{
|
||||
auto task = _tasksSyncing[i];
|
||||
auto state = task->GetState();
|
||||
if (EnumHasAllFlags(task->Flags, ObjectFlags::WasMarkedToDelete))
|
||||
state = TaskState::Finished;
|
||||
if (task->GetSyncPoint() <= _currentSyncPoint && state != TaskState::Finished)
|
||||
{
|
||||
// TODO: add stats counter and count performed jobs, print to log on exit.
|
||||
task->Sync();
|
||||
}
|
||||
if (state == TaskState::Failed || state == TaskState::Canceled)
|
||||
|
||||
@@ -460,6 +460,18 @@ void MaterialParameter::Bind(BindMeta& meta) const
|
||||
ASSERT_LOW_LAYER(meta.Constants.Get() && meta.Constants.Length() >= (int32)(_offset + sizeof(Float4)));
|
||||
*((Float4*)(meta.Constants.Get() + _offset)) = (Float4)e->Value.AsDouble4();
|
||||
break;
|
||||
case VariantType::Int2:
|
||||
ASSERT_LOW_LAYER(meta.Constants.Get() && meta.Constants.Length() >= (int32)(_offset + sizeof(Int2)));
|
||||
*((Int2*)(meta.Constants.Get() + _offset)) = (Int2)e->Value.AsInt2();
|
||||
break;
|
||||
case VariantType::Int3:
|
||||
ASSERT_LOW_LAYER(meta.Constants.Get() && meta.Constants.Length() >= (int32)(_offset + sizeof(Int3)));
|
||||
*((Int3*)(meta.Constants.Get() + _offset)) = (Int3)e->Value.AsInt3();
|
||||
break;
|
||||
case VariantType::Int4:
|
||||
ASSERT_LOW_LAYER(meta.Constants.Get() && meta.Constants.Length() >= (int32)(_offset + sizeof(Int4)));
|
||||
*((Int4*)(meta.Constants.Get() + _offset)) = (Int4)e->Value.AsInt4();
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ namespace FlaxEngine
|
||||
{
|
||||
ibData = dataPtr[IB];
|
||||
use16BitIndexBuffer = _formats[IB] == PixelFormat.R16_UInt;
|
||||
triangles = (uint)(_data[IB].Length / PixelFormatExtensions.SizeInBytes(_formats[IB]));
|
||||
triangles = (uint)(_data[IB].Length / (PixelFormatExtensions.SizeInBytes(_formats[IB]) * 3));
|
||||
}
|
||||
|
||||
if (mesh.Init(vertices, triangles, vbData, ibData, use16BitIndexBuffer, vbLayout))
|
||||
@@ -643,11 +643,16 @@ namespace FlaxEngine
|
||||
else
|
||||
{
|
||||
Float3 min = Float3.Maximum, max = Float3.Minimum;
|
||||
for (int i = 0; i < vertices; i++)
|
||||
PixelFormatSampler.Get(positionStream.Format, out var positionSampler);
|
||||
int positionStride = positionStream.Stride;
|
||||
fixed (byte* data = positionStream.Data)
|
||||
{
|
||||
Float3 pos = positionStream.GetFloat3(i);
|
||||
Float3.Min(ref min, ref pos, out min);
|
||||
Float3.Max(ref max, ref pos, out max);
|
||||
for (int i = 0; i < vertices; i++)
|
||||
{
|
||||
Float3 pos = new Float3(positionSampler.Read(data + i * positionStride));
|
||||
Float3.Min(ref min, ref pos, out min);
|
||||
Float3.Max(ref max, ref pos, out max);
|
||||
}
|
||||
}
|
||||
bounds = new BoundingBox(min, max);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,13 @@ bool ModelInstanceEntries::HasContentLoaded() const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ModelInstanceEntries::ShouldSerialize(const void* otherObj) const
|
||||
{
|
||||
if (!otherObj)
|
||||
return true;
|
||||
return !(*this == *(const ModelInstanceEntries*)otherObj);
|
||||
}
|
||||
|
||||
void ModelInstanceEntries::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
{
|
||||
SERIALIZE_GET_OTHER_OBJ(ModelInstanceEntries);
|
||||
@@ -43,12 +50,13 @@ void ModelInstanceEntries::Serialize(SerializeStream& stream, const void* otherO
|
||||
void ModelInstanceEntries::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
|
||||
{
|
||||
PROFILE_MEM(Graphics);
|
||||
const DeserializeStream& entries = stream["Entries"];
|
||||
ASSERT(entries.IsArray());
|
||||
Resize(entries.Size());
|
||||
for (rapidjson::SizeType i = 0; i < entries.Size(); i++)
|
||||
const DeserializeStream& entriesData = stream[rapidjson_flax::Value(rapidjson::StringRef("Entries", 7))];
|
||||
CHECK(entriesData.IsArray());
|
||||
Resize(entriesData.Size());
|
||||
ModelInstanceEntry* entries = Get();
|
||||
for (int32 i = 0; i < Count(); i++)
|
||||
{
|
||||
At(i).Deserialize((DeserializeStream&)entries[i], modifier);
|
||||
entries[i].Deserialize((DeserializeStream&)entriesData[i], modifier);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ public:
|
||||
|
||||
public:
|
||||
// [ISerializable]
|
||||
bool ShouldSerialize(const void* otherObj) const override;
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
};
|
||||
|
||||
@@ -353,8 +353,11 @@ Viewport SceneRenderTask::GetViewport() const
|
||||
viewport = Buffers->GetViewport();
|
||||
else
|
||||
viewport = Viewport(0, 0, 1280, 720);
|
||||
viewport.Width *= RenderingPercentage;
|
||||
viewport.Height *= RenderingPercentage;
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
float renderScale = RenderingPercentage * RenderScale;
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
viewport.Width *= renderScale;
|
||||
viewport.Height *= renderScale;
|
||||
return viewport;
|
||||
}
|
||||
|
||||
@@ -394,13 +397,16 @@ void SceneRenderTask::OnBegin(GPUContext* context)
|
||||
}
|
||||
|
||||
// Setup render buffers for the output rendering resolution
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
float renderScale = RenderingPercentage * RenderScale;
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
if (Output)
|
||||
{
|
||||
Buffers->Init((int32)((float)Output->Width() * RenderingPercentage), (int32)((float)Output->Height() * RenderingPercentage));
|
||||
Buffers->Init((int32)((float)Output->Width() * renderScale), (int32)((float)Output->Height() * renderScale));
|
||||
}
|
||||
else if (SwapChain)
|
||||
{
|
||||
Buffers->Init((int32)((float)SwapChain->GetWidth() * RenderingPercentage), (int32)((float)SwapChain->GetHeight() * RenderingPercentage));
|
||||
Buffers->Init((int32)((float)SwapChain->GetWidth() * renderScale), (int32)((float)SwapChain->GetHeight() * renderScale));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +440,10 @@ bool SceneRenderTask::Resize(int32 width, int32 height)
|
||||
PROFILE_MEM(Graphics);
|
||||
if (Output && Output->Resize(width, height))
|
||||
return true;
|
||||
if (Buffers && Buffers->Init((int32)((float)width * RenderingPercentage), (int32)((float)height * RenderingPercentage)))
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
float renderScale = RenderingPercentage * RenderScale;
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
if (Buffers && Buffers->Init((int32)((float)width * renderScale), (int32)((float)height * renderScale)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -477,12 +486,6 @@ void MainRenderTask::OnBegin(GPUContext* context)
|
||||
// Use the main camera for the game (can be later overriden in Begin event by external code)
|
||||
Camera = Camera::GetMainCamera();
|
||||
|
||||
#if !USE_EDITOR
|
||||
// Sync render buffers size with the backbuffer
|
||||
const auto size = Screen::GetSize();
|
||||
Buffers->Init((int32)(size.X * RenderingPercentage), (int32)(size.Y * RenderingPercentage));
|
||||
#endif
|
||||
|
||||
SceneRenderTask::OnBegin(context);
|
||||
}
|
||||
|
||||
@@ -507,3 +510,10 @@ RenderContextBatch::RenderContextBatch(const RenderContext& context)
|
||||
Contexts.Add(context);
|
||||
EnableAsync = JobSystem::GetThreadsCount() > 1;
|
||||
}
|
||||
|
||||
void RenderContextBatch::FlushWaitLabels()
|
||||
{
|
||||
for (const int64 label : WaitLabels)
|
||||
JobSystem::Wait(label);
|
||||
WaitLabels.Clear();
|
||||
}
|
||||
|
||||
@@ -268,8 +268,14 @@ public:
|
||||
|
||||
/// <summary>
|
||||
/// The scale of the rendering resolution relative to the output dimensions. If lower than 1 the scene and postprocessing will be rendered at a lower resolution and upscaled to the output backbuffer.
|
||||
/// [Deprecated in v1.13]
|
||||
/// </summary>
|
||||
API_FIELD() float RenderingPercentage = 1.0f;
|
||||
API_FIELD() DEPRECATED("Use RenderScale instead.") float RenderingPercentage = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The scale of the rendering resolution relative to the output dimensions. If lower than 1 the scene and postprocessing will be rendered at a lower resolution and upscaled to the output backbuffer.
|
||||
/// </summary>
|
||||
API_FIELD() float RenderScale = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The image resolution upscale location within rendering pipeline. Unused if RenderingPercentage is 1.
|
||||
@@ -533,4 +539,9 @@ API_STRUCT(NoDefault) struct FLAXENGINE_API RenderContextBatch
|
||||
{
|
||||
return Contexts.Get()[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits for all scheduled async jobs to complete and clears WaitLabels.
|
||||
/// </summary>
|
||||
void FlushWaitLabels();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user