Skip to content

Commit

Permalink
Ashespp: Fixed SonarCloud issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonJoker committed Jan 11, 2024
1 parent 2da486d commit 1f327f1
Show file tree
Hide file tree
Showing 176 changed files with 2,157 additions and 2,059 deletions.
71 changes: 70 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,76 @@ root = true

[*]
charset = utf-8
end_of_line = LF
end_of_line = CRLF
indent_style = tab
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
31 changes: 31 additions & 0 deletions build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export SRC_DIR=/mnt/z/Projets/C++/Ashes

rm -r ./build-clang
rm -r ./build-gcc
rm -r ./vcpkg-clang
rm -r ./vcpkg-gcc

mkdir build-clang
mkdir build-gcc
mkdir vcpkg-clang
mkdir vcpkg-gcc

cd ./build-clang
CC=clang-15 CXX=clang++-15 cmake $SRC_DIR --preset dev-ninja-debug -DPROJECTS_OUTPUT_DIR=$PWD
ninja -j30

cd ../build-gcc
CC=gcc-12 CXX=g++-12 cmake $SRC_DIR --preset dev-ninja-release -DPROJECTS_OUTPUT_DIR=$PWD
ninja -j30

cd ../vcpkg-clang
CC=clang-15 CXX=clang++-15 cmake $SRC_DIR --preset dev-vcpkg-ninja-release -DPROJECTS_OUTPUT_DIR=$PWD -DCMAKE_TOOLCHAIN_FILE=$SRC_DIR/external/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake .
ninja -j30

cd ../vcpkg-gcc
CC=gcc-12 CXX=g++-12 cmake $SRC_DIR --preset dev-vcpkg-ninja-debug -DPROJECTS_OUTPUT_DIR=$PWD -DCMAKE_TOOLCHAIN_FILE=$SRC_DIR/external/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake .
ninja -j30

cd ..
80 changes: 37 additions & 43 deletions include/ashes/ashes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,64 +14,64 @@ See LICENSE file in root folder.

namespace ashes
{
inline bool operator==( VkOffset2D const & lhs, VkOffset2D const & rhs )
constexpr bool operator==( VkOffset2D const & lhs, VkOffset2D const & rhs )
{
return lhs.x == rhs.x
&& lhs.y == rhs.y;
}

inline bool operator!=( VkOffset2D const & lhs, VkOffset2D const & rhs )
constexpr bool operator!=( VkOffset2D const & lhs, VkOffset2D const & rhs )
{
return !( lhs == rhs );
}

inline bool operator==( VkOffset3D const & lhs, VkOffset3D const & rhs )
constexpr bool operator==( VkOffset3D const & lhs, VkOffset3D const & rhs )
{
return lhs.x == rhs.x
&& lhs.y == rhs.y
&& lhs.z == rhs.z;
}

inline bool operator!=( VkOffset3D const & lhs, VkOffset3D const & rhs )
constexpr bool operator!=( VkOffset3D const & lhs, VkOffset3D const & rhs )
{
return !( lhs == rhs );
}

inline bool operator==( VkExtent2D const & lhs, VkExtent2D const & rhs )
constexpr bool operator==( VkExtent2D const & lhs, VkExtent2D const & rhs )
{
return lhs.width == rhs.width
&& lhs.height == rhs.height;
}

inline bool operator!=( VkExtent2D const & lhs, VkExtent2D const & rhs )
constexpr bool operator!=( VkExtent2D const & lhs, VkExtent2D const & rhs )
{
return !( lhs == rhs );
}

inline bool operator==( VkExtent3D const & lhs, VkExtent3D const & rhs )
constexpr bool operator==( VkExtent3D const & lhs, VkExtent3D const & rhs )
{
return lhs.width == rhs.width
&& lhs.height == rhs.height
&& lhs.depth == rhs.depth;
}

inline bool operator!=( VkExtent3D const & lhs, VkExtent3D const & rhs )
constexpr bool operator!=( VkExtent3D const & lhs, VkExtent3D const & rhs )
{
return !( lhs == rhs );
}

inline bool operator==( VkRect2D const & lhs, VkRect2D const & rhs )
constexpr bool operator==( VkRect2D const & lhs, VkRect2D const & rhs )
{
return lhs.offset == rhs.offset
&& lhs.extent == rhs.extent;
}

inline bool operator!=( VkRect2D const & lhs, VkRect2D const & rhs )
constexpr bool operator!=( VkRect2D const & lhs, VkRect2D const & rhs )
{
return !( lhs == rhs );
}

inline bool operator==( VkViewport const & lhs, VkViewport const & rhs )
constexpr bool operator==( VkViewport const & lhs, VkViewport const & rhs )
{
return lhs.x == rhs.x
&& lhs.y == rhs.y
Expand All @@ -81,12 +81,12 @@ namespace ashes
&& lhs.maxDepth == rhs.maxDepth;
}

inline bool operator!=( VkViewport const & lhs, VkViewport const & rhs )
constexpr bool operator!=( VkViewport const & lhs, VkViewport const & rhs )
{
return !( lhs == rhs );
}

inline bool operator==( VkAttachmentDescription const & lhs, VkAttachmentDescription const & rhs )
constexpr bool operator==( VkAttachmentDescription const & lhs, VkAttachmentDescription const & rhs )
{
return lhs.flags == rhs.flags
&& lhs.format == rhs.format
Expand All @@ -99,34 +99,34 @@ namespace ashes
&& lhs.finalLayout == rhs.finalLayout;
}

inline bool operator!=( VkAttachmentDescription const & lhs, VkAttachmentDescription const & rhs )
constexpr bool operator!=( VkAttachmentDescription const & lhs, VkAttachmentDescription const & rhs )
{
return !( lhs == rhs );
}

inline bool operator==( VkVertexInputAttributeDescription const & lhs, VkVertexInputAttributeDescription const & rhs )
constexpr bool operator==( VkVertexInputAttributeDescription const & lhs, VkVertexInputAttributeDescription const & rhs )
{
return lhs.binding == rhs.binding
&& lhs.format == rhs.format
&& lhs.location == rhs.location
&& lhs.offset == rhs.offset;
}

inline bool operator!=( VkVertexInputAttributeDescription const & lhs, VkVertexInputAttributeDescription const & rhs )
constexpr bool operator!=( VkVertexInputAttributeDescription const & lhs, VkVertexInputAttributeDescription const & rhs )
{
return !( lhs == rhs );
}

inline bool operator==( VkVertexInputBindingDescription const & lhs, VkVertexInputBindingDescription const & rhs )
constexpr bool operator==( VkVertexInputBindingDescription const & lhs, VkVertexInputBindingDescription const & rhs )
{
return lhs.binding == rhs.binding
&& lhs.stride == rhs.stride
&& lhs.inputRate == rhs.inputRate;
}

inline bool operator!=( VkVertexInputBindingDescription const & lhs, VkVertexInputBindingDescription const & rhs )
constexpr bool operator!=( VkVertexInputBindingDescription const & lhs, VkVertexInputBindingDescription const & rhs )
{
return !( lhs == rhs );
return !( lhs== rhs );
}
}

