Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::LightPool Class Referencefinal

#include <LightPool.h>

+ Inheritance diagram for Divide::LightPool:

Classes

struct  CSMShadowProperties
 
struct  LightProperties
 
struct  MovingVolume
 
struct  PointShadowProperties
 
struct  SceneData
 
struct  ShadowLightList
 
struct  ShadowProperties
 
struct  SpotShadowProperties
 

Public Types

using LightList = eastl::fixed_vector< Light *, 32u, true >
 

Public Member Functions

 LightPool (Scene &parentScene, PlatformContext &context)
 
 ~LightPool () override
 
bool addLight (Light &light)
 Add a new light to the manager.
 
bool removeLight (const Light &light)
 remove a light from the manager
 
void toggleLightType (const LightType type) noexcept
 disable or enable a specific light type
 
void toggleLightType (const LightType type, const bool state) noexcept
 
bool lightTypeEnabled (const LightType type) const noexcept
 
U32 getActiveLightCount (const RenderStage stage, const LightType type) const noexcept
 Retrieve the number of active lights in the scene;.
 
bool clear () noexcept
 
LightListgetLights (const LightType type)
 
LightgetLight (I64 lightGUID, LightType type) const
 
void sortLightData (RenderStage stage, const CameraSnapshot &cameraSnapshot)
 
void uploadLightData (RenderStage stage, const CameraSnapshot &cameraSnapshot, GFX::MemoryBarrierCommand &memCmdInOut)
 
void drawLightImpostors (GFX::CommandBuffer &bufferInOut) const
 
void preRenderAllPasses (const Camera *playerCamera)
 
void onVolumeMoved (const BoundingSphere &volume, bool staticSource)
 
void debugLight (Light *light)
 nullptr = disabled
 
 PROPERTY_RW (bool, lightImpostorsEnabled, false)
 
 POINTER_R (Light, debugLight, nullptr)
 
- Public Member Functions inherited from Divide::FrameListener
 FrameListener (const Str< 64 > &name, FrameListenerManager &parent, U32 callOrder)
 Either give it a name.
 
virtual ~FrameListener () override
 
bool operator< (FrameListener &that) const noexcept
 
- Public Member Functions inherited from Divide::GUIDWrapper
 GUIDWrapper () noexcept
 
 GUIDWrapper (const GUIDWrapper &old) noexcept
 
 GUIDWrapper (GUIDWrapper &&old) noexcept
 
virtual ~GUIDWrapper ()=default
 
FORCE_INLINE I64 getGUID () const noexcept
 
GUIDWrapperoperator= (const GUIDWrapper &old)=delete
 
GUIDWrapperoperator= (GUIDWrapper &&other)=delete
 
- Public Member Functions inherited from Divide::SceneComponent
 SceneComponent (Scene &parentScene) noexcept
 
SceneparentScene () noexcept
 
const SceneparentScene () const noexcept
 
- Public Member Functions inherited from Divide::PlatformContextComponent
 PlatformContextComponent (PlatformContext &context) noexcept
 
virtual ~PlatformContextComponent ()=default
 
PlatformContextcontext () noexcept
 
const PlatformContextcontext () const noexcept
 
- Public Member Functions inherited from Divide::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=default
 
NonCopyableoperator= (NonCopyable &&)=default
 

Static Public Member Functions

static void InitStaticData (PlatformContext &context)
 
static void DestroyStaticData ()
 
static U8 GetShadowBindSlotOffset (const ShadowType type) noexcept
 Get the appropriate shadow bind slot for every light's shadow.
 
- Static Public Member Functions inherited from Divide::GUIDWrapper
static I64 generateGUID () noexcept
 

Protected Types

using LightShadowProperties = std::array< Light::ShadowProperties, Config::Lighting::MAX_SHADOW_CASTING_LIGHTS >
 

Protected Member Functions

bool frameStarted (const FrameEvent &evt) override
 
