direct X bug , ALT+TAB on fullscreenmode

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Dareltibus
Posts: 115
Joined: Mon May 17, 2010 7:42 am

direct X bug , ALT+TAB on fullscreenmode

Post by Dareltibus »

Ok first the code that is getting the bug:
(i think this is a major bug)

Code: Select all

 //standard things

#include <irrlicht.h>


using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif

int main()
{

	
	IrrlichtDevice *device =
		createDevice( video::EDT_DIRECT3D8, dimension2d<u32>(640, 480), 16,
			true, false, false, 0);

	if (!device)
		return 1;


	device->setWindowCaption(L"Hello World!");

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();

	guienv->addStaticText(L"Hello World!",
		rect<s32>(10,10,260,22), true);

	
	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

Now i have tried two differents main loop and experimented the bug but in different ways:

WAY 1)

Code: Select all

while(device->run())
	{
		if(device->isWindowActive())
		{
		driver->beginScene(true, true, SColor(255,100,101,140));

		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();
		}
		else
			device->yield();
	}
	device->drop();

	return 0;

With this way i get the following bug:
Resizing window (640 480)
Resetting D3D8 device.
'01.HelloWorld.exe': loaded 'C:\Windows\System32\atipdlxx.dll'
'01.HelloWorld.exe': unloaded 'C:\Windows\System32\atipdlxx.dll'
Resizing window (160 25)
Resetting D3D8 device.
Resetting failed due to device lost.



WAY 2)

Code: Select all

while(device->run())
	{
		
		driver->beginScene(true, true, SColor(255,100,101,140));

		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();

	}
	device->drop();

	return 0;

with that code (a little simpler) i get a different(maybe the same) bug:
the debug output is:


DIRECT3D8 end scene failed.
DIRECT3D8 end scene failed.
DIRECT3D8 end scene failed.
DIRECT3D8 end scene failed.
DIRECT3D8 end scene failed.
DIRECT3D8 end scene failed.
(and continue to infinite..)


I get the bug only when running the window in fullscreen mode using D3D8 or D3D9 drivers. Nothing strange appens under OpenGL,Software or BurningsVideo drivers.

How to get the bug:
Continue changin the window using ALT+TAB and then restore the irrlicht application window clicking on its icon in the applications bar.

I have a ATI mobility radeon HD4570 and windows vista .

Any one get the same bug?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Thanks - and yes, it's known already: http://irrlicht.sourceforge.net/phpBB2/ ... 759#220759

I got one hint, but haven't found time for testing yet. You might try to check the return value of beginScene (should return false on failure) and not draw when it returned false.

I really hope we find time for that bug before 1.7.2 release.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Dareltibus
Posts: 115
Joined: Mon May 17, 2010 7:42 am

Post by Dareltibus »

ok these are my result testing with the following code:

I had to write this code for catching the value cause if i try to put a break point on "BeginScene" or on "EndScene" the computer crash.

Code: Select all

while(device->run())
	{
		u32 bugcatcher1;
		/*if(device->isWindowActive())
		{*/
			bugcatcher1=driver->beginScene(true, true, SColor(255,100,101,140));
			if(bugcatcher1)
			{
				smgr->drawAll();
				guienv->drawAll();

				bugcatcher1=driver->endScene();
				if(!bugcatcher1)
				{
					device->drop();
					return bugcatcher1; //1break point here
				}
			}
			else
			{
				device->drop();
				return bugcatcher1; //1 break point here
			}
		/*}
		else
			device->yield();*/ //commented out only for my first test
	}
	device->drop();

	return 0;
TEST without Yield()
The game just stop after pressing Alt+Tab.
//output:
Resizing window (640 480)
Resetting D3D8 device.
DIRECT3D8 device lost <-- my return and end of the program.
/////


EndScene failed and returned false.

TEST with Yield()

Again the faling appens on EndScene but this time it appens after i try to restore the window (so first AltTab minimize without troubles), but if i click on the application bar for restoring the window EndScene fails and return false..

//output: (it is the same)
Resizing window (640 480)
Resetting D3D8 device.
DIRECT3D8 device lost <-- my return and end of the program.
/////


I know that is very hard to debug! :) most times crashes during the debug visual studio in fullscreen mode. And without fullscreen there is nothing to debug. I think that issue will need a lot of extra debug output and storing somewhere values. cause breakpoints work not so fine..
Dareltibus
Posts: 115
Joined: Mon May 17, 2010 7:42 am

Post by Dareltibus »

my temporary solution is:
(and if you use that a little comment on your code with a little credits to me is wellcome lol)

Code: Select all

while(device->run())
	{
		u32 bugcatcher1; //ok i check it only if it is == 0. but is usefull have some more data capability
		if(device->isWindowActive())
		{
			if(!device->isWindowMinimized()) //temp bug fix by dareltibus :D. stop drawing if the window is not maximized
			{
				bugcatcher1=driver->beginScene(true, true, SColor(255,100,101,140));
				if(bugcatcher1)
				{
					smgr->drawAll();
					guienv->drawAll();

					bugcatcher1=driver->endScene();
					if(!bugcatcher1)
					{
						device->drop(); //end scene failed
						return bugcatcher1;
					}
				}
				else
				{
					device->drop(); //begin scene failed
					return bugcatcher1;
				}
			}
			else
				device->yield(); //cpu usage down
		}
		else
			device->yield(); //cpu usage down
	}
	device->drop(); //all went rightly

	return 0;
Hope it will be usefull to someone until the bug being fixed
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

Else you could try the alternative that ID software used on Quake II that was to trap the alt+tab key combination so there was no effect at all, when the user tried to switch windows. Maybe an irrlicht device creation parameter?

The problem is the management of resources in DX8/9. When the device is lost because of switching windows, some of the resources must be recreated, or managed somehow so they aren't lost at all, or that the resources are back to an optimal state when the device returns. In DX10+, given the resources are virtualized by WinVista or 7 this issue should not appear (i.e. from the point of view of the aplication, the resources are always available and never lost).

in OpenGL things work diferent because Open GL manages the resources in another way.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply