diff --git a/SHADE_Engine/src/Graphics/Buffers/SHVkBuffer.cpp b/SHADE_Engine/src/Graphics/Buffers/SHVkBuffer.cpp index 20b94626..841813e4 100644 --- a/SHADE_Engine/src/Graphics/Buffers/SHVkBuffer.cpp +++ b/SHADE_Engine/src/Graphics/Buffers/SHVkBuffer.cpp @@ -54,6 +54,11 @@ namespace SHADE return vkBuffer; } + vk::BufferUsageFlags SHVkBuffer::GetUsageBits(void) const noexcept + { + return bufferUsageFlags; + } + /***************************************************************************/ /*! diff --git a/SHADE_Engine/src/Graphics/Buffers/SHVkBuffer.h b/SHADE_Engine/src/Graphics/Buffers/SHVkBuffer.h index 7f4e0889..49f22e37 100644 --- a/SHADE_Engine/src/Graphics/Buffers/SHVkBuffer.h +++ b/SHADE_Engine/src/Graphics/Buffers/SHVkBuffer.h @@ -105,6 +105,7 @@ namespace SHADE /* SETTERS AND GETTERS */ /*-----------------------------------------------------------------------*/ vk::Buffer GetVkBuffer (void) const noexcept; + vk::BufferUsageFlags GetUsageBits(void) const noexcept; }; } diff --git a/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorSetGroup.cpp b/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorSetGroup.cpp index 16143aa5..0f4ee31c 100644 --- a/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorSetGroup.cpp +++ b/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorSetGroup.cpp @@ -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); + } + } \ No newline at end of file diff --git a/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorSetGroup.h b/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorSetGroup.h index 9e311e9a..25685e3e 100644 --- a/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorSetGroup.h +++ b/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorSetGroup.h @@ -59,6 +59,8 @@ namespace SHADE void ModifyWriteDescImage (uint32_t set, uint32_t binding, std::vector> const& imageViewsAndSamplers) noexcept; void UpdateDescriptorSet (void) noexcept; + void UpdateSingleDescriptorSetImages (uint32_t set, uint32_t binding) noexcept; + /*-----------------------------------------------------------------------------*/ /* Getter Functions */ /*-----------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.cpp b/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.cpp index 8252929d..b009f4ed 100644 --- a/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.cpp +++ b/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.cpp @@ -568,6 +568,11 @@ namespace SHADE vkLogicalDevice.updateDescriptorSets(writeDescSets, {}); } + void SHVkLogicalDevice::UpdateDescriptorSet(vk::WriteDescriptorSet const& writeDescSet) noexcept + { + vkLogicalDevice.updateDescriptorSets(1, &writeDescSet, 0, {}); + } + /***************************************************************************/ /*! diff --git a/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.h b/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.h index 01764e80..6c2a096d 100644 --- a/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.h +++ b/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.h @@ -181,7 +181,8 @@ namespace SHADE Handle CreateFence (void) const noexcept; Handle CreateSemaphore (void) const noexcept; - void UpdateDescriptorSets (std::vector const& writeDescSets) noexcept; + void UpdateDescriptorSets(std::vector const& writeDescSets) noexcept; + void UpdateDescriptorSet (vk::WriteDescriptorSet const& writeDescSet) noexcept; /*-----------------------------------------------------------------------*/ /* SETTERS AND GETTERS */ diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp index ee5049e3..22ba9695 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp @@ -6,6 +6,7 @@ #include "Graphics/Images/SHVkImage.h" #include "Graphics/Images/SHVkImageView.h" #include "Graphics/Framebuffer/SHVkFramebuffer.h" +#include "Graphics/Buffers/SHVkBuffer.h" #include "Tools/SHLogger.h" namespace SHADE @@ -1068,20 +1069,29 @@ namespace SHADE 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, uint32_t>> graphScopeBuffers) noexcept { commandPool->Reset(); auto& cmdBuffer = commandBuffers[frameIndex]; cmdBuffer->BeginRecording(); + // TODO: DON'T HARDCODE THIS 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(); } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h index f563841e..48701d87 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h @@ -292,7 +292,7 @@ namespace SHADE void AddResource (std::string resourceName, SH_ATT_DESC_TYPE type, uint32_t w = static_cast(-1), uint32_t h = static_cast(-1), vk::Format format = vk::Format::eB8G8R8A8Unorm, uint8_t levels = 1, vk::ImageCreateFlagBits createFlags = {}); Handle AddNode (std::string nodeName, std::initializer_list resourceNames, std::initializer_list predecessorNodes) noexcept; void Generate (void) noexcept; - void Execute (uint32_t frameIndex) noexcept; + void Execute (uint32_t frameIndex, std::initializer_list, uint32_t>> graphScopeBuffers) noexcept; /*-----------------------------------------------------------------------*/ /* SETTERS AND GETTERS */