由于一个模糊的原因,在我的项目中添加 cudart.lib 后,我对 IDXGIOutput5::DuplicateOutput1() 的调用失败并出现错误 0x887a0004 (DXGI_ERROR_UNSUPPORTED)。
我在 Visual Studio 2019 上工作,我的监视器复制代码是经典的:
hr = output5->DuplicateOutput1(this->dxgiDevice, 0, sizeof(supportedFormats) / sizeof(DXGI_FORMAT), supportedFormats, &this->dxgiOutputDuplication);
我目前唯一尝试对 cuda 做的就是列出 Cuda 设备:
int nDevices = 0;
cudaError_t error = cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
LOG_FUNC_DEBUG("Graphic adapter : Descripion: %s, Memory Clock Rate : %d kHz, Memory Bus Width : %u bits",
prop.name,
prop.memoryClockRate,
prop.memoryBusWidth
);
}
此外,在我尝试使用 DXGI 开始监控复制之后,这段代码被调用了很久。
我的应用程序中的每件事似乎都是正确的:我调用了 SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2),但我没有在离散 GPU 上运行(请参阅 [ https://support.microsoft.com/en-us/help/3019314/error -生成-when-desktop-duplication-api-capable-application-is-ru][1] )
顺便说一句,它曾经工作过,如果我从链接器输入中删除“如此简单”的 Cuda 调用和 cudart.lib ,它就会再次工作!
我真的不明白什么会导致这种奇怪的行为,有什么想法吗?