From 99e7dbfa01ff11de6aae872c4ad7c3813385ceaa Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Wed, 28 Dec 2022 20:47:20 +0800 Subject: [PATCH] WIP --- Assets/Shaders/DebugDrawMesh_VS.glsl | 2 +- Assets/Shaders/DebugDrawMesh_VS.shshaderb | Bin 1853 -> 1761 bytes Assets/Shaders/DebugDraw_VS.glsl | 2 +- Assets/Shaders/DebugDraw_VS.shshaderb | Bin 1749 -> 1657 bytes Assets/Shaders/DeferredComposite_CS.glsl | 12 +- Assets/Shaders/DeferredComposite_CS.shshaderb | Bin 5501 -> 5501 bytes Assets/Shaders/Kirsch_CS.glsl | 4 +- Assets/Shaders/Normals_FS.glsl | 2 +- Assets/Shaders/Normals_FS.shshaderb | Bin 2437 -> 2437 bytes Assets/Shaders/PureCopy_CS.glsl | 4 +- Assets/Shaders/PureCopy_CS.shshaderb | Bin 1273 -> 1273 bytes Assets/Shaders/SSAOBlur_CS.glsl | 4 +- Assets/Shaders/SSAOBlur_CS.shshaderb | Bin 4669 -> 4669 bytes Assets/Shaders/SSAO_CS.glsl | 12 +- Assets/Shaders/SSAO_CS.shshaderb | Bin 6141 -> 6141 bytes Assets/Shaders/TestCube_FS.glsl | 2 +- Assets/Shaders/TestCube_FS.shshaderb | Bin 2401 -> 2401 bytes Assets/Shaders/TestCube_Tile_FS.glsl | 2 +- Assets/Shaders/TestCube_Tile_FS.shshaderb | Bin 2185 -> 2185 bytes Assets/Shaders/TestCube_Tile_VS.glsl | 4 +- Assets/Shaders/TestCube_Tile_VS.shshaderb | Bin 4205 -> 4113 bytes Assets/Shaders/TestCube_VS.glsl | 2 +- Assets/Shaders/TestCube_VS.shshaderb | Bin 3781 -> 3689 bytes Assets/Shaders/Text_FS.glsl | 2 +- Assets/Shaders/Text_FS.shshaderb | Bin 2801 -> 2801 bytes Assets/Shaders/Text_VS.glsl | 4 +- Assets/Shaders/Text_VS.shshaderb | Bin 4921 -> 4813 bytes Assets/Shaders/ToSwapchain_FS.glsl | 2 +- Assets/Shaders/ToSwapchain_FS.shshaderb | Bin 881 -> 881 bytes Assets/Shaders/UI_FS.glsl | 2 +- Assets/Shaders/UI_FS.shshaderb | Bin 2285 -> 2285 bytes Assets/Shaders/UI_VS.glsl | 2 +- Assets/Shaders/UI_VS.shshaderb | Bin 3909 -> 3817 bytes .../MaterialInspector/SHMaterialInspector.cpp | 4 +- .../Graphics/MiddleEnd/Batching/SHBatch.cpp | 15 +-- .../GlobalData/SHGlobalDescriptorSets.cpp | 4 +- ...dData.cpp => SHGraphicsPredefinedData.cpp} | 79 +++++++----- ...finedData.h => SHGraphicsPredefinedData.h} | 40 ++++-- .../MiddleEnd/Interface/SHGraphicsConstants.h | 122 +++++++++--------- .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 35 +++-- .../MiddleEnd/Interface/SHMaterial.cpp | 6 +- .../Interface/SHMaterialInstance.cpp | 14 +- .../Interface/SHPostOffscreenRenderSystem.cpp | 2 +- .../MiddleEnd/Interface/SHRenderer.cpp | 4 +- .../Graphics/MiddleEnd/Interface/SHRenderer.h | 2 +- .../MiddleEnd/Lights/SHLightingSubSystem.cpp | 14 +- .../MiddleEnd/Pipeline/SHPipelineLibrary.cpp | 6 +- .../MiddleEnd/Pipeline/SHPipelineLibrary.h | 2 +- .../MiddleEnd/TextRendering/SHFont.cpp | 11 +- .../Graphics/MiddleEnd/TextRendering/SHFont.h | 1 + .../SHTextRenderingSubSystem.cpp | 12 +- .../TextRendering/SHTextRenderingSubSystem.h | 1 + .../MiddleEnd/Textures/SHTextureLibrary.cpp | 9 +- .../Graphics/Pipeline/SHVkPipelineLayout.cpp | 4 +- .../Graphics/RenderGraph/SHRenderGraph.cpp | 17 ++- .../src/Graphics/RenderGraph/SHRenderGraph.h | 2 +- .../RenderGraph/SHRenderGraphNode.cpp | 10 +- .../Graphics/RenderGraph/SHRenderGraphNode.h | 2 +- .../RenderGraph/SHRenderGraphNodeCompute.cpp | 48 ++++--- .../RenderGraph/SHRenderGraphNodeCompute.h | 4 +- .../RenderGraph/SHRenderGraphStorage.h | 2 +- .../SHRenderToSwapchainImageSystem.cpp | 4 +- .../src/Graphics/RenderGraph/SHSubpass.cpp | 19 ++- .../src/Graphics/RenderGraph/SHSubpass.h | 2 +- .../Serialization/SHSerializationHelper.hpp | 4 +- SHADE_Engine/src/Tools/SHEnumWrapper.h | 67 ++++++++++ .../src/Tools/Utilities/SHUtilities.h | 67 ---------- 67 files changed, 392 insertions(+), 307 deletions(-) rename SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/{SHPredefinedData.cpp => SHGraphicsPredefinedData.cpp} (67%) rename SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/{SHPredefinedData.h => SHGraphicsPredefinedData.h} (67%) create mode 100644 SHADE_Engine/src/Tools/SHEnumWrapper.h diff --git a/Assets/Shaders/DebugDrawMesh_VS.glsl b/Assets/Shaders/DebugDrawMesh_VS.glsl index 19c1a5b9..1f3b43ac 100644 --- a/Assets/Shaders/DebugDrawMesh_VS.glsl +++ b/Assets/Shaders/DebugDrawMesh_VS.glsl @@ -11,7 +11,7 @@ layout(location = 0) out struct vec4 Color; } Out; -layout(set = 2, binding = 0) uniform CameraData +layout(set = 1, binding = 0) uniform CameraData { vec4 position; mat4 vpMat; diff --git a/Assets/Shaders/DebugDrawMesh_VS.shshaderb b/Assets/Shaders/DebugDrawMesh_VS.shshaderb index 442cd789d87ff082d13ea456d7891105d3a27d52..c00e88f88b132792cb414c29188eba6b09c32e11 100644 GIT binary patch delta 57 zcmdnX_mG#F@dn#Q<{gZJtPFw-3=GUbTu_vs<(pWt`3>V##>qRGB^VhuUt*SJWMrHC MfkkvPC#wk)0JF>v?*IS* delta 141 zcmaFJyO)od(S&^?^A1Ksb_PKP1_ovzE=VmZE=Wx-$t+9tO)OzxU;{#s919TV7nNk> zgGCuOpJANJsOtd~hDovl6?ibP!uiTT{sm;Q$zjaOj7*!Wm}MEcA@;EYr3E(6V{v8z E000CPfdBvi diff --git a/Assets/Shaders/DebugDraw_VS.glsl b/Assets/Shaders/DebugDraw_VS.glsl index ce2dd544..dbfa7645 100644 --- a/Assets/Shaders/DebugDraw_VS.glsl +++ b/Assets/Shaders/DebugDraw_VS.glsl @@ -10,7 +10,7 @@ layout(location = 0) out struct vec4 vertColor; // location 0 } Out; -layout(set = 2, binding = 0) uniform CameraData +layout(set = 1, binding = 0) uniform CameraData { vec4 position; mat4 vpMat; diff --git a/Assets/Shaders/DebugDraw_VS.shshaderb b/Assets/Shaders/DebugDraw_VS.shshaderb index 9f5f7766a6fa15f0cfbb3fda364868075c99fad5..3ce6c3126f871cc084c827c69f936c92dae1cd4d 100644 GIT binary patch delta 58 zcmcc0`;&)>v0x+9Rz^Wq20;b}24)~GD9X?BO)S~`g0Yox@=|6AM#jzin0Xo5*}y8; KH(z7<&j{49q}WkXlq+keXbQS(fUXSi-=-2819v79h?qD#^$P zi!y9J!Pv^E>j4yoNwNYJcrdWS`N}~41!S?wPRz=TOqAgu_*Oi;cukX8a>m^_FNk_Q2hdQBjWEDz#?Y$DYpz03#y}egFUf delta 153 zcmeyX^;c`dMwWUO1_lOq1{MY>Agu_*Oi;cukX8a>m^_FNk_Q2hdQBjWEDz#?os8Qg$05NtMJ-OI?xGWi{wJR{3yKK6V*03^8$ga7~l diff --git a/Assets/Shaders/Kirsch_CS.glsl b/Assets/Shaders/Kirsch_CS.glsl index 3dec174d..8c60525a 100644 --- a/Assets/Shaders/Kirsch_CS.glsl +++ b/Assets/Shaders/Kirsch_CS.glsl @@ -50,8 +50,8 @@ #define NUM_MASKS 8 layout(local_size_x = 16, local_size_y = 16) in; -layout(set = 4, binding = 0, rgba8) uniform image2D inputImage; -layout(set = 4, binding = 1, rgba8) uniform image2D resultImage; +layout(set = 3, binding = 0, rgba8) uniform image2D inputImage; +layout(set = 3, binding = 1, rgba8) uniform image2D resultImage; const float kirsch[8][3][3] = { { diff --git a/Assets/Shaders/Normals_FS.glsl b/Assets/Shaders/Normals_FS.glsl index ba260d82..78b0a027 100644 --- a/Assets/Shaders/Normals_FS.glsl +++ b/Assets/Shaders/Normals_FS.glsl @@ -28,7 +28,7 @@ layout(location = 3) flat in struct } In2; layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) -layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials { MatPropData data[]; } MatProp; diff --git a/Assets/Shaders/Normals_FS.shshaderb b/Assets/Shaders/Normals_FS.shshaderb index 7595ece992210bbf6849ea1b242415990e5f4c3b..7f72d16f3a00f591aa3e2d61c458d7716631b3f4 100644 GIT binary patch delta 14 VcmZn_ZWZ3($->CA*^9-R6#yP819AWW delta 14 VcmZn_ZWZ3($->CI*^9-R6#yPE19JcX diff --git a/Assets/Shaders/PureCopy_CS.glsl b/Assets/Shaders/PureCopy_CS.glsl index 89da6dd9..6f396199 100644 --- a/Assets/Shaders/PureCopy_CS.glsl +++ b/Assets/Shaders/PureCopy_CS.glsl @@ -46,8 +46,8 @@ layout(local_size_x = 16, local_size_y = 16) in; -layout(set = 4, binding = 0, rgba8) uniform image2D inputImage; -layout(set = 4, binding = 1, rgba8) uniform image2D targetImage; +layout(set = 3, binding = 0, rgba8) uniform image2D inputImage; +layout(set = 3, binding = 1, rgba8) uniform image2D targetImage; void main() diff --git a/Assets/Shaders/PureCopy_CS.shshaderb b/Assets/Shaders/PureCopy_CS.shshaderb index 30a629f5bcc0a56885e4bad78b8a2a3c41950982..158214301f698e895295f654f39b8802303d6ebc 100644 GIT binary patch delta 20 bcmey#`IB=)CL<&BZc3S}eVOkDx delta 47 zcmeyX|5txQE;A#`OG5a&JZq{SzXJ$4wHr{-I-BthqSWFEn diff --git a/Assets/Shaders/TestCube_FS.glsl b/Assets/Shaders/TestCube_FS.glsl index d6f88687..b6a1eab6 100644 --- a/Assets/Shaders/TestCube_FS.glsl +++ b/Assets/Shaders/TestCube_FS.glsl @@ -28,7 +28,7 @@ layout(location = 3) flat in struct } In2; layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) -layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials { MatPropData data[]; } MatProp; diff --git a/Assets/Shaders/TestCube_FS.shshaderb b/Assets/Shaders/TestCube_FS.shshaderb index bcf5bf5ec1c14753c2ee4942289ea98261360a16..abd90cf744ad1b20429e7740fe4354edc390101c 100644 GIT binary patch delta 14 VcmaDT^iXJnCkrFfW-k_TRsbg=1Oxy8 delta 14 VcmaDT^iXJnCkrF=fMamzj}i^FQWp762$31uFmm delta 14 VcmeAa>=fMamzj}y^FQWp762$91uOsn diff --git a/Assets/Shaders/TestCube_Tile_VS.glsl b/Assets/Shaders/TestCube_Tile_VS.glsl index d27805ef..d3a1a0de 100644 --- a/Assets/Shaders/TestCube_Tile_VS.glsl +++ b/Assets/Shaders/TestCube_Tile_VS.glsl @@ -34,7 +34,7 @@ layout(location = 3) out struct } Out2; -layout(set = 2, binding = 0) uniform CameraData +layout(set = 1, binding = 0) uniform CameraData { vec4 position; mat4 vpMat; @@ -42,7 +42,7 @@ layout(set = 2, binding = 0) uniform CameraData mat4 projMat; } cameraData; -layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials { MatPropData data[]; } MatProp; diff --git a/Assets/Shaders/TestCube_Tile_VS.shshaderb b/Assets/Shaders/TestCube_Tile_VS.shshaderb index 9f83665663ad873e8c70d38c5227866e929b07d9..c7749607eeed6beb8fec3a36648f9e15387766c9 100644 GIT binary patch delta 64 zcmaE>Fj0Ytkz*s%OGZIf22}J&E%aYS22}j4yoNwNYJcrdWS`N}~41!S?w=U9{(nI?Z?+0Mwkc@--w6C?ZN4eX+u J53&bv006Fj8uq`%;F9F<~RqOGZIf22}>j4yoNwNYJcrdWS`N}~41!S?wZY;`-Oq;Vy3 C{up`y diff --git a/Assets/Shaders/Text_FS.glsl b/Assets/Shaders/Text_FS.glsl index fdf32583..36bdb8eb 100644 --- a/Assets/Shaders/Text_FS.glsl +++ b/Assets/Shaders/Text_FS.glsl @@ -28,7 +28,7 @@ layout(location = 3) flat in struct -layout(set = 4, binding = 0) uniform sampler2D fontBitmap; +layout(set = 2, binding = 0) uniform sampler2D fontBitmap; layout(location = 0) out vec4 color; layout(location = 1) out uint outEntityID; diff --git a/Assets/Shaders/Text_FS.shshaderb b/Assets/Shaders/Text_FS.shshaderb index d9b47d6ee781fc9da896109c90deb842550c2a77..024073a8ae8ef98827d7d1b01cf002338151d30a 100644 GIT binary patch delta 14 Vcmew;`cZVlLncP1&5xM)IRG%91yKM1 delta 14 Vcmew;`cZVlLncO+&5xM)IRG%L1ycY3 diff --git a/Assets/Shaders/Text_VS.glsl b/Assets/Shaders/Text_VS.glsl index 0498ae39..1e05dd25 100644 --- a/Assets/Shaders/Text_VS.glsl +++ b/Assets/Shaders/Text_VS.glsl @@ -25,7 +25,7 @@ layout(location = 3) out struct } Out2; // Camera data -layout(set = 2, binding = 0) uniform CameraData +layout(set = 1, binding = 0) uniform CameraData { vec4 position; mat4 vpMat; @@ -43,7 +43,7 @@ layout(std140, push_constant) uniform TestPushConstant } testPushConstant; // Descriptor sets -layout(std430, set = 4, binding = 1) buffer GlyphTransforms +layout(std430, set = 2, binding = 1) buffer GlyphTransforms { mat4 matrices[]; } glyphTransforms; diff --git a/Assets/Shaders/Text_VS.shshaderb b/Assets/Shaders/Text_VS.shshaderb index 25eff84a998699690af58db696ddca8c8bc20864..527b3db78c0c72f55812d5231faa7654e421e5b4 100644 GIT binary patch delta 317 zcmdm~c2-r4@rV!u7%(#_vokO-GH@~QGA!OG_LW(Xm0=1{h8c(pit@936H7MRurM+* zGHteFjb@yDkxhb;aq}xSRu)FK$sf2xCv$QuuqrUHFf80`$9qOTSi$nMfNYQ&kT^(w&W zAr{3j4=Tt6qyre(8MJ`(d>{rH0MY=Gmj>dAK!ZVY3xF8p0FW9-px8nny$FaW1FS6ov2PS0W-Jc2f}{RL~&m11N}_ZYm0{bR`ndjV(2}b??qb{I|B%7m!)` z5Q6vuK81U~ThnU7H+RlCH+P1-SKj7IW_eQjkL$#th>=Lfd~VwH5zh$A2$B4r1fjR^WT1 zzsD{RCwV(sno1Znj=BataF(@aKcg@I>;`#NM61{d`&&?dpzql4K#TJ=zX$D6UwbOl z2iSyddPb;^g-02B?ZPvE-mW|qrbFG5Q1sRv&;j~^=4H5Gux4G*3v^%|uSb1`9Ohw- M->tf9&nGs_4-?-vp8x;= diff --git a/Assets/Shaders/ToSwapchain_FS.glsl b/Assets/Shaders/ToSwapchain_FS.glsl index a68fa0c7..3cf1752f 100644 --- a/Assets/Shaders/ToSwapchain_FS.glsl +++ b/Assets/Shaders/ToSwapchain_FS.glsl @@ -3,7 +3,7 @@ #extension GL_ARB_shading_language_420pack : enable #extension GL_EXT_nonuniform_qualifier : require -layout (input_attachment_index = 0, set = 4, binding = 0) uniform subpassInput sceneTexture; +layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput sceneTexture; layout(location = 0) out vec4 fragColor; diff --git a/Assets/Shaders/ToSwapchain_FS.shshaderb b/Assets/Shaders/ToSwapchain_FS.shshaderb index b10a9d6cc18532c8501c040dbbba8899a7e9af1a..0bee0ac67036b416f1ad7249d12b6e7ea411b98d 100644 GIT binary patch delta 14 Vcmey!_K|HvCnF=n<}SwPi~uZA1yBG0 delta 14 Vcmey!_K|HvCnF=v<}SwPi~uZY1yle4 diff --git a/Assets/Shaders/UI_FS.glsl b/Assets/Shaders/UI_FS.glsl index 093cc9c6..0c4c526c 100644 --- a/Assets/Shaders/UI_FS.glsl +++ b/Assets/Shaders/UI_FS.glsl @@ -28,7 +28,7 @@ layout(location = 3) flat in struct } In2; layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) -layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials { MatPropData data[]; } MatProp; diff --git a/Assets/Shaders/UI_FS.shshaderb b/Assets/Shaders/UI_FS.shshaderb index fcb72b6e912e98ddd75e1e9eb888bad2282d0f97..703040e1a63c9c59d398cc68a6df7121a76c6b39 100644 GIT binary patch delta 14 VcmaDW_*QU(CkrFfW-pe-EC4B41f>7~ delta 14 VcmaDW_*QU(CkrFq_fnRb@d4jP<`;~DtPH9Q3=GUbTu_vs<(pWtS%xW;Y4S=I2}Z`vhge*h*xA4; S6gLa8A7^A_-h7KAn+*Uc>JP^N delta 142 zcmaDUdsL2@(T0B`^9x2pb_P`j1_ovzE=VmZE=Wx-$t+9tO)OzxU;{#s919TV7nNk> zgGCuO|6vSe()9oe!z5XO3OpEC;e2Hv{{phuWH%ONMyAbKEUrw9?2|XJiEci~wuh0C KWpf=zHX8twl^MwZ diff --git a/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp b/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp index 9dbb9542..ddcef902 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp @@ -196,10 +196,12 @@ namespace SHADE if (!fragShader) return; + auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); + // Get interface for the shader combination auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface ( - SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, + mappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA ); if (!interface) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp index c92ad808..ab36a7b4 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp @@ -25,7 +25,7 @@ of DigiPen Institute of Technology is prohibited. #include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" #include "ECS_Base/Managers/SHComponentManager.h" #include "Math/Transform/SHTransformComponent.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "Graphics/Descriptors/SHVkDescriptorPool.h" #include "Scene/SHSceneManager.h" #include "UI/SHUIComponent.h" @@ -411,12 +411,12 @@ namespace SHADE instancedIntegerData.reserve(numTotalElements); instancedIntegerData.clear(); - auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; + auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); // - Material Properties Data const Handle SHADER_INFO = pipeline->GetPipelineLayout()->GetShaderBlockInterface ( - descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), + descMappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, vk::ShaderStageFlagBits::eFragment ); @@ -571,14 +571,14 @@ namespace SHADE cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::INTEGER_DATA, instancedIntegerBuffer[frameIndex], 0); if (matPropsDescSet[frameIndex]) { - auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; + auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); cmdBuffer->BindDescriptorSet ( matPropsDescSet[frameIndex], SH_PIPELINE_TYPE::GRAPHICS, //SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, - descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), + descMappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), dynamicOffset ); } @@ -611,7 +611,7 @@ namespace SHADE { matPropsDescSet[frameIndex] = descPool->Allocate ( - SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::MATERIALS), + SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::MATERIALS), { 0 } ); #ifdef _DEBUG @@ -623,8 +623,7 @@ namespace SHADE #endif } - auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; - uint32_t const MATERIAL_DESC_SET_INDEX = descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS); + static constexpr uint32_t MATERIAL_DESC_SET_INDEX = 0; std::array, 1> bufferList = { matPropsBuffer[frameIndex] }; matPropsDescSet[frameIndex]->ModifyWriteDescBuffer diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.cpp index 09dbef51..9e1263cf 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.cpp @@ -23,8 +23,8 @@ namespace SHADE void SHGlobalDescriptorSets::BindStaticGlobalData(Handle cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept { // Bind descriptor set for static global data - static constexpr std::array TEX_DYNAMIC_OFFSET{ 0 }; - cmdBuffer->BindDescriptorSet(staticGlobalDataDescriptorSet, pipelineType, setIndex, const std::span{ TEX_DYNAMIC_OFFSET.data(), 1 }); + static std::array TEX_DYNAMIC_OFFSET{ 0 }; + cmdBuffer->BindDescriptorSet(staticGlobalDataDescriptorSet, pipelineType, setIndex, std::span{ TEX_DYNAMIC_OFFSET.data(), 1 }); } /***************************************************************************/ diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHPredefinedData.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp similarity index 67% rename from SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHPredefinedData.cpp rename to SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp index ac7ab982..36566108 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHPredefinedData.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp @@ -1,5 +1,5 @@ #include "SHpch.h" -#include "SHPredefinedData.h" +#include "SHGraphicsPredefinedData.h" #include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Pipeline/SHPipelineState.h" #include "Graphics/Pipeline/SHVkPipelineLayout.h" @@ -11,29 +11,32 @@ namespace SHADE /*-----------------------------------------------------------------------------------*/ /* Static Definitions */ /*-----------------------------------------------------------------------------------*/ - std::vector> SHPredefinedData::predefinedLayouts; - SHVertexInputState SHPredefinedData::defaultVertexInputState; - SHPredefinedData::PerSystem SHPredefinedData::batchingSystemData; - SHPredefinedData::PerSystem SHPredefinedData::textSystemData; - SHPredefinedData::PerSystem SHPredefinedData::renderGraphNodeComputeData; + std::vector> SHGraphicsPredefinedData::predefinedLayouts; + SHVertexInputState SHGraphicsPredefinedData::defaultVertexInputState; + std::vector SHGraphicsPredefinedData::perSystemData; - void SHPredefinedData::InitDescMappings(void) noexcept + //SHGraphicsPredefinedData::PerSystem SHGraphicsPredefinedData::batchingSystemData; + //SHGraphicsPredefinedData::PerSystem SHGraphicsPredefinedData::textSystemData; + //SHGraphicsPredefinedData::PerSystem SHGraphicsPredefinedData::renderGraphNodeComputeData; + + void SHGraphicsPredefinedData::InitDescMappings(void) noexcept { - batchingSystemData.descMappings.AddMappings + + perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descMappings.AddMappings ({ {SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0}, {SHGraphicsConstants::DescriptorSetTypes::CAMERA, 1}, {SHGraphicsConstants::DescriptorSetTypes::MATERIALS, 2}, }); - textSystemData.descMappings.AddMappings + perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descMappings.AddMappings ({ {SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0}, {SHGraphicsConstants::DescriptorSetTypes::CAMERA, 1}, {SHGraphicsConstants::DescriptorSetTypes::FONT, 2}, }); - renderGraphNodeComputeData.descMappings.AddMappings + perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descMappings.AddMappings ({ {SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0}, {SHGraphicsConstants::DescriptorSetTypes::LIGHTS, 1}, @@ -43,16 +46,17 @@ namespace SHADE }); } - void SHPredefinedData::InitDummyPipelineLayouts(Handle logicalDevice) noexcept + void SHGraphicsPredefinedData::InitDummyPipelineLayouts(Handle logicalDevice) noexcept { - batchingSystemData.dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ batchingSystemData.descSetLayouts }); - textSystemData.dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ textSystemData.descSetLayouts }); + perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descSetLayouts }); + perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descSetLayouts }); + perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descSetLayouts }); } /*-----------------------------------------------------------------------------------*/ /* Function Definitions */ /*-----------------------------------------------------------------------------------*/ - void SHPredefinedData::InitDescSetLayouts(Handle logicalDevice) noexcept + void SHGraphicsPredefinedData::InitDescSetLayouts(Handle logicalDevice) noexcept { SHVkDescriptorSetLayout::Binding genericDataBinding { @@ -153,22 +157,29 @@ namespace SHADE predefinedLayouts.push_back(materialDataPerInstanceLayout); predefinedLayouts.push_back(fontDataDescSetLayout); - batchingSystemData.descSetLayouts = GetPredefinedDescSetLayouts + perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descSetLayouts = GetPredefinedDescSetLayouts ( SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA | SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA | SHGraphicsConstants::PredefinedDescSetLayoutTypes::MATERIALS ); - textSystemData.descSetLayouts = GetPredefinedDescSetLayouts + perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descSetLayouts = GetPredefinedDescSetLayouts ( SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA | SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA | SHGraphicsConstants::PredefinedDescSetLayoutTypes::FONT ); + + perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descSetLayouts = GetPredefinedDescSetLayouts + ( + SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA | + SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA | + SHGraphicsConstants::PredefinedDescSetLayoutTypes::LIGHTS + ); } - void SHPredefinedData::InitDefaultVertexInputState(void) noexcept + void SHGraphicsPredefinedData::InitDefaultVertexInputState(void) noexcept { defaultVertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_3D) }); // positions at binding 0 defaultVertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_2D) }); // UVs at binding 1 @@ -178,15 +189,16 @@ namespace SHADE defaultVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::UINT32_2D) }); // Instanced integer data at index 8 } - void SHPredefinedData::Init(Handle logicalDevice) noexcept + void SHGraphicsPredefinedData::Init(Handle logicalDevice) noexcept { + perSystemData.resize(SHUtilities::ConvertEnum(SystemType::NUM_TYPES)); InitDescSetLayouts(logicalDevice); InitDefaultVertexInputState(); InitDescMappings(); InitDummyPipelineLayouts (logicalDevice); } - std::vector> SHPredefinedData::GetPredefinedDescSetLayouts(SHEnumWrapper types) noexcept + std::vector> SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHEnumWrapper types) noexcept { std::vector> layoutsFound; for (uint8_t i = 0; i < SHGraphicsConstants::numPredefinedDescSetLayoutTypes; ++i) @@ -198,26 +210,35 @@ namespace SHADE return layoutsFound; } - - SHVertexInputState const& SHPredefinedData::GetDefaultViState(void) noexcept + SHVertexInputState const& SHGraphicsPredefinedData::GetDefaultViState(void) noexcept { return defaultVertexInputState; } - SHPredefinedData::PerSystem const& SHPredefinedData::GetBatchingSystemData(void) noexcept + SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetSystemData(SystemType systemType) noexcept { - return batchingSystemData; + return perSystemData[static_cast(systemType)]; } - SHPredefinedData::PerSystem const& SHPredefinedData::GetTextSystemData(void) noexcept + SHDescriptorMappings::MapType const& SHGraphicsPredefinedData::GetMappings(SystemType systemType) noexcept { - return textSystemData; + return perSystemData[static_cast(systemType)].descMappings.GetMappings(); } - SHPredefinedData::PerSystem const& SHPredefinedData::GetRenderGraphNodeComputeData(void) noexcept - { - return renderGraphNodeComputeData; - } + //SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetBatchingSystemData(void) noexcept + //{ + // return batchingSystemData; + //} + + //SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetTextSystemData(void) noexcept + //{ + // return textSystemData; + //} + + //SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetRenderGraphNodeComputeData(void) noexcept + //{ + // return renderGraphNodeComputeData; + //} } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHPredefinedData.h b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h similarity index 67% rename from SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHPredefinedData.h rename to SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h index b19a1e0b..ac10093a 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHPredefinedData.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h @@ -5,6 +5,8 @@ #include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h" #include "Graphics/MiddleEnd/GlobalData/SHDescriptorMappings.h" #include "Tools/Utilities/SHUtilities.h" +#include "Tools/SHEnumWrapper.h" +#include namespace SHADE { @@ -13,17 +15,24 @@ namespace SHADE class SHVkDescriptorSetGroup; class SHVkPipelineLayout; - - class SH_API SHPredefinedData + class SH_API SHGraphicsPredefinedData { public: + enum class SystemType + { + BATCHING = 0, + TEXT_RENDERING, + RENDER_GRAPH_NODE_COMPUTE, + NUM_TYPES + }; + struct PerSystem { //! vector of descriptor set layouts used by a system std::vector> descSetLayouts; //! pipeline layout used for binding descriptor sets in the system - static Handle dummyPipelineLayout; + Handle dummyPipelineLayout; //! Descriptor type mappings for the system SHDescriptorMappings descMappings; @@ -36,14 +45,17 @@ namespace SHADE //! Default vertex input state (used by everything). static SHVertexInputState defaultVertexInputState; - //! predefined data for the batching system - static PerSystem batchingSystemData; + //! Predefined data for each type of system + static std::vector perSystemData; - //! predefined data for the text system - static PerSystem textSystemData; + ////! predefined data for the batching system + //static PerSystem batchingSystemData; - //! predefined data for the render graph node computes - static PerSystem renderGraphNodeComputeData; + ////! predefined data for the text system + //static PerSystem textSystemData; + + ////! predefined data for the render graph node computes + //static PerSystem renderGraphNodeComputeData; static void InitDescMappings (void) noexcept; static void InitDummyPipelineLayouts (Handle logicalDevice) noexcept; @@ -54,7 +66,7 @@ namespace SHADE /*-----------------------------------------------------------------------*/ /* Constructors */ /*-----------------------------------------------------------------------*/ - SHPredefinedData() = delete; + SHGraphicsPredefinedData() = delete; /*-----------------------------------------------------------------------*/ /* PUBLIC MEMBER FUNCTIONS */ @@ -66,8 +78,10 @@ namespace SHADE /*-----------------------------------------------------------------------*/ static std::vector> GetPredefinedDescSetLayouts (SHEnumWrapper types) noexcept; static SHVertexInputState const& GetDefaultViState (void) noexcept; - static PerSystem const& GetBatchingSystemData(void) noexcept; - static PerSystem const& GetTextSystemData(void) noexcept; - static PerSystem const& GetRenderGraphNodeComputeData(void) noexcept; + static PerSystem const& GetSystemData (SystemType systemType) noexcept; + static SHDescriptorMappings::MapType const& GetMappings (SystemType systemType) noexcept; + //static PerSystem const& GetBatchingSystemData(void) noexcept; + //static PerSystem const& GetTextSystemData(void) noexcept; + //static PerSystem const& GetRenderGraphNodeComputeData(void) noexcept; }; } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h index 06ffe381..86742b53 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h @@ -58,68 +58,68 @@ namespace SHADE static constexpr uint32_t EDITOR = 0; }; - struct DescriptorSetIndex - { - /***************************************************************************/ - /*! - \brief - DescriptorSet Index for static global values like generic data, and - texture samplers - */ - /***************************************************************************/ - static constexpr uint32_t STATIC_GLOBALS = 0; - /***************************************************************************/ - /*! - \brief - DescriptorSet Index for dynamic global values like lights. - */ - /***************************************************************************/ - static constexpr uint32_t DYNAMIC_GLOBALS = 1; - /***************************************************************************/ - /*! - \brief - DescriptorSet Index for high frequency changing global values like - camera matrices. - */ - /***************************************************************************/ - static constexpr uint32_t HIGH_FREQUENCY_GLOBALS = 2; - /***************************************************************************/ - /*! - \brief - DescriptorSet Index for per-instance/material changing values. - */ - /***************************************************************************/ - static constexpr uint32_t PER_INSTANCE = 3; - /***************************************************************************/ - /*! - \brief - DescriptorSet Index for render graph resources. Unlike the sets from - 1 to 3 and 6, this set index does not have hard coded bindings and is - NOT part of the layouts included in the global data. - */ - /***************************************************************************/ - static constexpr uint32_t RENDERGRAPH_RESOURCE = 4; - /***************************************************************************/ - /*! - \brief - DescriptorSet Index for render graph node compute resources. For data - that we wish to pass to compute shaders in the render graph, this is - the set to use. Unlike the sets from 1 to 3 and 6, this set index does not have - hard coded bindings and is NOT part of the layouts included in the global - data. - */ - /***************************************************************************/ - static constexpr uint32_t RENDERGRAPH_NODE_COMPUTE_RESOURCE = 5; + //struct DescriptorSetIndex + //{ + // /***************************************************************************/ + // /*! + // \brief + // DescriptorSet Index for static global values like generic data, and + // texture samplers + // */ + // /***************************************************************************/ + // static constexpr uint32_t STATIC_GLOBALS = 0; + // /***************************************************************************/ + // /*! + // \brief + // DescriptorSet Index for dynamic global values like lights. + // */ + // /***************************************************************************/ + // static constexpr uint32_t DYNAMIC_GLOBALS = 1; + // /***************************************************************************/ + // /*! + // \brief + // DescriptorSet Index for high frequency changing global values like + // camera matrices. + // */ + // /***************************************************************************/ + // static constexpr uint32_t HIGH_FREQUENCY_GLOBALS = 2; + // /***************************************************************************/ + // /*! + // \brief + // DescriptorSet Index for per-instance/material changing values. + // */ + // /***************************************************************************/ + // static constexpr uint32_t PER_INSTANCE = 3; + // /***************************************************************************/ + // /*! + // \brief + // DescriptorSet Index for render graph resources. Unlike the sets from + // 1 to 3 and 6, this set index does not have hard coded bindings and is + // NOT part of the layouts included in the global data. + // */ + // /***************************************************************************/ + // static constexpr uint32_t RENDERGRAPH_RESOURCE = 4; + // /***************************************************************************/ + // /*! + // \brief + // DescriptorSet Index for render graph node compute resources. For data + // that we wish to pass to compute shaders in the render graph, this is + // the set to use. Unlike the sets from 1 to 3 and 6, this set index does not have + // hard coded bindings and is NOT part of the layouts included in the global + // data. + // */ + // /***************************************************************************/ + // static constexpr uint32_t RENDERGRAPH_NODE_COMPUTE_RESOURCE = 5; - /***************************************************************************/ - /*! - \brief - To store font data. - - */ - /***************************************************************************/ - static constexpr uint32_t FONT_DATA = 4; - }; + // /***************************************************************************/ + // /*! + // \brief + // To store font data. + // + // */ + // /***************************************************************************/ + // static constexpr uint32_t FONT_DATA = 4; + //}; struct DescriptorSetBindings { diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 43b05311..b531e707 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -31,7 +31,7 @@ of DigiPen Institute of Technology is prohibited. #include "Graphics/MiddleEnd/Interface/SHRenderable.h" #include "Graphics/MiddleEnd/Batching/SHSuperBatch.h" #include "SHGraphicsConstants.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "Graphics/Buffers/SHVkBuffer.h" #include "Graphics/Images/SHVkSampler.h" #include "Assets/Asset Types/SHTextureAsset.h" @@ -127,6 +127,22 @@ namespace SHADE SHAssetManager::CompileAsset("../../Assets/Shaders/DebugDraw_VS.glsl", false); SHAssetManager::CompileAsset("../../Assets/Shaders/DebugDraw_FS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/DebugDrawMesh_VS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/Normals_FS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/SSAOBlur_CS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_FS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_Tile_FS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_Tile_VS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_VS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/Text_FS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/ToSwapchain_FS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/ToSwapchain_VS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/UI_VS.glsl", false); // Load Built In Shaders static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet(VS_DEFAULT); @@ -207,7 +223,7 @@ namespace SHADE renderGraph->AddResource("Scene", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, windowDims.first, windowDims.second); renderGraph->AddResource("SSAO", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR8Unorm); renderGraph->AddResource("SSAO Blur", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR8Unorm); - renderGraph->AddResource("Present", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT }, windowDims.first, windowDims.second, vk::Format::eR8Unorm); + renderGraph->AddResource("Present", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT }, windowDims.first, windowDims.second); /*-----------------------------------------------------------------------*/ @@ -261,10 +277,10 @@ namespace SHADE // Add the pass to generate an image with just SSAO data Handle ssaoPass = gBufferNode->AddNodeCompute("SSAO", ssaoShader, { "Position", "Normals", "SSAO" }); auto ssaoDataBuffer = ssaoStorage->GetBuffer(); - ssaoPass->ModifyWriteDescBufferComputeResource(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_NODE_COMPUTE_RESOURCE, SHSSAO::DESC_SET_BUFFER_BINDING, { &ssaoDataBuffer, 1 }, 0, ssaoStorage->GetBuffer()->GetSizeStored()); + ssaoPass->ModifyWriteDescBufferComputeResource(SHSSAO::DESC_SET_BUFFER_BINDING, { &ssaoDataBuffer, 1 }, 0, ssaoStorage->GetBuffer()->GetSizeStored()); auto viewSamplerLayout = ssaoStorage->GetViewSamplerLayout(); - ssaoPass->ModifyWriteDescImageComputeResource(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_NODE_COMPUTE_RESOURCE, SHSSAO::DESC_SET_IMAGE_BINDING, { &viewSamplerLayout, 1 }); + ssaoPass->ModifyWriteDescImageComputeResource(SHSSAO::DESC_SET_IMAGE_BINDING, { &viewSamplerLayout, 1 }); ssaoPass->SetRenderer (worldRenderer); // Add another pass to blur SSAO @@ -392,7 +408,7 @@ namespace SHADE void SHGraphicsSystem::InitMiddleEnd(void) noexcept { - SHPredefinedData::Init(device); + SHGraphicsPredefinedData::Init(device); InitRenderGraph(); @@ -435,7 +451,6 @@ namespace SHADE auto uiNode = renderGraph->GetNode("Screen Space Pass"); textRenderingSubSystem->Init(device, uiNode->GetRenderpass(), uiNode->GetSubpass("UI"), descPool, textVS, textFS); - SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup()); SHGlobalDescriptorSets::SetLightingSubSystem(lightingSubSystem); } @@ -844,7 +859,7 @@ namespace SHADE } // Create the renderer - auto renderer = resourceManager.Create(device, swapchain->GetNumImages(), renderContextCmdPools, descPool); + auto renderer = resourceManager.Create(device, swapchain->GetNumImages(), descPool, projectionType); // Store renderers.emplace_back(renderer); @@ -989,6 +1004,8 @@ namespace SHADE ); device->WaitIdle(); graphicsTexCmdBuffer.Free(); graphicsTexCmdBuffer = {}; + SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup()); + } Handle SHGraphicsSystem::GetTextureHandle(SHTexture::Index textureId) const @@ -1006,7 +1023,7 @@ namespace SHADE void SHGraphicsSystem::BuildFonts(void) noexcept { - fontLibrary.BuildFonts(device, graphicsQueue, graphicsCmdPool, descPool, SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::FONT)[0], resourceManager); + fontLibrary.BuildFonts(device, graphicsQueue, graphicsCmdPool, descPool, SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::FONT)[0], resourceManager); } #pragma endregion ADD_REMOVE @@ -1245,7 +1262,7 @@ namespace SHADE device, SHPipelineLayoutParams { .shaderModules = { (instanced ? debugMeshVertShader : debugVertShader) , debugFragShader }, - .predefinedDescSetLayouts = SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA) + .predefinedDescSetLayouts = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING).descSetLayouts } ); auto pipeline = resourceManager.Create(device, pipelineLayout, nullptr, renderPass, subpass); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterial.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterial.cpp index 1a007b95..8e7dbd0f 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterial.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterial.cpp @@ -9,6 +9,8 @@ #include "ECS_Base/Managers/SHSystemManager.h" #include "SHGraphicsSystem.h" #include "SHMaterialInstance.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" + namespace SHADE { @@ -95,9 +97,11 @@ namespace SHADE /*-----------------------------------------------------------------------------------*/ Handle SHMaterial::GetShaderBlockInterface() const noexcept { + auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); return pipeline->GetPipelineLayout()->GetShaderBlockInterface ( - SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, + mappings.at (SHGraphicsConstants::DescriptorSetTypes::MATERIALS), + //SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, vk::ShaderStageFlagBits::eFragment ); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterialInstance.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterialInstance.cpp index 7526538f..6a1f235e 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterialInstance.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterialInstance.cpp @@ -16,6 +16,7 @@ of DigiPen Institute of Technology is prohibited. #include "SHMaterial.h" #include "Graphics/Pipeline/SHVkPipeline.h" #include "Tools/Logger/SHLogger.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" namespace SHADE { @@ -78,11 +79,12 @@ namespace SHADE /*-----------------------------------------------------------------------------------*/ Handle SHMaterialInstance::getShaderBlockInterface() const noexcept { - return baseMaterial->GetPipeline()->GetPipelineLayout()->GetShaderBlockInterface - ( - SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, - SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, - vk::ShaderStageFlagBits::eFragment - ); + return baseMaterial->GetPipeline()->GetPipelineLayout()->GetShaderBlockInterface + ( + SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING).at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), + //SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, + SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, + vk::ShaderStageFlagBits::eFragment + ); } } \ No newline at end of file diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHPostOffscreenRenderSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHPostOffscreenRenderSystem.cpp index 8b41a979..dd3b4366 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHPostOffscreenRenderSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHPostOffscreenRenderSystem.cpp @@ -56,7 +56,7 @@ namespace SHADE }; // Create descriptor set layout - offscreenRenderDescSetLayout = logicalDevice->CreateDescriptorSetLayout(0, { imageBinding }, false); + offscreenRenderDescSetLayout = logicalDevice->CreateDescriptorSetLayout({ imageBinding }, false); // Create descriptor set offscreenRenderDescSet = descriptorPool->Allocate({ offscreenRenderDescSetLayout }, { 1 }); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHRenderer.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHRenderer.cpp index be9f0482..b1508ce7 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHRenderer.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHRenderer.cpp @@ -21,7 +21,7 @@ of DigiPen Institute of Technology is prohibited. #include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" #include "Graphics/Buffers/SHVkBuffer.h" #include "Camera/SHCameraDirector.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" namespace SHADE { @@ -36,7 +36,7 @@ namespace SHADE //for (uint32_t i = 0; i < commandBuffers.size(); ++i) // commandBuffers[i] = cmdPools[i]->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY); - cameraDescriptorSet = descriptorPool->Allocate(SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA), { 1 }); + cameraDescriptorSet = descriptorPool->Allocate(SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA), { 1 }); #ifdef _DEBUG const auto& CAM_DESC_SETS = cameraDescriptorSet->GetVkHandle(); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHRenderer.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHRenderer.h index c93050d7..baf76187 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHRenderer.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHRenderer.h @@ -36,7 +36,7 @@ namespace SHADE class SHVkCommandBuffer; class SHCamera; class SHVkDescriptorSetGroup; - class SHPredefinedData; + class SHGraphicsPredefinedData; class SHVkDescriptorPool; class SHVkBuffer; class SHCameraDirector; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp index abbf88c3..93e80cb0 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp @@ -1,6 +1,6 @@ #include "SHpch.h" #include "SHLightingSubSystem.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "Tools/Utilities/SHUtilities.h" #include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Buffers/SHVkBuffer.h" @@ -320,15 +320,16 @@ namespace SHADE void SHLightingSubSystem::UpdateDescSet(uint32_t binding) noexcept { auto buffer = perTypeData[binding].GetDataBuffer(); + static constexpr uint32_t LIGHTING_DATA_SET_INDEX = 0; // We bind the buffer with the correct desc set binding - lightingDataDescSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, + lightingDataDescSet->ModifyWriteDescBuffer(LIGHTING_DATA_SET_INDEX, binding + 1, // we want to +1 here because the first binding is reserved for count { &buffer, 1 }, 0, perTypeData[binding].GetDataSize() * perTypeData[binding].GetMaxLights()); - lightingDataDescSet->UpdateDescriptorSetBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, binding + 1); // +1 here, same reason. see above + lightingDataDescSet->UpdateDescriptorSetBuffer(LIGHTING_DATA_SET_INDEX, binding + 1); // +1 here, same reason. see above } /***************************************************************************/ @@ -385,7 +386,7 @@ namespace SHADE std::fill (variableSizes.begin(), variableSizes.end(), 1); // Create the descriptor set - lightingDataDescSet = descPool->Allocate({ SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::LIGHTS) }, variableSizes); + lightingDataDescSet = descPool->Allocate({ SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::LIGHTS) }, variableSizes); #ifdef _DEBUG const auto& CAM_DESC_SETS = lightingDataDescSet->GetVkHandle(); for (int i = 0; i < static_cast(CAM_DESC_SETS.size()); ++i) @@ -408,8 +409,9 @@ namespace SHADE // Create the GPU buffer to hold light count lightCountsBuffer = logicalDevice->CreateBuffer(lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Light Count Data"); - lightingDataDescSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT, {&lightCountsBuffer, 1}, 0, sizeof (uint32_t) * NUM_LIGHT_TYPES); - lightingDataDescSet->UpdateDescriptorSetBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT); + static constexpr uint32_t LIGHTING_DATA_SET_INDEX = 0; + lightingDataDescSet->ModifyWriteDescBuffer(LIGHTING_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT, { &lightCountsBuffer, 1 }, 0, sizeof(uint32_t) * NUM_LIGHT_TYPES); + lightingDataDescSet->UpdateDescriptorSetBuffer(LIGHTING_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT); for (uint32_t i = 0; i < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++i) { diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.cpp index 9b16a279..baf09a2d 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.cpp @@ -1,7 +1,7 @@ #include "SHpch.h" #include "SHPipelineLibrary.h" #include "Graphics/Devices/SHVkLogicalDevice.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "Graphics/RenderGraph/SHSubpass.h" #include "Graphics/SHVkUtil.h" @@ -13,7 +13,7 @@ namespace SHADE SHPipelineLayoutParams params { .shaderModules = {vsFsPair.first, vsFsPair.second}, - .globalDescSetLayouts = SHPredefinedData::GetBatchingSystemData().descSetLayouts + .predefinedDescSetLayouts = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING).descSetLayouts }; // Create the pipeline layout @@ -21,7 +21,7 @@ namespace SHADE // Create the pipeline and configure the default vertex input state auto newPipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, renderpass, subpass); - newPipeline->GetPipelineState().SetVertexInputState(SHPredefinedData::GetDefaultViState()); + newPipeline->GetPipelineState().SetVertexInputState(SHGraphicsPredefinedData::GetDefaultViState()); SHColorBlendState colorBlendState{}; colorBlendState.logic_op_enable = VK_FALSE; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.h b/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.h index 389f5fa8..5085f21f 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.h @@ -10,7 +10,7 @@ namespace SHADE class SHVkDescriptorSetLayouts; class SHVkPipeline; class SHSubpass; - class SHPredefinedData; + class SHGraphicsPredefinedData; // Pipeline library is a PURELY MIDDLE END SYSTEM. It is responsible for only creating pipelines from shaders and caching // them so that they don't need to be recreated again. diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHFont.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHFont.cpp index b0d02b4c..b6ec5f83 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHFont.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHFont.cpp @@ -1,7 +1,7 @@ #include "SHpch.h" #include "SHFont.h" #include "Graphics/Devices/SHVkLogicalDevice.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" #include "Graphics/Buffers/SHVkBuffer.h" #include "Graphics/Images/SHVkSampler.h" @@ -121,14 +121,15 @@ namespace SHADE descSet = descPool->Allocate({ layout }, { 1 }); auto viewLayoutSampler = std::make_tuple(bitmapDataImageView, sampler, vk::ImageLayout::eShaderReadOnlyOptimal); - descSet->ModifyWriteDescImage(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA, {&viewLayoutSampler, 1}); + static constexpr uint32_t FONT_DATA_SET_INDEX = 0; + descSet->ModifyWriteDescImage(FONT_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA, {&viewLayoutSampler, 1}); - descSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, + descSet->ModifyWriteDescBuffer(FONT_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::FONT_MATRIX_DATA, { &matrixDataBuffer, 1 }, 0, fontAsset.glyphTransformations.size() * sizeof(SHMatrix)); // Bind image and buffer to desc set. - descSet->UpdateDescriptorSetImages(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA); - descSet->UpdateDescriptorSetBuffer(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, SHGraphicsConstants::DescriptorSetBindings::FONT_MATRIX_DATA); + descSet->UpdateDescriptorSetImages(FONT_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA); + descSet->UpdateDescriptorSetBuffer(FONT_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::FONT_MATRIX_DATA); } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHFont.h b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHFont.h index ff15cff0..b3731af9 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHFont.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHFont.h @@ -3,6 +3,7 @@ #include "Resource/SHHandle.h" #include "msdf-atlas-gen/msdf-atlas-gen.h" #include "Assets/Asset Types/SHFontAsset.h" +#include "Graphics/Pipeline/SHPipelineType.h" namespace SHADE { diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp index ab58b626..3a0110a4 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp @@ -6,7 +6,7 @@ #include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/MiddleEnd/TextRendering/SHFont.h" #include "Graphics/Buffers/SHVkBuffer.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "Graphics/Pipeline/SHVkPipeline.h" #include "Graphics/SHVkUtil.h" #include "Graphics/RenderGraph/SHSubpass.h" @@ -103,7 +103,7 @@ namespace SHADE SHPipelineLayoutParams plParams { .shaderModules = {textVS, textFS}, - .predefinedDescSetLayouts = SHPredefinedData::GetTextSystemData().descSetLayouts + .predefinedDescSetLayouts = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::TEXT_RENDERING).descSetLayouts }; pipelineLayout = logicalDevice->CreatePipelineLayout(plParams); @@ -177,10 +177,10 @@ namespace SHADE void SHTextRenderingSubSystem::Render(Handle cmdBuffer, Handle renderer, uint32_t frameIndex) noexcept { auto& textRendererComps = SHComponentManager::GetDense(); - auto const& mappings = SHPredefinedData::GetTextSystemData().descMappings; - uint32_t fontSetIndex = mappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::FONT); - uint32_t staticGlobalSetIndex = mappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA); - uint32_t cameraSetIndex = mappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::CAMERA); + auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::TEXT_RENDERING); + uint32_t fontSetIndex = mappings.at(SHGraphicsConstants::DescriptorSetTypes::FONT); + uint32_t staticGlobalSetIndex = mappings.at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA); + uint32_t cameraSetIndex = mappings.at(SHGraphicsConstants::DescriptorSetTypes::CAMERA); for (auto& comp : textRendererComps) { diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.h b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.h index c9a89129..c91e7794 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.h @@ -20,6 +20,7 @@ namespace SHADE class SHVkRenderpass; class SHSubpass; class SHVkShaderModule; + class SHRenderer; class SHTextRenderingSubSystem { diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp index a31f54de..9df14eba 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp @@ -24,7 +24,7 @@ of DigiPen Institute of Technology is prohibited. #include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" #include "Graphics/Images/SHVkImage.h" #include "Graphics/Images/SHVkImageView.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "Assets/Asset Types/SHTextureAsset.h" namespace SHADE @@ -168,22 +168,23 @@ namespace SHADE } texDescriptors = descPool->Allocate ( - { SHPredefinedData::GetPredefinedDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS] }, + { SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA) }, { static_cast(texOrder.size()) } ); #ifdef _DEBUG for (auto set : texDescriptors->GetVkHandle()) SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals"); #endif + static constexpr uint32_t TEX_DESCRIPTOR_SET_INDEX = 0; texDescriptors->ModifyWriteDescImage ( - SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS, + TEX_DESCRIPTOR_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA, combinedImageSamplers ); texDescriptors->UpdateDescriptorSetImages ( - SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS, + TEX_DESCRIPTOR_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA ); } diff --git a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp index 0333aa09..c2d83052 100644 --- a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp +++ b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp @@ -220,7 +220,7 @@ namespace SHADE // 1 descriptor set layout for every descriptor set detected. for (auto const& set : setsWithBindings) { - auto newDescriptorSetLayout = logicalDeviceHdl->CreateDescriptorSetLayout(set.first, set.second); + auto newDescriptorSetLayout = logicalDeviceHdl->CreateDescriptorSetLayout(set.second); descriptorSetLayoutsAllocate.push_back(newDescriptorSetLayout); } @@ -317,7 +317,7 @@ namespace SHADE , logicalDeviceHdl {inLogicalDeviceHdl} , pushConstantInterface{} , vkPcRanges{} - , descriptorSetLayoutsGlobal{pipelineLayoutParams.globalDescSetLayouts } // do a copy, some other pipeline layout might need this + , descriptorSetLayoutsGlobal{pipelineLayoutParams.predefinedDescSetLayouts } // do a copy, some other pipeline layout might need this , descriptorSetLayoutsAllocate{} , vkDescriptorSetLayoutsAllocate{} , descriptorSetLayoutsPipeline{} diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp index d431cf47..a24f8968 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp @@ -12,7 +12,7 @@ #include "SHRenderGraphStorage.h" #include "Graphics/RenderGraph/SHRenderGraphNodeCompute.h" #include "Tools/Utilities/SHUtilities.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "Graphics/RenderGraph/SHRenderToSwapchainImageSystem.h" #include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h" @@ -578,7 +578,8 @@ namespace SHADE uint32_t h = static_cast(resource->GetHeight()); cmdBuffer->SetViewportScissor(static_cast(w), static_cast(h), w, h); - newSubpass->BindDescriptorInputDescriptorSets (cmdBuffer, frameIndex); + static constexpr uint32_t INPUT_IMAGE_SET_INDEX = 0; + newSubpass->BindInputDescriptorSets (cmdBuffer, INPUT_IMAGE_SET_INDEX, frameIndex); // draw a quad. cmdBuffer->DrawArrays(4, 1, 0, 0); @@ -634,16 +635,18 @@ namespace SHADE auto cmdBuffer = commandBuffers[frameIndex]; cmdBuffer->BeginLabeledSegment(name); - // Force bind pipeline layout - cmdBuffer->ForceSetPipelineLayout(SHPredefinedData::GetBatchingSystemData().dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS); - cmdBuffer->ForceSetPipelineLayout(SHPredefinedData::GetBatchingSystemData().dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE); + auto batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING); - auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; + // Force bind pipeline layout + cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS); + cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE); + + auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); for (auto& node : nodes) { // bind static global data - SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA)); + SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA)); node->Execute(cmdBuffer, descPool, frameIndex); } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h index c69e83b1..948fd9f7 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h @@ -29,7 +29,7 @@ namespace SHADE class SHVkCommandPool; class SHVkCommandBuffer; class SHRenderGraphNode; - class SHPredefinedData; + class SHGraphicsPredefinedData; class SHVkDescriptorPool; class SHRenderGraphStorage; class SHRenderToSwapchainImageSystem; diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp index c23e19d7..01363e6b 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp @@ -10,7 +10,7 @@ #include "Graphics/RenderGraph/SHRenderGraphNodeCompute.h" #include "Graphics/SHVkUtil.h" #include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" namespace SHADE { @@ -351,16 +351,18 @@ namespace SHADE commandBuffer->EndRenderpass(); - auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; + auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE); // We bind these 2 descriptor sets here because they apply to all node computes if (!nodeComputes.empty()) { + commandBuffer->ForceSetPipelineLayout(SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE); + // bind static global data - SHGlobalDescriptorSets::BindStaticGlobalData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA)); + SHGlobalDescriptorSets::BindStaticGlobalData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA)); // bind lighting data - SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::LIGHTS), frameIndex); + SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::LIGHTS), frameIndex); } // Execute all subpass computes diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.h b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.h index f7e55d4a..ebaf48e2 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.h @@ -19,7 +19,7 @@ namespace SHADE class SHVkLogicalDevice; class SHVkRenderpass; class SHVkDescriptorPool; - class SHPredefinedData; + class SHGraphicsPredefinedData; class SHRenderGraphStorage; class SHRenderGraphNodeCompute; class SHRenderer; diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.cpp index bb748913..c295d93b 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.cpp @@ -6,7 +6,7 @@ #include "Graphics/Descriptors/SHVkDescriptorSetLayout.h" #include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Pipeline/SHVkPipelineLayout.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "SHRenderGraphStorage.h" #include "SHRenderGraphResource.h" #include "Graphics/Commands/SHVkCommandBuffer.h" @@ -29,7 +29,7 @@ namespace SHADE SHPipelineLayoutParams pipelineLayoutParams { .shaderModules = {computeShaderModule}, - .predefinedDescSetLayouts = SHPredefinedData::GetRenderGraphNodeComputeData().descSetLayouts, + .predefinedDescSetLayouts = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).descSetLayouts, .dynamicBufferBindings = std::move(dynamicBufferBindings), }; @@ -47,13 +47,13 @@ namespace SHADE // save the resources resources = std::move (subpassComputeResources); - auto const& descMappings = SHPredefinedData::GetRenderGraphNodeComputeData().descMappings; + auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE); auto const& layouts = computePipeline->GetPipelineLayout()->GetDescriptorSetLayoutsPipeline(); //Get the descriptor set layouts required to allocate. We only want the ones for allocate because //global descriptors are already bound in the main system. - auto const& graphResourceLayout = layouts[descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE)]; + auto const& graphResourceLayout = layouts[descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE)]; // Allocate descriptor sets to hold the images for reading (STORAGE_IMAGE) for (uint32_t i = 0; i < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++i) @@ -66,11 +66,11 @@ namespace SHADE } // check if all layouts are there - if (layouts.size() == descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE) + 1) + if (layouts.size() == descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE) + 1) { // create compute resources computeResource = graphStorage->resourceHub->Create(); - auto computeResourceLayout = layouts[descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE)]; + auto computeResourceLayout = layouts[descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE)]; computeResource->descSet = graphStorage->descriptorPool->Allocate({ computeResourceLayout }, { 1 }); #ifdef _DEBUG for (auto set : computeResource->descSet->GetVkHandle()) @@ -94,21 +94,21 @@ namespace SHADE // bind the compute pipeline cmdBuffer->BindPipeline(computePipeline); - auto const& descMappings = SHPredefinedData::GetRenderGraphNodeComputeData().descMappings; + auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE); // bind render graph resource - cmdBuffer->BindDescriptorSet(graphResourceDescSets[frameIndex], SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE), {}); + cmdBuffer->BindDescriptorSet(graphResourceDescSets[frameIndex], SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE), {}); // bind compute resource if (computeResource) { - cmdBuffer->BindDescriptorSet(computeResource->descSet, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE), computeResource->dynamicOffsets[frameIndex]); + cmdBuffer->BindDescriptorSet(computeResource->descSet, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE), computeResource->dynamicOffsets[frameIndex]); } // bind camera data if (renderer) - renderer->BindDescriptorSet (cmdBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex); + renderer->BindDescriptorSet (cmdBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex); // dispatch compute cmdBuffer->ComputeDispatch(groupSizeX, groupSizeY, 1); @@ -120,11 +120,14 @@ namespace SHADE void SHRenderGraphNodeCompute::HandleResize(void) noexcept { - auto const& descMappings = SHPredefinedData::GetRenderGraphNodeComputeData().descMappings; - uint32_t renderGraphResourceSetIndex = descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE); + // We need to get from mappings because we want the introspected layout from the vector of layouts (of which the first few are predefined) + uint32_t RENDER_GRAPH_RESOURCE_SET_INDEX = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).at (SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE); + + // Since the descriptor set is standalone, the index we want to use is not the one in the shaders, it should always be 0. + uint32_t RENDER_GRAPH_RESOURCE_UPDATE_SET_INDEX = 0; // Get the layout for the render graph resource. We can index it this way because the container returned is a container of layouts that includes the global ones - auto pipelineDescSetLayouts = computePipeline->GetPipelineLayout()->GetDescriptorSetLayoutsPipeline()[renderGraphResourceSetIndex]; + auto pipelineDescSetLayouts = computePipeline->GetPipelineLayout()->GetDescriptorSetLayoutsPipeline()[RENDER_GRAPH_RESOURCE_SET_INDEX]; // everything below here needs resizing for (uint32_t frameIndex = 0; frameIndex < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++frameIndex) @@ -137,8 +140,8 @@ namespace SHADE uint32_t imageIndex = (resources[i]->resourceTypeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT)) ? frameIndex : 0; SHVkDescriptorSetGroup::viewSamplerLayout vsl = std::make_tuple(resources[i]->GetImageView(imageIndex), Handle{}, vk::ImageLayout::eGeneral); - graphResourceDescSets[frameIndex]->ModifyWriteDescImage(renderGraphResourceSetIndex, binding.BindPoint, { &vsl, 1 }); - graphResourceDescSets[frameIndex]->UpdateDescriptorSetImages(renderGraphResourceSetIndex, binding.BindPoint); + graphResourceDescSets[frameIndex]->ModifyWriteDescImage(RENDER_GRAPH_RESOURCE_UPDATE_SET_INDEX, binding.BindPoint, { &vsl, 1 }); + graphResourceDescSets[frameIndex]->UpdateDescriptorSetImages(RENDER_GRAPH_RESOURCE_UPDATE_SET_INDEX, binding.BindPoint); ++i; } } @@ -200,16 +203,19 @@ namespace SHADE renderer = inRenderer; } - void SHRenderGraphNodeCompute::ModifyWriteDescBufferComputeResource(uint32_t set, uint32_t binding, std::span> const& buffers, uint32_t offset, uint32_t range) noexcept + void SHRenderGraphNodeCompute::ModifyWriteDescBufferComputeResource(uint32_t binding, std::span> const& buffers, uint32_t offset, uint32_t range) noexcept { - computeResource->descSet->ModifyWriteDescBuffer(set, binding, buffers, offset, range); - computeResource->descSet->UpdateDescriptorSetBuffer(set, binding); + static constexpr uint32_t COMPUTE_RESOURCE_SET_INDEX = 0; + + computeResource->descSet->ModifyWriteDescBuffer(COMPUTE_RESOURCE_SET_INDEX, binding, buffers, offset, range); + computeResource->descSet->UpdateDescriptorSetBuffer(COMPUTE_RESOURCE_SET_INDEX, binding); } - void SHRenderGraphNodeCompute::ModifyWriteDescImageComputeResource(uint32_t set, uint32_t binding, std::span const& viewSamplerLayouts) noexcept + void SHRenderGraphNodeCompute::ModifyWriteDescImageComputeResource(uint32_t binding, std::span const& viewSamplerLayouts) noexcept { - computeResource->descSet->ModifyWriteDescImage(set, binding, viewSamplerLayouts); - computeResource->descSet->UpdateDescriptorSetImages(set, binding); + static constexpr uint32_t COMPUTE_RESOURCE_SET_INDEX = 0; + computeResource->descSet->ModifyWriteDescImage(COMPUTE_RESOURCE_SET_INDEX, binding, viewSamplerLayouts); + computeResource->descSet->UpdateDescriptorSetImages(COMPUTE_RESOURCE_SET_INDEX, binding); } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.h b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.h index cba37f80..dc3ca886 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.h @@ -82,8 +82,8 @@ namespace SHADE void SetDynamicOffsets (std::span perFrameSizes) noexcept; void SetRenderer (Handle inRenderer) noexcept; - void ModifyWriteDescBufferComputeResource (uint32_t set, uint32_t binding, std::span> const& buffers, uint32_t offset, uint32_t range) noexcept; - void ModifyWriteDescImageComputeResource(uint32_t set, uint32_t binding, std::span const& viewSamplerLayouts) noexcept; + void ModifyWriteDescBufferComputeResource (uint32_t binding, std::span> const& buffers, uint32_t offset, uint32_t range) noexcept; + void ModifyWriteDescImageComputeResource(uint32_t binding, std::span const& viewSamplerLayouts) noexcept; friend class SHRenderGraph; diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphStorage.h b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphStorage.h index d473dd2a..b0cd40bc 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphStorage.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphStorage.h @@ -7,7 +7,7 @@ namespace SHADE { class SHVkLogicalDevice; class SHVkSwapchain; - class SHPredefinedData; + class SHGraphicsPredefinedData; class SHVkDescriptorPool; class SHRenderGraphResource; diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderToSwapchainImageSystem.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderToSwapchainImageSystem.cpp index 4c575c99..80260b7b 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderToSwapchainImageSystem.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderToSwapchainImageSystem.cpp @@ -1,7 +1,7 @@ #include "SHpch.h" #include "SHRenderToSwapchainImageSystem.h" #include "Graphics/Devices/SHVkLogicalDevice.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" #include "Graphics/RenderGraph/SHRenderGraphNode.h" #include "Graphics/RenderGraph/SHSubpass.h" #include "Graphics/SHVkUtil.h" @@ -24,7 +24,7 @@ namespace SHADE auto pipelineLayout = logicalDevice->CreatePipelineLayout(SHPipelineLayoutParams { .shaderModules = {shaderModules.first, shaderModules.second}, - .predefinedDescSetLayouts = SHPredefinedData::GetBatchingSystemData().descSetLayouts + .predefinedDescSetLayouts = {} }); pipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, renderGraphNode->GetRenderpass(), subpass); diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp index e5052f59..c903553b 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp @@ -13,7 +13,7 @@ #include "SHRenderGraphResource.h" #include "Graphics/MiddleEnd/Interface/SHViewport.h" #include "Graphics/MiddleEnd/Interface/SHRenderer.h" -#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" namespace SHADE { @@ -224,10 +224,10 @@ namespace SHADE commandBuffer->SetViewportScissor(static_cast(w), static_cast(h), w, h); } - auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; + auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); if (renderer) - renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex); + renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex); // Draw all the batches superBatch->Draw(commandBuffer, frameIndex); @@ -245,11 +245,11 @@ namespace SHADE UpdateWriteDescriptors(); } - void SHSubpass::BindDescriptorInputDescriptorSets(Handle cmdBuffer, uint32_t frameIndex) const noexcept + void SHSubpass::BindInputDescriptorSets(Handle cmdBuffer, uint32_t setIndex, uint32_t frameIndex) const noexcept { if (!inputImageDescriptorSets.empty()) { - cmdBuffer->BindDescriptorSet(inputImageDescriptorSets[frameIndex], SH_PIPELINE_TYPE::GRAPHICS, SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_RESOURCE, { }); + cmdBuffer->BindDescriptorSet(inputImageDescriptorSets[frameIndex], SH_PIPELINE_TYPE::GRAPHICS, setIndex, { }); } } @@ -356,8 +356,13 @@ namespace SHADE // Update descriptor sets auto args = std::make_tuple(resource->GetImageView(viewIndex), inputSamplers[i], descriptorLayout); - group->ModifyWriteDescImage(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_RESOURCE, binding.BindPoint, std::span{&args, 1}); - group->UpdateDescriptorSetImages(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_RESOURCE, binding.BindPoint); + + + // Since the descriptor set is standalone, the index we want to use is not the one in the shaders, it should always be 0. + uint32_t RENDER_GRAPH_RESOURCE_SET_INDEX = 0; + + group->ModifyWriteDescImage(RENDER_GRAPH_RESOURCE_SET_INDEX, binding.BindPoint, std::span{&args, 1}); + group->UpdateDescriptorSetImages(RENDER_GRAPH_RESOURCE_SET_INDEX, binding.BindPoint); } ++i; diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h index b5c5c8b1..66d41ffd 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h @@ -121,7 +121,7 @@ namespace SHADE // Runtime functions void Execute(Handle commandBuffer, Handle descPool, uint32_t frameIndex) noexcept; void HandleResize (void) noexcept; - void BindDescriptorInputDescriptorSets (Handle cmdBuffer, uint32_t frameIndex) const noexcept; + void BindInputDescriptorSets (Handle cmdBuffer, uint32_t setIndex, uint32_t frameIndex) const noexcept; void Init(SHResourceHub& resourceManager) noexcept; diff --git a/SHADE_Engine/src/Serialization/SHSerializationHelper.hpp b/SHADE_Engine/src/Serialization/SHSerializationHelper.hpp index b560acae..ee02478a 100644 --- a/SHADE_Engine/src/Serialization/SHSerializationHelper.hpp +++ b/SHADE_Engine/src/Serialization/SHSerializationHelper.hpp @@ -10,6 +10,7 @@ #include "ECS_Base/Managers/SHComponentManager.h" #include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h" #include "Tools/Logger/SHLog.h" +#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h" namespace SHADE @@ -264,7 +265,8 @@ namespace SHADE if(spec.properties.IsDefined()) { auto fragShader = SHResourceManager::LoadOrGet(spec.fragShader); - auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface(SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA); + auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); + auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface(mappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA); int const varCount = static_cast(interface->GetVariableCount()); for (int i = 0; i < varCount; ++i) diff --git a/SHADE_Engine/src/Tools/SHEnumWrapper.h b/SHADE_Engine/src/Tools/SHEnumWrapper.h new file mode 100644 index 00000000..7c37659e --- /dev/null +++ b/SHADE_Engine/src/Tools/SHEnumWrapper.h @@ -0,0 +1,67 @@ +#pragma once + +#include + +namespace SHADE +{ + template + class SHEnumWrapper + { + public: + using UnderlyingType = typename std::underlying_type_t; + + private: + UnderlyingType mask; + + public: + + constexpr SHEnumWrapper(void) noexcept + : mask{ 0 } + { + + }; + + constexpr SHEnumWrapper(BitType bit) noexcept + : mask{ static_cast(bit) } + { + + }; + + constexpr SHEnumWrapper(SHEnumWrapper const& rhs) noexcept = default; + constexpr SHEnumWrapper& operator= (SHEnumWrapper const& rhs) noexcept = default; + + constexpr explicit SHEnumWrapper(UnderlyingType flags) noexcept + : mask{ flags } + { + + }; + + constexpr SHEnumWrapper operator| (SHEnumWrapper const& rhs) const noexcept + { + return static_cast> (mask | rhs.mask); + }; + + constexpr SHEnumWrapper operator& (SHEnumWrapper const& rhs) const noexcept + { + return static_cast> (mask & rhs.mask); + }; + + constexpr operator UnderlyingType() const noexcept + { + return mask; + }; + }; + + template>> + inline BitType operator|(const BitType& left, const BitType& right) + { + return static_cast(static_cast(left) | static_cast(right)); + } + + template>> + inline BitType operator&(const BitType& left, const BitType& right) + { + return static_cast(static_cast(left) & static_cast(right)); + } + +} diff --git a/SHADE_Engine/src/Tools/Utilities/SHUtilities.h b/SHADE_Engine/src/Tools/Utilities/SHUtilities.h index c3492f13..6cdd91ee 100644 --- a/SHADE_Engine/src/Tools/Utilities/SHUtilities.h +++ b/SHADE_Engine/src/Tools/Utilities/SHUtilities.h @@ -43,73 +43,6 @@ namespace SHADE static constexpr OutputType ConvertEnum(InputType enumClassMember) noexcept; }; - template - class SHEnumWrapper - { - public: - using UnderlyingType = typename std::underlying_type_t; - - private: - UnderlyingType mask; - - public: - - constexpr SHEnumWrapper(void) noexcept - : mask{ 0 } - { - - }; - - constexpr SHEnumWrapper(BitType bit) noexcept - : mask{ static_cast(bit) } - { - - }; - - constexpr SHEnumWrapper(SHEnumWrapper const& rhs) noexcept = default; - constexpr SHEnumWrapper& operator= (SHEnumWrapper const& rhs) noexcept = default; - - constexpr explicit SHEnumWrapper(UnderlyingType flags) noexcept - : mask{ flags } - { - - }; - - constexpr SHEnumWrapper operator| (SHEnumWrapper const& rhs) const noexcept - { - return static_cast> (mask | rhs.mask); - }; - - constexpr SHEnumWrapper operator& (SHEnumWrapper const& rhs) const noexcept - { - return static_cast> (mask & rhs.mask); - }; - - constexpr operator UnderlyingType() const noexcept - { - return mask; - }; - }; - - template>> - inline BitType operator|(const BitType& left, const BitType& right) - { - return static_cast(static_cast(left) | static_cast(right)); - } - - template>> - inline BitType operator&(const BitType& left, const BitType& right) - { - return static_cast(static_cast(left) & static_cast(right)); - } - - template - std::ostream& operator<<(std::ostream& os, EnumType const& type) - { - os << static_cast(type); - return os; - } - } // namespace SHADE #include "SHUtilities.hpp"