Add **GPU Memory profiler** to Editor

This commit is contained in:
Wojciech Figat
2022-12-08 16:30:37 +01:00
parent f2c594569d
commit df82a0f5d0
47 changed files with 548 additions and 195 deletions

View File

@@ -3,7 +3,6 @@
#pragma once
#include "Engine/Threading/Task.h"
#include "Engine/Core/Types/String.h"
class Asset;
class LoadingThread;
@@ -46,7 +45,6 @@ public:
/// <summary>
/// Gets a task type.
/// </summary>
/// <returns>The type.</returns>
FORCE_INLINE Type GetType() const
{
return _type;
@@ -68,13 +66,7 @@ protected:
public:
// [Task]
String ToString() const override
{
return String::Format(TEXT("Content Load Task {0} ({1})"),
ToString(GetType()),
::ToString(GetState())
);
}
String ToString() const override;
protected:
// [Task]

View File

@@ -211,6 +211,11 @@ void ContentLoadingManagerService::Dispose()
Tasks.CancelAll();
}
String ContentLoadTask::ToString() const
{
return String::Format(TEXT("Content Load Task {0} ({1})"), ToString(GetType()), (int32)GetState());
}
void ContentLoadTask::Enqueue()
{
Tasks.Add(this);

View File

@@ -2,8 +2,6 @@
#pragma once
#include "Engine/Core/Enums.h"
/// <summary>
/// Build game header flags.
/// </summary>

View File

@@ -4,7 +4,6 @@
#include "Engine/Threading/Task.h"
#include "Engine/Platform/Platform.h"
#include "Engine/Core/Log.h"
#include "GPUTasksContext.h"
class GPUResource;
@@ -89,32 +88,7 @@ public:
/// Executes this task.
/// </summary>
/// <param name="context">The context.</param>
void Execute(GPUTasksContext* context)
{
// Begin
ASSERT(IsQueued() && _context == nullptr);
_state = TaskState::Running;
// Perform an operation
const auto result = run(context);
// Process result
if (IsCancelRequested())
{
_state = TaskState::Canceled;
}
else if (result != Result::Ok)
{
LOG(Warning, "\'{0}\' failed with result: {1}", ToString(), ToString(result));
OnFail();
}
else
{
// Save task completion point (for synchronization)
_syncPoint = context->GetCurrentSyncPoint();
_context = context;
}
}
void Execute(GPUTasksContext* context);
/// <summary>
/// Action fired when asynchronous operation has been synchronized with a GPU
@@ -154,10 +128,7 @@ protected:
public:
// [Task]
String ToString() const override
{
return String::Format(TEXT("GPU Async Task {0} ({1})"), ToString(GetType()), ::ToString(GetState()));
}
String ToString() const override;
protected:
// [Task]

View File

@@ -2,6 +2,7 @@
#include "GPUTasksContext.h"
#include "GPUTask.h"
#include "Engine/Core/Log.h"
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Threading/Threading.h"

View File

@@ -3,8 +3,42 @@
#include "GPUTasksManager.h"
#include "GPUTask.h"
#include "GPUTasksExecutor.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Types/String.h"
#include "Engine/Graphics/GPUDevice.h"
void GPUTask::Execute(GPUTasksContext* context)
{
// Begin
ASSERT(IsQueued() && _context == nullptr);
_state = TaskState::Running;
// Perform an operation
const auto result = run(context);
// Process result
if (IsCancelRequested())
{
_state = TaskState::Canceled;
}
else if (result != Result::Ok)
{
LOG(Warning, "\'{0}\' failed with result: {1}", ToString(), ToString(result));
OnFail();
}
else
{
// Save task completion point (for synchronization)
_syncPoint = context->GetCurrentSyncPoint();
_context = context;
}
}
String GPUTask::ToString() const
{
return String::Format(TEXT("GPU Async Task {0} ({1})"), ToString(GetType()), (int32)GetState());
}
void GPUTask::Enqueue()
{
GPUDevice::Instance->GetTasksManager()->_tasks.Add(this);

View File

@@ -395,14 +395,9 @@ String GPUBuffer::ToString() const
#endif
}
GPUResource::ResourceType GPUBuffer::GetResourceType() const
GPUResourceType GPUBuffer::GetResourceType() const
{
return ResourceType::Buffer;
}
GPUResource::ObjectType GPUBuffer::GetObjectType() const
{
return ObjectType::Buffer;
return GPUResourceType::Buffer;
}
void GPUBuffer::OnReleaseGPU()

View File

@@ -205,8 +205,7 @@ protected:
public:
// [GPUResource]
String ToString() const override;
ResourceType GetResourceType() const final override;
ObjectType GetObjectType() const final override;
GPUResourceType GetResourceType() const final override;
protected:
// [GPUResource]

View File

@@ -23,6 +23,7 @@
#include "Engine/Engine/EngineService.h"
#include "Engine/Profiler/Profiler.h"
#include "Engine/Renderer/RenderList.h"
#include "Engine/Scripting/Enums.h"
GPUPipelineState* GPUPipelineState::Spawn(const SpawnParams& params)
{
@@ -79,9 +80,9 @@ bool GPUPipelineState::Init(const Description& desc)
return false;
}
GPUResource::ResourceType GPUPipelineState::GetResourceType() const
GPUResourceType GPUPipelineState::GetResourceType() const
{
return ResourceType::PipelineState;
return GPUResourceType::PipelineState;
}
GPUPipelineState::Description GPUPipelineState::Description::Default =
@@ -193,16 +194,13 @@ GPUResource::~GPUResource()
#endif
}
GPUResource::ObjectType GPUResource::GetObjectType() const
{
return ObjectType::Other;
}
uint64 GPUResource::GetMemoryUsage() const
{
return _memoryUsage;
}
static_assert((GPU_ENABLE_RESOURCE_NAMING) == (!BUILD_RELEASE), "Update build condition on around GPUResource Name property getter/setter.");
#if GPU_ENABLE_RESOURCE_NAMING
String GPUResource::GetName() const
@@ -394,11 +392,11 @@ void GPUDevice::DumpResourcesToLog() const
output.AppendLine();
output.AppendLine();
for (int32 typeIndex = 0; typeIndex < GPUResource::ResourceType_Count; typeIndex++)
for (int32 typeIndex = 0; typeIndex < (int32)GPUResourceType::MAX; typeIndex++)
{
const auto type = static_cast<GPUResource::ResourceType>(typeIndex);
const auto type = static_cast<GPUResourceType>(typeIndex);
output.AppendFormat(TEXT("Group: {0}s"), GPUResource::ToString(type));
output.AppendFormat(TEXT("Group: {0}s"), ScriptingEnum::ToString(type));
output.AppendLine();
int32 count = 0;

View File

@@ -4,7 +4,6 @@
#include "Engine/Platform/Platform.h"
#include "Engine/Platform/CriticalSection.h"
#include "Engine/Core/Enums.h"
#include "Engine/Core/NonCopyable.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Scripting/ScriptingObject.h"
@@ -43,7 +42,15 @@ public:
/// <summary>
/// Graphics Device states that describe its lifetime.
/// </summary>
DECLARE_ENUM_6(DeviceState, Missing, Created, Ready, Removed, Disposing, Disposed);
enum class DeviceState
{
Missing = 0,
Created,
Ready,
Removed,
Disposing,
Disposed
};
/// <summary>
/// Describes a video output display mode.

View File

@@ -160,5 +160,5 @@ public:
public:
// [GPUResource]
ResourceType GetResourceType() const final override;
GPUResourceType GetResourceType() const final override;
};

