本文整理汇总了C++中IDXGIAdapter1::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIAdapter1::QueryInterface方法的具体用法?C++ IDXGIAdapter1::QueryInterface怎么用?C++ IDXGIAdapter1::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDXGIAdapter1
的用法示例。
在下文中一共展示了IDXGIAdapter1::QueryInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DetectGpuInfo
void DetectGpuInfo(std::ostream& os)
{
#if defined KLAYGE_PLATFORM_WINDOWS
typedef HRESULT (WINAPI *CreateDXGIFactory1Func)(REFIID riid, void** ppFactory);
#if defined KLAYGE_PLATFORM_WINDOWS_DESKTOP
HMODULE dxgi = ::LoadLibraryEx(L"dxgi.dll", nullptr, 0);
if (!dxgi)
{
os << "Unknown GPU";
return;
}
CreateDXGIFactory1Func DynamicCreateDXGIFactory1 = (CreateDXGIFactory1Func)::GetProcAddress(dxgi, "CreateDXGIFactory1");
if (!DynamicCreateDXGIFactory1)
{
os << "Unknown GPU";
return;
}
#else
CreateDXGIFactory1Func DynamicCreateDXGIFactory1 = CreateDXGIFactory1;
#endif
IDXGIFactory1* factory;
if (SUCCEEDED((*DynamicCreateDXGIFactory1)(IID_IDXGIFactory1, reinterpret_cast<void**>(&factory))))
{
UINT adapter_no = 0;
IDXGIAdapter1* adapter = nullptr;
while (factory->EnumAdapters1(adapter_no, &adapter) != DXGI_ERROR_NOT_FOUND)
{
if (adapter != nullptr)
{
DXGI_ADAPTER_DESC1 adapter_desc;
adapter->GetDesc1(&adapter_desc);
IDXGIAdapter2* adapter2;
adapter->QueryInterface(IID_IDXGIAdapter2, reinterpret_cast<void**>(&adapter2));
if (adapter2 != nullptr)
{
DXGI_ADAPTER_DESC2 desc2;
adapter2->GetDesc2(&desc2);
memcpy(adapter_desc.Description, desc2.Description, sizeof(desc2.Description));
adapter_desc.VendorId = desc2.VendorId;
adapter_desc.DeviceId = desc2.DeviceId;
adapter_desc.SubSysId = desc2.SubSysId;
adapter_desc.Revision = desc2.Revision;
adapter_desc.DedicatedVideoMemory = desc2.DedicatedVideoMemory;
adapter_desc.DedicatedSystemMemory = desc2.DedicatedSystemMemory;
adapter_desc.SharedSystemMemory = desc2.SharedSystemMemory;
adapter_desc.AdapterLuid = desc2.AdapterLuid;
adapter_desc.Flags = desc2.Flags;
adapter2->Release();
}
adapter->Release();
if (adapter_desc.Flags != DXGI_ADAPTER_FLAG_SOFTWARE)
{
os << "Adapter " << adapter_no << endl << endl;
std::string description;
Convert(description, adapter_desc.Description);
os << "Brand: " << description << endl;
os << "Vendor ID: " << std::hex << std::uppercase << adapter_desc.VendorId << endl;
os << "Device ID: " << std::hex << std::uppercase << adapter_desc.DeviceId << endl;
os << "Revision: " << std::hex << std::uppercase << adapter_desc.Revision << endl;
os << "Dedicated video memory: " << std::dec << adapter_desc.DedicatedVideoMemory / 1024 / 1024 << " MB" << endl;
os << "Dedicated system memory: " << std::dec << adapter_desc.DedicatedSystemMemory / 1024 / 1024 << " MB" << endl;
os << "Shared system memory: " << std::dec << adapter_desc.SharedSystemMemory / 1024 / 1024 << " MB" << endl;
}
}
++ adapter_no;
}
}
#if defined KLAYGE_PLATFORM_WINDOWS_DESKTOP
::FreeLibrary(dxgi);
#endif
#else
os << "Unknown GPU" << endl;
#endif
}