Cleanup some headers in Graphics module

This commit is contained in:
2021-06-18 16:38:44 +02:00
parent f5a6a18232
commit 94f50ce8cb
11 changed files with 58 additions and 53 deletions
+3 -3
View File
@@ -2,12 +2,13 @@
#pragma once
#include "Engine/Core/Collections/Array.h"
#include "GPUBuffer.h"
/// <summary>
/// Dynamic GPU buffer that allows to update and use GPU data (index/vertex/other) during single frame (supports dynamic resizing)
/// </summary>
class FLAXENGINE_API DynamicBuffer : public NonCopyable
class FLAXENGINE_API DynamicBuffer
{
protected:
@@ -16,6 +17,7 @@ protected:
uint32 _stride;
public:
NON_COPYABLE(DynamicBuffer);
/// <summary>
/// Init
@@ -45,8 +47,6 @@ public:
return _buffer;
}
public:
/// <summary>
/// Clear data (begin for writing)
/// </summary>
+36
View File
@@ -155,6 +155,42 @@ GPUPipelineState::Description GPUPipelineState::Description::DefaultFullscreenTr
BlendingMode::Opaque,
};
GPUResource::GPUResource()
: PersistentScriptingObject(SpawnParams(Guid::New(), GPUResource::TypeInitializer))
{
}
GPUResource::GPUResource(const SpawnParams& params)
: PersistentScriptingObject(params)
{
}
GPUResource::~GPUResource()
{
#if !BUILD_RELEASE
ASSERT(_memoryUsage == 0);
#endif
}
GPUResource::ObjectType GPUResource::GetObjectType() const
{
return ObjectType::Other;
}
uint64 GPUResource::GetMemoryUsage() const
{
return _memoryUsage;
}
#if GPU_ENABLE_RESOURCE_NAMING
String GPUResource::GetName() const
{
return String::Empty;
}
#endif
void GPUResource::ReleaseGPU()
{
if (_memoryUsage != 0)
+10 -40
View File
@@ -2,8 +2,7 @@
#pragma once
#include "Engine/Core/Common.h"
#include "Engine/Core/NonCopyable.h"
#include "Engine/Core/Enums.h"
#include "Engine/Scripting/ScriptingObject.h"
#include "Config.h"
@@ -15,7 +14,7 @@
/// <summary>
/// The base class for all GPU resources.
/// </summary>
API_CLASS(Abstract, NoSpawn) class FLAXENGINE_API GPUResource : public PersistentScriptingObject, public NonCopyable
API_CLASS(Abstract, NoSpawn) class FLAXENGINE_API GPUResource : public PersistentScriptingObject
{
DECLARE_SCRIPTING_TYPE_NO_SPAWN(GPUResource);
public:
@@ -35,33 +34,23 @@ protected:
uint64 _memoryUsage = 0;
public:
NON_COPYABLE(GPUResource);
/// <summary>
/// Initializes a new instance of the <see cref="GPUResource"/> class.
/// </summary>
GPUResource()
: PersistentScriptingObject(SpawnParams(Guid::New(), GPUResource::TypeInitializer))
{
}
GPUResource();
/// <summary>
/// Initializes a new instance of the <see cref="GPUResource"/> class.
/// </summary>
/// <param name="params">The object initialization parameters.</param>
GPUResource(const SpawnParams& params)
: PersistentScriptingObject(params)
{
}
GPUResource(const SpawnParams& params);
/// <summary>
/// Finalizes an instance of the <see cref="GPUResource"/> class.
/// </summary>
virtual ~GPUResource()
{
#if !BUILD_RELEASE
ASSERT(_memoryUsage == 0);
#endif
}
virtual ~GPUResource();
public:
@@ -83,29 +72,19 @@ public:
/// <summary>
/// Gets resource object type.
/// </summary>
virtual ObjectType GetObjectType() const
{
return ObjectType::Other;
}
virtual ObjectType GetObjectType() const;
/// <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).
/// 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() FORCE_INLINE uint64 GetMemoryUsage() const
{
return _memoryUsage;
}
API_PROPERTY() uint64 GetMemoryUsage() const;
#if GPU_ENABLE_RESOURCE_NAMING
/// <summary>
/// Gets the resource name.
/// </summary>
virtual String GetName() const
{
return String::Empty;
}
virtual String GetName() const;
#endif
@@ -165,9 +144,6 @@ public:
, _name(name.Get(), name.Length())
#endif
{
ASSERT(device);
// Register
device->Resources.Add(this);
}
@@ -176,7 +152,6 @@ public:
/// </summary>
virtual ~GPUResourceBase()
{
// Unregister
if (_device)
_device->Resources.Remove(this);
}
@@ -186,7 +161,6 @@ public:
/// <summary>
/// Gets the graphics device.
/// </summary>
/// <returns>The device.</returns>
FORCE_INLINE DeviceType* GetDevice() const
{
return _device;
@@ -203,10 +177,7 @@ public:
#endif
void OnDeviceDispose() override
{
// Base
GPUResource::OnDeviceDispose();
// Unlink device handle
_device = nullptr;
}
};
@@ -234,6 +205,5 @@ public:
/// <summary>
/// Gets the native pointer to the underlying view. It's a platform-specific handle.
/// </summary>
/// <returns>The pointer.</returns>
virtual void* GetNativePtr() const = 0;
};
@@ -3,6 +3,7 @@
#pragma once
#include "IMaterial.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Graphics/GPUPipelineState.h"
#include "Engine/Renderer/Config.h"
+1
View File
@@ -3,6 +3,7 @@
#pragma once
#include "Engine/Core/Math/Viewport.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Scripting/ScriptingObject.h"
#include "Engine/Graphics/Textures/GPUTexture.h"
@@ -3,6 +3,7 @@
#include "GPUShader.h"
#include "GPUConstantBuffer.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Math/Math.h"
#include "Engine/Serialization/MemoryReadStream.h"
GPUShaderProgramsContainer::GPUShaderProgramsContainer()
+1 -1
View File
@@ -167,7 +167,7 @@ public:
/// <returns>The Constant Buffer object.</returns>
API_FUNCTION() FORCE_INLINE GPUConstantBuffer* GetCB(int32 slot) const
{
ASSERT_LOW_LAYER(Math::IsInRange<int32>(slot, 0, ARRAY_COUNT(_constantBuffers) - 1));
ASSERT_LOW_LAYER(slot >= 0 && slot < ARRAY_COUNT(_constantBuffers));
return _constantBuffers[slot];
}
@@ -4,6 +4,7 @@
#if GRAPHICS_API_DIRECTX12
#include "Engine/Core/Collections/Array.h"
#include "Engine/Graphics/GPUResource.h"
#include "../IncludeDirectXHeaders.h"
+1 -8
View File
@@ -3,6 +3,7 @@
#pragma once
#include "Engine/Core/Collections/Array.h"
#include "Engine/Core/Math/Vector2.h"
#include "Engine/Content/Assets/Texture.h"
#include "Engine/Graphics/Textures/GPUTexture.h"
#include "Engine/Utilities/RectPack.h"
@@ -91,7 +92,6 @@ public:
/// <summary>
/// Gets the atlas width.
/// </summary>
/// <returns>The width.</returns>
FORCE_INLINE uint32 GetWidth() const
{
return _width;
@@ -100,7 +100,6 @@ public:
/// <summary>
/// Gets the atlas height.
/// </summary>
/// <returns>The height.</returns>
FORCE_INLINE uint32 GetHeight() const
{
return _height;
@@ -109,7 +108,6 @@ public:
/// <summary>
/// Gets the atlas size.
/// </summary>
/// <returns>The size.</returns>
FORCE_INLINE Vector2 GetSize() const
{
return Vector2(static_cast<float>(_width), static_cast<float>(_height));
@@ -118,9 +116,6 @@ public:
/// <summary>
/// Determines whether this atlas is dirty and data need to be flushed.
/// </summary>
/// <returns>
/// <c>true</c> if this atlas is dirty; otherwise, <c>false</c>.
/// </returns>
FORCE_INLINE bool IsDirty() const
{
return _isDirty;
@@ -129,7 +124,6 @@ public:
/// <summary>
/// Gets padding style for textures in the atlas.
/// </summary>
/// <returns>The padding style.</returns>
FORCE_INLINE PaddingStyle GetPaddingStyle() const
{
return _paddingStyle;
@@ -138,7 +132,6 @@ public:
/// <summary>
/// Gets amount of pixels to pad textures inside an atlas.
/// </summary>
/// <returns>The padding amount.</returns>
uint32 GetPaddingAmount() const;
public:
+2 -1
View File
@@ -6,12 +6,13 @@
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Graphics/GPUBuffer.h"
#include "Engine/Core/Math/Color32.h"
#include "Engine/Core/Collections/ChunkedArray.h"
#include "Engine/Core/Collections/Dictionary.h"
#include "Engine/Content/Content.h"
#include "Engine/Engine/EngineService.h"
#include "Engine/Content/Assets/MaterialBase.h"
#include "Engine/Content/AssetReference.h"
#include "Engine/Renderer/DrawCall.h"
#include "Engine/Core/Collections/ChunkedArray.h"
// Must match structure defined in Terrain.shader
struct TerrainVertex
@@ -16,6 +16,7 @@
#include "Engine/Graphics/PixelFormatExtensions.h"
#if USE_EDITOR
#include "Engine/Core/Collections/Dictionary.h"
namespace
{
Dictionary<String, bool> TexturesHasAlphaCache;