Exemplo n.º 1
0
bool GSDevice9::Create(GSWnd* wnd)
{
	if(!__super::Create(wnd))
	{
		return false;
	}

	// d3d

	m_d3d.Attach(Direct3DCreate9(D3D_SDK_VERSION));

	if(!m_d3d) return false;

	UINT adapter;
	D3DDEVTYPE devtype;

	FindAdapter(m_d3d, adapter, devtype);

	D3DADAPTER_IDENTIFIER9 id;

	if(S_OK == m_d3d->GetAdapterIdentifier(adapter, 0, &id))
	{
		printf("%s (%d.%d.%d.%d)\n",
			id.Description,
			id.DriverVersion.HighPart >> 16,
			id.DriverVersion.HighPart & 0xffff,
			id.DriverVersion.LowPart >> 16,
			id.DriverVersion.LowPart & 0xffff);
	}
Exemplo n.º 2
0
bool FD3D11DynamicRHIModule::IsSupported()
{
	// if not computed yet
	if(!ChosenAdapter.IsValid())
	{
		FindAdapter();
	}

	// The hardware must support at least 10.0 (usually 11_0, 10_0 or 10_1).
	return ChosenAdapter.IsValid()
		&& ChosenAdapter.MaxSupportedFeatureLevel != D3D_FEATURE_LEVEL_9_1
		&& ChosenAdapter.MaxSupportedFeatureLevel != D3D_FEATURE_LEVEL_9_2
		&& ChosenAdapter.MaxSupportedFeatureLevel != D3D_FEATURE_LEVEL_9_3;
}
Exemplo n.º 3
0
uint32 GSDevice9::GetMaxDepth(uint32 msaa, std::string adapter_id)
{
	CComPtr<IDirect3D9> d3d;

	d3d.Attach(Direct3DCreate9(D3D_SDK_VERSION));

	UINT adapter;
	D3DDEVTYPE devtype;

	FindAdapter(d3d, adapter, devtype, adapter_id);

	switch(BestD3dFormat(d3d, adapter, devtype, msaa))
	{
		case D3DFMT_D32:
		case D3DFMT_D32F_LOCKABLE:
			return 32;
		case D3DFMT_D24S8:
			return 24;
	}

	return 0;
}
Exemplo n.º 4
0
HRESULT D3DPresentEngine::CreateD3DDevice()
{
    HRESULT     hr = S_OK;
    HWND        hwnd = NULL;
    HMONITOR    hMonitor = NULL;
    UINT        uAdapterID = D3DADAPTER_DEFAULT;
    DWORD       vp = 0;

    D3DCAPS9    ddCaps;
    ZeroMemory(&ddCaps, sizeof(ddCaps));

    IDirect3DDevice9* pDevice = NULL;

    // Hold the lock because we might be discarding an exisiting device.
    AutoLock lock(m_ObjectLock);    

    if (!m_pD3D9 || !m_pDeviceManager)
    {
        return MF_E_NOT_INITIALIZED;
    }

    hwnd = GetDesktopWindow();

    // Note: The presenter creates additional swap chains to present the
    // video frames. Therefore, it does not use the device's implicit 
    // swap chain, so the size of the back buffer here is 1 x 1.

	D3DPRESENT_PARAMETERS pp;
	ZeroMemory(&pp, sizeof(pp));

    pp.BackBufferWidth = 1;
    pp.BackBufferHeight = 1;
    pp.Windowed = TRUE;
    pp.SwapEffect = D3DSWAPEFFECT_COPY;
    pp.BackBufferFormat = D3DFMT_UNKNOWN;
    pp.hDeviceWindow = hwnd;
    pp.Flags = D3DPRESENTFLAG_VIDEO;
    pp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;

    // Find the monitor for this window.
    if (m_hwnd)
    {
        hMonitor = MonitorFromWindow(m_hwnd, MONITOR_DEFAULTTONEAREST);

        // Find the corresponding adapter.
    	CHECK_HR(hr = FindAdapter(m_pD3D9, hMonitor, &uAdapterID));
    }

    // Get the device caps for this adapter.
    CHECK_HR(hr = m_pD3D9->GetDeviceCaps(uAdapterID, D3DDEVTYPE_HAL, &ddCaps));

    if(ddCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
    {
        vp = D3DCREATE_HARDWARE_VERTEXPROCESSING;
    }
    else
    {
        vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
    }

	if(IsVistaOrLater())
	{
		IDirect3DDevice9Ex * pDeviceEx;

		// Create the device.
		CHECK_HR(hr = m_pD3D9->CreateDeviceEx(uAdapterID,
											  D3DDEVTYPE_HAL,
											  pp.hDeviceWindow,
											  vp | D3DCREATE_NOWINDOWCHANGES | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
										      &pp, 
										  	  NULL,
											  &pDeviceEx));
		pDevice = pDeviceEx;
	}
	else
	{
		CHECK_HR(hr = m_pD3D9->CreateDevice(uAdapterID,
											  D3DDEVTYPE_HAL,
											  pp.hDeviceWindow,
											  vp | D3DCREATE_NOWINDOWCHANGES | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
										      &pp, 
											  &pDevice));
	}

    // Get the adapter display mode.
    CHECK_HR(hr = m_pD3D9->GetAdapterDisplayMode(uAdapterID, &m_DisplayMode));

    // Reset the D3DDeviceManager with the new device 
    CHECK_HR(hr = m_pDeviceManager->ResetDevice(pDevice, m_DeviceResetToken));

    SAFE_RELEASE(m_pDevice);

    m_pDevice = pDevice;
    m_pDevice->AddRef();

done:
	SAFE_RELEASE(pDevice);
	return hr;
}