Skip to content

Commit

Permalink
Clusters: Added support for lights morton codes sorting.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonJoker committed May 29, 2023
1 parent 55a66d2 commit bec5c82
Show file tree
Hide file tree
Showing 33 changed files with 1,386 additions and 87 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- name: Checkout submodules
run: |
git submodule update --init -- "CMake"
git submodule update --init --recursive -- "external/Ashes"
git submodule update --init --recursive -- "external/ShaderWriter"
git submodule update --init --recursive -- "external/RenderGraph"
git submodule update --init -- "external/vcpkg"
- name: Setup vcpkg
uses: lukka/run-vcpkg@v10
Expand All @@ -51,7 +54,7 @@ jobs:
shell: bash
working-directory: ${{runner.workspace}}/build-${{ matrix.buildType }}
run: |
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.buildType }} -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/external/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/package/Castor3D -DPROJECTS_WARNINGS_AS_ERRORS=$PROJ_WAE -DPROJECTS_UNITY_BUILD=ON -DPROJECTS_USE_PRECOMPILED_HEADERS=OFF -DSDW_GENERATE_SOURCE=OFF -DCASTOR_BUILD_PLUGINS=ON -DCASTOR_BUILDGRP_INTEROP=OFF -DCASTOR_BUILDGRP_TEST=OFF -DCASTOR_USE_GLSLANG=ON -DCASTOR_DISABLE_DELAYED_INITIALISATION=ON -DASHES_BUILD_RENDERER_OGL=OFF -DCASTOR_BUILDGRP_SAMPLE=OFF -DCASTOR_BUILDGRP_TOOL=OFF -DCASTOR_FORCE_VCPKG_SUBMODULES=ON
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.buildType }} -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/external/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/package/Castor3D -DPROJECTS_WARNINGS_AS_ERRORS=$PROJ_WAE -DPROJECTS_UNITY_BUILD=ON -DPROJECTS_USE_PRECOMPILED_HEADERS=OFF -DSDW_GENERATE_SOURCE=OFF -DCASTOR_BUILD_PLUGINS=ON -DCASTOR_BUILDGRP_INTEROP=OFF -DCASTOR_BUILDGRP_TEST=OFF -DCASTOR_USE_GLSLANG=ON -DCASTOR_DISABLE_DELAYED_INITIALISATION=ON -DASHES_BUILD_RENDERER_OGL=OFF -DCASTOR_BUILDGRP_SAMPLE=OFF -DCASTOR_BUILDGRP_TOOL=OFF
- name: Build
if: steps.configure.conclusion == 'success'
id: build
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 c5bdda793361901762d273b76f5a2355f1ab5411
REF e9f6b3243095d832f409e15fbafff4f73af6e401
HEAD_REF master
SHA512 c9549ebb6109d6a3a5673b4180fe6f9491d14f8666714451b3bc6b0cd8b6d4a57c79d5122b4729af0e98580418ff0089700ec71c8882744a342e58b4d19be0e3
SHA512 3609da52a6f5c5c213fcc56416cfc714403d0bc80742540990cab2973b2ee3e41e9629b04f379db84c2194acff6cecf11c4e86d4167ca78aa8606a85cbcaa433
)

vcpkg_from_github(OUT_SOURCE_PATH CMAKE_SOURCE_PATH
REPO DragonJoker/CMakeUtils
REF 89a4c8fd4f0a464403676b6b1f1c5d178f6255b3
REF 3818effff171f863d0c23e6fbbf79911f03cc6d3
HEAD_REF master
SHA512 98c46a563f2e4a28d9c91f4f255c500118dd0c66a4422d42969bdcc16c1493581db45b709fc3167e1ced8fa628d51880cb459df0d6b3dc013b945f66597ec768
SHA512 3a13b371adf24f530fdef6005d3a9105185eca131c9b8aba68615a593f76d6aac2c3c7f0ecf6ce430e2b854afca4abd99f1400a1e6665478c9daa34a8dac6f5b
)

