Skip to content

Commit a618ba5

Browse files
committed
Fix remaining Sonar Scanner issues continued
1 parent 5e068be commit a618ba5

38 files changed

Lines changed: 495 additions & 424 deletions

File tree

Modules/Graphics/Mesh/Include/Methane/Graphics/CubeMesh.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class CubeMesh : public QuadMesh<VType>
6161
BaseMeshT::AppendVertices(face_mesh.GetVertices());
6262

6363
const Mesh::Indices& face_indices = face_mesh.GetIndices();
64-
std::transform(face_indices.begin(), face_indices.end(), Mesh::GetIndicesBackInserter(),
64+
std::ranges::transform(face_indices, Mesh::GetIndicesBackInserter(),
6565
[initial_vertices_count](const Mesh::Index& index)
6666
{
6767
return static_cast<Mesh::Index>(initial_vertices_count + index);

Modules/Graphics/Mesh/Include/Methane/Graphics/UberMesh.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class UberMesh : public BaseMesh<VType>
5757
META_CHECK_LESS(vertex_count, std::numeric_limits<Mesh::Index>::max());
5858

5959
const auto index_offset = static_cast<Mesh::Index>(vertex_count);
60-
std::transform(sub_indices.begin(), sub_indices.end(), BaseMeshT::GetIndicesBackInserter(),
60+
std::ranges::transform(sub_indices, BaseMeshT::GetIndicesBackInserter(),
6161
[index_offset](const Mesh::Index& index)
6262
{
6363
META_CHECK_LESS(index_offset, std::numeric_limits<Mesh::Index>::max() - index);

Modules/Graphics/RHI/Base/Sources/Methane/Graphics/Base/DescriptorManager.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Base descriptor manager implementation.
2828
#include <Methane/Instrumentation.h>
2929

3030
#include <taskflow/algorithm/for_each.hpp>
31+
#include <ranges>
3132

3233
namespace Methane::Graphics::Base
3334
{
@@ -55,12 +56,12 @@ void DescriptorManager::ReleaseExpiredProgramBindings()
5556
META_FUNCTION_TASK();
5657
std::scoped_lock lock_guard(m_program_bindings_mutex);
5758

58-
const auto program_bindings_end_it = std::remove_if(m_program_bindings.begin(), m_program_bindings.end(),
59+
const auto remove_range = std::ranges::remove_if(m_program_bindings,
5960
[](const WeakPtr<Rhi::IProgramBindings>& program_bindings_wptr)
6061
{ return program_bindings_wptr.expired(); }
6162
);
6263

63-
m_program_bindings.erase(program_bindings_end_it, m_program_bindings.end());
64+
m_program_bindings.erase(remove_range.begin(), remove_range.end());
6465
}
6566

6667
void DescriptorManager::CompleteProgramBindingsInitialization()
@@ -99,7 +100,7 @@ void DescriptorManager::AddProgramBindings(Rhi::IProgramBindings& program_bindin
99100
#ifdef _DEBUG
100101
// This may cause performance drop on adding massive amount of program bindings,
101102
// so we assume that only different program bindings are added and check it in Debug builds only
102-
const auto program_bindings_it = std::find_if(m_program_bindings.begin(), m_program_bindings.end(),
103+
const auto program_bindings_it = std::ranges::find_if(m_program_bindings,
103104
[&program_bindings](const WeakPtr<Rhi::IProgramBindings>& program_bindings_ptr)
104105
{ return !program_bindings_ptr.expired() && program_bindings_ptr.lock().get() == std::addressof(program_bindings); }
105106
);

Modules/Graphics/RHI/Base/Sources/Methane/Graphics/Base/Program.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Base implementation of the program interface.
2828

2929
#include <magic_enum/magic_enum.hpp>
3030
#include <algorithm>
31+
#include <ranges>
3132

3233
namespace Methane::Graphics::Base
3334
{
@@ -165,7 +166,7 @@ void Program::InitFrameConstantArgumentBindings()
165166
if (m_context.GetType() != Rhi::IContext::Type::Render)
166167
{
167168
const auto frame_constant_binding_by_arg_it =
168-
std::find_if(m_binding_by_argument.begin(), m_binding_by_argument.end(),
169+
std::ranges::find_if(m_binding_by_argument,
169170
[](const std::pair<Rhi::ProgramArgument, Ptr<ArgumentBinding>>& arg_binding)
170171
{ return arg_binding.second->GetSettings().argument.IsFrameConstant(); });
171172
META_CHECK_TRUE_DESCR(frame_constant_binding_by_arg_it == m_binding_by_argument.end(),
@@ -273,7 +274,7 @@ uint32_t Program::GetInputBufferIndexByArgumentSemantic(const std::string& argum
273274
for (size_t buffer_index = 0; buffer_index < m_settings.input_buffer_layouts.size(); buffer_index++)
274275
{
275276
const InputBufferLayout& input_buffer_layout = m_settings.input_buffer_layouts[buffer_index];
276-
if (auto argument_it = std::find(input_buffer_layout.argument_semantics.begin(), input_buffer_layout.argument_semantics.end(), argument_semantic);
277+
if (auto argument_it = std::ranges::find(input_buffer_layout.argument_semantics, argument_semantic);
277278
argument_it != input_buffer_layout.argument_semantics.end())
278279
return static_cast<uint32_t>(buffer_index);
279280
}

Modules/Graphics/RHI/Base/Sources/Methane/Graphics/Base/RenderPattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ AttachmentFormats RenderPattern::GetAttachmentFormats() const noexcept
6666
AttachmentFormats attachment_formats;
6767

6868
attachment_formats.colors.reserve(m_settings.color_attachments.size());
69-
std::transform(m_settings.color_attachments.begin(), m_settings.color_attachments.end(), std::back_inserter(attachment_formats.colors),
69+
std::ranges::transform(m_settings.color_attachments, std::back_inserter(attachment_formats.colors),
7070
[](const ColorAttachment& color_attachment) { return color_attachment.format; });
7171

7272
if (m_settings.depth_attachment)

Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/BufferSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static std::vector<D3D12_VERTEX_BUFFER_VIEW> GetNativeVertexBufferViews(const Re
4747
{
4848
META_FUNCTION_TASK();
4949
std::vector<D3D12_VERTEX_BUFFER_VIEW> vertex_buffer_views;
50-
std::transform(buffer_refs.begin(), buffer_refs.end(), std::back_inserter(vertex_buffer_views),
50+
std::ranges::transform(buffer_refs, std::back_inserter(vertex_buffer_views),
5151
[](const Ref<Rhi::IBuffer>& buffer_ref)
5252
{
5353
const auto& buffer = static_cast<const Buffer&>(buffer_ref.get());

Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/DescriptorManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Descriptor manager is a central place for creating and accessing descriptor heap
2828
#include <Methane/Checks.hpp>
2929

3030
#include <magic_enum/magic_enum.hpp>
31+
#include <ranges>
3132

3233
namespace Methane::Graphics::DirectX
3334
{
@@ -151,7 +152,7 @@ DescriptorHeap& DescriptorManager::GetDefaultShaderVisibleDescriptorHeap(Descrip
151152
"can not get reference to 'Undefined' descriptor heap");
152153

153154
const UniquePtrs<DescriptorHeap>& descriptor_heaps = m_descriptor_heap_types[magic_enum::enum_integer(type)];
154-
auto descriptor_heaps_it = std::find_if(descriptor_heaps.begin(), descriptor_heaps.end(),
155+
auto descriptor_heaps_it = std::ranges::find_if(descriptor_heaps,
155156
[](const UniquePtr<DescriptorHeap>& descriptor_heap_ptr)
156157
{
157158
META_CHECK_NOT_NULL(descriptor_heap_ptr);

Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ProgramArgumentBinding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ bool ProgramArgumentBinding::UpdateRootConstantResourceViews()
178178
const Rhi::ResourceViews& resource_views = (Base::ProgramArgumentBinding::GetResourceViews());
179179
m_resource_views_dx.clear();
180180

181-
std::transform(resource_views.begin(), resource_views.end(), std::back_inserter(m_resource_views_dx),
181+
std::ranges::transform(resource_views, std::back_inserter(m_resource_views_dx),
182182
[this](const Rhi::ResourceView& resource_view)
183183
{ return ResourceView(resource_view, m_shader_usage); });
184184

Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderPass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ RenderPass::RenderPass(Base::RenderPattern& render_pattern, const Settings& sett
186186
, m_dx_context(static_cast<const RenderContext&>(render_pattern.GetBaseRenderContext()))
187187
{
188188
META_FUNCTION_TASK();
189-
std::transform(settings.attachments.begin(), settings.attachments.end(), std::back_inserter(m_dx_attachments),
189+
std::ranges::transform(settings.attachments, std::back_inserter(m_dx_attachments),
190190
[](const Rhi::ITexture::View& texture_location)
191191
{ return ResourceView(texture_location, Rhi::ResourceUsageMask({ Rhi::ResourceUsage::RenderTarget })); });
192192

@@ -216,7 +216,7 @@ bool RenderPass::Update(const Settings& settings)
216216
m_begin_transition_barriers_ptr.reset();
217217
m_end_transition_barriers_ptr.reset();
218218

219-
std::transform(settings.attachments.begin(), settings.attachments.end(), std::back_inserter(m_dx_attachments),
219+
std::ranges::transform(settings.attachments, std::back_inserter(m_dx_attachments),
220220
[](const Rhi::ITexture::View& texture_location)
221221
{ return ResourceView(texture_location, Rhi::ResourceUsageMask({ Rhi::ResourceUsage::RenderTarget })); });
222222
}

Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ResourceBarriers.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ DirectX 12 specialization of the resource barriers.
2828
#include <Methane/Checks.hpp>
2929

3030
#include <directx/d3dx12_barriers.h>
31+
#include <ranges>
3132

3233
namespace Methane::Graphics::Rhi
3334
{
@@ -142,7 +143,7 @@ bool ResourceBarriers::Remove(const Barrier::Id& id)
142143

143144
const D3D12_RESOURCE_BARRIER_TYPE native_barrier_type = GetNativeBarrierType(id.GetType());
144145
const ID3D12Resource* native_resource_ptr = dynamic_cast<const IResource&>(id.GetResource()).GetNativeResource();
145-
const auto native_resource_barrier_it = std::find_if(m_native_resource_barriers.begin(), m_native_resource_barriers.end(),
146+
const auto native_resource_barrier_it = std::ranges::find_if(m_native_resource_barriers,
146147
GetNativeResourceBarrierPredicate(native_barrier_type, native_resource_ptr));
147148
META_CHECK_TRUE_DESCR(native_resource_barrier_it != m_native_resource_barriers.end(), "can not find DX resource barrier to update");
148149
m_native_resource_barriers.erase(native_resource_barrier_it);
@@ -169,7 +170,7 @@ void ResourceBarriers::UpdateNativeResourceBarrier(const Barrier::Id& id, const
169170
META_FUNCTION_TASK();
170171
const D3D12_RESOURCE_BARRIER_TYPE native_barrier_type = GetNativeBarrierType(id.GetType());
171172
const ID3D12Resource* native_resource_ptr = dynamic_cast<const IResource&>(id.GetResource()).GetNativeResource();
172-
const auto native_resource_barrier_it = std::find_if(m_native_resource_barriers.begin(), m_native_resource_barriers.end(),
173+
const auto native_resource_barrier_it = std::ranges::find_if(m_native_resource_barriers,
173174
GetNativeResourceBarrierPredicate(native_barrier_type, native_resource_ptr));
174175
META_CHECK_TRUE_DESCR(native_resource_barrier_it != m_native_resource_barriers.end(), "can not find DX resource barrier to update");
175176

0 commit comments

Comments
 (0)