Skip to content

Commit 804ad30

Browse files
authored
fix: 部分amd gpu不支持afmf捕获导致默认重启的问题 (#175)
1 parent 0283d79 commit 804ad30

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/platform/windows/display_base.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ namespace platf::dxgi {
115115
DXGI_OUTDUPL_DESC dup_desc;
116116
dup->GetDesc(&dup_desc);
117117

118-
119118
display->display_refresh_rate = dup_desc.ModeDesc.RefreshRate;
120119
double display_refresh_rate_decimal = (double) display->display_refresh_rate.Numerator / display->display_refresh_rate.Denominator;
121120

@@ -1011,26 +1010,35 @@ namespace platf {
10111010
try_types.push_back(config::video.capture);
10121011
}
10131012

1014-
// Check GPU vendor to avoid trying AMD capture on non-AMD GPUs
1015-
bool is_amd_gpu = false;
1013+
// Check if the primary GPU is a discrete AMD GPU that supports AFMF (not integrated)
1014+
bool is_amd_afmf_gpu = false;
10161015
if (std::find(try_types.begin(), try_types.end(), "amd") != try_types.end()) {
1017-
// Create a temporary factory to check GPU vendor
10181016
dxgi::factory1_t factory;
10191017
HRESULT status = CreateDXGIFactory1(IID_IDXGIFactory1, (void **) &factory);
10201018
if (SUCCEEDED(status)) {
10211019
dxgi::adapter_t adapter;
10221020
if (factory->EnumAdapters1(0, &adapter) != DXGI_ERROR_NOT_FOUND) {
10231021
DXGI_ADAPTER_DESC1 adapter_desc;
10241022
adapter->GetDesc1(&adapter_desc);
1025-
is_amd_gpu = (adapter_desc.VendorId == 0x1002);
1023+
// 0x1002 is AMD vendor ID, check for discrete GPU (not integrated)
1024+
bool is_amd_gpu = (adapter_desc.VendorId == 0x1002) && !(adapter_desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE);
1025+
// AFMF support: check for RDNA3 or newer (DeviceId range), not integrated
1026+
// RDNA3: Navi 3x, DeviceId 0x7440~0x74FF, 0x7D00~0x7DFF, etc.
1027+
// You may need to expand this range for future AFMF support
1028+
if (is_amd_gpu) {
1029+
uint32_t id = adapter_desc.DeviceId;
1030+
if ((id >= 0x7440 && id <= 0x74FF) || (id >= 0x7D00 && id <= 0x7DFF)) {
1031+
is_amd_afmf_gpu = true;
1032+
}
1033+
}
10261034
}
10271035
}
10281036
}
10291037

10301038
for (const auto &type : try_types) {
10311039
if (type == "amd" && hwdevice_type == mem_type_e::dxgi) {
10321040
// Only try AMD capture on AMD GPUs
1033-
if (!is_amd_gpu) {
1041+
if (!is_amd_afmf_gpu) {
10341042
BOOST_LOG(debug) << "Skipping AMD capture on non-AMD GPU";
10351043
continue;
10361044
}

0 commit comments

Comments
 (0)