Linked MeshLibrary to RenderGraph

This commit is contained in:
Kah Wei 2022-09-19 15:52:51 +08:00
parent d025abe43a
commit f408247007
7 changed files with 58 additions and 19 deletions

View File

@ -59,7 +59,8 @@ namespace Sandbox
SHADE::SHScriptEngine::Init(); SHADE::SHScriptEngine::Init();
// Create temp meshes // Create temp meshes
SHADE::SHPrimitiveGenerator::Cube(*graphicsSystem);
graphicsSystem->BuildMeshBuffers();
} }
void SBApplication::Update(void) void SBApplication::Update(void)

View File

@ -73,6 +73,34 @@ namespace SHADE
struct VertexBufferBindings struct VertexBufferBindings
{ {
/***************************************************************************/
/*!
\brief
Vertex buffer bindings for the transform matrix buffer.
*/
/***************************************************************************/
static constexpr uint32_t POSITION = 0;
/***************************************************************************/
/*!
\brief
Vertex buffer bindings for the transform matrix buffer.
*/
/***************************************************************************/
static constexpr uint32_t TEX_COORD = 1;
/***************************************************************************/
/*!
\brief
Vertex buffer bindings for the transform matrix buffer.
*/
/***************************************************************************/
static constexpr uint32_t NORMAL = 2;
/***************************************************************************/
/*!
\brief
Vertex buffer bindings for the transform matrix buffer.
*/
/***************************************************************************/
static constexpr uint32_t TANGENT = 3;
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief

View File

@ -27,6 +27,7 @@ of DigiPen Institute of Technology is prohibited.
#include "ECS_Base/Managers/SHComponentManager.h" #include "ECS_Base/Managers/SHComponentManager.h"
#include "Graphics/MiddleEnd/Interface/SHRenderable.h" #include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Graphics/MiddleEnd/Batching/SHSuperBatch.h" #include "Graphics/MiddleEnd/Batching/SHSuperBatch.h"
#include "SHGraphicsConstants.h"
namespace SHADE namespace SHADE
{ {
@ -197,6 +198,16 @@ namespace SHADE
// semaphore index. This is for render graphs to have semaphores to signal that the next render graph will use to wait on. // semaphore index. This is for render graphs to have semaphores to signal that the next render graph will use to wait on.
bool semIndex = 0; bool semIndex = 0;
using BufferPair = std::pair<Handle<SHVkBuffer>, uint32_t>;
const std::initializer_list<BufferPair> MESH_DATA =
{
std::make_pair(meshLibrary.GetVertexPositionsBuffer(), SHGraphicsConstants::VertexBufferBindings::POSITION),
std::make_pair(meshLibrary.GetVertexTexCoordsBuffer(), SHGraphicsConstants::VertexBufferBindings::TEX_COORD),
std::make_pair(meshLibrary.GetVertexNormalsBuffer(), SHGraphicsConstants::VertexBufferBindings::NORMAL),
std::make_pair(meshLibrary.GetVertexTangentsBuffer(), SHGraphicsConstants::VertexBufferBindings::TANGENT),
std::make_pair(meshLibrary.GetIndexBuffer(), 0),
};
// For every viewport // For every viewport
for (int vpIndex = 0; vpIndex < static_cast<int>(viewports.size()); ++vpIndex) for (int vpIndex = 0; vpIndex < static_cast<int>(viewports.size()); ++vpIndex)
{ {
@ -206,7 +217,7 @@ namespace SHADE
for (int renIndex = 0; renIndex < static_cast<int>(renderers.size()); ++renIndex) for (int renIndex = 0; renIndex < static_cast<int>(renderers.size()); ++renIndex)
{ {
// Draw first // Draw first
renderers[renIndex]->Draw(renderContext.GetCurrentFrame()); renderers[renIndex]->Draw(renderContext.GetCurrentFrame(), MESH_DATA);
// get render graph // get render graph
auto rg = renderers[renIndex]->GetRenderGraph(); auto rg = renderers[renIndex]->GetRenderGraph();
@ -388,7 +399,7 @@ namespace SHADE
transferCmdBuffer->BeginRecording(); transferCmdBuffer->BeginRecording();
meshLibrary.BuildBuffers(device, transferCmdBuffer); meshLibrary.BuildBuffers(device, transferCmdBuffer);
transferCmdBuffer->EndRecording(); transferCmdBuffer->EndRecording();
queue->SubmitCommandBuffer({ transferCmdBuffer }); graphicsQueue->SubmitCommandBuffer({ transferCmdBuffer });
} }
void SHGraphicsSystem::SetWindow(SHWindow* wind) noexcept void SHGraphicsSystem::SetWindow(SHWindow* wind) noexcept
@ -418,10 +429,6 @@ namespace SHADE
// For global data (generic data and textures) // For global data (generic data and textures)
Handle<SHVkDescriptorSetLayout> staticGlobalLayout = device->CreateDescriptorSetLayout({genericDataBinding, texturesBinding}); Handle<SHVkDescriptorSetLayout> staticGlobalLayout = device->CreateDescriptorSetLayout({genericDataBinding, texturesBinding});
SHVkDescriptorSetLayout::Binding lightBinding SHVkDescriptorSetLayout::Binding lightBinding
{ {
.Type = vk::DescriptorType::eStorageBufferDynamic, .Type = vk::DescriptorType::eStorageBufferDynamic,
@ -433,10 +440,6 @@ namespace SHADE
// For Dynamic global data (lights) // For Dynamic global data (lights)
Handle<SHVkDescriptorSetLayout> dynamicGlobalLayout = device->CreateDescriptorSetLayout({ lightBinding }); Handle<SHVkDescriptorSetLayout> dynamicGlobalLayout = device->CreateDescriptorSetLayout({ lightBinding });
SHVkDescriptorSetLayout::Binding cameraDataBinding SHVkDescriptorSetLayout::Binding cameraDataBinding
{ {
.Type = vk::DescriptorType::eUniformBufferDynamic, .Type = vk::DescriptorType::eUniformBufferDynamic,
@ -448,10 +451,6 @@ namespace SHADE
// For High frequency global data (camera) // For High frequency global data (camera)
Handle<SHVkDescriptorSetLayout> cameraDataGlobalLayout = device->CreateDescriptorSetLayout({ cameraDataBinding }); Handle<SHVkDescriptorSetLayout> cameraDataGlobalLayout = device->CreateDescriptorSetLayout({ cameraDataBinding });
SHVkDescriptorSetLayout::Binding materialDataBinding SHVkDescriptorSetLayout::Binding materialDataBinding
{ {
.Type = vk::DescriptorType::eStorageBufferDynamic, .Type = vk::DescriptorType::eStorageBufferDynamic,

View File

@ -40,9 +40,9 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Drawing Functions */ /* Drawing Functions */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void SHRenderer::Draw(uint32_t frameIndex) noexcept void SHRenderer::Draw(uint32_t frameIndex, std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> graphScopeBuffers) noexcept
{ {
renderGraph->Execute(frameIndex); renderGraph->Execute(frameIndex, graphScopeBuffers);
} }
Handle<SHRenderGraph> SHRenderer::GetRenderGraph(void) const noexcept Handle<SHRenderGraph> SHRenderer::GetRenderGraph(void) const noexcept

View File

@ -62,7 +62,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Drawing Functions */ /* Drawing Functions */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
void Draw(uint32_t frameIndex) noexcept; void Draw(uint32_t frameIndex, std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> graphScopeBuffers) noexcept;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Setters and Getters */ /* Setters and Getters */

View File

@ -14,6 +14,7 @@ of DigiPen Institute of Technology is prohibited.
#include "SHPrimitiveGenerator.h" #include "SHPrimitiveGenerator.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h" #include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
#include "Graphics/MiddleEnd/Interface/SHMeshLibrary.h"
namespace SHADE namespace SHADE
{ {

View File

@ -14,17 +14,27 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes // Project Includes
#include "Math/SHMath.h" #include "Math/SHMath.h"
#include "SHMeshData.h" #include "SHMeshData.h"
#include "SH_API.h"
namespace SHADE namespace SHADE
{ {
/*-----------------------------------------------------------------------------------*/
/* Forward Declarations */
/*-----------------------------------------------------------------------------------*/
class SHGraphicsSystem;
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------------*/
/*************************************************************************************/ /*************************************************************************************/
/*! /*!
\brief \brief
Static class that contains functions for generating 3D primitives. Static class that contains functions for generating 3D primitives.
*/ */
/*************************************************************************************/ /*************************************************************************************/
class SHPrimitiveGenerator class SH_API SHPrimitiveGenerator
{ {
public:
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Constructors */ /* Constructors */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/