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

Debug drawer #632

Merged
merged 12 commits into from
Apr 29, 2024
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
12 changes: 6 additions & 6 deletions include/Core/Castor3D/Buffer/ObjectBufferPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ namespace castor3d
public:
struct ModelBuffers
{
explicit ModelBuffers( GpuPackedBaseBufferUPtr vtx )
: vertex{ castor::move( vtx ) }
explicit ModelBuffers( GpuPackedBaseBufferUPtr idx )
: index{ castor::move( idx ) }
{
}

GpuPackedBaseBufferUPtr vertex;
GpuPackedBaseBufferUPtr index;
};
using BufferArray = castor::Vector< ModelBuffers >;

Expand All @@ -119,15 +119,15 @@ namespace castor3d
/**
*\~english
*\brief Retrieves a GPU buffer with the given size.
*\param[in] vertexCount The wanted buffer element count.
*\param[in] indexCount The wanted buffer element count.
*\return The GPU buffer.
*\~french
*\brief Récupère un tampon GPU avec la taille donnée.
*\param[in] vertexCount Le nombre d'éléments voulu pour le tampon.
*\param[in] indexCount Le nombre d'éléments voulu pour le tampon.
*\return Le tampon GPU.
*/
template< typename IndexT >
ObjectBufferOffset getBuffer( VkDeviceSize vertexCount );
ObjectBufferOffset getBuffer( VkDeviceSize indexCount );
/**
*\~english
*\brief Releases a GPU buffer.
Expand Down
20 changes: 10 additions & 10 deletions include/Core/Castor3D/Buffer/ObjectBufferPool.inl
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ namespace castor3d
ObjectBufferOffset VertexBufferPool::getBuffer( VkDeviceSize vertexCount )
{
ObjectBufferOffset result;
auto size = vertexCount * sizeof( VertexT );
auto size = VkDeviceSize( vertexCount * sizeof( VertexT ) );
auto it = doFindBuffer( size, m_buffers );

if ( it == m_buffers.end() )
{
ModelBuffers buffers{ details::createBaseBuffer< uint8_t >( m_device
, size
, std::max( size, VkDeviceSize( 65536U ) )
, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
, m_debugName + cuT( "Vertex" ) + castor::string::toString( m_buffers.size() )
, 1u ) };
, uint32_t( m_device.properties.limits.minMemoryMapAlignment ) ) };
m_buffers.emplace_back( castor::move( buffers ) );
it = std::next( m_buffers.begin()
, ptrdiff_t( m_buffers.size() - 1u ) );
Expand All @@ -87,27 +87,27 @@ namespace castor3d
//*********************************************************************************************

template< typename IndexT >
ObjectBufferOffset IndexBufferPool::getBuffer( VkDeviceSize vertexCount )
ObjectBufferOffset IndexBufferPool::getBuffer( VkDeviceSize indexCount )
{
ObjectBufferOffset result;
auto size = vertexCount * sizeof(IndexT);
auto size = VkDeviceSize( indexCount * sizeof( IndexT ) );
auto it = doFindBuffer( size, m_buffers );

if ( it == m_buffers.end() )
{
ModelBuffers buffers{ details::createBaseBuffer< uint8_t >( m_device
, size
, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
, std::max( size, VkDeviceSize( 65536U ) )
, VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
, m_debugName + cuT( "Index" ) + castor::string::toString( m_buffers.size() )
, 1u ) };
, uint32_t( m_device.properties.limits.minMemoryMapAlignment ) ) };
m_buffers.emplace_back( castor::move( buffers ) );
it = std::next( m_buffers.begin()
, ptrdiff_t( m_buffers.size() - 1u ) );
}

result.buffers[uint32_t( SubmeshData::eIndex )].buffer = it->vertex.get();
result.buffers[uint32_t( SubmeshData::eIndex )].chunk = it->vertex->allocate( size );
result.buffers[uint32_t( SubmeshData::eIndex )].buffer = it->index.get();
result.buffers[uint32_t( SubmeshData::eIndex )].chunk = it->index->allocate( size );
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace castor3d
C3D_API crg::FramePass const & createAssignLightsToClustersPass( crg::FramePassGroup & graph
, crg::FramePassArray const & previousPasses
, RenderDevice const & device
, CameraUbo const & cameraUbo
, CameraUbo const & mainCameraUbo
, CameraUbo const & clustersCameraUbo
, FrustumClusters & clusters );
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
See LICENSE file in root folder
*/
#ifndef ___C3D_RadixSortLightsMortonCode_H___
#define ___C3D_RadixSortLightsMortonCode_H___
#ifndef ___C3D_BucketSortLightsMortonCode_H___
#define ___C3D_BucketSortLightsMortonCode_H___

#include "ClusteredModule.hpp"

