Skip to content

Commit e6b2ee2

Browse files
committed
Treat Samsung GPU same as AMD GPU.
The Samsung GPU (Xclipse) is an AMD RDNA2 derivative but has a Samsung PCI vendor ID. As such, the GPA code needs to check both for AMD and Samsung. With this change and similar vendor ID checks in RenderDoc, RenderDoc is able to capture AMD perf counters when targeting an Xclipse GPU (requires bundling libGPUPerfAPIVK.so in the replayer server APK.)
1 parent 0c175a3 commit e6b2ee2

File tree

10 files changed

+52
-23
lines changed

10 files changed

+52
-23
lines changed

source/gpu_perf_api_common/gpa_context.cc

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,8 @@ GpaContext::GpaContext(GpaHwInfo& hw_info, GpaOpenContextFlags flags)
2222
, hw_info_(hw_info)
2323
, invalidate_and_flush_l2_cache_enabled_(false)
2424
, is_open_(false)
25-
, is_amd_device_(false)
2625
, active_session_(nullptr)
2726
{
28-
GpaUInt32 vendor_id;
29-
30-
if (hw_info_.GetVendorId(vendor_id) && kAmdVendorId == vendor_id)
31-
{
32-
is_amd_device_ = true;
33-
}
3427
}
3528

3629
GpaContext::~GpaContext()
@@ -416,15 +409,19 @@ void GpaContext::SetAsOpened(bool open)
416409

417410
bool GpaContext::IsAmdDevice() const
418411
{
419-
GpaUInt32 vendor_id;
420-
bool is_amd = false;
412+
GpaUInt32 vendor_id = 0;
413+
return hw_info_.GetVendorId(vendor_id) && (kAmdVendorId == vendor_id);
414+
}
421415

422-
if (hw_info_.GetVendorId(vendor_id) && kAmdVendorId == vendor_id)
423-
{
424-
is_amd = true;
425-
}
416+
bool GpaContext::IsSamsungDevice() const
417+
{
418+
GpaUInt32 vendor_id = 0;
419+
return hw_info_.GetVendorId(vendor_id) && (kSamsungVendorId == vendor_id);
420+
}
426421

427-
return is_amd;
422+
bool GpaContext::IsAmdOrSamsungDevice() const
423+
{
424+
return IsAmdDevice() || IsSamsungDevice();
428425
}
429426

430427
void GpaContext::AddGpaSession(IGpaSession* gpa_session)

source/gpu_perf_api_common/gpa_context.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,19 @@ class GpaContext : public IGpaContext
129129
/// @return true if context device is AMD device otherwise false.
130130
bool IsAmdDevice() const;
131131

132+
/// @brief Returns whether the device is Samsung device or not.
133+
///
134+
/// @return true if context device is Samsung device otherwise false.
135+
bool IsSamsungDevice() const;
136+
137+
/// @brief Returns whether the device is AMD or Samsung device.
138+
///
139+
/// The Samsung Xclipse GPU is based on AMD RDNA2 and can be treated like AMD
140+
/// in most cases.
141+
///
142+
/// @return true if context device is AMD or Samsung device otherwise false.
143+
bool IsAmdOrSamsungDevice() const;
144+
132145
/// @brief Adds the GPA session to the session list.
133146
///
134147
/// @param [in] gpa_session GPA session object pointer.
@@ -163,7 +176,6 @@ class GpaContext : public IGpaContext
163176
bool invalidate_and_flush_l2_cache_enabled_; ///< Flag indicating flush and invalidation of L2 cache is enabled or not.
164177
bool is_open_; ///< Flag indicating context is open or not.
165178
GpaSessionList gpa_session_list_; ///< List of GPA sessions in the context.
166-
bool is_amd_device_; ///< Flag indicating whether the device is AMD or not.
167179
mutable std::mutex gpa_session_list_mutex_; ///< Mutex for GPA session list.
168180
IGpaSession* active_session_; ///< Gpa session to keep track of active session.
169181
mutable std::mutex active_session_mutex_; ///< Mutex for the active session.

source/gpu_perf_api_common/gpa_hw_info.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ bool GpaHwInfo::UpdateDeviceInfoBasedOnDeviceId()
264264
}
265265

