Shifted Command buffers outside of render graph

Command buffers now exist in renderer instead
Graphics system that calls the renderer, begins and ends the renderer recording in it's main loop as well
This commit is contained in:
Brandon Mak 2022-09-22 09:23:40 +08:00
parent 7acf25a770
commit ba181eb9c9
12 changed files with 239 additions and 79 deletions

View File

@ -138,6 +138,7 @@ xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"</Command
<ClInclude Include="src\ECS_Base\UnitTesting\SHECSUnitTest.h" />
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestComponents.h" />
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestSystems.h" />
<ClInclude Include="src\Editor\SHEditor.h" />
<ClInclude Include="src\Engine\SHEngine.h" />
<ClInclude Include="src\Events\SHEvent.h" />
<ClInclude Include="src\Events\SHEventDefines.h" />
@ -167,13 +168,31 @@ xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"</Command
<ClInclude Include="src\Graphics\Images\SHVkImageView.h" />
<ClInclude Include="src\Graphics\Images\SHVkSampler.h" />
<ClInclude Include="src\Graphics\Instance\SHVkInstance.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHBatch.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHBatcher.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHSuperBatch.h" />
<ClInclude Include="src\Graphics\MiddleEnd\GlobalData\SHGraphicsGlobalData.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHCamera.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsConstants.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterial.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterial.hpp" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.hpp" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMeshLibrary.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderable.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderer.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHViewport.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Meshes\SHMeshData.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Meshes\SHPrimitiveGenerator.h" />
<ClInclude Include="src\Graphics\MiddleEnd\PerFrame\SHPerFrameData.h" />
<ClInclude Include="src\Graphics\MiddleEnd\PerFrame\SHRenderContext.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Pipeline\SHPipelineLibrary.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderModuleLibrary.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderSourceLibrary.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderType.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Textures\SHTextureLibrary.h" />
<ClInclude Include="src\Graphics\Pipeline\SHPipelineLayoutParams.h" />
<ClInclude Include="src\Graphics\Pipeline\SHPipelineState.h" />
<ClInclude Include="src\Graphics\Pipeline\SHPipelineType.h" />
@ -250,6 +269,7 @@ xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"</Command
<ClCompile Include="src\ECS_Base\System\SHFixedSystemRoutine.cpp" />
<ClCompile Include="src\ECS_Base\System\SHSystemRoutine.cpp" />
<ClCompile Include="src\ECS_Base\UnitTesting\SHECSUnitTest.cpp" />
<ClCompile Include="src\Editor\SHEditor.cpp" />
<ClCompile Include="src\Engine\SHEngine.cpp" />
<ClCompile Include="src\FRC\SHFramerateController.cpp" />
<ClCompile Include="src\Filesystem\SHFileSystem.cpp" />
@ -273,12 +293,26 @@ xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"</Command
<ClCompile Include="src\Graphics\Images\SHVkImageView.cpp" />
<ClCompile Include="src\Graphics\Images\SHVkSampler.cpp" />
<ClCompile Include="src\Graphics\Instance\SHVkInstance.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHBatch.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHBatcher.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHSuperBatch.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\GlobalData\SHGraphicsGlobalData.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHCamera.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMaterial.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMeshLibrary.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderable.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderer.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHViewport.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Meshes\SHPrimitiveGenerator.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\PerFrame\SHPerFrameData.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\PerFrame\SHRenderContext.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Pipeline\SHPipelineLibrary.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Shaders\SHShaderModuleLibrary.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Shaders\SHShaderSourceLibrary.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Textures\SHTextureLibrary.cpp" />
<ClCompile Include="src\Graphics\Pipeline\SHPipelineState.cpp" />
<ClCompile Include="src\Graphics\Pipeline\SHPushConstantInterface.cpp" />
<ClCompile Include="src\Graphics\Pipeline\SHVkPipeline.cpp" />

View File

