diff --git a/Source/Editor/Content/PreviewsCache.cpp b/Source/Editor/Content/PreviewsCache.cpp
index e05f16600..a284f9734 100644
--- a/Source/Editor/Content/PreviewsCache.cpp
+++ b/Source/Editor/Content/PreviewsCache.cpp
@@ -36,7 +36,7 @@ bool PreviewsCache::FlushTask::Run()
return true;
}
auto mipData = _data.GetData(0, 0);
- ASSERT(mipData->DepthPitch == CalculateTextureMemoryUsage(_cache->GetTexture()->Format(), _cache->Width(), _cache->Height(), 1));
+ ASSERT(mipData->DepthPitch == RenderTools::CalculateTextureMemoryUsage(_cache->GetTexture()->Format(), _cache->Width(), _cache->Height(), 1));
ScopeLock lock(_cache->Locker);
@@ -250,7 +250,7 @@ CreateAssetResult PreviewsCache::create(CreateAssetContext& context)
context.Data.CustomData.Copy(&textureHeader);
// Create blank image (chunk 0)
- uint64 imageSize = CalculateTextureMemoryUsage(ASSETS_ICONS_ATLAS_FORMAT, ASSETS_ICONS_ATLAS_SIZE, ASSETS_ICONS_ATLAS_SIZE, 1);
+ uint64 imageSize = RenderTools::CalculateTextureMemoryUsage(ASSETS_ICONS_ATLAS_FORMAT, ASSETS_ICONS_ATLAS_SIZE, ASSETS_ICONS_ATLAS_SIZE, 1);
ASSERT(imageSize <= MAX_int32);
if (context.AllocateChunk(0))
return CreateAssetResult::CannotAllocateChunk;
diff --git a/Source/Engine/Foliage/FoliageInstance.h b/Source/Engine/Foliage/FoliageInstance.h
index a4dd2b25b..2968d6372 100644
--- a/Source/Engine/Foliage/FoliageInstance.h
+++ b/Source/Engine/Foliage/FoliageInstance.h
@@ -10,7 +10,7 @@
///
/// Foliage instanced mesh instance. Packed data with very little of logic. Managed by the foliage chunks and foliage actor itself.
///
-API_STRUCT(NoPod) struct FoliageInstance
+API_STRUCT(NoPod) struct FLAXENGINE_API FoliageInstance
{
DECLARE_SCRIPTING_TYPE_NO_SPAWN(FoliageInstance);
diff --git a/Source/Engine/Graphics/RenderTools.cpp b/Source/Engine/Graphics/RenderTools.cpp
index 8a6d12349..12b3b872d 100644
--- a/Source/Engine/Graphics/RenderTools.cpp
+++ b/Source/Engine/Graphics/RenderTools.cpp
@@ -395,6 +395,35 @@ void RenderTools::UpdateModelLODTransition(byte& lodTransition)
lodTransition = static_cast(Math::Min(newProgress, 255));
}
+uint64 RenderTools::CalculateTextureMemoryUsage(PixelFormat format, int32 width, int32 height, int32 mipLevels)
+{
+ uint64 result = 0;
+
+ if (mipLevels == 0)
+ mipLevels = 69;
+
+ uint32 rowPitch, slicePitch;
+ while (mipLevels > 0 && (width >= 1 || height >= 1))
+ {
+ ComputePitch(format, width, height, rowPitch, slicePitch);
+ result += slicePitch;
+
+ if (width > 1)
+ width >>= 1;
+ if (height > 1)
+ height >>= 1;
+
+ mipLevels--;
+ }
+
+ return result;
+}
+
+uint64 RenderTools::CalculateTextureMemoryUsage(PixelFormat format, int32 width, int32 height, int32 depth, int32 mipLevels)
+{
+ return CalculateTextureMemoryUsage(format, width, height, mipLevels) * depth;
+}
+
float RenderTools::ComputeBoundsScreenRadiusSquared(const Vector3& origin, float radius, const Vector3& viewOrigin, const Matrix& projectionMatrix)
{
const float screenMultiple = 0.5f * Math::Max(projectionMatrix.Values[0][0], projectionMatrix.Values[1][1]);
@@ -452,35 +481,6 @@ int32 RenderTools::ComputeSkinnedModelLOD(const SkinnedModel* model, const Vecto
return 0;
}
-uint64 CalculateTextureMemoryUsage(PixelFormat format, int32 width, int32 height, int32 mipLevels)
-{
- uint64 result = 0;
-
- if (mipLevels == 0)
- mipLevels = 69;
-
- uint32 rowPitch, slicePitch;
- while (mipLevels > 0 && (width >= 1 || height >= 1))
- {
- RenderTools::ComputePitch(format, width, height, rowPitch, slicePitch);
- result += slicePitch;
-
- if (width > 1)
- width >>= 1;
- if (height > 1)
- height >>= 1;
-
- mipLevels--;
- }
-
- return result;
-}
-
-uint64 CalculateTextureMemoryUsage(PixelFormat format, int32 width, int32 height, int32 depth, int32 mipLevels)
-{
- return CalculateTextureMemoryUsage(format, width, height, mipLevels) * depth;
-}
-
int32 MipLevelsCount(int32 width, bool useMipLevels)
{
if (!useMipLevels)
diff --git a/Source/Engine/Graphics/RenderTools.h b/Source/Engine/Graphics/RenderTools.h
index bbfe07e0b..84f4d52f5 100644
--- a/Source/Engine/Graphics/RenderTools.h
+++ b/Source/Engine/Graphics/RenderTools.h
@@ -18,7 +18,7 @@ PACK_STRUCT(struct QuadShaderData
///
/// Set of utilities for rendering.
///
-API_CLASS(Static) class RenderTools
+API_CLASS(Static) class FLAXENGINE_API RenderTools
{
DECLARE_SCRIPTING_TYPE_NO_SPAWN(RenderTools);
public:
@@ -56,6 +56,8 @@ public:
public:
static void UpdateModelLODTransition(byte& lodTransition);
+ static uint64 CalculateTextureMemoryUsage(PixelFormat format, int32 width, int32 height, int32 mipLevels);
+ static uint64 CalculateTextureMemoryUsage(PixelFormat format, int32 width, int32 height, int32 depth, int32 mipLevels);
///
/// Computes the bounds screen radius squared.
@@ -110,23 +112,6 @@ public:
}
};
-// Get texture memory usage
-// @param format Surface pixels format type
-// @param width Width in pixels
-// @param height Height in pixels
-// @param mipLevels Amount of mip levels
-// @returns Memory usage in bytes
-extern uint64 CalculateTextureMemoryUsage(PixelFormat format, int32 width, int32 height, int32 mipLevels);
-
-// Get texture memory usage
-// @param format Surface pixels format type
-// @param width Width in pixels
-// @param height Height in pixels
-// @param depth Depth in pixels
-// @param mipLevels Amount of mip levels
-// @returns Memory usage in bytes
-extern uint64 CalculateTextureMemoryUsage(PixelFormat format, int32 width, int32 height, int32 depth, int32 mipLevels);
-
// Calculate mip levels count for a texture 1D
// @param width Most detailed mip width
// @param useMipLevels True if use mip levels, otherwise false (use only 1 mip)
diff --git a/Source/Engine/Graphics/Textures/GPUTexture.cpp b/Source/Engine/Graphics/Textures/GPUTexture.cpp
index 106dacaac..4d02f5b5c 100644
--- a/Source/Engine/Graphics/Textures/GPUTexture.cpp
+++ b/Source/Engine/Graphics/Textures/GPUTexture.cpp
@@ -561,7 +561,7 @@ bool GPUTexture::Resize(int32 width, int32 height, int32 depth)
uint64 GPUTexture::calculateMemoryUsage() const
{
- return CalculateTextureMemoryUsage(Format(), Width(), Height(), Depth(), MipLevels()) * ArraySize();
+ return RenderTools::CalculateTextureMemoryUsage(Format(), Width(), Height(), Depth(), MipLevels()) * ArraySize();
}
String GPUTexture::ToString() const
diff --git a/Source/Engine/Graphics/Textures/StreamingTexture.cpp b/Source/Engine/Graphics/Textures/StreamingTexture.cpp
index 87ad4d048..45a11d52c 100644
--- a/Source/Engine/Graphics/Textures/StreamingTexture.cpp
+++ b/Source/Engine/Graphics/Textures/StreamingTexture.cpp
@@ -144,7 +144,7 @@ void StreamingTexture::UnloadTexture()
uint64 StreamingTexture::GetTotalMemoryUsage() const
{
const uint64 arraySize = _header.IsCubeMap ? 6 : 1;
- return CalculateTextureMemoryUsage(_header.Format, _header.Width, _header.Height, _header.MipLevels) * arraySize;
+ return RenderTools::CalculateTextureMemoryUsage(_header.Format, _header.Width, _header.Height, _header.MipLevels) * arraySize;
}
String StreamingTexture::ToString() const
diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp
index e9d83bfc3..4fdf02636 100644
--- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp
+++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp
@@ -231,9 +231,9 @@ bool GPUSwapChainDX11::Resize(int32 width, int32 height)
_width = width;
_height = height;
#if PLATFORM_WINDOWS
- _memoryUsage = CalculateTextureMemoryUsage(RenderToolsDX::ToPixelFormat(swapChainDesc.BufferDesc.Format), _width, _height, 1) * swapChainDesc.BufferCount;
+ _memoryUsage = RenderTools::CalculateTextureMemoryUsage(RenderToolsDX::ToPixelFormat(swapChainDesc.BufferDesc.Format), _width, _height, 1) * swapChainDesc.BufferCount;
#else
- _memoryUsage = CalculateTextureMemoryUsage(RenderToolsDX::ToPixelFormat(swapChainDesc.Format), _width, _height, 1) * swapChainDesc.BufferCount;
+ _memoryUsage = RenderTools::CalculateTextureMemoryUsage(RenderToolsDX::ToPixelFormat(swapChainDesc.Format), _width, _height, 1) * swapChainDesc.BufferCount;
#endif
getBackBuffer();
diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp
index 90ba88210..51302e901 100644
--- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp
+++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp
@@ -231,7 +231,7 @@ bool GPUSwapChainDX12::Resize(int32 width, int32 height)
_currentFrameIndex = _swapChain->GetCurrentBackBufferIndex();
_width = width;
_height = height;
- _memoryUsage = CalculateTextureMemoryUsage(_format, _width, _height, 1) * swapChainDesc.BufferCount;
+ _memoryUsage = RenderTools::CalculateTextureMemoryUsage(_format, _width, _height, 1) * swapChainDesc.BufferCount;
getBackBuffer();
#endif
diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp
index fa6c62a67..df310cc5c 100644
--- a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp
+++ b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp
@@ -415,7 +415,7 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height)
}
// Calculate memory usage
- _memoryUsage = CalculateTextureMemoryUsage(_format, _width, _height, 1) * _backBuffers.Count();
+ _memoryUsage = RenderTools::CalculateTextureMemoryUsage(_format, _width, _height, 1) * _backBuffers.Count();
return false;
}
diff --git a/Source/Engine/Level/Scene/SceneLightmapsData.h b/Source/Engine/Level/Scene/SceneLightmapsData.h
index 8d5b26787..7dc465af2 100644
--- a/Source/Engine/Level/Scene/SceneLightmapsData.h
+++ b/Source/Engine/Level/Scene/SceneLightmapsData.h
@@ -52,7 +52,7 @@ public:
///
/// Lightmap index
/// Lightmap or null if missing or not ready
- Lightmap* GetReadyLightmap(int32 index);
+ FLAXENGINE_API Lightmap* GetReadyLightmap(int32 index);
///
/// Gets lightmaps array
diff --git a/Source/Engine/Renderer/RenderList.h b/Source/Engine/Renderer/RenderList.h
index 3d372b09e..10b51448d 100644
--- a/Source/Engine/Renderer/RenderList.h
+++ b/Source/Engine/Renderer/RenderList.h
@@ -207,8 +207,8 @@ class RenderListAllocation
{
public:
- static void* Allocate(uintptr size);
- static void Free(void* ptr, uintptr size);
+ static FLAXENGINE_API void* Allocate(uintptr size);
+ static FLAXENGINE_API void Free(void* ptr, uintptr size);
template
class Data