本文整理汇总了C++中IDXGIFactory类的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIFactory类的具体用法?C++ IDXGIFactory怎么用?C++ IDXGIFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IDXGIFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDefaultAdapterLuid
static ovrGraphicsLuid GetDefaultAdapterLuid()
{
ovrGraphicsLuid luid = ovrGraphicsLuid();
#if defined(_WIN32)
IDXGIFactory* factory = nullptr;
if (SUCCEEDED(CreateDXGIFactory(IID_PPV_ARGS(&factory))))
{
IDXGIAdapter* adapter = nullptr;
if (SUCCEEDED(factory->EnumAdapters(0, &adapter)))
{
DXGI_ADAPTER_DESC desc;
adapter->GetDesc(&desc);
memcpy(&luid, &desc.AdapterLuid, sizeof(luid));
adapter->Release();
}
factory->Release();
}
#endif
return luid;
}
示例2: return
/*
* Class: org_lwjgl_d3d11_impl_DXGIFactoryImpl
* Method: nMakeWindowAssociation
* Signature: (JJI)J
*/
extern "C" JNIEXPORT jlong JNICALL Java_org_lwjgl_d3d11_impl_DXGIFactoryImpl_nMakeWindowAssociation
(JNIEnv * env, jclass clazz, jlong thisPtr, jlong hwnd, jint flags) {
IDXGIFactory* factory = (IDXGIFactory*)(intptr_t)thisPtr;
HWND hWnd = (HWND)hwnd;
UINT Flags = (UINT)flags;
return (jlong)factory->MakeWindowAssociation(hWnd, Flags);
}
示例3: LogVideoCardStats
void LogVideoCardStats()
{
HRESULT err;
IDXGIFactory *factory;
if(SUCCEEDED(err = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory)))
{
UINT i=0;
IDXGIAdapter *giAdapter;
while(factory->EnumAdapters(i++, &giAdapter) == S_OK)
{
Log(TEXT("------------------------------------------"));
DXGI_ADAPTER_DESC adapterDesc;
if(err = SUCCEEDED(giAdapter->GetDesc(&adapterDesc)))
{
Log(TEXT("Adapter %u"), i);
Log(TEXT(" Video Adapter: %s"), adapterDesc.Description);
Log(TEXT(" Video Adapeter Dedicated Video Memory: %u"), adapterDesc.DedicatedVideoMemory);
Log(TEXT(" Video Adapeter Shared System Memory: %u"), adapterDesc.SharedSystemMemory);
}
else
AppWarning(TEXT("Could not query adapter %u"), i);
giAdapter->Release();
}
factory->Release();
}
}
示例4: D3D10CreateDevice
//========================================================================
// Initialize hardware for rendering. Member of AbstractRender
//========================================================================
HRESULT DX10Render::initDevice()
{
UINT createDeviceFlags = 0;
#ifdef _DEBUG
createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
#endif
HRESULT hr = D3D10CreateDevice(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, D3D10_SDK_VERSION, &this->device);
if (FAILED(hr)) return hr;
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = this->resolution.width;
sd.BufferDesc.Height = this->resolution.height;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = this->hWindow;
sd.SampleDesc.Count = 4;
sd.SampleDesc.Quality = 4;
sd.Windowed = !this->fullscreen;
IDXGIFactory *factory = getDeviceFactory(device);
if (factory == NULL) return E_FAIL;
hr = factory->CreateSwapChain(device, &sd, &swapChain);
if (FAILED(hr)) return hr;
factory->Release();
return S_OK;
}
示例5: 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();
}
示例6: CreateDXGIFactory
std::wstring
DXGI::GetGPUInfo (void)
{
static wchar_t adapters [4096];
*adapters = L'\0';
if (!NVAPI::CountPhysicalGPUs ()) {
IDXGIFactory* pFactory = NULL;
CreateDXGIFactory (__uuidof(IDXGIFactory), (void **)&pFactory);
IDXGIAdapter* pDXGIAdapter;
for (UINT i = 0; pFactory->EnumAdapters (i, &pDXGIAdapter) != DXGI_ERROR_NOT_FOUND; ++i) {
DXGI_ADAPTER_DESC adapterDesc;
pDXGIAdapter->GetDesc (&adapterDesc);
// Skip Microsoft's virtual adapters...
if (adapterDesc.VendorId != 0x1414) {
swprintf (adapters, L"%sAdapter %02u (Vendor ID: %04X):\r\n"
L"----------------------------------------\r\n\r\n"
L" %s\r\n\r\n"
L" %4.1f GiB Dedicated VRAM\r\n"
L" %4.1f GiB Shared Memory (GART)\r\n\r\n",
adapters,
i,
adapterDesc.VendorId,
adapterDesc.Description,
(float)adapterDesc.DedicatedVideoMemory / 1024.0f / 1024.0f / 1024.0f,
(float)adapterDesc.SharedSystemMemory / 1024.0f / 1024.0f / 1024.0f);
}
pDXGIAdapter->Release ();
}
pFactory->Release ();
}
else {
DXGI_ADAPTER_DESC* adapter_descs = NVAPI::EnumGPUs_DXGI ();
int i = 0;
while (*adapter_descs [i].Description != L'\0') {
swprintf (adapters, L"%sAdapter %02d (Vendor ID: %04X):\r\n"
L"----------------------------------------\r\n\r\n"
L" %s\r\n\r\n"
L" %4.1f GiB Dedicated VRAM\r\n"
L" %4.1f GiB Shared Memory (GART)\r\n\r\n",
adapters,
i,
adapter_descs [i].VendorId,
adapter_descs [i].Description,
(float)adapter_descs [i].DedicatedVideoMemory / 1024.0f / 1024.0f / 1024.0f,
(float)adapter_descs [i].SharedSystemMemory / 1024.0f / 1024.0f / 1024.0f);
++i;
}
}
return std::wstring (adapters);
}
示例7: ARRAYSIZE
HRESULT CContextManager::CreateContext(HWND hWnd, int Width, int Height)
{
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
};
UINT numFeatureLevels = ARRAYSIZE(featureLevels);
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = Width;
sd.BufferDesc.Height = Height;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hWnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
/*#if _DEBUG
int flags = D3D11_CREATE_DEVICE_DEBUG;
#else
int flags = 0;
#endif*/
int flags = 0;
if (FAILED(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, featureLevels, numFeatureLevels,
D3D11_SDK_VERSION, &sd, &m_SwapChain, &m_D3DDevice, NULL, &m_DeviceContext)))
{
return S_FALSE;
}
#if _DEBUG
HRESULT hr = m_D3DDevice->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&m_D3DDebug));
if (FAILED(hr))
return hr;
#endif
// treure el ALT+INTRO automàtic
IDXGIFactory* dxgiFactory;
hr = m_SwapChain->GetParent(__uuidof(IDXGIFactory), (void **)&dxgiFactory);
assert(hr == S_OK);
hr = dxgiFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER);
assert(hr == S_OK);
dxgiFactory->Release();
return S_OK;
}
示例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: OVR_PUBLIC_FUNCTION
OVR_PUBLIC_FUNCTION(ovrResult) ovr_Create(ovrSession* pSession, ovrGraphicsLuid* pLuid)
{
// Initialize the opaque pointer with our own OpenVR-specific struct
ovrSession session = new struct ovrHmdStruct();
memset(session->ColorTexture, 0, sizeof(ovrHmdStruct::ColorTexture));
session->ThumbStick[ovrHand_Left] = true;
// Get the compositor interface
session->compositor = (vr::IVRCompositor*)VR_GetGenericInterface(vr::IVRCompositor_Version, &g_InitError);
if (g_InitError != vr::VRInitError_None)
return REV_InitErrorToOvrError(g_InitError);
session->compositor->SetTrackingSpace(vr::TrackingUniverseSeated);
// Get the settings interface
session->settings = (vr::IVRSettings*)VR_GetGenericInterface(vr::IVRSettings_Version, &g_InitError);
if (g_InitError != vr::VRInitError_None)
return REV_InitErrorToOvrError(g_InitError);
// Get the overlay interface
session->overlay = (vr::IVROverlay*)VR_GetGenericInterface(vr::IVROverlay_Version, &g_InitError);
if (g_InitError != vr::VRInitError_None)
return REV_InitErrorToOvrError(g_InitError);
// Apply settings
session->ThumbStickRange = session->settings->GetFloat(REV_SETTINGS_SECTION, "ThumbStickRange", 0.8f);
// Get the LUID for the adapter
int32_t index;
g_VRSystem->GetDXGIOutputInfo(&index);
if (index == -1)
index = 0;
// Create the DXGI factory
IDXGIFactory* pFactory;
HRESULT hr = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory));
if (FAILED(hr))
return ovrError_IncompatibleGPU;
IDXGIAdapter* pAdapter;
hr = pFactory->EnumAdapters(index, &pAdapter);
if (FAILED(hr))
return ovrError_MismatchedAdapters;
DXGI_ADAPTER_DESC desc;
hr = pAdapter->GetDesc(&desc);
if (FAILED(hr))
return ovrError_MismatchedAdapters;
// Copy the LUID into the structure
memcpy(pLuid, &desc.AdapterLuid, sizeof(LUID));
// Cleanup and return
pFactory->Release();
pAdapter->Release();
*pSession = session;
return ovrSuccess;
}
示例10: D3D
// Constructor. Creates a Direct3D device.
D3D() : _Device(NULL), _ImmediateContext(NULL)
{
IDXGIFactory* factory;
if (FAILED(CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory))) return;
HRESULT hr = S_OK;
UINT createDeviceFlags = 0;
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_DRIVER_TYPE driverTypes[] =
{
D3D_DRIVER_TYPE_UNKNOWN,
};
UINT numDriverTypes = sizeof(driverTypes) / sizeof(driverTypes[0]);
D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0 };
unsigned int numFeatureLevels = 1;
D3D_FEATURE_LEVEL usedFeatureLevel = D3D_FEATURE_LEVEL_11_0;
// iterate the display adapters and look for a DirectX 11 capable device.
for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++)
{
D3D_DRIVER_TYPE driverType = driverTypes[driverTypeIndex];
IDXGIAdapter* adapter;
for (UINT i = 0;
factory->EnumAdapters(i, &adapter) != DXGI_ERROR_NOT_FOUND;
++i)
{
DXGI_ADAPTER_DESC desc;
adapter->GetDesc(&desc);
std::wstring adapterDesc(desc.Description);
hr = D3D11CreateDevice(adapter, driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &_Device, &usedFeatureLevel, &_ImmediateContext);
if (SUCCEEDED(hr))
{
wprintf(L"D3D is using: %s\n", adapterDesc.c_str());
break;
}
}
if (!_Device) {
printf("Couldn't create DirectX device.\nMaybe DirectX 11 is not supported on your machine?\n");
exit(-1);
}
if (adapter) adapter->Release();
if (SUCCEEDED(hr))
break;
}
factory->Release();
}
示例11: MessageBox
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;
}
示例12: GetCurrentProcessId
EGLint SwapChain11Api::createSwapChain(
int backbufferWidth, int backbufferHeight, IDXGISwapChain **outSwapChain)
{
// We cannot create a swap chain for an HWND that is owned by a
// different process
DWORD currentProcessId = GetCurrentProcessId();
DWORD wndProcessId;
GetWindowThreadProcessId((HWND)mWindow, &wndProcessId);
if (currentProcessId != wndProcessId)
{
ERR("Could not create swap chain, window owned by different process");
return EGL_BAD_NATIVE_WINDOW;
}
ID3D11Device *device = getRenderer()->getDevice();
IDXGIFactory *factory = getRenderer()->getDxgiFactory();
DXGI_FORMAT format = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
DXGI_SWAP_CHAIN_DESC swapChainDesc = {0};
swapChainDesc.BufferCount = 2;
swapChainDesc.BufferDesc.Format = format;
swapChainDesc.BufferDesc.Width = backbufferWidth;
swapChainDesc.BufferDesc.Height = backbufferHeight;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.Flags = 0;
swapChainDesc.OutputWindow = mWindow;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.Windowed = TRUE;
IDXGISwapChain *swapChain;
HRESULT result = factory->CreateSwapChain(device, &swapChainDesc, &swapChain);
if (SUCCEEDED(result))
{
*outSwapChain = swapChain;
d3d11::ResourceTracker::Track(swapChain);
return EGL_SUCCESS;
}
else
{
if (d3d11::isDeviceLostError(result))
return EGL_CONTEXT_LOST;
else
return EGL_BAD_ALLOC;
}
}
示例13: DX12GetAdapterDesc
GPA_Status DX12GetAdapterDesc(IUnknown* pDevice, DXGI_ADAPTER_DESC& adapterDesc)
{
GPA_Status status = GPA_STATUS_OK;
if (nullptr == pDevice)
{
GPA_LogError("Parameter 'pDevice' is NULL.");
status = GPA_STATUS_ERROR_NULL_POINTER;
}
else
{
ID3D12Device* dx12Device = static_cast<ID3D12Device*>(pDevice);
LUID adapterLuid = dx12Device->GetAdapterLuid();
IDXGIFactory* pDXGIFactory = nullptr;
HRESULT hr = CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&pDXGIFactory));
if (FAILED(hr) || (nullptr == pDXGIFactory))
{
GPA_LogError("Unable to get IDXGIFactory interface from ID3D12Device.");
status = GPA_STATUS_ERROR_FAILED;
}
else
{
IDXGIAdapter* pAdapter = nullptr;
for (UINT index = 0; pDXGIFactory->EnumAdapters(index, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++index)
{
memset(&adapterDesc, 0, sizeof(adapterDesc));
hr = pAdapter->GetDesc(&adapterDesc);
if (FAILED(hr))
{
GPA_LogError("Could not get adapter description, hardware cannot be supported.");
status = GPA_STATUS_ERROR_FAILED;
}
else
{
if (adapterDesc.AdapterLuid.HighPart == adapterLuid.HighPart && adapterDesc.AdapterLuid.LowPart == adapterLuid.LowPart)
{
// We found the matching adapter luid, so we're done.
break;
}
}
}
}
pDXGIFactory->Release();
}
return status;
}
示例14: 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;
}
示例15: memcpy
void SysMtgsThread::OpenPlugin()
{
if( m_PluginOpened ) return;
memcpy( RingBuffer.Regs, PS2MEM_GS, sizeof(PS2MEM_GS) );
GSsetBaseMem( RingBuffer.Regs );
GSirqCallback( dummyIrqCallback );
int result;
if( GSopen2 != NULL )
result = GSopen2( (void*)pDsp, 1 | (renderswitch ? 4 : 0) );
else
result = GSopen( (void*)pDsp, "PCSX2", renderswitch ? 2 : 1 );
GSsetVsync(EmuConfig.GS.FrameLimitEnable && EmuConfig.GS.VsyncEnable);
if( result != 0 )
{
DevCon.WriteLn( "GSopen Failed: return code: 0x%x", result );
throw Exception::PluginOpenError( PluginId_GS );
}
// This is the preferred place to implement DXGI fullscreen overrides, using LoadLibrary.
// But I hate COM, I don't know to make this work, and I don't have DX10, so I give up
// and enjoy my working DX9 alt-enter instead. Someone else can fix this mess. --air
// Also: Prolly needs some DX10 header includes? Which ones? Too many, I gave up.
#if 0 // defined(__WXMSW__) && defined(_MSC_VER)
wxDynamicLibrary dynlib( L"dxgi.dll" );
SomeFuncTypeIDunno isThisEvenTheRightFunctionNameIDunno = dynlib.GetSymbol("CreateDXGIFactory");
if( isThisEvenTheRightFunctionNameIDunno )
{
// Is this how LoadLibrary for COM works? I dunno. I dont care.
IDXGIFactory* pFactory;
hr = isThisEvenTheRightFunctionNameIDunno(__uuidof(IDXGIFactory), (void**)(&pFactory) );
pFactory->MakeWindowAssociation((HWND)&pDsp, DXGI_MWA_NO_WINDOW_CHANGES);
pFactory->Release();
}
#endif
m_PluginOpened = true;
m_sem_OpenDone.Post();
GSsetGameCRC( ElfCRC, 0 );
}