diff --git a/cmake/cppcheck-suppression-list.txt b/cmake/cppcheck-suppression-list.txt index 1e24575e4..798c327a9 100644 --- a/cmake/cppcheck-suppression-list.txt +++ b/cmake/cppcheck-suppression-list.txt @@ -201,6 +201,8 @@ shadowFunction:*/src/vsg/state/Image.cpp shadowFunction:*/src/vsg/state/ImageView.cpp shadowFunction:*/src/vsg/state/MultisampleState.cpp shadowFunction:*/src/vsg/state/DescriptorImage.cpp +shadowFunction:*/src/vsg/utils/FindDynamicObjects.cpp + // suppress unhelpful warning of c casts cstyleCast:*/include/vsg/io/mem_stream.h diff --git a/src/vsg/state/ImageInfo.cpp b/src/vsg/state/ImageInfo.cpp index cb5bcaa2c..acea25fc9 100644 --- a/src/vsg/state/ImageInfo.cpp +++ b/src/vsg/state/ImageInfo.cpp @@ -137,7 +137,7 @@ int ImageInfo::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_pointer(sampler, rhs.sampler))) return result; if ((result = compare_pointer(imageView, rhs.imageView))) return result; diff --git a/src/vsg/state/MultisampleState.cpp b/src/vsg/state/MultisampleState.cpp index f56eeae0a..e9d87fb29 100644 --- a/src/vsg/state/MultisampleState.cpp +++ b/src/vsg/state/MultisampleState.cpp @@ -42,7 +42,7 @@ int MultisampleState::compare(const Object& rhs_object) const int result = GraphicsPipelineState::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_value(rasterizationSamples, rhs.rasterizationSamples))) return result; if ((result = compare_value(sampleShadingEnable, rhs.sampleShadingEnable))) return result; diff --git a/src/vsg/state/PipelineLayout.cpp b/src/vsg/state/PipelineLayout.cpp index eb65a58b0..bc586ed11 100644 --- a/src/vsg/state/PipelineLayout.cpp +++ b/src/vsg/state/PipelineLayout.cpp @@ -51,7 +51,7 @@ int PipelineLayout::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_value(flags, rhs.flags))) return result; if ((result = compare_pointer_container(setLayouts, rhs.setLayouts))) return result; @@ -86,13 +86,13 @@ void PipelineLayout::write(Output& output) const output.writeValue("flags", flags); output.writeValue("setLayouts", setLayouts.size()); - for (auto& descriptorLayout : setLayouts) + for (const auto& descriptorLayout : setLayouts) { output.writeObject("descriptorLayout", descriptorLayout); } output.writeValue("pushConstantRanges", pushConstantRanges.size()); - for (auto& pushConstantRange : pushConstantRanges) + for (const auto& pushConstantRange : pushConstantRanges) { output.writeValue("stageFlags", pushConstantRange.stageFlags); output.write("offset", pushConstantRange.offset); diff --git a/src/vsg/state/RasterizationState.cpp b/src/vsg/state/RasterizationState.cpp index cd41ca22d..721558d14 100644 --- a/src/vsg/state/RasterizationState.cpp +++ b/src/vsg/state/RasterizationState.cpp @@ -45,7 +45,7 @@ int RasterizationState::compare(const Object& rhs_object) const int result = GraphicsPipelineState::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); return compare_region(depthClampEnable, lineWidth, rhs.depthClampEnable); } diff --git a/src/vsg/state/Sampler.cpp b/src/vsg/state/Sampler.cpp index 8340ad968..85bc0d08d 100644 --- a/src/vsg/state/Sampler.cpp +++ b/src/vsg/state/Sampler.cpp @@ -31,7 +31,7 @@ int Sampler::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); return compare_region(flags, unnormalizedCoordinates, rhs.flags); } diff --git a/src/vsg/state/ShaderModule.cpp b/src/vsg/state/ShaderModule.cpp index cc2477cea..ca701fc70 100644 --- a/src/vsg/state/ShaderModule.cpp +++ b/src/vsg/state/ShaderModule.cpp @@ -28,7 +28,7 @@ int ShaderCompileSettings::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_value(vulkanVersion, rhs.vulkanVersion))) return result; if ((result = compare_value(clientInputVersion, rhs.clientInputVersion))) return result; @@ -108,7 +108,7 @@ int ShaderModule::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_value(source, rhs.source))) return result; if ((result = compare_pointer(hints, rhs.hints))) return result; diff --git a/src/vsg/state/StateCommand.cpp b/src/vsg/state/StateCommand.cpp index fef473641..12036209b 100644 --- a/src/vsg/state/StateCommand.cpp +++ b/src/vsg/state/StateCommand.cpp @@ -34,7 +34,7 @@ int StateCommand::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); return compare_value(slot, rhs.slot); } diff --git a/src/vsg/state/TessellationState.cpp b/src/vsg/state/TessellationState.cpp index 9d99fecfd..4b0c91b17 100644 --- a/src/vsg/state/TessellationState.cpp +++ b/src/vsg/state/TessellationState.cpp @@ -37,7 +37,7 @@ int TessellationState::compare(const Object& rhs_object) const int result = GraphicsPipelineState::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); return compare_value(patchControlPoints, rhs.patchControlPoints); } diff --git a/src/vsg/state/VertexInputState.cpp b/src/vsg/state/VertexInputState.cpp index 77ebe67fb..a1b907c57 100644 --- a/src/vsg/state/VertexInputState.cpp +++ b/src/vsg/state/VertexInputState.cpp @@ -43,7 +43,7 @@ int VertexInputState::compare(const Object& rhs_object) const int result = GraphicsPipelineState::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_value_container(vertexBindingDescriptions, rhs.vertexBindingDescriptions))) return result; return compare_value_container(vertexAttributeDescriptions, rhs.vertexAttributeDescriptions); diff --git a/src/vsg/state/ViewDependentState.cpp b/src/vsg/state/ViewDependentState.cpp index f8bfa9c8a..4c20aad52 100644 --- a/src/vsg/state/ViewDependentState.cpp +++ b/src/vsg/state/ViewDependentState.cpp @@ -80,7 +80,7 @@ int ViewDescriptorSetLayout::compare(const Object& rhs_object) const int result = DescriptorSetLayout::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); return compare_pointer(_viewDescriptorSetLayout, rhs._viewDescriptorSetLayout); } @@ -119,7 +119,7 @@ int BindViewDescriptorSets::compare(const Object& rhs_object) const int result = StateCommand::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_value(pipelineBindPoint, rhs.pipelineBindPoint))) return result; if ((result = compare_pointer(layout, rhs.layout))) return result; @@ -229,7 +229,7 @@ void ViewDependentState::init(ResourceRequirements& requirements) uint32_t shadowHeight = 2048; uint32_t maxShadowMaps = 8; - auto& viewDetails = requirements.views[view]; + const auto& viewDetails = requirements.views[view]; if ((view->features & (RECORD_LIGHTS | RECORD_SHADOW_MAPS)) != 0) { @@ -448,7 +448,7 @@ void ViewDependentState::compile(Context& context) shadowDepthImage->compile(context); uint32_t layer = 0; - for (auto& shadowMap : shadowMaps) + for (const auto& shadowMap : shadowMaps) { // create depth buffer auto depthImageView = ImageView::create(shadowDepthImage, VK_IMAGE_ASPECT_DEPTH_BIT); @@ -686,7 +686,7 @@ void ViewDependentState::traverse(RecordTraversal& rt) const // lightData requirements = vec4 * (num_ambientLights + 3 * num_directionLights + 3 * num_pointLights + 4 * num_spotLights + 4 * num_shadow_maps) - for (auto& entry : ambientLights) + for (const auto& entry : ambientLights) { auto light = entry.second; (*light_itr++).set(light->color.r, light->color.g, light->color.b, light->intensity); diff --git a/src/vsg/state/ViewportState.cpp b/src/vsg/state/ViewportState.cpp index c96eef9cd..dbe0fe18a 100644 --- a/src/vsg/state/ViewportState.cpp +++ b/src/vsg/state/ViewportState.cpp @@ -47,7 +47,7 @@ int ViewportState::compare(const Object& rhs_object) const int result = GraphicsPipelineState::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_value_container(viewports, rhs.viewports))) return result; return compare_value_container(scissors, rhs.scissors); diff --git a/src/vsg/text/CpuLayoutTechnique.cpp b/src/vsg/text/CpuLayoutTechnique.cpp index ebe7233d0..1aff2d9ac 100644 --- a/src/vsg/text/CpuLayoutTechnique.cpp +++ b/src/vsg/text/CpuLayoutTechnique.cpp @@ -99,7 +99,7 @@ ref_ptr CpuLayoutTechnique::createRenderingSubgraph(ref_ptr sha bool singleOutlineColor = true; bool singleOutlineWidth = true; bool singleCenterAutoScaleDistance = true; - for (auto& quad : quads) + for (const auto& quad : quads) { for (int i = 0; i < 4; ++i) { diff --git a/src/vsg/text/GpuLayoutTechnique.cpp b/src/vsg/text/GpuLayoutTechnique.cpp index dbbbb509e..2c5742d8f 100644 --- a/src/vsg/text/GpuLayoutTechnique.cpp +++ b/src/vsg/text/GpuLayoutTechnique.cpp @@ -111,7 +111,7 @@ void GpuLayoutTechnique::setup(Text* text, uint32_t minimumAllocation, ref_ptr(text.valueCount())); auto itr = textArray->begin(); - for (auto& c : text) + for (const auto& c : text) { assignValue(*(itr++), font.glyphIndexForCharcode(c), updated); } @@ -121,7 +121,7 @@ void GpuLayoutTechnique::setup(Text* text, uint32_t minimumAllocation, ref_ptr(text.valueCount())); auto itr = textArray->begin(); - for (auto& c : text) + for (const auto& c : text) { assignValue(*(itr++), font.glyphIndexForCharcode(c), updated); } @@ -131,7 +131,7 @@ void GpuLayoutTechnique::setup(Text* text, uint32_t minimumAllocation, ref_ptr(text.valueCount())); auto itr = textArray->begin(); - for (auto& c : text) + for (const auto& c : text) { assignValue(*(itr++), font.glyphIndexForCharcode(c), updated); } diff --git a/src/vsg/text/StandardLayout.cpp b/src/vsg/text/StandardLayout.cpp index bfded57e4..d83c2b462 100644 --- a/src/vsg/text/StandardLayout.cpp +++ b/src/vsg/text/StandardLayout.cpp @@ -35,35 +35,35 @@ namespace void apply(const stringValue& text) override { - for (auto& c : text.value()) + for (const auto& c : text.value()) { character(uint8_t(c)); } } void apply(const wstringValue& text) override { - for (auto& c : text.value()) + for (const auto& c : text.value()) { character(uint16_t(c)); } } void apply(const ubyteArray& text) override { - for (auto& c : text) + for (const auto& c : text) { character(c); } } void apply(const ushortArray& text) override { - for (auto& c : text) + for (const auto& c : text) { character(c); } } void apply(const uintArray& text) override { - for (auto& c : text) + for (const auto& c : text) { character(c); } @@ -398,7 +398,7 @@ void StandardLayout::layout(const Data* text, const Font& font, TextQuads& quads if (layout.horizontalAlignment != BASELINE_ALIGNMENT || layout.verticalAlignment != BASELINE_ALIGNMENT) { - vec2 alignment(0.0f, 0.0f); + vec2 glyphAlignment(0.0f, 0.0f); float left = textQuads[start_of_conversion].vertices[0].x; float right = textQuads[start_of_conversion].vertices[1].x; @@ -406,7 +406,7 @@ void StandardLayout::layout(const Data* text, const Font& font, TextQuads& quads float top = textQuads[start_of_conversion].vertices[3].y; for (size_t i = start_of_conversion + 1; i < textQuads.size(); ++i) { - auto& quad = textQuads[i]; + const auto& quad = textQuads[i]; if (quad.vertices[0].x < left) left = quad.vertices[0].x; if (quad.vertices[1].x > right) right = quad.vertices[1].x; if (quad.vertices[0].y < bottom) bottom = quad.vertices[0].y; @@ -415,21 +415,21 @@ void StandardLayout::layout(const Data* text, const Font& font, TextQuads& quads switch (layout.horizontalAlignment) { - case (BASELINE_ALIGNMENT): alignment.x = 0.0f; break; - case (LEFT_ALIGNMENT): alignment.x = -left; break; - case (CENTER_ALIGNMENT): alignment.x = -(right + left) * 0.5f; break; - case (RIGHT_ALIGNMENT): alignment.x = -right; break; + case (BASELINE_ALIGNMENT): glyphAlignment.x = 0.0f; break; + case (LEFT_ALIGNMENT): glyphAlignment.x = -left; break; + case (CENTER_ALIGNMENT): glyphAlignment.x = -(right + left) * 0.5f; break; + case (RIGHT_ALIGNMENT): glyphAlignment.x = -right; break; } switch (layout.verticalAlignment) { - case (BASELINE_ALIGNMENT): alignment.y = 0.0f; break; - case (TOP_ALIGNMENT): alignment.y = -top; break; - case (CENTER_ALIGNMENT): alignment.y = -(bottom + top) * 0.5f; break; - case (BOTTOM_ALIGNMENT): alignment.y = -bottom; break; + case (BASELINE_ALIGNMENT): glyphAlignment.y = 0.0f; break; + case (TOP_ALIGNMENT): glyphAlignment.y = -top; break; + case (CENTER_ALIGNMENT): glyphAlignment.y = -(bottom + top) * 0.5f; break; + case (BOTTOM_ALIGNMENT): glyphAlignment.y = -bottom; break; } - offset = layout.horizontal * alignment.x + layout.vertical * alignment.y; + offset = layout.horizontal * glyphAlignment.x + layout.vertical * glyphAlignment.y; } if (!layout.billboard) diff --git a/src/vsg/text/TextGroup.cpp b/src/vsg/text/TextGroup.cpp index 426c6e9db..9ff7468d5 100644 --- a/src/vsg/text/TextGroup.cpp +++ b/src/vsg/text/TextGroup.cpp @@ -26,7 +26,7 @@ int TextGroup::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); return compare_pointer_container(children, rhs.children); } diff --git a/src/vsg/threading/OperationThreads.cpp b/src/vsg/threading/OperationThreads.cpp index 3f5e8cb30..9d3803519 100644 --- a/src/vsg/threading/OperationThreads.cpp +++ b/src/vsg/threading/OperationThreads.cpp @@ -21,7 +21,7 @@ OperationThreads::OperationThreads(uint32_t numThreads, ref_ptr if (!status) status = ActivityStatus::create(); queue = OperationQueue::create(status); - auto run = [](ref_ptr q, ref_ptr thread_status) { + auto runThread = [](ref_ptr q, ref_ptr thread_status) { while (thread_status->active()) { ref_ptr operation = q->take_when_available(); @@ -34,7 +34,7 @@ OperationThreads::OperationThreads(uint32_t numThreads, ref_ptr for (size_t i = 0; i < numThreads; ++i) { - threads.emplace_back(run, queue, status); + threads.emplace_back(runThread, queue, status); } } diff --git a/src/vsg/utils/Builder.cpp b/src/vsg/utils/Builder.cpp index fa42739c1..19b5f035f 100644 --- a/src/vsg/utils/Builder.cpp +++ b/src/vsg/utils/Builder.cpp @@ -91,7 +91,7 @@ ref_ptr Builder::createStateGroup(const StateInfo& stateInfo) graphicsPipelineConfig->assignTexture("displacementMap", stateInfo.displacementMap, sampler); } - if (auto& materialBinding = activeShaderSet->getDescriptorBinding("material")) + if (const auto& materialBinding = activeShaderSet->getDescriptorBinding("material")) { ref_ptr mat = materialBinding.data; if (!mat) mat = vsg::PhongMaterialValue::create(); @@ -247,7 +247,7 @@ ref_ptr Builder::decorateAndCompileIfRequired(const GeometryInfo& info, co if (auto v3a = info.positions.cast()) { box bound; - for (auto& v : *v3a) + for (const auto& v : *v3a) { bound.add(v); } diff --git a/src/vsg/utils/GraphicsPipelineConfigurator.cpp b/src/vsg/utils/GraphicsPipelineConfigurator.cpp index 4b03f9634..072ed0cdb 100644 --- a/src/vsg/utils/GraphicsPipelineConfigurator.cpp +++ b/src/vsg/utils/GraphicsPipelineConfigurator.cpp @@ -100,7 +100,7 @@ int DescriptorConfigurator::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_pointer(shaderSet, rhs.shaderSet))) return result; if ((result = compare_value(blending, rhs.blending))) return result; @@ -252,7 +252,7 @@ bool DescriptorConfigurator::assignDefaults(const std::set& inheritedS if (descriptorBinding.define.empty() && assigned.count(descriptorBinding.name) == 0) { bool set_matched = false; - for (auto& cds : shaderSet->customDescriptorSetBindings) + for (const auto& cds : shaderSet->customDescriptorSetBindings) { if (cds->set == descriptorBinding.set) { @@ -310,7 +310,7 @@ int ArrayConfigurator::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_pointer(shaderSet, rhs.shaderSet))) return result; if ((result = compare_value(baseAttributeBinding, rhs.baseAttributeBinding))) return result; @@ -493,7 +493,7 @@ int GraphicsPipelineConfigurator::compare(const Object& rhs_object) const int result = Object::compare(rhs_object); if (result != 0) return result; - auto& rhs = static_cast(rhs_object); + const auto& rhs = static_cast(rhs_object); if ((result = compare_pointer_container(pipelineStates, rhs.pipelineStates))) return result; @@ -599,7 +599,7 @@ bool GraphicsPipelineConfigurator::copyTo(StateCommands& stateCommands, ref_ptr< bool stateAssigned = false; bool pipelineUnique = true; - for (auto& sc : inheritedState) + for (const auto& sc : inheritedState) { if (compare_pointer(sc, bindGraphicsPipeline) == 0) pipelineUnique = false; } @@ -632,7 +632,7 @@ bool GraphicsPipelineConfigurator::copyTo(StateCommands& stateCommands, ref_ptr< auto bindDescriptorSet = BindDescriptorSet::create(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, static_cast(set), ds); bool dsUnique = true; - for (auto& sc : inheritedState) + for (const auto& sc : inheritedState) { if (compare_pointer(sc, bindDescriptorSet) == 0) dsUnique = false; }