View File

@@ -2,7 +2,6 @@
#pragma once
#include "Engine/Core/Enums.h"
#include "Engine/Scripting/ScriptingObject.h"
#include "Config.h"
@@ -12,23 +11,41 @@
#define SAFE_DELETE_GPU_RESOURCE(x) if (x) { (x)->DeleteObjectNow(); (x) = nullptr; }
#define SAFE_DELETE_GPU_RESOURCES(x) for (auto& e : (x)) if (e) { e->DeleteObjectNow(); e = nullptr; }
/// <summary>
/// GPU resources types.
/// </summary>
API_ENUM() enum class GPUResourceType
{
// GPU render target texture
RenderTarget = 0,
// GPU texture
Texture,
// GPU cube texture (cubemap)
CubeTexture,
// GPU volume texture (3D)
VolumeTexture,
// GPU buffer
Buffer,
// GPU shader
Shader,
// GPU pipeline state object (PSO)
PipelineState,
// GPU binding descriptor
Descriptor,
// GPU timer query
Query,
// GPU texture sampler
Sampler,
MAX
};
/// <summary>
/// The base class for all GPU resources.
/// </summary>
API_CLASS(Abstract, NoSpawn) class FLAXENGINE_API GPUResource : public ScriptingObject
{
DECLARE_SCRIPTING_TYPE_NO_SPAWN(GPUResource);
public:
/// <summary>
/// GPU Resources types.
/// </summary>
DECLARE_ENUM_10(ResourceType, RenderTarget, Texture, CubeTexture, VolumeTexture, Buffer, Shader, PipelineState, Descriptor, Query, Sampler);
/// <summary>
/// GPU Resources object types. Used to detect Texture objects from subset of Types: RenderTarget, Texture, CubeTexture, VolumeTexture which use the same API object.
/// </summary>
DECLARE_ENUM_3(ObjectType, Texture, Buffer, Other);
protected:
uint64 _memoryUsage = 0;
#if GPU_ENABLE_RESOURCE_NAMING
@@ -65,21 +82,16 @@ public:
public:
/// <summary>
/// Gets the resource type.
/// Gets the GPU resource type.
/// </summary>
virtual ResourceType GetResourceType() const = 0;
/// <summary>
/// Gets resource object type.
/// </summary>
virtual ObjectType GetObjectType() const;
API_PROPERTY() virtual GPUResourceType GetResourceType() const = 0;
/// <summary>
/// Gets amount of GPU memory used by this resource (in bytes). It's a rough estimation. GPU memory may be fragmented, compressed or sub-allocated so the actual memory pressure from this resource may vary (also depends on the current graphics backend).
/// </summary>
API_PROPERTY() uint64 GetMemoryUsage() const;
#if GPU_ENABLE_RESOURCE_NAMING
#if !BUILD_RELEASE
/// <summary>
/// Gets the resource name.
/// </summary>

View File

@@ -95,7 +95,7 @@ String GPUSwapChain::ToString() const
#endif
}
GPUResource::ResourceType GPUSwapChain::GetResourceType() const
GPUResourceType GPUSwapChain::GetResourceType() const
{
return ResourceType::Texture;
return GPUResourceType::Texture;
}