get_filename_component(SRC_PATH "${CMAKE_SOURCE_PATH}" DIRECTORY)
Expand Down
8 changes: 4 additions & 4 deletions data/vcpkg/ports/shaderwriter/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/ShaderWriter
REF 42aa67fda5b2a72f21c0fcc9f51c2ed2838e1360
REF 6aa2e9bb7f51c80df3ebf5f3d7ea5936d87e671f
HEAD_REF development
SHA512 37826bf50ae09e2e1eea68e21ee2dcf4461b56c3833cc0d19b4005411bfbc81e5bcce2586e63359c6b5226b92d3c71d4d9129319fa85df57013e0fd025538e60
SHA512 04c9973c513ff4b912283d4db93e255455e2ed909fa1ebfc09759d39e79bd7e156abf65f5686a8ffa311f7441b9c802c8a346ec41b02eb4e42564b53431042b8
)

vcpkg_from_github(OUT_SOURCE_PATH CMAKE_SOURCE_PATH
REPO DragonJoker/CMakeUtils
REF 89a4c8fd4f0a464403676b6b1f1c5d178f6255b3
REF 3818effff171f863d0c23e6fbbf79911f03cc6d3
HEAD_REF master
SHA512 98c46a563f2e4a28d9c91f4f255c500118dd0c66a4422d42969bdcc16c1493581db45b709fc3167e1ced8fa628d51880cb459df0d6b3dc013b945f66597ec768
SHA512 3a13b371adf24f530fdef6005d3a9105185eca131c9b8aba68615a593f76d6aac2c3c7f0ecf6ce430e2b854afca4abd99f1400a1e6665478c9daa34a8dac6f5b
)

file(REMOVE_RECURSE "${SOURCE_PATH}/CMake")
Expand Down
2 changes: 1 addition & 1 deletion external/vcpkg
Submodule vcpkg updated 2946 files
30 changes: 30 additions & 0 deletions include/Core/Castor3D/Buffer/GpuBufferOffset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ See LICENSE file in root folder

