Skip to content

Commit

Permalink
VulkanLayer: Fixed SonarCloud issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonJoker committed Jan 8, 2024
1 parent 0064d18 commit 352f052
Show file tree
Hide file tree
Showing 10 changed files with 373 additions and 402 deletions.
67 changes: 67 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,70 @@ indent_size = 4
tab_width = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.{c++,cc,cpp,cppm,cu,cuh,cxx,fx,h,h++,hh,hlsl,hpp,hxx,inl,ipp,ixx,tlh,tli}]
# Visual C++ Code Style settings
cpp_generate_documentation_comments = doxygen_slash_star
# Visual C++ Formatting settings
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = true
cpp_indent_case_contents = true
cpp_indent_case_labels = false
cpp_indent_case_contents_when_block = true
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_goto_labels = leftmost_column
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = true
cpp_new_line_before_open_brace_namespace = new_line
cpp_new_line_before_open_brace_type = new_line
cpp_new_line_before_open_brace_function = new_line
cpp_new_line_before_open_brace_block = new_line
cpp_new_line_before_open_brace_lambda = new_line
cpp_new_line_scope_braces_on_separate_lines = true
cpp_new_line_close_brace_same_line_empty_type = false
cpp_new_line_close_brace_same_line_empty_function = false
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = true
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = true
cpp_space_between_empty_parameter_list_parentheses = false
cpp_space_after_keywords_in_control_flow_statements = true
cpp_space_within_control_flow_statement_parentheses = true
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = true
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = true
cpp_space_before_block_open_brace = true
cpp_space_between_empty_braces = false
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = true
cpp_space_preserve_in_initializer_list = false
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = true
cpp_space_before_constructor_colon = true
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = true
cpp_space_remove_around_unary_operator = true
cpp_space_around_binary_operator = insert
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = center
cpp_space_around_ternary_operator = insert
cpp_use_unreal_engine_macro_formatting = true
cpp_wrap_preserve_blocks = never
# Visual C++ Inlcude Cleanup settings
cpp_include_cleanup_add_missing_error_tag_type = suggestion
cpp_include_cleanup_remove_unused_error_tag_type = dimmed
69 changes: 23 additions & 46 deletions include/VulkanLayer/ArrayHolder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,29 @@ namespace ast::vk
{
using VecT = std::vector< ValueT >;

inline FixedSizeArrayT()
FixedSizeArrayT()
: VecT{}
{
}

inline FixedSizeArrayT( ValueT const * pbegin
FixedSizeArrayT( ValueT const * pbegin
, ValueT const * pend )
: VecT{ pbegin, pend }
{
}

inline FixedSizeArrayT( size_t count
FixedSizeArrayT( size_t count
, ValueT const & value )
: VecT{}
{
VecT::resize( count, value );
}

inline explicit FixedSizeArrayT( ValueT const & value )
explicit FixedSizeArrayT( ValueT const & value )
: FixedSizeArrayT{ 1u, value }
{
}

inline FixedSizeArrayT( FixedSizeArrayT const & rhs )
: VecT{ rhs }
{
}

inline FixedSizeArrayT( FixedSizeArrayT && rhs )noexcept
: VecT{ std::move( rhs ) }
{
}

inline FixedSizeArrayT & operator=( FixedSizeArrayT const & rhs )
{
VecT::operator=( rhs );
return *this;
}

inline FixedSizeArrayT & operator=( FixedSizeArrayT && rhs )noexcept
{
VecT::operator=( std::move( rhs ) );
return *this;
}

using VecT::empty;
using VecT::data;
using VecT::size;
Expand All @@ -88,14 +66,12 @@ namespace ast::vk
{
using VecT = FixedSizeArrayT< ValueT >;

inline ArrayHolder()
: values{}
, data{}
ArrayHolder()
{
updateData( nullptr, 0u );
}

inline explicit ArrayHolder( DataT pdata )
explicit ArrayHolder( DataT pdata )
: values{ ( ( *getCount( pdata ) && *getPtr( pdata ) )
? VecT{ *getPtr( pdata ), *getPtr( pdata ) + ( *getCount( pdata ) / DivisorT ) }
: ( *getCount( pdata )
Expand All @@ -110,38 +86,37 @@ namespace ast::vk
updateData();
}

inline ArrayHolder( ValueT const * begin
ArrayHolder( ValueT const * begin
, ValueT const * end )
: values{ values, end }
, data{}
: values{ begin, end }
{
updateData();
}

inline ArrayHolder( ArrayHolder const & rhs )
ArrayHolder( ArrayHolder const & rhs )
: values{ rhs.values }
, data{ rhs.data }
{
updateData();
}

inline ArrayHolder( ArrayHolder && rhs )noexcept
ArrayHolder( ArrayHolder && rhs )noexcept
: values{ std::move( rhs.values ) }
, data{ std::move( rhs.data ) }
{
rhs.data = {};
updateData();
}

inline ArrayHolder & operator=( ArrayHolder const & rhs )
ArrayHolder & operator=( ArrayHolder const & rhs )
{
values = rhs.values;
data = rhs.data;
updateData();
return *this;
}

inline ArrayHolder & operator=( ArrayHolder && rhs )noexcept
ArrayHolder & operator=( ArrayHolder && rhs )noexcept
{
values = std::move( rhs.values );
data = std::move( rhs.data );
Expand All @@ -150,36 +125,38 @@ namespace ast::vk
return *this;
}

inline ArrayHolder( ValueT const * pvalues
ArrayHolder( ValueT const * pvalues
, size_t size )
: ArrayHolder{ pvalues, pvalues + size }
{
}

inline explicit ArrayHolder( FixedSizeArrayT< ValueT > const & rhs )
explicit ArrayHolder( FixedSizeArrayT< ValueT > const & rhs )
: ArrayHolder{ rhs.data(), rhs.size() }
{
}

inline explicit ArrayHolder( std::vector< ValueT > const & rhs )
explicit ArrayHolder( std::vector< ValueT > const & rhs )
: ArrayHolder{ rhs.data(), rhs.size() }
{
}

template< size_t SizeT >
inline explicit ArrayHolder( std::array< ValueT, SizeT > const & rhs )
explicit ArrayHolder( std::array< ValueT, SizeT > const & rhs )
: ArrayHolder{ rhs.data(), SizeT }
{
}

template< size_t SizeT >
inline explicit ArrayHolder( ValueT const ( &rhs )[SizeT] )
explicit ArrayHolder( ValueT const ( &rhs )[SizeT] )
: ArrayHolder{ rhs, SizeT }
{
}

VecT values;
DataT data;
~ArrayHolder() = default;

VecT values{};
DataT data{};

private:
void updateData( ValueT * ptr
Expand All @@ -197,14 +174,14 @@ namespace ast::vk

static ValueT ** getPtr( DataT & data )
{
auto buffer = reinterpret_cast< uint8_t * >( &data );
auto buffer = reinterpret_cast< std::byte * >( &data );
buffer += DataOffsetT;
return reinterpret_cast< ValueT ** >( buffer );
}

static CountT * getCount( DataT & data )
{
auto buffer = reinterpret_cast< uint8_t * >( &data );
auto buffer = reinterpret_cast<std::byte* >( &data );
buffer += CountOffsetT;
return reinterpret_cast< CountT * >( buffer );
}
Expand Down
4 changes: 2 additions & 2 deletions include/VulkanLayer/PipelineBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace ast::vk
* \p VK_ERROR_VALIDATION_FAILED if the create info don't match the infos expected by the program.
* \see ast::vk::ProgramPipeline::checkGraphicsPipeline.
*/
VkResult createGraphicsPipeline( VkGraphicsPipelineCreateInfo createInfos
VkResult createGraphicsPipeline( VkGraphicsPipelineCreateInfo const & createInfos
, VkPipeline * result )const;
/**
*\brief
Expand All @@ -63,7 +63,7 @@ namespace ast::vk
* \p VK_ERROR_VALIDATION_FAILED if the create info don't match the infos expected by the program.
* \see ast::vk::ProgramPipeline::checkComputePipeline.
*/
VkResult createComputePipeline( VkComputePipelineCreateInfo createInfos
VkResult createComputePipeline( VkComputePipelineCreateInfo const & createInfos
, VkPipeline * result )const;

VkDevice getDevice()const
Expand Down
28 changes: 15 additions & 13 deletions include/VulkanLayer/PipelineShaderStageCreateInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace ast::vk
SpecializationInfoOpt spec;
VkPipelineShaderStageCreateInfo data;

inline PipelineShaderStageCreateInfo()
PipelineShaderStageCreateInfo()
: spec{ std::nullopt }
, data{ get() }
{
updateData();
}

inline explicit PipelineShaderStageCreateInfo( VkPipelineShaderStageCreateInfo rhs )
explicit PipelineShaderStageCreateInfo( VkPipelineShaderStageCreateInfo rhs )
: spec{ ( rhs.pSpecializationInfo
? SpecializationInfoOpt{ SpecializationInfo{ *rhs.pSpecializationInfo } }
: std::nullopt ) }
Expand All @@ -31,7 +31,7 @@ namespace ast::vk
updateData();
}

inline PipelineShaderStageCreateInfo( VkPipelineShaderStageCreateFlags flags
PipelineShaderStageCreateInfo( VkPipelineShaderStageCreateFlags flags
, VkShaderStageFlagBits stage
, VkShaderModule shaderModule
, SpecializationInfoOpt pspec )
Expand All @@ -41,22 +41,22 @@ namespace ast::vk
updateData();
}

inline PipelineShaderStageCreateInfo( PipelineShaderStageCreateInfo const & rhs )
PipelineShaderStageCreateInfo( PipelineShaderStageCreateInfo const & rhs )
: spec{ rhs.spec }
, data{ rhs.data }
{
updateData();
}

inline PipelineShaderStageCreateInfo( PipelineShaderStageCreateInfo && rhs )noexcept
PipelineShaderStageCreateInfo( PipelineShaderStageCreateInfo && rhs )noexcept
: spec{ std::move( rhs.spec ) }
, data{ std::move( rhs.data ) }
{
rhs.data = get();
updateData();
}

inline PipelineShaderStageCreateInfo & operator=( PipelineShaderStageCreateInfo const & rhs )
PipelineShaderStageCreateInfo & operator=( PipelineShaderStageCreateInfo const & rhs )
{
if ( rhs.spec )
{
Expand All @@ -72,7 +72,7 @@ namespace ast::vk
return *this;
}

inline PipelineShaderStageCreateInfo & operator=( PipelineShaderStageCreateInfo && rhs )noexcept
PipelineShaderStageCreateInfo & operator=( PipelineShaderStageCreateInfo && rhs )noexcept
{
if ( rhs.spec )
{
Expand All @@ -90,27 +90,29 @@ namespace ast::vk
return *this;
}

inline VkPipelineShaderStageCreateInfo * operator->()
~PipelineShaderStageCreateInfo() = default;

VkPipelineShaderStageCreateInfo * operator->()
{
return &data;
}

inline VkPipelineShaderStageCreateInfo const * operator->()const
VkPipelineShaderStageCreateInfo const * operator->()const
{
return &data;
}

inline VkPipelineShaderStageCreateInfo & operator*()
VkPipelineShaderStageCreateInfo & operator*()
{
return data;
}

inline VkPipelineShaderStageCreateInfo const & operator*()const
VkPipelineShaderStageCreateInfo const & operator*()const
{
return data;
}

static inline VkPipelineShaderStageCreateInfo get( VkPipelineShaderStageCreateFlags flags = 0u
static VkPipelineShaderStageCreateInfo get( VkPipelineShaderStageCreateFlags flags = 0u
, VkShaderStageFlagBits stage = VkShaderStageFlagBits::VK_SHADER_STAGE_ALL
, VkShaderModule shaderModule = nullptr )
{
Expand All @@ -127,7 +129,7 @@ namespace ast::vk
}

private:
inline void updateData()
void updateData()
{
if ( spec )
{
Expand Down
Loading

0 comments on commit 352f052

Please sign in to comment.