Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Rendergraph #598

Merged
merged 14 commits into from
Aug 30, 2023
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
4 changes: 2 additions & 2 deletions data/vcpkg/ports/rendergraph/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
vcpkg_from_github(OUT_SOURCE_PATH SOURCE_PATH
REPO DragonJoker/RenderGraph
REF ed897d45ee5ad0c80cc457298bf5683c2ad63b57
REF ffc35182fb53a8f3db3e7f94eb289e26e624e206
HEAD_REF master
SHA512 1292236904a473bb8e6b4c070d473eafa26eabbe8372c9162437fc4b001fc2f6f410738bb33ddaf2673b937c6b54b85c5933decdc69ddcd325750f230938ada1
SHA512 c2bca7a37828efd621221336c5377d28a8cf10c07b54af175c09744c4df05a728f1bdd3077819fe1d48a2a896a67ad6f35fd72769c616a8ea3ae9744bd31895b
)

vcpkg_from_github(OUT_SOURCE_PATH CMAKE_SOURCE_PATH
Expand Down
4 changes: 2 additions & 2 deletions data/vcpkg/ports/shaderwriter/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
vcpkg_from_github(OUT_SOURCE_PATH SOURCE_PATH
REPO DragonJoker/ShaderWriter
REF 6aa2e9bb7f51c80df3ebf5f3d7ea5936d87e671f
REF c6626373eb3714fad26f8008849818e97deefb20
HEAD_REF development
SHA512 04c9973c513ff4b912283d4db93e255455e2ed909fa1ebfc09759d39e79bd7e156abf65f5686a8ffa311f7441b9c802c8a346ec41b02eb4e42564b53431042b8
SHA512 c92ac248d24a20112d879cb7720619be2cb13bd5e77e85cd791aa1236e53f1327ba09246615610250b2fd11bba0a326f666c6563272defdb9df066bf7db0ba31
)

vcpkg_from_github(OUT_SOURCE_PATH CMAKE_SOURCE_PATH
Expand Down
2 changes: 1 addition & 1 deletion doc/Castor3D/Castor3D Scene.xml

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions include/Core/Castor3D/Miscellaneous/MiscellaneousModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,12 @@ namespace castor3d
eMeshWorkGroupSizeX,
eMeshWorkGroupSizeY,
eMeshWorkGroupSizeZ,
eMeshTotalMemorySize,
eMeshOutputVertices,
eMeshOutputPrimitives,
eDrawMeshTasksCount,
eTaskWorkGroupInvocations,
eTaskWorkGroupSizeX,
eTaskWorkGroupSizeY,
eTaskWorkGroupSizeZ,
eTaskTotalMemorySize,
eTaskOutputCount,
CU_ScopedEnumBounds( eTexture1DSize )
};
/**
Expand Down
4 changes: 4 additions & 0 deletions include/Core/Castor3D/Miscellaneous/makeVkType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,10 @@ namespace castor3d
template<> struct VkStructTraits< VkPhysicalDeviceMeshShaderFeaturesNV >{ static VkStructureType constexpr value = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV; };
template<> struct VkStructTraits< VkPhysicalDeviceMeshShaderPropertiesNV >{ static VkStructureType constexpr value = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_NV; };
#endif
#if VK_EXT_mesh_shader
template<> struct VkStructTraits< VkPhysicalDeviceMeshShaderFeaturesEXT >{ static VkStructureType constexpr value = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT; };
template<> struct VkStructTraits< VkPhysicalDeviceMeshShaderPropertiesEXT >{ static VkStructureType constexpr value = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_EXT; };
#endif
#if VK_NV_fragment_shader_barycentric
template<> struct VkStructTraits< VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV >{ static VkStructureType constexpr value = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_NV; };
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ namespace castor3d

private:
using RunnablePass::resetCommandBuffer;
using RunnablePass::resetCommandBuffers;

LightRenderPass doCreateRenderPass( bool blend
, bool hasStencil );
Expand Down
4 changes: 3 additions & 1 deletion include/Core/Castor3D/Render/Overlays/OverlayPreparer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ namespace castor3d
C3D_API OverlayPreparer( OverlayRenderer & renderer
, RenderDevice const & device
, VkRenderPass renderPass
, VkFramebuffer framebuffer );
, VkFramebuffer framebuffer
, crg::Fence & fence );
C3D_API OverlayPreparer( OverlayPreparer && rhs )noexcept;
C3D_API OverlayPreparer & operator=( OverlayPreparer && rhs )noexcept;
C3D_API ~OverlayPreparer()noexcept;
Expand Down Expand Up @@ -74,6 +75,7 @@ namespace castor3d
private:
OverlayRenderer & m_renderer;
RenderDevice const & m_device;
crg::Fence & m_fence;
using OverlayDataArray = std::vector< OverlayDrawData >;
using OverlayDatasMap = std::map< OverlayPipelineData *, OverlayDataArray >;
std::map< uint32_t, OverlayDatasMap > m_levelsOverlays;
Expand Down
7 changes: 5 additions & 2 deletions include/Core/Castor3D/Render/Overlays/OverlayRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ namespace castor3d
*/
C3D_API OverlayPreparer beginPrepare( RenderDevice const & device
, VkRenderPass renderPass
, VkFramebuffer framebuffer );
, VkFramebuffer framebuffer
, crg::Fence & fence );
/**
*\~english
*\brief Uploads all GPU buffers to VRAM.
Expand Down Expand Up @@ -239,6 +240,7 @@ namespace castor3d
ashes::DescriptorSet const & createTextDescriptorSet( FontTexture & fontTexture );
void beginPrepare( VkRenderPass renderPass
, VkFramebuffer framebuffer
, crg::Fence & fence
, crg::FramePassTimer & timer
, castor::Size const & size );
void endPrepare();
Expand Down Expand Up @@ -274,7 +276,8 @@ namespace castor3d

private:
ashes::CommandBuffer & doBeginPrepare( VkRenderPass renderPass
, VkFramebuffer framebuffer );
, VkFramebuffer framebuffer
, crg::Fence & fence );
void doEndPrepare();
std::pair< OverlayDrawNode *, OverlayPipelineData * > doGetDrawNodeData( RenderDevice const & device
, VkRenderPass renderPass
Expand Down
1 change: 1 addition & 0 deletions include/Core/Castor3D/Render/RenderTarget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ namespace castor3d

private:
static uint32_t sm_uiCount;
RenderDevice & m_device;
TargetType m_type{};
castor::Size m_size;
castor::Size m_safeBandedSize;
Expand Down
4 changes: 0 additions & 4 deletions source/Core/Castor3D/Miscellaneous/GpuInformations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,12 @@ namespace castor3d
"Max mesh work group size X",
"Max mesh work group size Y",
"Max mesh work group size Z",
"Max mesh total memory size",
"Max mesh output vertices",
"Max mesh output primitives",
"Max draw mesh tasks count",
"Max task work group invocations",
"Max task work group size X",
"Max task work group size Y",
"Max task work group size Z",
"Max task total memory size",
"Max task output count",
};
stream << "GPU informations:" << "\n";
stream << " Vendor: " << object.getVendor() << "\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CU_ImplementSmartPtr( castor3d, MeshletComponent )

namespace castor3d
{
#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
namespace mshletcomp
{
static castor::String getName( MeshletComponent const & component )
Expand Down Expand Up @@ -45,7 +45,7 @@ namespace castor3d

void MeshletComponent::createDescriptorSet( Geometry const & geometry )
{
#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
auto & baseBuffers = getOwner()->getFinalBufferOffsets( geometry );
auto descSetIt = m_descriptorSets.emplace( &geometry, nullptr ).first;

Expand Down Expand Up @@ -135,7 +135,7 @@ namespace castor3d

ProgramFlags MeshletComponent::getProgramFlags( Material const & material )const
{
#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
return ProgramFlag::eHasMesh
| ( m_cull.empty()
? ProgramFlag::eNone
Expand Down Expand Up @@ -190,7 +190,7 @@ namespace castor3d

bool MeshletComponent::doInitialise( RenderDevice const & device )
{
#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
if ( !m_meshlets.empty() )
{
for ( auto & finalCullBuffer : m_finalCullBuffers )
Expand Down Expand Up @@ -261,7 +261,7 @@ namespace castor3d
return;
}

#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
auto count = uint32_t( m_meshlets.size() );

if ( count )
Expand All @@ -288,7 +288,7 @@ namespace castor3d

void MeshletComponent::doCreateDescriptorLayout( RenderDevice const & device )
{
#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
ashes::VkDescriptorSetLayoutBindingArray bindings;
bindings.emplace_back( makeDescriptorSetLayoutBinding( uint32_t( MeshBuffersIdx::eMeshlets )
, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace castor3d
auto a = convert( value.data[0], value.data[1], value.data[2], value.data[3] );
auto b = convert( value.data[4], value.data[5], value.data[6], value.data[7] );
auto c = convert( value.data[8], value.data[9], value.data[10], value.data[11] );
auto d = convert( value.data[12], value.data[13], value.data[14], value.data[15] );
auto d = convert( value.data[12], value.data[13], value.data[14], 0u );
result.push_back( castor::Point4ui{ a, b, c, d } );
}

Expand Down
10 changes: 10 additions & 0 deletions source/Core/Castor3D/Render/EnvironmentMap/EnvironmentMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ namespace castor3d
, index
, *m_scene.getBackground() );
m_runnables[index] = graph.compile( m_device.makeContext() );
m_scene.getEngine()->registerTimer( m_runnables[index]->getName() + "/Graph"
, m_runnables[index]->getTimer() );
printGraph( *m_runnables[index] );
auto runnable = m_runnables[index].get();
m_device.renderSystem.getEngine()->postEvent( makeGpuFunctorEvent( GpuEventType::ePreUpload
Expand Down Expand Up @@ -212,6 +214,12 @@ namespace castor3d

void EnvironmentMap::cleanup()
{
for ( auto & runnable : m_runnables )
{
m_scene.getEngine()->unregisterTimer( runnable->getName() + "/Graph"
, runnable->getTimer() );
}

m_runnables.clear();
m_passes.clear();
m_environmentMapViews.clear();
Expand Down Expand Up @@ -406,6 +414,8 @@ namespace castor3d
, index
, *m_scene.getBackground() ) );
m_runnables.emplace_back( graph.compile( m_device.makeContext() ) );
m_scene.getEngine()->registerTimer( graph.getName()
, m_runnables.back()->getTimer() );
printGraph( *m_runnables.back() );
m_runnables.back()->record();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ namespace castor3d
m_aabb = m_scene.getBoundingBox();
m_lightPropagationPassesDesc = doCreatePropagationPasses();
m_runnable = m_graph.compile( m_device.makeContext() );
m_scene.getEngine()->registerTimer( m_runnable->getName() + "/Graph"
, m_runnable->getTimer() );
printGraph( *m_runnable );
m_recordEvent = m_device.renderSystem.getEngine()->postEvent( makeGpuFunctorEvent( GpuEventType::ePreUpload
, [this]( RenderDevice const & device
Expand Down Expand Up @@ -384,8 +386,12 @@ namespace castor3d

if ( m_runnable )
{
m_scene.getEngine()->unregisterTimer( m_runnable->getName() + "/Graph"
, m_runnable->getTimer() );
m_runnable.reset();
m_runnable = m_graph.compile( m_device.makeContext() );
m_scene.getEngine()->registerTimer( m_runnable->getName() + "/Graph"
, m_runnable->getTimer() );
printGraph( *m_runnable );

if ( m_recordEvent )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ namespace castor3d
m_aabb = m_scene.getBoundingBox();
m_lightPropagationPassesDesc = doCreatePropagationPasses();
m_runnable = m_graph.compile( m_device.makeContext() );
m_scene.getEngine()->registerTimer( m_runnable->getName() + "/Graph"
, m_runnable->getTimer() );
printGraph( *m_runnable );
m_recordEvent = m_device.renderSystem.getEngine()->postEvent( makeGpuFunctorEvent( GpuEventType::ePreUpload
, [this]( RenderDevice const & device
Expand Down Expand Up @@ -549,6 +551,8 @@ namespace castor3d

if ( m_runnable )
{
m_scene.getEngine()->unregisterTimer( m_runnable->getName() + "/Graph"
, m_runnable->getTimer() );
m_runnable.reset();
m_runnable = m_graph.compile( m_device.makeContext() );
printGraph( *m_runnable );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ namespace castor3d
, progress ) }
, m_runnable{ m_graph.compile( m_device.makeContext() ) }
{
m_scene.getEngine()->registerTimer( m_runnable->getName() + "/Graph"
, m_runnable->getTimer() );
printGraph( *m_runnable );
m_graph.addOutput( m_firstBounce.wholeViewId
, crg::makeLayoutState( VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL ) );
Expand All @@ -168,6 +170,8 @@ namespace castor3d

Voxelizer::~Voxelizer()
{
m_scene.getEngine()->unregisterTimer( m_runnable->getName() + "/Graph"
, m_runnable->getTimer() );
m_runnable.reset();
m_firstBounce.destroy();
m_secondaryBounce.destroy();
Expand Down
22 changes: 11 additions & 11 deletions source/Core/Castor3D/Render/Node/QueueRenderNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ namespace castor3d
m_billboardIndirectCommands.reset();
m_submeshNIdxIndirectCommands.reset();
m_submeshIdxIndirectCommands.reset();
#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
m_submeshMeshletIndirectCommands.reset();
#endif
}
Expand Down Expand Up @@ -1118,7 +1118,7 @@ namespace castor3d
{
auto & queue = *getOwner();
auto & scene = queue.getCuller().getScene();
#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
auto renderPass = queue.getOwner();
auto origIndirectMshBuffer = m_submeshMeshletIndirectCommands
? m_submeshMeshletIndirectCommands->lock( 0u, ashes::WholeSize, 0u )
Expand All @@ -1144,7 +1144,7 @@ namespace castor3d

for ( auto & culled : bufferIt.second )
{
#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
queuerndnd::fillNodeCommands( *culled.node
, scene
, renderPass->isMeshShading()
Expand Down Expand Up @@ -1175,7 +1175,7 @@ namespace castor3d
{
for ( auto & submeshIt : passIt.second )
{
#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader
queuerndnd::fillNodeCommands( submeshIt.second
, renderPass->isMeshShading()
, indirectMshBuffer
Expand All @@ -1194,7 +1194,7 @@ namespace castor3d
}
}

#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader

if ( m_submeshMeshletIndirectCommands )
{
Expand Down Expand Up @@ -1260,7 +1260,7 @@ namespace castor3d
, 0u
, 0u ) );

#if VK_NV_mesh_shader
#if VK_EXT_mesh_shader || VK_NV_mesh_shader

auto & submeshMshCommands = *m_submeshMeshletIndirectCommands;
auto & submeshIdxCommands = *m_submeshIdxIndirectCommands;
Expand Down Expand Up @@ -1419,13 +1419,13 @@ namespace castor3d
, frontCulled
, m_pipelines );

if ( it == m_pipelines.end() )
if ( pipelineFlags.usesMesh() )
{
if ( pipelineFlags.usesMesh() )
{
node.createMeshletDescriptorSet();
}
node.createMeshletDescriptorSet();
}

if ( it == m_pipelines.end() )
{
auto & result = frontCulled
? renderPass.prepareFrontPipeline( pipelineFlags
, node.getGeometryBuffers( pipelineFlags ).layouts
Expand Down
3 changes: 2 additions & 1 deletion source/Core/Castor3D/Render/Opaque/OpaquePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace castor3d
ShaderFlags OpaquePass::getShaderFlags()const
{
return ShaderFlag::eTangentSpace
| ShaderFlag::eViewSpace
| ShaderFlag::eOpacity
| ShaderFlag::eColour;
}
Expand Down Expand Up @@ -101,7 +102,7 @@ namespace castor3d

ashes::PipelineColorBlendStateCreateInfo OpaquePass::doCreateBlendState( PipelineFlags const & flags )const
{
return RenderNodesPass::createBlendState( flags.colourBlendMode, flags.alphaBlendMode, 6u );
return RenderNodesPass::createBlendState( flags.colourBlendMode, BlendMode::eNoBlend, 4u );
}

ShaderPtr OpaquePass::doGetPixelShaderSource( PipelineFlags const & flags )const
Expand Down
6 changes: 4 additions & 2 deletions source/Core/Castor3D/Render/Overlays/OverlayPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ namespace castor3d
m_counts = {};
auto preparer = m_renderer->beginPrepare( m_device
, m_renderPass.getRenderPass( 0u )
, m_renderPass.getFramebuffer( 0u ) );
, m_renderPass.getFramebuffer( 0u )
, m_graph.getFence() );
preparer.setDrawCounts( m_counts.drawCalls );

if ( m_drawGlobal )
Expand Down Expand Up @@ -137,7 +138,8 @@ namespace castor3d
{
m_renderer->beginPrepare( m_device
, m_renderPass.getRenderPass( 0u )
, m_renderPass.getFramebuffer( 0u ) );
, m_renderPass.getFramebuffer( 0u )
, m_graph.getFence() );
}

m_renderer->registerComputeCommands( context, commandBuffer );
Expand Down
Loading
Loading