Expand All @@ -137,10 +137,6 @@ namespace ashes
#include "common/Signal.hpp"
#include "common/Format.hpp"

#if defined( MemoryBarrier )
# undef MemoryBarrier
#endif

#include <cstdint>
#include <memory>
#include <string>
Expand All @@ -157,32 +153,32 @@ namespace ashes
using StringArray = std::vector< std::string >;
using CharPtrArray = std::vector< char const * >;

static VkDeviceSize constexpr WholeSize = ~( 0ull );
static uint32_t constexpr RemainingArrayLayers = ~( 0u );
static VkDeviceSize constexpr WholeSize = ~0ULL;
static uint32_t constexpr RemainingArrayLayers = ~0u;

inline constexpr uint32_t getMajor( uint32_t version )
constexpr uint32_t getMajor( uint32_t version )
{
return ( version >> 22u );
}

inline constexpr uint32_t getMinor( uint32_t version )
constexpr uint32_t getMinor( uint32_t version )
{
return ( version >> 12u ) & 0x000003ffu;
}

inline constexpr uint32_t getPatch( uint32_t version )
constexpr uint32_t getPatch( uint32_t version )
{
return version & 0x00000fffu;
}

inline constexpr uint32_t makeVersion( uint32_t major
constexpr uint32_t makeVersion( uint32_t major
, uint32_t minor
, uint32_t patch )
{
return ( ( ( major ) << 22 ) | ( ( minor ) << 12 ) | ( patch ) );
return ( ( major << 22 ) | ( minor << 12 ) | patch );
}

inline uint32_t checkFlag( uint32_t a, uint32_t b )
constexpr uint32_t checkFlag( uint32_t a, uint32_t b )
{
return ( a & b ) == b;
}
Expand Down Expand Up @@ -265,7 +261,7 @@ namespace ashes

for ( uint32_t i = 0u; i < count; ++i )
{
result.push_back( *values );
result.emplace_back( *values );
++values;
}

Expand Down Expand Up @@ -304,7 +300,7 @@ namespace ashes

for ( auto & value : values )
{
result.push_back( value );
result.emplace_back( value );
}

return result;
Expand All @@ -326,14 +322,14 @@ namespace ashes

inline VkClearValue makeClearValue( VkClearColorValue v )
{
VkClearValue result;
VkClearValue result{};
result.color = std::move( v );
return result;
}

inline VkClearValue makeClearValue( VkClearDepthStencilValue v )
{
VkClearValue result;
VkClearValue result{};
result.depthStencil = std::move( v );
return result;
}
Expand Down Expand Up @@ -772,7 +768,7 @@ namespace ashes
{
for ( auto & elem : makeArrayView( ptr, count ) )
{
result.push_back( deepCopy( elem, std::forward< Params && >( params )... ) );
result.push_back( deepCopy( elem, std::forward< Params >( params )... ) );
}
}

Expand All @@ -791,7 +787,7 @@ namespace ashes
{
for ( auto & elem : makeArrayView( ptr, count ) )
{
result.push_back( deepCopy( elem, std::forward< Params && >( params )... ) );
result.push_back( deepCopy( elem, std::forward< Params >( params )... ) );
}
}

Expand All @@ -804,7 +800,7 @@ namespace ashes
, Params && ... params )
{
return ptr
? Optional< Type >{ deepCopy( *ptr, std::forward< Params && >( params )... ) }
? Optional< Type >{ deepCopy( *ptr, std::forward< Params >( params )... ) }
: Optional< Type >{};
}

Expand All @@ -814,12 +810,10 @@ namespace ashes
{
for ( uint32_t i = 0; i < memoryProperties.memoryTypeCount; ++i )
{
if ( ( typeBits & 1 ) == 1 )
if ( ( typeBits & 1 ) == 1
&& ( memoryProperties.memoryTypes[i].propertyFlags & requirements ) == requirements )
{
if ( ( memoryProperties.memoryTypes[i].propertyFlags & requirements ) == requirements )
{
return i;
}
return i;
}

typeBits >>= 1;
Expand Down
Loading

0 comments on commit 1f327f1

Please sign in to comment.