Skip to content

Commit 4ab1eed

Browse files
committed
Minor code cleanup
1 parent a618ba5 commit 4ab1eed

File tree

8 files changed

+25
-16
lines changed

8 files changed

+25
-16
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Descriptor Heap is a platform abstraction of DirectX 12 descriptor heaps.
3434

3535
#include <magic_enum/magic_enum.hpp>
3636
#include <directx/d3dx12_root_signature.h>
37+
#include <ranges>
3738
#include <cassert>
3839

3940
namespace Methane::Graphics::DirectX
@@ -56,7 +57,7 @@ DescriptorHeapReservation::DescriptorHeapReservation(const Ref<DescriptorHeap>&
5657
: heap(heap)
5758
{
5859
META_FUNCTION_TASK();
59-
std::fill(ranges.begin(), ranges.end(), DescriptorHeap::Range(0, 0));
60+
std::ranges::fill(ranges, DescriptorHeap::Range(0, 0));
6061
}
6162

6263
DescriptorHeapReservation::DescriptorHeapReservation(const Ref<DescriptorHeap>& heap, const Ranges& ranges)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ DirectX 12 implementation of the program bindings interface.
3737
#include <Methane/Checks.hpp>
3838

3939
#include <magic_enum/magic_enum.hpp>
40+
#include <ranges>
4041

4142
namespace Methane::Graphics::DirectX
4243
{
4344

4445
DescriptorsCountByAccess::DescriptorsCountByAccess()
4546
{
46-
std::fill(m_count_by_access_type.begin(), m_count_by_access_type.end(), 0U);
47+
std::ranges::fill(m_count_by_access_type, 0U);
4748
}
4849

4950
uint32_t& DescriptorsCountByAccess::operator[](Rhi::ProgramArgumentAccessType access_type)

Modules/Graphics/RHI/Impl/Sources/Methane/Graphics/RHI/System.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ std::string System::ToString() const
104104
const Devices& System::UpdateDevices(const Ptrs<Rhi::IDevice>& devices) const
105105
{
106106
m_devices.clear();
107-
std::ranges::transform(devices.cbegin(), devices.cend(), std::back_inserter(m_devices),
108-
[](const Ptr<Rhi::IDevice>& device_ptr)
109-
{ return Device(device_ptr); });
107+
std::ranges::transform(devices, std::back_inserter(m_devices),
108+
[](const Ptr<Rhi::IDevice>& device_ptr)
109+
{ return Device(device_ptr); });
110110
return m_devices;
111111
}
112112

Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/Sampler.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ namespace Methane::Graphics::Metal
3434

3535
struct IContext;
3636

37-
class Sampler final : public Resource<Base::Sampler>
37+
class Sampler final
38+
: public Resource<Base::Sampler>
3839
{
3940
public:
4041
Sampler(const Base::Context& context, const Settings& settings);

Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Program.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include <Methane/Instrumentation.h>
3636
#include <Methane/Checks.hpp>
3737

38+
#include <ranges>
39+
3840
#if defined(__MAC_15_0) || defined(__IPHONE_18_0)
3941
#define MTL_PIPELINE_OPTION_BINDING_INFO MTLPipelineOptionBindingInfo
4042
#else
@@ -182,7 +184,7 @@
182184
{
183185
META_FUNCTION_TASK();
184186
m_shader_argument_buffer_layouts.clear();
185-
std::fill(m_arguments_range_size_by_access_type.begin(), m_arguments_range_size_by_access_type.end(), 0U);
187+
std::ranges::fill(m_arguments_range_size_by_access_type, 0U);
186188

187189
ForEachShader([this](const Base::Shader& shader)
188190
{
@@ -221,7 +223,7 @@
221223
? dynamic_cast<const Rhi::IRenderContext&>(context).GetSettings().frame_buffers_count
222224
: 1U;
223225
m_frame_constant_argument_buffer_ranges.resize(frames_count);
224-
std::fill(m_frame_constant_argument_buffer_ranges.begin(), m_frame_constant_argument_buffer_ranges.end(), ArgumentsRange{});
226+
std::ranges::fill(m_frame_constant_argument_buffer_ranges, ArgumentsRange{});
225227

226228
if (const Data::Size frame_const_args_range_size = GetArgumentsBufferRangeSize(Rhi::ProgramArgumentAccessType::FrameConstant))
227229
{

Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/ProgramBindings.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include <Methane/Instrumentation.h>
3535
#include <Methane/Checks.hpp>
3636

37+
#include <ranges>
38+
3739
namespace Methane::Graphics::Metal
3840
{
3941

@@ -747,7 +749,7 @@ static void WriteArgumentBindingResourceIds(const ProgramArgumentBinding& arg_bi
747749
const auto& program = GetMetalProgram();
748750
auto& descriptor_manager = static_cast<DescriptorManager&>(program.GetContext().GetDescriptorManager());
749751
std::array<Data::Size, magic_enum::enum_count<Rhi::ProgramArgumentAccessType>()> arg_layout_offset_by_buffer;
750-
std::fill(arg_layout_offset_by_buffer.begin(), arg_layout_offset_by_buffer.end(), 0U);
752+
std::ranges::fill(arg_layout_offset_by_buffer, 0U);
751753

752754
for(const Program::ShaderArgumentBufferLayout& arg_layout : program.GetShaderArgumentBufferLayouts())
753755
{

Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Shader.mm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ static MTLVertexStepFunction GetVertexStepFunction(Rhi::ProgramInputBufferLayout
6868
META_FUNCTION_TASK();
6969
switch(mtl_arg_type)
7070
{
71-
case MTLBindingTypeBuffer: return Rhi::ResourceType::Buffer;
72-
case MTLBindingTypeTexture: return Rhi::ResourceType::Texture;
73-
case MTLBindingTypeSampler: return Rhi::ResourceType::Sampler;
71+
using enum Rhi::ResourceType;
72+
case MTLBindingTypeBuffer: return Buffer;
73+
case MTLBindingTypeTexture: return Texture;
74+
case MTLBindingTypeSampler: return Sampler;
7475
default: META_UNEXPECTED_RETURN(mtl_arg_type, IResource::Type::Buffer);
7576
}
7677
}
@@ -103,9 +104,10 @@ static uint32_t GetBindingBufferSize(id<MTLBinding> mtl_binding)
103104
META_FUNCTION_TASK();
104105
switch(mtl_data_type)
105106
{
106-
case MTLDataTypePointer: return Rhi::ResourceType::Buffer;
107-
case MTLDataTypeTexture: return Rhi::ResourceType::Texture;
108-
case MTLDataTypeSampler: return Rhi::ResourceType::Sampler;
107+
using enum Rhi::ResourceType;
108+
case MTLDataTypePointer: return Buffer;
109+
case MTLDataTypeTexture: return Texture;
110+
case MTLDataTypeSampler: return Sampler;
109111
default: META_UNEXPECTED_RETURN(mtl_data_type, Rhi::ResourceType::Buffer);
110112
}
111113
}

Modules/UserInterface/Typography/Sources/Methane/UserInterface/FontImpl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ class Font::Impl // NOSONAR - class destructor is required, class has more than
467467

468468
// Sort chars by decreasing of glyph pixels count from largest to smallest
469469
std::ranges::sort(font_chars,
470-
[](const Ref<Char>& left, const Ref<Char>& right)
470+
[](Ref<Char> left, Ref<Char> right)
471471
{ return left.get() > right.get(); }
472472
);
473473

0 commit comments

Comments
 (0)