@ -28,6 +28,9 @@
<Filter Include="ECS_Base\UnitTesting">
<UniqueIdentifier>{078AA1A3-F318-2B6D-9C37-3F6888A53B13}</UniqueIdentifier>
</Filter>
<Filter Include="Editor">
<UniqueIdentifier>{8C1A20B0-78BC-4A86-6177-5EDA4DB8D1D6}</UniqueIdentifier>
</Filter>
<Filter Include="Engine">
<UniqueIdentifier>{DBC7D3B0-C769-FE86-B024-12DB9C6585D7}</UniqueIdentifier>
</Filter>
@ -70,15 +73,30 @@
<Filter Include="Graphics\MiddleEnd">
<UniqueIdentifier>{4B204703-3704-0859-A064-02AC8C67F2DA}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Batching">
<UniqueIdentifier>{7A02D7B0-E60F-0597-6FF6-0082DB02D14D}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\GlobalData">
<UniqueIdentifier>{85EFB65D-F107-9E87-BAB4-2D21268C3221}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Interface">
<UniqueIdentifier>{EBA1D3FF-D75C-C3AB-8014-3CF66CAE0D3C}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Meshes">
<UniqueIdentifier>{1F603FFC-8B22-7386-D4D2-011340D44B64}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\PerFrame">
<UniqueIdentifier>{8CDBA7C9-F8E8-D5AF-81CF-D19AEDDBA166}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Pipeline">
<UniqueIdentifier>{D04C14FB-3C5A-42E1-C540-3ECC314D0E98}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Shaders">
<UniqueIdentifier>{2460C057-1070-6C28-7929-D14665585BC1}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Textures">
<UniqueIdentifier>{7E76F08B-EA83-1E72-736A-1A5DDF76EA28}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\Pipeline">
<UniqueIdentifier>{FBD334F8-67EA-328E-B061-BEAF1CB70316}</UniqueIdentifier>
</Filter>
@ -121,6 +139,9 @@
<Filter Include="Math\Geometry">
<UniqueIdentifier>{EAD6C33D-5697-3F74-1FD2-88F18B518450}</UniqueIdentifier>
</Filter>
<Filter Include="Math\Transform">
<UniqueIdentifier>{3AB383AD-2681-77B3-0F15-E8D9FB815318}</UniqueIdentifier>
</Filter>
<Filter Include="Math\Vector">
<UniqueIdentifier>{F1B75745-5D6D-D03A-E661-CA115216C73E}</UniqueIdentifier>
</Filter>
@ -207,6 +228,9 @@
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestSystems.h">
<Filter>ECS_Base\UnitTesting</Filter>
</ClInclude>
<ClInclude Include="src\Editor\SHEditor.h">
<Filter>Editor</Filter>
</ClInclude>
<ClInclude Include="src\Engine\SHEngine.h">
<Filter>Engine</Filter>
</ClInclude>
@ -294,18 +318,69 @@
<ClInclude Include="src\Graphics\Instance\SHVkInstance.h">
<Filter>Graphics\Instance</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHBatch.h">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHBatcher.h">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHSuperBatch.h">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\GlobalData\SHGraphicsGlobalData.h">
<Filter>Graphics\MiddleEnd\GlobalData</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHCamera.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsConstants.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterial.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterial.hpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.hpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMeshLibrary.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderable.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderer.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHViewport.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Meshes\SHMeshData.h">
<Filter>Graphics\MiddleEnd\Meshes</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Meshes\SHPrimitiveGenerator.h">
<Filter>Graphics\MiddleEnd\Meshes</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\PerFrame\SHPerFrameData.h">
<Filter>Graphics\MiddleEnd\PerFrame</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\PerFrame\SHRenderContext.h">
<Filter>Graphics\MiddleEnd\PerFrame</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Pipeline\SHPipelineLibrary.h">
<Filter>Graphics\MiddleEnd\Pipeline</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderModuleLibrary.h">
<Filter>Graphics\MiddleEnd\Shaders</Filter>
</ClInclude>
@ -315,6 +390,9 @@
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderType.h">
<Filter>Graphics\MiddleEnd\Shaders</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Textures\SHTextureLibrary.h">
<Filter>Graphics\MiddleEnd\Textures</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\Pipeline\SHPipelineLayoutParams.h">
<Filter>Graphics\Pipeline</Filter>
</ClInclude>
@ -421,7 +499,13 @@
<Filter>Math</Filter>
</ClInclude>
<ClInclude Include="src\Math\Transform\SHTransform.h">
<Filter>Math</Filter>
<Filter>Math\Transform</Filter>
</ClInclude>
<ClInclude Include="src\Math\Transform\SHTransformComponent.h">
<Filter>Math\Transform</Filter>
</ClInclude>
<ClInclude Include="src\Math\Transform\SHTransformSystem.h">
<Filter>Math\Transform</Filter>
</ClInclude>
<ClInclude Include="src\Math\Vector\SHVec2.h">
<Filter>Math\Vector</Filter>
@ -498,8 +582,6 @@
<ClInclude Include="src\Tools\SHUtilities.hpp">
<Filter>Tools</Filter>
</ClInclude>
<ClInclude Include="src\Math\Transform\SHTransformComponent.h" />
<ClInclude Include="src\Math\Transform\SHTransformSystem.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\ECS_Base\Components\SHComponent.cpp">
@ -529,6 +611,9 @@
<ClCompile Include="src\ECS_Base\UnitTesting\SHECSUnitTest.cpp">
<Filter>ECS_Base\UnitTesting</Filter>
</ClCompile>
<ClCompile Include="src\Editor\SHEditor.cpp">
<Filter>Editor</Filter>
</ClCompile>
<ClCompile Include="src\Engine\SHEngine.cpp">
<Filter>Engine</Filter>
</ClCompile>
@ -598,24 +683,66 @@
<ClCompile Include="src\Graphics\Instance\SHVkInstance.cpp">
<Filter>Graphics\Instance</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHBatch.cpp">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHBatcher.cpp">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHSuperBatch.cpp">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\GlobalData\SHGraphicsGlobalData.cpp">
<Filter>Graphics\MiddleEnd\GlobalData</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHCamera.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMaterial.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMeshLibrary.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderable.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderer.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHViewport.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Meshes\SHPrimitiveGenerator.cpp">
<Filter>Graphics\MiddleEnd\Meshes</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\PerFrame\SHPerFrameData.cpp">
<Filter>Graphics\MiddleEnd\PerFrame</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\PerFrame\SHRenderContext.cpp">
<Filter>Graphics\MiddleEnd\PerFrame</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Pipeline\SHPipelineLibrary.cpp">
<Filter>Graphics\MiddleEnd\Pipeline</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Shaders\SHShaderModuleLibrary.cpp">
<Filter>Graphics\MiddleEnd\Shaders</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Shaders\SHShaderSourceLibrary.cpp">
<Filter>Graphics\MiddleEnd\Shaders</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Textures\SHTextureLibrary.cpp">
<Filter>Graphics\MiddleEnd\Textures</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\Pipeline\SHPipelineState.cpp">
<Filter>Graphics\Pipeline</Filter>
</ClCompile>
@ -698,7 +825,13 @@
<Filter>Math</Filter>
</ClCompile>
<ClCompile Include="src\Math\Transform\SHTransform.cpp">
<Filter>Math</Filter>
<Filter>Math\Transform</Filter>
</ClCompile>
<ClCompile Include="src\Math\Transform\SHTransformComponent.cpp">
<Filter>Math\Transform</Filter>
</ClCompile>
<ClCompile Include="src\Math\Transform\SHTransformSystem.cpp">
<Filter>Math\Transform</Filter>
</ClCompile>
<ClCompile Include="src\Math\Vector\SHVec2.cpp">
<Filter>Math\Vector</Filter>
@ -740,7 +873,5 @@
<ClCompile Include="src\Tools\SHStringUtils.cpp">
<Filter>Tools</Filter>
</ClCompile>
<ClCompile Include="src\Math\Transform\SHTransformComponent.cpp" />
<ClCompile Include="src\Math\Transform\SHTransformSystem.cpp" />
</ItemGroup>
</Project>

