Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
build-macos:
strategy:
matrix:
os: [[macos-13,x64-osx,clang]]
os: [[macos-latest,x64-osx,clang]]
buildType: [Release]
runs-on: ${{ matrix.os[0] }}
steps:
Expand Down
5 changes: 3 additions & 2 deletions include/RenderGraph/FrameGraphBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ See LICENSE file in root folder.
*/
#pragma once

#include <vulkan/vulkan.h>

#pragma warning( push )
#pragma warning( disable: 4365 )
#pragma warning( disable: 4865 )
#pragma warning( disable: 5262 )
#include <vulkan/vulkan.h>

#include <algorithm>
#include <bit>
#include <functional>
Expand Down
2 changes: 1 addition & 1 deletion include/RenderGraph/RunnablePass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace crg
*\brief
* Resets the command buffer to initial state.
*/
CRG_API void resetCommandBuffer( uint32_t passIndex );
CRG_API bool resetCommandBuffer( uint32_t passIndex );
CRG_API void notifyPassRender();

LayoutState getLayoutState( crg::ImageViewId view )const
Expand Down
30 changes: 30 additions & 0 deletions include/RenderGraph/RunnablePasses/PipelineHolder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace crg
CRG_API void recordInto( RecordContext const & context
, VkCommandBuffer commandBuffer
, uint32_t index );
CRG_API void resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config );
CRG_API void resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index );
CRG_API void createDescriptorSet( uint32_t index );
Expand Down Expand Up @@ -131,6 +134,33 @@ namespace crg
m_baseConfig.pushConstants( config );
return static_cast< BuilderT & >( *this );
}
/**
*\param[in] config
* The push constants range for the pipeline.
*/
auto & pushConstants( VkPushConstantRangeArray const & config )
{
m_baseConfig.pushConstants( config );
return static_cast< BuilderT & >( *this );
}
/**
*\param[in] config
* The descriptor set layouts.
*/
auto & layout( VkDescriptorSetLayout const & config )
{
m_baseConfig.layout( config );
return *this;
}
/**
*\param[in] config
* The descriptor set layouts.
*/
auto & layouts( std::vector< VkDescriptorSetLayout > const & config )
{
m_baseConfig.layouts( config );
return *this;
}

pp::Config const & getBaseConfig()const noexcept
{
Expand Down
4 changes: 4 additions & 0 deletions include/RenderGraph/RunnablePasses/RenderMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ namespace crg
, rm::Config rmConfig );
CRG_API ~RenderMesh()noexcept override = default;

CRG_API void resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config
, uint32_t index );
CRG_API void resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index );

Expand Down
4 changes: 4 additions & 0 deletions include/RenderGraph/RunnablePasses/RenderMeshHolder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ namespace crg
, VkRenderPass renderPass
, VkPipelineColorBlendStateCreateInfo blendState
, uint32_t index );
CRG_API void resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config
, uint32_t index );
CRG_API void resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index );
CRG_API void record( RecordContext & context
Expand Down
4 changes: 4 additions & 0 deletions include/RenderGraph/RunnablePasses/RenderQuad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ namespace crg
, ru::Config const & ruConfig
, rq::Config rqConfig );

CRG_API void resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config
, uint32_t index );
CRG_API void resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index );

Expand Down
18 changes: 18 additions & 0 deletions include/RenderGraph/RunnablePasses/RenderQuadConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ namespace crg
}
/**
*\param[in] config
* The push constants range.
*/
auto & pushConstants( VkPushConstantRange const & config )
{
m_baseConfig.pushConstants( VkPushConstantRangeArray{ config } );
return *this;
}
/**
*\param[in] config
* The push constants range.
*/
auto & pushConstants( VkPushConstantRangeArray const & config )
{
m_baseConfig.pushConstants( config );
return *this;
}
/**
*\param[in] config
* Tells if disabled pass should record render pass begin/end.
*/
auto & baseConfig( pp::Config const & config )
Expand Down
4 changes: 4 additions & 0 deletions include/RenderGraph/RunnablePasses/RenderQuadHolder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ namespace crg
, VkRenderPass renderPass
, VkPipelineColorBlendStateCreateInfo blendState
, uint32_t index );
CRG_API void resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config
, uint32_t index );
CRG_API void resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index );
CRG_API void record( RecordContext & context
Expand Down
7 changes: 6 additions & 1 deletion source/RenderGraph/RunnablePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,21 +589,26 @@ namespace crg
}
}

void RunnablePass::resetCommandBuffer( uint32_t passIndex )
bool RunnablePass::resetCommandBuffer( uint32_t passIndex )
{
bool result{};

if ( m_context.device )
{
assert( m_passes.size() > passIndex );
auto & pass = m_passes[passIndex];

if ( pass.commandBuffer.commandBuffer )
{
result = true;
pass.fence.wait( 0xFFFFFFFFFFFFFFFFULL );
pass.commandBuffer.recorded = false;
m_context.vkResetCommandBuffer( pass.commandBuffer.commandBuffer
, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT );
}
}

return result;
}