View File

@@ -160,5 +160,5 @@ public:
public:
// [GPUResource]
String ToString() const override;
ResourceType GetResourceType() const final override;
GPUResourceType GetResourceType() const final override;
};

View File

@@ -48,14 +48,8 @@ public:
{
return TEXT("TimerQuery");
}
ResourceType GetResourceType() const final override
GPUResourceType GetResourceType() const final override
{
return ResourceType::Query;
}
ObjectType GetObjectType() const final override
{
return ObjectType::Other;
return GPUResourceType::Query;
}
};

View File

@@ -251,7 +251,7 @@ bool Mesh::Load(uint32 vertices, uint32 triangles, void* vb0, void* vb1, void* v
// Create GPU buffers
#if GPU_ENABLE_RESOURCE_NAMING
#define MESH_BUFFER_NAME(postfix) GetModel()->ToString() + TEXT(postfix)
#define MESH_BUFFER_NAME(postfix) GetModel()->GetPath() + TEXT(postfix)
#else
#define MESH_BUFFER_NAME(postfix) String::Empty
#endif

View File

@@ -2,7 +2,6 @@
#pragma once
#include "Engine/Core/Enums.h"
#include "Engine/Core/Math/Packed.h"
#include "Engine/Core/Math/Vector2.h"
#include "Engine/Core/Math/Vector3.h"
@@ -23,7 +22,15 @@ struct RenderView;
/// <summary>
/// Importing model lightmap UVs source
/// </summary>
DECLARE_ENUM_6(ModelLightmapUVsSource, Disable, Generate, Channel0, Channel1, Channel2, Channel3);
enum class ModelLightmapUVsSource
{
Disable = 0,
Generate,
Channel0,
Channel1,
Channel2,
Channel3
};
/// <summary>
/// The mesh buffer types.

View File

@@ -3,7 +3,6 @@
#pragma once
#include "Engine/Core/Types/BaseTypes.h"
#include "Engine/Core/Enums.h"
#include "Engine/Graphics/Config.h"
#include "Engine/Graphics/Materials/MaterialInfo.h"
#include "../Config.h"
@@ -31,7 +30,12 @@ public:
/// <summary>
/// Different shader cache storage modes (disabled, inside asset and in project cache)
/// </summary>
DECLARE_ENUM_3(CachingMode, Disabled, AssetInternal, ProjectCache);
enum class CachingMode
{
Disabled = 0,
AssetInternal,
ProjectCache
};
/// <summary>
/// Current shaders caching mode to use

View File

@@ -23,8 +23,8 @@ public:
public:
// [GPUResource]
ResourceType GetResourceType() const override
GPUResourceType GetResourceType() const override
{
return ResourceType::Buffer;
return GPUResourceType::Buffer;
}
};