View File

@ -50,9 +50,8 @@ namespace SHADE
return *this;
}
std::vector<Handle<SHVkDescriptorSetGroup>> SHVkDescriptorPool::Allocate(const std::vector<Handle<SHVkDescriptorSetLayout>>& layouts, std::vector<uint32_t> const& variableDescCounts)
Handle<SHVkDescriptorSetGroup> SHVkDescriptorPool::Allocate(const std::vector<Handle<SHVkDescriptorSetLayout>>& layouts, std::vector<uint32_t> const& variableDescCounts)
{
SHVkInstance::GetResourceManager().Create<SHVkDescriptorSetGroup>(device, GetHandle(), layouts, variableDescCounts);
return {};
return SHVkInstance::GetResourceManager().Create<SHVkDescriptorSetGroup>(device, GetHandle(), layouts, variableDescCounts);
}
}

View File

@ -101,7 +101,7 @@ namespace SHADE
/// Handles to the created Descriptor Sets. If this DescriptorPool has run out of
/// space, lesser number of Handles will be returned.
/// </returns>
std::vector<Handle<SHVkDescriptorSetGroup>> Allocate(const std::vector<Handle<SHVkDescriptorSetLayout>>& layouts, std::vector<uint32_t> const& variableDescCounts);
Handle<SHVkDescriptorSetGroup> Allocate(const std::vector<Handle<SHVkDescriptorSetLayout>>& layouts, std::vector<uint32_t> const& variableDescCounts);
private:
/*-----------------------------------------------------------------------------*/

