本文整理汇总了C++中IDXGIDevice类的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIDevice类的具体用法?C++ IDXGIDevice怎么用?C++ IDXGIDevice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IDXGIDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CHECKED
void DesktopDuplication::init()
{
IDXGIFactory1* dxgiFactory = nullptr;
CHECKED(hr, CreateDXGIFactory1(__uuidof(IDXGIFactory1), reinterpret_cast<void**>(&dxgiFactory)));
IDXGIAdapter1* dxgiAdapter = nullptr;
CHECKED(hr, dxgiFactory->EnumAdapters1(adapter, &dxgiAdapter));
dxgiFactory->Release();
CHECKED(hr, D3D11CreateDevice(dxgiAdapter,
D3D_DRIVER_TYPE_UNKNOWN,
NULL,
NULL,
NULL,
NULL,
D3D11_SDK_VERSION,
&d3dDevice,
NULL,
&d3dContext));
IDXGIOutput* dxgiOutput = nullptr;
CHECKED(hr, dxgiAdapter->EnumOutputs(output, &dxgiOutput));
dxgiAdapter->Release();
IDXGIOutput1* dxgiOutput1 = nullptr;
CHECKED(hr, dxgiOutput->QueryInterface(__uuidof(dxgiOutput1), reinterpret_cast<void**>(&dxgiOutput1)));
dxgiOutput->Release();
IDXGIDevice* dxgiDevice = nullptr;
CHECKED(hr, d3dDevice->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&dxgiDevice)));
CHECKED(hr, dxgiOutput1->DuplicateOutput(dxgiDevice, &outputDuplication));
dxgiOutput1->Release();
dxgiDevice->Release();
}
示例2: SafeRelease
static IDXGIFactory *GetDXGIFactoryFromDevice(ID3D11Device *device)
{
IDXGIDevice *dxgiDevice = nullptr;
HRESULT result =
device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void **>(&dxgiDevice));
if (FAILED(result))
{
return nullptr;
}
IDXGIAdapter *dxgiAdapter = nullptr;
result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void **>(&dxgiAdapter));
SafeRelease(dxgiDevice);
if (FAILED(result))
{
return nullptr;
}
IDXGIFactory *dxgiFactory = nullptr;
result =
dxgiAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void **>(&dxgiFactory));
SafeRelease(dxgiAdapter);
if (FAILED(result))
{
return nullptr;
}
return dxgiFactory;
}
示例3:
bool DX11Engine::CreateSwapChain(HWND handle, UINT xSize, UINT ySize)
{
mXsize = xSize;
mYSize = ySize;
IDXGIDevice* dxgiDevice = nullptr;
HRESULT hr = m_pDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
if (hr != S_OK)
{
return false;
}
IDXGIAdapter* dxgiAdapter = nullptr;
hr = dxgiDevice->GetAdapter(&dxgiAdapter);
if (hr != S_OK)
{
return false;
}
IDXGIFactory1* dxgiFactory1 = nullptr;
hr = dxgiAdapter->GetParent(__uuidof(IDXGIFactory1), (void**)&dxgiFactory1);
if (hr != S_OK)
{
return false;
}
DXGI_SWAP_CHAIN_DESC desc;
desc.BufferDesc.Width = xSize;
desc.BufferDesc.Height = ySize;
desc.BufferDesc.RefreshRate.Numerator = 0;
desc.BufferDesc.RefreshRate.Denominator = 1;
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.BufferUsage = DXGI_USAGE_BACK_BUFFER | DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.BufferCount = 2;
desc.OutputWindow = handle;
desc.Windowed = TRUE;
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
desc.Flags = 0;
hr = dxgiFactory1->CreateSwapChain(dxgiDevice, &desc, &m_pSwapChain);
if (hr != S_OK)
{
return false;
}
dxgiDevice->Release();
dxgiAdapter->Release();
dxgiFactory1->Release();
return true;
}
示例4: while
UINT D3D10System::GetNumOutputs()
{
UINT count = 0;
IDXGIDevice *device;
if(SUCCEEDED(d3d->QueryInterface(__uuidof(IDXGIDevice), (void**)&device)))
{
IDXGIAdapter *adapter;
if(SUCCEEDED(device->GetAdapter(&adapter)))
{
IDXGIOutput *outputInterface;
while(SUCCEEDED(adapter->EnumOutputs(count, &outputInterface)))
{
count++;
outputInterface->Release();
}
adapter->Release();
}
device->Release();
}
return count;
}
示例5: getGPUName
static string getGPUName( IUnknown* pDevice )
{
string sRet = "";
IDXGIDevice* pDXGIDevice = NULL;
pDevice->QueryInterface( __uuidof( IDXGIDevice ), ( void** )&pDXGIDevice );
if ( pDXGIDevice )
{
IDXGIAdapter* pDXGIAdapter = NULL;
pDXGIDevice->GetAdapter( &pDXGIAdapter );
if ( pDXGIAdapter )
{
DXGI_ADAPTER_DESC adapterDesc;
pDXGIAdapter->GetDesc( &adapterDesc );
sRet = PluginManager::UTF82ACP( PluginManager::UCS22UTF8( adapterDesc.Description ) );
SAFE_RELEASE( pDXGIAdapter );
}
SAFE_RELEASE( pDXGIDevice );
}
return sRet;
}
示例6: HR
void D3D11RenderWindow::_createSwapChain()
{
// Fill out a DXGI_SWAP_CHAIN_DESC to describe our swap chain.
DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = mWidth;
sd.BufferDesc.Height = mHeight;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
// Use 4X MSAA?
if (mEnable4xMsaa)
{
sd.SampleDesc.Count = 4;
sd.SampleDesc.Quality = m4xMsaaQuality - 1;
}
// No MSAA
else
{
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
}
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 2;
sd.OutputWindow = mhMainWnd;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
// To correctly create the swap chain, we must use the IDXGIFactory that was
// used to create the device. If we tried to use a different IDXGIFactory instance
// (by calling CreateDXGIFactory), we get an error: "IDXGIFactory::CreateSwapChain:
// This function is being called with a device from a different IDXGIFactory."
IDXGIDevice* dxgiDevice = 0;
HR(md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice));
IDXGIAdapter* dxgiAdapter = 0;
HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter));
IDXGIFactory* dxgiFactory = 0;
HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory));
HR(dxgiFactory->CreateSwapChain(md3dDevice, &sd, &mSwapChain));
ReleaseCOM(dxgiDevice);
ReleaseCOM(dxgiAdapter);
ReleaseCOM(dxgiFactory);
// The remaining steps that need to be carried out for d3d creation
// also need to be executed every time the window is resized. So
// just call the OnResize method here to avoid code duplication.
_updateSwapChain();
}
示例7: SAFE_RELEASE
bool CDuplicateOutputDx11::CreateOutputDuplicator()
{
SAFE_RELEASE(m_pOutputDuplication);
HRESULT hRes = S_OK;
IDXGIDevice* pDxgiDevice = nullptr;
hRes = m_pDevice->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&pDxgiDevice));
if (!SUCCEEDED(hRes))
{
DOLOG("m_pDevice->QueryInterface failed!");
return false;
}
IDXGIAdapter* pDxgiAdapter = nullptr;
hRes = pDxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&pDxgiAdapter));
SAFE_RELEASE(pDxgiDevice);
if (!SUCCEEDED(hRes))
{
DOLOG("pDxgiDevice->GetParent failed!");
return false;
}
DXGI_ADAPTER_DESC descAdapter;
pDxgiAdapter->GetDesc(&descAdapter);
// Get output
IDXGIOutput* pDxgiOutput = nullptr;
hRes = pDxgiAdapter->EnumOutputs(0, &pDxgiOutput);
SAFE_RELEASE(pDxgiAdapter);
if (!SUCCEEDED(hRes))
{
DOLOG("pDxgiAdapter->EnumOutputs failed!");
return false;
}
// Get output1
IDXGIOutput1* pDxgiOutput1 = nullptr;
hRes = pDxgiOutput->QueryInterface(__uuidof(IDXGIOutput1), reinterpret_cast<void**>(&pDxgiOutput1));
SAFE_RELEASE(pDxgiOutput);
if (!SUCCEEDED(hRes))
{
DOLOG("pDxgiOutput->QueryInterface failed!");
return false;
}
// Get duplicate
hRes = pDxgiOutput1->DuplicateOutput(m_pDevice, &m_pOutputDuplication);
SAFE_RELEASE(pDxgiOutput1);
if (!SUCCEEDED(hRes))
{
DOLOG("pDxgiOutput1->DuplicateOutput");
return false;
}
return true;
}
示例8: D3D11CreateDevice
void D3DContext::InitD3D(HWND hWnd)
{
m_MSAAEnabled = true;
HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, m_DebugLayerEnabled ? D3D11_CREATE_DEVICE_DEBUG : D3D11_CREATE_DEVICE_SINGLETHREADED, NULL, NULL, D3D11_SDK_VERSION, &dev, &m_D3DFeatureLevel, &devcon);
dev->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 4, &m_MSAAQuality);
// assert(m_MSAAQuality > 0);
DXGI_SWAP_CHAIN_DESC scd;
ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));
scd.BufferDesc.Width = m_Properties.width;
scd.BufferDesc.Height = m_Properties.height;
scd.BufferDesc.RefreshRate.Numerator = 60;
scd.BufferDesc.RefreshRate.Denominator = 1;
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scd.SampleDesc.Count = m_MSAAEnabled ? 4 : 1;
scd.SampleDesc.Quality = m_MSAAEnabled ? (m_MSAAQuality - 1) : 0;
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scd.BufferCount = 3;
scd.OutputWindow = hWnd;
scd.Windowed = !m_Properties.fullscreen;
scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
IDXGIDevice* dxgiDevice = 0;
IDXGIAdapter* dxgiAdapter = 0;
IDXGIFactory* dxgiFactory = 0;
dev->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter);
dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory);
dxgiFactory->CreateSwapChain(dev, &scd, &swapchain);
dxgiFactory->Release();
dxgiAdapter->Release();
dxgiDevice->Release();
if (m_DebugLayerEnabled)
{
dev->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&m_DebugLayer));
m_DebugLayer->ReportLiveDeviceObjects(D3D11_RLDO_SUMMARY);
ID3D11InfoQueue* infoQueue;
dev->QueryInterface(__uuidof(ID3D11InfoQueue), reinterpret_cast<void**>(&infoQueue));
D3D11_MESSAGE_ID hide[] = { D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET };
D3D11_INFO_QUEUE_FILTER filter;
memset(&filter, 0, sizeof(filter));
filter.DenyList.NumIDs = 1;
filter.DenyList.pIDList = hide;
infoQueue->AddStorageFilterEntries(&filter);
}
Resize();
}
示例9: CreateSwapChain
bool TRenderDevice::CreateSwapChain(){
IDXGIDevice* device;
if (FAILED(Device->QueryInterface(__uuidof(IDXGIDevice), (void**) &device))){
MessageBox(0,L"获取设备接口失败",0,0);
return false;
}
IDXGIAdapter* adapter;
if (FAILED(device->GetParent(__uuidof(IDXGIAdapter), (void**) &adapter))){
MessageBox(0,L"获取适配器接口失败",0,0);
return false;
}
IDXGIFactory* factory;
if (FAILED(adapter->GetParent(__uuidof(IDXGIFactory), (void**) &factory))){
MessageBox(0,L"获取Factory接口失败",0,0);
return false;
}
DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = RenderSize->GetRenderWidth();
sd.BufferDesc.Height = RenderSize->GetRenderHeight();
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
if (MsaaQuality>0){
sd.SampleDesc.Count = MsaaQuality;
sd.SampleDesc.Quality = MsaaQuality - 1;
}else{
sd.SampleDesc.Count=1;
sd.SampleDesc.Quality=0;
}
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = RenderWindow->GetHWnd();
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
if (FAILED(factory->CreateSwapChain(Device, &sd, &SwapChain))){
MessageBox(0,L"创建SwapChain失败",0,0);
return false;
}
device->Release();
adapter->Release();
factory->Release();
return true;
}
示例10: GetDXGIAdapterFromD3D11Device
IDXGIAdapter* GetDXGIAdapterFromD3D11Device(ID3D11Device* device)
{
IDXGIDevice* dxgiDevice = NULL;
CHECK_HR(device->QueryInterface(&dxgiDevice));
IDXGIAdapter* dxgiAdapter = NULL;
CHECK_HR(dxgiDevice->GetAdapter(&dxgiAdapter));
SafeRelease(dxgiDevice);
return dxgiAdapter;
}
示例11: HR
//*************************************************************************************************
// Create the swap chain for the device
//*************************************************************************************************
SBOOL RenderContext::createSwapChain(HWND clientWindow, SUINT clientWidth, SUINT clientHeight)
{
// Fill out DXGI swap chain description
DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = clientWidth;
sd.BufferDesc.Height = clientHeight;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
// Use 4x Msaa
if(_4xMsaaEnabled)
{
sd.SampleDesc.Count = 4;
sd.SampleDesc.Quality = _4xMsaaQuality - 1;
}
// No Msaa
else
{
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
}
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = clientWindow;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
// Generate an IDXGI factory to properly initialize the swap chain
IDXGIDevice* dxgiDevice = 0;
HR(_d3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice));
IDXGIAdapter* dxgiAdapter = 0;
HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter));
IDXGIFactory* dxgiFactory = 0;
HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory));
HR(dxgiFactory->CreateSwapChain(_d3dDevice, &sd, &_swapChain));
ReleaseCOM(dxgiDevice);
ReleaseCOM(dxgiAdapter);
ReleaseCOM(dxgiFactory);
return true;
}
示例12: ZeroMemory
std::shared_ptr<SwapChain> Device::createSwapChain(const Window& window)
{
std::shared_ptr<SwapChain> swapChain;
IDXGIDevice* dxgiDevice = nullptr;
if (SUCCEEDED(m_device->QueryInterface<IDXGIDevice>(&dxgiDevice)))
{
IDXGIAdapter* adapter = nullptr;
if (SUCCEEDED(dxgiDevice->GetAdapter(&adapter)))
{
IDXGIFactory* dxgiFactory = nullptr;
if (SUCCEEDED(adapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory))))
{
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = window.getWidth();
sd.BufferDesc.Height = window.getHeight();
sd.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 0;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = window.getPlatformData()->getHandle();
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
IDXGISwapChain* nativeSwapChain = nullptr;
if (SUCCEEDED(dxgiFactory->CreateSwapChain(m_device, &sd, &nativeSwapChain)))
{
ID3D11Texture2D* backBufferTexture = nullptr;
if (SUCCEEDED(nativeSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBufferTexture))))
{
auto texture = std::make_shared<Texture2d>(backBufferTexture);
auto backBufferRenderCommandEncoder = createRenderCommandEncoder(1, &texture, nullptr, false);
swapChain = std::make_shared<SwapChain>(nativeSwapChain, backBufferRenderCommandEncoder);
}
dxgiFactory->Release();
}
adapter->Release();
}
}
dxgiDevice->Release();
}
return swapChain;
}
示例13: GetDXGIAdapter
// Callers must Release the DXGIAdapter after use or risk mem-leak
static bool GetDXGIAdapter(__out IDXGIAdapter **DXGIAdapter)
{
ID3D10Device1 *D2D10Device;
IDXGIDevice *DXGIDevice;
bool result = false;
if (D2D10Device = mozilla::gfx::Factory::GetDirect3D10Device()) {
if (D2D10Device->QueryInterface(__uuidof(IDXGIDevice), (void **)&DXGIDevice) == S_OK) {
result = (DXGIDevice->GetAdapter(DXGIAdapter) == S_OK);
DXGIDevice->Release();
}
}
return result;
}
示例14: DisableDXGIWindowChanges
inline void DisableDXGIWindowChanges(IUnknown* device, HWND window)
{
IDXGIDevice * pDXGIDevice;
ThrowIfFailed(device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)));
IDXGIAdapter * pDXGIAdapter;
ThrowIfFailed(pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)));
IDXGIFactory * pIDXGIFactory;
ThrowIfFailed(pDXGIAdapter->GetParent(IID_PPV_ARGS(&pIDXGIFactory)));
ThrowIfFailed(pIDXGIFactory->MakeWindowAssociation(window, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER));
pIDXGIFactory->Release();
pDXGIAdapter->Release();
pDXGIDevice->Release();
}
示例15: FactoryFromDevice
static IDXGIFactory* FactoryFromDevice(ID3D11Device *device) {
assert(device);
IDXGIDevice *dxgiDevice = nullptr;
DEBUG_HR(device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&dxgiDevice)));
IDXGIAdapter *dxgiAdapter = nullptr;
DEBUG_HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&dxgiAdapter)));
IDXGIFactory *dxgiFactory = nullptr;
DEBUG_HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory)));
ReleaseCom(dxgiAdapter);
ReleaseCom(dxgiDevice);
return dxgiFactory;
}