namespace castor3d
{
C3D_API void createUniformPassBinding( crg::FramePass & pass
, uint32_t binding
, std::string const & name
, std::vector< ashes::BufferBase const * > buffers
, VkDeviceSize offset
, VkDeviceSize size );
C3D_API void createInputStoragePassBinding( crg::FramePass & pass
, uint32_t binding
, std::string const & name
, std::vector< ashes::BufferBase const * > buffers
, VkDeviceSize offset
, VkDeviceSize size );
C3D_API void createInOutStoragePassBinding( crg::FramePass & pass
, uint32_t binding
, std::string const & name
, std::vector< ashes::BufferBase const * > buffers
, VkDeviceSize offset
, VkDeviceSize size );
C3D_API void createOutputStoragePassBinding( crg::FramePass & pass
, uint32_t binding
, std::string const & name
, std::vector< ashes::BufferBase const * > buffers
, VkDeviceSize offset
, VkDeviceSize size );
C3D_API void createClearableOutputStorageBinding( crg::FramePass & pass
, uint32_t binding
, std::string const & name
, std::vector< ashes::BufferBase const * > buffers
, VkDeviceSize offset
, VkDeviceSize size );
C3D_API void createUniformPassBinding( crg::FramePass & pass
, uint32_t binding
, std::string const & name
Expand Down
2 changes: 1 addition & 1 deletion include/Core/Castor3D/Render/Clustered/BuildLightsBVH.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ See LICENSE file in root folder
namespace castor3d
{
C3D_API crg::FramePass const & createBuildLightsBVHPass( crg::FramePassGroup & graph
, crg::FramePass const * previousPass
, crg::FramePassArray const & previousPasses
, RenderDevice const & device
, CameraUbo const & cameraUbo
, FrustumClusters & clusters );
Expand Down
2 changes: 2 additions & 0 deletions include/Core/Castor3D/Render/Clustered/ClusteredModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ namespace castor3d
using OnClustersBuffersChanged = castor::SignalT< ClustersBuffersChangedFunction >;
using OnClustersBuffersChangedConnection = castor::ConnectionT< ClustersBuffersChangedFunction >;

C3D_API u32 getLightsMortonCodeChunkCount( u32 lightCount );

//@}
//@}
}
Expand Down
44 changes: 33 additions & 11 deletions include/Core/Castor3D/Render/Clustered/FrustumClusters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,24 @@ namespace castor3d
return *m_spotBVHBuffer;
}

void swapLightMortonIndicesIO()
void initPointLightMortonIndicesIO()noexcept
{
m_lightMortonIndicesInput = 1u - m_lightMortonIndicesInput;
m_pointLightMortonIndicesInput = 1u;
}

void initSpotLightMortonIndicesIO()noexcept
{
m_spotLightMortonIndicesInput = 1u;
}

void swapPointLightMortonIndicesIO()noexcept
{
m_pointLightMortonIndicesInput = 1u - m_pointLightMortonIndicesInput;
}

void swapSpotLightMortonIndicesIO()noexcept
{
m_spotLightMortonIndicesInput = 1u - m_spotLightMortonIndicesInput;
}

ashes::BufferBase & getPointLightIndicesBuffer( uint32_t index )const noexcept
Expand All @@ -167,42 +182,47 @@ namespace castor3d

ashes::BufferBase & getInputPointLightIndicesBuffer()const noexcept
{
return getPointLightIndicesBuffer( m_lightMortonIndicesInput );
return getPointLightIndicesBuffer( m_pointLightMortonIndicesInput );
}

ashes::BufferBase & getInputSpotLightIndicesBuffer()const noexcept
{
return getSpotLightIndicesBuffer( m_lightMortonIndicesInput );
return getSpotLightIndicesBuffer( m_spotLightMortonIndicesInput );
}

ashes::BufferBase & getOutputPointLightIndicesBuffer()const noexcept
{
return getPointLightIndicesBuffer( 1u - m_lightMortonIndicesInput );
return getPointLightIndicesBuffer( 1u - m_pointLightMortonIndicesInput );
}

ashes::BufferBase & getOutputSpotLightIndicesBuffer()const noexcept
{
return getSpotLightIndicesBuffer( 1u - m_lightMortonIndicesInput );
return getSpotLightIndicesBuffer( 1u - m_spotLightMortonIndicesInput );
}

ashes::BufferBase & getInputPointLightMortonCodesBuffer()const noexcept
{
return getPointLightMortonCodesBuffer( m_lightMortonIndicesInput );
return getPointLightMortonCodesBuffer( m_pointLightMortonIndicesInput );
}

ashes::BufferBase & getInputSpotLightMortonCodesBuffer()const noexcept
{
return getSpotLightMortonCodesBuffer( m_lightMortonIndicesInput );
return getSpotLightMortonCodesBuffer( m_spotLightMortonIndicesInput );
}

ashes::BufferBase & getOutputPointLightMortonCodesBuffer()const noexcept
{
return getPointLightMortonCodesBuffer( 1u - m_lightMortonIndicesInput );
return getPointLightMortonCodesBuffer( 1u - m_pointLightMortonIndicesInput );
}

ashes::BufferBase & getOutputSpotLightMortonCodesBuffer()const noexcept
{
return getSpotLightMortonCodesBuffer( 1u - m_lightMortonIndicesInput );
return getSpotLightMortonCodesBuffer( 1u - m_spotLightMortonIndicesInput );
}

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

auto & getCamera()const noexcept
Expand All @@ -229,7 +249,8 @@ namespace castor3d
bool m_clustersDirty{ true };
bool m_lightsDirty{ true };
bool m_first{ true };
uint32_t m_lightMortonIndicesInput{ 1u };
uint32_t m_pointLightMortonIndicesInput{ 1u };
uint32_t m_spotLightMortonIndicesInput{ 1u };
castor::GroupChangeTracked< castor::Point3ui > m_dimensions;
castor::GroupChangeTracked< uint32_t > m_clusterSize;
castor::GroupChangeTracked< castor::Matrix4x4f > m_cameraProjection;
Expand All @@ -242,6 +263,7 @@ namespace castor3d
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;
Expand Down
18 changes: 18 additions & 0 deletions include/Core/Castor3D/Render/Clustered/SortLightsMortonCode.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
See LICENSE file in root folder
*/
#ifndef ___C3D_SortLightsMortonCode_H___
#define ___C3D_SortLightsMortonCode_H___

#include "ClusteredModule.hpp"

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

#endif
2 changes: 1 addition & 1 deletion include/Core/CastorUtils/Design/DataHolder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace castor
public:
DataHolderT()noexcept = default;

DataHolderT( Data d )noexcept
explicit DataHolderT( Data d )noexcept
: m_data{ std::move( d ) }
{
}
Expand Down
1 change: 0 additions & 1 deletion include/Core/CastorUtils/Exception/Assertion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ See LICENSE file in root folder
namespace castor
{
CU_API void cuLogError( char const * const description );
[[ noreturn ]]
CU_API void cuFailure( char const * const description );
}

Expand Down
Loading

0 comments on commit bec5c82

Please sign in to comment.