Skip to content

Commit

Permalink
Rename pointer variables to follow code convention with _ptr suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
egorodet committed Sep 19, 2024
1 parent aaaf92a commit 3dd6478
Show file tree
Hide file tree
Showing 62 changed files with 554 additions and 547 deletions.
61 changes: 31 additions & 30 deletions Modules/Common/Instrumentation/Include/Methane/IttApiHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned long long>(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<unsigned long long>(name_ptr))) // NOSONAR
, m_domain_ptr(domain_ptr)
{ }

template<class T>
typename std::enable_if<std::is_floating_point_v<T>, void>::type AddArg(__itt_string_handle* p_name, const T& value) const noexcept
typename std::enable_if<std::is_floating_point_v<T>, void>::type
AddArg(__itt_string_handle* name_ptr, const T& value) const noexcept
{
double double_value = static_cast<double>(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<void*>(p_value));
__itt_metadata_add(m_domain_ptr, m_id, name_ptr, __itt_metadata_unknown, 1, const_cast<void*>(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
Expand All @@ -104,52 +105,52 @@ 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;
};

template<bool bRegion = true>
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);
}
}

~Task()
{
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);
}
}
};
Expand All @@ -168,8 +169,8 @@ template<typename ValueType>
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); }
Expand Down
12 changes: 6 additions & 6 deletions Modules/Common/Instrumentation/Include/Methane/TracyGpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,18 @@ 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__)

#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) \
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ class AlignedAllocator
#ifdef WIN32
return static_cast<pointer>(_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<pointer>(p_memory);
return static_cast<pointer(memory_ptr);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class ArcBallCamera : public Camera
inline float GetRadiusInPixels(const Data::FloatSize& screen_size) const noexcept
{ return std::min(screen_size.GetWidth(), screen_size.GetHeight()) * m_radius_ratio / 2.F; }

inline bool IsExternalViewCamera() const noexcept { return m_p_view_camera; }
inline const Camera* GetExternalViewCamera() const noexcept { return m_p_view_camera; }
inline const Camera& GetViewCamera() const noexcept { return m_p_view_camera ? *m_p_view_camera : *this; }
inline bool IsExternalViewCamera() const noexcept { return m_view_camera_ptr; }
inline const Camera* GetExternalViewCamera() const noexcept { return m_view_camera_ptr; }
inline const Camera& GetViewCamera() const noexcept { return m_view_camera_ptr ? *m_view_camera_ptr : *this; }

void ApplyLookDirection(const hlslpp::float3& look_dir);
void RotateInView(const hlslpp::float3& view_axis, float angle_rad, const Orientation& base_orientation);
Expand All @@ -77,7 +77,7 @@ class ArcBallCamera : public Camera
inline void SetMousePressedOrientation(const Orientation& orientation) noexcept { m_mouse_pressed_orientation = orientation; }

private:
const Camera* m_p_view_camera = nullptr;
const Camera* m_view_camera_ptr = nullptr;
Pivot m_pivot;
float m_radius_ratio = 0.9F;
SphereProjection m_mouse_pressed_on_sphere { };
Expand Down
29 changes: 14 additions & 15 deletions Modules/Graphics/Camera/Sources/Methane/Graphics/ArcBallCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ArcBallCamera::ArcBallCamera(Pivot pivot) noexcept

ArcBallCamera::ArcBallCamera(const Camera& view_camera, Pivot pivot) noexcept
: Camera()
, m_p_view_camera(&view_camera)
, m_view_camera_ptr(&view_camera)
, m_pivot(pivot)
{ }

Expand Down Expand Up @@ -87,7 +87,7 @@ void ArcBallCamera::MouseDrag(const Point2I& mouse_screen_pos)
ArcBallCamera::SphereProjection ArcBallCamera::GetNormalizedSphereProjection(const Point2I& mouse_screen_pos, bool is_primary) const noexcept
{
META_FUNCTION_TASK();
const Data::FloatSize& screen_size = m_p_view_camera ? m_p_view_camera->GetScreenSize() : 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<Point2F>(mouse_screen_pos) - screen_center;

Expand All @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<const stbi_uc *>(raw_image_data.GetDataPtr()), // NOSONAR
static_cast<int>(raw_image_data.GetDataSize()),
&image_width, &image_height, &image_channels_count,
static_cast<int>(channels_count));
stbi_uc* image_data_ptr = stbi_load_from_memory(reinterpret_cast<const stbi_uc *>(raw_image_data.GetDataPtr()), // NOSONAR
static_cast<int>(raw_image_data.GetDataSize()),
&image_width, &image_height, &image_channels_count,
static_cast<int>(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");
Expand All @@ -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<Data::ConstRawPtr>(p_image_data), // NOSONAR
reinterpret_cast<Data::ConstRawPtr>(p_image_data + image_data_size)); // NOSONAR
Data::Bytes image_data_copy(reinterpret_cast<Data::ConstRawPtr>(image_data_ptr), // NOSONAR
reinterpret_cast<Data::ConstRawPtr>(image_data_ptr + image_data_size)); // NOSONAR
ImageData image_data(image_dimensions, static_cast<uint32_t>(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<uint32_t>(image_channels_count),
Data::Chunk(reinterpret_cast<Data::ConstRawPtr>(p_image_data), image_data_size)); // NOSONAR
Data::Chunk(reinterpret_cast<Data::ConstRawPtr>(image_data_ptr), image_data_size)); // NOSONAR
}

#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class RenderPass
bool m_is_begun = false;
mutable Refs<Texture> m_color_attachment_textures;
mutable Ptrs<Texture> 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
Loading

0 comments on commit 3dd6478

Please sign in to comment.