Frame Rate + Hardware Acceleration Problem [SOLVED]

Started by
44 comments, last by Nads 16 years, 1 month ago


Thanks for all your help guys!


@EvilSteve

d3ddev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

done that now, thanks.

Yeh, I am getting d3d device to be null?!!? I dont understand why though. This only happens when hardware acceleration is on!

This is how it is declared:

LPDIRECT3DDEVICE9 d3ddev;

Its showing as:
__vfptr = CXX0030: Error: expression cannot be evaluated


Also I cant find "d3d9d.lib" in my SDK! I only have the normal one without debug! So ive commented this one out.

Im also getting a failure on this line when i debug:
if(FAILED(d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCaps)))	   return false;

which is what is causing the above to be null.

If I miss that line(comment out) then I get a failure on:
d3d->CreateDevice(D3DADAPTER_DEFAULT,                      D3DDEVTYPE_HAL,                      hWnd,                      VertexProcessing,                      &d3dpp,                      &d3ddev)


Are all these occuring because I dont have d3d9d.lib? or is it some other problem?

I will also try and catch those memory leaks! With Trial and error i guess!

oh and by the way I am using D3DSWAPEFFECT_DISCARD :)

thanks
Advertisement
Quote:Original post by theonecalledtom
Often you will find (in my case this is 100%) that discrepencies between the visuals when switching between debug and release runtimes come down to missing state changes that cause different behaviors. You should focus on tracking these down to make sure you don't compound them with further development.

A very useful tool for both performance tracking and render state changing is PIX. This was originally a 360 performance tool and now there is a PC version that is orientated around graphical debugging and performance. Using is has been a little hit or miss on my laptops (seems somewhat prone to crashing) but when working it has provided very useful information - esp when debugging pixel and vertex shaders.

PIX will show you how long each draw call / render state change takes and you can get information on the paramters passed and even wireframe views of draw calls pre and post transformation.


OK thanks will look into PIX!
Quote:Original post by dpadam450
It sounds like you grabbed models offline from random. So I'm guessing they are really high poly.

To find the vert counts, right-click the files and open in notepad. .X is a txt file. It says something like verts towards the top. It'll be a number in the thousands if you don't see it.


thanks I had a look, for example one had lots of different mesh and each had its own verts.

Its total comes to about:
49,616

which does seem like a lot doesnt it? or is that normal?

The square of 3d grass even had total of about 10,000.

thanks
Yeah, sorry - I've updated my journal entry on the debug runtimes; d3d9d.lib doesn't actually exist, I was talking crap [smile]

If that code crashes on access to your D3D interface, is it NULL too? Any time you have a null pointer, you should look at where you expect that pointer to be intiailised and check it's being initialised properly.

In this case, check that you don't get a null pointer from Direct3DCreate9(). If you do, then it means that no D3D support is available, presumably because you don't have video card drivers installed (do you?). Again, the debug runtimes should tell you if that's the case.

Actually, if I try to run my code through Remote Desktop, I get:
D3DX: (INFO) Using AMD SSE2 Instructions'TEH ARTYESS.exe': Loaded 'C:\WINDOWS\system32\d3d9d.dll', No symbols loaded.Direct3D9: :====> ENTER: DLLMAIN(02a3fc50): Process Attach: 00001068, tid=0000058cDirect3D9: :====> EXIT: DLLMAIN(02a3fc50): Process Attach: 00001068Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.Direct3D9: :Device doesn't support mip-mapsDirect3D9: (ERROR) :No hardware acceleration is available in the current modeDirect3D9: :Device doesn't support mip-mapsDirect3D9: (ERROR) :No hardware acceleration is available in the current modeDirect3D9: (ERROR) :No hardware acceleration is available in the current modeDirect3D9: (ERROR) :No ddraw acceleration is available in the current mode

And then GetDeviceCaps() fails with:
D3D9 Helper: IDirect3D9::GetDeviceCaps failed: D3DERR_NOTAVAILABLE

Which looks exactly like what's happening in your case. Do you have up to date video card drivers?

50k vertices isn't that much at all and shouldn't be the cause of your slowdown. Although if you don't have hardware acceleration, drawing anything is going to be painfully slow...
Quote:Original post by Evil Steve
Yeah, sorry - I've updated my journal entry on the debug runtimes; d3d9d.lib doesn't actually exist, I was talking crap [smile]

If that code crashes on access to your D3D interface, is it NULL too? Any time you have a null pointer, you should look at where you expect that pointer to be intiailised and check it's being initialised properly.

In this case, check that you don't get a null pointer from Direct3DCreate9(). If you do, then it means that no D3D support is available, presumably because you don't have video card drivers installed (do you?). Again, the debug runtimes should tell you if that's the case.

Actually, if I try to run my code through Remote Desktop, I get:
*** Source Snippet Removed ***
And then GetDeviceCaps() fails with:
*** Source Snippet Removed ***
Which looks exactly like what's happening in your case. Do you have up to date video card drivers?

50k vertices isn't that much at all and shouldn't be the cause of your slowdown. Although if you don't have hardware acceleration, drawing anything is going to be painfully slow...


OK thanks EvilSteve, I pressume I have video card drivers installed otherwise i wouldnt be able to play any games on my laptop right? (like Half Life 2)

Being up to date is another thing though, I havnt physically been to the ATI site to update my graphics card in the last 2-3 months!
But I have Vista installed a few months ago and that was the time when I updated everything so it should be fairly up to date, does it require the absolute latest drivers?

Yes the deviceCaps is failing and breaking out of the function.

d3d device has the value null everywhere its not being set in the CreateDevice function. I am at work so cant check the error messages, but will see what i get from it tonight.

thanks


As for the models, perhaps hardware acceleration is the problem then why im getting low fps with those models!
Perhaps it is the drivers stuff then rather then my code :D (which is a good thing to hear if its the case)
Quote:Original post by Nads
OK thanks EvilSteve, I pressume I have video card drivers installed otherwise i wouldnt be able to play any games on my laptop right? (like Half Life 2)
Hmm, that's a good point. I'm not really sure what's going on then :/

Quote:Original post by Nads
Being up to date is another thing though, I havnt physically been to the ATI site to update my graphics card in the last 2-3 months!
But I have Vista installed a few months ago and that was the time when I updated everything so it should be fairly up to date, does it require the absolute latest drivers?
Nah, so long as you have some sort of drivers (Even the ones that come with Vista might be enough), there shouldn't be a problem. It can't hurt to get the latest drivers in any case.

Quote:Original post by Nads
Yes the deviceCaps is failing and breaking out of the function.

d3d device has the value null everywhere its not being set in the CreateDevice function. I am at work so cant check the error messages, but will see what i get from it tonight.
If it's failing, it'll be returning an error code and the debug runtimes will show what that error is and why. So long as the D3D pointer isn't null anyway, since that should never be the case. If the device pointer is null, that's not too bad - since it just means CreateDevice failed, which it can do for loads of reasons.


Still, I'm confused as to why Half Life 2 can work properly when D3D says there's no hardware acceleration available. Unless it's using OpenGL for rendering?
Quote:Original post by Evil Steve
Quote:Original post by Nads
OK thanks EvilSteve, I pressume I have video card drivers installed otherwise i wouldnt be able to play any games on my laptop right? (like Half Life 2)
Hmm, that's a good point. I'm not really sure what's going on then :/

Quote:Original post by Nads
Being up to date is another thing though, I havnt physically been to the ATI site to update my graphics card in the last 2-3 months!
But I have Vista installed a few months ago and that was the time when I updated everything so it should be fairly up to date, does it require the absolute latest drivers?
Nah, so long as you have some sort of drivers (Even the ones that come with Vista might be enough), there shouldn't be a problem. It can't hurt to get the latest drivers in any case.

Quote:Original post by Nads
Yes the deviceCaps is failing and breaking out of the function.

d3d device has the value null everywhere its not being set in the CreateDevice function. I am at work so cant check the error messages, but will see what i get from it tonight.
If it's failing, it'll be returning an error code and the debug runtimes will show what that error is and why. So long as the D3D pointer isn't null anyway, since that should never be the case. If the device pointer is null, that's not too bad - since it just means CreateDevice failed, which it can do for loads of reasons.


Still, I'm confused as to why Half Life 2 can work properly when D3D says there's no hardware acceleration available. Unless it's using OpenGL for rendering?


I think that is the problem I am having the d3d device is being NULL because CreateDevice is failing! Anyway I can find out why create device might be failing? I think yesterday on checking it I might have noticed some warning message on the break at createdevice, something about HND ?!? (Does it ring any bells? I can probably give more info on it tonight though if required)

As for the graphics card, how can i check that half life 2 is rendering with openGL rather then hardware or directx? (is there even a easy way?)