View File

@@ -190,9 +190,9 @@ GPUShaderProgram* GPUShader::GetShader(ShaderStage stage, const StringAnsiView&
return shader;
}
GPUResource::ResourceType GPUShader::GetResourceType() const
GPUResourceType GPUShader::GetResourceType() const
{
return ResourceType::Shader;
return GPUResourceType::Shader;
}
void GPUShader::OnReleaseGPU()

View File

@@ -182,7 +182,7 @@ protected:
public:
// [GPUResource]
ResourceType GetResourceType() const final override;
GPUResourceType GetResourceType() const final override;
protected:
// [GPUResource]

View File

@@ -101,14 +101,9 @@ String GPUSampler::ToString() const
#endif
}
GPUResource::ResourceType GPUSampler::GetResourceType() const
GPUResourceType GPUSampler::GetResourceType() const
{
return ResourceType::Sampler;
}
GPUResource::ObjectType GPUSampler::GetObjectType() const
{
return ObjectType::Other;
return GPUResourceType::Sampler;
}
void GPUSampler::OnReleaseGPU()

View File

@@ -43,8 +43,7 @@ protected:
public:
// [GPUResource]
String ToString() const override;
ResourceType GetResourceType() const final override;
ObjectType GetObjectType() const final override;
GPUResourceType GetResourceType() const final override;
protected:
// [GPUResource]

View File

@@ -575,18 +575,13 @@ String GPUTexture::ToString() const
#endif
}
GPUResource::ResourceType GPUTexture::GetResourceType() const
GPUResourceType GPUTexture::GetResourceType() const
{
if (IsVolume())
return ResourceType::VolumeTexture;
return GPUResourceType::VolumeTexture;
if (IsCubeMap())
return ResourceType::CubeTexture;
return IsRegularTexture() ? ResourceType::Texture : ResourceType::RenderTarget;
}
GPUResource::ObjectType GPUTexture::GetObjectType() const
{
return ObjectType::Texture;
return GPUResourceType::CubeTexture;
return IsRegularTexture() ? GPUResourceType::Texture : GPUResourceType::RenderTarget;
}
void GPUTexture::OnReleaseGPU()

View File

@@ -573,8 +573,7 @@ protected:
public:
// [GPUResource]
String ToString() const override;
ResourceType GetResourceType() const final override;
ObjectType GetObjectType() const final override;
GPUResourceType GetResourceType() const final override;
protected:
// [GPUResource]

View File

@@ -1,6 +1,7 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
#include "StreamingTexture.h"
#include "Engine/Core/Log.h"
#include "Engine/Threading/Threading.h"
#include "Engine/Streaming/StreamingGroup.h"
#include "Engine/Content/Loading/ContentLoadingManager.h"

View File

@@ -190,9 +190,9 @@ public:
public:
// [GPUResourceDX12]
ResourceType GetResourceType() const override
GPUResourceType GetResourceType() const override
{
return ResourceType::Descriptor;
return GPUResourceType::Descriptor;
}
protected:

View File

@@ -128,9 +128,9 @@ void DescriptorHeapWithSlotsDX12::ReleaseSlot(uint32 index)
value &= ~mask;
}
GPUResource::ResourceType DescriptorHeapWithSlotsDX12::GetResourceType() const
GPUResourceType DescriptorHeapWithSlotsDX12::GetResourceType() const
{
return ResourceType::Descriptor;
return GPUResourceType::Descriptor;
}
DescriptorHeapPoolDX12::DescriptorHeapPoolDX12(GPUDeviceDX12* device, D3D12_DESCRIPTOR_HEAP_TYPE type, uint32 descriptorsCountPerHeap, bool shaderVisible)

View File

