From 1f31b2a2a3fee63ab77ffe1d9faed2e688061801 Mon Sep 17 00:00:00 2001 From: kj16609 Date: Mon, 26 Feb 2024 22:52:34 -0500 Subject: [PATCH] Fixes a shit ton of warnings --- cmake_modules/gcc.cmake | 4 +-- src/engine/EngineContext.cpp | 35 +++++++++++++------ src/engine/KeyboardMovementController.cpp | 10 +++--- src/engine/Renderer.cpp | 2 +- src/engine/SwapChain.cpp | 12 ++++--- src/engine/buffers/Buffer.cpp | 4 +-- .../buffers/BufferSuballocationHandle.cpp | 4 +-- .../buffers/UniqueFrameSuballocation.hpp | 8 ++--- src/engine/debug/drawers.cpp | 5 ++- src/engine/debug/drawers.hpp | 4 +-- src/engine/descriptors/DescriptorSet.hpp | 3 +- src/engine/image/Image.hpp | 4 +-- src/engine/image/ImageView.hpp | 2 +- src/engine/image/Sampler.hpp | 2 +- src/engine/math/taitBryanMatrix.cpp | 2 ++ src/engine/math/taitBryanMatrix.hpp | 2 +- src/engine/model/BoundingBox.cpp | 3 +- src/engine/model/BoundingBox.hpp | 4 +-- src/engine/model/Model.cpp | 2 +- src/engine/model/gltfLoading.cpp | 10 +++--- src/engine/pipeline/PipelineConfigInfo.cpp | 2 +- src/engine/primitives/Coordinate.hpp | 8 +++-- src/engine/primitives/Frustum.hpp | 12 +++---- src/engine/primitives/Line.hpp | 7 ++-- src/engine/primitives/Matrix.hpp | 3 +- src/engine/primitives/Plane.hpp | 2 +- src/engine/primitives/Rotation.cpp | 4 +-- src/engine/primitives/Rotation.hpp | 2 ++ src/engine/primitives/Vector.cpp | 8 ++--- src/engine/primitives/Vector.hpp | 4 +-- src/engine/systems/CullingSystem.hpp | 4 +-- src/engine/systems/EntityRendererSystem.cpp | 2 +- src/engine/texture/Texture.cpp | 8 ++++- src/engine/texture/TextureHandle.cpp | 12 +++++-- src/engine/texture/TextureHandle.hpp | 8 ++--- 35 files changed, 122 insertions(+), 86 deletions(-) diff --git a/cmake_modules/gcc.cmake b/cmake_modules/gcc.cmake index b926114..9c54e1d 100644 --- a/cmake_modules/gcc.cmake +++ b/cmake_modules/gcc.cmake @@ -110,7 +110,7 @@ set(FGL_CONFIG "-std=c++23 -fmax-errors=1 -fconcepts-diagnostics-depth=8 -Werror") - set(FGL_SHARED_OPTIMIZATION_FLAGS "-mavx -mavx2") + set(FGL_SHARED_OPTIMIZATION_FLAGS "-march=native") # Optimization flags set(FGL_OPTIMIZATION_FLAGS_RELEASE "-O2 -s -fdevirtualize-at-ltrans -fdevirtualize-speculatively -funroll-loops") # System agonistc flags @@ -119,7 +119,7 @@ set(FGL_OPTIMIZATION_FLAGS_RELWITHDEBINFO "-O2 -s -fdevirtualize-at-ltrans -fdevirtualize-speculatively -fdeclone-ctor-dtor -funroll-loops ${FGL_SHARED_OPTIMIZATION_FLAGS}") # Final sets - set(FGL_FLAGS "${FGL_CONFIG} ${FGL_OPTIMIZATION_FLAGS_${UPPER_BUILD_TYPE}} ${FLG_WARNINGS}" PARENT_SCOPE) # Flags for our shit + set(FGL_FLAGS "${FGL_CONFIG} ${FGL_OPTIMIZATION_FLAGS_${UPPER_BUILD_TYPE}} ${FGL_WARNINGS}" PARENT_SCOPE) # Flags for our shit #set(FGL_FLAGS "${FGL_OPTIMIZATION_FLAGS_${UPPER_BUILD_TYPE}}" PARENT_SCOPE) set(FGL_CHILD_FLAGS "${FGL_OPTIMIZATION_FLAGS_${UPPER_BUILD_TYPE}}" PARENT_SCOPE) # Child flags for adding optmization to anything we build ourselves but doesn't follow our standard #set(CMAKE_CXX_FLAGS "${FGL_CHILD_FLAGS}") diff --git a/src/engine/EngineContext.cpp b/src/engine/EngineContext.cpp index 499e883..355e9bc 100644 --- a/src/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -187,12 +187,13 @@ namespace fgl::engine ImGui::Text( "Framerate" ); ImGui::SameLine(); - ImGui::Text( "%.1f FPS", ImGui::GetIO().Framerate ); + ImGui::Text( "%.1f FPS", static_cast< double >( ImGui::GetIO().Framerate ) ); ImGui::Text( "Frame Time" ); ImGui::SameLine(); - ImGui::Text( "%.3f ms", 1000.0f / ImGui::GetIO().Framerate ); - ImGui::Text( "Average rolling frametime: %.3f ms", rolling_ms_average.average() ); + ImGui::Text( "%.3f ms", static_cast< double >( 1000.0f / ImGui::GetIO().Framerate ) ); + ImGui::Text( + "Average rolling frametime: %.3f ms", static_cast< double >( rolling_ms_average.average() ) ); auto inputVec3 = []( const std::string label, glm::vec3& vec ) { @@ -259,7 +260,13 @@ namespace fgl::engine const auto& frustum { camera.getFrustumBounds() }; auto printVec3 = []( const glm::vec3& vec ) - { ImGui::Text( "(%.2f, %.2f, %.2f)", vec.x, vec.y, vec.z ); }; + { + ImGui::Text( + "(%.2f, %.2f, %.2f)", + static_cast< double >( vec.x ), + static_cast< double >( vec.y ), + static_cast< double >( vec.z ) ); + }; auto printPlane = [ printVec3 ]( const auto& plane, const std::string name ) { @@ -269,9 +276,13 @@ namespace fgl::engine ImGui::SameLine( 120.0f ); printVec3( plane.direction() ); ImGui::SameLine(); - ImGui::Text( "Distance: %.3f", plane.distance() ); + ImGui::Text( "Distance: %.3f", static_cast< double >( plane.distance() ) ); const auto pos { plane.getPosition() }; - ImGui::Text( "Center: %.2f %.2f %.2f", pos.x, pos.y, pos.z ); + ImGui::Text( + "Center: %.2f %.2f %.2f", + static_cast< double >( pos.x ), + static_cast< double >( pos.y ), + static_cast< double >( pos.z ) ); }; printPlane( frustum.near, "Near" ); @@ -362,8 +373,8 @@ namespace fgl::engine if ( !sampler.has_value() ) continue; ImVec2 size; - size.x = extent.width; - size.y = extent.height; + size.x = static_cast< float >( extent.width ); + size.y = static_cast< float >( extent.height ); if ( std::find( textures.begin(), textures.end(), texture.getID() ) == textures.end() ) @@ -391,7 +402,7 @@ namespace fgl::engine { for ( const auto& buffer : Buffer::getActiveBufferHandles() ) { - ImGui::Text( "Address: %p", buffer.lock()->address() ); + ImGui::Text( "Address: %p", static_cast< void* >( buffer.lock()->address() ) ); ImGui::Text( "Size: %zu", buffer.lock()->size() ); } } @@ -480,7 +491,9 @@ namespace fgl::engine { auto sponza = GameObject::createGameObject(); sponza.model = model; - sponza.transform.translation = { 0.0f + ( y * 30 ), 0.0f + ( x * 20 ), 0.0f }; + sponza.transform.translation = { 0.0f + ( static_cast< float >( y ) * 30.0f ), + 0.0f + ( static_cast< float >( x ) * 20.0f ), + 0.0f }; sponza.transform.scale = { 0.007f, 0.007f, 0.007f }; sponza.transform.rotation = { 0.0f, 0.0f, 0.0f }; @@ -550,7 +563,7 @@ namespace fgl::engine { IMGUI_CHECKVERSION(); ImGui::CreateContext(); - ImGuiIO& io { ImGui::GetIO() }; + [[maybe_unused]] ImGuiIO& io { ImGui::GetIO() }; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; ImGui::StyleColorsDark(); diff --git a/src/engine/KeyboardMovementController.cpp b/src/engine/KeyboardMovementController.cpp index 64cd943..9be02d7 100644 --- a/src/engine/KeyboardMovementController.cpp +++ b/src/engine/KeyboardMovementController.cpp @@ -74,13 +74,11 @@ namespace fgl::engine if ( !cursor_enabled ) { const auto pos { getCursorPos( window ) }; - const auto xpos { pos.x }; - const auto ypos { pos.y }; + const float xpos { pos.x }; + const float ypos { pos.y }; - target.transform.rotation.yaw() += - static_cast< float >( ( xpos * 0.006 ) * static_cast< double >( look_speed ) ); - target.transform.rotation.pitch() -= - static_cast< float >( ( ypos * 0.006 ) * static_cast< double >( look_speed ) ); + target.transform.rotation.yaw() += ( xpos * 0.006f ) * look_speed; + target.transform.rotation.pitch() -= ( ypos * 0.006f ) * look_speed; setCursorPos( window, { 0, 0 } ); } diff --git a/src/engine/Renderer.cpp b/src/engine/Renderer.cpp index 3c0f046..bf13b89 100644 --- a/src/engine/Renderer.cpp +++ b/src/engine/Renderer.cpp @@ -150,7 +150,7 @@ namespace fgl::engine throw std::runtime_error( "Failed to submit commmand buffer" ); is_frame_started = false; - current_frame_idx = ( current_frame_idx + 1 ) % SwapChain::MAX_FRAMES_IN_FLIGHT; + current_frame_idx = static_cast< std::uint16_t >( ( current_frame_idx + 1 ) % SwapChain::MAX_FRAMES_IN_FLIGHT ); } void Renderer::beginSwapchainRendererPass( vk::CommandBuffer buffer ) diff --git a/src/engine/SwapChain.cpp b/src/engine/SwapChain.cpp index 405443d..e3edc6b 100644 --- a/src/engine/SwapChain.cpp +++ b/src/engine/SwapChain.cpp @@ -118,6 +118,9 @@ namespace fgl::engine Device::getInstance().graphicsQueue().submit( 1, &submitInfo, inFlightFences[ currentFrame ] ); result != vk::Result::eSuccess ) { +#pragma GCC diagnostic push + //Can't possibly handle all of these. It will add like....100 lines of just empty cases +#pragma GCC diagnostic ignored "-Wswitch-enum" switch ( result ) { case vk::Result::eErrorOutOfDateKHR: @@ -130,6 +133,7 @@ namespace fgl::engine throw std::runtime_error( "failed to submit draw command buffer!: ID" + std::to_string( static_cast< int >( result ) ) ); } +#pragma GCC diagnostic pop } vk::PresentInfoKHR presentInfo = {}; @@ -141,7 +145,7 @@ namespace fgl::engine presentInfo.swapchainCount = 1; presentInfo.pSwapchains = swapChains; - std::array< std::uint32_t, 1 > indicies { imageIndex }; + std::array< std::uint32_t, 1 > indicies { { imageIndex } }; presentInfo.setImageIndices( indicies ); if ( auto present_result = Device::getInstance().presentQueue().presentKHR( &presentInfo ); @@ -249,9 +253,9 @@ namespace fgl::engine g_buffer_normal.createResourceSpread( imageCount(), getSwapChainExtent() ); g_buffer_albedo.createResourceSpread( imageCount(), getSwapChainExtent() ); - g_buffer_position.setClear( vk::ClearColorValue( std::array< float, 4 > { 0.0f, 0.0f, 0.0f, 0.0f } ) ); - g_buffer_normal.setClear( vk::ClearColorValue( std::array< float, 4 > { 0.0f, 0.0f, 0.0f, 0.0f } ) ); - g_buffer_albedo.setClear( vk::ClearColorValue( std::array< float, 4 > { 0.0f, 0.0f, 0.0f, 0.0f } ) ); + g_buffer_position.setClear( vk::ClearColorValue( std::array< float, 4 > { { 0.0f, 0.0f, 0.0f, 0.0f } } ) ); + g_buffer_normal.setClear( vk::ClearColorValue( std::array< float, 4 > { { 0.0f, 0.0f, 0.0f, 0.0f } } ) ); + g_buffer_albedo.setClear( vk::ClearColorValue( std::array< float, 4 > { { 0.0f, 0.0f, 0.0f, 0.0f } } ) ); g_buffer_position.m_attachment_resources.m_images[ 0 ]->setName( "GBufferPosition" ); g_buffer_normal.m_attachment_resources.m_images[ 0 ]->setName( "GBufferNormal" ); diff --git a/src/engine/buffers/Buffer.cpp b/src/engine/buffers/Buffer.cpp index 2e47899..d6b439b 100644 --- a/src/engine/buffers/Buffer.cpp +++ b/src/engine/buffers/Buffer.cpp @@ -180,7 +180,7 @@ namespace fgl::engine << "Attempted to allocate block of size: " << fgl::literals::size_literals::to_string( memory_size ) << std::endl; - int allocated_memory_counter { 0 }; + std::uint64_t allocated_memory_counter { 0 }; //Sum up all memory to check for leaks for ( auto [ offset, size ] : m_suballocations ) { @@ -190,7 +190,7 @@ namespace fgl::engine std::cout << "Total memory allocated: " << fgl::literals::size_literals::to_string( allocated_memory_counter ) << std::endl; - int free_memory_counter { 0 }; + std::uint64_t free_memory_counter { 0 }; for ( auto [ offset, size ] : m_free_blocks ) { free_memory_counter += size; diff --git a/src/engine/buffers/BufferSuballocationHandle.cpp b/src/engine/buffers/BufferSuballocationHandle.cpp index 3efb669..1559b6d 100644 --- a/src/engine/buffers/BufferSuballocationHandle.cpp +++ b/src/engine/buffers/BufferSuballocationHandle.cpp @@ -9,8 +9,8 @@ namespace fgl::engine { BufferSuballocationHandle:: - BufferSuballocationHandle( Buffer& buffer, vk::DeviceSize offset, vk::DeviceSize memory_size ) : - buffer( buffer ), + BufferSuballocationHandle( Buffer& p_buffer, vk::DeviceSize offset, vk::DeviceSize memory_size ) : + buffer( p_buffer ), m_size( memory_size ), m_offset( offset ), mapped( buffer.map( *this ) ) diff --git a/src/engine/buffers/UniqueFrameSuballocation.hpp b/src/engine/buffers/UniqueFrameSuballocation.hpp index 009ebeb..f681e04 100644 --- a/src/engine/buffers/UniqueFrameSuballocation.hpp +++ b/src/engine/buffers/UniqueFrameSuballocation.hpp @@ -19,7 +19,7 @@ namespace fgl::engine PerFrameSuballocation( Buffer& buffer, const std::uint32_t frames_in_flight ) : m_buffer( buffer ) { m_suballocations.reserve( frames_in_flight ); - for ( std::uint8_t i = 0; i < frames_in_flight; ++i ) + for ( std::uint16_t i = 0; i < frames_in_flight; ++i ) { static_assert( std::is_default_constructible_v< typename Suballocation::value_type >, @@ -28,11 +28,11 @@ namespace fgl::engine } } - void setMaxFramesInFlight( std::uint8_t max ) { m_suballocations.resize( max ); } + void setMaxFramesInFlight( std::uint16_t max ) { m_suballocations.resize( max ); } - Suballocation& operator[]( std::uint8_t index ) { return *m_suballocations[ index ]; } + Suballocation& operator[]( std::uint16_t index ) { return *m_suballocations[ index ]; } - void bindForFrame( vk::CommandBuffer& cmd_buffer, std::uint8_t frame_idx ) + void bindForFrame( vk::CommandBuffer& cmd_buffer, std::uint16_t frame_idx ) { m_suballocations[ frame_idx ].bind( cmd_buffer ); } diff --git a/src/engine/debug/drawers.cpp b/src/engine/debug/drawers.cpp index 829f3ad..bbfa59b 100644 --- a/src/engine/debug/drawers.cpp +++ b/src/engine/debug/drawers.cpp @@ -240,7 +240,10 @@ namespace fgl::engine::debug } void drawBoolAlpha( - const glm::vec2 screen_point, const Camera& camera, const bool value, const glm::vec2 offset ) + const glm::vec2 screen_point, + [[maybe_unused]] const Camera& camera, + const bool value, + const glm::vec2 offset ) { const auto color { value ? glm::vec3( 0.0f, 1.0f, 0.0f ) : glm::vec3( 1.0f, 0.0f, 0.0f ) }; drawText( glm::vec2( screen_point.x, screen_point.y + offset.y ), value ? "true" : "false", color ); diff --git a/src/engine/debug/drawers.hpp b/src/engine/debug/drawers.hpp index 6c42f07..0a19f3e 100644 --- a/src/engine/debug/drawers.hpp +++ b/src/engine/debug/drawers.hpp @@ -12,13 +12,13 @@ namespace fgl::engine { template < CoordinateSpace type > - class BoundingBox; + struct BoundingBox; template < CoordinateSpace type > class Coordinate; template < CoordinateSpace type > - class Line; + struct Line; class Camera; diff --git a/src/engine/descriptors/DescriptorSet.hpp b/src/engine/descriptors/DescriptorSet.hpp index e1ec49b..2876eac 100644 --- a/src/engine/descriptors/DescriptorSet.hpp +++ b/src/engine/descriptors/DescriptorSet.hpp @@ -23,7 +23,8 @@ namespace fgl::engine std::vector< std::variant< std::monostate, vk::DescriptorImageInfo, vk::DescriptorBufferInfo > > m_infos {}; std::vector< vk::WriteDescriptorSet > descriptor_writes {}; - std::vector< std::variant< std::shared_ptr< ImageView >, std::shared_ptr< BufferSuballocation > > > m_resources; + std::vector< std::variant< std::shared_ptr< ImageView >, std::shared_ptr< BufferSuballocation > > > + m_resources {}; vk::DescriptorSetLayout m_layout; vk::DescriptorSet m_set; diff --git a/src/engine/image/Image.hpp b/src/engine/image/Image.hpp index a23be73..beab2b5 100644 --- a/src/engine/image/Image.hpp +++ b/src/engine/image/Image.hpp @@ -17,8 +17,8 @@ namespace fgl::engine class Image { - std::shared_ptr< ImageHandle > m_handle; - std::weak_ptr< ImageView > view; + std::shared_ptr< ImageHandle > m_handle {}; + std::weak_ptr< ImageView > view {}; public: diff --git a/src/engine/image/ImageView.hpp b/src/engine/image/ImageView.hpp index ef26e80..e649f32 100644 --- a/src/engine/image/ImageView.hpp +++ b/src/engine/image/ImageView.hpp @@ -21,7 +21,7 @@ namespace fgl::engine { std::shared_ptr< ImageHandle > m_resource; - std::optional< Sampler > m_sampler; + std::optional< Sampler > m_sampler { std::nullopt }; vk::DescriptorImageInfo m_descriptor_info {}; diff --git a/src/engine/image/Sampler.hpp b/src/engine/image/Sampler.hpp index f5cce79..9999a0f 100644 --- a/src/engine/image/Sampler.hpp +++ b/src/engine/image/Sampler.hpp @@ -12,7 +12,7 @@ namespace fgl::engine class Sampler { bool valid { false }; - vk::Sampler m_sampler; + vk::Sampler m_sampler { VK_NULL_HANDLE }; public: diff --git a/src/engine/math/taitBryanMatrix.cpp b/src/engine/math/taitBryanMatrix.cpp index ef30087..b85d9bd 100644 --- a/src/engine/math/taitBryanMatrix.cpp +++ b/src/engine/math/taitBryanMatrix.cpp @@ -197,6 +197,8 @@ namespace fgl::engine mat[ 2 ] = glm::vec4( row_2, 0.0f ); return mat; } + case RotationOrder::END_OF_ENUM: + [[fallthrough]]; default: throw std::runtime_error( "Unimplemented rotation order" ); } diff --git a/src/engine/math/taitBryanMatrix.hpp b/src/engine/math/taitBryanMatrix.hpp index 7e1b106..018e58e 100644 --- a/src/engine/math/taitBryanMatrix.hpp +++ b/src/engine/math/taitBryanMatrix.hpp @@ -8,7 +8,7 @@ namespace fgl::engine { - class Rotation; + struct Rotation; enum RotationOrder { diff --git a/src/engine/model/BoundingBox.cpp b/src/engine/model/BoundingBox.cpp index e3564ed..829daa7 100644 --- a/src/engine/model/BoundingBox.cpp +++ b/src/engine/model/BoundingBox.cpp @@ -80,6 +80,7 @@ namespace fgl::engine // clang-format off std::array< std::uint32_t, indicies_count > data { + { //Top tris 0, 1, 2, 1, 2, 3, @@ -97,7 +98,7 @@ namespace fgl::engine 0, 7, 4, //Side 4 2, 1, 6, - 1, 6, 5 + 1, 6, 5 } }; // clang-format on diff --git a/src/engine/model/BoundingBox.hpp b/src/engine/model/BoundingBox.hpp index 5be169e..dc6d6e5 100644 --- a/src/engine/model/BoundingBox.hpp +++ b/src/engine/model/BoundingBox.hpp @@ -18,9 +18,9 @@ namespace fgl::engine { template < CoordinateSpace type > - class Frustum; + struct Frustum; - class Vertex; + struct Vertex; template < CoordinateSpace CType > struct BoundingBox diff --git a/src/engine/model/Model.cpp b/src/engine/model/Model.cpp index ba96579..31a98d7 100644 --- a/src/engine/model/Model.cpp +++ b/src/engine/model/Model.cpp @@ -50,7 +50,7 @@ namespace fgl::engine BoundingBox< CoordinateSpace::Model > box { primitives.at( 0 ).m_bounding_box }; - for ( int i = 1; i < primitives.size(); i++ ) box = box.combine( primitives[ i ].m_bounding_box ); + for ( std::uint64_t i = 1; i < primitives.size(); i++ ) box = box.combine( primitives[ i ].m_bounding_box ); return box; } diff --git a/src/engine/model/gltfLoading.cpp b/src/engine/model/gltfLoading.cpp index efa9ba3..e7b966e 100644 --- a/src/engine/model/gltfLoading.cpp +++ b/src/engine/model/gltfLoading.cpp @@ -210,9 +210,9 @@ namespace fgl::engine VertexBufferSuballocation vertex_buffer { m_vertex_buffer, verts }; IndexBufferSuballocation index_buffer { m_index_buffer, indicies_data }; - if ( primitive.material >= 0 && primitive.material < model.materials.size() ) + if ( primitive.material >= 0 && primitive.material < static_cast< int >( model.materials.size() ) ) { - const auto& material { model.materials.at( primitive.material ) }; + const auto& material { model.materials.at( static_cast< unsigned long >( primitive.material ) ) }; //TODO: Implement material normals @@ -222,10 +222,10 @@ namespace fgl::engine const auto& color_texture { material.values.at( "baseColorTexture" ) }; const auto color_index { color_texture.TextureIndex() }; - const auto& texture { model.textures.at( color_index ) }; + const auto& texture { model.textures.at( static_cast< unsigned long >( color_index ) ) }; - const auto& source { model.images.at( texture.source ) }; - const auto& sampler { model.samplers.at( texture.sampler ) }; + const auto& source { model.images.at( static_cast< unsigned long >( texture.source ) ) }; + const auto& sampler { model.samplers.at( static_cast< unsigned long >( texture.sampler ) ) }; auto translateFilterToVK = []( const int val ) -> vk::Filter { diff --git a/src/engine/pipeline/PipelineConfigInfo.cpp b/src/engine/pipeline/PipelineConfigInfo.cpp index ead4972..d3a4d0e 100644 --- a/src/engine/pipeline/PipelineConfigInfo.cpp +++ b/src/engine/pipeline/PipelineConfigInfo.cpp @@ -104,7 +104,7 @@ namespace fgl::engine info.color_blend_attachment.emplace_back( state ); info.color_blend_info.pAttachments = info.color_blend_attachment.data(); - info.color_blend_info.attachmentCount = info.color_blend_attachment.size(); + info.color_blend_info.attachmentCount = static_cast< std::uint32_t >( info.color_blend_attachment.size() ); } PipelineConfigInfo::PipelineConfigInfo( vk::RenderPass pass ) diff --git a/src/engine/primitives/Coordinate.hpp b/src/engine/primitives/Coordinate.hpp index 8074ce1..f10d9fa 100644 --- a/src/engine/primitives/Coordinate.hpp +++ b/src/engine/primitives/Coordinate.hpp @@ -32,11 +32,13 @@ namespace fgl::engine float& forward() { return y; } - Coordinate() : glm::vec3( constants::DEFAULT_VEC3 ) {} + Coordinate() noexcept : glm::vec3( constants::DEFAULT_VEC3 ) {} - constexpr explicit Coordinate( const glm::vec3 position ) : glm::vec3( position ) {} + constexpr explicit Coordinate( const glm::vec3 position ) noexcept : glm::vec3( position ) {} - constexpr explicit Coordinate( const float x, const float y, const float z ) : glm::vec3( x, y, z ) {} + constexpr explicit Coordinate( const float i_x, const float i_y, const float i_z ) noexcept : + glm::vec3( i_x, i_y, i_z ) + {} constexpr explicit Coordinate( const float value ) : glm::vec3( value ) {} diff --git a/src/engine/primitives/Frustum.hpp b/src/engine/primitives/Frustum.hpp index 155f960..d5ddd99 100644 --- a/src/engine/primitives/Frustum.hpp +++ b/src/engine/primitives/Frustum.hpp @@ -17,14 +17,14 @@ namespace fgl::engine template < CoordinateSpace CType = CoordinateSpace::World > struct Frustum { - Plane< CType > near; - Plane< CType > far; + Plane< CType > near { constants::WORLD_FORWARD, constants::DEFAULT_FLOAT }; + Plane< CType > far { constants::WORLD_FORWARD, constants::DEFAULT_FLOAT }; - Plane< CType > top; - Plane< CType > bottom; + Plane< CType > top { constants::WORLD_FORWARD, constants::DEFAULT_FLOAT }; + Plane< CType > bottom { constants::WORLD_FORWARD, constants::DEFAULT_FLOAT }; - Plane< CType > right; - Plane< CType > left; + Plane< CType > right { constants::WORLD_FORWARD, constants::DEFAULT_FLOAT }; + Plane< CType > left { constants::WORLD_FORWARD, constants::DEFAULT_FLOAT }; friend class Camera; diff --git a/src/engine/primitives/Line.hpp b/src/engine/primitives/Line.hpp index 7ac6945..6f651a1 100644 --- a/src/engine/primitives/Line.hpp +++ b/src/engine/primitives/Line.hpp @@ -17,9 +17,12 @@ namespace fgl::engine Vector direction() const { return Vector( static_cast< glm::vec3 >( end - start ) ); } - Line( const Coordinate< CType > start, const Coordinate< CType > end ) : start( start ), end( end ) {} + Line( const Coordinate< CType > i_start, const Coordinate< CType > i_end ) noexcept : + start( i_start ), + end( i_end ) + {} - Line( const glm::vec3 start, glm::vec3 end ) : start( start ), end( end ) {} + Line( const glm::vec3 i_start, glm::vec3 i_end ) : start( i_start ), end( i_end ) {} inline Line< CType > flip() const { return { end, start }; } }; diff --git a/src/engine/primitives/Matrix.hpp b/src/engine/primitives/Matrix.hpp index e5d22eb..67e922e 100644 --- a/src/engine/primitives/Matrix.hpp +++ b/src/engine/primitives/Matrix.hpp @@ -22,7 +22,7 @@ namespace fgl::engine { public: - explicit Matrix( const float value = 1.0f ) : glm::mat4( value ) {} + explicit Matrix( const float i_value = 1.0f ) : glm::mat4( i_value ) {} explicit Matrix( const glm::mat4& matrix ) : glm::mat4( matrix ) {} }; @@ -33,5 +33,4 @@ namespace fgl::engine return Matrix< MatrixType::WorldToScreen >( static_cast< glm::mat4 >( lhs ) * static_cast< glm::mat4 >( rhs ) ); } - }; // namespace fgl::engine diff --git a/src/engine/primitives/Plane.hpp b/src/engine/primitives/Plane.hpp index a6f5758..f32a8f6 100644 --- a/src/engine/primitives/Plane.hpp +++ b/src/engine/primitives/Plane.hpp @@ -46,7 +46,7 @@ namespace fgl::engine //! Returns the distance from a point to the plane. Negative if behind, positive if in front float distanceFrom( const WorldCoordinate coord ) const; - bool isForward( const WorldCoordinate coord ) const { return distanceFrom( coord ) > 0.0; } + bool isForward( const WorldCoordinate coord ) const { return distanceFrom( coord ) > 0.0f; } bool isBehind( const WorldCoordinate coord ) const { return !isForward( coord ); } diff --git a/src/engine/primitives/Rotation.cpp b/src/engine/primitives/Rotation.cpp index e58cbee..4d82ca3 100644 --- a/src/engine/primitives/Rotation.cpp +++ b/src/engine/primitives/Rotation.cpp @@ -23,9 +23,9 @@ namespace fgl::engine return *this; } - Rotation& Rotation::operator+=( const glm::vec3 vec ) + Rotation& Rotation::operator+=( const glm::vec3 i_vec ) { - static_cast< glm::vec3& >( *this ) += vec; + static_cast< glm::vec3& >( *this ) += i_vec; return *this; } diff --git a/src/engine/primitives/Rotation.hpp b/src/engine/primitives/Rotation.hpp index 6c9ca18..d6bb978 100644 --- a/src/engine/primitives/Rotation.hpp +++ b/src/engine/primitives/Rotation.hpp @@ -28,6 +28,8 @@ namespace fgl::engine Rotation( const float pitch_r, const float roll_r, const float yaw_r ); + Rotation( const Rotation& other ) = default; + Rotation& operator=( const Rotation other ); Rotation& operator+=( const glm::vec3 vec ); diff --git a/src/engine/primitives/Vector.cpp b/src/engine/primitives/Vector.cpp index 085e20e..afb6e94 100644 --- a/src/engine/primitives/Vector.cpp +++ b/src/engine/primitives/Vector.cpp @@ -7,12 +7,8 @@ namespace fgl::engine { - Vector::Vector( const Vector& other ) - { - x = other.x; - y = other.y; - z = other.z; - } + Vector::Vector( const Vector& other ) : glm::vec3( other.x, other.y, other.z ) + {} Vector& Vector::operator=( const Vector& other ) { diff --git a/src/engine/primitives/Vector.hpp b/src/engine/primitives/Vector.hpp index 5162c14..93cec46 100644 --- a/src/engine/primitives/Vector.hpp +++ b/src/engine/primitives/Vector.hpp @@ -20,7 +20,7 @@ namespace fgl::engine constexpr explicit Vector( const float value ) : glm::vec3( value ) {} - constexpr explicit Vector( const glm::vec3 vec ) : glm::vec3( vec ) + constexpr explicit Vector( const glm::vec3 i_vec ) : glm::vec3( i_vec ) { assert( ( x <= 1.0f || std::numeric_limits< float >::max() ) @@ -33,7 +33,7 @@ namespace fgl::engine && "Value too high for Vector. Forgot to normalize?" ); } - constexpr explicit Vector( const float x, const float y, const float z ) : glm::vec3( x, y, z ) {} + constexpr explicit Vector( const float i_x, const float i_y, const float i_z ) : glm::vec3( i_x, i_y, i_z ) {} operator glm::vec4() const { return glm::vec4( static_cast< glm::vec3 >( *this ), 0.0f ); } diff --git a/src/engine/systems/CullingSystem.hpp b/src/engine/systems/CullingSystem.hpp index 12ac7c9..82a99d6 100644 --- a/src/engine/systems/CullingSystem.hpp +++ b/src/engine/systems/CullingSystem.hpp @@ -15,8 +15,8 @@ namespace fgl::engine { std::thread m_thread; - std::optional< FrameInfo* > m_info; - std::stop_token m_stop_token; + std::optional< FrameInfo* > m_info { std::nullopt }; + std::stop_token m_stop_token {}; void runner(); diff --git a/src/engine/systems/EntityRendererSystem.cpp b/src/engine/systems/EntityRendererSystem.cpp index 1ee1493..161c1c8 100644 --- a/src/engine/systems/EntityRendererSystem.cpp +++ b/src/engine/systems/EntityRendererSystem.cpp @@ -151,7 +151,7 @@ namespace fgl::engine for ( auto& itter : draw_pairs ) { auto cmd { itter.first }; - cmd.firstInstance = model_matrices.size(); + cmd.firstInstance = static_cast< std::uint32_t >( model_matrices.size() ); auto matricies { std::move( itter.second ) }; draw_commands.emplace_back( cmd ); diff --git a/src/engine/texture/Texture.cpp b/src/engine/texture/Texture.cpp index 06b1253..394e0fc 100644 --- a/src/engine/texture/Texture.cpp +++ b/src/engine/texture/Texture.cpp @@ -12,9 +12,15 @@ #include "engine/descriptors/DescriptorPool.hpp" #include "engine/descriptors/DescriptorSet.hpp" #include "engine/image/ImageView.hpp" -#include "imgui/imgui_impl_vulkan.h" #include "objectloaders/stb_image.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wconversion" +#include "imgui/imgui_impl_vulkan.h" +#pragma GCC diagnostic pop + namespace fgl::engine { diff --git a/src/engine/texture/TextureHandle.cpp b/src/engine/texture/TextureHandle.cpp index f2b452c..a4bf0af 100644 --- a/src/engine/texture/TextureHandle.cpp +++ b/src/engine/texture/TextureHandle.cpp @@ -7,13 +7,19 @@ #include "engine/buffers/BufferSuballocation.hpp" #include "engine/image/Image.hpp" #include "engine/image/ImageView.hpp" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wconversion" #include "imgui/imgui_impl_vulkan.h" +#pragma GCC diagnostic pop namespace fgl::engine { - TextureHandle:: - TextureHandle( const std::vector< unsigned char >& data, const vk::Extent2D extent, const int channels ) : + TextureHandle::TextureHandle( + const std::vector< unsigned char >& data, const vk::Extent2D extent, [[maybe_unused]] const int channels ) : m_extent( extent ) { ZoneScoped; @@ -24,7 +30,7 @@ namespace fgl::engine auto image = std::make_shared< Image >( extent, format, - vk::ImageUsageFlags( vk::ImageUsageFlagBits::eTransferDst | vk::ImageUsageFlagBits::eSampled ), + vk::ImageUsageFlagBits::eTransferDst | vk::ImageUsageFlagBits::eSampled, vk::ImageLayout::eUndefined, vk::ImageLayout::eShaderReadOnlyOptimal ); diff --git a/src/engine/texture/TextureHandle.hpp b/src/engine/texture/TextureHandle.hpp index 10ad25b..3463c11 100644 --- a/src/engine/texture/TextureHandle.hpp +++ b/src/engine/texture/TextureHandle.hpp @@ -19,13 +19,13 @@ namespace fgl::engine class TextureHandle { //TODO: Implement reusing texture ids - TextureID m_texture_id; + TextureID m_texture_id { std::numeric_limits< TextureID >::infinity() }; - std::shared_ptr< ImageView > m_image_view; + std::shared_ptr< ImageView > m_image_view {}; - std::unique_ptr< BufferSuballocation > m_staging; + std::unique_ptr< BufferSuballocation > m_staging { nullptr }; - vk::Extent2D m_extent; + vk::Extent2D m_extent { 0, 0 }; vk::DescriptorSet m_imgui_set { VK_NULL_HANDLE };