bool frameEnded (const FrameEvent &evt) override
 frameEnded is called after the buffers have been swapped
 
void generateShadowMaps (const Camera &playerCamera, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
 
LightList::const_iterator findLight (const I64 GUID, const LightType type) const
 
LightList::const_iterator findLightLocked (const I64 GUID, const LightType type) const
 
bool isShadowCacheInvalidated (const vec3< F32 > &cameraPosition, Light *light)
 
U32 sortedLightCount (const RenderStage stage) const
 
- Protected Member Functions inherited from Divide::FrameListener
void setCallOrder (const U32 order) noexcept
 
virtual bool frameStarted (const FrameEvent &evt)
 
virtual bool framePreRender (const FrameEvent &evt)
 framePreRenderStarted is called when we need to start processing the visual aspect of a scene
 
virtual bool frameSceneRenderStarted (const FrameEvent &evt)
 frameSceneRenderStarted is called right before rendering the scene for the current player starts
 
virtual bool frameSceneRenderEnded (const FrameEvent &evt)
 frameSceneRenderEnded is called immediately after scene rendering for the current player has ended but before any blitting operations
 
virtual bool frameRenderingQueued (const FrameEvent &evt)
 
virtual bool framePostRender (const FrameEvent &evt)
 
virtual bool frameEnded (const FrameEvent &evt)
 frameEnded is called after the buffers have been swapped
 
 PROPERTY_R_IW (bool, enabled, false)
 
 PROPERTY_RW (Str< 64 >, name)
 
- Protected Member Functions inherited from Divide::NonCopyable
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 

Static Protected Member Functions

static bool IsLightInViewFrustum (const Frustum &frustum, const Light *light) noexcept
 
static ShaderBufferShadowBuffer ()
 
static ShaderBufferLightBuffer ()
 
static ShaderBufferSceneBuffer ()
 

Private Types

using LightData = std::array< LightProperties, Config::Lighting::MAX_ACTIVE_LIGHTS_PER_FRAME >
 
using LightCountPerType = std::array< U32, to_base(LightType::COUNT)>
 

Private Member Functions

U32 uploadLightList (RenderStage stage, const LightList &lights, const mat4< F32 > &viewMatrix)
 

Private Attributes

std::array< LightCountPerType, to_base(RenderStage::COUNT)> _activeLightCount {}
 
std::array< LightList, to_base(RenderStage::COUNT)> _sortedLights {}
 
std::array< LightData, to_base(RenderStage::COUNT)> _sortedLightProperties {}
 
std::array< U32, to_base(RenderStage::COUNT)> _sortedLightPropertiesCount {}
 
std::array< SceneData, to_base(RenderStage::COUNT)> _sortedSceneProperties {}
 
std::array< LightList, to_base(LightType::COUNT)> _lights {}
 
std::array< bool, to_base(LightType::COUNT)> _lightTypeState {}
 
ShadowProperties _shadowBufferData
 
SharedMutex _movedSceneVolumesLock
 
eastl::fixed_vector< MovingVolume, Config::MAX_VISIBLE_NODES, true > _movedSceneVolumes
 
SharedMutex _lightLock {}
 
Time::ProfileTimer_shadowPassTimer
 
U32 _totalLightCount = 0u
 
bool _shadowBufferDirty = false
 

Static Private Attributes

static std::array< U8, to_base(ShadowType::COUNT)> s_shadowLocation
 
static Handle< Textures_lightIconsTexture = INVALID_HANDLE<Texture>
 
static Handle< ShaderPrograms_lightImpostorShader = INVALID_HANDLE<ShaderProgram>
 
static ShaderBuffer_uptr s_lightBuffer = nullptr
 
static ShaderBuffer_uptr s_sceneBuffer = nullptr
 
static ShaderBuffer_uptr s_shadowBuffer = nullptr
 

Friends

class RenderPass
 
class ProjectManager
 
class ShadowMap
 
class Renderer
 

Additional Inherited Members

- Protected Attributes inherited from Divide::GUIDWrapper
const I64 _guid
 
- Protected Attributes inherited from Divide::SceneComponent
Scene_parentScene
 
- Protected Attributes inherited from Divide::PlatformContextComponent
PlatformContext_context
 

Detailed Description

Definition at line 57 of file LightPool.h.

Member Typedef Documentation

◆ LightCountPerType

Definition at line 217 of file LightPool.h.

◆ LightData

◆ LightList

using Divide::LightPool::LightList = eastl::fixed_vector<Light*, 32u, true>

Definition at line 115 of file LightPool.h.

◆ LightShadowProperties

Constructor & Destructor Documentation

◆ LightPool()

Divide::LightPool::LightPool ( Scene parentScene,
PlatformContext context 
)
explicit

Definition at line 131 of file LightPool.cpp.

◆ ~LightPool()

Divide::LightPool::~LightPool ( )
override

Definition at line 146 of file LightPool.cpp.

Member Function Documentation

◆ addLight()

bool Divide::LightPool::addLight ( Light light)

Add a new light to the manager.

Definition at line 182 of file LightPool.cpp.

◆ clear()

bool Divide::LightPool::clear ( )
noexcept

Definition at line 161 of file LightPool.cpp.

◆ debugLight()

void Divide::LightPool::debugLight ( Light light)

nullptr = disabled

Definition at line 355 of file LightPool.cpp.

◆ DestroyStaticData()

void Divide::LightPool::DestroyStaticData ( )
static

Definition at line 121 of file LightPool.cpp.

◆ drawLightImpostors()

void Divide::LightPool::drawLightImpostors ( GFX::CommandBuffer bufferInOut) const

Definition at line 574 of file LightPool.cpp.

◆ findLight()

LightList::const_iterator Divide::LightPool::findLight ( const I64  GUID,
const LightType  type 
) const
inlineprotected

Definition at line 174 of file LightPool.h.

◆ findLightLocked()

LightList::const_iterator Divide::LightPool::findLightLocked ( const I64  GUID,
const LightType  type 
) const
inlineprotected

Definition at line 179 of file LightPool.h.

◆ frameEnded()

bool Divide::LightPool::frameEnded ( const FrameEvent evt)
overrideprotectedvirtual

frameEnded is called after the buffers have been swapped

Reimplemented from Divide::FrameListener.

Definition at line 173 of file LightPool.cpp.

◆ frameStarted()

bool Divide::LightPool::frameStarted ( const FrameEvent evt)
overrideprotectedvirtual

Adapter patern instead of pure interface for the same reason as the Ogre boys pointed out: Implement what you need without filling classes with dummy functions frameStarted is calld at the beggining of a new frame before processing the logic aspect of a scene

Reimplemented from Divide::FrameListener.

Definition at line 166 of file LightPool.cpp.

◆ generateShadowMaps()

void Divide::LightPool::generateShadowMaps ( const Camera playerCamera,
GFX::CommandBuffer bufferInOut,
GFX::MemoryBarrierCommand memCmdInOut 
)
protected

Definition at line 229 of file LightPool.cpp.

◆ getActiveLightCount()

U32 Divide::LightPool::getActiveLightCount ( const RenderStage  stage,
const LightType  type 
) const
inlinenoexcept

Retrieve the number of active lights in the scene;.

Definition at line 133 of file LightPool.h.

◆ getLight()

Light * Divide::LightPool::getLight ( I64  lightGUID,
LightType  type 
) const

Definition at line 361 of file LightPool.cpp.

◆ getLights()

LightList & Divide::LightPool::getLights ( const LightType  type)
inline

Definition at line 136 of file LightPool.h.

◆ GetShadowBindSlotOffset()

static U8 Divide::LightPool::GetShadowBindSlotOffset ( const ShadowType  type)
inlinestaticnoexcept

Get the appropriate shadow bind slot for every light's shadow.

Definition at line 156 of file LightPool.h.

◆ InitStaticData()

void Divide::LightPool::InitStaticData ( PlatformContext context)
static

< no shadows

< no shadows

Definition at line 55 of file LightPool.cpp.

◆ IsLightInViewFrustum()

bool Divide::LightPool::IsLightInViewFrustum ( const Frustum frustum,
const Light light 
)
staticprotectednoexcept

Definition at line 49 of file LightPool.cpp.

◆ isShadowCacheInvalidated()

bool Divide::LightPool::isShadowCacheInvalidated ( const vec3< F32 > &  cameraPosition,
Light light 
)
protected

Definition at line 502 of file LightPool.cpp.

◆ LightBuffer()

static ShaderBuffer * Divide::LightPool::LightBuffer ( )
inlinestaticprotected

Definition at line 196 of file LightPool.h.

◆ lightTypeEnabled()

bool Divide::LightPool::lightTypeEnabled ( const LightType  type) const
inlinenoexcept

Definition at line 131 of file LightPool.h.

◆ onVolumeMoved()

void Divide::LightPool::onVolumeMoved ( const BoundingSphere volume,
bool  staticSource 
)

Definition at line 220 of file LightPool.cpp.

◆ POINTER_R()

Divide::LightPool::POINTER_R ( Light  ,
debugLight  ,
nullptr   
)

◆ preRenderAllPasses()

void Divide::LightPool::preRenderAllPasses ( const Camera playerCamera)

Definition at line 537 of file LightPool.cpp.

◆ PROPERTY_RW()

Divide::LightPool::PROPERTY_RW ( bool  ,
lightImpostorsEnabled  ,
false   
)

◆ removeLight()

bool Divide::LightPool::removeLight ( const Light light)

remove a light from the manager

Definition at line 203 of file LightPool.cpp.

◆ SceneBuffer()

static ShaderBuffer * Divide::LightPool::SceneBuffer ( )
inlinestaticprotected

Definition at line 197 of file LightPool.h.

◆ ShadowBuffer()

static ShaderBuffer * Divide::LightPool::ShadowBuffer ( )
inlinestaticprotected

Definition at line 193 of file LightPool.h.

◆ sortedLightCount()

U32 Divide::LightPool::sortedLightCount ( const RenderStage  stage) const
inlineprotected

Definition at line 199 of file LightPool.h.

◆ sortLightData()

void Divide::LightPool::sortLightData ( RenderStage  stage,
const CameraSnapshot cameraSnapshot 
)

Definition at line 423 of file LightPool.cpp.

◆ toggleLightType() [1/2]

void Divide::LightPool::toggleLightType ( const LightType  type)
inlinenoexcept

disable or enable a specific light type

Definition at line 128 of file LightPool.h.

◆ toggleLightType() [2/2]

void Divide::LightPool::toggleLightType ( const LightType  type,
const bool  state 
)
inlinenoexcept

Definition at line 129 of file LightPool.h.

◆ uploadLightData()

void Divide::LightPool::uploadLightData ( RenderStage  stage,
const CameraSnapshot cameraSnapshot,
GFX::MemoryBarrierCommand memCmdInOut 
)

Definition at line 465 of file LightPool.cpp.

◆ uploadLightList()

U32 Divide::LightPool::uploadLightList ( RenderStage  stage,
const LightList lights,
const mat4< F32 > &  viewMatrix 
)
private

Definition at line 375 of file LightPool.cpp.

Friends And Related Function Documentation

◆ ProjectManager

friend class ProjectManager
friend

Definition at line 173 of file LightPool.h.

◆ Renderer

friend class Renderer
friend

Definition at line 195 of file LightPool.h.

◆ RenderPass

friend class RenderPass
friend

Definition at line 170 of file LightPool.h.

◆ ShadowMap

friend class ShadowMap
friend

Definition at line 192 of file LightPool.h.

Member Data Documentation

◆ _activeLightCount

std::array<LightCountPerType, to_base(RenderStage::COUNT)> Divide::LightPool::_activeLightCount {}
private

Definition at line 219 of file LightPool.h.

◆ _lightLock

SharedMutex Divide::LightPool::_lightLock {}
mutableprivate

Definition at line 232 of file LightPool.h.

◆ _lights

std::array<LightList, to_base(LightType::COUNT)> Divide::LightPool::_lights {}
private

Definition at line 225 of file LightPool.h.

◆ _lightTypeState

std::array<bool, to_base(LightType::COUNT)> Divide::LightPool::_lightTypeState {}
private

Definition at line 226 of file LightPool.h.

◆ _movedSceneVolumes

eastl::fixed_vector<MovingVolume, Config::MAX_VISIBLE_NODES, true> Divide::LightPool::_movedSceneVolumes
private

Definition at line 230 of file LightPool.h.

◆ _movedSceneVolumesLock

SharedMutex Divide::LightPool::_movedSceneVolumesLock
mutableprivate

Definition at line 229 of file LightPool.h.

◆ _shadowBufferData

ShadowProperties Divide::LightPool::_shadowBufferData
private

Definition at line 227 of file LightPool.h.

◆ _shadowBufferDirty

bool Divide::LightPool::_shadowBufferDirty = false
private

Definition at line 235 of file LightPool.h.

◆ _shadowPassTimer

Time::ProfileTimer& Divide::LightPool::_shadowPassTimer
private

Definition at line 233 of file LightPool.h.

◆ _sortedLightProperties

std::array<LightData, to_base(RenderStage::COUNT)> Divide::LightPool::_sortedLightProperties {}
private

Definition at line 221 of file LightPool.h.

◆ _sortedLightPropertiesCount

std::array<U32, to_base(RenderStage::COUNT)> Divide::LightPool::_sortedLightPropertiesCount {}
private

Definition at line 222 of file LightPool.h.

◆ _sortedLights

std::array<LightList, to_base(RenderStage::COUNT)> Divide::LightPool::_sortedLights {}
private

Definition at line 220 of file LightPool.h.

◆ _sortedSceneProperties

std::array<SceneData, to_base(RenderStage::COUNT)> Divide::LightPool::_sortedSceneProperties {}
private

Definition at line 223 of file LightPool.h.

◆ _totalLightCount

U32 Divide::LightPool::_totalLightCount = 0u
private

Definition at line 234 of file LightPool.h.

◆ s_lightBuffer

ShaderBuffer_uptr Divide::LightPool::s_lightBuffer = nullptr
staticprivate

Definition at line 240 of file LightPool.h.

◆ s_lightIconsTexture

Handle< Texture > Divide::LightPool::s_lightIconsTexture = INVALID_HANDLE<Texture>
staticprivate

Definition at line 238 of file LightPool.h.

◆ s_lightImpostorShader

Handle< ShaderProgram > Divide::LightPool::s_lightImpostorShader = INVALID_HANDLE<ShaderProgram>
staticprivate

Definition at line 239 of file LightPool.h.

◆ s_sceneBuffer

ShaderBuffer_uptr Divide::LightPool::s_sceneBuffer = nullptr
staticprivate

Definition at line 241 of file LightPool.h.

◆ s_shadowBuffer

ShaderBuffer_uptr Divide::LightPool::s_shadowBuffer = nullptr
staticprivate

Definition at line 242 of file LightPool.h.

◆ s_shadowLocation

std::array< U8, to_base(ShadowType::COUNT)> Divide::LightPool::s_shadowLocation
staticprivate
Initial value:
=
{{
4,
5,
6
} }

Definition at line 237 of file LightPool.h.


The documentation for this class was generated from the following files: