Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 1,114 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
DirectX : 3d Hardware Reset Failure #481956
11/27/20 02:22
11/27/20 02:22
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Hello friends

When I run my game, and a screensaver takes over, there is a chance my game will crash with a "3d Hardware Reset Failure" error when I wake up the computer. Not every single time, but eventually it will crash with this error, whether I wake up the computer from a screen saver, or lock/unlock the computer. If I run the game fullscreen, the screensaver will not run, however if you lock your computer and let the screensaver take over, log back in, the game will be frozen.

I think it has to do with a render chain, or any views that have a stage. When I turn off view stages, the crash doesnt happen. However, I lose all my fancy effects/shadows frown

Does anyone have any experience with a render chain and this error?

Re: DirectX : 3d Hardware Reset Failure [Re: jumpman] #481957
11/27/20 03:44
11/27/20 03:44
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline
User
Dooley  Offline
User

Joined: May 2005
Posts: 868
Chicago, IL
I've seen it happen with my games too. Not sure about how to avoid that. I'm wondering if you could switch off view stages if the game window loses focus, or perhaps there is a windows.h command that would let you prevent a screensaver from running.

Re: DirectX : 3d Hardware Reset Failure [Re: jumpman] #481958
11/27/20 05:23
11/27/20 05:23
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Hmm thats an interesting idea, I can look inside the windows.H to see if I can find anything, thank you Dooley!

Currently "on_d3d_lost " and "on_d3d_reset" dont fire off before the "3d hardware reset failure" error, so I cant find a way to intercept that error by switching the stages off before the wakeup during a screensaver. I was testing some other people's simple level files with a simple post processing chain, and the error happened even there when waking up from a screensaver.

Acknex/DirectX is having trouble recreating textures linked in a stage, whether its a TargetMap or an explicitly created bmap attached to a view frown

Please let me know if anyone has a workaround for this, outside of not using a render chain altogether.

Re: DirectX : 3d Hardware Reset Failure [Re: jumpman] #481959
11/27/20 07:29
11/27/20 07:29
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
I think I found something inside windows.H Dooley! Will test and report my findings asap!

Re: DirectX : 3d Hardware Reset Failure [Re: jumpman] #481961
11/27/20 11:06
11/27/20 11:06
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
Hello jumpman, there is a workaround for this problem: https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=478106#Post478106

Re: DirectX : 3d Hardware Reset Failure [Re: jumpman] #481964
11/28/20 01:58
11/28/20 01:58
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Hi Emre, thanks for linking your solution. Here is what I've done so far, with advice and code snippets from both of you.

It currently isnt working 100%, but here is the major parts of the code that I believe help a lot, I think it completely got rid of the 3d Hardware Reset failure crash when waking up from a screensaver:

Code
#include <windows.h>  //----------include windows.h

...

function main()
{

var render_chain_destroy=0;
var render_chain_state=0;

while(1) ///--------------------put this in your main loop
{

BOOL bSaver;  //--------------------------------creates a BOOL flag that will be changed by the windows.h function SystemParametersInfo
SystemParametersInfo(114,0,&bSaver,0);  //---------114 is a specific parameter that tells gamestudio whether or not a screensaver is running

...


        //---------If bSaver is 1/true then it means the windows screensaver is running:

	if((bSaver)||(window_focus==0))  //-----------bSaver is a flag set by SystemParametersInfo above. I put window_focus in here as well 
	{

   render_chain_destroy=1;  //-------get ready to destroy the render chain

        }

       else
      {

      render_chain_destroy=0;  //-------if the screen saver isnt running, dont destroy the render chain

      }



if(render_chain_destroy==1)  //-----we are ready to destroy the render chain because the screensaver is on
{

if(render_chain_state==0)
{

destroy_render_chain();  //-------put your render chain destruction here (remove stages, remove bmaps, purge bmaps
render_chain_state=1;  //-----destroy the chain once
}


}


if(render_chain_destroy==0)  //-------if the system doesnt have a screensaver running
{

if(render_chain_state==1) //------and we recently destroyed the render chain because we destroyed it when a screensaver came on before
{
recreate_render_chain(); //--------recreate your render chain here
wait(-2); //------------I waited 2 seconds here, not sure if this helps or not
render_chain_state=0;  //-------we reset this var to 0, which is only set to 1 when a screensaver is on.

}


}


There some caveats to the above screensaver code. It only consistently works if gamestudio is running in a window. Obviously, if gamestudio is full screen, the screensaver will never trigger.

But lets work on the next hurdle. Locking your computer.

...
if (DeskHwnd != 0)
{
DesktopResult = SwitchDesktop(DeskHwnd);
}


if((DesktopResult==0)||(key_o))
{
...

With Emre's code, I can get gamestudio to recognize when the computer is locked! I destroy the render chain and remove the stages the moment gamestudio detects a lock.

However, when you log back in to a running windowed gamestudio exe, the game gave me a "cant create texture unnamed", but it didnt crash the game. When you select OK, the game seems to run ok in windowed mode after.

If you run the game in fullscreen, then lock, destroy the render chain in gamestudio, then log back in, the game looks like its frozen, however if you press alt+enter, the game seems to unfreeze and start working again.

Emre, have you tried to see if your game works when you run fullscreen, then lock, then log back into the desktop to see what a running gamestudio does?

Thank you two for your help so far.

Re: DirectX : 3d Hardware Reset Failure [Re: jumpman] #481965
11/28/20 07:20
11/28/20 07:20
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
Thank you for sharing code.

Originally Posted by jumpman

Emre, have you tried to see if your game works when you run fullscreen, then lock, then log back into the desktop to see what a running gamestudio does?


I've never tried fullscreen test before. You're right, it freezes when in fullscreen indeed.

Originally Posted by jumpman

However, when you log back in to a running windowed gamestudio exe, the game gave me a "cant create texture unnamed", but it didnt crash the game. When you select OK, the game seems to run ok in windowed mode after.

I surprised by this. Although i run four pp effects at the same time, i don't get any error. I don't know what caused this problem.

EDIT: Btw i found another solution and this is effective in any case in window mode. (Screensaver, UAC, Lock secreen, etc...)

Code

#include <acknex.h>
#include <windows.h>
#include <default.c>

#ifndef material_and_view
	#define material_and_view
	MATERIAL* test_mat1 = 
	{
		effect="Texture TargetMap;
		sampler2D g_samSrcColor = sampler_state { texture = <TargetMap>; MipFilter = Linear;	};
		float4 postprocessing_negative( float2 Tex : TEXCOORD0 ) : COLOR0 
		{
			float3 Color = 1. - tex2D( g_samSrcColor, Tex.xy).xyz;
			return float4(Color,1.);
		}
		technique PostProcess 
		{
			pass p1 
			{
				AlphaBlendEnable = false;
				VertexShader = null;
				PixelShader = compile ps_2_0 postprocessing_negative();
			}
		}";
	}

	VIEW* post_view1 ={layer = 0; flags = PROCESS_TARGET; material=test_mat1;}
#endif



action testet()
{
	while(1)
	{
		my.pan+=5*time_step;
		wait(1);
	}
}
function main()
{
	video_mode=10;
	video_screen=2;

	wait(3);
	fps_max=500;
	
	level_load("");
	camera.stage = post_view1;  
	ent_create(CUBE_MDL,vector(150,0,0),testet);
	HWND	foreground = GetForegroundWindow();
	while(1)
	{
		foreground = GetForegroundWindow();

		if(foreground!=hWnd)
		{
			beep();
			camera.stage=NULL;
			while(1)
			{
				foreground = GetForegroundWindow();
				if(foreground==hWnd)
				{
					break;
				}
				wait(1);
			}
			camera.stage=post_view1;
			beep();
		}
		
		wait(1);
	}
}



EDIT 2: For fullscreen, you can use video_set after the background, instead of alt + enter. i don't know how but it restore something.

Code

foreground = GetForegroundWindow();

		if(foreground!=hWnd)
		{
			beep();
			camera.stage=NULL;
			while(1)
			{
				foreground = GetForegroundWindow();
				if(foreground==hWnd)
				{
					break;
				}
				wait(1);
			}
			camera.stage=post_view1;
			video_set(0,0,0,2);
			beep();
		}
		



Last edited by Emre; 11/28/20 12:05.
Re: DirectX : 3d Hardware Reset Failure [Re: jumpman] #481970
11/28/20 18:28
11/28/20 18:28
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
I noticed the same thing too with video_set! Emre, to me this is very elegant and simpler code, thank you.

It currently works without hitch/error on my desktop, so I'm going to be testing it on my laptop and post the results here today.

Re: DirectX : 3d Hardware Reset Failure [Re: jumpman] #481988
12/01/20 12:10
12/01/20 12:10
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
I'm happy to help. Hope it works without any error.

Re: DirectX : 3d Hardware Reset Failure [Re: jumpman] #481991
12/01/20 17:32
12/01/20 17:32
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Hey Emre, so far its been working really well on multiple desktops and laptops! I always have the feeling its not 100% perfect, but I think this is it!

I hope everyone can see Emre's solution above, because its been working for me!

Thank you Emre and Dooley!!!

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1