View File

@ -29,6 +29,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/MiddleEnd/Batching/SHSuperBatch.h"
#include "SHGraphicsConstants.h"
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h"
#include "Graphics/Buffers/SHVkBuffer.h"
namespace SHADE
{
@ -129,7 +130,7 @@ namespace SHADE
}
// Initialize world render graph
worldRenderGraph->Init(device, swapchain, renderContextCmdPools, globalData);
worldRenderGraph->Init(device, swapchain, globalData);
//worldRenderGraph->AddResource("Position", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat);
//worldRenderGraph->AddResource("Normals", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat);
//worldRenderGraph->AddResource("Composite", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat);
@ -167,7 +168,7 @@ namespace SHADE
debugWorldRenderer->SetCamera(worldCamera);*/
// Add world renderer to default viewport
worldRenderer = defaultViewport->AddRenderer(resourceManager, swapchain->GetNumImages(), descPool, globalData->GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS], worldRenderGraph);
worldRenderer = defaultViewport->AddRenderer(resourceManager, swapchain->GetNumImages(), renderContextCmdPools, descPool, globalData->GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS], worldRenderGraph);
worldRenderer->SetCamera(worldCamera);
@ -228,16 +229,37 @@ namespace SHADE
// For every renderer
for (int renIndex = 0; renIndex < static_cast<int>(renderers.size()); ++renIndex)
{
// Draw first
renderers[renIndex]->Draw(renderContext.GetCurrentFrame(), MESH_DATA);
/*-----------------------------------------------------------------------*/
/* Renderer start */
/*-----------------------------------------------------------------------*/
// get command buffer of the renderer in the current frame
auto currentCmdBuffer = renderers[renIndex]->GetCommandBuffer(renderContext.GetCurrentFrame());
// get render graph
auto rg = renderers[renIndex]->GetRenderGraph();
// Begin recording the command buffer
currentCmdBuffer->BeginRecording();
// Bind all the buffers required for meshes
for (auto& [buffer, bindingPoint] : MESH_DATA)
{
if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eVertexBuffer)
currentCmdBuffer->BindVertexBuffer(bindingPoint, buffer, 0);
else if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eIndexBuffer)
currentCmdBuffer->BindIndexBuffer(buffer, 0);
}
// Draw first
renderers[renIndex]->Draw(renderContext.GetCurrentFrame());
// End the command buffer recording
currentCmdBuffer->EndRecording();
/*-----------------------------------------------------------------------*/
/* Renderer end */
/*-----------------------------------------------------------------------*/
// submit a command buffer from the current render graph and make it wait for the previous render graph before submitting it to GPU.
graphicsQueue->SubmitCommandBuffer
(
{ rg->GetCommandBuffer(renderContext.GetCurrentFrame()) },
{ currentCmdBuffer },
{ (vpIndex == viewports.size() - 1 && renIndex == renderers.size() - 1) ? frameData.semRenderFinishHdl : graphSemaphores[!semIndex] },
{ (vpIndex == 0 && renIndex == 0) ? frameData.semImgAvailableHdl : graphSemaphores[semIndex] },
{ vk::PipelineStageFlagBits::eColorAttachmentOutput },

View File

@ -20,20 +20,28 @@ of DigiPen Institute of Technology is prohibited.
#include "SHMaterial.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h"
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
#include "Graphics/Buffers/SHVkBuffer.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Constructor/Destructors */
/*-----------------------------------------------------------------------------------*/
SHRenderer::SHRenderer(Handle<SHVkLogicalDevice> logicalDevice, uint32_t numFrames, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHViewport> viewport, Handle<SHRenderGraph> renderGraph)
SHRenderer::SHRenderer(Handle<SHVkLogicalDevice> logicalDevice, uint32_t numFrames, std::vector<Handle<SHVkCommandPool>>& cmdPools, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHViewport> viewport, Handle<SHRenderGraph> renderGraph)
: viewport { viewport }
, renderGraph { renderGraph }
{
cameraDescriptorSet = logicalDevice->CreateDescriptorSetGroup(descriptorPool, { cameraDescLayout }, { 1 });
commandBuffers.resize(static_cast<std::size_t>(numFrames));
for (uint32_t i = 0; i < commandBuffers.size(); ++i)
commandBuffers[i] = cmdPools[i]->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
cameraDescriptorSet = descriptorPool->Allocate({ cameraDescLayout }, { 1 });
cpuCameraData.resize(numFrames);
cameraDataAlignedSize = logicalDevice->PadUBOSize(sizeof(SHShaderCameraData));
cameraBuffer = logicalDevice->CreateBuffer(cameraDataAlignedSize * numFrames, nullptr, cameraDataAlignedSize * numFrames, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
}
/*-----------------------------------------------------------------------------------*/
@ -47,9 +55,9 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
/* Drawing Functions */
/*-----------------------------------------------------------------------------------*/
void SHRenderer::Draw(uint32_t frameIndex, std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> graphScopeBuffers) noexcept
void SHRenderer::Draw(uint32_t frameIndex) noexcept
{
renderGraph->Execute(frameIndex, graphScopeBuffers);
renderGraph->Execute(frameIndex, commandBuffers[frameIndex]);
}
void SHRenderer::BindDescriptorSet(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept
@ -64,4 +72,9 @@ namespace SHADE
return renderGraph;
}
Handle<SHVkCommandBuffer> SHRenderer::GetCommandBuffer(uint32_t frameIndex) const noexcept
{
return commandBuffers[frameIndex];
}
}

View File

@ -39,6 +39,7 @@ namespace SHADE
class SHVkDescriptorSetGroup;
class SHGraphicsGlobalData;
class SHVkDescriptorPool;
class SHVkBuffer;
struct SHShaderCameraData
{
@ -63,7 +64,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Constructor/Destructors */
/*-----------------------------------------------------------------------------*/
SHRenderer(Handle<SHVkLogicalDevice> logicalDevice, uint32_t numFrames, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHViewport> viewport, Handle<SHRenderGraph> renderGraph);
SHRenderer(Handle<SHVkLogicalDevice> logicalDevice, uint32_t numFrames, std::vector<Handle<SHVkCommandPool>>& cmdPools, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHViewport> viewport, Handle<SHRenderGraph> renderGraph);
/*-----------------------------------------------------------------------------*/
/* Camera Registration */
@ -73,13 +74,14 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Drawing Functions */
/*-----------------------------------------------------------------------------*/
void Draw(uint32_t frameIndex, std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> graphScopeBuffers) noexcept;
void Draw(uint32_t frameIndex) noexcept;
void BindDescriptorSet (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept;
/*-----------------------------------------------------------------------------*/
/* Setters and Getters */
/*-----------------------------------------------------------------------------*/
Handle<SHRenderGraph> GetRenderGraph (void) const noexcept;
Handle<SHVkCommandBuffer> GetCommandBuffer(uint32_t frameIndex) const noexcept;
private:
/*-----------------------------------------------------------------------------*/
@ -92,7 +94,13 @@ namespace SHADE
Handle<SHCamera> camera;
Handle<SHRenderGraph> renderGraph;
Handle<SHVkDescriptorSetGroup> cameraDescriptorSet;
Handle<SHVkBuffer> cameraBuffer;
std::vector<SHShaderCameraData> cpuCameraData;
//! Command buffers for the render graph
std::vector<Handle<SHVkCommandBuffer>> commandBuffers;
};
}

View File

@ -49,10 +49,10 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Renderer Registration Functions */
/*---------------------------------------------------------------------------------*/
Handle<SHRenderer> SHViewport::AddRenderer(ResourceManager& resourceManager, uint32_t numFrames, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHRenderGraph> renderGraph)
Handle<SHRenderer> SHViewport::AddRenderer(ResourceManager& resourceManager, uint32_t numFrames, std::vector<Handle<SHVkCommandPool>>& cmdPools, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHRenderGraph> renderGraph)
{
// Create the renderer
auto renderer = resourceManager.Create<SHRenderer>(device, numFrames, descriptorPool, cameraDescLayout, GetHandle(), renderGraph);
auto renderer = resourceManager.Create<SHRenderer>(device, numFrames, cmdPools, descriptorPool, cameraDescLayout, GetHandle(), renderGraph);
// Store
renderers.emplace_back(renderer);

View File

@ -32,6 +32,7 @@ namespace SHADE
class SHRenderGraph;
class SHVkDescriptorPool;
class SHVkDescriptorSetLayout;
class SHVkCommandPool;
/*---------------------------------------------------------------------------------*/
/* Type Definitions */
@ -58,7 +59,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Renderers Registration Functions */
/*-----------------------------------------------------------------------------*/
Handle<SHRenderer> AddRenderer(ResourceManager& resourceManager, uint32_t numFrames, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHRenderGraph> renderGraph);
Handle<SHRenderer> AddRenderer(ResourceManager& resourceManager, uint32_t numFrames, std::vector<Handle<SHVkCommandPool>>& cmdPools, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHRenderGraph> renderGraph);
void RemoveRenderer(Handle<SHRenderer> renderer);
/*-----------------------------------------------------------------------------*/

View File

@ -946,25 +946,6 @@ namespace SHADE
}
}
/***************************************************************************/
/*!
\brief
Configures command pools and command buffers.
*/
/***************************************************************************/
void SHRenderGraph::ConfigureCommands(void) noexcept
{
//commandPools.resize (static_cast<std::size_t>(swapchainHdl->GetNumImages()));
commandBuffers.resize(static_cast<std::size_t>(swapchainHdl->GetNumImages()));
for (uint32_t i = 0; i < commandBuffers.size(); ++i)
{
commandBuffers[i] = commandPools[i]->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
}
}
/***************************************************************************/
/*!
@ -980,12 +961,11 @@ namespace SHADE
*/
/***************************************************************************/
void SHRenderGraph::Init(Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, std::vector<Handle<SHVkCommandPool>> const& cmdPools, Handle<SHGraphicsGlobalData> inGlobalData) noexcept
void SHRenderGraph::Init(Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, Handle<SHGraphicsGlobalData> inGlobalData) noexcept
{
logicalDeviceHdl = logicalDevice;
swapchainHdl = swapchain;
globalData = inGlobalData;
commandPools = cmdPools;
}
/***************************************************************************/
@ -1087,33 +1067,17 @@ namespace SHADE
ConfigureSubpasses();
ConfigureRenderpasses();
ConfigureFramebuffers();
ConfigureCommands();
}
// TODO: The graph scope buffers were meant to bind vertex buffers and index buffers for meshes. Find a
// better way to manage these
void SHRenderGraph::Execute(uint32_t frameIndex, std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> graphScopeBuffers) noexcept
void SHRenderGraph::Execute(uint32_t frameIndex, Handle<SHVkCommandBuffer> cmdBuffer) noexcept
{
//commandPools[frameIndex]->Reset();
auto& cmdBuffer = commandBuffers[frameIndex];
cmdBuffer->BeginRecording();
// TODO: DON'T HARDCODE THIS
cmdBuffer->SetViewportScissor(1920.0f, 1080.0f, 1920, 1080);
for (auto& [buffer, bindingPoint]: graphScopeBuffers)
{
if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eVertexBuffer)
cmdBuffer->BindVertexBuffer(bindingPoint, buffer, 0);
else if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eIndexBuffer)
cmdBuffer->BindIndexBuffer(buffer, 0);
}
for (auto& node : nodes)
node->Execute(cmdBuffer, frameIndex);
cmdBuffer->EndRecording();
}
void SHRenderGraph::FinaliseBatch()
@ -1132,9 +1096,5 @@ namespace SHADE
return {};
}
Handle<SHVkCommandBuffer> const& SHRenderGraph::GetCommandBuffer(uint32_t frameIndex) const noexcept
{
return commandBuffers[frameIndex];
}
}

