Fixed the fence with high quality wood
This commit is contained in:
parent
147292f91c
commit
0bc3a23161
|
@ -122,8 +122,14 @@ namespace SHADE
|
||||||
// Get render graph from default viewport world renderer
|
// Get render graph from default viewport world renderer
|
||||||
auto worldRenderGraph = resourceManager.Create<SHRenderGraph>();
|
auto worldRenderGraph = resourceManager.Create<SHRenderGraph>();
|
||||||
|
|
||||||
|
std::vector<Handle<SHVkCommandPool>> renderContextCmdPools{swapchain->GetNumImages()};
|
||||||
|
for (uint32_t i = 0; i < renderContextCmdPools.size(); ++i)
|
||||||
|
{
|
||||||
|
renderContextCmdPools[i] = renderContext.GetFrameData(i).cmdPoolHdls[0];
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize world render graph
|
// Initialize world render graph
|
||||||
worldRenderGraph->Init(device, swapchain, globalData);
|
worldRenderGraph->Init(device, swapchain, renderContextCmdPools, globalData);
|
||||||
//worldRenderGraph->AddResource("Position", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat);
|
//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("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);
|
//worldRenderGraph->AddResource("Composite", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat);
|
||||||
|
@ -211,6 +217,9 @@ namespace SHADE
|
||||||
std::make_pair(meshLibrary.GetIndexBuffer(), 0),
|
std::make_pair(meshLibrary.GetIndexBuffer(), 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
renderContext.ResetFence();
|
||||||
|
|
||||||
|
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
|
@ -292,6 +301,7 @@ namespace SHADE
|
||||||
|
|
||||||
// #BackEndTest: Acquire the next image in the swapchain available
|
// #BackEndTest: Acquire the next image in the swapchain available
|
||||||
renderContext.AcquireNextIamge();
|
renderContext.AcquireNextIamge();
|
||||||
|
const uint32_t CURR_FRAME_IDX_2 = renderContext.GetCurrentFrame();
|
||||||
|
|
||||||
// #BackEndTest: Get the current frame from frame manager
|
// #BackEndTest: Get the current frame from frame manager
|
||||||
auto& currFrameData = renderContext.GetCurrentFrameData();
|
auto& currFrameData = renderContext.GetCurrentFrameData();
|
||||||
|
@ -301,6 +311,7 @@ namespace SHADE
|
||||||
throw std::runtime_error("No command pools available!");
|
throw std::runtime_error("No command pools available!");
|
||||||
currFrameData.cmdPoolHdls[0]->Reset();
|
currFrameData.cmdPoolHdls[0]->Reset();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
@ -316,15 +327,6 @@ namespace SHADE
|
||||||
const uint32_t CURR_FRAME_IDX = renderContext.GetCurrentFrame();
|
const uint32_t CURR_FRAME_IDX = renderContext.GetCurrentFrame();
|
||||||
auto& currFrameData = renderContext.GetCurrentFrameData();
|
auto& currFrameData = renderContext.GetCurrentFrameData();
|
||||||
|
|
||||||
renderContext.ResetFence();
|
|
||||||
|
|
||||||
// #BackEndTest: Prepare to present current image
|
|
||||||
vk::PresentInfoKHR presentInfo{};
|
|
||||||
presentInfo.waitSemaphoreCount = 1;
|
|
||||||
presentInfo.pWaitSemaphores = &currFrameData.semRenderFinishHdl->GetVkSem();
|
|
||||||
presentInfo.swapchainCount = 1;
|
|
||||||
presentInfo.pSwapchains = &swapchain->GetVkSwapchain();
|
|
||||||
presentInfo.pImageIndices = &CURR_FRAME_IDX;
|
|
||||||
|
|
||||||
// #BackEndTest: queues an image for presentation
|
// #BackEndTest: queues an image for presentation
|
||||||
if (auto result = graphicsQueue->Present(swapchain, { currFrameData.semRenderFinishHdl }, CURR_FRAME_IDX); result != vk::Result::eSuccess)
|
if (auto result = graphicsQueue->Present(swapchain, { currFrameData.semRenderFinishHdl }, CURR_FRAME_IDX); result != vk::Result::eSuccess)
|
||||||
|
|
|
@ -946,11 +946,12 @@ namespace SHADE
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
void SHRenderGraph::ConfigureCommands(void) noexcept
|
void SHRenderGraph::ConfigureCommands(void) noexcept
|
||||||
{
|
{
|
||||||
commandPool = logicalDeviceHdl->CreateCommandPool(SH_QUEUE_FAMILY_ARRAY_INDEX::GRAPHICS, SH_CMD_POOL_RESET::POOL_BASED, true);
|
//commandPools.resize (static_cast<std::size_t>(swapchainHdl->GetNumImages()));
|
||||||
commandBuffers.resize(static_cast<std::size_t>(swapchainHdl->GetNumImages()));
|
commandBuffers.resize(static_cast<std::size_t>(swapchainHdl->GetNumImages()));
|
||||||
for (auto& cmdBuffer : commandBuffers)
|
|
||||||
|
for (uint32_t i = 0; i < commandBuffers.size(); ++i)
|
||||||
{
|
{
|
||||||
cmdBuffer = commandPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
|
commandBuffers[i] = commandPools[i]->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -969,11 +970,12 @@ namespace SHADE
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
void SHRenderGraph::Init(Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, Handle<SHGraphicsGlobalData> inGlobalData) noexcept
|
void SHRenderGraph::Init(Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, std::vector<Handle<SHVkCommandPool>> const& cmdPools, Handle<SHGraphicsGlobalData> inGlobalData) noexcept
|
||||||
{
|
{
|
||||||
logicalDeviceHdl = logicalDevice;
|
logicalDeviceHdl = logicalDevice;
|
||||||
swapchainHdl = swapchain;
|
swapchainHdl = swapchain;
|
||||||
globalData = inGlobalData;
|
globalData = inGlobalData;
|
||||||
|
commandPools = cmdPools;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
@ -1082,7 +1084,7 @@ namespace SHADE
|
||||||
// better way to manage these
|
// 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, std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> graphScopeBuffers) noexcept
|
||||||
{
|
{
|
||||||
commandPool->Reset();
|
//commandPools[frameIndex]->Reset();
|
||||||
|
|
||||||
auto& cmdBuffer = commandBuffers[frameIndex];
|
auto& cmdBuffer = commandBuffers[frameIndex];
|
||||||
cmdBuffer->BeginRecording();
|
cmdBuffer->BeginRecording();
|
||||||
|
|
|
@ -272,8 +272,8 @@ namespace SHADE
|
||||||
//! Resource library for graph handles
|
//! Resource library for graph handles
|
||||||
ResourceManager resourceManager;
|
ResourceManager resourceManager;
|
||||||
|
|
||||||
//! Command pool for the render graph
|
//! 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.
|
||||||
Handle<SHVkCommandPool> commandPool;
|
std::vector<Handle<SHVkCommandPool>> commandPools;
|
||||||
|
|
||||||
//! Command buffers for the render graph
|
//! Command buffers for the render graph
|
||||||
std::vector<Handle<SHVkCommandBuffer>> commandBuffers;
|
std::vector<Handle<SHVkCommandBuffer>> commandBuffers;
|
||||||
|
@ -290,7 +290,7 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* PUBLIC MEMBER FUNCTIONS */
|
/* PUBLIC MEMBER FUNCTIONS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
void Init (Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, Handle<SHGraphicsGlobalData> inGlobalData) noexcept;
|
void Init (Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, std::vector<Handle<SHVkCommandPool>> const& cmdPools, 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 = {});
|
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;
|
||||||
|
|
Loading…
Reference in New Issue