Optimize compilation time
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "DefaultGPUTasksExecutor.h"
|
||||
#include "GPUTasksContext.h"
|
||||
#include "GPUTask.h"
|
||||
#include "GPUTasksManager.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
|
||||
DefaultGPUTasksExecutor::DefaultGPUTasksExecutor()
|
||||
@@ -30,7 +31,7 @@ void DefaultGPUTasksExecutor::FrameEnd()
|
||||
|
||||
// Default implementation performs async operations on end of the frame which is synchronized with a rendering thread
|
||||
GPUTask* buffer[32];
|
||||
const int32 count = GPUDevice::Instance->TasksManager.RequestWork(buffer, 32);
|
||||
const int32 count = GPUDevice::Instance->GetTasksManager()->RequestWork(buffer, 32);
|
||||
for (int32 i = 0; i < count; i++)
|
||||
{
|
||||
_context->Run(buffer[i]);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "GPUTasksExecutor.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
|
||||
GPUTasksExecutor::~GPUTasksExecutor()
|
||||
|
||||
@@ -37,7 +37,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the context list.
|
||||
/// </summary>
|
||||
/// <returns>GPU contexts</returns>
|
||||
FORCE_INLINE const Array<GPUTasksContext*>* GetContextList() const
|
||||
{
|
||||
return &_contextList;
|
||||
|
||||
@@ -7,26 +7,13 @@
|
||||
|
||||
void GPUTask::Enqueue()
|
||||
{
|
||||
GPUDevice::Instance->TasksManager._tasks.Add(this);
|
||||
GPUDevice::Instance->GetTasksManager()->_tasks.Add(this);
|
||||
}
|
||||
|
||||
GPUTasksManager::GPUTasksManager(GPUDevice* device)
|
||||
: _device(device)
|
||||
, _executor(nullptr)
|
||||
, _bufferIndex(0)
|
||||
GPUTasksManager::GPUTasksManager()
|
||||
{
|
||||
_buffers[0].EnsureCapacity(64);
|
||||
_buffers[1].EnsureCapacity(64);
|
||||
|
||||
// Setup executor
|
||||
SetExecutor(device->CreateTasksExecutor());
|
||||
ASSERT(_executor != nullptr);
|
||||
}
|
||||
|
||||
GPUTasksManager::~GPUTasksManager()
|
||||
{
|
||||
// Ensure that Dispose has been called
|
||||
ASSERT(_executor == nullptr);
|
||||
}
|
||||
|
||||
void GPUTasksManager::SetExecutor(GPUTasksExecutor* value)
|
||||
@@ -114,3 +101,8 @@ int32 GPUTasksManager::RequestWork(GPUTask** buffer, int32 maxCount)
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
String GPUTasksManager::ToString() const
|
||||
{
|
||||
return TEXT("GPU Tasks Manager");
|
||||
}
|
||||
|
||||
@@ -22,30 +22,17 @@ class GPUTasksManager : public Object, public NonCopyable
|
||||
friend GPUTask;
|
||||
|
||||
private:
|
||||
GPUDevice* _device;
|
||||
GPUTasksExecutor* _executor;
|
||||
GPUTasksExecutor* _executor = nullptr;
|
||||
ConcurrentTaskQueue<GPUTask> _tasks;
|
||||
Array<GPUTask*> _buffers[2];
|
||||
int32 _bufferIndex;
|
||||
|
||||
private:
|
||||
GPUTasksManager(GPUDevice* device);
|
||||
~GPUTasksManager();
|
||||
int32 _bufferIndex = 0;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Gets the parent Graphics Device.
|
||||
/// </summary>
|
||||
/// <returns>The device.</returns>
|
||||
FORCE_INLINE GPUDevice* GetDevice() const
|
||||
{
|
||||
return _device;
|
||||
}
|
||||
GPUTasksManager();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the GPU tasks executor.
|
||||
/// </summary>
|
||||
/// <returns>The tasks executor.</returns>
|
||||
FORCE_INLINE GPUTasksExecutor* GetExecutor() const
|
||||
{
|
||||
return _executor;
|
||||
@@ -60,7 +47,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the amount of enqueued tasks to perform.
|
||||
/// </summary>
|
||||
/// <returns>The tasks count.</returns>
|
||||
FORCE_INLINE int32 GetTaskCount() const
|
||||
{
|
||||
return _tasks.Count();
|
||||
@@ -94,8 +80,5 @@ public:
|
||||
|
||||
public:
|
||||
// [Object]
|
||||
String ToString() const override
|
||||
{
|
||||
return TEXT("GPU Tasks Manager");
|
||||
}
|
||||
String ToString() const override;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "DynamicBuffer.h"
|
||||
#include "GPUContext.h"
|
||||
#include "PixelFormatExtensions.h"
|
||||
#include "GPUDevice.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Utilities.h"
|
||||
#include "Engine/Core/Math/Math.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
|
||||
DynamicBuffer::DynamicBuffer(uint32 initialCapacity, uint32 stride, const String& name)
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
#include "Graphics.h"
|
||||
#include "Shaders/GPUShader.h"
|
||||
#include "Async/DefaultGPUTasksExecutor.h"
|
||||
#include "Async/GPUTasksManager.h"
|
||||
#include "Engine/Content/Assets/Shader.h"
|
||||
#include "Engine/Content/Assets/Material.h"
|
||||
#include "Engine/Content/Content.h"
|
||||
#include "Engine/Content/SoftAssetReference.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Render2D/Render2D.h"
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
@@ -263,6 +265,7 @@ struct GPUDevice::PrivateData
|
||||
AssetReference<Texture> DefaultNormalMap;
|
||||
AssetReference<Texture> DefaultWhiteTexture;
|
||||
AssetReference<Texture> DefaultBlackTexture;
|
||||
GPUTasksManager TasksManager;
|
||||
};
|
||||
|
||||
GPUDevice* GPUDevice::Instance = nullptr;
|
||||
@@ -277,7 +280,6 @@ GPUDevice::GPUDevice(RendererType type, ShaderProfile profile)
|
||||
, _shaderProfile(profile)
|
||||
, _featureLevel(RenderTools::GetFeatureLevel(profile))
|
||||
, _res(New<PrivateData>())
|
||||
, TasksManager(this)
|
||||
, TotalGraphicsMemory(0)
|
||||
, QuadShader(nullptr)
|
||||
, CurrentTask(nullptr)
|
||||
@@ -296,6 +298,7 @@ GPUDevice::~GPUDevice()
|
||||
|
||||
bool GPUDevice::Init()
|
||||
{
|
||||
_res->TasksManager.SetExecutor(CreateTasksExecutor());
|
||||
LOG(Info, "Total graphics memory: {0}", Utilities::BytesToText(TotalGraphicsMemory));
|
||||
return false;
|
||||
}
|
||||
@@ -492,7 +495,7 @@ void GPUDevice::Draw()
|
||||
// Begin frame
|
||||
context->FrameBegin();
|
||||
RenderBegin();
|
||||
TasksManager.FrameBegin();
|
||||
_res->TasksManager.FrameBegin();
|
||||
Render2D::BeginFrame();
|
||||
|
||||
// Perform actual drawing
|
||||
@@ -502,7 +505,7 @@ void GPUDevice::Draw()
|
||||
|
||||
// End frame
|
||||
Render2D::EndFrame();
|
||||
TasksManager.FrameEnd();
|
||||
_res->TasksManager.FrameEnd();
|
||||
RenderEnd();
|
||||
context->FrameEnd();
|
||||
|
||||
@@ -520,6 +523,11 @@ uint64 GPUDevice::GetMemoryUsage() const
|
||||
return Resources.GetMemoryUsage();
|
||||
}
|
||||
|
||||
GPUTasksManager* GPUDevice::GetTasksManager() const
|
||||
{
|
||||
return &_res->TasksManager;
|
||||
}
|
||||
|
||||
MaterialBase* GPUDevice::GetDefaultMaterial() const
|
||||
{
|
||||
return _res->DefaultMaterial;
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Platform/Platform.h"
|
||||
#include "Engine/Core/Enums.h"
|
||||
#include "Engine/Core/NonCopyable.h"
|
||||
#include "Engine/Scripting/ScriptingObject.h"
|
||||
#include "Async/GPUTasksManager.h"
|
||||
#include "GPUResourcesCollection.h"
|
||||
#include "GPUAdapter.h"
|
||||
#include "GPULimits.h"
|
||||
@@ -20,7 +21,11 @@ class GPUTexture;
|
||||
class GPUBuffer;
|
||||
class GPUSampler;
|
||||
class GPUPipelineState;
|
||||
class GPUConstantBuffer;
|
||||
class GPUTasksContext;
|
||||
class GPUTasksExecutor;
|
||||
class GPUSwapChain;
|
||||
class GPUTasksManager;
|
||||
class Shader;
|
||||
class Model;
|
||||
class Material;
|
||||
@@ -105,11 +110,6 @@ public:
|
||||
/// </summary>
|
||||
GPUResourcesCollection Resources;
|
||||
|
||||
/// <summary>
|
||||
/// GPU asynchronous work manager.
|
||||
/// </summary>
|
||||
GPUTasksManager TasksManager;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// The total amount of graphics memory in bytes.
|
||||
@@ -220,6 +220,11 @@ public:
|
||||
/// </summary>
|
||||
API_PROPERTY() uint64 GetMemoryUsage() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the GPU asynchronous work manager.
|
||||
/// </summary>
|
||||
GPUTasksManager* GetTasksManager() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default material.
|
||||
/// </summary>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "GPUDevice.h"
|
||||
#include "Textures/GPUTexture.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Threading/Task.h"
|
||||
|
||||
class GPUSwapChainDownloadTask : public Task
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "Graphics.h"
|
||||
#include "GPUDevice.h"
|
||||
#include "PixelFormatExtensions.h"
|
||||
#include "Async/GPUTasksManager.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Config/GraphicsSettings.h"
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
#include "Engine/Engine/EngineService.h"
|
||||
@@ -194,7 +196,7 @@ void GraphicsService::BeforeExit()
|
||||
if (GPUDevice::Instance)
|
||||
{
|
||||
// Start disposing
|
||||
GPUDevice::Instance->TasksManager.Dispose();
|
||||
GPUDevice::Instance->GetTasksManager()->Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
#include "DecalMaterialShader.h"
|
||||
#include "MaterialParams.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Math/OrientedBoundingBox.h"
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Graphics/Shaders/GPUShader.h"
|
||||
#include "Engine/Graphics/RenderBuffers.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ForwardMaterialShader.h"
|
||||
#include "MaterialShaderFeatures.h"
|
||||
#include "MaterialParams.h"
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Graphics/GPULimits.h"
|
||||
#include "Engine/Graphics/RenderView.h"
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
#include "GUIMaterialShader.h"
|
||||
#include "MaterialParams.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Math/Viewport.h"
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Graphics/Shaders/GPUShader.h"
|
||||
#include "Engine/Graphics/RenderView.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Graphics/Shaders/GPUConstantBuffer.h"
|
||||
#include "Engine/Graphics/Shaders/GPUShader.h"
|
||||
#include "Engine/Engine/Time.h"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Renderer/Lightmaps.h"
|
||||
#endif
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Level/Scene/Lightmap.h"
|
||||
#include "Engine/Level/Actors/EnvironmentProbe.h"
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "PostFxMaterialShader.h"
|
||||
#include "MaterialParams.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Graphics/Shaders/GPUShader.h"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "ModelInstanceEntry.h"
|
||||
#include "Engine/Content/Assets/Material.h"
|
||||
#include "Engine/Content/Assets/Model.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Math/Transform.h"
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
@@ -11,6 +12,7 @@
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Serialization/MemoryReadStream.h"
|
||||
#include "Engine/Threading/Task.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
#if USE_MONO
|
||||
#include <ThirdParty/mono-2.0/mono/metadata/appdomain.h>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "ModelLOD.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Math/Transform.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Serialization/MemoryReadStream.h"
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
#include "ModelInstanceEntry.h"
|
||||
#include "Engine/Content/Assets/Material.h"
|
||||
#include "Engine/Content/Assets/SkinnedModel.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Level/Scene/Scene.h"
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Serialization/MemoryReadStream.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Threading/Task.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
#if USE_MONO
|
||||
#include <ThirdParty/mono-2.0/mono/metadata/appdomain.h>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "SkinnedMeshDrawData.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Animations/Config.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Math/Matrix.h"
|
||||
#include "Engine/Core/Math/Matrix3x4.h"
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "SkinnedModelLOD.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Content/Assets/Model.h"
|
||||
#include "Engine/Serialization/MemoryReadStream.h"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "RenderTargetPool.h"
|
||||
#include "GPUDevice.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
|
||||
struct Entry
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "RenderTask.h"
|
||||
#include "Engine/Content/Assets/Model.h"
|
||||
#include "Engine/Content/Assets/SkinnedModel.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Engine/Time.h"
|
||||
|
||||
const Char* ToString(RendererType value)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ShaderAssetBase.h"
|
||||
#include "ShaderStorage.h"
|
||||
#include "ShaderCacheManager.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Graphics/Shaders/GPUShader.h"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "GPUSampler.h"
|
||||
#include "GPUSamplerDescription.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Types/String.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user