266266
// Only emit an error for AMD devices.
267-
if (IsAmd())
267+
if (IsAmdOrSamsung())
268268
{
269269
std::stringstream ss;
270270
ss << "Unrecognized device ID: " << device_id_ << ".";

source/gpu_perf_api_common/gpa_hw_info.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
static const int kAmdVendorId = 0x1002; ///< The AMD vendor ID.
1919
static const int kNvidiaVendorId = 0x10DE; ///< The Nvidia vendor ID.
2020
static const int kIntelVendorId = 0x8086; ///< The Intel vendor ID.
21+
static const int kSamsungVendorId = 0x144D; ///< The Samsung vendor ID.
2122

2223
/// @brief Stores information about the hardware installed in the machine.
2324
class GpaHwInfo
@@ -230,7 +231,26 @@ class GpaHwInfo
230231
/// @return True if the current hardware is AMD hardware.
231232
bool IsAmd() const
232233
{
233-
return vendor_id_set_ && kAmdVendorId == vendor_id_;
234+
return vendor_id_set_ && (kAmdVendorId == vendor_id_);
235+
};
236+
237+
/// @brief Check if the current hardware is Samsung hardware.
238+
///
239+
/// @return True if the current hardware is Samsung hardware.
240+
bool IsSamsung() const
241+
{
242+
return vendor_id_set_ && (kSamsungVendorId == vendor_id_);
243+
};
244+
245+
/// @brief Check if the current hardware is AMD or Samsung hardware.
246+
///
247+
/// The Samsung Xclipse GPU is based on AMD RDNA2 and can be treated like AMD
248+
/// in most cases.
249+
///
250+
/// @return True if the current hardware is AMD or Samsung hardware.
251+
bool IsAmdOrSamsung() const
252+
{
253+
return IsAmd() || IsSamsung();
234254
};
235255

236256
/// @brief Check if the current hardware is Nvidia hardware.

source/gpu_perf_api_common/gpa_implementor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ GpaStatus GpaImplementor::IsDeviceSupported(GpaContextInfoPtr context_info, GpaH
305305
return kGpaStatusErrorFailed;
306306
}
307307

308-
if (api_hw_info.IsAmd())
308+
if (api_hw_info.IsAmdOrSamsung())
309309
{
310310
AMDTADLUtils::Instance()->GetAsicInfoList(asic_info_list);
311311
GpaHwInfo asic_hw_info;

source/gpu_perf_api_counter_generator/gpa_counter_generator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ GpaStatus GenerateCounters(GpaApiType desired_api,
163163
{
164164
desired_generation = GDT_HW_GENERATION_INTEL;
165165
}
166-
else if (kAmdVendorId == vendor_id)
166+
else if ((kAmdVendorId == vendor_id) || (kSamsungVendorId == vendor_id))
167167
{
168168
if (AMDTDeviceInfoUtils::Instance()->GetDeviceInfo(device_id, revision_id, card_info))
169169
{

source/gpu_perf_api_dx11/dx11_gpa_implementor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool Dx11GpaImplementor::VerifyApiHwSupport(const GpaContextInfoPtr context_info
128128
{
129129
GpaStatus status = kGpaStatusOk;
130130

131-
if (hw_info.IsAmd())
131+
if (hw_info.IsAmdOrSamsung())
132132
{
133133
unsigned int major_ver = 0;
134134
unsigned int minor_ver = 0;

source/gpu_perf_api_dx12/dx12_gpa_context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ bool Dx12GpaContext::InitializeAMDExtension()
137137

138138
if (nullptr != d3d12_device_)
139139
{
140-
if (nullptr == gpa_interface_ && IsAmdDevice())
140+
if (nullptr == gpa_interface_ && IsAmdOrSamsungDevice())
141141
{
142142
result = kGpaStatusErrorDriverNotSupported;
143143

source/gpu_perf_api_gl/gl_gpa_context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ bool GlGpaContext::ValidateAndUpdateGlCounters() const
311311
{
312312
GPA_LOG_ERROR("Unable to get necessary hardware info.");
313313
}
314-
else if (hwInfo.IsAmd())
314+
else if (hwInfo.IsAmdOrSamsung())
315315
{
316316
if (driver_counter_group_info_.size() == 0)
317317
{

source/gpu_perf_api_vk/vk_gpa_implementor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool VkGpaImplementor::GetHwInfoFromApi(const GpaContextInfoPtr context_info, Gp
9191
{
9292
hardware_generation = GDT_HW_GENERATION_INTEL;
9393
}
94-
else if (kAmdVendorId == vendor_id)
94+
else if ((kAmdVendorId == vendor_id) || (kSamsungVendorId == vendor_id))
9595
{
9696
GDT_GfxCardInfo card_info = {};
9797

0 commit comments

Comments
 (0)