Render graph execution now takes in graph scope buffers

This commit is contained in:
Brandon Mak 2022-09-19 15:32:03 +08:00
parent 8070b2dafa
commit d025abe43a
8 changed files with 45 additions and 5 deletions

View File

@ -54,6 +54,11 @@ namespace SHADE
return vkBuffer; return vkBuffer;
} }
vk::BufferUsageFlags SHVkBuffer::GetUsageBits(void) const noexcept
{
return bufferUsageFlags;
}
/***************************************************************************/ /***************************************************************************/
/*! /*!

View File

@ -105,6 +105,7 @@ namespace SHADE
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
vk::Buffer GetVkBuffer (void) const noexcept; vk::Buffer GetVkBuffer (void) const noexcept;
vk::BufferUsageFlags GetUsageBits(void) const noexcept;
}; };
} }

View File

@ -185,4 +185,20 @@ namespace SHADE
} }
void SHVkDescriptorSetGroup::UpdateSingleDescriptorSetImages(uint32_t set, uint32_t binding) noexcept
{
vk::WriteDescriptorSet writeDescSet{};
// Initialize info for write
writeDescSet.descriptorType = vk::DescriptorType::eCombinedImageSampler;
writeDescSet.dstArrayElement = 0;
writeDescSet.dstSet = descSets[set];
writeDescSet.dstBinding = binding;
writeDescSet.pImageInfo = updater.writeInfos[set].descImageInfos.data();
writeDescSet.descriptorCount = updater.writeInfos[set].descImageInfos.size();
device->UpdateDescriptorSet(writeDescSet);
}
} }

View File

@ -59,6 +59,8 @@ namespace SHADE
void ModifyWriteDescImage (uint32_t set, uint32_t binding, std::vector<std::pair<vk::ImageView, vk::Sampler>> const& imageViewsAndSamplers) noexcept; void ModifyWriteDescImage (uint32_t set, uint32_t binding, std::vector<std::pair<vk::ImageView, vk::Sampler>> const& imageViewsAndSamplers) noexcept;
void UpdateDescriptorSet (void) noexcept; void UpdateDescriptorSet (void) noexcept;
void UpdateSingleDescriptorSetImages (uint32_t set, uint32_t binding) noexcept;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Getter Functions */ /* Getter Functions */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/

View File

@ -568,6 +568,11 @@ namespace SHADE
vkLogicalDevice.updateDescriptorSets(writeDescSets, {}); vkLogicalDevice.updateDescriptorSets(writeDescSets, {});
} }
void SHVkLogicalDevice::UpdateDescriptorSet(vk::WriteDescriptorSet const& writeDescSet) noexcept
{
vkLogicalDevice.updateDescriptorSets(1, &writeDescSet, 0, {});
}
/***************************************************************************/ /***************************************************************************/
/*! /*!

View File

@ -181,7 +181,8 @@ namespace SHADE
Handle<SHVkFence> CreateFence (void) const noexcept; Handle<SHVkFence> CreateFence (void) const noexcept;
Handle<SHVkSemaphore> CreateSemaphore (void) const noexcept; Handle<SHVkSemaphore> CreateSemaphore (void) const noexcept;
void UpdateDescriptorSets (std::vector<vk::WriteDescriptorSet> const& writeDescSets) noexcept; void UpdateDescriptorSets(std::vector<vk::WriteDescriptorSet> const& writeDescSets) noexcept;
void UpdateDescriptorSet (vk::WriteDescriptorSet const& writeDescSet) noexcept;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */

View File

@ -6,6 +6,7 @@
#include "Graphics/Images/SHVkImage.h" #include "Graphics/Images/SHVkImage.h"
#include "Graphics/Images/SHVkImageView.h" #include "Graphics/Images/SHVkImageView.h"
#include "Graphics/Framebuffer/SHVkFramebuffer.h" #include "Graphics/Framebuffer/SHVkFramebuffer.h"
#include "Graphics/Buffers/SHVkBuffer.h"
#include "Tools/SHLogger.h" #include "Tools/SHLogger.h"
namespace SHADE namespace SHADE
@ -1068,20 +1069,29 @@ namespace SHADE
ConfigureCommands(); ConfigureCommands();
} }
void SHRenderGraph::Execute(uint32_t frameIndex) noexcept // 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
{ {
commandPool->Reset(); commandPool->Reset();
auto& cmdBuffer = commandBuffers[frameIndex]; auto& cmdBuffer = commandBuffers[frameIndex];
cmdBuffer->BeginRecording(); cmdBuffer->BeginRecording();
// TODO: DON'T HARDCODE THIS
cmdBuffer->SetViewportScissor(1920.0f, 1080.0f, 1920, 1080); cmdBuffer->SetViewportScissor(1920.0f, 1080.0f, 1920, 1080);
for (auto& node : nodes) for (auto& [buffer, bindingPoint]: graphScopeBuffers)
{ {
node->Execute(commandBuffers[frameIndex], frameIndex); 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(commandBuffers[frameIndex], frameIndex);
cmdBuffer->EndRecording(); cmdBuffer->EndRecording();
} }

View File

@ -292,7 +292,7 @@ namespace SHADE
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 = {}); 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; Handle<SHRenderGraphNode> AddNode (std::string nodeName, std::initializer_list<std::string> resourceNames, std::initializer_list<std::string> predecessorNodes) noexcept;
void Generate (void) noexcept; void Generate (void) noexcept;
void Execute (uint32_t frameIndex) noexcept; void Execute (uint32_t frameIndex, std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> graphScopeBuffers) noexcept;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */