From 3dd64782ff724df7f23c97120479b8be49d3f22e Mon Sep 17 00:00:00 2001 From: Evgeny Gorodetsky Date: Fri, 20 Sep 2024 00:15:08 +0300 Subject: [PATCH] Rename pointer variables to follow code convention with _ptr suffix --- .../Include/Methane/IttApiHelper.h | 61 ++++++++------- .../Include/Methane/TracyGpu.hpp | 12 +-- .../Include/Methane/Data/AlignedAllocator.hpp | 6 +- .../Include/Methane/Graphics/ArcBallCamera.h | 8 +- .../Methane/Graphics/ArcBallCamera.cpp | 29 ++++--- .../Sources/Methane/Graphics/ImageLoader.cpp | 18 ++--- .../Methane/Graphics/Base/RenderPass.h | 4 +- .../Methane/Graphics/Base/RenderPass.cpp | 30 +++---- .../Include/Methane/Graphics/DirectX/Buffer.h | 2 +- .../Methane/Graphics/DirectX/CommandList.hpp | 56 ++++++------- .../Methane/Graphics/DirectX/CommandQueue.h | 2 +- .../Methane/Graphics/DirectX/ComputeState.h | 2 +- .../Methane/Graphics/DirectX/Context.hpp | 14 ++-- .../Methane/Graphics/DirectX/DescriptorHeap.h | 4 +- .../Include/Methane/Graphics/DirectX/Device.h | 14 ++-- .../Methane/Graphics/DirectX/ErrorHandling.h | 4 +- .../Include/Methane/Graphics/DirectX/Fence.h | 2 +- .../Methane/Graphics/DirectX/Program.h | 4 +- .../Graphics/DirectX/ProgramArgumentBinding.h | 6 +- .../Graphics/DirectX/ProgramBindings.h | 4 +- .../Methane/Graphics/DirectX/RenderContext.h | 4 +- .../Methane/Graphics/DirectX/RenderState.h | 2 +- .../Methane/Graphics/DirectX/Resource.hpp | 39 +++++----- .../Include/Methane/Graphics/DirectX/Shader.h | 4 +- .../Include/Methane/Graphics/DirectX/System.h | 6 +- .../Methane/Graphics/DirectX/Texture.h | 4 +- .../Methane/Graphics/DirectX/Buffer.cpp | 18 ++--- .../Methane/Graphics/DirectX/CommandQueue.cpp | 20 ++--- .../Methane/Graphics/DirectX/ComputeState.cpp | 23 +++--- .../Graphics/DirectX/DescriptorHeap.cpp | 26 +++---- .../Methane/Graphics/DirectX/Device.cpp | 32 ++++---- .../Methane/Graphics/DirectX/Fence.cpp | 24 +++--- .../Methane/Graphics/DirectX/Program.cpp | 11 +-- .../DirectX/ProgramArgumentBinding.cpp | 49 ++++++------ .../Graphics/DirectX/ProgramBindings.cpp | 30 +++---- .../Graphics/DirectX/RenderCommandList.cpp | 8 +- .../Graphics/DirectX/RenderContext.cpp | 39 +++++----- .../Methane/Graphics/DirectX/RenderPass.cpp | 16 ++-- .../Methane/Graphics/DirectX/RenderState.cpp | 22 +++--- .../Methane/Graphics/DirectX/Sampler.cpp | 14 ++-- .../Methane/Graphics/DirectX/Shader.cpp | 22 +++--- .../Methane/Graphics/DirectX/System.cpp | 52 ++++++------- .../Methane/Graphics/DirectX/Texture.cpp | 48 ++++++------ .../Graphics/RHI/IResourceBarriers.cpp | 12 +-- .../Methane/Graphics/Vulkan/ProgramBindings.h | 2 +- .../Graphics/Vulkan/ProgramBindings.cpp | 4 +- .../Sources/Methane/Platform/Linux/AppLin.cpp | 6 +- .../Methane/Platform/MacOS/AppDelegate.hh | 2 +- .../Methane/Platform/MacOS/AppDelegate.mm | 28 +++---- .../Sources/Methane/Platform/MacOS/AppMac.mm | 4 +- .../Platform/MacOS/AppViewController.hh | 2 +- .../Platform/MacOS/AppViewController.mm | 78 +++++++++---------- .../Methane/Platform/MacOS/WindowDelegate.hh | 2 +- .../Methane/Platform/MacOS/WindowDelegate.mm | 38 ++++----- .../Methane/Platform/Windows/AppWin.cpp | 50 ++++++------ .../Methane/Platform/iOS/AppDelegate.mm | 8 +- .../Methane/Platform/iOS/AppViewController.hh | 2 +- .../Methane/Platform/iOS/AppViewController.mm | 34 ++++---- .../Include/Methane/Platform/AppView.h | 2 +- .../Methane/Platform/MacOS/AppViewMetal.mm | 10 +-- .../Include/Methane/Platform/Apple/Types.hh | 4 +- .../Methane/UserInterface/TextMesh.cpp | 18 ++--- 62 files changed, 554 insertions(+), 547 deletions(-) diff --git a/Modules/Common/Instrumentation/Include/Methane/IttApiHelper.h b/Modules/Common/Instrumentation/Include/Methane/IttApiHelper.h index b8e3fdcbe..022fe5251 100644 --- a/Modules/Common/Instrumentation/Include/Methane/IttApiHelper.h +++ b/Modules/Common/Instrumentation/Include/Methane/IttApiHelper.h @@ -51,46 +51,47 @@ namespace Methane::ITT class Event { public: - Event(const __itt_domain* p_domain, __itt_string_handle* p_name) noexcept - : m_id(__itt_id_make(const_cast<__itt_domain*>(p_domain), reinterpret_cast(p_name))) // NOSONAR - , m_p_domain(p_domain) + Event(const __itt_domain* domain_ptr, __itt_string_handle* name_ptr) noexcept + : m_id(__itt_id_make(const_cast<__itt_domain*>(domain_ptr), reinterpret_cast(name_ptr))) // NOSONAR + , m_domain_ptr(domain_ptr) { } template - typename std::enable_if, void>::type AddArg(__itt_string_handle* p_name, const T& value) const noexcept + typename std::enable_if, void>::type + AddArg(__itt_string_handle* name_ptr, const T& value) const noexcept { double double_value = static_cast(value); - __itt_metadata_add(m_p_domain, m_id, p_name, __itt_metadata_double, 1, &double_value); + __itt_metadata_add(m_domain_ptr, m_id, name_ptr, __itt_metadata_double, 1, &double_value); } - void AddArg(__itt_string_handle* p_name, int64_t value) const noexcept + void AddArg(__itt_string_handle* name_ptr, int64_t value) const noexcept { - __itt_metadata_add(m_p_domain, m_id, p_name, __itt_metadata_s64, 1, &value); + __itt_metadata_add(m_domain_ptr, m_id, name_ptr, __itt_metadata_s64, 1, &value); } - void AddArg(__itt_string_handle* p_name, const char* value) const noexcept + void AddArg(__itt_string_handle* name_ptr, const char* value) const noexcept { #if ITT_PLATFORM==ITT_PLATFORM_WIN && (defined(UNICODE) || defined(_UNICODE)) // string value must be converted to wchar_t - __itt_metadata_str_add(m_p_domain, m_id, p_name, nowide::widen(value).c_str(), 0); + __itt_metadata_str_add(m_domain_ptr, m_id, name_ptr, nowide::widen(value).c_str(), 0); #else - __itt_metadata_str_add(m_p_domain, m_id, p_name, value, 0); + __itt_metadata_str_add(m_domain_ptr, m_id, name_ptr, value, 0); #endif } - void AddArg(__itt_string_handle* p_name, void const* const p_value) const noexcept + void AddArg(__itt_string_handle* name_ptr, void const* const value_ptr) const noexcept { - __itt_metadata_add(m_p_domain, m_id, p_name, __itt_metadata_unknown, 1, const_cast(p_value)); + __itt_metadata_add(m_domain_ptr, m_id, name_ptr, __itt_metadata_unknown, 1, const_cast(value_ptr)); } - void AddArg(__itt_string_handle* p_name, const std::string& value) const noexcept + void AddArg(__itt_string_handle* name_ptr, const std::string& value) const noexcept { - AddArg(p_name, value.c_str()); + AddArg(name_ptr, value.c_str()); } protected: __itt_id m_id = __itt_null; - const __itt_domain* m_p_domain; + const __itt_domain* m_domain_ptr; }; class Marker : public Event @@ -104,23 +105,23 @@ class Marker : public Event Task = __itt_scope_task, //means a task that will long until another marker with task scope in this thread occurs }; - Marker(const __itt_domain* p_domain, const char* p_name, Scope scope) noexcept - : Marker(p_domain, UNICODE_AGNOSTIC(__itt_string_handle_create)(p_name), scope) + Marker(const __itt_domain* domain_ptr, const char* name_ptr, Scope scope) noexcept + : Marker(domain_ptr, UNICODE_AGNOSTIC(__itt_string_handle_create)(name_ptr), scope) { } void Notify() const noexcept { - __itt_marker(m_p_domain, m_id, m_p_name, m_scope); + __itt_marker(m_domain_ptr, m_id, m_name_ptr, m_scope); } private: - Marker(const __itt_domain* p_domain, __itt_string_handle* p_itt_name, Scope scope) noexcept - : Event(p_domain, p_itt_name) - , m_p_name(p_itt_name) + Marker(const __itt_domain* domain_ptr, __itt_string_handle* itt_name_ptr, Scope scope) noexcept + : Event(domain_ptr, itt_name_ptr) + , m_name_ptr(itt_name_ptr) , m_scope(static_cast<__itt_scope>(scope)) { } - __itt_string_handle* m_p_name; + __itt_string_handle* m_name_ptr; __itt_scope m_scope; }; @@ -128,16 +129,16 @@ template class Task : public Event { public: - Task(const __itt_domain* p_domain, __itt_string_handle* p_name) noexcept - : Event(p_domain, p_name) + Task(const __itt_domain* domain_ptr, __itt_string_handle* name_ptr) noexcept + : Event(domain_ptr, name_ptr) { if (bRegion) { - __itt_region_begin(m_p_domain, m_id, __itt_null, p_name); + __itt_region_begin(m_domain_ptr, m_id, __itt_null, name_ptr); } else { - __itt_task_begin(m_p_domain, m_id, __itt_null, p_name); + __itt_task_begin(m_domain_ptr, m_id, __itt_null, name_ptr); } } @@ -145,11 +146,11 @@ class Task : public Event { if (bRegion) { - __itt_region_end(m_p_domain, m_id); + __itt_region_end(m_domain_ptr, m_id); } else { - __itt_task_end(m_p_domain); + __itt_task_end(m_domain_ptr); } } }; @@ -168,8 +169,8 @@ template class Counter { public: - Counter(const char* p_name, const char* p_domain) noexcept - : m_id(UNICODE_AGNOSTIC(__itt_counter_create_typed)(p_name, p_domain, GetMetadataType(ValueType{}))) + Counter(const char* name_ptr, const char* domain_ptr) noexcept + : m_id(UNICODE_AGNOSTIC(__itt_counter_create_typed)(name_ptr, domain_ptr, GetMetadataType(ValueType{}))) { } Counter(Counter&& other) : m_id(std::move(other.m_id)) {} ~Counter() { __itt_counter_destroy(m_id); } diff --git a/Modules/Common/Instrumentation/Include/Methane/TracyGpu.hpp b/Modules/Common/Instrumentation/Include/Methane/TracyGpu.hpp index 7d3a09bae..e4af51961 100644 --- a/Modules/Common/Instrumentation/Include/Methane/TracyGpu.hpp +++ b/Modules/Common/Instrumentation/Include/Methane/TracyGpu.hpp @@ -396,8 +396,8 @@ class GpuScope #define TRACY_GPU_SCOPE_TYPE Methane::Tracy::GpuScope #define TRACY_GPU_SCOPE_INIT(gpu_context) gpu_context -#define TRACY_GPU_SCOPE_BEGIN_AT_LOCATION(gpu_scope, p_location) \ - gpu_scope.Begin(p_location) +#define TRACY_GPU_SCOPE_BEGIN_AT_LOCATION(gpu_scope, location_ptr) \ + gpu_scope.Begin(location_ptr) #define TRACY_GPU_SCOPE_BEGIN_UNNAMED(gpu_scope) \ gpu_scope.Begin(__LINE__, __FUNCTION__, __FILE__) @@ -405,9 +405,9 @@ class GpuScope #define TRACY_GPU_SCOPE_BEGIN_NAMED(gpu_scope, name) \ gpu_scope.Begin(name, __LINE__, __FUNCTION__, __FILE__) -#define TRACY_GPU_SCOPE_TRY_BEGIN_AT_LOCATION(gpu_scope, p_location) \ +#define TRACY_GPU_SCOPE_TRY_BEGIN_AT_LOCATION(gpu_scope, location_ptr) \ if (gpu_scope.GetState() != Methane::Tracy::GpuScope::State::Begun) \ - gpu_scope.Begin(p_location) + gpu_scope.Begin(location_ptr) #define TRACY_GPU_SCOPE_TRY_BEGIN_UNNAMED(gpu_scope) \ if (gpu_scope.GetState() != Methane::Tracy::GpuScope::State::Begun) \ @@ -461,10 +461,10 @@ struct SourceLocationStub { }; #define TRACY_SOURCE_LOCATION_ALLOC(name) 0U #define TRACY_GPU_SCOPE_TYPE char* /* NOSONAR */ #define TRACY_GPU_SCOPE_INIT(gpu_context) nullptr -#define TRACY_GPU_SCOPE_BEGIN_AT_LOCATION(gpu_scope, p_location) +#define TRACY_GPU_SCOPE_BEGIN_AT_LOCATION(gpu_scope, location_ptr) #define TRACY_GPU_SCOPE_BEGIN_UNNAMED(gpu_scope) #define TRACY_GPU_SCOPE_BEGIN_NAMED(gpu_scope, name) -#define TRACY_GPU_SCOPE_TRY_BEGIN_AT_LOCATION(gpu_scope, p_location) +#define TRACY_GPU_SCOPE_TRY_BEGIN_AT_LOCATION(gpu_scope, location_ptr) #define TRACY_GPU_SCOPE_TRY_BEGIN_UNNAMED(gpu_scope) #define TRACY_GPU_SCOPE_TRY_BEGIN_NAMED(gpu_scope, name) #define TRACY_GPU_SCOPE_BEGIN(gpu_scope, name) diff --git a/Modules/Data/Primitives/Include/Methane/Data/AlignedAllocator.hpp b/Modules/Data/Primitives/Include/Methane/Data/AlignedAllocator.hpp index 07359fd23..081b7cc90 100644 --- a/Modules/Data/Primitives/Include/Methane/Data/AlignedAllocator.hpp +++ b/Modules/Data/Primitives/Include/Methane/Data/AlignedAllocator.hpp @@ -68,10 +68,10 @@ class AlignedAllocator #ifdef WIN32 return static_cast(_aligned_malloc(allocate_size, N)); #else - void* p_memory = nullptr; - if (posix_memalign(&p_memory, N, allocate_size)) + void memory_ptr = nullptr; + if (posix_memalign&memory_ptr, N, allocate_size)) throw std::bad_alloc(); - return static_cast(p_memory); + return static_castGetScreenSize() : GetScreenSize(); + const Data::FloatSize& screen_size = m_view_camera_ptr ? m_view_camera_ptr->GetScreenSize() : GetScreenSize(); const Point2F screen_center(screen_size.GetWidth() / 2.F, screen_size.GetHeight() / 2.F); Point2F screen_point = static_cast(mouse_screen_pos) - screen_center; @@ -101,8 +101,8 @@ ArcBallCamera::SphereProjection ArcBallCamera::GetNormalizedSphereProjection(con const float inside_sphere_sign = inside_sphere ? 1.F : -1.F; // Reflect coordinates for natural camera movement - const Point2F mirror_multipliers = m_p_view_camera - ? Point2F(inside_sphere_sign, -1.F ) * UnitSign(hlslpp::dot(GetLookDirection(m_mouse_pressed_orientation), m_p_view_camera->GetLookDirection())) + const Point2F mirror_multipliers = m_view_camera_ptr + ? Point2F(inside_sphere_sign, -1.F ) * UnitSign(hlslpp::dot(GetLookDirection(m_mouse_pressed_orientation), m_view_camera_ptr->GetLookDirection())) : Point2F(-1.F, 1.F); screen_point.SetX(screen_point.GetX() * mirror_multipliers.GetX()); screen_point.SetY(screen_point.GetY() * mirror_multipliers.GetY()); @@ -148,24 +148,23 @@ void ArcBallCamera::RotateInView(const hlslpp::float3& view_axis, float angle_ra { META_FUNCTION_TASK(); const hlslpp::float4x4 view_rotation_matrix = hlslpp::float4x4::rotation_axis(view_axis, -angle_rad); - const Camera* p_view_camera = GetExternalViewCamera(); + const Camera* view_camera_ptr = GetExternalViewCamera(); - const hlslpp::float4 look_in_view = p_view_camera - ? p_view_camera->TransformWorldToView(hlslpp::float4(GetLookDirection(base_orientation), 1.F)) + const hlslpp::float4 look_in_view = view_camera_ptr + ? view_camera_ptr->TransformWorldToView(hlslpp::float4(GetLookDirection(base_orientation), 1.F)) : hlslpp::float4(0.F, 0.F, GetAimDistance(base_orientation), 1.F); - const hlslpp::float3 look_dir = p_view_camera - ? p_view_camera->TransformViewToWorld(hlslpp::mul(look_in_view, view_rotation_matrix)).xyz + const hlslpp::float3 look_dir = view_camera_ptr + ? view_camera_ptr->TransformViewToWorld(hlslpp::mul(look_in_view, view_rotation_matrix)).xyz : TransformViewToWorld(hlslpp::mul(look_in_view, view_rotation_matrix), base_orientation).xyz; - const hlslpp::float4 up_in_view = p_view_camera - ? p_view_camera->TransformWorldToView(hlslpp::float4(base_orientation.up, 1.F)) + const hlslpp::float4 up_in_view = view_camera_ptr + ? view_camera_ptr->TransformWorldToView(hlslpp::float4(base_orientation.up, 1.F)) : hlslpp::float4(0.F, hlslpp::length(base_orientation.up), 0.F, 1.F); - SetOrientationUp( - p_view_camera - ? p_view_camera->TransformViewToWorld(hlslpp::mul(up_in_view, view_rotation_matrix)).xyz - : TransformViewToWorld(hlslpp::mul(up_in_view, view_rotation_matrix), base_orientation).xyz + SetOrientationUp(view_camera_ptr + ? view_camera_ptr->TransformViewToWorld(hlslpp::mul(up_in_view, view_rotation_matrix)).xyz + : TransformViewToWorld(hlslpp::mul(up_in_view, view_rotation_matrix), base_orientation).xyz ); ApplyLookDirection(look_dir); diff --git a/Modules/Graphics/Primitives/Sources/Methane/Graphics/ImageLoader.cpp b/Modules/Graphics/Primitives/Sources/Methane/Graphics/ImageLoader.cpp index 8f389bdc8..2fec7952d 100644 --- a/Modules/Graphics/Primitives/Sources/Methane/Graphics/ImageLoader.cpp +++ b/Modules/Graphics/Primitives/Sources/Methane/Graphics/ImageLoader.cpp @@ -125,12 +125,12 @@ ImageData ImageLoader::LoadImageData(const std::string& image_path, Data::Size c int image_width = 0; int image_height = 0; int image_channels_count = 0; - stbi_uc* p_image_data = stbi_load_from_memory(reinterpret_cast(raw_image_data.GetDataPtr()), // NOSONAR - static_cast(raw_image_data.GetDataSize()), - &image_width, &image_height, &image_channels_count, - static_cast(channels_count)); + stbi_uc* image_data_ptr = stbi_load_from_memory(reinterpret_cast(raw_image_data.GetDataPtr()), // NOSONAR + static_cast(raw_image_data.GetDataSize()), + &image_width, &image_height, &image_channels_count, + static_cast(channels_count)); - META_CHECK_ARG_NOT_NULL_DESCR(p_image_data, "failed to load image data from memory"); + META_CHECK_ARG_NOT_NULL_DESCR(image_data_ptr, "failed to load image data from memory"); META_CHECK_ARG_GREATER_OR_EQUAL_DESCR(image_width, 1, "invalid image width"); META_CHECK_ARG_GREATER_OR_EQUAL_DESCR(image_height, 1, "invalid image height"); META_CHECK_ARG_GREATER_OR_EQUAL_DESCR(image_channels_count, 1, "invalid image channels count"); @@ -143,16 +143,16 @@ ImageData ImageLoader::LoadImageData(const std::string& image_path, Data::Size c if (create_copy) { - Data::Bytes image_data_copy(reinterpret_cast(p_image_data), // NOSONAR - reinterpret_cast(p_image_data + image_data_size)); // NOSONAR + Data::Bytes image_data_copy(reinterpret_cast(image_data_ptr), // NOSONAR + reinterpret_cast(image_data_ptr + image_data_size)); // NOSONAR ImageData image_data(image_dimensions, static_cast(image_channels_count), Data::Chunk(std::move(image_data_copy))); - stbi_image_free(p_image_data); + stbi_image_free(image_data_ptr); return image_data; } else { return ImageData(image_dimensions, static_cast(image_channels_count), - Data::Chunk(reinterpret_cast(p_image_data), image_data_size)); // NOSONAR + Data::Chunk(reinterpret_cast(image_data_ptr), image_data_size)); // NOSONAR } #endif diff --git a/Modules/Graphics/RHI/Base/Include/Methane/Graphics/Base/RenderPass.h b/Modules/Graphics/RHI/Base/Include/Methane/Graphics/Base/RenderPass.h index b937f10ad..ed535fb3c 100644 --- a/Modules/Graphics/RHI/Base/Include/Methane/Graphics/Base/RenderPass.h +++ b/Modules/Graphics/RHI/Base/Include/Methane/Graphics/Base/RenderPass.h @@ -82,8 +82,8 @@ class RenderPass bool m_is_begun = false; mutable Refs m_color_attachment_textures; mutable Ptrs m_non_frame_buffer_attachment_textures; - mutable Texture* m_p_depth_attachment_texture = nullptr; - mutable Texture* m_p_stencil_attachment_texture = nullptr; + mutable Texture* m_depth_attachment_texture_ptr = nullptr; + mutable Texture* m_stencil_attachment_texture_ptr = nullptr; }; } // namespace Methane::Graphics::Base diff --git a/Modules/Graphics/RHI/Base/Sources/Methane/Graphics/Base/RenderPass.cpp b/Modules/Graphics/RHI/Base/Sources/Methane/Graphics/Base/RenderPass.cpp index b6daf395f..ba5ec0b20 100644 --- a/Modules/Graphics/RHI/Base/Sources/Methane/Graphics/Base/RenderPass.cpp +++ b/Modules/Graphics/RHI/Base/Sources/Methane/Graphics/Base/RenderPass.cpp @@ -51,7 +51,7 @@ bool RenderPass::Update(const Rhi::RenderPassSettings& settings) m_non_frame_buffer_attachment_textures.clear(); m_color_attachment_textures.clear(); - m_p_depth_attachment_texture = nullptr; + m_depth_attachment_texture_ptr = nullptr; InitAttachmentStates(); return true; @@ -115,10 +115,10 @@ void RenderPass::SetAttachmentStates(const Opt& color_state, if (depth_state) { - if (Texture* p_depth_texture = GetDepthAttachmentTexture(); - p_depth_texture) + if (Texture* depth_texture_ptr = GetDepthAttachmentTexture(); + depth_texture_ptr) { - p_depth_texture->SetState(*depth_state); + depth_texture_ptr->SetState(*depth_state); } } } @@ -141,10 +141,10 @@ void RenderPass::SetAttachmentStates(const Opt& color_state, if (depth_state) { - if (Texture* p_depth_texture = GetDepthAttachmentTexture(); - p_depth_texture) + if (Texture* depth_texture_ptr = GetDepthAttachmentTexture(); + depth_texture_ptr) { - attachment_states_changed |= p_depth_texture->SetState(*depth_state, transition_barriers_ptr); + attachment_states_changed |= depth_texture_ptr->SetState(*depth_state, transition_barriers_ptr); } } @@ -180,29 +180,29 @@ const Refs& RenderPass::GetColorAttachmentTextures() const Texture* RenderPass::GetDepthAttachmentTexture() const { META_FUNCTION_TASK(); - if (m_p_depth_attachment_texture) - return m_p_depth_attachment_texture; + if (m_depth_attachment_texture_ptr) + return m_depth_attachment_texture_ptr; const Opt& depth_attachment_opt = GetPattern().GetSettings().depth_attachment; if (!depth_attachment_opt) return nullptr; - m_p_depth_attachment_texture = static_cast(GetAttachmentTextureView(*depth_attachment_opt).GetTexturePtr().get()); - return m_p_depth_attachment_texture; + m_depth_attachment_texture_ptr = static_cast(GetAttachmentTextureView(*depth_attachment_opt).GetTexturePtr().get()); + return m_depth_attachment_texture_ptr; } Texture* RenderPass::GetStencilAttachmentTexture() const { META_FUNCTION_TASK(); - if (m_p_stencil_attachment_texture) - return m_p_stencil_attachment_texture; + if (m_stencil_attachment_texture_ptr) + return m_stencil_attachment_texture_ptr; const Opt& stencil_attachment_opt = GetPattern().GetSettings().stencil_attachment; if (!stencil_attachment_opt) return nullptr; - m_p_stencil_attachment_texture = static_cast(GetAttachmentTextureView(*stencil_attachment_opt).GetTexturePtr().get()); - return m_p_stencil_attachment_texture; + m_stencil_attachment_texture_ptr = static_cast(GetAttachmentTextureView(*stencil_attachment_opt).GetTexturePtr().get()); + return m_stencil_attachment_texture_ptr; } const Ptrs& RenderPass::GetNonFrameBufferAttachmentTextures() const diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Buffer.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Buffer.h index 294ab1b4e..f305a7beb 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Buffer.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Buffer.h @@ -51,7 +51,7 @@ class Buffer final // NOSONAR - inheritance hierarchy is greater than 5 D3D12_CONSTANT_BUFFER_VIEW_DESC GetNativeConstantBufferViewDesc() const; private: - wrl::ComPtr m_cp_upload_resource; + wrl::ComPtr m_upload_resource_cptr; }; } // namespace Methane::Graphics::DirectX diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/CommandList.hpp b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/CommandList.hpp index 956014d32..c71d5082d 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/CommandList.hpp +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/CommandList.hpp @@ -63,12 +63,12 @@ class CommandList : CommandListBaseT(std::forward(construct_args)...) { META_FUNCTION_TASK(); - const wrl::ComPtr& cp_device = GetDirectCommandQueue().GetDirectContext().GetDirectDevice().GetNativeDevice(); - META_CHECK_ARG_NOT_NULL(cp_device); + const wrl::ComPtr& device_cptr = GetDirectCommandQueue().GetDirectContext().GetDirectDevice().GetNativeDevice(); + META_CHECK_ARG_NOT_NULL(device_cptr); - ThrowIfFailed(cp_device->CreateCommandAllocator(command_list_type, IID_PPV_ARGS(&m_cp_command_allocator)), cp_device.Get()); - ThrowIfFailed(cp_device->CreateCommandList(0, command_list_type, m_cp_command_allocator.Get(), nullptr, IID_PPV_ARGS(&m_cp_command_list)), cp_device.Get()); - m_cp_command_list.As(&m_cp_command_list_4); + ThrowIfFailed(device_cptr->CreateCommandAllocator(command_list_type, IID_PPV_ARGS(&m_command_allocator_cptr)), device_cptr.Get()); + ThrowIfFailed(device_cptr->CreateCommandList(0, command_list_type, m_command_allocator_cptr.Get(), nullptr, IID_PPV_ARGS(&m_command_list_cptr)), device_cptr.Get()); + m_command_list_cptr.As(&m_command_list_4_cptr); InitializeTimestampQueries(); BeginGpuZoneDx(); @@ -83,14 +83,14 @@ class CommandList META_FUNCTION_TASK(); CommandListBaseT::PushDebugGroup(debug_group); const std::wstring& group_name = static_cast(debug_group).GetWideName(); - PIXBeginEvent(m_cp_command_list.Get(), 0, group_name.c_str()); + PIXBeginEvent(m_command_list_cptr.Get(), 0, group_name.c_str()); } void PopDebugGroup() final { META_FUNCTION_TASK(); CommandListBaseT::PopDebugGroup(); - PIXEndEvent(m_cp_command_list.Get()); + PIXEndEvent(m_command_list_cptr.Get()); } void Commit() override @@ -101,7 +101,7 @@ class CommandList EndGpuZoneDx(); - m_cp_command_list->Close(); + m_command_list_cptr->Close(); m_is_native_committed = true; } @@ -116,11 +116,11 @@ class CommandList META_LOG("{} Command list '{}' SET RESOURCE BARRIERS:\n{}", magic_enum::enum_name(GetType()), GetName(), static_cast(resource_barriers)); - META_CHECK_ARG_NOT_NULL(m_cp_command_list); + META_CHECK_ARG_NOT_NULL(m_command_list_cptr); const auto& dx_resource_barriers = static_cast(resource_barriers); const std::vector& d3d12_resource_barriers = dx_resource_barriers.GetNativeResourceBarriers(); - m_cp_command_list->ResourceBarrier(static_cast(d3d12_resource_barriers.size()), d3d12_resource_barriers.data()); + m_command_list_cptr->ResourceBarrier(static_cast(d3d12_resource_barriers.size()), d3d12_resource_barriers.data()); } // Rhi::ICommandList interface @@ -134,9 +134,9 @@ class CommandList m_is_native_committed = false; - const wrl::ComPtr& cp_device = GetDirectCommandQueue().GetDirectContext().GetDirectDevice().GetNativeDevice(); - ThrowIfFailed(m_cp_command_allocator->Reset(), cp_device.Get()); - ThrowIfFailed(m_cp_command_list->Reset(m_cp_command_allocator.Get(), nullptr), cp_device.Get()); + const wrl::ComPtr device_cptr = GetDirectCommandQueue().GetDirectContext().GetDirectDevice().GetNativeDevice(); + ThrowIfFailed(m_command_allocator_cptr->Reset(), device_cptr.Get()); + ThrowIfFailed(m_command_list_cptr->Reset(m_command_allocator_cptr.Get(), nullptr), device_cptr.Get()); BeginGpuZoneDx(); @@ -151,11 +151,11 @@ class CommandList if (!CommandListBaseT::SetName(name)) return false; - META_CHECK_ARG_NOT_NULL(m_cp_command_list); - m_cp_command_list->SetName(nowide::widen(name).c_str()); + META_CHECK_ARG_NOT_NULL(m_command_list_cptr); + m_command_list_cptr->SetName(nowide::widen(name).c_str()); - META_CHECK_ARG_NOT_NULL(m_cp_command_allocator); - m_cp_command_allocator->SetName(nowide::widen(fmt::format("{} allocator", name)).c_str()); + META_CHECK_ARG_NOT_NULL(m_command_allocator_cptr); + m_command_allocator_cptr->SetName(nowide::widen(fmt::format("{} allocator", name)).c_str()); return true; } @@ -166,10 +166,10 @@ class CommandList Rhi::CommandListType GetCommandListType() const final { return Base::CommandList::GetType(); } ID3D12GraphicsCommandList& GetNativeCommandList() const final { - META_CHECK_ARG_NOT_NULL(m_cp_command_list); - return *m_cp_command_list.Get(); + META_CHECK_ARG_NOT_NULL(m_command_list_cptr); + return *m_command_list_cptr.Get(); } - ID3D12GraphicsCommandList4* GetNativeCommandList4() const final { return m_cp_command_list_4.Get(); } + ID3D12GraphicsCommandList4* GetNativeCommandList4() const final { return m_command_list_4_cptr.Get(); } protected: void ApplyProgramBindings(Base::ProgramBindings& program_bindings, Rhi::ProgramBindingsApplyBehaviorMask apply_behavior) final @@ -183,14 +183,14 @@ class CommandList ID3D12CommandAllocator& GetNativeCommandAllocatorRef() { - META_CHECK_ARG_NOT_NULL(m_cp_command_allocator); - return *m_cp_command_allocator.Get(); + META_CHECK_ARG_NOT_NULL(m_command_allocator_cptr); + return *m_command_allocator_cptr.Get(); } ID3D12GraphicsCommandList& GetNativeCommandListRef() { - META_CHECK_ARG_NOT_NULL(m_cp_command_list); - return *m_cp_command_list.Get(); + META_CHECK_ARG_NOT_NULL(m_command_list_cptr); + return *m_command_list_cptr.Get(); } void BeginGpuZoneDx() @@ -204,7 +204,7 @@ class CommandList static_cast(__LINE__), __FILE__, strlen(__FILE__), __FUNCTION__, strlen(__FUNCTION__), zone_name.data(), zone_name.length(), - m_cp_command_list.Get(), true); + m_command_list_cptr.Get(), true); #endif } @@ -217,9 +217,9 @@ class CommandList } private: - wrl::ComPtr m_cp_command_allocator; - wrl::ComPtr m_cp_command_list; - wrl::ComPtr m_cp_command_list_4; // extended interface for the same command list (may be unavailable on older Windows) + wrl::ComPtr m_command_allocator_cptr; + wrl::ComPtr m_command_list_cptr; + wrl::ComPtr m_command_list_4_cptr; // extended interface for the same command list (may be unavailable on older Windows) bool m_is_native_committed = false; #if defined(METHANE_GPU_INSTRUMENTATION_ENABLED) && METHANE_GPU_INSTRUMENTATION_ENABLED == 2 diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/CommandQueue.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/CommandQueue.h index a9c10f1c5..6c331e3d8 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/CommandQueue.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/CommandQueue.h @@ -72,7 +72,7 @@ class CommandQueue final // NOSONAR - destructor is needed private: const IContext& m_dx_context; - wrl::ComPtr m_cp_command_queue; + wrl::ComPtr m_command_queue_cptr; TracyD3D12Ctx m_tracy_context; }; diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ComputeState.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ComputeState.h index 4539778be..473f14175 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ComputeState.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ComputeState.h @@ -61,7 +61,7 @@ class ComputeState final const Device& m_device; D3D12_COMPUTE_PIPELINE_STATE_DESC m_pipeline_state_desc{ }; - wrl::ComPtr m_cp_pipeline_state; + wrl::ComPtr m_pipeline_state_cptr; }; } // namespace Methane::Graphics::DirectX diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Context.hpp b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Context.hpp index f28456e5b..d8c9486eb 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Context.hpp +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Context.hpp @@ -83,9 +83,9 @@ class Context m_descriptor_manager_init_settings.default_heap_sizes = descriptor_manager.GetDescriptorHeapSizes(true, false); m_descriptor_manager_init_settings.shader_visible_heap_sizes = descriptor_manager.GetDescriptorHeapSizes(true, true); - for(wrl::ComPtr& cp_query_heap : m_query_heaps) + for(wrl::ComPtr& query_heap_cptr : m_query_heaps) { - cp_query_heap.Reset(); + query_heap_cptr.Reset(); } GetDirectMutableDevice().ReleaseNativeDevice(); @@ -162,17 +162,17 @@ class Context { META_FUNCTION_TASK(); META_CHECK_ARG_LESS(static_cast(type), m_query_heaps.size()); - wrl::ComPtr& cp_query_heap = m_query_heaps[type]; - if (!cp_query_heap) + wrl::ComPtr query_heap_cptr = m_query_heaps[type]; + if (!query_heap_cptr) { D3D12_QUERY_HEAP_DESC query_heap_desc{}; query_heap_desc.Count = max_query_count; query_heap_desc.Type = type; - ThrowIfFailed(GetDirectDevice().GetNativeDevice()->CreateQueryHeap(&query_heap_desc, IID_PPV_ARGS(&cp_query_heap)), + ThrowIfFailed(GetDirectDevice().GetNativeDevice()->CreateQueryHeap(&query_heap_desc, IID_PPV_ARGS(&query_heap_cptr)), GetDirectDevice().GetNativeDevice().Get()); } - META_CHECK_ARG_NOT_NULL(cp_query_heap); - return *cp_query_heap.Get(); + META_CHECK_ARG_NOT_NULL(query_heap_cptr); + return*query_heap_cptr.Get(); } protected: diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/DescriptorHeap.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/DescriptorHeap.h index e10e69d73..04a479844 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/DescriptorHeap.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/DescriptorHeap.h @@ -111,7 +111,7 @@ class DescriptorHeap // NOSONAR - this class requires destructor DescriptorHeap(const Base::Context& context, const Settings& settings); ~DescriptorHeap() override; - [[nodiscard]] ID3D12DescriptorHeap* GetNativeDescriptorHeap() noexcept { return m_cp_descriptor_heap.Get(); } + [[nodiscard]] ID3D12DescriptorHeap* GetNativeDescriptorHeap() noexcept { return m_descriptor_heap_cptr.Get(); } [[nodiscard]] D3D12_DESCRIPTOR_HEAP_TYPE GetNativeDescriptorHeapType() const noexcept { return m_descriptor_heap_type; } [[nodiscard]] D3D12_CPU_DESCRIPTOR_HANDLE GetNativeCpuDescriptorHandle(uint32_t descriptor_index) const; [[nodiscard]] D3D12_GPU_DESCRIPTOR_HANDLE GetNativeGpuDescriptorHandle(uint32_t descriptor_index) const; @@ -145,7 +145,7 @@ class DescriptorHeap // NOSONAR - this class requires destructor TracyLockable(std::mutex, m_modification_mutex); D3D12_DESCRIPTOR_HEAP_TYPE m_descriptor_heap_type; uint32_t m_descriptor_size; - wrl::ComPtr m_cp_descriptor_heap; + wrl::ComPtr m_descriptor_heap_cptr; }; } // namespace Methane::Graphics::DirectX diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Device.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Device.h index 0ac5b77f0..1a6056460 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Device.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Device.h @@ -42,9 +42,9 @@ namespace wrl = Microsoft::WRL; class Device final : public Base::Device { public: - static Rhi::DeviceFeatureMask GetSupportedFeatures(const wrl::ComPtr& cp_adapter, D3D_FEATURE_LEVEL feature_level); + static Rhi::DeviceFeatureMask GetSupportedFeatures(const wrl::ComPtr& adapter_cptr, D3D_FEATURE_LEVEL feature_level); - Device(const wrl::ComPtr& cp_adapter, D3D_FEATURE_LEVEL feature_level, const Capabilities& capabilities); + Device(const wrl::ComPtr& adapter_cptr, D3D_FEATURE_LEVEL feature_level, const Capabilities& capabilities); // IDevice interface [[nodiscard]] Ptr CreateRenderContext(const Platform::AppEnvironment& env, tf::Executor& parallel_executor, const Rhi::RenderContextSettings& settings) override; @@ -55,15 +55,15 @@ class Device final : public Base::Device using NativeFeatureOptions5 = std::optional; const NativeFeatureOptions5& GetNativeFeatureOptions5() const { return m_feature_options_5; } - const wrl::ComPtr& GetNativeAdapter() const { return m_cp_adapter; } + const wrl::ComPtr& GetNativeAdapter() const { return m_adapter_cptr; } const wrl::ComPtr& GetNativeDevice() const; void ReleaseNativeDevice(); private: - const wrl::ComPtr m_cp_adapter; - const D3D_FEATURE_LEVEL m_feature_level; - mutable NativeFeatureOptions5 m_feature_options_5; - mutable wrl::ComPtr m_cp_device; + const wrl::ComPtr m_adapter_cptr; + const D3D_FEATURE_LEVEL m_feature_level; + mutable NativeFeatureOptions5 m_feature_options_5; + mutable wrl::ComPtr m_device_cptr; }; bool IsSoftwareAdapterDxgi(IDXGIAdapter1& adapter); diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ErrorHandling.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ErrorHandling.h index f476ee771..4e5679fde 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ErrorHandling.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ErrorHandling.h @@ -58,10 +58,10 @@ inline void SafeCloseHandle(HANDLE& handle) noexcept handle = nullptr; } -inline void ThrowIfFailed(HRESULT hr, ID3D12Device* p_device = nullptr) +inline void ThrowIfFailed(HRESULT hr, ID3D12Device* device_ptr = nullptr) { if (FAILED(hr)) - throw RuntimeException(hr, p_device); + throw RuntimeException(hr, device_ptr); } inline void ThrowIfFailed(HRESULT hr, const wrl::ComPtr& error_blob) diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Fence.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Fence.h index 44d8ebbea..5bc5f22fb 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Fence.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Fence.h @@ -58,7 +58,7 @@ class Fence final // NOSONAR - custom destructor is required private: CommandQueue& GetDirectCommandQueue(); - wrl::ComPtr m_cp_fence; + wrl::ComPtr m_fence_cptr; HANDLE m_event = nullptr; }; diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Program.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Program.h index b389b262a..cf6dd1199 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Program.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Program.h @@ -58,7 +58,7 @@ class Program final : public Base::Program // NOSONAR - this class requires dest Shader& GetDirectVertexShader() const; Shader& GetDirectPixelShader() const; - const wrl::ComPtr& GetNativeRootSignature() const noexcept { return m_cp_root_signature; } + const wrl::ComPtr& GetNativeRootSignature() const noexcept { return m_root_signature_cptr; } D3D12_INPUT_LAYOUT_DESC GetNativeInputLayoutDesc() const noexcept; const IContext& GetDirectContext() const noexcept { return m_dx_context; } @@ -76,7 +76,7 @@ class Program final : public Base::Program // NOSONAR - this class requires dest using DescriptorRangeByHeapAndAccessType = std::map, DescriptorHeapReservation>; const IContext& m_dx_context; - wrl::ComPtr m_cp_root_signature; + wrl::ComPtr m_root_signature_cptr; mutable std::vector m_dx_vertex_input_layout; DescriptorRangeByHeapAndAccessType m_constant_descriptor_range_by_heap_and_access_type; diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ProgramArgumentBinding.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ProgramArgumentBinding.h index 4fab5e44f..113b178c6 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ProgramArgumentBinding.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ProgramArgumentBinding.h @@ -95,7 +95,7 @@ class ProgramArgumentBinding final // NOSONAR - custom destructor is required void SetRootParameterIndex(uint32_t root_parameter_index) { m_root_parameter_index = root_parameter_index; } void SetDescriptorRange(const DescriptorRange& descriptor_range); - void SetDescriptorHeapReservation(const DescriptorHeapReservation* p_reservation); + void SetDescriptorHeapReservation(const DescriptorHeapReservation* reservation_ptr); protected: // IRootConstantBufferCallback overrides... @@ -108,9 +108,9 @@ class ProgramArgumentBinding final // NOSONAR - custom destructor is required const Rhi::ResourceUsageMask m_shader_usage; uint32_t m_root_parameter_index = std::numeric_limits::max();; DescriptorRange m_descriptor_range; - const DescriptorHeapReservation* m_p_descriptor_heap_reservation = nullptr; + const DescriptorHeapReservation* m_descriptor_heap_reservation_ptr = nullptr; ResourceViews m_resource_views_dx; - const wrl::ComPtr m_cp_native_device; + const wrl::ComPtr m_native_device_cptr; }; } // namespace Methane::Graphics::DirectX diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ProgramBindings.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ProgramBindings.h index c4aa19737..d78e65468 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ProgramBindings.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/ProgramBindings.h @@ -80,7 +80,7 @@ class ProgramBindings final // NOSONAR - custom destructor is required void ReserveDescriptorHeapRanges(); void AddRootParameterBinding(const Rhi::ProgramArgumentAccessor& argument_desc, const RootParameterBinding& root_parameter_binding); void UpdateRootParameterBindings(); - void AddRootParameterBindingsForArgument(ArgumentBinding& argument_binding, const DescriptorHeap::Reservation* p_heap_reservation); + void AddRootParameterBindingsForArgument(ArgumentBinding& argument_binding, const DescriptorHeap::Reservation* heap_reservation_ptr); void ApplyRootParameterBindings(Rhi::ProgramArgumentAccessMask access, const ICommandList& command_list, const Base::ProgramBindings* applied_program_bindings_ptr, bool apply_changes_only) const; template @@ -89,7 +89,7 @@ class ProgramBindings final // NOSONAR - custom destructor is required void CopyDescriptorsToGpu() const; void CopyDescriptorsToGpuForArgument(const wrl::ComPtr& d3d12_device, ArgumentBinding& argument_binding, - const DescriptorHeap::Reservation* p_heap_reservation) const; + const DescriptorHeap::Reservation* heap_reservation_ptr) const; using RootParameterBindings = std::vector; using RootParameterBindingsByAccess = std::array()>; diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/RenderContext.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/RenderContext.h index 816f1d133..9ae31a391 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/RenderContext.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/RenderContext.h @@ -55,7 +55,7 @@ class RenderContext final // NOSONAR - manual destructor is required, inheritanc void Initialize(Base::Device& device, bool is_callback_emitted = true) override; void Release() override; - const wrl::ComPtr& GetNativeSwapChain() const { return m_cp_swap_chain; } + const wrl::ComPtr& GetNativeSwapChain() const { return m_swap_chain_cptr; } protected: // Base::RenderContext overrides @@ -68,7 +68,7 @@ class RenderContext final // NOSONAR - manual destructor is required, inheritanc void WaitForSwapChainLatency(); const Platform::AppEnvironment m_platform_env; - wrl::ComPtr m_cp_swap_chain; + wrl::ComPtr m_swap_chain_cptr; HANDLE m_frame_latency_waitable_object {}; bool m_is_tearing_supported = false; }; diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/RenderState.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/RenderState.h index 73015a274..c4adcfd3c 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/RenderState.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/RenderState.h @@ -59,7 +59,7 @@ class RenderState final const RenderContext& GetDirectRenderContext() const noexcept; D3D12_GRAPHICS_PIPELINE_STATE_DESC m_pipeline_state_desc{ }; - wrl::ComPtr m_cp_pipeline_state; + wrl::ComPtr m_pipeline_state_cptr; std::array m_blend_factor{ 0.0, 0.0, 0.0, 0.0 }; }; diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Resource.hpp b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Resource.hpp index c8b961564..f08872cfa 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Resource.hpp +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Resource.hpp @@ -92,9 +92,9 @@ class Resource // NOSONAR - destructor in use if (!Base::Resource::SetName(name)) return false; - if (m_cp_resource) + if (m_resource_cptr) { - m_cp_resource->SetName(nowide::widen(name).c_str()); + m_resource_cptr->SetName(nowide::widen(name).c_str()); } return true; } @@ -114,10 +114,10 @@ class Resource // NOSONAR - destructor in use } // IResource overrides - ID3D12Resource& GetNativeResourceRef() const final { META_CHECK_ARG_NOT_NULL(m_cp_resource); return *m_cp_resource.Get(); } - ID3D12Resource* GetNativeResource() const noexcept final { return m_cp_resource.Get(); } - const wrl::ComPtr& GetNativeResourceComPtr() const noexcept final { return m_cp_resource; } - D3D12_GPU_VIRTUAL_ADDRESS GetNativeGpuAddress() const noexcept final { return m_cp_resource ? m_cp_resource->GetGPUVirtualAddress() : 0; } + ID3D12Resource& GetNativeResourceRef() const final { META_CHECK_ARG_NOT_NULL(m_resource_cptr); return *m_resource_cptr.Get(); } + ID3D12Resource* GetNativeResource() const noexcept final { return m_resource_cptr.Get(); } + const wrl::ComPtr& GetNativeResourceComPtr() const noexcept final { return m_resource_cptr; } + D3D12_GPU_VIRTUAL_ADDRESS GetNativeGpuAddress() const noexcept final { return m_resource_cptr ? m_resource_cptr->GetGPUVirtualAddress() : 0; } protected: enum class TransferOperation @@ -133,36 +133,35 @@ class Resource // NOSONAR - destructor in use }; const IContext& GetDirectContext() const noexcept { return m_dx_context; } - void SetNativeResourceComPtr(const wrl::ComPtr& cp_resource) noexcept { m_cp_resource = cp_resource; } + void SetNativeResourceComPtr(const wrl::ComPtr resource_cptr) noexcept { m_resource_cptr = resource_cptr; } wrl::ComPtr CreateCommittedResource(const D3D12_RESOURCE_DESC& resource_desc, D3D12_HEAP_TYPE heap_type, - D3D12_RESOURCE_STATES resource_state, const D3D12_CLEAR_VALUE* p_clear_value = nullptr) + D3D12_RESOURCE_STATES resource_state, const D3D12_CLEAR_VALUE* clear_value_ptr = nullptr) { META_FUNCTION_TASK(); - wrl::ComPtr cp_resource; + wrl::ComPtr resource_cptr; const CD3DX12_HEAP_PROPERTIES heap_properties(heap_type); - const wrl::ComPtr& cp_native_device = GetDirectContext().GetDirectDevice().GetNativeDevice(); + const wrl::ComPtr native_device_cptr = GetDirectContext().GetDirectDevice().GetNativeDevice(); ThrowIfFailed( - cp_native_device->CreateCommittedResource( + native_device_cptr->CreateCommittedResource( &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, resource_state, - p_clear_value, - IID_PPV_ARGS(&cp_resource) - ), - cp_native_device.Get() + clear_value_ptr, + IID_PPV_ARGS(&resource_cptr)), + native_device_cptr.Get() ); - return cp_resource; + return resource_cptr; } void InitializeCommittedResource(const D3D12_RESOURCE_DESC& resource_desc, D3D12_HEAP_TYPE heap_type, - Rhi::ResourceState resource_state, const D3D12_CLEAR_VALUE* p_clear_value = nullptr) + Rhi::ResourceState resource_state, const D3D12_CLEAR_VALUE* clear_value_ptr = nullptr) { META_FUNCTION_TASK(); - META_CHECK_ARG_DESCR(m_cp_resource.Get(), !m_cp_resource, "committed resource is already initialized"); + META_CHECK_ARG_DESCR(m_resource_cptr.Get(), !m_resource_cptr, "committed resource is already initialized"); const D3D12_RESOURCE_STATES d3d_resource_state = IResource::GetNativeResourceState(resource_state); - m_cp_resource = CreateCommittedResource(resource_desc, heap_type, d3d_resource_state, p_clear_value); + m_resource_cptr = CreateCommittedResource(resource_desc, heap_type, d3d_resource_state, clear_value_ptr); SetState(resource_state); } @@ -227,7 +226,7 @@ class Resource // NOSONAR - destructor in use const IContext& m_dx_context; DescriptorByViewId m_descriptor_by_view_id; - wrl::ComPtr m_cp_resource; + wrl::ComPtr m_resource_cptr; TransferBarriers m_upload_barriers; TransferBarriers m_read_back_barriers; }; diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Shader.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Shader.h index 9241fee00..fc00659bd 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Shader.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Shader.h @@ -56,8 +56,8 @@ class Shader final private: UniquePtr m_byte_code_chunk_ptr; - wrl::ComPtr m_cp_byte_code; - wrl::ComPtr m_cp_reflection; + wrl::ComPtr m_byte_code_cptr; + wrl::ComPtr m_reflection_cptr; }; } // namespace Methane::Graphics::DirectX diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/System.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/System.h index d58e7986f..5c0c9c3d0 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/System.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/System.h @@ -58,12 +58,12 @@ class System final // NOSONAR - custom destructor is required const Ptrs& UpdateGpuDevices(const Platform::AppEnvironment& app_env, const Rhi::DeviceCaps& required_device_caps) override; const Ptrs& UpdateGpuDevices(const Rhi::DeviceCaps& required_device_caps) override; - [[nodiscard]] const wrl::ComPtr& GetNativeFactory() const noexcept { return m_cp_factory; } + [[nodiscard]] const wrl::ComPtr& GetNativeFactory() const noexcept { return m_factory_cptr; } void ReportLiveObjects() const noexcept; private: void Initialize(); - void AddDevice(const wrl::ComPtr& cp_adapter, D3D_FEATURE_LEVEL feature_level); + void AddDevice(const wrl::ComPtr& adapter_cptr, D3D_FEATURE_LEVEL feature_level); #ifdef ADAPTERS_CHANGE_HANDLING void RegisterAdapterChangeEvent(); @@ -73,7 +73,7 @@ class System final // NOSONAR - custom destructor is required DWORD m_adapter_change_registration_cookie = 0; #endif - wrl::ComPtr m_cp_factory; + wrl::ComPtr m_factory_cptr; }; } // namespace Methane::Graphics::DirectX diff --git a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Texture.h b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Texture.h index 97fb3f272..b29d183ec 100644 --- a/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Texture.h +++ b/Modules/Graphics/RHI/DirectX/Include/Methane/Graphics/DirectX/Texture.h @@ -81,8 +81,8 @@ class Texture final // NOSONAR - inheritance hierarchy is greater than 5 void GenerateMipLevels(std::vector& dx_sub_resources, ::DirectX::ScratchImage& scratch_image) const; // Upload & Read-back resources are created for TextureType::Image only - wrl::ComPtr m_cp_upload_resource; - wrl::ComPtr m_cp_read_back_resource; + wrl::ComPtr m_upload_resource_cptr; + wrl::ComPtr m_read_back_resource_cptr; }; } // namespace Methane::Graphics::DirectX diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Buffer.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Buffer.cpp index 28a6930ff..cad20cb66 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Buffer.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Buffer.cpp @@ -72,7 +72,7 @@ Buffer::Buffer(const Base::Context& context, const Settings& orig_settings) if (is_private_storage) { resource_desc.Width = Data::AlignUp(resource_desc.Width, UINT64(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT)); - m_cp_upload_resource = CreateCommittedResource(resource_desc, D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ); + m_upload_resource_cptr = CreateCommittedResource(resource_desc, D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ); } // Resources on D3D12_HEAP_TYPE_UPLOAD heaps requires D3D12_RESOURCE_STATE_GENERIC_READ or D3D12_RESOURCE_STATE_RESOLVE_SOURCE, which can not be changed. @@ -86,9 +86,9 @@ bool Buffer::SetName(std::string_view name) if (!Resource::SetName(name)) return false; - if (m_cp_upload_resource) + if (m_upload_resource_cptr) { - m_cp_upload_resource->SetName(nowide::widen(fmt::format("{} Upload Resource", name)).c_str()); + m_upload_resource_cptr->SetName(nowide::widen(fmt::format("{} Upload Resource", name)).c_str()); } return true; } @@ -101,19 +101,19 @@ void Buffer::SetData(Rhi::ICommandQueue& target_cmd_queue, const SubResource& su const Settings& settings = GetSettings(); const CD3DX12_RANGE zero_read_range(0U, 0U); const bool is_private_storage = settings.storage_mode == IBuffer::StorageMode::Private; - ID3D12Resource& d3d12_resource = is_private_storage ? *m_cp_upload_resource.Get() : GetNativeResourceRef(); + ID3D12Resource& d3d12_resource = is_private_storage ? *m_upload_resource_cptr.Get() : GetNativeResourceRef(); // Using zero range, since we're not going to read this resource on CPU const Data::Index sub_resource_raw_index = sub_resource.GetIndex().GetRawIndex(Rhi::SubResourceCount()); - Data::RawPtr p_sub_resource_data = nullptr; + Data::RawPtr sub_resource_data_ptr = nullptr; ThrowIfFailed( d3d12_resource.Map(sub_resource_raw_index, &zero_read_range, - reinterpret_cast(&p_sub_resource_data)), // NOSONAR + reinterpret_cast(&sub_resource_data_ptr)), // NOSONAR GetDirectContext().GetDirectDevice().GetNativeDevice().Get() ); - META_CHECK_ARG_NOT_NULL_DESCR(p_sub_resource_data, "failed to map buffer subresource"); - stdext::checked_array_iterator target_data_it(p_sub_resource_data, sub_resource.GetDataSize()); + META_CHECK_ARG_NOT_NULL_DESCR(sub_resource_data_ptr, "failed to map buffer subresource"); + stdext::checked_array_iterator target_data_it(sub_resource_data_ptr, sub_resource.GetDataSize()); std::copy(sub_resource.GetDataPtr(), sub_resource.GetDataEndPtr(), target_data_it); if (sub_resource.HasDataRange()) @@ -131,7 +131,7 @@ void Buffer::SetData(Rhi::ICommandQueue& target_cmd_queue, const SubResource& su // In case of private GPU storage, copy buffer data from intermediate upload resource to the private GPU resource const TransferCommandList& upload_cmd_list = PrepareResourceTransfer(TransferOperation::Upload, target_cmd_queue, State::CopyDest); - upload_cmd_list.GetNativeCommandList().CopyBufferRegion(GetNativeResource(), 0U, m_cp_upload_resource.Get(), 0U, settings.size); + upload_cmd_list.GetNativeCommandList().CopyBufferRegion(GetNativeResource(), 0U, m_upload_resource_cptr.Get(), 0U, settings.size); GetContext().RequestDeferredAction(Rhi::IContext::DeferredAction::UploadResources); } diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/CommandQueue.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/CommandQueue.cpp index 032f6ca96..27b1034da 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/CommandQueue.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/CommandQueue.cpp @@ -82,26 +82,26 @@ static D3D12_COMMAND_LIST_TYPE GetNativeCommandListType(Rhi::CommandListType com static wrl::ComPtr CreateNativeCommandQueue(const Device& device, D3D12_COMMAND_LIST_TYPE command_list_type) { META_FUNCTION_TASK(); - const wrl::ComPtr& cp_device = device.GetNativeDevice(); - META_CHECK_ARG_NOT_NULL(cp_device); + const wrl::ComPtr& device_cptr = device.GetNativeDevice(); + META_CHECK_ARG_NOT_NULL(device_cptr); D3D12_COMMAND_QUEUE_DESC queue_desc{}; queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queue_desc.Type = command_list_type; - wrl::ComPtr cp_command_queue; - ThrowIfFailed(cp_device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&cp_command_queue)), cp_device.Get()); - return cp_command_queue; + wrl::ComPtr command_queue_cptr; + ThrowIfFailed(device_cptr->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&command_queue_cptr)), device_cptr.Get()); + return command_queue_cptr; } CommandQueue::CommandQueue(const Base::Context& context, Rhi::CommandListType command_lists_type) : Base::CommandQueueTracking(context, command_lists_type) , m_dx_context(dynamic_cast(context)) - , m_cp_command_queue(CreateNativeCommandQueue(m_dx_context.GetDirectDevice(), GetNativeCommandListType(command_lists_type, context.GetOptions()))) + , m_command_queue_cptr(CreateNativeCommandQueue(m_dx_context.GetDirectDevice(), GetNativeCommandListType(command_lists_type, context.GetOptions()))) { META_FUNCTION_TASK(); #if defined(METHANE_GPU_INSTRUMENTATION_ENABLED) && METHANE_GPU_INSTRUMENTATION_ENABLED == 2 - m_tracy_context = TracyD3D12Context(GetDirectContext().GetDirectDevice().GetNativeDevice().Get(), m_cp_command_queue.Get()); + m_tracy_context = TracyD3D12Context(GetDirectContext().GetDirectDevice().GetNativeDevice().Get(), m_command_queue_cptr.Get()); #endif } @@ -159,7 +159,7 @@ bool CommandQueue::SetName(std::string_view name) return false; Base::CommandQueueTracking::SetName(name); - m_cp_command_queue->SetName(nowide::widen(name).c_str()); + m_command_queue_cptr->SetName(nowide::widen(name).c_str()); #if defined(METHANE_GPU_INSTRUMENTATION_ENABLED) && METHANE_GPU_INSTRUMENTATION_ENABLED == 2 TracyD3D12ContextName(m_tracy_context, GetName().data(), static_cast(name.length())); @@ -185,8 +185,8 @@ void CommandQueue::CompleteExecution(const Opt& frame_index) ID3D12CommandQueue& CommandQueue::GetNativeCommandQueue() { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_cp_command_queue); - return *m_cp_command_queue.Get(); + META_CHECK_ARG_NOT_NULL(m_command_queue_cptr); + return *m_command_queue_cptr.Get(); } } // namespace Methane::Graphics::DirectX diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ComputeState.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ComputeState.cpp index 26ce07704..564af7089 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ComputeState.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ComputeState.cpp @@ -59,9 +59,9 @@ static const Device& GetDirectDeviceFromContext(const Rhi::IContext& context) inline CD3DX12_SHADER_BYTECODE GetShaderByteCode(const Ptr& shader_ptr) { META_FUNCTION_TASK(); - const Data::Chunk* p_byte_code_chunk = shader_ptr ? static_cast(*shader_ptr).GetNativeByteCode() : nullptr; - return p_byte_code_chunk - ? CD3DX12_SHADER_BYTECODE(p_byte_code_chunk->GetDataPtr(), p_byte_code_chunk->GetDataSize()) + const Data::Chunk* byte_code_chunk_ptr = shader_ptr ? static_cast(*shader_ptr).GetNativeByteCode() : nullptr; + return byte_code_chunk_ptr + ? CD3DX12_SHADER_BYTECODE(byte_code_chunk_ptr->GetDataPtr(), byte_code_chunk_ptr->GetDataSize()) : CD3DX12_SHADER_BYTECODE(nullptr, 0); } @@ -86,7 +86,7 @@ void ComputeState::Reset(const Settings& settings) m_pipeline_state_desc.CachedPSO = {}; m_pipeline_state_desc.Flags = {}; - m_cp_pipeline_state.Reset(); + m_pipeline_state_cptr.Reset(); } void ComputeState::Apply(Base::ComputeCommandList& command_list) @@ -105,9 +105,9 @@ bool ComputeState::SetName(std::string_view name) if (!Base::ComputeState::SetName(name)) return false; - if (m_cp_pipeline_state) + if (m_pipeline_state_cptr) { - m_cp_pipeline_state->SetName(nowide::widen(name).c_str()); + m_pipeline_state_cptr->SetName(nowide::widen(name).c_str()); } return true; } @@ -115,22 +115,23 @@ bool ComputeState::SetName(std::string_view name) void ComputeState::InitializeNativePipelineState() { META_FUNCTION_TASK(); - if (m_cp_pipeline_state) + if (m_pipeline_state_cptr) return; - const wrl::ComPtr& cp_native_device = GetDirectDevice().GetNativeDevice(); - ThrowIfFailed(cp_native_device->CreateComputePipelineState(&m_pipeline_state_desc, IID_PPV_ARGS(&m_cp_pipeline_state)), cp_native_device.Get()); + const wrl::ComPtr native_device_cptr = GetDirectDevice().GetNativeDevice(); + ThrowIfFailed(native_device_cptr->CreateComputePipelineState(&m_pipeline_state_desc, IID_PPV_ARGS(&m_pipeline_state_cptr)), + native_device_cptr.Get()); SetName(GetName()); } wrl::ComPtr& ComputeState::GetNativePipelineState() { META_FUNCTION_TASK(); - if (!m_cp_pipeline_state) + if (!m_pipeline_state_cptr) { InitializeNativePipelineState(); } - return m_cp_pipeline_state; + return m_pipeline_state_cptr; } Program& ComputeState::GetDirectProgram() diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/DescriptorHeap.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/DescriptorHeap.cpp index 5f487a55d..518996a56 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/DescriptorHeap.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/DescriptorHeap.cpp @@ -169,17 +169,17 @@ void DescriptorHeap::SetDeferredAllocation(bool deferred_allocation) D3D12_CPU_DESCRIPTOR_HANDLE DescriptorHeap::GetNativeCpuDescriptorHandle(uint32_t descriptor_index) const { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_cp_descriptor_heap); + META_CHECK_ARG_NOT_NULL(m_descriptor_heap_cptr); META_CHECK_ARG_LESS(descriptor_index, GetAllocatedSize()); - return CD3DX12_CPU_DESCRIPTOR_HANDLE(m_cp_descriptor_heap->GetCPUDescriptorHandleForHeapStart(), descriptor_index, m_descriptor_size); + return CD3DX12_CPU_DESCRIPTOR_HANDLE(m_descriptor_heap_cptr->GetCPUDescriptorHandleForHeapStart(), descriptor_index, m_descriptor_size); } D3D12_GPU_DESCRIPTOR_HANDLE DescriptorHeap::GetNativeGpuDescriptorHandle(uint32_t descriptor_index) const { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_cp_descriptor_heap); + META_CHECK_ARG_NOT_NULL(m_descriptor_heap_cptr); META_CHECK_ARG_LESS(descriptor_index, GetAllocatedSize()); - return CD3DX12_GPU_DESCRIPTOR_HANDLE(m_cp_descriptor_heap->GetGPUDescriptorHandleForHeapStart(), descriptor_index, m_descriptor_size); + return CD3DX12_GPU_DESCRIPTOR_HANDLE(m_descriptor_heap_cptr->GetGPUDescriptorHandleForHeapStart(), descriptor_index, m_descriptor_size); } void DescriptorHeap::Allocate() @@ -191,11 +191,11 @@ void DescriptorHeap::Allocate() if (allocated_size == deferred_size) return; - const wrl::ComPtr& cp_device = m_dx_context.GetDirectDevice().GetNativeDevice(); - META_CHECK_ARG_NOT_NULL(cp_device); + const wrl::ComPtr device_cptr = m_dx_context.GetDirectDevice().GetNativeDevice(); + META_CHECK_ARG_NOT_NULL(device_cptr); const bool is_shader_visible_heap = GetSettings().shader_visible; - wrl::ComPtr cp_old_descriptor_heap = m_cp_descriptor_heap; + wrl::ComPtr old_descriptor_heap_cptr = m_descriptor_heap_cptr; D3D12_DESCRIPTOR_HEAP_DESC heap_desc{}; heap_desc.NumDescriptors = deferred_size; @@ -205,17 +205,17 @@ void DescriptorHeap::Allocate() : D3D12_DESCRIPTOR_HEAP_FLAG_NONE; // Allocate new descriptor heap of deferred size - ThrowIfFailed(cp_device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&m_cp_descriptor_heap)), cp_device.Get()); + ThrowIfFailed(device_cptr->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&m_descriptor_heap_cptr)), device_cptr.Get()); - if (!is_shader_visible_heap && cp_old_descriptor_heap && allocated_size > 0) + if (!is_shader_visible_heap && old_descriptor_heap_cptr && allocated_size > 0) { // Copy descriptors from old heap to the new one. It works for non-shader-visible CPU heaps only. // Shader-visible heaps must be re-filled with updated descriptors // using Rhi::IProgramBindings::CompleteInitialization() & DescriptorManager::CompleteInitialization() - cp_device->CopyDescriptorsSimple(allocated_size, - m_cp_descriptor_heap->GetCPUDescriptorHandleForHeapStart(), - cp_old_descriptor_heap->GetCPUDescriptorHandleForHeapStart(), - m_descriptor_heap_type); + device_cptr->CopyDescriptorsSimple(allocated_size, + m_descriptor_heap_cptr->GetCPUDescriptorHandleForHeapStart(), + old_descriptor_heap_cptr->GetCPUDescriptorHandleForHeapStart(), + m_descriptor_heap_type); } m_allocated_size = m_deferred_size; diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Device.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Device.cpp index 01b8a80d3..d4205e533 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Device.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Device.cpp @@ -91,7 +91,7 @@ static void ConfigureDeviceDebugFeature(const wrl::ComPtr& device_ #endif -Rhi::DeviceFeatureMask Device::GetSupportedFeatures(const wrl::ComPtr& /*cp_adapter*/, D3D_FEATURE_LEVEL /*feature_level*/) +Rhi::DeviceFeatureMask Device::GetSupportedFeatures(const wrl::ComPtr& /*adapter_cptr*/, D3D_FEATURE_LEVEL /*feature_level*/) { META_FUNCTION_TASK(); Rhi::DeviceFeatureMask supported_features; @@ -102,11 +102,11 @@ Rhi::DeviceFeatureMask Device::GetSupportedFeatures(const wrl::ComPtr& cp_adapter, D3D_FEATURE_LEVEL feature_level, const Capabilities& capabilities) - : Base::Device(GetAdapterNameDxgi(*cp_adapter.Get()), - IsSoftwareAdapterDxgi(static_cast(*cp_adapter.Get())), +Device::Device(const wrl::ComPtr& adapter_cptr, D3D_FEATURE_LEVEL feature_level, const Capabilities& capabilities) + : Base::Device(GetAdapterNameDxgi(*adapter_cptr.Get()), + IsSoftwareAdapterDxgi(static_cast(*adapter_cptr.Get())), capabilities) - , m_cp_adapter(cp_adapter) + , m_adapter_cptr(adapter_cptr) , m_feature_level(feature_level) { } @@ -132,9 +132,9 @@ bool Device::SetName(std::string_view name) if (!Base::Device::SetName(name)) return false; - if (m_cp_device) + if (m_device_cptr) { - m_cp_device->SetName(nowide::widen(name).c_str()); + m_device_cptr->SetName(nowide::widen(name).c_str()); } return true; } @@ -142,17 +142,17 @@ bool Device::SetName(std::string_view name) const wrl::ComPtr& Device::GetNativeDevice() const { META_FUNCTION_TASK(); - if (m_cp_device) - return m_cp_device; + if (m_device_cptr) + return m_device_cptr; - ThrowIfFailed(D3D12CreateDevice(m_cp_adapter.Get(), m_feature_level, IID_PPV_ARGS(&m_cp_device))); + ThrowIfFailed(D3D12CreateDevice(m_adapter_cptr.Get(), m_feature_level, IID_PPV_ARGS(&m_device_cptr))); if (!GetName().empty()) { - m_cp_device->SetName(nowide::widen(GetName()).c_str()); + m_device_cptr->SetName(nowide::widen(GetName()).c_str()); } if (D3D12_FEATURE_DATA_D3D12_OPTIONS5 feature_options_5{}; - m_cp_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &feature_options_5, sizeof(feature_options_5)) == S_OK) + m_device_cptr->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &feature_options_5, sizeof(feature_options_5)) == S_OK) { m_feature_options_5 = feature_options_5; } @@ -160,7 +160,7 @@ const wrl::ComPtr& Device::GetNativeDevice() const #ifdef METHANE_GPU_INSTRUMENTATION_ENABLED if (Platform::Windows::IsDeveloperModeEnabled()) { - ThrowIfFailed(m_cp_device->SetStablePowerState(TRUE), m_cp_device.Get()); + ThrowIfFailed(m_device_cptr->SetStablePowerState(TRUE), m_device_cptr.Get()); } else { @@ -171,16 +171,16 @@ const wrl::ComPtr& Device::GetNativeDevice() const #endif #ifdef _DEBUG - ConfigureDeviceDebugFeature(m_cp_device); + ConfigureDeviceDebugFeature(m_device_cptr); #endif - return m_cp_device; + return m_device_cptr; } void Device::ReleaseNativeDevice() { META_FUNCTION_TASK(); - m_cp_device.Reset(); + m_device_cptr.Reset(); } } // namespace Methane::Graphics::DirectX diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Fence.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Fence.cpp index 620767b37..b197d12b0 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Fence.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Fence.cpp @@ -45,10 +45,10 @@ Fence::Fence(Base::CommandQueue& command_queue) ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError())); } - const wrl::ComPtr& cp_device = GetDirectCommandQueue().GetDirectContext().GetDirectDevice().GetNativeDevice(); - META_CHECK_ARG_NOT_NULL(cp_device); + const wrl::ComPtr device_cptr = GetDirectCommandQueue().GetDirectContext().GetDirectDevice().GetNativeDevice(); + META_CHECK_ARG_NOT_NULL(device_cptr); - ThrowIfFailed(cp_device->CreateFence(GetValue(), D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_cp_fence)), cp_device.Get()); + ThrowIfFailed(device_cptr->CreateFence(GetValue(), D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_fence_cptr)), device_cptr.Get()); } Fence::~Fence() @@ -62,9 +62,9 @@ void Fence::Signal() META_FUNCTION_TASK(); Base::Fence::Signal(); - META_CHECK_ARG_NOT_NULL(m_cp_fence); + META_CHECK_ARG_NOT_NULL(m_fence_cptr); CommandQueue& command_queue = GetDirectCommandQueue(); - ThrowIfFailed(command_queue.GetNativeCommandQueue().Signal(m_cp_fence.Get(), GetValue()), + ThrowIfFailed(command_queue.GetNativeCommandQueue().Signal(m_fence_cptr.Get(), GetValue()), command_queue.GetDirectContext().GetDirectDevice().GetNativeDevice().Get()); } @@ -74,16 +74,16 @@ void Fence::WaitOnCpu() Base::Fence::WaitOnCpu(); const uint64_t wait_value = GetValue(); - const uint64_t curr_value = m_cp_fence->GetCompletedValue(); + const uint64_t curr_value = m_fence_cptr->GetCompletedValue(); if (curr_value >= wait_value) // NOSONAR - curr_value declared outside if return; META_LOG("Fence '{}' with value {} SLEEP until value {}", GetName(), curr_value, wait_value); - META_CHECK_ARG_NOT_NULL(m_cp_fence); + META_CHECK_ARG_NOT_NULL(m_fence_cptr); META_CHECK_ARG_NOT_NULL(m_event); - ThrowIfFailed(m_cp_fence->SetEventOnCompletion(GetValue(), m_event), + ThrowIfFailed(m_fence_cptr->SetEventOnCompletion(GetValue(), m_event), GetDirectCommandQueue().GetDirectContext().GetDirectDevice().GetNativeDevice().Get()); WaitForSingleObjectEx(m_event, INFINITE, FALSE); @@ -95,10 +95,10 @@ void Fence::WaitOnGpu(Rhi::ICommandQueue& wait_on_command_queue) META_FUNCTION_TASK(); Base::Fence::WaitOnGpu(wait_on_command_queue); - META_CHECK_ARG_NOT_NULL(m_cp_fence); + META_CHECK_ARG_NOT_NULL(m_fence_cptr); auto& dx_wait_on_command_queue = static_cast(wait_on_command_queue); ID3D12CommandQueue& native_wait_on_command_queue = dx_wait_on_command_queue.GetNativeCommandQueue(); - ThrowIfFailed(native_wait_on_command_queue.Wait(m_cp_fence.Get(), GetValue()), + ThrowIfFailed(native_wait_on_command_queue.Wait(m_fence_cptr.Get(), GetValue()), dx_wait_on_command_queue.GetDirectContext().GetDirectDevice().GetNativeDevice().Get()); } @@ -108,8 +108,8 @@ bool Fence::SetName(std::string_view name) if (!Base::Fence::SetName(name)) return false; - META_CHECK_ARG_NOT_NULL(m_cp_fence); - m_cp_fence->SetName(nowide::widen(name).c_str()); + META_CHECK_ARG_NOT_NULL(m_fence_cptr); + m_fence_cptr->SetName(nowide::widen(name).c_str()); return true; } diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Program.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Program.cpp index 26f2f28d1..6dcecf9f9 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Program.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Program.cpp @@ -155,8 +155,8 @@ bool Program::SetName(std::string_view name) if (!Base::Program::SetName(name)) return false; - META_CHECK_ARG_NOT_NULL(m_cp_root_signature); - m_cp_root_signature->SetName(nowide::widen(name).c_str()); + META_CHECK_ARG_NOT_NULL(m_root_signature_cptr); + m_root_signature_cptr->SetName(nowide::widen(name).c_str()); return true; } @@ -230,8 +230,8 @@ void Program::InitRootSignature() D3D12_FEATURE_DATA_ROOT_SIGNATURE feature_data{}; feature_data.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_1; - const wrl::ComPtr& cp_native_device = GetDirectContext().GetDirectDevice().GetNativeDevice(); - if (FAILED(cp_native_device->CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE, &feature_data, sizeof(feature_data)))) + const wrl::ComPtr& native_device_cptr = GetDirectContext().GetDirectDevice().GetNativeDevice(); + if (FAILED(native_device_cptr->CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE, &feature_data, sizeof(feature_data)))) { feature_data.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_0; } @@ -239,7 +239,8 @@ void Program::InitRootSignature() wrl::ComPtr root_signature_blob; wrl::ComPtr error_blob; ThrowIfFailed(D3DX12SerializeVersionedRootSignature(&root_signature_desc, feature_data.HighestVersion, &root_signature_blob, &error_blob), error_blob); - ThrowIfFailed(cp_native_device->CreateRootSignature(0, root_signature_blob->GetBufferPointer(), root_signature_blob->GetBufferSize(), IID_PPV_ARGS(&m_cp_root_signature)), cp_native_device.Get()); + ThrowIfFailed(native_device_cptr->CreateRootSignature(0, root_signature_blob->GetBufferPointer(), root_signature_blob->GetBufferSize(), + IID_PPV_ARGS(&m_root_signature_cptr)), native_device_cptr.Get()); } DescriptorHeap::Range Program::ReserveDescriptorRange(DescriptorHeap& heap, ArgumentAccessor::Type access_type, uint32_t range_length) diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ProgramArgumentBinding.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ProgramArgumentBinding.cpp index d68c2b168..baff04ec2 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ProgramArgumentBinding.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ProgramArgumentBinding.cpp @@ -47,11 +47,11 @@ ProgramArgumentBinding::ProgramArgumentBinding(const Base::Context& context, con : Base::ProgramArgumentBinding(context, settings) , m_settings_dx(settings) , m_shader_usage(GetShaderUsage(settings.type)) - , m_cp_native_device(dynamic_cast(context).GetDirectDevice().GetNativeDevice()) + , m_native_device_cptr(dynamic_cast(context).GetDirectDevice().GetNativeDevice()) { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_cp_native_device); - META_CHECK_ARG_NAME("m_p_descriptor_heap_reservation", !m_p_descriptor_heap_reservation); + META_CHECK_ARG_NOT_NULL(m_native_device_cptr); + META_CHECK_ARG_NAME("m_descriptor_heap_reservation_ptr", !m_descriptor_heap_reservation_ptr); } ProgramArgumentBinding::ProgramArgumentBinding(const ProgramArgumentBinding& other) @@ -60,16 +60,16 @@ ProgramArgumentBinding::ProgramArgumentBinding(const ProgramArgumentBinding& oth , m_shader_usage(other.m_shader_usage) , m_root_parameter_index(other.m_root_parameter_index) , m_descriptor_range(other.m_descriptor_range) - , m_p_descriptor_heap_reservation(other.m_p_descriptor_heap_reservation) + , m_descriptor_heap_reservation_ptr(other.m_descriptor_heap_reservation_ptr) , m_resource_views_dx(other.m_resource_views_dx) - , m_cp_native_device(other.m_cp_native_device) + , m_native_device_cptr(other.m_native_device_cptr) { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_cp_native_device); - if (m_p_descriptor_heap_reservation) + META_CHECK_ARG_NOT_NULL(m_native_device_cptr); + if (m_descriptor_heap_reservation_ptr) { - META_CHECK_ARG_TRUE( m_p_descriptor_heap_reservation->heap.get().IsShaderVisible()); - META_CHECK_ARG_EQUAL(m_p_descriptor_heap_reservation->heap.get().GetSettings().type, m_descriptor_range.heap_type); + META_CHECK_ARG_TRUE( m_descriptor_heap_reservation_ptr->heap.get().IsShaderVisible()); + META_CHECK_ARG_EQUAL(m_descriptor_heap_reservation_ptr->heap.get().GetSettings().type, m_descriptor_range.heap_type); } } @@ -98,17 +98,17 @@ bool ProgramArgumentBinding::SetResourceViews(const Rhi::ResourceViews& resource META_CHECK_ARG_LESS_DESCR(resource_views.size(), m_descriptor_range.count + 1, "the number of bound resources exceeds reserved descriptors count"); } - const uint32_t descriptor_range_start = m_p_descriptor_heap_reservation - ? m_p_descriptor_heap_reservation->GetRange(m_settings_dx.argument.GetAccessorIndex()).GetStart() + const uint32_t descriptor_range_start = m_descriptor_heap_reservation_ptr + ? m_descriptor_heap_reservation_ptr->GetRange(m_settings_dx.argument.GetAccessorIndex()).GetStart() : std::numeric_limits::max(); - const DescriptorHeap* p_dx_descriptor_heap = m_p_descriptor_heap_reservation - ? static_cast(&m_p_descriptor_heap_reservation->heap.get()) + const DescriptorHeap* dx_descriptor_heap_ptr = m_descriptor_heap_reservation_ptr + ? static_cast(&m_descriptor_heap_reservation_ptr->heap.get()) : nullptr; - const DescriptorHeap::Type descriptor_heap_type = p_dx_descriptor_heap - ? p_dx_descriptor_heap->GetSettings().type + const DescriptorHeap::Type descriptor_heap_type = dx_descriptor_heap_ptr + ? dx_descriptor_heap_ptr->GetSettings().type : DescriptorHeap::Type::Undefined; - const D3D12_DESCRIPTOR_HEAP_TYPE native_heap_type = p_dx_descriptor_heap - ? p_dx_descriptor_heap->GetNativeDescriptorHeapType() + const D3D12_DESCRIPTOR_HEAP_TYPE native_heap_type = dx_descriptor_heap_ptr + ? dx_descriptor_heap_ptr->GetNativeDescriptorHeapType() : D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; uint32_t resource_index = 0; @@ -118,7 +118,7 @@ bool ProgramArgumentBinding::SetResourceViews(const Rhi::ResourceViews& resource for(const Rhi::ResourceView& resource_view : resource_views) { m_resource_views_dx.emplace_back(resource_view, m_shader_usage); - if (!p_dx_descriptor_heap) + if (!dx_descriptor_heap_ptr) continue; const ResourceView& dx_resource_view = m_resource_views_dx.back(); @@ -128,9 +128,8 @@ bool ProgramArgumentBinding::SetResourceViews(const Rhi::ResourceViews& resource magic_enum::enum_name(m_settings_dx.argument.GetShaderType())); const uint32_t descriptor_index = descriptor_range_start + m_descriptor_range.offset + resource_index; - m_cp_native_device->CopyDescriptorsSimple( - 1, - p_dx_descriptor_heap->GetNativeCpuDescriptorHandle(descriptor_index), + m_native_device_cptr->CopyDescriptorsSimple(1, + dx_descriptor_heap_ptr->GetNativeCpuDescriptorHandle(descriptor_index), dx_resource_view.GetNativeCpuDescriptorHandle(), native_heap_type ); @@ -167,14 +166,16 @@ void ProgramArgumentBinding::SetDescriptorRange(const DescriptorRange& descripto m_descriptor_range = descriptor_range; } -void ProgramArgumentBinding::SetDescriptorHeapReservation(const DescriptorHeapReservation* p_reservation) +void ProgramArgumentBinding::SetDescriptorHeapReservation(const DescriptorHeapReservation* reservation_ptr) { META_FUNCTION_TASK(); META_CHECK_ARG_NAME_DESCR("p_reservation", - !p_reservation || (p_reservation->heap.get().IsShaderVisible() && p_reservation->heap.get().GetSettings().type == m_descriptor_range.heap_type), + !reservation_ptr || + (reservation_ptr->heap.get().IsShaderVisible() && + reservation_ptr->heap.get().GetSettings().type == m_descriptor_range.heap_type), "argument binding reservation must be made in shader visible descriptor heap of type '{}'", magic_enum::enum_name(m_descriptor_range.heap_type)); - m_p_descriptor_heap_reservation = p_reservation; + m_descriptor_heap_reservation_ptr = reservation_ptr; } void ProgramArgumentBinding::OnRootConstantBufferChanged(Base::RootConstantBuffer& root_constant_buffer) diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ProgramBindings.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ProgramBindings.cpp index 99e40d82a..dd91a9b0c 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ProgramBindings.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/ProgramBindings.cpp @@ -259,13 +259,13 @@ void ProgramBindings::UpdateRootParameterBindings() root_parameter_bindings.clear(); } - ForEachArgumentBinding([this](ArgumentBinding& argument_binding, const DescriptorHeap::Reservation* p_heap_reservation) + ForEachArgumentBinding([this](ArgumentBinding& argument_binding, const DescriptorHeap::Reservation* heap_reservation_ptr) { - AddRootParameterBindingsForArgument(argument_binding, p_heap_reservation); + AddRootParameterBindingsForArgument(argument_binding, heap_reservation_ptr); }); } -void ProgramBindings::AddRootParameterBindingsForArgument(ArgumentBinding& argument_binding, const DescriptorHeap::Reservation* p_heap_reservation) +void ProgramBindings::AddRootParameterBindingsForArgument(ArgumentBinding& argument_binding, const DescriptorHeap::Reservation* heap_reservation_ptr) { META_FUNCTION_TASK(); using DXBindingType = ArgumentBinding::Type; @@ -274,10 +274,10 @@ void ProgramBindings::AddRootParameterBindingsForArgument(ArgumentBinding& argum if (const ArgumentBinding::Settings& binding_settings = argument_binding.GetDirectSettings(); binding_settings.type == DXBindingType::DescriptorTable) { - META_CHECK_ARG_NOT_NULL_DESCR(p_heap_reservation, "descriptor heap reservation is not available for \"Descriptor Table\" resource binding"); - const auto& dx_descriptor_heap = static_cast(p_heap_reservation->heap.get()); + META_CHECK_ARG_NOT_NULL_DESCR(heap_reservation_ptr, "descriptor heap reservation is not available for \"Descriptor Table\" resource binding"); + const auto& dx_descriptor_heap = static_cast(heap_reservation_ptr->heap.get()); const DXDescriptorRange& descriptor_range = argument_binding.GetDescriptorRange(); - const uint32_t descriptor_index = p_heap_reservation->GetRange(binding_settings.argument.GetAccessorIndex()).GetStart() + descriptor_range.offset; + const uint32_t descriptor_index = heap_reservation_ptr->GetRange(binding_settings.argument.GetAccessorIndex()).GetStart() + descriptor_range.offset; AddRootParameterBinding(binding_settings.argument, { argument_binding, @@ -394,28 +394,30 @@ void ProgramBindings::CopyDescriptorsToGpu() const META_FUNCTION_TASK(); META_LOG("Copy descriptors to GPU for program bindings '{}'", GetName()); - const wrl::ComPtr& cp_d3d12_device = static_cast(GetProgram()).GetDirectContext().GetDirectDevice().GetNativeDevice(); - ForEachArgumentBinding([this, &cp_d3d12_device](ArgumentBinding& argument_binding, const DescriptorHeap::Reservation* p_heap_reservation) + const wrl::ComPtr& d3d12_device_cptr = static_cast(GetProgram()).GetDirectContext().GetDirectDevice().GetNativeDevice(); + ForEachArgumentBinding([this, &d3d12_device_cptr](ArgumentBinding& argument_binding, const DescriptorHeap::Reservation* heap_reservation_ptr) { - CopyDescriptorsToGpuForArgument(cp_d3d12_device, argument_binding, p_heap_reservation); + CopyDescriptorsToGpuForArgument(d3d12_device_cptr, argument_binding, heap_reservation_ptr); }); } -void ProgramBindings::CopyDescriptorsToGpuForArgument(const wrl::ComPtr& d3d12_device, ArgumentBinding& argument_binding, const DescriptorHeap::Reservation* p_heap_reservation) const +void ProgramBindings::CopyDescriptorsToGpuForArgument(const wrl::ComPtr& d3d12_device, + ArgumentBinding& argument_binding, + const DescriptorHeap::Reservation* heap_reservation_ptr) const { META_FUNCTION_TASK(); - if (!p_heap_reservation) + if (!heap_reservation_ptr) return; using AcceessType = Rhi::ProgramArgumentAccessType; - const auto& dx_descriptor_heap = static_cast(p_heap_reservation->heap.get()); + const auto& dx_descriptor_heap = static_cast(heap_reservation_ptr->heap.get()); const ArgumentBinding::DescriptorRange& descriptor_range = argument_binding.GetDescriptorRange(); const DescriptorHeap::Type heap_type = dx_descriptor_heap.GetSettings().type; - const DescriptorHeap::Range& heap_range = p_heap_reservation->GetRange(argument_binding.GetSettings().argument.GetAccessorIndex()); + const DescriptorHeap::Range& heap_range = heap_reservation_ptr->GetRange(argument_binding.GetSettings().argument.GetAccessorIndex()); const D3D12_DESCRIPTOR_HEAP_TYPE native_heap_type = dx_descriptor_heap.GetNativeDescriptorHeapType(); - argument_binding.SetDescriptorHeapReservation(p_heap_reservation); + argument_binding.SetDescriptorHeapReservation(heap_reservation_ptr); META_CHECK_ARG_NOT_NULL(d3d12_device); META_CHECK_ARG_LESS_DESCR(descriptor_range.offset, heap_range.GetLength(), "descriptor range offset is out of reserved descriptor range bounds"); diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderCommandList.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderCommandList.cpp index 237fc4934..b58ef5109 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderCommandList.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderCommandList.cpp @@ -86,11 +86,11 @@ void RenderCommandList::ResetNative(const Ptr& render_state_ptr) SetNativeCommitted(false); SetCommandListState(Rhi::CommandListState::Encoding); - ID3D12PipelineState* p_dx_initial_state = render_state_ptr ? render_state_ptr->GetNativePipelineState().Get() : nullptr; + ID3D12PipelineState* dx_initial_state_ptr = render_state_ptr ? render_state_ptr->GetNativePipelineState().Get() : nullptr; ID3D12CommandAllocator& dx_cmd_allocator = GetNativeCommandAllocatorRef(); - ID3D12Device* p_native_device = GetDirectCommandQueue().GetDirectContext().GetDirectDevice().GetNativeDevice().Get(); - ThrowIfFailed(dx_cmd_allocator.Reset(), p_native_device); - ThrowIfFailed(GetNativeCommandListRef().Reset(&dx_cmd_allocator, p_dx_initial_state), p_native_device); + ID3D12Device* native_device_ptr = GetDirectCommandQueue().GetDirectContext().GetDirectDevice().GetNativeDevice().Get(); + ThrowIfFailed(dx_cmd_allocator.Reset(), native_device_ptr); + ThrowIfFailed(GetNativeCommandListRef().Reset(&dx_cmd_allocator, dx_initial_state_ptr), native_device_ptr); BeginGpuZone(); diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderContext.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderContext.cpp index 28424c00d..29abbae78 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderContext.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderContext.cpp @@ -102,7 +102,7 @@ void RenderContext::Release() { META_FUNCTION_TASK(); - m_cp_swap_chain.Reset(); + m_swap_chain_cptr.Reset(); Context::Release(); } @@ -137,12 +137,13 @@ void RenderContext::Initialize(Base::Device& device, bool is_callback_emitted) swap_chain_desc.SampleDesc.Count = 1; swap_chain_desc.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; // requires Windows 8.1 - const wrl::ComPtr& cp_dxgi_factory = System::Get().GetNativeFactory(); - META_CHECK_ARG_NOT_NULL(cp_dxgi_factory); + const wrl::ComPtr& dxgi_factory_cptr = System::Get().GetNativeFactory(); + META_CHECK_ARG_NOT_NULL(dxgi_factory_cptr); BOOL present_tearing_support = FALSE; - ID3D12Device* p_native_device = GetDirectDevice().GetNativeDevice().Get(); - ThrowIfFailed(cp_dxgi_factory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &present_tearing_support, sizeof(present_tearing_support)), p_native_device); + ID3D12Device* native_device_ptr = GetDirectDevice().GetNativeDevice().Get(); + ThrowIfFailed(dxgi_factory_cptr->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &present_tearing_support, + sizeof(present_tearing_support)), native_device_ptr); if (present_tearing_support) { swap_chain_desc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; @@ -153,16 +154,17 @@ void RenderContext::Initialize(Base::Device& device, bool is_callback_emitted) m_is_tearing_supported = false; } - wrl::ComPtr cp_swap_chain; + wrl::ComPtr swap_chain_cptr; ID3D12CommandQueue& dx_command_queue = GetDirectDefaultCommandQueue(Rhi::CommandListType::Render).GetNativeCommandQueue(); - ThrowIfFailed(cp_dxgi_factory->CreateSwapChainForHwnd(&dx_command_queue, m_platform_env.window_handle, &swap_chain_desc, nullptr, nullptr, &cp_swap_chain), p_native_device); + ThrowIfFailed(dxgi_factory_cptr->CreateSwapChainForHwnd(&dx_command_queue, m_platform_env.window_handle, &swap_chain_desc, + nullptr, nullptr, &swap_chain_cptr), native_device_ptr); - META_CHECK_ARG_NOT_NULL(cp_swap_chain); - ThrowIfFailed(cp_swap_chain.As(&m_cp_swap_chain), p_native_device); + META_CHECK_ARG_NOT_NULL(swap_chain_cptr); + ThrowIfFailed(swap_chain_cptr.As(&m_swap_chain_cptr), native_device_ptr); // Create waitable object to reduce frame latency (https://docs.microsoft.com/en-us/windows/uwp/gaming/reduce-latency-with-dxgi-1-3-swap-chains) - m_cp_swap_chain->SetMaximumFrameLatency(settings.frame_buffers_count); - m_frame_latency_waitable_object = m_cp_swap_chain->GetFrameLatencyWaitableObject(); + m_swap_chain_cptr->SetMaximumFrameLatency(settings.frame_buffers_count); + m_frame_latency_waitable_object = m_swap_chain_cptr->GetFrameLatencyWaitableObject(); META_CHECK_ARG_NOT_ZERO_DESCR(m_frame_latency_waitable_object, "swap-chain waitable object is null"); if (settings.is_full_screen) @@ -172,7 +174,7 @@ void RenderContext::Initialize(Base::Device& device, bool is_callback_emitted) } // With tearing support enabled we will handle ALT+Enter key presses in the window message loop rather than let DXGI handle it by calling SetFullscreenState - ThrowIfFailed(cp_dxgi_factory->MakeWindowAssociation(m_platform_env.window_handle, DXGI_MWA_NO_ALT_ENTER), p_native_device); + ThrowIfFailed(dxgi_factory_cptr->MakeWindowAssociation(m_platform_env.window_handle, DXGI_MWA_NO_ALT_ENTER), native_device_ptr); UpdateFrameBufferIndex(); @@ -189,8 +191,9 @@ void RenderContext::Resize(const FrameSize& frame_size) // Resize the swap chain to the desired dimensions DXGI_SWAP_CHAIN_DESC1 desc{}; - m_cp_swap_chain->GetDesc1(&desc); - ThrowIfFailed(m_cp_swap_chain->ResizeBuffers(GetSettings().frame_buffers_count, frame_size.GetWidth(), frame_size.GetHeight(), desc.Format, desc.Flags), + m_swap_chain_cptr->GetDesc1(&desc); + ThrowIfFailed(m_swap_chain_cptr->ResizeBuffers(GetSettings().frame_buffers_count, frame_size.GetWidth(), + frame_size.GetHeight(), desc.Format, desc.Flags), GetDirectDevice().GetNativeDevice().Get()); UpdateFrameBufferIndex(); @@ -207,8 +210,8 @@ void RenderContext::Present() const uint32_t present_flags = GetPresentFlags(); const uint32_t vsync_interval = GetPresentVSyncInterval(); - META_CHECK_ARG_NOT_NULL(m_cp_swap_chain); - ThrowIfFailed(m_cp_swap_chain->Present(vsync_interval, present_flags), + META_CHECK_ARG_NOT_NULL(m_swap_chain_cptr); + ThrowIfFailed(m_swap_chain_cptr->Present(vsync_interval, present_flags), GetDirectDevice().GetNativeDevice().Get()); Context::OnCpuPresentComplete(); @@ -218,8 +221,8 @@ void RenderContext::Present() uint32_t RenderContext::GetNextFrameBufferIndex() { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_cp_swap_chain); - return m_cp_swap_chain->GetCurrentBackBufferIndex(); + META_CHECK_ARG_NOT_NULL(m_swap_chain_cptr); + return m_swap_chain_cptr->GetCurrentBackBufferIndex(); } void RenderContext::WaitForSwapChainLatency() diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderPass.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderPass.cpp index ec91cb8d3..a5135d1d7 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderPass.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderPass.cpp @@ -361,16 +361,16 @@ void RenderPass::Begin(Base::RenderCommandList& command_list) SetNativeDescriptorHeaps(command_list_dx); - ID3D12GraphicsCommandList4* p_dx_command_list_4 = command_list_dx.GetNativeCommandList4(); + ID3D12GraphicsCommandList4* dx_command_list_4_ptr = command_list_dx.GetNativeCommandList4(); if (!m_is_native_render_pass_available.has_value() || m_is_native_render_pass_available.value()) { - m_is_native_render_pass_available = !!p_dx_command_list_4; + m_is_native_render_pass_available = !!dx_command_list_4_ptr; } if (m_is_native_render_pass_available.value()) { // Begin render pass - p_dx_command_list_4->BeginRenderPass( + dx_command_list_4_ptr->BeginRenderPass( static_cast(m_render_target_descs.size()), m_render_target_descs.data(), m_depth_stencil_desc ? &*m_depth_stencil_desc : nullptr, m_pass_flags @@ -401,9 +401,9 @@ void RenderPass::End(Base::RenderCommandList& command_list) if (m_is_native_render_pass_available.has_value() && m_is_native_render_pass_available.value()) { - ID3D12GraphicsCommandList4* p_dx_command_list_4 = static_cast(command_list).GetNativeCommandList4(); - META_CHECK_ARG_NOT_NULL(p_dx_command_list_4); - p_dx_command_list_4->EndRenderPass(); + ID3D12GraphicsCommandList4* dx_command_list_4_ptr = static_cast(command_list).GetNativeCommandList4(); + META_CHECK_ARG_NOT_NULL(dx_command_list_4_ptr); + dx_command_list_4_ptr->EndRenderPass(); } if (GetBasePattern().GetSettings().is_final_pass) @@ -433,8 +433,8 @@ void RenderPass::SetNativeRenderTargets(const RenderCommandList& dx_command_list { META_FUNCTION_TASK(); const std::vector& rt_cpu_handles = GetNativeRenderTargetCPUHandles(); - const D3D12_CPU_DESCRIPTOR_HANDLE* p_depth_stencil_cpu_handle = GetNativeDepthStencilCPUHandle(); - dx_command_list.GetNativeCommandList().OMSetRenderTargets(static_cast(rt_cpu_handles.size()), rt_cpu_handles.data(), FALSE, p_depth_stencil_cpu_handle); + const D3D12_CPU_DESCRIPTOR_HANDLE* depth_stencil_cpu_handle_ptr = GetNativeDepthStencilCPUHandle(); + dx_command_list.GetNativeCommandList().OMSetRenderTargets(static_cast(rt_cpu_handles.size()), rt_cpu_handles.data(), FALSE, depth_stencil_cpu_handle_ptr); } const std::vector& RenderPass::GetNativeDescriptorHeaps() const diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderState.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderState.cpp index 32a2e3107..348f6b50e 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderState.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/RenderState.cpp @@ -52,9 +52,9 @@ constexpr size_t g_max_rtv_count = sizeof(D3D12_GRAPHICS_PIPELINE_STATE_DESC::RT inline CD3DX12_SHADER_BYTECODE GetShaderByteCode(const Ptr& shader_ptr) { META_FUNCTION_TASK(); - const Data::Chunk* p_byte_code_chunk = shader_ptr ? static_cast(*shader_ptr).GetNativeByteCode() : nullptr; - return p_byte_code_chunk - ? CD3DX12_SHADER_BYTECODE(p_byte_code_chunk->GetDataPtr(), p_byte_code_chunk->GetDataSize()) + const Data::Chunk* byte_code_chunk_ptr = shader_ptr ? static_cast(*shader_ptr).GetNativeByteCode() : nullptr; + return byte_code_chunk_ptr + ? CD3DX12_SHADER_BYTECODE(byte_code_chunk_ptr->GetDataPtr(), byte_code_chunk_ptr->GetDataSize()) : CD3DX12_SHADER_BYTECODE(nullptr, 0); } @@ -275,7 +275,7 @@ void RenderState::Reset(const Settings& settings) ? TypeConverter::PixelFormatToDxgi(attachment_formats.depth) : DXGI_FORMAT_UNKNOWN; - m_cp_pipeline_state.Reset(); + m_pipeline_state_cptr.Reset(); } void RenderState::Apply(Base::RenderCommandList& command_list, Groups state_groups) @@ -303,9 +303,9 @@ bool RenderState::SetName(std::string_view name) if (!Base::RenderState::SetName(name)) return false; - if (m_cp_pipeline_state) + if (m_pipeline_state_cptr) { - m_cp_pipeline_state->SetName(nowide::widen(name).c_str()); + m_pipeline_state_cptr->SetName(nowide::widen(name).c_str()); } return true; } @@ -313,22 +313,22 @@ bool RenderState::SetName(std::string_view name) void RenderState::InitializeNativePipelineState() { META_FUNCTION_TASK(); - if (m_cp_pipeline_state) + if (m_pipeline_state_cptr) return; - const wrl::ComPtr& cp_native_device = GetDirectRenderContext().GetDirectDevice().GetNativeDevice(); - ThrowIfFailed(cp_native_device->CreateGraphicsPipelineState(&m_pipeline_state_desc, IID_PPV_ARGS(&m_cp_pipeline_state)), cp_native_device.Get()); + const wrl::ComPtr& native_device_cptr = GetDirectRenderContext().GetDirectDevice().GetNativeDevice(); + ThrowIfFailed(native_device_cptr->CreateGraphicsPipelineState(&m_pipeline_state_desc, IID_PPV_ARGS(&m_pipeline_state_cptr)), native_device_cptr.Get()); SetName(GetName()); } wrl::ComPtr& RenderState::GetNativePipelineState() { META_FUNCTION_TASK(); - if (!m_cp_pipeline_state) + if (!m_pipeline_state_cptr) { InitializeNativePipelineState(); } - return m_cp_pipeline_state; + return m_pipeline_state_cptr; } Program& RenderState::GetDirectProgram() diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Sampler.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Sampler.cpp index d70b5f042..81e9eceda 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Sampler.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Sampler.cpp @@ -180,26 +180,26 @@ static D3D12_TEXTURE_ADDRESS_MODE ConvertAddressModeToDirectX(Rhi::ISampler::Add } } -static void SetColor(const Color4F& in_color, FLOAT* p_out_color) +static void SetColor(const Color4F& in_color, FLOAT* out_color_ptr) { META_FUNCTION_TASK(); for (Data::Size i = 0; i < Color4F::Size; ++i) { - p_out_color[i] = in_color[i]; + out_color_ptr[i] = in_color[i]; } } -static void ConvertBorderColorToDXColor(Rhi::ISampler::BorderColor border_color, FLOAT* p_out_color) +static void ConvertBorderColorToDXColor(Rhi::ISampler::BorderColor border_color, FLOAT* out_color_ptr) { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(p_out_color); + META_CHECK_ARG_NOT_NULL(out_color_ptr); using BorderColor = Rhi::ISampler::BorderColor; switch (border_color) { - case BorderColor::TransparentBlack: SetColor({ 0.F, 0.F, 0.F, 0.F }, p_out_color); break; - case BorderColor::OpaqueBlack: SetColor({ 0.F, 0.F, 0.F, 1.F }, p_out_color); break; - case BorderColor::OpaqueWhite: SetColor({ 1.F, 1.F, 1.F, 1.F }, p_out_color); break; + case BorderColor::TransparentBlack: SetColor({ 0.F, 0.F, 0.F, 0.F }, out_color_ptr); break; + case BorderColor::OpaqueBlack: SetColor({ 0.F, 0.F, 0.F, 1.F }, out_color_ptr); break; + case BorderColor::OpaqueWhite: SetColor({ 1.F, 1.F, 1.F, 1.F }, out_color_ptr); break; default: META_UNEXPECTED_ARG(border_color); } } diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Shader.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Shader.cpp index 702149d3e..25378a043 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Shader.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Shader.cpp @@ -161,12 +161,12 @@ Shader::Shader(Type type, const Base::Context& context, const Settings& settings settings.source_compile_target.c_str(), shader_compile_flags, 0, - &m_cp_byte_code, + &m_byte_code_cptr, &error_blob ), error_blob); - m_byte_code_chunk_ptr = std::make_unique(static_cast(m_cp_byte_code->GetBufferPointer()), - static_cast(m_cp_byte_code->GetBufferSize())); + m_byte_code_chunk_ptr = std::make_unique(static_cast(m_byte_code_cptr->GetBufferPointer()), + static_cast(m_byte_code_cptr->GetBufferSize())); } else { @@ -175,18 +175,18 @@ Shader::Shader(Type type, const Base::Context& context, const Settings& settings } META_CHECK_ARG_NOT_NULL(m_byte_code_chunk_ptr); - ThrowIfFailed(D3DReflect(m_byte_code_chunk_ptr->GetDataPtr(), m_byte_code_chunk_ptr->GetDataSize(), IID_PPV_ARGS(&m_cp_reflection))); + ThrowIfFailed(D3DReflect(m_byte_code_chunk_ptr->GetDataPtr(), m_byte_code_chunk_ptr->GetDataSize(), IID_PPV_ARGS(&m_reflection_cptr))); } Ptrs Shader::GetArgumentBindings(const Rhi::ProgramArgumentAccessors& argument_accessors) const { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_cp_reflection); + META_CHECK_ARG_NOT_NULL(m_reflection_cptr); Ptrs argument_bindings; D3D12_SHADER_DESC shader_desc{}; - ThrowIfFailed(m_cp_reflection->GetDesc(&shader_desc)); + ThrowIfFailed(m_reflection_cptr->GetDesc(&shader_desc)); #ifdef METHANE_LOGGING_ENABLED std::stringstream log_ss; @@ -198,14 +198,14 @@ Ptrs Shader::GetArgumentBindings(const Rhi::Progra for (UINT resource_index = 0; resource_index < shader_desc.BoundResources; ++resource_index) { D3D12_SHADER_INPUT_BIND_DESC binding_desc{}; - ThrowIfFailed(m_cp_reflection->GetResourceBindingDesc(resource_index, &binding_desc)); + ThrowIfFailed(m_reflection_cptr->GetResourceBindingDesc(resource_index, &binding_desc)); const Rhi::ProgramArgumentAccessType arg_access_type = Rhi::ProgramArgumentAccessor::GetTypeByRegisterSpace(binding_desc.Space); const Rhi::ProgramArgument shader_argument(GetType(), Base::Shader::GetCachedArgName(binding_desc.Name)); const Rhi::ProgramArgumentAccessor* argument_ptr = Rhi::IProgram::FindArgumentAccessor(argument_accessors, shader_argument); const Rhi::ProgramArgumentAccessor argument_acc = argument_ptr ? *argument_ptr : Rhi::ProgramArgumentAccessor(shader_argument, arg_access_type); - const D3D12_SHADER_BUFFER_DESC buffer_desc = GetConstantBufferDesc(*m_cp_reflection.Get(), binding_desc); + const D3D12_SHADER_BUFFER_DESC buffer_desc = GetConstantBufferDesc(*m_reflection_cptr.Get(), binding_desc); ProgramArgumentBindingType dx_binding_type = ProgramArgumentBindingType::DescriptorTable; if (argument_acc.IsRootConstant()) @@ -270,10 +270,10 @@ Ptrs Shader::GetArgumentBindings(const Rhi::Progra std::vector Shader::GetNativeProgramInputLayout(const Program& program) const { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_cp_reflection); + META_CHECK_ARG_NOT_NULL(m_reflection_cptr); D3D12_SHADER_DESC shader_desc{}; - m_cp_reflection->GetDesc(&shader_desc); + m_reflection_cptr->GetDesc(&shader_desc); #ifdef METHANE_LOGGING_ENABLED std::stringstream log_ss; @@ -287,7 +287,7 @@ std::vector Shader::GetNativeProgramInputLayout(const for (UINT param_index = 0; param_index < shader_desc.InputParameters; ++param_index) { D3D12_SIGNATURE_PARAMETER_DESC param_desc{}; - m_cp_reflection->GetInputParameterDesc(param_index, ¶m_desc); + m_reflection_cptr->GetInputParameterDesc(param_index, ¶m_desc); #ifdef METHANE_LOGGING_ENABLED log_ss << " - Parameter " << param_index diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/System.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/System.cpp index 2cfc8b70d..b3263961b 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/System.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/System.cpp @@ -115,7 +115,7 @@ System::~System() UnregisterAdapterChangeEvent(); #endif - m_cp_factory.Reset(); + m_factory_cptr.Reset(); ClearDevices(); ReportLiveObjects(); @@ -131,8 +131,8 @@ void System::Initialize() dxgi_factory_flags |= DXGI_CREATE_FACTORY_DEBUG; #endif - ThrowIfFailed(CreateDXGIFactory2(dxgi_factory_flags, IID_PPV_ARGS(&m_cp_factory))); - META_CHECK_ARG_NOT_NULL(m_cp_factory); + ThrowIfFailed(CreateDXGIFactory2(dxgi_factory_flags, IID_PPV_ARGS(&m_factory_cptr))); + META_CHECK_ARG_NOT_NULL(m_factory_cptr); #ifdef ADAPTERS_CHANGE_HANDLING RegisterAdapterChangeEvent(); @@ -144,8 +144,8 @@ void System::Initialize() void System::RegisterAdapterChangeEvent() { META_FUNCTION_TASK(); - wrl::ComPtr cp_factory7; - if (!SUCCEEDED(m_cp_factory->QueryInterface(IID_PPV_ARGS(&cp_factory7)))) + wrl::ComPtrQueryInterface(IID_PPV_ARGS&factory7_cptr)))) return; m_adapter_change_event = CreateEvent(nullptr, FALSE, FALSE, nullptr); @@ -154,20 +154,20 @@ void System::RegisterAdapterChangeEvent() ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError())); } - META_CHECK_ARG_NOT_NULL(cp_factory7); - ThrowIfFailed(cp_factory7->RegisterAdaptersChangedEvent(m_adapter_change_event, &m_adapter_change_registration_cookie)); + META_CHECK_ARG_NOT_NULL(factory7_cptr); + ThrowIfFailed(factory7_cptr->RegisterAdaptersChangedEvent(m_adapter_change_event, &m_adapter_change_registration_cookie)); } void System::UnregisterAdapterChangeEvent() { META_FUNCTION_TASK(); - wrl::ComPtr cp_factory7; + wrl::ComPtrQueryInterface(IID_PPV_ARGS(&cp_factory7)))) + !SUCCEEDED(m_factory_cptr->QueryInterface(IID_PPV_ARGS&factory7_cptr)))) return; - META_CHECK_ARG_NOT_NULL(cp_factory7); - ThrowIfFailed(cp_factory7->UnregisterAdaptersChangedEvent(m_adapter_change_registration_cookie)); + META_CHECK_ARG_NOT_NULL(factory7_cptr); + ThrowIfFailed(factory7_cptr->UnregisterAdaptersChangedEvent(m_adapter_change_registration_cookie)); m_adapter_change_registration_cookie = 0; CloseHandle(m_adapter_change_event); @@ -182,7 +182,7 @@ void System::CheckForChanges() #ifdef ADAPTERS_CHANGE_HANDLING const bool adapters_changed = m_adapter_change_event ? WaitForSingleObject(m_adapter_change_event, 0) == WAIT_OBJECT_0 - : !m_cp_factory->IsCurrent(); + : !m_factory_cptr->IsCurrent(); if (!adapters_changed) return; @@ -225,45 +225,45 @@ const Ptrs& System::UpdateGpuDevices(const Platform::AppEnvironmen const Ptrs& System::UpdateGpuDevices(const Rhi::DeviceCaps& required_device_caps) { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_cp_factory); + META_CHECK_ARG_NOT_NULL(m_factory_cptr); const D3D_FEATURE_LEVEL dx_feature_level = D3D_FEATURE_LEVEL_11_0; SetDeviceCapabilities(required_device_caps); ClearDevices(); - IDXGIAdapter1* p_adapter = nullptr; - for (UINT adapter_index = 0; DXGI_ERROR_NOT_FOUND != m_cp_factory->EnumAdapters1(adapter_index, &p_adapter); ++adapter_index) + IDXGIAdapter1* adapter_ptr = nullptr; + for (UINT adapter_index = 0; DXGI_ERROR_NOT_FOUND != m_factory_cptr->EnumAdapters1(adapter_index, &adapter_ptr); ++adapter_index) { - META_CHECK_ARG_NOT_NULL(p_adapter); - if (IsSoftwareAdapterDxgi(*p_adapter)) + META_CHECK_ARG_NOT_NULL(adapter_ptr); + if (IsSoftwareAdapterDxgi(*adapter_ptr)) continue; - AddDevice(p_adapter, dx_feature_level); + AddDevice(adapter_ptr, dx_feature_level); } - wrl::ComPtr cp_warp_adapter; - m_cp_factory->EnumWarpAdapter(IID_PPV_ARGS(&cp_warp_adapter)); - if (cp_warp_adapter) + wrl::ComPtr warp_adapter_cptr; + m_factory_cptr->EnumWarpAdapter(IID_PPV_ARGS(&warp_adapter_cptr)); + if(warp_adapter_cptr) { - AddDevice(cp_warp_adapter, dx_feature_level); + AddDevice(warp_adapter_cptr, dx_feature_level); } return GetGpuDevices(); } -void System::AddDevice(const wrl::ComPtr& cp_adapter, D3D_FEATURE_LEVEL feature_level) +void System::AddDevice(const wrl::ComPtr& adapter_cptr, D3D_FEATURE_LEVEL feature_level) { META_FUNCTION_TASK(); // Check to see if the adapter supports Direct3D 12, but don't create the actual device yet - if (!SUCCEEDED(D3D12CreateDevice(cp_adapter.Get(), feature_level, _uuidof(ID3D12Device), nullptr))) + if (!SUCCEEDED(D3D12CreateDevice(adapter_cptr.Get(), feature_level, _uuidof(ID3D12Device), nullptr))) return; - if (const Rhi::DeviceFeatureMask device_supported_features = Device::GetSupportedFeatures(cp_adapter, feature_level); + if (const Rhi::DeviceFeatureMask device_supported_features = Device::GetSupportedFeatures(adapter_cptr, feature_level); !device_supported_features.HasBits(GetDeviceCapabilities().features)) return; - Base::System::AddDevice(std::make_shared(cp_adapter, feature_level, GetDeviceCapabilities())); + Base::System::AddDevice(std::make_shared(adapter_cptr, feature_level, GetDeviceCapabilities())); } void System::ReportLiveObjects() const noexcept diff --git a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Texture.cpp b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Texture.cpp index 734256109..705fd0230 100644 --- a/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Texture.cpp +++ b/Modules/Graphics/RHI/DirectX/Sources/Methane/Graphics/DirectX/Texture.cpp @@ -349,13 +349,13 @@ bool Texture::SetName(std::string_view name) if (!Resource::SetName(name)) return false; - if (m_cp_upload_resource) + if (m_upload_resource_cptr) { - m_cp_upload_resource->SetName(nowide::widen(fmt::format("{} Upload Resource", name)).c_str()); + m_upload_resource_cptr->SetName(nowide::widen(fmt::format("{} Upload Resource", name)).c_str()); } - if (m_cp_read_back_resource) + if (m_read_back_resource_cptr) { - m_cp_read_back_resource->SetName(nowide::widen(fmt::format("{} Read-back Resource", name)).c_str()); + m_read_back_resource_cptr->SetName(nowide::widen(fmt::format("{} Read-back Resource", name)).c_str()); } return true; @@ -364,7 +364,7 @@ bool Texture::SetName(std::string_view name) void Texture::SetData(Rhi::ICommandQueue& target_cmd_queue, const SubResources& sub_resources) { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL_DESCR(m_cp_upload_resource, "Only Image textures support data upload from CPU."); + META_CHECK_ARG_NOT_NULL_DESCR(m_upload_resource_cptr, "Only Image textures support data upload from CPU."); Base::Texture::SetData(target_cmd_queue, sub_resources); @@ -400,7 +400,7 @@ void Texture::SetData(Rhi::ICommandQueue& target_cmd_queue, const SubResources& // Upload texture subresources data to GPU via intermediate upload resource const TransferCommandList& upload_cmd_list = PrepareResourceTransfer(TransferOperation::Upload, target_cmd_queue, State::CopyDest); UpdateSubresources(&upload_cmd_list.GetNativeCommandList(), - GetNativeResource(), m_cp_upload_resource.Get(), 0, 0, + GetNativeResource(), m_upload_resource_cptr.Get(), 0, 0, static_cast(dx_sub_resources.size()), dx_sub_resources.data()); GetContext().RequestDeferredAction(Rhi::IContext::DeferredAction::UploadResources); } @@ -410,7 +410,7 @@ Rhi::SubResource Texture::GetData(Rhi::ICommandQueue& target_cmd_queue, const Su META_FUNCTION_TASK(); META_CHECK_ARG_TRUE_DESCR(GetUsage().HasAnyBit(Rhi::ResourceUsage::ReadBack), "getting texture data from GPU is allowed for buffers with CPU Read-back flag only"); - META_CHECK_ARG_NOT_NULL(m_cp_read_back_resource); + META_CHECK_ARG_NOT_NULL(m_read_back_resource_cptr); ValidateSubResource(sub_resource_index, data_range); @@ -430,7 +430,7 @@ Rhi::SubResource Texture::GetData(Rhi::ICommandQueue& target_cmd_queue, const Su } }; const CD3DX12_TEXTURE_COPY_LOCATION src_copy_location(GetNativeResource(), sub_resource_raw_index); - const CD3DX12_TEXTURE_COPY_LOCATION dst_copy_location(m_cp_read_back_resource.Get(), src_footprint); + const CD3DX12_TEXTURE_COPY_LOCATION dst_copy_location(m_read_back_resource_cptr.Get(), src_footprint); transfer_cmd_list.GetNativeCommandList().CopyTextureRegion(&dst_copy_location, 0, 0, 0, &src_copy_location, nullptr); GetBaseContext().UploadResources(); @@ -440,21 +440,21 @@ Rhi::SubResource Texture::GetData(Rhi::ICommandQueue& target_cmd_queue, const Su const Data::Index data_end = data_start + data_length; const CD3DX12_RANGE read_range(data_start, data_start + data_length); - Data::RawPtr p_sub_resource_data = nullptr; + Data::RawPtr sub_resource_data_ptr = nullptr; ThrowIfFailed( - m_cp_read_back_resource->Map(sub_resource_raw_index, &read_range, - reinterpret_cast(&p_sub_resource_data)), // NOSONAR + m_read_back_resource_cptr->Map(sub_resource_raw_index, &read_range, + reinterpret_cast(&sub_resource_data_ptr)), // NOSONAR GetDirectContext().GetDirectDevice().GetNativeDevice().Get() ); - META_CHECK_ARG_NOT_NULL_DESCR(p_sub_resource_data, "failed to map buffer subresource"); + META_CHECK_ARG_NOT_NULL_DESCR(sub_resource_data_ptr, "failed to map buffer subresource"); - stdext::checked_array_iterator source_data_it(p_sub_resource_data, data_end); + stdext::checked_array_iterator source_data_it(sub_resource_data_ptr, data_end); Data::Bytes sub_resource_data(data_length, {}); std::copy(source_data_it + data_start, source_data_it + data_end, sub_resource_data.begin()); const CD3DX12_RANGE zero_write_range(0, 0); - m_cp_read_back_resource->Unmap(sub_resource_raw_index, &zero_write_range); + m_read_back_resource_cptr->Unmap(sub_resource_raw_index, &zero_write_range); return SubResource(std::move(sub_resource_data), sub_resource_index, data_range); } @@ -526,11 +526,11 @@ void Texture::InitializeAsImage() InitializeCommittedResource(resource_desc, D3D12_HEAP_TYPE_DEFAULT, Rhi::ResourceState::CopyDest); const UINT64 texture_buffer_size = GetRequiredIntermediateSize(GetNativeResource(), 0, GetSubresourceCount().GetRawCount()); - m_cp_upload_resource = CreateCommittedResource(CD3DX12_RESOURCE_DESC::Buffer(texture_buffer_size), D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ); + m_upload_resource_cptr = CreateCommittedResource(CD3DX12_RESOURCE_DESC::Buffer(texture_buffer_size), D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ); if (settings.usage_mask.HasAnyBit(Usage::ReadBack)) { - m_cp_read_back_resource = CreateCommittedResource(CD3DX12_RESOURCE_DESC::Buffer(texture_buffer_size), D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_STATE_COPY_DEST); + m_read_back_resource_cptr = CreateCommittedResource(CD3DX12_RESOURCE_DESC::Buffer(texture_buffer_size), D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_STATE_COPY_DEST); } } @@ -552,12 +552,12 @@ void Texture::InitializeAsFrameBuffer() META_CHECK_ARG_TRUE_DESCR(GetUsage().HasAnyBit(Usage::RenderTarget), "frame-buffer texture supports only 'RenderTarget' usage"); META_CHECK_ARG_TRUE_DESCR(GetSettings().frame_index_opt.has_value(), "frame-buffer texture requires frame-index to be set in texture settings"); - wrl::ComPtr cp_resource; + wrl::ComPtr resource_cptr; ThrowIfFailed( - static_cast(GetDirectContext()).GetNativeSwapChain()->GetBuffer(settings.frame_index_opt.value(), IID_PPV_ARGS(&cp_resource)), + static_cast(GetDirectContext()).GetNativeSwapChain()->GetBuffer(settings.frame_index_opt.value(), IID_PPV_ARGS(&resource_cptr)), GetDirectContext().GetDirectDevice().GetNativeDevice().Get() ); - SetNativeResourceComPtr(cp_resource); + SetNativeResourceComPtr(resource_cptr); } void Texture::InitializeAsDepthStencil() @@ -701,8 +701,8 @@ void Texture::GenerateMipLevels(std::vector& dx_sub_reso { for (uint32_t mip = 1; mip < tex_metadata.mipLevels; ++mip) { - const ::DirectX::Image* p_mip_image = scratch_image.GetImage(mip, item, depth); - META_CHECK_ARG_NOT_NULL_DESCR(p_mip_image, + const ::DirectX::Image* mip_image_ptr = scratch_image.GetImage(mip, item, depth); + META_CHECK_ARG_NOT_NULL_DESCR(mip_image_ptr, "failed to generate mipmap level {} for array item {} in depth {} of texture '{}'", mip, item, depth, GetName()); @@ -710,9 +710,9 @@ void Texture::GenerateMipLevels(std::vector& dx_sub_reso META_CHECK_ARG_LESS(dx_sub_resource_index, dx_sub_resources.size()); D3D12_SUBRESOURCE_DATA& dx_sub_resource = dx_sub_resources[dx_sub_resource_index]; - dx_sub_resource.pData = p_mip_image->pixels; - dx_sub_resource.RowPitch = p_mip_image->rowPitch; - dx_sub_resource.SlicePitch = p_mip_image->slicePitch; + dx_sub_resource.pData = mip_image_ptr->pixels; + dx_sub_resource.RowPitch = mip_image_ptr->rowPitch; + dx_sub_resource.SlicePitch = mip_image_ptr->slicePitch; } } } diff --git a/Modules/Graphics/RHI/Interface/Sources/Methane/Graphics/RHI/IResourceBarriers.cpp b/Modules/Graphics/RHI/Interface/Sources/Methane/Graphics/RHI/IResourceBarriers.cpp index dbb545321..f2aa3923c 100644 --- a/Modules/Graphics/RHI/Interface/Sources/Methane/Graphics/RHI/IResourceBarriers.cpp +++ b/Modules/Graphics/RHI/Interface/Sources/Methane/Graphics/RHI/IResourceBarriers.cpp @@ -39,17 +39,17 @@ ResourceBarrierId::ResourceBarrierId(Type type, Rhi::IResource& resource) noexce bool ResourceBarrierId::operator<(const ResourceBarrierId& other) const noexcept { META_FUNCTION_TASK(); - const Rhi::IResource* p_this_resource = std::addressof(m_resource_ref.get()); - const Rhi::IResource* p_other_resource = std::addressof(other.GetResource()); - return std::tie(m_type, p_this_resource) < std::tie(other.m_type, p_other_resource); + const Rhi::IResource* this_resource_ptr = std::addressof(m_resource_ref.get()); + const Rhi::IResource* other_resource_ptr = std::addressof(other.GetResource()); + return std::tie(m_type, this_resource_ptr) < std::tie(other.m_type, other_resource_ptr); } bool ResourceBarrierId::operator==(const ResourceBarrierId& other) const noexcept { META_FUNCTION_TASK(); - const Rhi::IResource* p_this_resource = std::addressof(m_resource_ref.get()); - const Rhi::IResource* p_other_resource = std::addressof(other.GetResource()); - return std::tie(m_type, p_this_resource) == std::tie(other.m_type, p_other_resource); + const Rhi::IResource* this_resource_ptr = std::addressof(m_resource_ref.get()); + const Rhi::IResource* other_resource_ptr = std::addressof(other.GetResource()); + return std::tie(m_type, this_resource_ptr) == std::tie(other.m_type, other_resource_ptr); } bool ResourceBarrierId::operator!=(const ResourceBarrierId& other) const noexcept diff --git a/Modules/Graphics/RHI/Vulkan/Include/Methane/Graphics/Vulkan/ProgramBindings.h b/Modules/Graphics/RHI/Vulkan/Include/Methane/Graphics/Vulkan/ProgramBindings.h index 665ea01cf..02ab06377 100644 --- a/Modules/Graphics/RHI/Vulkan/Include/Methane/Graphics/Vulkan/ProgramBindings.h +++ b/Modules/Graphics/RHI/Vulkan/Include/Methane/Graphics/Vulkan/ProgramBindings.h @@ -55,7 +55,7 @@ class ProgramBindings final void CompleteInitialization() override; void Apply(ICommandList& command_list, const Rhi::ICommandQueue& command_queue, - const Base::ProgramBindings* p_applied_program_bindings, ApplyBehaviorMask apply_behavior) const; + const Base::ProgramBindings* applied_program_bindings_ptr, ApplyBehaviorMask apply_behavior) const; protected: // IProgramBindings::IProgramArgumentBindingCallback diff --git a/Modules/Graphics/RHI/Vulkan/Sources/Methane/Graphics/Vulkan/ProgramBindings.cpp b/Modules/Graphics/RHI/Vulkan/Sources/Methane/Graphics/Vulkan/ProgramBindings.cpp index b414fe929..b61d7e4c1 100644 --- a/Modules/Graphics/RHI/Vulkan/Sources/Methane/Graphics/Vulkan/ProgramBindings.cpp +++ b/Modules/Graphics/RHI/Vulkan/Sources/Methane/Graphics/Vulkan/ProgramBindings.cpp @@ -184,7 +184,7 @@ void ProgramBindings::Apply(Base::CommandList& command_list, ApplyBehaviorMask a } void ProgramBindings::Apply(ICommandList& command_list_vk, const Rhi::ICommandQueue& command_queue, - const Base::ProgramBindings* p_applied_program_bindings, ApplyBehaviorMask apply_behavior) const + const Base::ProgramBindings* applied_program_bindings_ptr, ApplyBehaviorMask apply_behavior) const { META_FUNCTION_TASK(); META_CHECK_ARG_NOT_EMPTY(m_descriptor_sets); @@ -193,7 +193,7 @@ void ProgramBindings::Apply(ICommandList& command_list_vk, const Rhi::ICommandQu apply_access.SetBitOn(Rhi::ProgramArgumentAccessType::Mutable); uint32_t first_descriptor_set_layout_index = 0U; - if (apply_behavior == ApplyBehaviorMask(ApplyBehavior::ConstantOnce) && p_applied_program_bindings) + if (apply_behavior == ApplyBehaviorMask(ApplyBehavior::ConstantOnce) && applied_program_bindings_ptr) { if (!m_has_mutable_descriptor_set) return; diff --git a/Modules/Platform/App/Sources/Methane/Platform/Linux/AppLin.cpp b/Modules/Platform/App/Sources/Methane/Platform/Linux/AppLin.cpp index 428e5c0cb..ec13a0a36 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Linux/AppLin.cpp +++ b/Modules/Platform/App/Sources/Methane/Platform/Linux/AppLin.cpp @@ -330,11 +330,11 @@ static void AddIconData(const Data::Chunk& icon_data, std::vector& com int image_width = 0; int image_height = 0; int image_channels_count = 0; - stbi_uc* p_image_data = stbi_load_from_memory(reinterpret_cast(icon_data.GetDataPtr()), // NOSONAR + stbi_uc image_data_ptr = stbi_load_from_memory(reinterpret_cast(icon_data.GetDataPtr()), // NOSONAR static_cast(icon_data.GetDataSize()), &image_width, &image_height, &image_channels_count, 4); - META_CHECK_ARG_NOT_NULL_DESCR(p_image_data, "failed to load image data from memory"); + META_CHECK_ARG_NOT_NULL_DESCR(image_data_ptr, "failed to load image data from memory"); META_CHECK_ARG_GREATER_OR_EQUAL_DESCR(image_width, 2, "invalid image width"); META_CHECK_ARG_GREATER_OR_EQUAL_DESCR(image_height, 2, "invalid image height"); META_CHECK_ARG_GREATER_OR_EQUAL_DESCR(image_channels_count, 3, "invalid image channels count"); @@ -348,7 +348,7 @@ static void AddIconData(const Data::Chunk& icon_data, std::vector& com { uint32_t bgra_pixel_data = 0; uint8_t* bgra_pixel = reinterpret_cast(&bgra_pixel_data); // NOSONAR - uint8_t* rgba_pixel = &p_image_data[(y * image_width + x) * 4]; // NOSONAR + uint8_t* rgba_pixel&image_data_ptr[(y * image_width + x) * 4]; // NOSONAR bgra_pixel[0] = rgba_pixel[2]; bgra_pixel[1] = rgba_pixel[1]; diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.hh b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.hh index 40888030f..bb21d58b6 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.hh +++ b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.hh @@ -34,7 +34,7 @@ namespace Methane::Platform { class AppMac; } @property (nonatomic, strong, nonnull) IBOutlet AppViewController* viewController; @property (nonatomic, readwrite, nullable, retain) NSWindow* window; -- (id _Nullable) initWithApp : (Methane::Platform::AppMac* _Nonnull) p_app andSettings : (const Methane::Platform::AppBase::Settings* _Nonnull) p_settings; +- (id _Nullable) initWithApp : (Methane::Platform::AppMac* _Nonnull) app_ptr andSettings : (const Methane::Platform::AppBase::Settings* _Nonnull) settings_ptr; - (void) run; - (void) alert : (nonnull NSString*) ns_title withInformation: (nonnull NSString*) ns_info andStyle: (NSAlertStyle) ns_alert_style; diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.mm b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.mm index 0f98ae157..3fc96ce3f 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.mm +++ b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.mm @@ -40,15 +40,15 @@ @implementation AppDelegate @synthesize window = m_window; -- (id) initWithApp : (AppMac*) p_app andSettings : (const AppBase::Settings*) p_settings +- (id) initWithApp : (AppMac*) app_ptr andSettings : (const AppBase::Settings*) settings_ptr { META_FUNCTION_TASK(); self = [super init]; - if (!self || !p_settings) + if (!self || !settings_ptr) return nil; NSScreen* ns_main_screen = [NSScreen mainScreen]; - const Methane::Data::FloatSize& frame_size = p_settings->size; + const Methane::Data::FloatSize& frame_size = settings_ptr->size; const auto& ns_frame_size = ns_main_screen.frame.size; CGFloat frame_width = frame_size.GetWidth() < 1.0 @@ -58,7 +58,7 @@ - (id) initWithApp : (AppMac*) p_app andSettings : (const AppBase::Settings*) p_ ? ns_frame_size.height * (frame_size.GetHeight() > 0.0 ? frame_size.GetHeight() : 0.7) : static_cast(frame_size.GetHeight()); - const Methane::Data::FrameSize& min_frame_size = p_settings->min_size; + const Methane::Data::FrameSize& min_frame_size = settings_ptr->min_size; NSRect frame = NSMakeRect(0, 0, frame_width, frame_height); NSUInteger style_mask = NSWindowStyleMaskTitled | @@ -70,17 +70,17 @@ - (id) initWithApp : (AppMac*) p_app andSettings : (const AppBase::Settings*) p_ m_window = [[NSWindow alloc] initWithContentRect:frame styleMask:style_mask backing:backing defer:YES]; m_window.contentMinSize = NSMakeSize(static_cast(min_frame_size.GetWidth()), static_cast(min_frame_size.GetHeight())); - m_window.title = MacOS::ConvertToNsString(p_settings->name); + m_window.title = MacOS::ConvertToNsString(settings_ptr->name); - m_window_delegate = [[WindowDelegate alloc] initWithApp:p_app]; + m_window_delegate = [[WindowDelegate alloc] initWithApp:app_ptr]; m_window.delegate = m_window_delegate; [m_window center]; NSRect backing_frame = [ns_main_screen convertRectToBacking:frame]; - self.viewController = [[AppViewController alloc] initWithApp:p_app andFrameRect:backing_frame]; + self.viewController = [[AppViewController alloc] initWithApp:app_ptr andFrameRect:backing_frame]; - p_app->SetWindow(m_window); + app_ptr->SetWindow(m_window); return self; } @@ -129,18 +129,18 @@ - (void) windowWillEnterFullScreen:(NSNotification *)notification { META_FUNCTION_TASK(); #pragma unused(notification) - AppMac* p_app = [self.viewController getApp]; - META_CHECK_ARG_NOT_NULL(p_app); - p_app->SetFullScreenInternal(true); + AppMac* app_ptr = [self.viewController getApp]; + META_CHECK_ARG_NOT_NULL(app_ptr); + app_ptr->SetFullScreenInternal(true); } - (void) windowWillExitFullScreen:(NSNotification *)notification { META_FUNCTION_TASK(); #pragma unused(notification) - AppMac* p_app = [self.viewController getApp]; - META_CHECK_ARG_NOT_NULL(p_app); - p_app->SetFullScreenInternal(false); + AppMac* app_ptr = [self.viewController getApp]; + META_CHECK_ARG_NOT_NULL(app_ptr); + app_ptr->SetFullScreenInternal(false); } - (void) applicationWillTerminate:(NSNotification *)notification diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppMac.mm b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppMac.mm index 42d8edb87..20ebd37a0 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppMac.mm +++ b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppMac.mm @@ -62,10 +62,10 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_ { META_FUNCTION_TASK(); AppView app_view = GetView(); - META_CHECK_ARG_NOT_NULL(app_view.p_native_view); + META_CHECK_ARG_NOT_NULL(app_view.native_view_ptr); META_CHECK_ARG_NOT_NULL(m_ns_window); - [m_ns_window.contentView addSubview: app_view.p_native_view]; + [m_ns_window.contentView addSubview: app_view.native_view_ptr]; } int AppMac::Run(const RunArgs& args) diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.hh b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.hh index 3dbe039e3..272b95449 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.hh +++ b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.hh @@ -29,7 +29,7 @@ namespace Methane::Platform { class AppMac; } @property (nonatomic, readonly, nullable) NSWindow* window; -- (id _Nullable) initWithApp : (Methane::Platform::AppMac* _Nonnull) p_app andFrameRect : (NSRect) frame; +- (id _Nullable) initWithApp : (Methane::Platform::AppMac* _Nonnull app_ptr andFrameRect : (NSRect) frame; - (Methane::Platform::AppMac* _Nonnull) getApp; @end diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.mm b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.mm index 2c983a764..38ffbf706 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.mm +++ b/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.mm @@ -36,13 +36,13 @@ @implementation AppViewController { - pal::AppMac* m_p_app; + pal::AppMac* m_app_ptr; NSRect m_frame_rect; bool m_is_initialized; std::string m_error; } -- (id) initWithApp : (pal::AppMac*) p_app andFrameRect : (NSRect) frame_rect +- (id) initWithApp : (pal::AppMac*) app_ptr andFrameRect : (NSRect) frame_rect { META_FUNCTION_TASK(); @@ -50,7 +50,7 @@ - (id) initWithApp : (pal::AppMac*) p_app andFrameRect : (NSRect) frame_rect if (!self) return nil; - m_p_app = p_app; + m_app_ptr = app_ptr; m_frame_rect = frame_rect; m_is_initialized = false; @@ -60,19 +60,19 @@ - (id) initWithApp : (pal::AppMac*) p_app andFrameRect : (NSRect) frame_rect -(NSWindow*) window { META_FUNCTION_TASK(); - return m_p_app ? m_p_app->GetWindow() : nil; + return m_app_ptr ? m_app_ptr->GetWindow() : nil; } - (pal::AppMac*) getApp { - return m_p_app; + return m_app_ptr; } - (void) loadView { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); - m_p_app->InitContextWithErrorHandling({ self }, data::FrameSize(m_frame_rect.size.width, m_frame_rect.size.height)); + META_CHECK_ARG_NOT_NULL(m_app_ptr); + m_app_ptr->InitContextWithErrorHandling({ self }, data::FrameSize(m_frame_rect.size.width, m_frame_rect.size.height)); } - (void)viewDidLoad @@ -85,27 +85,27 @@ - (void)viewDidLoad - (void)appView: (nonnull AppViewMetal *) view drawableSizeWillChange: (CGSize)size { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); if (!m_is_initialized) { - m_is_initialized = m_p_app->InitWithErrorHandling(); + m_is_initialized = m_app_ptr->InitWithErrorHandling(); } m_frame_rect = [view frame]; - m_p_app->Resize( data::FrameSize(size.width, size.height), false); + m_app_ptr->Resize( data::FrameSize(size.width, size.height), false); } - (void) drawInView: (nonnull AppViewMetal*) view { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(view) if (!m_is_initialized) { - m_is_initialized = m_p_app->InitWithErrorHandling(); + m_is_initialized = m_app_ptr->InitWithErrorHandling(); } - m_p_app->UpdateAndRenderWithErrorHandling(); + m_app_ptr->UpdateAndRenderWithErrorHandling(); } // ====== Keyboard event handlers ====== @@ -113,27 +113,27 @@ - (void) drawInView: (nonnull AppViewMetal*) view - (void) keyDown:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnKeyboardChanged, + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnKeyboardChanged, pin::Keyboard::KeyConverter({ [event keyCode], [event modifierFlags] }).GetKey(), pin::Keyboard::KeyState::Pressed); } - (void) keyUp:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnKeyboardChanged, + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnKeyboardChanged, pin::Keyboard::KeyConverter({ [event keyCode], [event modifierFlags] }).GetKey(), pin::Keyboard::KeyState::Released); } - (void) flagsChanged:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnModifiersChanged, pin::Keyboard::KeyConverter({ [event keyCode], [event modifierFlags] }).GetModifiers()); + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnModifiersChanged, pin::Keyboard::KeyConverter({ [event keyCode], [event modifierFlags] }).GetModifiers()); } // ====== Mouse event handlers ====== @@ -141,32 +141,32 @@ - (void) flagsChanged:(NSEvent *)event - (void)mouseMoved:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); NSPoint pos = [event locationInWindow]; pos.x *= self.view.window.backingScaleFactor; pos.y = (m_frame_rect.size.height - pos.y) * self.view.window.backingScaleFactor; - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMousePositionChanged, + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMousePositionChanged, pin::Mouse::Position{ static_cast(pos.x), static_cast(pos.y) }); } - (void)mouseDown:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(event) - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, pin::Mouse::Button::Left, pin::Mouse::ButtonState::Pressed); } - (void)mouseUp:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(event) - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, pin::Mouse::Button::Left, pin::Mouse::ButtonState::Released); } @@ -179,20 +179,20 @@ - (void)mouseDragged:(NSEvent *)event - (void)rightMouseDown:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(event) - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, pin::Mouse::Button::Right, pin::Mouse::ButtonState::Pressed); } - (void)rightMouseUp:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(event) - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, pin::Mouse::Button::Right, pin::Mouse::ButtonState::Released); } @@ -205,18 +205,18 @@ - (void)rightMouseDragged:(NSEvent *)event - (void)otherMouseDown:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, static_cast(static_cast([event buttonNumber])), pin::Mouse::ButtonState::Pressed); } - (void)otherMouseUp:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, static_cast(static_cast([event buttonNumber])), pin::Mouse::ButtonState::Released); } @@ -229,25 +229,25 @@ - (void)otherMouseDragged:(NSEvent *)event - (void)mouseEntered:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(event) - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseInWindowChanged, true); + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseInWindowChanged, true); } - (void)mouseExited:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(event) - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseInWindowChanged, false); + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseInWindowChanged, false); } - (void)scrollWheel:(NSEvent *)event { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); pin::Mouse::Scroll scroll([event scrollingDeltaX], -[event scrollingDeltaY]); if ([event hasPreciseScrollingDeltas]) @@ -256,7 +256,7 @@ - (void)scrollWheel:(NSEvent *)event if (fabs(scroll.GetX()) < 0.00001 && fabs(scroll.GetY()) > 0.00001) return; - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseScrollChanged, scroll); + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseScrollChanged, scroll); } @end diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh b/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh index 70d7465ff..b65081b99 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh +++ b/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh @@ -27,6 +27,6 @@ namespace Methane { namespace Platform { class AppMac; } } @interface WindowDelegate : NSObject -- (id _Nullable) initWithApp : (Methane::Platform::AppMac* _Nonnull) p_app; +- (id _Nullable) initWithApp : (Methane::Platform::AppMac* _Nonnull) app_ptr; @end diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm b/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm index 6b6143326..86cbbe1df 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm +++ b/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm @@ -32,11 +32,11 @@ @implementation WindowDelegate { - AppMac* m_p_app; + AppMac* m_app_ptr; Data::FrameSize m_frame_size; } -- (id) initWithApp : (AppMac*) p_app +- (id) initWithApp : (AppMac*) app_ptr { META_FUNCTION_TASK(); @@ -44,7 +44,7 @@ - (id) initWithApp : (AppMac*) p_app if (!self) return nil; - m_p_app = p_app; + m_app_ptr = app_ptr; return self; } @@ -52,73 +52,73 @@ - (id) initWithApp : (AppMac*) p_app - (void) windowDidEnterFullScreen:(NSNotification*) notification { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(notification) - m_p_app->SetFullScreen(true); + m_app_ptr->SetFullScreen(true); } - (void) windowDidExitFullScreen:(NSNotification*) notification { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(notification) - m_p_app->SetFullScreen(false); + m_app_ptr->SetFullScreen(false); } - (void) windowDidMiniaturize:(NSNotification*) notification { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(notification) - m_p_app->Resize(m_p_app->GetFrameSize(), true); + m_app_ptr->Resize(m_app_ptr->GetFrameSize(), true); } - (void) windowDidDeminiaturize:(NSNotification*) notification { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(notification) - m_p_app->Resize(m_p_app->GetFrameSize(), false); + m_app_ptr->Resize(m_app_ptr->GetFrameSize(), false); } - (void) windowWillStartLiveResize:(NSNotification*) notification { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(notification) - m_p_app->StartResizing(); + m_app_ptr->StartResizing(); } - (void) windowDidEndLiveResize:(NSNotification*) notification { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(notification) - m_p_app->EndResizing(); + m_app_ptr->EndResizing(); } - (void) windowDidBecomeKey:(NSNotification*) notification { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(notification) - m_p_app->SetKeyboardFocus(true); + m_app_ptr->SetKeyboardFocus(true); } - (void) windowDidResignKey:(NSNotification*) notification { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(notification) - m_p_app->SetKeyboardFocus(false); + m_app_ptr->SetKeyboardFocus(false); } @end diff --git a/Modules/Platform/App/Sources/Methane/Platform/Windows/AppWin.cpp b/Modules/Platform/App/Sources/Methane/Platform/Windows/AppWin.cpp index 17e399acc..842327bd7 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Windows/AppWin.cpp +++ b/Modules/Platform/App/Sources/Methane/Platform/Windows/AppWin.cpp @@ -261,22 +261,22 @@ LRESULT AppWin::OnWindowResizing(WPARAM w_param, LPARAM l_param) const int32_t min_window_height = settings.min_size.GetHeight() + header; // Update window rectangle with respect to minimum size limit - auto p_window_rect = reinterpret_cast(l_param); // NOSONAR + auto window_rect_ptr = reinterpret_cast(l_param); // NOSONAR - if (p_window_rect->right - p_window_rect->left < min_window_width) + if(window_rect_ptr->right - window_rect_ptr->left < min_window_width) { if (w_param == WMSZ_RIGHT || w_param == WMSZ_BOTTOMRIGHT || w_param == WMSZ_TOPRIGHT) - p_window_rect->right = p_window_rect->left + min_window_width; + window_rect_ptr->right = window_rect_ptr->left + min_window_width; else - p_window_rect->left = p_window_rect->right - min_window_width; + window_rect_ptr->left = window_rect_ptr->right - min_window_width; } - if (p_window_rect->bottom - p_window_rect->top < min_window_height) + if(window_rect_ptr->bottom - window_rect_ptr->top < min_window_height) { if (w_param == WMSZ_BOTTOM || w_param == WMSZ_BOTTOMLEFT || w_param == WMSZ_BOTTOMRIGHT) - p_window_rect->bottom = p_window_rect->top + min_window_height; + window_rect_ptr->bottom = window_rect_ptr->top + min_window_height; else - p_window_rect->top = p_window_rect->bottom - min_window_height; + window_rect_ptr->top = window_rect_ptr->bottom - min_window_height; } return TRUE; @@ -414,8 +414,8 @@ LRESULT CALLBACK AppWin::WindowProc(HWND h_wnd, UINT msg_id, WPARAM w_param, LPA return 0; } - auto p_app = reinterpret_cast(GetWindowLongPtr(h_wnd, GWLP_USERDATA)); // NOSONAR - if (!p_app || !p_app->IsMessageProcessing()) + auto app_ptr = reinterpret_cast(GetWindowLongPtr(h_wnd, GWLP_USERDATA)); // NOSONAR + if (!app_ptr || !app_ptr->IsMessageProcessing()) { return DefWindowProc(h_wnd, msg_id, w_param, l_param); } @@ -426,22 +426,22 @@ LRESULT CALLBACK AppWin::WindowProc(HWND h_wnd, UINT msg_id, WPARAM w_param, LPA #endif switch (msg_id) { - case WM_ALERT: p_app->OnWindowAlert(); break; - case WM_DESTROY: return p_app->OnWindowDestroy(); + case WM_ALERT: app_ptr->OnWindowAlert(); break; + case WM_DESTROY: return app_ptr->OnWindowDestroy(); // Windows resizing events - case WM_ENTERSIZEMOVE: p_app->StartResizing(); break; - case WM_EXITSIZEMOVE: p_app->EndResizing(); break; - case WM_SIZING: return p_app->OnWindowResizing(w_param, l_param); - case WM_SIZE: p_app->OnWindowResized(w_param, l_param); break; + case WM_ENTERSIZEMOVE: app_ptr->StartResizing(); break; + case WM_EXITSIZEMOVE: app_ptr->EndResizing(); break; + case WM_SIZING: return app_ptr->OnWindowResizing(w_param, l_param); + case WM_SIZE: app_ptr->OnWindowResized(w_param, l_param); break; // Keyboard events - case WM_SETFOCUS: p_app->SetKeyboardFocus(true); break; - case WM_KILLFOCUS: p_app->SetKeyboardFocus(false); break; + case WM_SETFOCUS: app_ptr->SetKeyboardFocus(true); break; + case WM_KILLFOCUS: app_ptr->SetKeyboardFocus(false); break; case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: - case WM_SYSKEYUP: p_app->OnWindowKeyboardEvent(w_param, l_param); break; + case WM_SYSKEYUP: app_ptr->OnWindowKeyboardEvent(w_param, l_param); break; // Mouse events case WM_LBUTTONDOWN: @@ -451,11 +451,11 @@ LRESULT CALLBACK AppWin::WindowProc(HWND h_wnd, UINT msg_id, WPARAM w_param, LPA case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: - case WM_XBUTTONUP: return p_app->OnWindowMouseButtonEvent(msg_id, w_param, l_param); - case WM_MOUSEMOVE: return p_app->OnWindowMouseMoveEvent(w_param, l_param); - case WM_MOUSEWHEEL: return p_app->OnWindowMouseWheelEvent(true, w_param, l_param); - case WM_MOUSEHWHEEL: return p_app->OnWindowMouseWheelEvent(false, w_param, l_param); - case WM_MOUSELEAVE: return p_app->OnWindowMouseLeave(); + case WM_XBUTTONUP: return app_ptr->OnWindowMouseButtonEvent(msg_id, w_param, l_param); + case WM_MOUSEMOVE: return app_ptr->OnWindowMouseMoveEvent(w_param, l_param); + case WM_MOUSEWHEEL: return app_ptr->OnWindowMouseWheelEvent(true, w_param, l_param); + case WM_MOUSEHWHEEL: return app_ptr->OnWindowMouseWheelEvent(false, w_param, l_param); + case WM_MOUSELEAVE: return app_ptr->OnWindowMouseLeave(); default: break; } @@ -463,11 +463,11 @@ LRESULT CALLBACK AppWin::WindowProc(HWND h_wnd, UINT msg_id, WPARAM w_param, LPA } catch (std::exception& e) { - p_app->Alert({ Message::Type::Error, "Application Input Error", e.what() }); + app_ptr->Alert({ Message::Type::Error, "Application Input Error", e.what() }); } catch (...) { - p_app->Alert({ Message::Type::Error, "Application Input Error", "Unknown exception occurred." }); + app_ptr->Alert({ Message::Type::Error, "Application Input Error", "Unknown exception occurred." }); } #endif diff --git a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.mm b/Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.mm index 24620f427..4bd35b074 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.mm +++ b/Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.mm @@ -45,13 +45,13 @@ - (id) init if (!self) return nil; - AppIOS * p_app = AppIOS::GetInstance(); - UIScreen* ns_main_screen = [UIScreen mainScreen]; - const auto& ns_frame_size = ns_main_screen.bounds.size; + AppIOS* app_ptr = AppIOS::GetInstance(); + UIScreen* ns_main_screen = [UIScreen mainScreen]; + const auto& ns_frame_size = ns_main_screen.bounds.size; const CGRect backing_frame = CGRectMake(0.f, 0.f, ns_frame_size.width * ns_main_screen.nativeScale, ns_frame_size.height * ns_main_screen.nativeScale); - self.viewController = [[AppViewController alloc] initWithApp:p_app andFrameRect:backing_frame]; + self.viewController = [[AppViewController alloc] initWithApp:app_ptr andFrameRect:backing_frame]; m_window = nil; return self; diff --git a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.hh b/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.hh index cbcfafd53..12f3eb14c 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.hh +++ b/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.hh @@ -31,7 +31,7 @@ namespace Methane::Platform { class AppIOS; } @property (nonatomic, readonly, nullable) UIWindow* window; -- (id _Nullable)initWithApp : (Methane::Platform::AppIOS* _Nonnull) p_app andFrameRect : (CGRect) frame; +- (id _Nullable)initWithApp : (Methane::Platform::AppIOS* _Nonnull) app_ptr andFrameRect : (CGRect) frame; - (Methane::Platform::AppIOS* _Nonnull) getApp; @end diff --git a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.mm b/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.mm index 46705349b..603c7088e 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.mm +++ b/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.mm @@ -53,13 +53,13 @@ @implementation AppViewController { - pal::AppIOS* m_p_app; + pal::AppIOS* m_app_ptr; CGRect m_frame_rect; bool m_is_initialized; std::string m_error; } -- (id)initWithApp : (pal::AppIOS*) p_app andFrameRect : (CGRect) frame_rect +- (id)initWithApp : (pal::AppIOS*) app_ptr andFrameRect : (CGRect) frame_rect { META_FUNCTION_TASK(); @@ -67,7 +67,7 @@ - (id)initWithApp : (pal::AppIOS*) p_app andFrameRect : (CGRect) frame_rect if (!self) return nil; - m_p_app = p_app; + m_app_ptr = app_ptr; m_frame_rect = frame_rect; m_is_initialized = false; @@ -77,19 +77,19 @@ - (id)initWithApp : (pal::AppIOS*) p_app andFrameRect : (CGRect) frame_rect -(nullable UIWindow*) window { META_FUNCTION_TASK(); - return m_p_app ? m_p_app->GetWindow() : nil; + return m_app_ptr ? m_app_ptr->GetWindow() : nil; } - (pal::AppIOS*) getApp { - return m_p_app; + return m_app_ptr; } - (void) loadView { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); - m_p_app->InitContextWithErrorHandling({ self }, data::FrameSize(m_frame_rect.size.width, m_frame_rect.size.height)); + META_CHECK_ARG_NOT_NULL(m_app_ptr); + m_app_ptr->InitContextWithErrorHandling({ self }, data::FrameSize(m_frame_rect.size.width, m_frame_rect.size.height)); } - (void)viewDidLoad @@ -104,27 +104,27 @@ - (void)viewDidLoad - (void)appView: (nonnull AppViewMetal *) view drawableSizeWillChange: (CGSize)size { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); if (!m_is_initialized) { - m_is_initialized = m_p_app->InitWithErrorHandling(); + m_is_initialized = m_app_ptr->InitWithErrorHandling(); } m_frame_rect = [view frame]; - m_p_app->Resize( data::FrameSize(size.width, size.height), false); + m_app_ptr->Resize( data::FrameSize(size.width, size.height), false); } - (void) drawInView: (nonnull AppViewMetal*) view { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); #pragma unused(view) if (!m_is_initialized) { - m_is_initialized = m_p_app->InitWithErrorHandling(); + m_is_initialized = m_app_ptr->InitWithErrorHandling(); } - m_p_app->UpdateAndRenderWithErrorHandling(); + m_app_ptr->UpdateAndRenderWithErrorHandling(); } - (void)touchesBegan:(NSSet *)touches @@ -192,22 +192,22 @@ - (void)touchesMoved:(NSSet *)touches - (void)handleTouchPosition:(UITouch *) touch { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); CGPoint pos = [touch locationInView:self.view]; UIScreen* ns_main_screen = [UIScreen mainScreen]; pos.x *= ns_main_screen.nativeScale; pos.y *= ns_main_screen.nativeScale; - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMousePositionChanged, pin::Mouse::Position{ static_cast(pos.x), static_cast(pos.y) }); + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMousePositionChanged, pin::Mouse::Position{ static_cast(pos.x), static_cast(pos.y) }); } - (void) handeTouches:(NSSet *)touches withMouseButtonChange:(pin::Mouse::ButtonState) mouse_button_state { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_NULL(m_p_app); + META_CHECK_ARG_NOT_NULL(m_app_ptr); const pin::Mouse::Button mouse_button = pin::GetMouseButtonByTouchesCount(static_cast(touches.count)); - m_p_app->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, mouse_button, mouse_button_state); + m_app_ptr->ProcessInputWithErrorHandling(&pin::IActionController::OnMouseButtonChanged, mouse_button, mouse_button_state); } @end diff --git a/Modules/Platform/AppView/Include/Methane/Platform/AppView.h b/Modules/Platform/AppView/Include/Methane/Platform/AppView.h index dd9e37e7d..58f478f88 100644 --- a/Modules/Platform/AppView/Include/Methane/Platform/AppView.h +++ b/Modules/Platform/AppView/Include/Methane/Platform/AppView.h @@ -57,7 +57,7 @@ using NativeAppViewPtr = NativeAppView*; struct AppView { - NativeAppViewPtr p_native_view; + NativeAppViewPtr native_view_ptr; }; class AppViewResizeRequiredError diff --git a/Modules/Platform/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm b/Modules/Platform/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm index df4391fe7..6ba772251 100644 --- a/Modules/Platform/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm +++ b/Modules/Platform/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm @@ -179,12 +179,12 @@ static CVReturn DispatchRenderLoop(CVDisplayLinkRef /*display_link*/, const CVTimeStamp* /*output_time*/, CVOptionFlags /*flags_in*/, CVOptionFlags* /*flags_out*/, - void* p_display_link_context) + void* display_link_context_ptr) { META_FUNCTION_TASK(); // 'DispatchRenderLoop' is always called on a secondary thread. // Merge the dispatch source setup for the main queue so that rendering occurs on the main thread. - __weak dispatch_source_t source = (__bridge dispatch_source_t)p_display_link_context; + __weak dispatch_source_t source = (__bridge dispatch_source_t) display_link_context_ptr; dispatch_source_merge_data(source, 1); return kCVReturnSuccess; } @@ -203,12 +203,12 @@ - (BOOL) setupDisplayLinkForScreen:(NSScreen*) screen // DispatchRenderLoop merges this dispatch source in each call // to execute rendering on the main thread. m_display_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA_ADD, 0, 0, dispatch_get_main_queue()); - __weak AppViewMetal* p_weak_view = self; + __weak AppViewMetal* weak_view_ptr = self; dispatch_source_set_event_handler(m_display_source, ^(){ - if (!p_weak_view.redrawing) + if (!weak_view_ptr.redrawing) return; - [p_weak_view redraw]; + [weak_view_ptr redraw]; }); dispatch_resume(m_display_source); diff --git a/Modules/Platform/Utils/Include/Methane/Platform/Apple/Types.hh b/Modules/Platform/Utils/Include/Methane/Platform/Apple/Types.hh index 2b89910e3..fa0c80ac2 100644 --- a/Modules/Platform/Utils/Include/Methane/Platform/Apple/Types.hh +++ b/Modules/Platform/Utils/Include/Methane/Platform/Apple/Types.hh @@ -53,9 +53,9 @@ inline bool ConvertFromNsBool(BOOL value) return value == YES; } -inline std::string ConvertFromNsString(const NSString* p_ns_str) +inline std::string ConvertFromNsString(const NSString* ns_str_ptr) { - return p_ns_str ? std::string([p_ns_str UTF8String]) : std::string(); + return ns_str_ptr ? std::string([ns_str_ptr UTF8String]) : std::string(); } } // namespace Methane::MacOS diff --git a/Modules/UserInterface/Typography/Sources/Methane/UserInterface/TextMesh.cpp b/Modules/UserInterface/Typography/Sources/Methane/UserInterface/TextMesh.cpp index e4670de64..975bfff95 100644 --- a/Modules/UserInterface/Typography/Sources/Methane/UserInterface/TextMesh.cpp +++ b/Modules/UserInterface/Typography/Sources/Methane/UserInterface/TextMesh.cpp @@ -50,7 +50,7 @@ void ForEachTextCharacterInRange(const Font::Impl& font, const FontChars& text_c { META_FUNCTION_TASK(); META_CHECK_ARG_NOT_EMPTY(char_positions); - const FontChar* p_prev_text_char = nullptr; + const FontChar* prev_text_char_ptr = nullptr; for (size_t char_index = index_range.first; char_index < index_range.second; ++char_index) { @@ -66,7 +66,7 @@ void ForEachTextCharacterInRange(const Font::Impl& font, const FontChars& text_c if (text_char.IsLineBreak()) { char_positions.emplace_back(0, char_pos.GetY() + font.GetLineHeight(), true); - p_prev_text_char = nullptr; + prev_text_char_ptr = nullptr; continue; } @@ -77,25 +77,25 @@ void ForEachTextCharacterInRange(const Font::Impl& font, const FontChars& text_c char_pos.SetX(0); char_pos.SetY(char_pos.GetY() + font.GetLineHeight()); char_pos.is_line_start = true; - p_prev_text_char = nullptr; + prev_text_char_ptr = nullptr; } - if (!p_prev_text_char && char_index && !text_chars[char_index - 1].get().IsLineBreak()) - p_prev_text_char = &(text_chars[char_index - 1].get()); + if (!prev_text_char_ptr && char_index && !text_chars[char_index - 1].get().IsLineBreak()) + prev_text_char_ptr = &(text_chars[char_index - 1].get()); - if (p_prev_text_char) - char_pos += font.GetKerning(*p_prev_text_char, text_char); + if(prev_text_char_ptr) + char_pos += font.GetKerning(*prev_text_char_ptr, text_char); switch (const CharAction action = process_char_at_position(text_char, char_pos, char_index); action) { case CharAction::Continue: char_positions.emplace_back(char_pos.GetX() + text_char.GetAdvance().GetX(), char_pos.GetY()); - p_prev_text_char = &text_char; + prev_text_char_ptr = &text_char; break; case CharAction::Wrap: char_positions.emplace_back(0, char_pos.GetY() + font.GetLineHeight(), true); - p_prev_text_char = nullptr; + prev_text_char_ptr = nullptr; break; case CharAction::Stop: