Nameless Engine
Loading...
Searching...
No Matches
LightingShaderResourceManager.h
1#pragma once
2
3// Standard.
4#include <mutex>
5#include <memory>
6#include <functional>
7#include <unordered_map>
8#include <unordered_set>
9
10// Custom.
11#include "render/general/resource/UploadBuffer.h"
12#include "render/general/resource/frame/FrameResourceManager.h"
13#include "shader/general/resource/ShaderLightArray.h"
14#if defined(WIN32)
15#include "render/directx/resource/DirectXResource.h"
16#include "shader/hlsl/RootSignatureGenerator.h"
17#include "render/directx/pipeline/DirectXPso.h"
18#endif
19
20// External.
21#include "vulkan/vulkan_core.h"
22#if defined(WIN32)
23#include "directx/d3dx12.h"
24#include <wrl.h>
25#endif
26
27namespace ne {
28#if defined(WIN32)
29 using namespace Microsoft::WRL;
30#endif
31
32 class Renderer;
33 class Pipeline;
34 class ComputeShaderInterface;
35 class VulkanPipeline;
36
40 alignas(iVkVec4Alignment) glm::mat4 viewProjectionMatrix = glm::identity<glm::mat4>();
41
43 alignas(iVkVec4Alignment) glm::vec4 position = glm::vec4(0.0F, 0.0F, 0.0F, 1.0F);
44 };
45
51 // Only renderer is allowed to create and update resources of this manager.
52 friend class Renderer;
53
54 public:
58 alignas(iVkVec4Alignment) glm::vec4 ambientLight = glm::vec4(0.0F, 0.0F, 0.0F, 1.0F);
59
61 alignas(iVkScalarAlignment) unsigned int iPointLightCountInCameraFrustum = 0;
62
64 alignas(iVkScalarAlignment) unsigned int iDirectionalLightCount = 0;
65
67 alignas(iVkScalarAlignment) unsigned int iSpotLightCountInCameraFrustum = 0;
68 };
69
71 struct GpuData {
72 GpuData() = default;
73
75 std::array<std::unique_ptr<UploadBuffer>, FrameResourceManager::getFrameResourceCount()>
77
84 };
85
87
89
96
102 static std::string getPointLightsShaderResourceName();
103
109 static std::string getDirectionalLightsShaderResourceName();
110
116 static std::string getSpotlightsShaderResourceName();
117
125
133
141
149
150#if defined(WIN32)
163 inline void setShadowPassLightInfoViewToCommandList(
164 DirectXPso* pPso,
165 const ComPtr<ID3D12GraphicsCommandList>& pCommandList,
166 size_t iCurrentFrameResourceIndex) {
167 // Lock internal resources.
168 std::scoped_lock gpuDataGuard(mtxGpuData.first);
169
170 auto& pipelineData = pPso->getInternalResources()->second;
171
172#if defined(DEBUG)
173 // Self check: make sure this resource is actually being used in the PSO.
174 if (pipelineData.rootParameterIndices.find(sShadowPassLightInfoShaderResourceName) ==
175 pipelineData.rootParameterIndices.end()) [[unlikely]] {
176 Error error(std::format(
177 "shader resource \"{}\" is not used in the shaders of the specified PSO \"{}\" "
178 "but you are attempting to set this resource to a command list",
180 pPso->getPipelineIdentifier()));
181 error.showError();
182 throw std::runtime_error(error.getFullErrorMessage());
183 }
184#endif
185
186 // Bind array.
187 setLightingArrayViewToCommandList(
188 pPso,
189 pCommandList,
190 iCurrentFrameResourceIndex,
193 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
194 SpecialRootParameterSlot::SHADOW_PASS_LIGHT_INFO)]);
195 }
196#endif
197
198#if defined(WIN32)
214 static inline void setLightingArrayViewToCommandList(
215 DirectXPso* pPso,
216 const ComPtr<ID3D12GraphicsCommandList>& pCommandList,
217 size_t iCurrentFrameResourceIndex,
218 const std::unique_ptr<ShaderLightArray>& pArray,
219 const std::string& sArrayNameInShaders,
220 UINT iArrayRootParameterIndex) {
221 std::scoped_lock lightsGuard(pArray->mtxResources.first);
222
223#if defined(DEBUG)
224 // Self check: make sure this resource is actually being used in the PSO.
225 if (pPso->getInternalResources()->second.rootParameterIndices.find(sArrayNameInShaders) ==
226 pPso->getInternalResources()->second.rootParameterIndices.end()) [[unlikely]] {
227 Error error(std::format(
228 "shader resource \"{}\" is not used in the shaders of the specified PSO \"{}\" "
229 "but you are attempting to set this resource to a command list",
230 sArrayNameInShaders,
231 pPso->getPipelineIdentifier()));
232 error.showError();
233 throw std::runtime_error(error.getFullErrorMessage());
234 }
235#endif
236
237 // Bind lights array
238 // (resource is guaranteed to be not `nullptr`, see field docs).
239 pCommandList->SetGraphicsRootShaderResourceView(
240 iArrayRootParameterIndex,
241 reinterpret_cast<DirectXResource*>(
242 pArray->mtxResources.second.vGpuArrayLightDataResources[iCurrentFrameResourceIndex]
243 ->getInternalResource())
244 ->getInternalResource()
245 ->GetGPUVirtualAddress());
246 }
247#endif
248
256 ShaderLightArray* getPointLightDataArray() const;
257
265 ShaderLightArray* getDirectionalLightDataArray() const;
266
274 ShaderLightArray* getSpotlightDataArray() const;
275
283 ShaderLightArray* getShadowPassLightInfoArray() const;
284
293 [[nodiscard]] std::optional<Error> bindDescriptorsToRecreatedPipelineResources();
294
305 [[nodiscard]] std::optional<Error> updateDescriptorsForPipelineResource(Pipeline* pPipeline);
306
314 std::pair<std::recursive_mutex, GpuData>* getInternalResources();
315
316#if defined(WIN32)
329 inline void setResourceViewToCommandList(
330 DirectXPso* pPso,
331 const ComPtr<ID3D12GraphicsCommandList>& pCommandList,
332 size_t iCurrentFrameResourceIndex) {
333 // Lock internal resources.
334 std::scoped_lock gpuDataGuard(mtxGpuData.first);
335
336 auto& pipelineData = pPso->getInternalResources()->second;
337
338#if defined(DEBUG)
339 // Self check: make sure this resource is actually being used in the PSO.
340 if (pipelineData.rootParameterIndices.find(sGeneralLightingDataShaderResourceName) ==
341 pipelineData.rootParameterIndices.end()) [[unlikely]] {
342 Error error(std::format(
343 "shader resource \"{}\" is not used in the shaders of the specified PSO \"{}\" "
344 "but you are attempting to set this resource to a command list",
346 pPso->getPipelineIdentifier()));
347 error.showError();
348 throw std::runtime_error(error.getFullErrorMessage());
349 }
350#endif
351
352 // Bind general lighting resources buffer.
353 pCommandList->SetGraphicsRootConstantBufferView(
354 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
355 SpecialRootParameterSlot::GENERAL_LIGHTING)],
356 reinterpret_cast<DirectXResource*>(
357 mtxGpuData.second.vGeneralDataGpuResources[iCurrentFrameResourceIndex]
358 ->getInternalResource())
359 ->getInternalResource()
360 ->GetGPUVirtualAddress());
361
362 // Bind point lights array.
363 setLightingArrayViewToCommandList(
364 pPso,
365 pCommandList,
366 iCurrentFrameResourceIndex,
369 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
370 SpecialRootParameterSlot::POINT_LIGHTS)]);
371
372 // Bind directional lights array.
373 setLightingArrayViewToCommandList(
374 pPso,
375 pCommandList,
376 iCurrentFrameResourceIndex,
379 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
380 SpecialRootParameterSlot::DIRECTIONAL_LIGHTS)]);
381
382 // Bind spotlights array.
383 setLightingArrayViewToCommandList(
384 pPso,
385 pCommandList,
386 iCurrentFrameResourceIndex,
389 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
390 SpecialRootParameterSlot::SPOT_LIGHTS)]);
391
392#if defined(DEBUG)
393 static_assert(sizeof(LightArrays) == 32, "consider adding new arrays here"); // NOLINT
394#endif
395 }
396
408 inline void setOpaqueLightGridResourcesViewToCommandList(
409 DirectXPso* pPso, const ComPtr<ID3D12GraphicsCommandList>& pCommandList) const {
410 auto& pipelineData = pPso->getInternalResources()->second;
411
412 // Bind point light index list.
413 pCommandList->SetGraphicsRootUnorderedAccessView(
414 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
415 SpecialRootParameterSlot::LIGHT_CULLING_POINT_LIGHT_INDEX_LIST)],
416 reinterpret_cast<DirectXResource*>(
418 ->getInternalResource()
419 ->GetGPUVirtualAddress());
420
421 // Bind spotlight index list.
422 pCommandList->SetGraphicsRootUnorderedAccessView(
423 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
424 SpecialRootParameterSlot::LIGHT_CULLING_SPOT_LIGHT_INDEX_LIST)],
425 reinterpret_cast<DirectXResource*>(
427 ->getInternalResource()
428 ->GetGPUVirtualAddress());
429
430 // Bind point light grid.
431 pCommandList->SetGraphicsRootDescriptorTable(
432 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
433 SpecialRootParameterSlot::LIGHT_CULLING_POINT_LIGHT_GRID)],
434 *reinterpret_cast<DirectXResource*>(
436 ->getBindedDescriptorGpuHandle(DirectXDescriptorType::UAV));
437
438 // Bind spotlight light grid.
439 pCommandList->SetGraphicsRootDescriptorTable(
440 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
441 SpecialRootParameterSlot::LIGHT_CULLING_SPOT_LIGHT_GRID)],
442 *reinterpret_cast<DirectXResource*>(
444 ->getBindedDescriptorGpuHandle(DirectXDescriptorType::UAV));
445 }
446
458 inline void setTransparentLightGridResourcesViewToCommandList(
459 DirectXPso* pPso, const ComPtr<ID3D12GraphicsCommandList>& pCommandList) const {
460 auto& pipelineData = pPso->getInternalResources()->second;
461
462 // Bind point light index list.
463 pCommandList->SetGraphicsRootUnorderedAccessView(
464 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
465 SpecialRootParameterSlot::LIGHT_CULLING_POINT_LIGHT_INDEX_LIST)],
466 reinterpret_cast<DirectXResource*>(
468 ->getInternalResource()
469 ->GetGPUVirtualAddress());
470
471 // Bind spotlight index list.
472 pCommandList->SetGraphicsRootUnorderedAccessView(
473 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
474 SpecialRootParameterSlot::LIGHT_CULLING_SPOT_LIGHT_INDEX_LIST)],
475 reinterpret_cast<DirectXResource*>(
477 ->getInternalResource()
478 ->GetGPUVirtualAddress());
479
480 // Bind point light grid.
481 pCommandList->SetGraphicsRootDescriptorTable(
482 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
483 SpecialRootParameterSlot::LIGHT_CULLING_POINT_LIGHT_GRID)],
484 *reinterpret_cast<DirectXResource*>(
486 ->getBindedDescriptorGpuHandle(DirectXDescriptorType::UAV));
487
488 // Bind spotlight light grid.
489 pCommandList->SetGraphicsRootDescriptorTable(
490 pipelineData.vSpecialRootParameterIndices[static_cast<size_t>(
491 SpecialRootParameterSlot::LIGHT_CULLING_SPOT_LIGHT_GRID)],
492 *reinterpret_cast<DirectXResource*>(
494 ->getBindedDescriptorGpuHandle(DirectXDescriptorType::UAV));
495 }
496
497#endif
498
499 private:
501 struct LightArrays {
503 std::unique_ptr<ShaderLightArray> pPointLightDataArray;
504
506 std::unique_ptr<ShaderLightArray> pDirectionalLightDataArray;
507
509 std::unique_ptr<ShaderLightArray> pSpotlightDataArray;
510
512 std::unique_ptr<ShaderLightArray> pShadowPassLightInfoArray;
513 };
514
522 struct Plane {
524 glm::vec3 normal;
525
528 };
529
535 struct Frustum {
538 };
539
544 struct ComputeInfo {
546 alignas(iVkScalarAlignment) unsigned int iThreadGroupCountX = 0;
547
549 alignas(iVkScalarAlignment) unsigned int iThreadGroupCountY = 0;
550
552 alignas(iVkScalarAlignment) unsigned int iTileCountX = 0;
553
555 alignas(iVkScalarAlignment) unsigned int iTileCountY = 0;
556 };
557
561 alignas(iVkMat4Alignment) glm::mat4 inverseProjectionMatrix = glm::identity<glm::mat4>();
562
564 alignas(iVkScalarAlignment) unsigned int iRenderTargetWidth = 0;
565
567 alignas(iVkScalarAlignment) unsigned int iRenderTargetHeight = 0;
568 };
569
576 std::unique_ptr<UploadBuffer> pComputeInfo;
577
582 std::unique_ptr<UploadBuffer> pScreenToViewData;
583
585 std::unique_ptr<GpuResource> pCalculatedFrustums;
586 };
587
597 [[nodiscard]] std::optional<Error> initialize(Renderer* pRenderer);
598
608 [[nodiscard]] std::optional<Error> updateDataAndSubmitShader(
610 const std::pair<unsigned int, unsigned int>& renderTargetSize,
611 const glm::mat4& inverseProjectionMatrix);
612
614 std::unique_ptr<ComputeShaderInterface> pComputeInterface;
615
618
623 unsigned int iLastUpdateTileCountX = 0;
624
629 unsigned int iLastUpdateTileCountY = 0;
630
632 bool bIsInitialized = false;
633
638 static inline const auto sComputeInfoShaderResourceName = "computeInfo";
639
644 static inline const auto sScreenToViewDataShaderResourceName = "screenToViewData";
645
650 static inline const auto sCalculatedFrustumsShaderResourceName = "calculatedFrustums";
651 };
652 };
653
659 alignas(iVkScalarAlignment) unsigned int iPointLightListOpaque = 0;
660
662 alignas(iVkScalarAlignment) unsigned int iSpotlightListOpaque = 0;
663
665 alignas(iVkScalarAlignment) unsigned int iPointLightListTransparent = 0;
666
668 alignas(iVkScalarAlignment) unsigned int iSpotlightListTransparent = 0;
669 };
670
676 alignas(iVkScalarAlignment) unsigned int iThreadGroupCountX = 0;
677
679 alignas(iVkScalarAlignment) unsigned int iThreadGroupCountY = 0;
680 };
681
688 std::unique_ptr<UploadBuffer> pThreadGroupCount;
689
691 std::unique_ptr<GpuResource> pGlobalCountersIntoLightIndexList;
692
694 std::unique_ptr<GpuResource> pOpaquePointLightIndexList;
695
697 std::unique_ptr<GpuResource> pOpaqueSpotLightIndexList;
698
700 std::unique_ptr<GpuResource> pTransparentPointLightIndexList;
701
703 std::unique_ptr<GpuResource> pTransparentSpotLightIndexList;
704
709 std::unique_ptr<GpuResource> pOpaquePointLightGrid;
710
715 std::unique_ptr<GpuResource> pOpaqueSpotLightGrid;
716
721 std::unique_ptr<GpuResource> pTransparentPointLightGrid;
722
727 std::unique_ptr<GpuResource> pTransparentSpotLightGrid;
728
734
740 };
741
753 [[nodiscard]] std::optional<Error> initialize(
755 const FrustumGridComputeShader::ComputeShader& frustumGridShader);
756
771 [[nodiscard]] std::variant<bool, Error> createLightIndexListsAndLightGrid(
772 Renderer* pRenderer, size_t iTileCountX, size_t iTileCountY);
773
796 [[nodiscard]] std::optional<Error> queueExecutionForNextFrame(
798 FrameResource* pCurrentFrameResource,
799 size_t iCurrentFrameResourceIndex,
800 GpuResource* pGeneralLightingData,
801 GpuResource* pPointLightArray,
802 GpuResource* pSpotlightArray,
803 GpuResource* pNonCulledPointLightsIndicesArray,
804 GpuResource* pNonCulledSpotlightsIndicesArray) const;
805
807 std::unique_ptr<ComputeShaderInterface> pComputeInterface;
808
811
814
816 bool bIsInitialized = false;
817
822 static inline const auto sDepthTextureShaderResourceName = "depthTexture";
823
828 static inline const auto sThreadGroupCountShaderResourceName = "threadGroupCount";
829
835 "globalCountersIntoLightIndexList";
836 };
837 };
838 };
839
847 static std::unique_ptr<LightingShaderResourceManager> create(Renderer* pRenderer);
848
855
865 [[nodiscard]] std::optional<Error> recalculateLightTileFrustums(
866 const std::pair<unsigned int, unsigned int>& renderTargetSize,
867 const glm::mat4& inverseProjectionMatrix);
868
876
884 void setAmbientLight(const glm::vec3& ambientLight);
885
900 void updateResources(FrameResource* pCurrentFrameResource, size_t iCurrentFrameResourceIndex);
901
907 void onPointLightArraySizeChanged(size_t iNewSize);
908
915 void onPointLightsInFrustumCulled(size_t iCurrentFrameResourceIndex);
916
922 void onDirectionalLightArraySizeChanged(size_t iNewSize);
923
929 void onSpotlightArraySizeChanged(size_t iNewSize);
930
937 void onSpotlightsInFrustumCulled(size_t iCurrentFrameResourceIndex);
938
945 void copyDataToGpu(size_t iCurrentFrameResourceIndex);
946
955 [[nodiscard]] std::optional<Error> rebindGpuDataToAllPipelines();
956
967 [[nodiscard]] std::optional<Error> rebindGpuDataToPipelineIfUsed(Pipeline* pPipeline);
968
971
973 std::pair<std::recursive_mutex, GpuData> mtxGpuData;
974
977
980
982 std::unique_ptr<ComputeShaderInterface> pPrepareLightCullingComputeInterface;
983
985 Renderer* pRenderer = nullptr;
986
989
991 static inline const std::string sGeneralLightingDataShaderResourceName = "generalLightingData";
992
994 static inline const std::string sPointLightsShaderResourceName = "pointLights";
995
997 static inline const std::string sDirectionalLightsShaderResourceName = "directionalLights";
998
1000 static inline const std::string sSpotlightsShaderResourceName = "spotlights";
1001
1004 "pointLightsInCameraFrustumIndices";
1005
1008 "spotlightsInCameraFrustumIndices";
1009
1014 static inline const std::string sShadowPassLightInfoShaderResourceName = "shadowPassLightInfo";
1015
1017 static constexpr auto generalLightingDataDescriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
1018 };
1019}
Definition: DirectXPso.h:22
std::pair< std::recursive_mutex, InternalResources > * getInternalResources()
Definition: DirectXPso.h:144
Definition: Error.h:27
static constexpr unsigned int getFrameResourceCount()
Definition: FrameResourceManager.h:74
Definition: GpuResource.h:16
Definition: LightingShaderResourceManager.h:50
ShaderLightArray * getPointLightDataArray() const
Definition: LightingShaderResourceManager.cpp:19
static std::unique_ptr< LightingShaderResourceManager > create(Renderer *pRenderer)
Definition: LightingShaderResourceManager.cpp:1328
std::unique_ptr< ComputeShaderInterface > pPrepareLightCullingComputeInterface
Definition: LightingShaderResourceManager.h:982
std::optional< Error > bindDescriptorsToRecreatedPipelineResources()
Definition: LightingShaderResourceManager.cpp:35
LightArrays lightArrays
Definition: LightingShaderResourceManager.h:970
ShaderLightArray * getSpotlightDataArray() const
Definition: LightingShaderResourceManager.cpp:27
void setAmbientLight(const glm::vec3 &ambientLight)
Definition: LightingShaderResourceManager.cpp:1273
void updateResources(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex)
Definition: LightingShaderResourceManager.cpp:131
static const std::string sSpotlightsInCameraFrustumIndicesShaderResourceName
Definition: LightingShaderResourceManager.h:1007
void onSpotlightsInFrustumCulled(size_t iCurrentFrameResourceIndex)
Definition: LightingShaderResourceManager.cpp:294
void onDirectionalLightArraySizeChanged(size_t iNewSize)
Definition: LightingShaderResourceManager.cpp:245
static const std::string sGeneralLightingDataShaderResourceName
Definition: LightingShaderResourceManager.h:991
static std::string getGeneralLightingDataShaderResourceName()
Definition: LightingShaderResourceManager.cpp:1299
static const std::string sShadowPassLightInfoShaderResourceName
Definition: LightingShaderResourceManager.h:1014
ComputeShaderData::FrustumGridComputeShader::ComputeShader frustumGridComputeShaderData
Definition: LightingShaderResourceManager.h:976
std::optional< Error > rebindGpuDataToPipelineIfUsed(Pipeline *pPipeline)
Definition: LightingShaderResourceManager.cpp:361
static const std::string sDirectionalLightsShaderResourceName
Definition: LightingShaderResourceManager.h:997
Renderer * pRenderer
Definition: LightingShaderResourceManager.h:985
ShaderLightArray * getShadowPassLightInfoArray() const
Definition: LightingShaderResourceManager.cpp:31
static const std::string sPointLightsInCameraFrustumIndicesShaderResourceName
Definition: LightingShaderResourceManager.h:1003
static std::string getPointLightWorldLocationsShaderResourceName()
std::optional< Error > recalculateLightTileFrustums(const std::pair< unsigned int, unsigned int > &renderTargetSize, const glm::mat4 &inverseProjectionMatrix)
Definition: LightingShaderResourceManager.cpp:1158
void onPointLightArraySizeChanged(size_t iNewSize)
Definition: LightingShaderResourceManager.cpp:196
std::pair< std::recursive_mutex, GpuData > * getInternalResources()
Definition: LightingShaderResourceManager.cpp:127
static const std::string sSpotlightsShaderResourceName
Definition: LightingShaderResourceManager.h:1000
std::optional< Error > rebindGpuDataToAllPipelines()
Definition: LightingShaderResourceManager.cpp:327
void onPointLightsInFrustumCulled(size_t iCurrentFrameResourceIndex)
Definition: LightingShaderResourceManager.cpp:220
ComputeShaderData::LightCullingComputeShader::ComputeShader lightCullingComputeShaderData
Definition: LightingShaderResourceManager.h:979
static std::string getPointLightsShaderResourceName()
Definition: LightingShaderResourceManager.cpp:1303
void onEngineShadersCompiled()
Definition: LightingShaderResourceManager.cpp:1271
static std::string getShadowPassLightInfoArrayShaderResourceName()
Definition: LightingShaderResourceManager.cpp:1323
std::optional< Error > updateDescriptorsForPipelineResource(Pipeline *pPipeline)
Definition: LightingShaderResourceManager.cpp:81
ShaderLightArray * getDirectionalLightDataArray() const
Definition: LightingShaderResourceManager.cpp:23
static std::string getSpotlightsShaderResourceName()
Definition: LightingShaderResourceManager.cpp:1311
static std::string getSpotlightsInCameraFrustumIndicesShaderResourceName()
Definition: LightingShaderResourceManager.cpp:1319
static std::string getPointLightsInCameraFrustumIndicesShaderResourceName()
Definition: LightingShaderResourceManager.cpp:1315
void onSpotlightArraySizeChanged(size_t iNewSize)
Definition: LightingShaderResourceManager.cpp:270
static std::string getDirectionalLightsShaderResourceName()
Definition: LightingShaderResourceManager.cpp:1307
bool bEngineShadersCompiled
Definition: LightingShaderResourceManager.h:988
static const std::string sPointLightsShaderResourceName
Definition: LightingShaderResourceManager.h:994
static constexpr auto generalLightingDataDescriptorType
Definition: LightingShaderResourceManager.h:1017
void copyDataToGpu(size_t iCurrentFrameResourceIndex)
Definition: LightingShaderResourceManager.cpp:319
std::pair< std::recursive_mutex, GpuData > mtxGpuData
Definition: LightingShaderResourceManager.h:973
Definition: Pipeline.h:20
std::string getPipelineIdentifier() const
Definition: Pipeline.cpp:175
Definition: Renderer.h:43
Definition: FrameResource.h:15
unsigned int iThreadGroupCountY
Definition: LightingShaderResourceManager.h:549
unsigned int iTileCountX
Definition: LightingShaderResourceManager.h:552
unsigned int iThreadGroupCountX
Definition: LightingShaderResourceManager.h:546
unsigned int iTileCountY
Definition: LightingShaderResourceManager.h:555
ShaderResources resources
Definition: LightingShaderResourceManager.h:617
static const auto sCalculatedFrustumsShaderResourceName
Definition: LightingShaderResourceManager.h:650
static const auto sScreenToViewDataShaderResourceName
Definition: LightingShaderResourceManager.h:644
std::optional< Error > initialize(Renderer *pRenderer)
Definition: LightingShaderResourceManager.cpp:726
std::unique_ptr< ComputeShaderInterface > pComputeInterface
Definition: LightingShaderResourceManager.h:614
unsigned int iLastUpdateTileCountY
Definition: LightingShaderResourceManager.h:629
unsigned int iLastUpdateTileCountX
Definition: LightingShaderResourceManager.h:623
static const auto sComputeInfoShaderResourceName
Definition: LightingShaderResourceManager.h:638
std::optional< Error > updateDataAndSubmitShader(Renderer *pRenderer, const std::pair< unsigned int, unsigned int > &renderTargetSize, const glm::mat4 &inverseProjectionMatrix)
Definition: LightingShaderResourceManager.cpp:637
unsigned int iRenderTargetWidth
Definition: LightingShaderResourceManager.h:564
unsigned int iRenderTargetHeight
Definition: LightingShaderResourceManager.h:567
std::unique_ptr< GpuResource > pCalculatedFrustums
Definition: LightingShaderResourceManager.h:585
std::unique_ptr< UploadBuffer > pComputeInfo
Definition: LightingShaderResourceManager.h:576
std::unique_ptr< UploadBuffer > pScreenToViewData
Definition: LightingShaderResourceManager.h:582
Definition: LightingShaderResourceManager.h:535
Plane planes[4]
Definition: LightingShaderResourceManager.h:537
std::variant< bool, Error > createLightIndexListsAndLightGrid(Renderer *pRenderer, size_t iTileCountX, size_t iTileCountY)
Definition: LightingShaderResourceManager.cpp:890
static const auto sGlobalCountersIntoLightIndexListShaderResourceName
Definition: LightingShaderResourceManager.h:834
ShaderResources resources
Definition: LightingShaderResourceManager.h:810
ThreadGroupCount threadGroupCount
Definition: LightingShaderResourceManager.h:813
std::optional< Error > initialize(Renderer *pRenderer, const FrustumGridComputeShader::ComputeShader &frustumGridShader)
Definition: LightingShaderResourceManager.cpp:802
std::optional< Error > queueExecutionForNextFrame(Renderer *pRenderer, FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, GpuResource *pGeneralLightingData, GpuResource *pPointLightArray, GpuResource *pSpotlightArray, GpuResource *pNonCulledPointLightsIndicesArray, GpuResource *pNonCulledSpotlightsIndicesArray) const
Definition: LightingShaderResourceManager.cpp:1044
static const auto sThreadGroupCountShaderResourceName
Definition: LightingShaderResourceManager.h:828
static const auto sDepthTextureShaderResourceName
Definition: LightingShaderResourceManager.h:822
std::unique_ptr< ComputeShaderInterface > pComputeInterface
Definition: LightingShaderResourceManager.h:807
std::unique_ptr< GpuResource > pOpaqueSpotLightGrid
Definition: LightingShaderResourceManager.h:715
std::unique_ptr< UploadBuffer > pThreadGroupCount
Definition: LightingShaderResourceManager.h:688
std::unique_ptr< GpuResource > pTransparentPointLightGrid
Definition: LightingShaderResourceManager.h:721
std::unique_ptr< GpuResource > pTransparentSpotLightIndexList
Definition: LightingShaderResourceManager.h:703
std::unique_ptr< GpuResource > pOpaquePointLightIndexList
Definition: LightingShaderResourceManager.h:694
std::unique_ptr< GpuResource > pGlobalCountersIntoLightIndexList
Definition: LightingShaderResourceManager.h:691
std::unique_ptr< GpuResource > pOpaquePointLightGrid
Definition: LightingShaderResourceManager.h:709
std::unique_ptr< GpuResource > pOpaqueSpotLightIndexList
Definition: LightingShaderResourceManager.h:697
std::unique_ptr< GpuResource > pTransparentPointLightIndexList
Definition: LightingShaderResourceManager.h:700
std::unique_ptr< GpuResource > pTransparentSpotLightGrid
Definition: LightingShaderResourceManager.h:727
unsigned int iThreadGroupCountY
Definition: LightingShaderResourceManager.h:679
unsigned int iThreadGroupCountX
Definition: LightingShaderResourceManager.h:676
Definition: LightingShaderResourceManager.h:522
glm::vec3 normal
Definition: LightingShaderResourceManager.h:524
float distanceFromOrigin
Definition: LightingShaderResourceManager.h:527
Definition: LightingShaderResourceManager.h:516
Definition: LightingShaderResourceManager.h:56
glm::vec4 ambientLight
Definition: LightingShaderResourceManager.h:58
unsigned int iPointLightCountInCameraFrustum
Definition: LightingShaderResourceManager.h:61
unsigned int iSpotLightCountInCameraFrustum
Definition: LightingShaderResourceManager.h:67
unsigned int iDirectionalLightCount
Definition: LightingShaderResourceManager.h:64
Definition: LightingShaderResourceManager.h:71
std::array< std::unique_ptr< UploadBuffer >, FrameResourceManager::getFrameResourceCount()> vGeneralDataGpuResources
Definition: LightingShaderResourceManager.h:76
GeneralLightingShaderData generalData
Definition: LightingShaderResourceManager.h:83
Definition: LightingShaderResourceManager.h:501
std::unique_ptr< ShaderLightArray > pShadowPassLightInfoArray
Definition: LightingShaderResourceManager.h:512
std::unique_ptr< ShaderLightArray > pSpotlightDataArray
Definition: LightingShaderResourceManager.h:509
std::unique_ptr< ShaderLightArray > pDirectionalLightDataArray
Definition: LightingShaderResourceManager.h:506
std::unique_ptr< ShaderLightArray > pPointLightDataArray
Definition: LightingShaderResourceManager.h:503
Definition: LightingShaderResourceManager.h:38
glm::vec4 position
Definition: LightingShaderResourceManager.h:43
glm::mat4 viewProjectionMatrix
Definition: LightingShaderResourceManager.h:40