locked
Directx and Surface Pro. RRS feed

  • Question

  • Hello, I've recently acquired a Surface Pro and I'd like it to be an "experimental development environment" for the mean time. Since I'm a University Student I've acquired a free copy of visual studio professional and installed right away. Since I'm working on a DirectX 11 game engine project lately I downloaded June 2010 DirectX SDK from MSDN. I then copied all my project files from my Laptop via USB to my Surface Pro and opened the game engine project. So when I run it, it gets an error when choosing a rendering driver it gets an error. ( It's fine with DirectX 11 feature, I checked ). If you need more info, just ask me, I would gladly share more.

    #ifdef _DEBUG
    	creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    #endif
    
    	HRESULT result;
    	unsigned int driver = 0;
    
    	for(driver = 0; driver < totalDriverTypes; ++driver)
    	{
    		result = D3D11CreateDeviceAndSwapChain( 0, driverTypes[driver], 0,
    			creationFlags, featureLevels, totalFeatureLevels,
    			D3D11_SDK_VERSION, &swapChainDesc, &m_swapChain,
    			&m_d3dDevice, &m_featureLevel, &m_d3dContext);
    
    		if(SUCCEEDED(result))
    		{
    			m_driverType = driverTypes[driver];
    #ifdef FEATURE_LEVEL_DEBUG
    			TCHAR message[80];
    			wsprintf(message, "%i", driver);
    			MessageBox(NULL, message, TEXT("Driver Type"), MB_ICONINFORMATION);
    #endif
    			break;
    		}
    	}
    
    	if(FAILED(result))
    	{
    		MessageBox(NULL, TEXT("Failed to create a device adfasdfasdf"), TEXT("ERROR"), MB_ICONERROR);
    		DXTRACE_MSG(TEXT("Failed to create the Directed3d device!"));
    		return false;
    	}

    Thursday, July 4, 2013 4:58 AM