View File

@ -250,7 +250,6 @@ namespace SHADE
void ConfigureSubpasses (void) noexcept;
void ConfigureRenderpasses (void) noexcept;
void ConfigureFramebuffers (void) noexcept;
void ConfigureCommands (void) noexcept;
/*-----------------------------------------------------------------------*/
/* PRIVATE MEMBER VARIABLES */
@ -272,12 +271,6 @@ namespace SHADE
//! Resource library for graph handles
ResourceManager resourceManager;
//! Command pool for the render graph. DO NOT RESET OR FREE THESE, THEY ARE NON-OWNING. TODO: If application is multithreaded, we need more pools.
std::vector<Handle<SHVkCommandPool>> commandPools;
//! Command buffers for the render graph
std::vector<Handle<SHVkCommandBuffer>> commandBuffers;
//! Handle to global data
Handle<SHGraphicsGlobalData> globalData;
@ -290,18 +283,17 @@ namespace SHADE
/*-----------------------------------------------------------------------*/
/* PUBLIC MEMBER FUNCTIONS */
/*-----------------------------------------------------------------------*/
void Init (Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, std::vector<Handle<SHVkCommandPool>> const& cmdPools, Handle<SHGraphicsGlobalData> inGlobalData) noexcept;
void Init (Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, Handle<SHGraphicsGlobalData> inGlobalData) noexcept;
void AddResource (std::string resourceName, SH_ATT_DESC_TYPE type, uint32_t w = static_cast<uint32_t>(-1), uint32_t h = static_cast<uint32_t>(-1), vk::Format format = vk::Format::eB8G8R8A8Unorm, uint8_t levels = 1, vk::ImageCreateFlagBits createFlags = {});
Handle<SHRenderGraphNode> AddNode (std::string nodeName, std::initializer_list<std::string> resourceNames, std::initializer_list<std::string> predecessorNodes) noexcept;
void Generate (void) noexcept;
void Execute (uint32_t frameIndex, std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> graphScopeBuffers) noexcept;
void Execute (uint32_t frameIndex, Handle<SHVkCommandBuffer> cmdBuffer) noexcept;
void FinaliseBatch();
/*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */
/*-----------------------------------------------------------------------*/
Handle<SHRenderGraphNode> GetNode (std::string const& nodeName) const noexcept;
Handle<SHVkCommandBuffer> const& GetCommandBuffer (uint32_t frameIndex) const noexcept;
};
}

View File

@ -9,4 +9,4 @@
#include "SHQuaternion.h"
#include "SHMatrix.h"
#include "SHTransform.h"
#include "Transform/SHTransform.h"