@@ -87,7 +87,7 @@ public:
public:
// [GPUResourceDX12]
ResourceType GetResourceType() const final override;
GPUResourceType GetResourceType() const final override;
protected:
@@ -170,9 +170,9 @@ public:
public:
// [GPUResourceDX12]
ResourceType GetResourceType() const final override
GPUResourceType GetResourceType() const final override
{
return ResourceType::Descriptor;
return GPUResourceType::Descriptor;
}
protected:

View File

@@ -1299,25 +1299,23 @@ void GPUContextDX12::CopyResource(GPUResource* dstResource, GPUResource* srcReso
auto dstResourceDX12 = dynamic_cast<ResourceOwnerDX12*>(dstResource);
auto srcResourceDX12 = dynamic_cast<ResourceOwnerDX12*>(srcResource);
auto dstBufferDX12 = dynamic_cast<GPUBufferDX12*>(dstResource);
auto srcBufferDX12 = dynamic_cast<GPUBufferDX12*>(srcResource);
auto dstTextureDX12 = dynamic_cast<GPUTextureDX12*>(dstResource);
auto srcTextureDX12 = dynamic_cast<GPUTextureDX12*>(srcResource);
SetResourceState(dstResourceDX12, D3D12_RESOURCE_STATE_COPY_DEST);
SetResourceState(srcResourceDX12, D3D12_RESOURCE_STATE_COPY_SOURCE);
flushRBs();
auto srcType = srcResource->GetObjectType();
auto dstType = dstResource->GetObjectType();
// Buffer -> Buffer
if (srcType == GPUResource::ObjectType::Buffer && dstType == GPUResource::ObjectType::Buffer)
if (srcBufferDX12 && dstBufferDX12)
{
_commandList->CopyResource(dstResourceDX12->GetResource(), srcResourceDX12->GetResource());
}
// Texture -> Texture
else if (srcType == GPUResource::ObjectType::Texture && dstType == GPUResource::ObjectType::Texture)
else if (srcTextureDX12 && dstTextureDX12)
{
auto dstTextureDX12 = static_cast<GPUTextureDX12*>(dstResource);
auto srcTextureDX12 = static_cast<GPUTextureDX12*>(srcResource);
if (dstTextureDX12->IsStaging())
{
// Staging Texture -> Staging Texture
@@ -1388,32 +1386,26 @@ void GPUContextDX12::CopySubresource(GPUResource* dstResource, uint32 dstSubreso
{
ASSERT(dstResource && srcResource);
auto srcType = srcResource->GetObjectType();
auto dstType = dstResource->GetObjectType();
auto dstResourceDX12 = dynamic_cast<ResourceOwnerDX12*>(dstResource);
auto srcResourceDX12 = dynamic_cast<ResourceOwnerDX12*>(srcResource);
auto dstBufferDX12 = dynamic_cast<GPUBufferDX12*>(dstResource);
auto srcBufferDX12 = dynamic_cast<GPUBufferDX12*>(srcResource);
auto dstTextureDX12 = dynamic_cast<GPUTextureDX12*>(dstResource);
auto srcTextureDX12 = dynamic_cast<GPUTextureDX12*>(srcResource);
SetResourceState(dstResourceDX12, D3D12_RESOURCE_STATE_COPY_DEST);
SetResourceState(srcResourceDX12, D3D12_RESOURCE_STATE_COPY_SOURCE);
flushRBs();
// Buffer -> Buffer
if (srcType == GPUResource::ObjectType::Buffer && dstType == GPUResource::ObjectType::Buffer)
if (srcBufferDX12 && dstBufferDX12)
{
auto dstBufferDX12 = dynamic_cast<ResourceOwnerDX12*>(dstResource);
auto srcBufferDX12 = dynamic_cast<ResourceOwnerDX12*>(srcResource);
SetResourceState(dstBufferDX12, D3D12_RESOURCE_STATE_COPY_DEST);
SetResourceState(srcBufferDX12, D3D12_RESOURCE_STATE_COPY_SOURCE);
flushRBs();
uint64 bytesCount = srcResource->GetMemoryUsage();
_commandList->CopyBufferRegion(dstBufferDX12->GetResource(), 0, srcBufferDX12->GetResource(), 0, bytesCount);
}
// Texture -> Texture
else if (srcType == GPUResource::ObjectType::Texture && dstType == GPUResource::ObjectType::Texture)
else if (srcTextureDX12 && dstTextureDX12)
{
auto dstTextureDX12 = static_cast<GPUTextureDX12*>(dstResource);
auto srcTextureDX12 = static_cast<GPUTextureDX12*>(srcResource);
SetResourceState(dstTextureDX12, D3D12_RESOURCE_STATE_COPY_DEST);
SetResourceState(srcTextureDX12, D3D12_RESOURCE_STATE_COPY_SOURCE);
flushRBs();
if (srcTextureDX12->IsStaging() || dstTextureDX12->IsStaging())
{
Log::NotImplementedException(TEXT("Copy region of staging resources is not supported yet."));

View File

@@ -56,9 +56,9 @@ public:
public:
// [GPUResourceDX12]
ResourceType GetResourceType() const final override
GPUResourceType GetResourceType() const final override
{
return ResourceType::Buffer;
return GPUResourceType::Buffer;
}
// [ResourceOwnerDX12]

View File

@@ -87,7 +87,7 @@ namespace DescriptorSet
return ShaderStage::Geometry;
default:
CRASH;
return static_cast<ShaderStage>(ShaderStage_Count);
return (ShaderStage)ShaderStage_Count;
}
}

View File

@@ -5,6 +5,7 @@
#include "GPUBufferVulkan.h"
#include "GPUContextVulkan.h"
#include "RenderToolsVulkan.h"
#include "Engine/Core/Log.h"
#include "Engine/Threading/Threading.h"
#include "Engine/Graphics/Async/Tasks/GPUUploadBufferTask.h"

View File

@@ -1493,17 +1493,13 @@ void GPUContextVulkan::CopyResource(GPUResource* dstResource, GPUResource* srcRe
if (cmdBuffer->IsInsideRenderPass())
EndRenderPass();
auto dstTextureVulkan = static_cast<GPUTextureVulkan*>(dstResource);
auto srcTextureVulkan = static_cast<GPUTextureVulkan*>(srcResource);
auto dstBufferVulkan = static_cast<GPUBufferVulkan*>(dstResource);
auto srcBufferVulkan = static_cast<GPUBufferVulkan*>(srcResource);
const auto srcType = srcResource->GetObjectType();
const auto dstType = dstResource->GetObjectType();
auto dstTextureVulkan = dynamic_cast<GPUTextureVulkan*>(dstResource);
auto srcTextureVulkan = dynamic_cast<GPUTextureVulkan*>(srcResource);
auto dstBufferVulkan = dynamic_cast<GPUBufferVulkan*>(dstResource);
auto srcBufferVulkan = dynamic_cast<GPUBufferVulkan*>(srcResource);
// Buffer -> Buffer
if (srcType == GPUResource::ObjectType::Buffer && dstType == GPUResource::ObjectType::Buffer)
if (srcBufferVulkan && dstBufferVulkan)
{
// Transition resources
AddBufferBarrier(dstBufferVulkan, VK_ACCESS_TRANSFER_WRITE_BIT);
@@ -1519,7 +1515,7 @@ void GPUContextVulkan::CopyResource(GPUResource* dstResource, GPUResource* srcRe
vkCmdCopyBuffer(cmdBuffer->GetHandle(), srcBufferVulkan->GetHandle(), dstBufferVulkan->GetHandle(), 1, &bufferCopy);
}
// Texture -> Texture
else if (srcType == GPUResource::ObjectType::Texture && dstType == GPUResource::ObjectType::Texture)
else if (srcTextureVulkan && dstTextureVulkan)
{
if (dstTextureVulkan->IsStaging())
{
@@ -1632,17 +1628,13 @@ void GPUContextVulkan::CopySubresource(GPUResource* dstResource, uint32 dstSubre
if (cmdBuffer->IsInsideRenderPass())
EndRenderPass();
auto dstTextureVulkan = static_cast<GPUTextureVulkan*>(dstResource);
auto srcTextureVulkan = static_cast<GPUTextureVulkan*>(srcResource);
auto dstBufferVulkan = static_cast<GPUBufferVulkan*>(dstResource);
auto srcBufferVulkan = static_cast<GPUBufferVulkan*>(srcResource);
auto srcType = srcResource->GetObjectType();
auto dstType = dstResource->GetObjectType();
auto dstTextureVulkan = dynamic_cast<GPUTextureVulkan*>(dstResource);
auto srcTextureVulkan = dynamic_cast<GPUTextureVulkan*>(srcResource);
auto dstBufferVulkan = dynamic_cast<GPUBufferVulkan*>(dstResource);
auto srcBufferVulkan = dynamic_cast<GPUBufferVulkan*>(srcResource);
// Buffer -> Buffer
if (srcType == GPUResource::ObjectType::Buffer && dstType == GPUResource::ObjectType::Buffer)
if (srcBufferVulkan && dstBufferVulkan)
{
ASSERT(dstSubresource == 0 && srcSubresource == 0);
@@ -1660,7 +1652,7 @@ void GPUContextVulkan::CopySubresource(GPUResource* dstResource, uint32 dstSubre
vkCmdCopyBuffer(cmdBuffer->GetHandle(), srcBufferVulkan->GetHandle(), dstBufferVulkan->GetHandle(), 1, &bufferCopy);
}
// Texture -> Texture
else if (srcType == GPUResource::ObjectType::Texture && dstType == GPUResource::ObjectType::Texture)
else if (srcTextureVulkan && dstTextureVulkan)
{
const int32 dstMipMaps = dstTextureVulkan->MipLevels();
const int32 dstMipIndex = dstSubresource % dstMipMaps;

View File

@@ -67,9 +67,9 @@ public:
public:
// [GPUResourceVulkan]
ResourceType GetResourceType() const final override
GPUResourceType GetResourceType() const final override
{
return ResourceType::Buffer;
return GPUResourceType::Buffer;
}
// [ResourceOwnerVulkan]

View File

@@ -3,7 +3,7 @@
#pragma once
#include "Engine/Core/Config.h"
#include "Engine/Core/Enums.h"
#include "Engine/Core/Types/BaseTypes.h"
// Level system types
class SceneObject;

View File

@@ -2,7 +2,6 @@
#pragma once
#include "Engine/Core/Enums.h"
#include "Engine/Core/Config.h"
#include "Engine/Core/Math/Vector2.h"
#include "Engine/Core/Math/Vector3.h"

View File

@@ -119,9 +119,8 @@ public:
public:
/// <summary>
/// Gets shader function meta stage type
/// Gets shader function meta stage type.
/// </summary>
/// <returns>Shader Stage type</returns>
virtual ShaderStage GetStage() const = 0;
};

View File

@@ -3,6 +3,7 @@
#include "TerrainPatch.h"
#include "Terrain.h"
#include "Engine/Serialization/Serialization.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Math/Color32.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Physics/Physics.h"

View File

@@ -35,7 +35,7 @@ void MainThreadTask::RunAll(float dt)
String MainThreadTask::ToString() const
{
return String::Format(TEXT("Main Thread Task ({0})"), ::ToString(GetState()));
return String::Format(TEXT("Main Thread Task ({0})"), (int32)GetState());
}
void MainThreadTask::Enqueue()

View File

@@ -13,7 +13,15 @@
/// <summary>
/// Represents the current stage in the lifecycle of a Task.
/// </summary>
DECLARE_ENUM_EX_6(TaskState, int64, 0, Created, Failed, Canceled, Queued, Running, Finished);
enum class TaskState : int64
{
Created = 0,
Failed,
Canceled,
Queued,
Running,
Finished
};
/// <summary>
/// Represents an asynchronous operation.

View File

@@ -7,6 +7,7 @@
#include "ConcurrentTaskQueue.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Math/Math.h"
#include "Engine/Core/Types/String.h"
#include "Engine/Engine/Globals.h"
#include "Engine/Engine/EngineService.h"
#include "Engine/Platform/ConditionVariable.h"
@@ -27,6 +28,11 @@ namespace ThreadPoolImpl
CriticalSection JobsMutex;
}
String ThreadPoolTask::ToString() const
{
return String::Format(TEXT("Thread Pool Task ({0})"), (int32)GetState());
}
void ThreadPoolTask::Enqueue()
{
ThreadPoolImpl::Jobs.Add(this);

View File

@@ -3,7 +3,6 @@
#pragma once
#include "Task.h"
#include "Engine/Core/Types/String.h"
class ThreadPool;
@@ -28,10 +27,7 @@ protected:
public:
// [Task]
String ToString() const override
{
return String::Format(TEXT("Thread Pool Task ({0})"), ::ToString(GetState()));
}
String ToString() const override;
protected:

View File

@@ -1,6 +1,7 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
#include "Screenshot.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Math/Math.h"
#include "Engine/Graphics/RenderTask.h"
#include "Engine/Platform/FileSystem.h"