Answers

  • Sorry for forgetting about this forum. I've found the solution after looking at the sample codes of DirectX 11 and I just combine their method for creating device and swap chain, although a new problem arises, I don't know why it works as opposed to the code displayed at the top. If anyone can answer why it works.

    bool CAIGE::InitDirect3D()
    {
    	// Create the device and device context.
    
    	UINT createDeviceFlags = 0;
    #if defined(DEBUG) || defined(_DEBUG)  
        createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
    #endif
    
    	D3D_FEATURE_LEVEL featureLevel;
    
    	// Fill out a DXGI_SWAP_CHAIN_DESC to describe our swap chain.
    
    	DXGI_SWAP_CHAIN_DESC sd;
    	sd.BufferDesc.Width  = m_ClientWidth;
    	sd.BufferDesc.Height = m_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( m_Enable4xMsaa )
    	{
    		sd.SampleDesc.Count   = 4;
    		sd.SampleDesc.Quality = m_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 = m_hWnd;
    	sd.Windowed     = true;
    	sd.SwapEffect   = DXGI_SWAP_EFFECT_DISCARD;
    	sd.Flags        = 0;
    
    	HRESULT hr;
    	hr = D3D11CreateDeviceAndSwapChain( NULL, m_d3dDriverType, NULL, createDeviceFlags, 0, 0,
                                                D3D11_SDK_VERSION, &sd, &m_SwapChain, &m_d3dDevice, &featureLevel, &m_d3dImmediateContext );
    	if( FAILED(hr) )
    	{
    		MessageBox(0, L"D3D11CreateDevice Failed.", 0, 0);
    		return false;
    	}
    
    	if( featureLevel != D3D_FEATURE_LEVEL_11_0 )
    	{
    		MessageBox(0, L"Direct3D Feature Level 11 unsupported.", 0, 0);
    		return false;
    	}
    	
    	// Check 4X MSAA quality support for our back buffer format.
    	// All Direct3D 11 capable devices support 4X MSAA for all render 
    	// target formats, so we only need to check quality support.
    
    	HR(m_d3dDevice->CheckMultisampleQualityLevels(
    		DXGI_FORMAT_R8G8B8A8_UNORM, 4, &m_4xMsaaQuality));
    	assert( m_4xMsaaQuality > 0 );
    
    
    	// 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.
    	
    	OnResize();
    
    	return true;
    }
    

    • Marked as answer by JoeyAndres Sunday, July 21, 2013 8:24 PM
    Sunday, July 21, 2013 8:24 PM

All replies

  • You're more likely to get an answer in a Direct3D forum: http://xboxforums.create.msdn.com/forums/76.aspx

    And be sure to specify what error you are getting.

    Thursday, July 4, 2013 5:47 AM
  • The problem could be that you are using the legacy DirectX SDK (June 2010) which isn't fully compatible with Windows 8 or Windows 7 Service Pack 1.

    Which compiler are you using to build your app? Does the problem happen only in DEBUG? What OS is your laptop running?

    http://blogs.msdn.com/b/chuckw/archive/2013/02/26/directx-11-1-and-windows-7-update.aspx

    http://blogs.msdn.com/b/chuckw/archive/2012/03/22/where-is-the-directx-sdk.aspx

    http://blogs.msdn.com/b/chuckw/archive/2013/07/01/where-is-the-directx-sdk-2013-edition.aspx

    More basically, since you are apparently doing the development on a different system than the Surface Pro, you may not have all the required Developer Runtime stuff installed on your test system (VS DEBUG CRT, DirectX Developer Runtime, and/or legacy DirectX SDK DirectSetup bits).

    Note that while a Surface RT requires you do this kind of remote development, a Surface Pro is fully capable of running the actual development tools directly.



    Tuesday, July 9, 2013 12:14 AM
  • Sorry for forgetting about this forum. I've found the solution after looking at the sample codes of DirectX 11 and I just combine their method for creating device and swap chain, although a new problem arises, I don't know why it works as opposed to the code displayed at the top. If anyone can answer why it works.

    bool CAIGE::InitDirect3D()
    {
    	// Create the device and device context.
    
    	UINT createDeviceFlags = 0;
    #if defined(DEBUG) || defined(_DEBUG)  
        createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
    #endif
    
    	D3D_FEATURE_LEVEL featureLevel;
    
    	// Fill out a DXGI_SWAP_CHAIN_DESC to describe our swap chain.
    
    	DXGI_SWAP_CHAIN_DESC sd;
    	sd.BufferDesc.Width  = m_ClientWidth;
    	sd.BufferDesc.Height = m_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( m_Enable4xMsaa )
    	{
    		sd.SampleDesc.Count   = 4;
    		sd.SampleDesc.Quality = m_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 = m_hWnd;
    	sd.Windowed     = true;
    	sd.SwapEffect   = DXGI_SWAP_EFFECT_DISCARD;
    	sd.Flags        = 0;
    
    	HRESULT hr;
    	hr = D3D11CreateDeviceAndSwapChain( NULL, m_d3dDriverType, NULL, createDeviceFlags, 0, 0,
                                                D3D11_SDK_VERSION, &sd, &m_SwapChain, &m_d3dDevice, &featureLevel, &m_d3dImmediateContext );
    	if( FAILED(hr) )
    	{
    		MessageBox(0, L"D3D11CreateDevice Failed.", 0, 0);
    		return false;
    	}
    
    	if( featureLevel != D3D_FEATURE_LEVEL_11_0 )
    	{
    		MessageBox(0, L"Direct3D Feature Level 11 unsupported.", 0, 0);
    		return false;
    	}
    	
    	// Check 4X MSAA quality support for our back buffer format.
    	// All Direct3D 11 capable devices support 4X MSAA for all render 
    	// target formats, so we only need to check quality support.
    
    	HR(m_d3dDevice->CheckMultisampleQualityLevels(
    		DXGI_FORMAT_R8G8B8A8_UNORM, 4, &m_4xMsaaQuality));
    	assert( m_4xMsaaQuality > 0 );
    
    
    	// 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.
    	
    	OnResize();
    
    	return true;
    }
    

    • Marked as answer by JoeyAndres Sunday, July 21, 2013 8:24 PM
    Sunday, July 21, 2013 8:24 PM