Cleanup some headers in Graphics module
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user