Rename RenderListAllocation into RendererAllocation
This commit is contained in:
@@ -169,7 +169,7 @@ private:
|
||||
};
|
||||
|
||||
typedef Array<struct BatchedDrawCall, InlinedAllocation<8>> DrawCallsList;
|
||||
typedef Dictionary<DrawKey, struct BatchedDrawCall, class RenderListAllocation> BatchedDrawCalls;
|
||||
typedef Dictionary<DrawKey, struct BatchedDrawCall, class RendererAllocation> BatchedDrawCalls;
|
||||
void DrawInstance(RenderContext& renderContext, FoliageInstance& instance, FoliageType& type, Model* model, int32 lod, float lodDitherFactor, DrawCallsList* drawCallsLists, BatchedDrawCalls& result) const;
|
||||
void DrawCluster(RenderContext& renderContext, FoliageCluster* cluster, FoliageType& type, DrawCallsList* drawCallsLists, BatchedDrawCalls& result) const;
|
||||
#else
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Engine/Platform/CriticalSection.h"
|
||||
#include "Engine/Scripting/ScriptingObjectReference.h"
|
||||
#include "Engine/Scripting/ScriptingType.h"
|
||||
#include "Engine/Renderer/RendererAllocation.h"
|
||||
#include "PostProcessBase.h"
|
||||
#include "RenderView.h"
|
||||
|
||||
@@ -448,7 +449,7 @@ API_STRUCT(NoDefault) struct RenderContextBatch
|
||||
/// <summary>
|
||||
/// The all render views collection for the current rendering (main view, shadow projections, etc.).
|
||||
/// </summary>
|
||||
API_FIELD() Array<RenderContext> Contexts;
|
||||
API_FIELD() Array<RenderContext, RendererAllocation> Contexts;
|
||||
|
||||
RenderContextBatch() = default;
|
||||
RenderContextBatch(SceneRenderTask* task);
|
||||
|
||||
@@ -48,7 +48,7 @@ void SceneRendering::Draw(RenderContextBatch& renderContextBatch, DrawCategory c
|
||||
auto& list = Actors[(int32)category];
|
||||
|
||||
// Setup frustum data
|
||||
Array<BoundingFrustum, RenderListAllocation> frustumsData;
|
||||
Array<BoundingFrustum, RendererAllocation> frustumsData;
|
||||
BoundingFrustum* frustums = &view.CullingFrustum;
|
||||
int32 frustumsCount = renderContextBatch.Contexts.Count();
|
||||
if (frustumsCount != 1)
|
||||
|
||||
@@ -110,7 +110,7 @@ void RendererSkyLightData::SetupLightData(LightData* data, bool useShadow) const
|
||||
data->RadiusInv = 1.0f / Radius;
|
||||
}
|
||||
|
||||
void* RenderListAllocation::Allocate(uintptr size)
|
||||
void* RendererAllocation::Allocate(uintptr size)
|
||||
{
|
||||
void* result = nullptr;
|
||||
for (int32 i = 0; i < MemPool.Count(); i++)
|
||||
@@ -129,7 +129,7 @@ void* RenderListAllocation::Allocate(uintptr size)
|
||||
return result;
|
||||
}
|
||||
|
||||
void RenderListAllocation::Free(void* ptr, uintptr size)
|
||||
void RendererAllocation::Free(void* ptr, uintptr size)
|
||||
{
|
||||
MemPool.Add({ ptr, size });
|
||||
}
|
||||
@@ -326,7 +326,7 @@ void RenderList::RunCustomPostFxPass(GPUContext* context, RenderContext& renderC
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderList::HasAnyPostFx(RenderContext& renderContext, PostProcessEffectLocation postProcess) const
|
||||
bool RenderList::HasAnyPostFx(const RenderContext& renderContext, PostProcessEffectLocation postProcess) const
|
||||
{
|
||||
if (renderContext.View.Flags & ViewFlags::CustomPostProcess)
|
||||
{
|
||||
@@ -342,7 +342,7 @@ bool RenderList::HasAnyPostFx(RenderContext& renderContext, PostProcessEffectLoc
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RenderList::HasAnyPostFx(RenderContext& renderContext, MaterialPostFxLocation materialPostFx) const
|
||||
bool RenderList::HasAnyPostFx(const RenderContext& renderContext, MaterialPostFxLocation materialPostFx) const
|
||||
{
|
||||
for (int32 i = 0; i < Settings.PostFxMaterials.Materials.Count(); i++)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Engine/Graphics/DynamicBuffer.h"
|
||||
#include "Engine/Scripting/ScriptingObject.h"
|
||||
#include "DrawCall.h"
|
||||
#include "RendererAllocation.h"
|
||||
|
||||
enum class StaticFlags;
|
||||
class RenderBuffers;
|
||||
@@ -220,89 +221,10 @@ struct DrawBatch
|
||||
}
|
||||
};
|
||||
|
||||
class RenderListAllocation
|
||||
{
|
||||
public:
|
||||
static FLAXENGINE_API void* Allocate(uintptr size);
|
||||
static FLAXENGINE_API void Free(void* ptr, uintptr size);
|
||||
|
||||
template<typename T>
|
||||
class Data
|
||||
{
|
||||
T* _data = nullptr;
|
||||
uintptr _size;
|
||||
|
||||
public:
|
||||
FORCE_INLINE Data()
|
||||
{
|
||||
}
|
||||
|
||||
FORCE_INLINE ~Data()
|
||||
{
|
||||
if (_data)
|
||||
RenderListAllocation::Free(_data, _size);
|
||||
}
|
||||
|
||||
FORCE_INLINE T* Get()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
FORCE_INLINE const T* Get() const
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
FORCE_INLINE int32 CalculateCapacityGrow(int32 capacity, int32 minCapacity) const
|
||||
{
|
||||
capacity = capacity ? capacity * 2 : 64;
|
||||
if (capacity < minCapacity)
|
||||
capacity = minCapacity;
|
||||
return capacity;
|
||||
}
|
||||
|
||||
FORCE_INLINE void Allocate(uint64 capacity)
|
||||
{
|
||||
_size = capacity * sizeof(T);
|
||||
_data = (T*)RenderListAllocation::Allocate(_size);
|
||||
}
|
||||
|
||||
FORCE_INLINE void Relocate(uint64 capacity, int32 oldCount, int32 newCount)
|
||||
{
|
||||
T* newData = capacity != 0 ? (T*)RenderListAllocation::Allocate(capacity * sizeof(T)) : nullptr;
|
||||
if (oldCount)
|
||||
{
|
||||
if (newCount > 0)
|
||||
Memory::MoveItems(newData, _data, newCount);
|
||||
Memory::DestructItems(_data, oldCount);
|
||||
}
|
||||
if (_data)
|
||||
RenderListAllocation::Free(_data, _size);
|
||||
_data = newData;
|
||||
_size = capacity * sizeof(T);
|
||||
}
|
||||
|
||||
FORCE_INLINE void Free()
|
||||
{
|
||||
if (_data)
|
||||
{
|
||||
RenderListAllocation::Free(_data, _size);
|
||||
_data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE void Swap(Data& other)
|
||||
{
|
||||
::Swap(_data, other._data);
|
||||
::Swap(_size, other._size);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct BatchedDrawCall
|
||||
{
|
||||
DrawCall DrawCall;
|
||||
Array<struct InstanceData, RenderListAllocation> Instances;
|
||||
Array<struct InstanceData, RendererAllocation> Instances;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
85
Source/Engine/Renderer/RendererAllocation.h
Normal file
85
Source/Engine/Renderer/RendererAllocation.h
Normal file
@@ -0,0 +1,85 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Core/Memory/Memory.h"
|
||||
#include "Engine/Core/Types/BaseTypes.h"
|
||||
|
||||
class RendererAllocation
|
||||
{
|
||||
public:
|
||||
static FLAXENGINE_API void* Allocate(uintptr size);
|
||||
static FLAXENGINE_API void Free(void* ptr, uintptr size);
|
||||
|
||||
template<typename T>
|
||||
class Data
|
||||
{
|
||||
T* _data = nullptr;
|
||||
uintptr _size;
|
||||
|
||||
public:
|
||||
FORCE_INLINE Data()
|
||||
{
|
||||
}
|
||||
|
||||
FORCE_INLINE ~Data()
|
||||
{
|
||||
if (_data)
|
||||
RendererAllocation::Free(_data, _size);
|
||||
}
|
||||
|
||||
FORCE_INLINE T* Get()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
FORCE_INLINE const T* Get() const
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
FORCE_INLINE int32 CalculateCapacityGrow(int32 capacity, int32 minCapacity) const
|
||||
{
|
||||
capacity = capacity ? capacity * 2 : 64;
|
||||
if (capacity < minCapacity)
|
||||
capacity = minCapacity;
|
||||
return capacity;
|
||||
}
|
||||
|
||||
FORCE_INLINE void Allocate(uint64 capacity)
|
||||
{
|
||||
_size = capacity * sizeof(T);
|
||||
_data = (T*)RendererAllocation::Allocate(_size);
|
||||
}
|
||||
|
||||
FORCE_INLINE void Relocate(uint64 capacity, int32 oldCount, int32 newCount)
|
||||
{
|
||||
T* newData = capacity != 0 ? (T*)RendererAllocation::Allocate(capacity * sizeof(T)) : nullptr;
|
||||
if (oldCount)
|
||||
{
|
||||
if (newCount > 0)
|
||||
Memory::MoveItems(newData, _data, newCount);
|
||||
Memory::DestructItems(_data, oldCount);
|
||||
}
|
||||
if (_data)
|
||||
RendererAllocation::Free(_data, _size);
|
||||
_data = newData;
|
||||
_size = capacity * sizeof(T);
|
||||
}
|
||||
|
||||
FORCE_INLINE void Free()
|
||||
{
|
||||
if (_data)
|
||||
{
|
||||
RendererAllocation::Free(_data, _size);
|
||||
_data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE void Swap(Data& other)
|
||||
{
|
||||
::Swap(_data, other._data);
|
||||
::Swap(_size, other._size);
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -588,8 +588,8 @@ void VolumetricFogPass::Render(RenderContext& renderContext)
|
||||
GPUTextureView* localShadowedLightScattering = nullptr;
|
||||
{
|
||||
// Get lights to render
|
||||
Array<const RendererPointLightData*, InlinedAllocation<64, RenderListAllocation>> pointLights;
|
||||
Array<const RendererSpotLightData*, InlinedAllocation<64, RenderListAllocation>> spotLights;
|
||||
Array<const RendererPointLightData*, InlinedAllocation<64, RendererAllocation>> pointLights;
|
||||
Array<const RendererSpotLightData*, InlinedAllocation<64, RendererAllocation>> spotLights;
|
||||
for (int32 i = 0; i < renderContext.List->PointLights.Count(); i++)
|
||||
{
|
||||
const auto& light = renderContext.List->PointLights[i];
|
||||
|
||||
Reference in New Issue
Block a user