本文整理汇总了C++中microsoft::wrl::ComPtr::GetDesc1方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::GetDesc1方法的具体用法?C++ ComPtr::GetDesc1怎么用?C++ ComPtr::GetDesc1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类microsoft::wrl::ComPtr
的用法示例。
在下文中一共展示了ComPtr::GetDesc1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Initialize
// Initialize the DirectX resources required to run.
void Graphics::Initialize(void)
{
ASSERT(s_SwapChain1 == nullptr, "Graphics has already been initialized");
Microsoft::WRL::ComPtr<ID3D12Device> pDevice;
#if _DEBUG
Microsoft::WRL::ComPtr<ID3D12Debug> debugInterface;
if (SUCCEEDED(D3D12GetDebugInterface(MY_IID_PPV_ARGS(&debugInterface))))
debugInterface->EnableDebugLayer();
else
Utility::Print("WARNING: Unable to enable D3D12 debug validation layer\n");
#endif
#ifdef DXIL
EnableExperimentalShaderModels();
#endif
// Obtain the DXGI factory
Microsoft::WRL::ComPtr<IDXGIFactory4> dxgiFactory;
ASSERT_SUCCEEDED(CreateDXGIFactory2(0, MY_IID_PPV_ARGS(&dxgiFactory)));
// Create the D3D graphics device
Microsoft::WRL::ComPtr<IDXGIAdapter1> pAdapter;
static const bool bUseWarpDriver = false;
if (!bUseWarpDriver)
{
SIZE_T MaxSize = 0;
for (uint32_t Idx = 0; DXGI_ERROR_NOT_FOUND != dxgiFactory->EnumAdapters1(Idx, &pAdapter); ++Idx)
{
DXGI_ADAPTER_DESC1 desc;
pAdapter->GetDesc1(&desc);
if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
continue;
if (desc.DedicatedVideoMemory > MaxSize && SUCCEEDED(D3D12CreateDevice(pAdapter.Get(), D3D_FEATURE_LEVEL_11_0, MY_IID_PPV_ARGS(&pDevice))))
{
pAdapter->GetDesc1(&desc);
Utility::Printf(L"D3D12-capable hardware found: %s (%u MB)\n", desc.Description, desc.DedicatedVideoMemory >> 20);
MaxSize = desc.DedicatedVideoMemory;
}
}
示例2: onInit
void Scene::onInit()
{
this->mpZBufferDSV.Reset();
this->mpZBuffer.Reset();
this->mpBackBufferRTV.Reset();
this->mpBackBuffer.Reset();
this->mpImmediateContext.Reset();
this->mpDevice.Reset();
this->mpSwapChain.Reset();
//デバイスなどを作り直す
//DXGIを使う上で必要となるIDXGIFactory1を作成
HRESULT hr;
Microsoft::WRL::ComPtr<IDXGIFactory1> pFactory;
hr = CreateDXGIFactory1(IID_PPV_ARGS(pFactory.GetAddressOf()));
if (FAILED(hr)) {
throw std::runtime_error("IDXGIFactoryクラスの作成に失敗しました。");
}
//GPUアダプターを列挙して一番最初に見つかった使えるものを選ぶ
Microsoft::WRL::ComPtr<IDXGIAdapter1> pAdapterIt;
for (UINT adapterIndex = 0; S_OK == pFactory->EnumAdapters1(adapterIndex, pAdapterIt.GetAddressOf()); ++adapterIndex) {
DXGI_ADAPTER_DESC1 desc;
pAdapterIt->GetDesc1(&desc);
OutputDebugStringA( std::string("adapter " + std::to_string(adapterIndex) + "\n").c_str());
OutputDebugStringW((std::wstring(L" decription = ") + desc.Description + L"\n").c_str());
OutputDebugStringA( std::string(" VemdorId = " + std::to_string(desc.VendorId) + "\n").c_str());
OutputDebugStringA( std::string(" DeviceId = " + std::to_string(desc.DeviceId) + "\n").c_str());
OutputDebugStringA( std::string(" SubSysId = " + std::to_string(desc.SubSysId) + "\n").c_str());
OutputDebugStringA( std::string(" Revision = " + std::to_string(desc.Revision) + "\n").c_str());
OutputDebugStringA( std::string(" DedicatedVideoMemory = " + std::to_string(desc.DedicatedVideoMemory) + "\n").c_str());
OutputDebugStringA( std::string(" DedicatedSystemMemory = " + std::to_string(desc.DedicatedSystemMemory) + "\n").c_str());
OutputDebugStringA( std::string(" SharedSystemMemory = " + std::to_string(desc.SharedSystemMemory) + "\n").c_str());
OutputDebugStringA( std::string(" AdapterLuid = high:" + std::to_string(desc.AdapterLuid.HighPart) + " low:" + std::to_string(desc.AdapterLuid.LowPart) + "\n").c_str());
OutputDebugStringA( std::string(" Flag = " + std::to_string(desc.Flags) + "\n").c_str());
if (nullptr == this->mpAdapter) {
if (desc.Flags ^= DXGI_ADAPTER_FLAG_SOFTWARE) {
this->mpAdapter = pAdapterIt;
OutputDebugStringA(std::string("このアダプターを使用します。 adapterIndex = " + std::to_string(adapterIndex) + "\n").c_str());
}
//期待通りに動作してくれなかった
//LARGE_INTEGER version;
//hr = pAdapterIt->CheckInterfaceSupport(__uuidof(ID3D11Device), &version);
//DXGI_ERROR_UNSUPPORTED;
//if (S_OK == hr) {
// pAdapter = pAdapterIt;
// OutputDebugStringA(std::string("このアダプターを使用します。 adapterIndex = " + std::to_string(adapterIndex) + "\n").c_str());
//}
}
//使い終わったら必ずReleaseすること
pAdapterIt.Reset();
}
//ID3D11DeviceとID3D11DeviceContextの作成
std::array<D3D_FEATURE_LEVEL, 3> featureLevels = { {
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0
} };
UINT flags = 0;
#ifdef _DEBUG
flags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_FEATURE_LEVEL usedLevel;
hr = D3D11CreateDevice(
this->mpAdapter.Get(),
D3D_DRIVER_TYPE_UNKNOWN,
nullptr,
flags,
featureLevels.data(),
static_cast<UINT>(featureLevels.size()),
D3D11_SDK_VERSION,
this->mpDevice.GetAddressOf(),
&usedLevel,
this->mpImmediateContext.GetAddressOf()
);
if (FAILED(hr)) {
throw std::runtime_error("ID3D11Deviceの作成に失敗。");
}
//IDXGISwapChainの作成
DXGI_SWAP_CHAIN_DESC swapChainDesc = { 0 };
swapChainDesc.OutputWindow = Win32Application::hwnd();
swapChainDesc.BufferCount = 2;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
//swapChainDesc.Flags = 0;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
//フルスクリーンとウィンドモードの切り替えがしたい場合は、まずウィンドウモードとして生成することを推奨しているみたい
//https://msdn.microsoft.com/en-us/library/bb174579(v=vs.85).aspx
swapChainDesc.Windowed = true;
//.........这里部分代码省略.........