namespace castor3d
{
C3D_API crg::FramePassArray createRadixSortLightsPass( crg::FramePassGroup & graph
C3D_API crg::FramePassArray createBucketSortLightsPass( crg::FramePassGroup & graph
, crg::FramePass const * previousPass
, RenderDevice const & device
, FrustumClusters & clusters );
Expand Down
14 changes: 14 additions & 0 deletions include/Core/Castor3D/Render/Clustered/BuildLightsBVH.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ namespace castor3d
, crg::FramePassArray const & previousPasses
, RenderDevice const & device
, FrustumClusters & clusters );
C3D_API void createDisplayPointLightsBVHProgram( RenderDevice const & device
, FrustumClusters const & clusters
, CameraUbo const & mainCameraUbo
, CameraUbo const & clustersCameraUbo
, ashes::PipelineShaderStageCreateInfoArray & program
, ashes::VkDescriptorSetLayoutBindingArray & bindings
, ashes::WriteDescriptorSetArray & writes );
C3D_API void createDisplaySpotLightsBVHProgram( RenderDevice const & device
, FrustumClusters const & clusters
, CameraUbo const & mainCameraUbo
, CameraUbo const & clustersCameraUbo
, ashes::PipelineShaderStageCreateInfoArray & program
, ashes::VkDescriptorSetLayoutBindingArray & bindings
, ashes::WriteDescriptorSetArray & writes );
}

#endif
5 changes: 2 additions & 3 deletions include/Core/Castor3D/Render/Clustered/ClusteredModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ namespace castor3d
enum class ClusterSplitScheme
{
eExponentialBase = 0,
eExponentialBiased = 1,
eLinear = 2,
eExponentialLinearHybrid = 3,
eLinear = 1,
eExponentialLinearHybrid = 2,
CU_ScopedEnumBounds( eExponentialBase, eExponentialLinearHybrid )
};
C3D_API castor::String getName( ClusterSplitScheme value );
Expand Down
21 changes: 18 additions & 3 deletions include/Core/Castor3D/Render/Clustered/ClustersConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ See LICENSE file in root folder

namespace castor3d
{
enum class ClusterDebugDisplay
{
eNone = 0,
eClustersAABB = 1,
eLightsAABB = 2,
eLightsBVH = 3,
CU_ScopedEnumBounds( eNone, eLightsBVH )
};

struct ClustersConfig
{
C3D_API ClustersConfig();
Expand Down Expand Up @@ -50,12 +59,18 @@ namespace castor3d
//!\~english Enable sorting of clusters lights.
//!\~french Autoriser le tri des sources lumineuses dans les clusters.
castor::GroupChangeTracked< bool > enablePostAssignSort;
//!\~english Locks clusters frustum, for debug purpose.
//!\~french Verrouille le frustum des clusters, pour le débogage.
castor::GroupChangeTracked< bool > lockClustersFrustum;
//!\~english Debug display mode.
//!\~french Mode d'affichage de debug.
castor::GroupChangeTracked< ClusterDebugDisplay > debugDisplay;
//!\~english The clusters Z split scheme.
//!\~french Le mode découpage en Z des clusters.
castor::GroupChangeTracked < ClusterSplitScheme > splitScheme;
//!\~english The biased exponential split scheme bias.
//!\~french Le décalage en mode de découpage exponentiel décalé.
castor::GroupChangeTracked< float > bias;
//!\~english The hybrid split scheme minimal threshold distance.
//!\~french La distance minimale en mode de découpage hybride.
castor::GroupChangeTracked< float > minDistance;
};

C3D_API bool operator==( ClustersConfig const & lhs, ClustersConfig const & rhs );
Expand Down
5 changes: 3 additions & 2 deletions include/Core/Castor3D/Render/Clustered/ClustersMask.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
See LICENSE file in root folder
*/
#ifndef ___C3D_ClustersMask_H___
Expand All @@ -11,7 +11,8 @@ namespace castor3d
crg::FramePass const & createClustersMaskPass( crg::FramePassGroup & graph
, crg::FramePass const & previousPass
, RenderDevice const & device
, CameraUbo const & cameraUbo
, CameraUbo const & mainCameraUbo
, CameraUbo const & clustersCameraUbo
, FrustumClusters & clusters
, RenderTechnique & technique
, RenderNodesPass *& nodesPass );
Expand Down
10 changes: 9 additions & 1 deletion include/Core/Castor3D/Render/Clustered/ComputeClustersAABB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ namespace castor3d
C3D_API crg::FramePass const & createComputeClustersAABBPass( crg::FramePassGroup & graph
, crg::FramePass const * previousPass
, RenderDevice const & device
, CameraUbo const & cameraUbo
, CameraUbo const & mainCameraUbo
, CameraUbo const & clustersCameraUbo
, FrustumClusters const & clusters );
C3D_API void createDisplayClustersAABBProgram( RenderDevice const & device
, FrustumClusters const & clusters
, CameraUbo const & mainCameraUbo
, CameraUbo const & clustersCameraUbo
, ashes::PipelineShaderStageCreateInfoArray & program
, ashes::VkDescriptorSetLayoutBindingArray & bindings
, ashes::WriteDescriptorSetArray & writes );
}

#endif
10 changes: 9 additions & 1 deletion include/Core/Castor3D/Render/Clustered/ComputeLightsAABB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ namespace castor3d
C3D_API crg::FramePass const & createComputeLightsAABBPass( crg::FramePassGroup & graph
, crg::FramePass const * previousPass
, RenderDevice const & device
, CameraUbo const & cameraUbo
, CameraUbo const & mainCameraUbo
, CameraUbo const & clustersCameraUbo
, FrustumClusters const & clusters );
C3D_API void createDisplayLightsAABBProgram( RenderDevice const & device
, FrustumClusters const & clusters
, CameraUbo const & mainCameraUbo
, CameraUbo const & clustersCameraUbo
, ashes::PipelineShaderStageCreateInfoArray & program
, ashes::VkDescriptorSetLayoutBindingArray & bindings
, ashes::WriteDescriptorSetArray & writes );
}

#endif
Loading
Loading