Nameless Engine
|
#include <LightingShaderResourceManager.h>
Classes | |
struct | ComputeShaderData |
struct | GeneralLightingShaderData |
struct | GpuData |
struct | LightArrays |
Public Member Functions | |
ShaderLightArray * | getPointLightDataArray () const |
ShaderLightArray * | getDirectionalLightDataArray () const |
ShaderLightArray * | getSpotlightDataArray () const |
ShaderLightArray * | getShadowPassLightInfoArray () const |
std::optional< Error > | bindDescriptorsToRecreatedPipelineResources () |
std::optional< Error > | updateDescriptorsForPipelineResource (Pipeline *pPipeline) |
std::pair< std::recursive_mutex, GpuData > * | getInternalResources () |
Static Public Member Functions | |
static std::string | getGeneralLightingDataShaderResourceName () |
static std::string | getPointLightsShaderResourceName () |
static std::string | getDirectionalLightsShaderResourceName () |
static std::string | getSpotlightsShaderResourceName () |
static std::string | getPointLightsInCameraFrustumIndicesShaderResourceName () |
static std::string | getSpotlightsInCameraFrustumIndicesShaderResourceName () |
static std::string | getShadowPassLightInfoArrayShaderResourceName () |
static std::string | getPointLightWorldLocationsShaderResourceName () |
Private Member Functions | |
LightingShaderResourceManager (Renderer *pRenderer) | |
std::optional< Error > | recalculateLightTileFrustums (const std::pair< unsigned int, unsigned int > &renderTargetSize, const glm::mat4 &inverseProjectionMatrix) |
void | onEngineShadersCompiled () |
void | setAmbientLight (const glm::vec3 &ambientLight) |
void | updateResources (FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex) |
void | onPointLightArraySizeChanged (size_t iNewSize) |
void | onPointLightsInFrustumCulled (size_t iCurrentFrameResourceIndex) |
void | onDirectionalLightArraySizeChanged (size_t iNewSize) |
void | onSpotlightArraySizeChanged (size_t iNewSize) |
void | onSpotlightsInFrustumCulled (size_t iCurrentFrameResourceIndex) |
void | copyDataToGpu (size_t iCurrentFrameResourceIndex) |
std::optional< Error > | rebindGpuDataToAllPipelines () |
std::optional< Error > | rebindGpuDataToPipelineIfUsed (Pipeline *pPipeline) |
Static Private Member Functions | |
static std::unique_ptr< LightingShaderResourceManager > | create (Renderer *pRenderer) |
Private Attributes | |
LightArrays | lightArrays |
std::pair< std::recursive_mutex, GpuData > | mtxGpuData |
ComputeShaderData::FrustumGridComputeShader::ComputeShader | frustumGridComputeShaderData |
ComputeShaderData::LightCullingComputeShader::ComputeShader | lightCullingComputeShaderData |
std::unique_ptr< ComputeShaderInterface > | pPrepareLightCullingComputeInterface |
Renderer * | pRenderer = nullptr |
bool | bEngineShadersCompiled = false |
Static Private Attributes | |
static const std::string | sGeneralLightingDataShaderResourceName = "generalLightingData" |
static const std::string | sPointLightsShaderResourceName = "pointLights" |
static const std::string | sDirectionalLightsShaderResourceName = "directionalLights" |
static const std::string | sSpotlightsShaderResourceName = "spotlights" |
static const std::string | sPointLightsInCameraFrustumIndicesShaderResourceName |
static const std::string | sSpotlightsInCameraFrustumIndicesShaderResourceName |
static const std::string | sShadowPassLightInfoShaderResourceName = "shadowPassLightInfo" |
static constexpr auto | generalLightingDataDescriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER |
Friends | |
class | Renderer |
Manages GPU resources that store lighting related data (such as data of all spawned light sources (data such as color, intensity, position, etc.)).
|
private |
Initializes a new manager.
pRenderer | Used renderer. |
std::optional< Error > ne::LightingShaderResourceManager::bindDescriptorsToRecreatedPipelineResources | ( | ) |
Updates descriptors in all graphics pipelines to make descriptors reference the underlying buffers.
|
private |
Copies data from mtxGpuData to the GPU resource of the current frame resource.
iCurrentFrameResourceIndex | Index of the frame resource that will be used to submit the next frame. |
|
staticprivate |
Creates a new manager.
pRenderer | Used renderer. |
ShaderLightArray * ne::LightingShaderResourceManager::getDirectionalLightDataArray | ( | ) | const |
Returns a non-owning reference to an array that stores data of all spawned directional lights.
|
static |
Return name of the shader resource that stores array of directional lights (name from shader code).
|
static |
Return name of the shader resource that stores general lighting data (name from shader code).
std::pair< std::recursive_mutex, LightingShaderResourceManager::GpuData > * ne::LightingShaderResourceManager::getInternalResources | ( | ) |
Returns manager's internal resources.
ShaderLightArray * ne::LightingShaderResourceManager::getPointLightDataArray | ( | ) | const |
Returns a non-owning reference to an array that stores data of all spawned point lights.
|
static |
Return name of the shader resource that stores indices of point lights in camera's frustum (name from shader code).
|
static |
Return name of the shader resource that stores array of point lights (name from shader code).
|
static |
Returns name of the shader resource that stores array of world positions for all point lights (used for shadow mapping).
ShaderLightArray * ne::LightingShaderResourceManager::getShadowPassLightInfoArray | ( | ) | const |
Returns a non-owning reference to an array that stores info for shadow pass of spawned lights.
|
static |
Returns name of the shader resource that stores array of viewProjectionMatrix
for all light sources (used for shadow mapping).
ShaderLightArray * ne::LightingShaderResourceManager::getSpotlightDataArray | ( | ) | const |
Returns a non-owning reference to an array that stores data of all spawned spotlights.
|
static |
Return name of the shader resource that stores indices of spotlights in camera's frustum (name from shader code).
|
static |
Return name of the shader resource that stores array of spotlights (name from shader code).
|
private |
Called after array of directional light sources changed its size.
iNewSize | New size of the array that stores GPU data for spawned directional lights. |
|
private |
Called by renderer to notify that all engine shaders were compiled.
|
private |
Called after array of point light sources changed its size.
iNewSize | New size of the array that stores GPU data for spawned point lights. |
|
private |
Called after array of indices to point lights in frustum was changed (indices changed).
iCurrentFrameResourceIndex | Index of the frame resource that will be used to submit the next frame. |
|
private |
Called after array of spotlights changed its size.
iNewSize | New size of the array that stores GPU data for spawned spotlights. |
|
private |
Called after array of indices to spotlights in frustum was changed (indices changed).
iCurrentFrameResourceIndex | Index of the frame resource that will be used to submit the next frame. |
|
private |
Updates descriptors in all graphics pipelines to make descriptors reference the underlying buffers from mtxGpuData.
|
private |
Updates descriptors in the specified graphics pipeline to make descriptors reference the underlying buffers from mtxGpuData.
pPipeline | Pipeline to bind data to. |
|
private |
Called by renderer when render resolution or projection matrix changes to queue a compute shader that will recalculate grid of frustums used during light culling.
renderTargetSize | New render of the underlying render image in pixels. |
inverseProjectionMatrix | Inverse projection matrix of the currently active camera. |
|
private |
Sets light color intensity of ambient lighting.
ambientLight | Color in RGB format. |
|
private |
Updates all light source resources marked as "needs update" and copies new (updated) data to the GPU resource of the specified frame resource.
drawNextFrame
function so that renderer's depth texture without multisampling pointer will not change.pCurrentFrameResource | Current frame resource that will be used to submit the next frame. |
iCurrentFrameResourceIndex | Index of the frame resource that will be used to submit the next frame. |
|
private |
true
if the renderer has finished compiling engine shaders, false
otherwise.
|
private |
Calculates frustum grid for light culling.
|
staticconstexprprivate |
Type of the descriptor used to store data from mtxGpuData.
|
private |
Groups GPU resources that store arrays of light sources.
|
private |
Does light culling.
|
private |
Groups GPU related data.
|
private |
Compute interface that runs before light culling shader to reset global variables.
|
private |
Used renderer.
|
inlinestaticprivate |
Name of the resource that stores array of directional lights.
|
inlinestaticprivate |
Name of the resource that stores data from mtxGpuData (name from shader code).
|
inlinestaticprivate |
Name of the resources that stores indices of point lights in camera's frustum.
|
inlinestaticprivate |
Name of the resource that stores array of point lights.
|
inlinestaticprivate |
Name of the resource that stores array light infos for all spawned lights (used in shadow pass).
|
inlinestaticprivate |
Name of the resources that stores indices of spotlights in camera's frustum.
|
inlinestaticprivate |
Name of the resource that stores array of spotlights.