Nameless Engine
Loading...
Searching...
No Matches
ne::ShadowMapHandle Class Reference

#include <ShadowMapHandle.h>

Classes

struct  InternalResources
 

Public Member Functions

 ShadowMapHandle (const ShadowMapHandle &)=delete
 
ShadowMapHandleoperator= (const ShadowMapHandle &)=delete
 
 ShadowMapHandle (ShadowMapHandle &&other) noexcept=delete
 
ShadowMapHandleoperator= (ShadowMapHandle &&other) noexcept=delete
 
std::pair< std::recursive_mutex, InternalResources > * getResources ()
 
ShadowMapType getShadowMapType () const
 
size_t getShadowMapSize () const
 

Private Member Functions

 ShadowMapHandle (ShadowMapManager *pManager, GpuResource *pDepthTexture, ShadowMapType type, size_t iTextureSize, const std::function< void(unsigned int)> &onArrayIndexChanged, GpuResource *pColorTexture=nullptr)
 
void changeArrayIndex (unsigned int iNewArrayIndex)
 
void setUpdatedResources (GpuResource *pDepthTexture, size_t iShadowMapSize, GpuResource *pColorTexture=nullptr)
 
void recreateFramebuffers ()
 

Private Attributes

ShadowMapManagerpManager = nullptr
 
std::pair< std::recursive_mutex, InternalResourcesmtxResources
 
size_t iShadowMapSize = 0
 
const std::function< void(unsigned int)> onArrayIndexChanged
 
const ShadowMapType shadowMapType = ShadowMapType::DIRECTIONAL
 

Friends

class ShadowMapManager
 
class ShadowMapArrayIndexManager
 

Detailed Description

Small raw pointer wrapper that acts kind of like std::unique_ptr for shadow maps to do some extra work when started/stopped referencing a shadow map.

When deleted causes the resource to be also deleted.

Constructor & Destructor Documentation

◆ ShadowMapHandle()

ne::ShadowMapHandle::ShadowMapHandle ( ShadowMapManager pManager,
GpuResource pDepthTexture,
ShadowMapType  type,
size_t  iTextureSize,
const std::function< void(unsigned int)> &  onArrayIndexChanged,
GpuResource pColorTexture = nullptr 
)
private

Constructs a new handle.

Parameters
pManagerManager that owns the resource.
pDepthTextureResource to point to.
typeType of the shadow map this handle references.
iTextureSizeSize (in pixels) of the shadow map.
onArrayIndexChangedCalled after the index of the shadow map into the descriptor array of shadow maps was initialized/changed.
pColorTextureOptional "color" target, used for point lights to store additional information.

Member Function Documentation

◆ changeArrayIndex()

void ne::ShadowMapHandle::changeArrayIndex ( unsigned int  iNewArrayIndex)
private

Called by array index manager to notify the shadow map user about array index changed.

Parameters
iNewArrayIndexNew array index.

◆ getResources()

std::pair< std::recursive_mutex, InternalResources > * ne::ShadowMapHandle::getResources ( )
inline

Returns the underlying resource.

Warning
Do not delete (free) returned pointer.
Remarks
Use returned resource only when mutex is locked.
Returns
Valid pointer to resource.

◆ getShadowMapSize()

size_t ne::ShadowMapHandle::getShadowMapSize ( ) const
inline

Returns the current size of the shadow map resource.

Returns
Size in pixels.

◆ getShadowMapType()

ShadowMapType ne::ShadowMapHandle::getShadowMapType ( ) const
inline

Returns type of a shadow map that this handle references.

Returns
Shadow map type.

◆ recreateFramebuffers()

void ne::ShadowMapHandle::recreateFramebuffers ( )
private

(Re)creates framebuffers from mtxResources if running Vulkan renderer.

◆ setUpdatedResources()

void ne::ShadowMapHandle::setUpdatedResources ( GpuResource pDepthTexture,
size_t  iShadowMapSize,
GpuResource pColorTexture = nullptr 
)
private

Called by shadow map manager after GPU resources were re-created (due to some render settings changed for example) to assign new resources.

Parameters
pDepthTextureResource to point to.
iShadowMapSizeSize (in pixels) of the shadow map.
pColorTextureOptional "color" target, used for point lights to store additional information.

Member Data Documentation

◆ iShadowMapSize

size_t ne::ShadowMapHandle::iShadowMapSize = 0
private

Size (in pixels) of the mtxResources texture, used for fast access.

◆ mtxResources

std::pair<std::recursive_mutex, InternalResources> ne::ShadowMapHandle::mtxResources
private

Resource that this handle references.

◆ onArrayIndexChanged

const std::function<void(unsigned int)> ne::ShadowMapHandle::onArrayIndexChanged
private

Called after the index of the shadow map into the descriptor array of shadow maps was initialized/changed.

◆ pManager

ShadowMapManager* ne::ShadowMapHandle::pManager = nullptr
private

Manager that owns the resource we are pointing to.

◆ shadowMapType

const ShadowMapType ne::ShadowMapHandle::shadowMapType = ShadowMapType::DIRECTIONAL
private

Type of the shadow map that this handle references.


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