void RunnablePass::notifyPassRender()
Expand Down
30 changes: 30 additions & 0 deletions source/RenderGraph/RunnablePasses/PipelineHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,36 @@ namespace crg
context->vkCmdBindDescriptorSets( commandBuffer, m_bindingPoint, m_pipelineLayout, 0u, 1u, &m_descriptorSets[index].set, 0u, nullptr );
}

void PipelineHolder::resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config )
{
bool hadPipelineLayout{};
if ( m_pipelineLayout )
{
hadPipelineLayout = true;
auto pipelineLayout = m_pipelineLayout;
m_context.delQueue.push( [pipelineLayout]( GraphContext & context )
{
crgUnregisterObject( context, pipelineLayout );
context.vkDestroyPipelineLayout( context.device
, pipelineLayout
, context.allocator );
} );
m_pipelineLayout = {};
}

m_baseConfig.layouts( layouts );
m_baseConfig.pushConstants( ranges );

if ( hadPipelineLayout )
doCreatePipelineLayout();

auto count = uint32_t( m_pipelines.size() );
for ( uint32_t i = 0; i < count; ++i )
resetPipeline( config, i );
}

void PipelineHolder::resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index )
{
Expand Down
11 changes: 11 additions & 0 deletions source/RenderGraph/RunnablePasses/RenderMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ namespace crg
{
}

void RenderMesh::resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config
, uint32_t index )
{
bool hadCommandBuffer = resetCommandBuffer( index );
m_renderMesh.resetPipelineLayout( layouts, ranges, config, index );
if ( hadCommandBuffer )
reRecordCurrent();
}

void RenderMesh::resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index )
{
Expand Down
13 changes: 13 additions & 0 deletions source/RenderGraph/RunnablePasses/RenderMeshHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ namespace crg
doCreatePipeline( index );
}

void RenderMeshHolder::resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config
, uint32_t index )
{
m_pipeline.resetPipelineLayout( layouts, ranges, config );

if ( m_renderPass )
{
doCreatePipeline( index );
}
}

void RenderMeshHolder::resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index )
{
Expand Down
11 changes: 11 additions & 0 deletions source/RenderGraph/RunnablePasses/RenderQuad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ namespace crg
{
}

void RenderQuad::resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config
, uint32_t index )
{
bool hadCommandBuffer = resetCommandBuffer( index );
m_renderQuad.resetPipelineLayout( layouts, ranges, config, index );
if ( hadCommandBuffer )
reRecordCurrent();
}

void RenderQuad::resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index )
{
Expand Down
13 changes: 13 additions & 0 deletions source/RenderGraph/RunnablePasses/RenderQuadHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ namespace crg
doCreatePipeline( index );
}

void RenderQuadHolder::resetPipelineLayout( std::vector< VkDescriptorSetLayout > const & layouts
, std::vector< VkPushConstantRange > const & ranges
, VkPipelineShaderStageCreateInfoArray const & config
, uint32_t index )
{
m_pipeline.resetPipelineLayout( layouts, ranges, config );

if ( m_renderPass )
{
doCreatePipeline( index );
}
}

void RenderQuadHolder::resetPipeline( VkPipelineShaderStageCreateInfoArray config
, uint32_t index )
{
Expand Down
2 changes: 2 additions & 0 deletions test/TestRunnablePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,9 @@ namespace
require( renderQuad )
require( renderMesh )
checkNoThrow( renderQuad->resetPipeline( crg::VkPipelineShaderStageCreateInfoArray{ VkPipelineShaderStageCreateInfo{} }, 0u ) )
checkNoThrow( renderQuad->resetPipelineLayout( {}, {}, crg::VkPipelineShaderStageCreateInfoArray{ VkPipelineShaderStageCreateInfo{} }, 0u ) )
checkNoThrow( renderMesh->resetPipeline( crg::VkPipelineShaderStageCreateInfoArray{ VkPipelineShaderStageCreateInfo{} }, 0u ) )
checkNoThrow( renderMesh->resetPipelineLayout( {}, {}, crg::VkPipelineShaderStageCreateInfoArray{ VkPipelineShaderStageCreateInfo{} }, 0u ) )
checkNoThrow( runnable->record() )
checkNoThrow( runnable->run( crg::SemaphoreWait{ VkSemaphore( 1 ), crg::PipelineStageFlags::eAllGraphics }, VkQueue{} ) )
checkEqual( graph.getFinalLayoutState( sampledv, 0u ).layout, crg::ImageLayout::eShaderReadOnly )
Expand Down