CreateDevice error on other comps

Started by
17 comments, last by Endar 17 years, 1 month ago
Glad all HTML code is parsed from AP posts...

Your code is certified as:
http://www.codinghorror.com/blog/images/works-on-my-machine-stamped.png
Advertisement
Quote:Original post by Anonymous Poster
Glad all HTML code is parsed from AP posts...

Your code is certified as:
http://www.codinghorror.com/blog/images/works-on-my-machine-stamped.png


Do you have the DX SDK?

Could you also give me some basic specs so I can get a feel for how new your comp/graphics card is?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
I do believe that I have found the problem.

I found the "DirectX Caps Viewer", which I assume stands for "capabilities".

The laptop has no graphics hardware (at least none that DX apparently recognises). I am able to run the demo in fullscreen and windowed, if I create a REF device. I also found out the the laptop can run with X8R8G8B8 windowed and fullscreen.

The only problem with a REF device is that it is incredibly slow. But I suppose that if a game/graphics company is running a demo, they're not going to be running it on a laptop with no graphics hardware.

Also, hikikomori, as far as I can see, in your source, I found this little snippet of code:
if( 0 == _strcmpi( g_AdapterInfoVec[uAdapter].adapterIdentifier.Description,				"NVIDIA NVPerfHUD" ) ){	//g_Log( "Using NVidia PerfHUD." );	DevType = D3DDEVTYPE_REF;}else{	// Not using NVidia PerfHUD..	DevType = D3DDEVTYPE_HAL;}

It appears that you only use a REF device for a single graphics device. [smile]

I think I found the reason why your app didn't work.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Quote:Original post by Endar
I do believe that I have found the problem.

I found the "DirectX Caps Viewer", which I assume stands for "capabilities".

The laptop has no graphics hardware (at least none that DX apparently recognises). I am able to run the demo in fullscreen and windowed, if I create a REF device. I also found out the the laptop can run with X8R8G8B8 windowed and fullscreen.
If there's no graphics hardware thar DX recognises, that would certainly explain why it doesn't work. Out of interest, can you call IDirect3D9::GetCaps(), or does it fail? I have this problem when trying to use D3D via remote desktop.
Basically, it looks like your laptop doesn't have D3D drivers installed.


Quote:Original post by Endar
The only problem with a REF device is that it is incredibly slow. But I suppose that if a game/graphics company is running a demo, they're not going to be running it on a laptop with no graphics hardware.

Also, hikikomori, as far as I can see, in your source, I found this little snippet of code:
*** Source Snippet Removed ***
It appears that you only use a REF device for a single graphics device. [smile]

I think I found the reason why your app didn't work.
The REF device is only present on machines with the SDK installed, which is why it's not suitable for deployment. It emulates everything in software, so it's an "ideal" card that supports everything. But because of that, it runs incredibly slowly (It's a software renderer). The only use for it is for testing your code when your card doesn't support something (E.g. pixel shaders), or when you think there might be a driver bug (If HAL and REF give different results, it's probably a driver bug. REF is always right).

As for hikikomori's code, that's slightly different. NVPerfHUD hooks D3D, and requires you to create a REF device. Under the hood, a HAL device is created though. The reason for having to explicitly request a REF device is to prevent people from running NVPerfHUD on applications they didn't write - E.g. Unreal or some other game using D3D. Because apps are never deployed using the REF device (for the reasons I mentioned above), no application should try to create a REF device, meaning you shouldn't be able to run NVPerfHUD on someone elses app.

NVPerfHUD is NVidia's performance analysis tool if you weren't aware.

Finally, you can capture debug output from an app by using tools like DebugView, which will capture all debug output from a program (Including D3D and D3DX debug spew). That should give you some information from D3D telling you why it failed.
Could you tell us what color depth the desktop is on? Right-click desktop > Properties.. then choose the settings tab, and see what Color Quality is used. If it's 24bpp, then I think you will not be able to initialize D3D in windowed mode. you will have to set the desktop color depth to 16bpp before running the demo.

If the following code doesn't work, I don't think anything else will.
HRESULT InitD3DDevice(){	HRESULT hr;	ZeroMemory( &g_D3DPP, sizeof( D3DPRESENT_PARAMETERS ) );	g_D3DPP.Windowed = TRUE;	g_D3DPP.BackBufferFormat = D3DFMT_X8R8G8B8;	g_D3DPP.BackBufferWidth = 0;	g_D3DPP.BackBufferHeight = 0;	g_D3DPP.SwapEffect = D3DSWAPEFFECT_DISCARD;	g_D3DPP.hDeviceWindow = g_hWnd;	g_D3DPP.EnableAutoDepthStencil = FALSE;	g_D3DPP.PresentationInterval = D3DPRESENT_INTERVAL_ONE;	hr = g_pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, g_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,								&g_D3DPP, &g_pD3DDevice );	if( FAILED( hr ) )	{		OutputDebugString( "Failed to create device using X8R8G8B8, trying R5G6B5" );		g_D3DPP.BackBufferFormat = D3DFMT_R5G6B5;		hr = g_pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, g_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,								&g_D3DPP, &g_pD3DDevice );		if( FAILED( hr ) )			OutputDebugString( "Failed to create device using R5G6B5... your card is crap!" );	}	if( SUCCEEDED( hr ) )	{		OutputDebugString( "Everything went well" );		g_hrDeviceState = g_pD3DDevice->TestCooperativeLevel();	}	else		g_hrDeviceState = D3DERR_INVALIDDEVICE;	return hr;}


To test it, replace the InitD3DDevice() from the above demo with this one, and clear the D3DCLEAR_ZBUFFER flag from the Clear() method in OnIdle().
Finally, here is the "mini article" that I was planning on posting somewhere.. it might be helpful. If all fails, save the caps from the caps viewer into a file and post it so we can have a look at it. Hope this helps.
-Love & Peace!
If you're looking for a software device solution that will work with all video cards, try using the D3DDEVTYPE_SW. Use this code before you create your device. You'll have to download the software rasterizer from the microsoft website though if you don't have it.

example:
         // Open up the Direct3D Software Rasterizer and get a pointer to the	// entry point.	if( NULL == ( hRast = LoadLibrary( "C:\\WINDOWS\\System32\\RGB9Rast_1.dll" ) ) &&		NULL == ( hRast = LoadLibrary( "RGB9Rast_1.dll" ) ) )	{		GameError( "Direct3D init failed!\n\n!LoadLibrary:\n"			"Failed to open Direct3D9 RGB software rasterizer." );		return E_FAIL;	}	// Locate the entry point of the software rasterizer	FARPROC Proc = GetProcAddress( hRast, "D3D9GetSWInfo" );	// Register the software renderer so that Direct3D can use it.	if( FAILED( hr = lpD3D->RegisterSoftwareDevice( Proc ) ) )	{		GameError( "Direct3D init failed!\n\nIDirect3D9::RegisterSoftwareDevice:\n"			"Failed to register software driver." );		return hr;	}


and now you can create a Direct3D device using D3DDEVTYPE_SW. Unlike REF, it doesn't support everything like shaders, but it works on everything I've used so far.
I'll take a look at the things that you guys suggested, but my main worry was that I'd hand the demo to a game dev studio to look at, and it wouldn't run.

I suppose that fear is mostly baseless (at least in regards to this program) now.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
I would hope that any respectable game development studio has the necessary hardware requirements to run your game as it was meant to be.
Quote:Original post by Justin Rebuilt
I would hope that any respectable game development studio has the necessary hardware requirements to run your game as it was meant to be.


Hopefully. So I think I won't worry about fullscreen and just leave it windowed and at my original 800x800 window size.

Edit:: I've just posted what I'll most likely be using as the final version of the demo (unless any unforseen bugs pop up) up in the game programming forum.

[Edited by - Endar on March 20, 2007 10:42:40 PM]
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper

This topic is closed to new replies.

Advertisement