thnx for your help
Just to chime in; Half Life 2 is a purely D3D game, there is no OpenGL renderer in it, so it'll be running some form of D3D code.
Quote:Original post by Nads
I think that is the problem I am having the d3d device is being NULL because CreateDevice is failing! Anyway I can find out why create device might be failing? I think yesterday on checking it I might have noticed some warning message on the break at createdevice, something about HND ?!? (Does it ring any bells? I can probably give more info on it tonight though if required)
Yeah, CreateDevice() will be failing because there's no hardware support, so you can't create a D3DDEVTYPE_HAL device.
All I can suggest is seeing what the debug output says. I suppose you could also use the DX Caps viewer to see if it lists the HAL device there - but then if HL2 works reasonably well, it should be going fine...

Quote:Original post by Nads
As for the graphics card, how can i check that half life 2 is rendering with openGL rather then hardware or directx? (is there even a easy way?)

Quote:Original post by phantom
Just to chime in; Half Life 2 is a purely D3D game, there is no OpenGL renderer in it, so it'll be running some form of D3D code.
Ah, I wasn't sure if it had a D3D / OpenGL renderer, or if it was just D3D.

OK thanks,

Will first update drivers, then look into the Create Device function and see if I can find why its failing!

Also EviLSteve can you have a look at my code for that part and see if it looks ok or if it needs any changes:

bool initD3D(HWND hWnd){    // This object will allow us to set the display mode of the screen.    D3DDISPLAYMODE DisplayMode;    // Create a struct to hold various device information    D3DPRESENT_PARAMETERS d3dpp;        // This is used to get the capabilities of the hardware.    D3DCAPS9 D3DCaps;    // Create the Direct3D interface    d3d = Direct3DCreate9(D3D_SDK_VERSION);        // Make sure that it was successful.    if(d3d == NULL)    {	MessageBox(NULL, "Error, can not initialize DirectX!","Error!", MB_OK);		return false;    }    // This function will get the display mode of the device and place it in DisplayMode    if(FAILED(d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &DisplayMode)))    {         MessageBox(NULL, "Error setting the display mode!", "Error!", MB_OK);         return false;    }    // Get the capabilities of the hardware.    if(FAILED(d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCaps)))	   return false;    // Test hardware or software support for vertex processing    DWORD VertexProcessing = 0;   if(D3DCaps.VertexProcessingCaps != 0)      VertexProcessing |= D3DCREATE_HARDWARE_VERTEXPROCESSING;   else      VertexProcessing |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;   ZeroMemory(&d3dpp, sizeof(d3dpp));	        // Clear out the struct for use   d3dpp.Windowed = WINDOW_TOGGLE;  	        // Program windowed   d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    // Discard old frames   d3dpp.hDeviceWindow = hWnd;			// Set the window to be used by Direct3D   d3dpp.BackBufferFormat = DisplayMode.Format; // Set the back buffer format   d3dpp.BackBufferCount = 1;                   // Number of back buffers   d3dpp.BackBufferWidth = SCREEN_WIDTH;	// Set the width of the back buffer   d3dpp.BackBufferHeight = SCREEN_HEIGHT;	// Set the height of the back buffer   d3dpp.EnableAutoDepthStencil = TRUE;		// Automatically run the z-buffer   d3dpp.AutoDepthStencilFormat = D3DFMT_D16;  // 16-bit pixel format for the z-buffer   // Create a device class using this information and the info from the d3dpp struct   if(FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT,                      D3DDEVTYPE_HAL,                      hWnd,                      VertexProcessing,                      &d3dpp,                      &d3ddev)))   {		MessageBox(NULL, "CreateDevice() failed!  Make sure you have DirectX 9!","Error!", MB_OK);        return false;   }   d3ddev->SetRenderState(D3DRS_LIGHTING, TRUE);					   // Turn ON the 3D lighting   d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE);						   // Turn ON the z-buffer   d3ddev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(100, 100, 100));   // Ambient light   d3ddev->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);		// Handle normals in scaling	   // This will render the front and back of the triangles.   d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);				   // Disable culling    d3ddev->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);   // Set the Camera perspective   SetPerspective();   // Set the image states to get a good quality image   d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);   d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);   // Clamp texture co-ordinates to get rid of horrible seam (Used for Skybox)   d3ddev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);   d3ddev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);    return true;}//End initD3D



The GetDeviceCaps is failing so it is exiting the function altogather!

If I comment that bit out then it fails on: CreateDevice

ANything you might be able to notice from the source code?

thanks

This topic is closed to new replies.

Advertisement