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

Clusters: Added support for scene samples clustering. #590

Merged
merged 1 commit into from
Jun 1, 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/ashes/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ vcpkg_from_github(
vcpkg_from_github(
OUT_SOURCE_PATH CMAKE_SOURCE_PATH
REPO DragonJoker/CMakeUtils
REF 89a4c8fd4f0a464403676b6b1f1c5d178f6255b3
REF 4e0292ed50d76dab5fc8c81840ae0e021dc60c2a
HEAD_REF master
SHA512 98c46a563f2e4a28d9c91f4f255c500118dd0c66a4422d42969bdcc16c1493581db45b709fc3167e1ced8fa628d51880cb459df0d6b3dc013b945f66597ec768
SHA512 c79c6a5ef2e059b56d4de20cc73e74386bf8b6acea2f6b76fd9949a6a2760f82302c90419e4a753f50c30d01cc4f3a039e04b585f5c0d4461cce3464d9fb9c95
)

file(REMOVE_RECURSE "${SOURCE_PATH}/CMake")
Expand Down
6 changes: 3 additions & 3 deletions data/vcpkg/ports/castor3d/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ vcpkg_from_github(
REPO DragonJoker/Castor3D
REF 31c7acf35e4c5e5605df591fee61b989dc4d4d9d
HEAD_REF master
SHA512 203dbd28c32e02e714726460cab5a6477bec03f5a63e08001074cd1fc8342b6d64b91369cdf3a6d55d6758991c59bce691c377f3c82aa866cd09ecea8f6a518a
SHA512 0
)

vcpkg_from_github(OUT_SOURCE_PATH CMAKE_SOURCE_PATH
REPO DragonJoker/CMakeUtils
REF 7d355194fa795c437ce970cecf00e23ae10fc686
REF 4e0292ed50d76dab5fc8c81840ae0e021dc60c2a
HEAD_REF master
SHA512 ca25b19bdeb3e8fda7abc32f8548731f0ba1cd09889a70f6f287ad76d2fdfa0fedbb7f6f65b26d356ea51543bed8926c6bb463f8e8461b7d51d3b7b33134374c
SHA512 c79c6a5ef2e059b56d4de20cc73e74386bf8b6acea2f6b76fd9949a6a2760f82302c90419e4a753f50c30d01cc4f3a039e04b585f5c0d4461cce3464d9fb9c95
)

file(REMOVE_RECURSE "${SOURCE_PATH}/CMake")
Expand Down
8 changes: 4 additions & 4 deletions data/vcpkg/ports/rendergraph/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
vcpkg_from_github(OUT_SOURCE_PATH SOURCE_PATH
REPO DragonJoker/RenderGraph
REF e9f6b3243095d832f409e15fbafff4f73af6e401
REF 1223fb79f141c62cda27406bab53d06cb3dc588a
HEAD_REF master
SHA512 3609da52a6f5c5c213fcc56416cfc714403d0bc80742540990cab2973b2ee3e41e9629b04f379db84c2194acff6cecf11c4e86d4167ca78aa8606a85cbcaa433
SHA512 82503225e44c9bd956b326c0eb42e5983bcb52a879f0aa23eb8bd2ba8cd214ead26e302c294609e0d0b73cc48d2eb4ca896cb806a5ce5146b220f1d208b813f1
)

vcpkg_from_github(OUT_SOURCE_PATH CMAKE_SOURCE_PATH
REPO DragonJoker/CMakeUtils
REF 3818effff171f863d0c23e6fbbf79911f03cc6d3
REF 4e0292ed50d76dab5fc8c81840ae0e021dc60c2a
HEAD_REF master
SHA512 3a13b371adf24f530fdef6005d3a9105185eca131c9b8aba68615a593f76d6aac2c3c7f0ecf6ce430e2b854afca4abd99f1400a1e6665478c9daa34a8dac6f5b
SHA512 c79c6a5ef2e059b56d4de20cc73e74386bf8b6acea2f6b76fd9949a6a2760f82302c90419e4a753f50c30d01cc4f3a039e04b585f5c0d4461cce3464d9fb9c95
)

get_filename_component(SRC_PATH "${CMAKE_SOURCE_PATH}" DIRECTORY)
Expand Down
4 changes: 2 additions & 2 deletions data/vcpkg/ports/shaderwriter/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ vcpkg_from_github(OUT_SOURCE_PATH SOURCE_PATH

vcpkg_from_github(OUT_SOURCE_PATH CMAKE_SOURCE_PATH
REPO DragonJoker/CMakeUtils
REF 3818effff171f863d0c23e6fbbf79911f03cc6d3
REF 4e0292ed50d76dab5fc8c81840ae0e021dc60c2a
HEAD_REF master
SHA512 3a13b371adf24f530fdef6005d3a9105185eca131c9b8aba68615a593f76d6aac2c3c7f0ecf6ce430e2b854afca4abd99f1400a1e6665478c9daa34a8dac6f5b
SHA512 c79c6a5ef2e059b56d4de20cc73e74386bf8b6acea2f6b76fd9949a6a2760f82302c90419e4a753f50c30d01cc4f3a039e04b585f5c0d4461cce3464d9fb9c95
)

file(REMOVE_RECURSE "${SOURCE_PATH}/CMake")
Expand Down
2 changes: 1 addition & 1 deletion external/vcpkg
Submodule vcpkg updated 62 files
+3 −2 ports/azure-c-shared-utility/vcpkg.json
+2 −2 ports/bdwgc/portfile.cmake
+1 −1 ports/bdwgc/vcpkg.json
+4 −4 ports/blend2d/portfile.cmake
+2 −3 ports/blend2d/vcpkg.json
+21 −0 ports/cminpack/portfile.cmake
+1 −1 ports/cminpack/vcpkg.json
+6 −1 ports/ftxui/portfile.cmake
+1 −1 ports/ftxui/vcpkg.json
+1 −1 ports/jsonifier/portfile.cmake
+1 −1 ports/jsonifier/vcpkg.json
+12 −12 ports/libgit2/fix-configcmake.patch
+5 −4 ports/libgit2/portfile.cmake
+1 −2 ports/libgit2/vcpkg.json
+6 −8 ports/libheif/gdk-pixbuf.patch
+1 −1 ports/libheif/portfile.cmake
+1 −2 ports/libheif/vcpkg.json
+1 −1 ports/liblsl/portfile.cmake
+1 −2 ports/liblsl/vcpkg.json
+2 −2 ports/libtcod/portfile.cmake
+1 −1 ports/libtcod/vcpkg.json
+26 −0 ports/lightningscanner/portfile.cmake
+4 −0 ports/lightningscanner/usage
+18 −0 ports/lightningscanner/vcpkg.json
+1 −1 ports/opencl/portfile.cmake
+6 −5 ports/opencl/vcpkg-cmake-wrapper.cmake
+1 −1 ports/opencl/vcpkg.json
+22 −25 ports/podofo/portfile.cmake
+24 −4 ports/podofo/vcpkg.json
+1 −1 ports/quill/portfile.cmake
+1 −1 ports/quill/vcpkg.json
+0 −0 ports/sdl1/SDL1_2017.sln.in
+11 −11 ports/sdl1/portfile.cmake
+1 −1 ports/sdl1/vcpkg.json
+24 −0 ports/sleef/portfile.cmake
+1 −1 ports/sleef/vcpkg.json
+0 −16 ports/sqlitecpp/0001-unofficial-sqlite3-and-sqlcipher.patch
+12 −0 ports/sqlitecpp/add_runtime_destination.patch
+28 −11 ports/sqlitecpp/fix_dependency.patch
+3 −6 ports/sqlitecpp/portfile.cmake
+1 −2 ports/sqlitecpp/vcpkg.json
+6 −0 ports/tbb/portfile.cmake
+12 −1 ports/tbb/vcpkg.json
+5 −0 versions/a-/azure-c-shared-utility.json
+5 −0 versions/b-/bdwgc.json
+5 −0 versions/b-/blend2d.json
+26 −22 versions/baseline.json
+5 −0 versions/c-/cminpack.json
+5 −0 versions/f-/ftxui.json
+5 −0 versions/j-/jsonifier.json
+5 −0 versions/l-/libgit2.json
+5 −0 versions/l-/libheif.json
+5 −0 versions/l-/liblsl.json
+5 −0 versions/l-/libtcod.json
+9 −0 versions/l-/lightningscanner.json
+5 −0 versions/o-/opencl.json
+5 −0 versions/p-/podofo.json
+5 −0 versions/q-/quill.json
+5 −0 versions/s-/sdl1.json
+5 −0 versions/s-/sleef.json
+5 −0 versions/s-/sqlitecpp.json
+5 −0 versions/t-/tbb.json
16 changes: 10 additions & 6 deletions include/Core/Castor3D/Cache/LightCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,22 @@ namespace castor3d
C3D_API ashes::WriteDescriptorSet getBinding( uint32_t binding
, VkDeviceSize offset
, VkDeviceSize size )const;
/**
*\~english
*\param[in] type The light type.
*\return The number of light sources of the given type, in the buffer.
*\~french
*\brief Crée le descriptor write pour le buffer de sources lumineuses.
*\param[in] type Le type de lumière.
*\return Le nombre de sources lumineuses du type donné, dans le buffer.
*/
C3D_API uint32_t getLightsBufferCount( LightType type )const noexcept;

uint32_t getLightsCount( LightType type )const
{
return uint32_t( getLights( type ).size() );
}

GpuBufferOffsetT< castor::Point2ui > getLightsIndexOffset()const noexcept
{
return m_lightsIndexOffset;
}

bool isDirty()const noexcept
{
return m_dirty || !m_dirtyLights.empty();
Expand All @@ -171,7 +176,6 @@ namespace castor3d
private:
LightsRefArray m_dirtyLights;
LightBufferUPtr m_lightBuffer;
GpuBufferOffsetT< castor::Point2ui > m_lightsIndexOffset;
std::vector< Light * > m_pendingLights;
bool m_dirty{ true };
};
Expand Down
6 changes: 2 additions & 4 deletions include/Core/Castor3D/Limits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace castor3d
* Directional Light Shadows.
*/
//@{
static uint32_t constexpr ShadowMapDirectionalTextureSize = 2048u;
static uint32_t constexpr ShadowMapDirectionalTextureSize = 2'048u;
static uint32_t constexpr MaxDirectionalCascadesCount = 6u;
//@}
/**
Expand Down Expand Up @@ -123,7 +123,6 @@ namespace castor3d
// Pass Buffer.
static uint32_t constexpr MaxMaterialsCount = 2'048u;
static uint32_t constexpr MaxSssProfilesCount = 128u;
static int32_t constexpr MaxMaterialComponentsCount = 8;
// Texture Configuration Buffer.
static uint32_t constexpr MaxTextureConfigurationCount = 4'096u;
// Texture Animation Buffer.
Expand All @@ -147,12 +146,11 @@ namespace castor3d
*/
//@{
// The number of vec4s in the random buffer.
static uint32_t constexpr RandomDataCount = 1024u;
static uint32_t constexpr RandomDataCount = 1'024u;
// Max overlay count per buffer
static uint32_t constexpr MaxOverlaysPerBuffer = 65'536u;
// Max counts for text overlays
static uint32_t constexpr MaxCharsPerOverlay = 1'024u;
static uint32_t constexpr MaxLinesPerOverlay = 1'024u;
// Max counts for text overlays text buffer
static uint32_t constexpr MaxCharsPerBuffer = 65'536u;
static uint32_t constexpr MaxWordsPerBuffer = 16'384u;
Expand Down
12 changes: 10 additions & 2 deletions include/Core/Castor3D/Miscellaneous/makeVkType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ See LICENSE file in root folder

#include "MiscellaneousModule.hpp"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"

namespace castor3d
{
template< typename AshesType >
Expand Down Expand Up @@ -884,22 +887,27 @@ namespace castor3d
template<> struct VkStructTraits< VkVideoEncodeRateControlInfoKHR >{ static VkStructureType constexpr value = VK_STRUCTURE_TYPE_VIDEO_ENCODE_RATE_CONTROL_INFO_KHR; };
#endif

template< typename VkStructT >
static VkStructureType constexpr vkStructureTypeV = VkStructTraits< VkStructT >::value;

template< typename VkStructT, typename ... ParamsT >
inline VkStructT makeVkStructPNext( void * next
, ParamsT && ... params )
{
return VkStructT{ VkStructTraits< VkStructT >::value
return VkStructT{ vkStructureTypeV< VkStructT >
, next
, std::forward< ParamsT >( params )... };
}

template< typename VkStructT, typename ... ParamsT >
inline VkStructT makeVkStruct( ParamsT && ... params )
{
return VkStructT{ VkStructTraits< VkStructT >::value
return VkStructT{ vkStructureTypeV< VkStructT >
, nullptr
, std::forward< ParamsT >( params )... };
}
}

#pragma GCC diagnostic pop

#endif
20 changes: 20 additions & 0 deletions include/Core/Castor3D/Render/Clustered/ClustersMask.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
See LICENSE file in root folder
*/
#ifndef ___C3D_ClustersMask_H___
#define ___C3D_ClustersMask_H___

#include "ClusteredModule.hpp"

namespace castor3d
{
crg::FramePass const & createClustersMaskPass( crg::FramePassGroup & graph
, crg::FramePass const & previousPass
, RenderDevice const & device
, CameraUbo const & cameraUbo
, FrustumClusters & clusters
, RenderTechnique & technique
, RenderNodesPass *& nodesPass );
}

#endif
18 changes: 18 additions & 0 deletions include/Core/Castor3D/Render/Clustered/FindUniqueClusters.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
See LICENSE file in root folder
*/
#ifndef ___C3D_FindUniqueClusters_H___
#define ___C3D_FindUniqueClusters_H___

#include "ClusteredModule.hpp"

namespace castor3d
{
C3D_API crg::FramePass const & createFindUniqueClustersPass( crg::FramePassGroup & graph
, crg::FramePass const & previousPass
, RenderDevice const & device
, CameraUbo const & cameraUbo
, FrustumClusters & clusters );
}

#endif
62 changes: 41 additions & 21 deletions include/Core/Castor3D/Render/Clustered/FrustumClusters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ namespace castor3d
*/
C3D_API crg::FramePass const & createFramePasses( crg::FramePassGroup & graph
, crg::FramePass const * previousPass
, CameraUbo const & cameraUbo );
, RenderTechnique & technique
, CameraUbo const & cameraUbo
, RenderNodesPass *& nodesPass );
/**
*\~english
*\brief Compute the number of nodes for given BVH level.
Expand Down Expand Up @@ -124,20 +126,17 @@ namespace castor3d

auto & getLightsAABBBuffer()const noexcept
{
CU_Require( m_lightsAABBBuffer );
return *m_lightsAABBBuffer;
return m_lightsAABBBuffer->getBuffer();
}

auto & getPointLightBVHBuffer()const noexcept
{
CU_Require( m_pointBVHBuffer );
return *m_pointBVHBuffer;
return m_pointBVHBuffer->getBuffer();
}

auto & getSpotLightBVHBuffer()const noexcept
{
CU_Require( m_spotBVHBuffer );
return *m_spotBVHBuffer;
return m_spotBVHBuffer->getBuffer();
}

void initPointLightMortonIndicesIO()noexcept
Expand All @@ -162,22 +161,22 @@ namespace castor3d

ashes::BufferBase & getPointLightIndicesBuffer( uint32_t index )const noexcept
{
return *m_pointIndicesBuffers[index];
return m_pointIndicesBuffers[index]->getBuffer();
}

ashes::BufferBase & getSpotLightIndicesBuffer( uint32_t index )const noexcept
{
return *m_spotIndicesBuffers[index];
return m_spotIndicesBuffers[index]->getBuffer();
}

ashes::BufferBase & getPointLightMortonCodesBuffer( uint32_t index )const noexcept
{
return *m_pointMortonCodesBuffers[index];
return m_pointMortonCodesBuffers[index]->getBuffer();
}

ashes::BufferBase & getSpotLightMortonCodesBuffer( uint32_t index )const noexcept
{
return *m_spotMortonCodesBuffers[index];
return m_spotMortonCodesBuffers[index]->getBuffer();
}

ashes::BufferBase & getInputPointLightIndicesBuffer()const noexcept
Expand Down Expand Up @@ -222,7 +221,22 @@ namespace castor3d

ashes::BufferBase & getMergePathPartitionsBuffer()const noexcept
{
return *m_mergePathPartitionsBuffer;
return m_mergePathPartitionsBuffer->getBuffer();
}

ashes::BufferBase & getClusterFlagsBuffer()const noexcept
{
return *m_clusterFlags;
}

ashes::BufferBase & getUniqueClustersBuffer()const noexcept
{
return *m_uniqueClusters;
}

ashes::BufferBase & getClustersIndirectBuffer()const noexcept
{
return m_clustersIndirect->getBuffer();
}

auto & getCamera()const noexcept
Expand All @@ -237,7 +251,6 @@ namespace castor3d
{
castor::Point4f min;
castor::Point4f max;
castor::Point4f sphere;
};

private:
Expand All @@ -257,19 +270,26 @@ namespace castor3d
castor::GroupChangeTracked< castor::Matrix4x4f > m_cameraView;
castor::GroupChangeTracked< float > m_nearK;
ClustersUbo m_clustersUbo;
ashes::BufferPtr< VkDispatchIndirectCommand > m_clustersIndirect;

// Fixed size buffers, related to lights
ashes::BufferPtr< AABB > m_lightsAABBBuffer;
std::array< ashes::BufferPtr< u32 >, 2u > m_pointMortonCodesBuffers;
std::array< ashes::BufferPtr< u32 >, 2u > m_spotMortonCodesBuffers;
std::array< ashes::BufferPtr< u32 >, 2u > m_pointIndicesBuffers;
std::array< ashes::BufferPtr< u32 >, 2u > m_spotIndicesBuffers;
ashes::BufferPtr< AABB > m_pointBVHBuffer;
ashes::BufferPtr< AABB > m_spotBVHBuffer;
ashes::BufferPtr< s32 > m_mergePathPartitionsBuffer;

// Variable size buffers, related to frustum dimensions
ashes::BufferBasePtr m_aabbBuffer;
ashes::BufferBasePtr m_pointLightClusterGridBuffer;
ashes::BufferBasePtr m_spotLightClusterGridBuffer;
ashes::BufferBasePtr m_pointLightClusterIndexBuffer;
ashes::BufferBasePtr m_spotLightClusterIndexBuffer;
ashes::BufferBasePtr m_lightsAABBBuffer;
ashes::BufferBasePtr m_mergePathPartitionsBuffer;
std::array< ashes::BufferBasePtr, 2u > m_pointMortonCodesBuffers;
std::array< ashes::BufferBasePtr, 2u > m_spotMortonCodesBuffers;
std::array< ashes::BufferBasePtr, 2u > m_pointIndicesBuffers;
std::array< ashes::BufferBasePtr, 2u > m_spotIndicesBuffers;
ashes::BufferBasePtr m_pointBVHBuffer;
ashes::BufferBasePtr m_spotBVHBuffer;
ashes::BufferBasePtr m_clusterFlags;
ashes::BufferBasePtr m_uniqueClusters;
std::vector< ashes::BufferBasePtr > m_toDelete;
};
}
Expand Down
8 changes: 2 additions & 6 deletions include/Core/Castor3D/Render/Prepass/DepthPass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,10 @@ namespace castor3d
ProgramFlags doAdjustProgramFlags( ProgramFlags flags )const override;
SceneFlags doAdjustSceneFlags( SceneFlags flags )const override;
void doFillAdditionalBindings( PipelineFlags const & flags
, ashes::VkDescriptorSetLayoutBindingArray & bindings )const override
{
}
, ashes::VkDescriptorSetLayoutBindingArray & bindings )const override;
void doFillAdditionalDescriptor( PipelineFlags const & flags
, ashes::WriteDescriptorSetArray & descriptorWrites
, ShadowMapLightTypeArray const & shadowMaps )override
{
}
, ShadowMapLightTypeArray const & shadowMaps )override;
ashes::PipelineDepthStencilStateCreateInfo doCreateDepthStencilState( PipelineFlags const & flags )const override;
ashes::PipelineColorBlendStateCreateInfo doCreateBlendState( PipelineFlags const & flags )const override;
ShaderPtr doGetGeometryShaderSource( PipelineFlags const & flags )const override;
Expand Down
1 change: 1 addition & 0 deletions include/Core/Castor3D/Render/RenderTechnique.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ namespace castor3d
PrepassRendering m_prepass;
crg::FramePass const * m_lastDepthPass{};
crg::FramePass const * m_depthRangePass{};
RenderNodesPass * m_clustersFlagsPass{};
crg::FramePass const * m_clustersLastPass{};
BackgroundRendererUPtr m_background{};
OpaqueRendering m_opaque;
Expand Down
5 changes: 5 additions & 0 deletions include/Core/Castor3D/Scene/Light/Light.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ namespace castor3d
return m_category->getLightType();
}

uint32_t getComponentCount()const
{
return m_category->getComponentCount();
}

bool isEnabled()const
{
return m_enabled;
Expand Down
Loading