These "Black screen" issues on ATI HD 4870....

Hi,

Well, i have been running in a couple of these issues recently. First of all, I’d like to mention, this one is different from the infinite loop issues in shaders, which also provocate black screens. (I have experienced these also and they were my fault). :wink:

Here, i have a fraps counter displaying realtime framerates, the application still responds, but the screen remains desperatelly black.

Error logs are empty, no (syntaxical) errors are found in the shaders, and there isn’t a single warning (i’m using GLSL 120, by specifying #version 120).

The first case where this happened was when i had to refine a minima extraction on a function with something like a bijection. I did my nice function, which was called only once. And i was running into this issue.

What i did to fix it is to copy paste the code in the caller function… Not a single line of the algorithm changed and then just like magic, it worked.

But now i’m running into a similar issue again… So i start to wonder about the drivers. I’m trying to code something like packet tracing for raymarching on GPU. Typically I’d like to trace a bundle of 16 rays, in order to reduce the number of distance function evaluations. I’ll output the intersection t in a bundle of 4 rgba float32 rendertargets… which is the max allowed as far as i recall. (I’d like to try larger sizes also but i’m limited by the API or hardware here it seems…).

I don’t really know what to do with these issues. It is also probable that with the latter example i have a stupid bug somewhere also… I’ll try to solve it. But still, if “copy paste in the caller function” is the solution there must be something wrong in the driver isn’t it?

Regards,

What’s the function look like? Could you post it?

Yes, here it is:


		float tA = minT - minDist;
		float tB = minT + minDist;
		
		float dstM = minDist;
		float tM = minT;
		
		float dEps = minDist*0.05;
		for (int i=0; i<8; i++)
		{
			if (dEps < 0.0000001) break;
			
			float dM = softShadowDistance( p, d, tM+dEps, lightTanRatio ) - dstM;
			
			if (dM <= 0.0) tA = tM;
			else tB = tM;
			
			tM = (tA+tB) * 0.5;
			dstM = softShadowDistance( p, d, tM, lightTanRatio );
			
			float ratioM = dstM / tM;
			if (ratioM <= minTanRatio) minTanRatio = ratioM;
			
			dEps = (tB-tA)*0.025;
		}

Or actually, i don’t mind sharing more of the shader code:


float softShadowDistance( vec3 p, vec3 d, float t, float lightTanRatio )
{
return distanceFunc( p + dt ) + lightTanRatiot*0.707;
}

float raymarchSoftShadow( vec3 p, vec3 d, float tfar, float lightRadius )
{
float t = 0.01;
float lightTanRatio = lightRadius / tfar;
float upperLightTanRatio = lightTanRatio * 1.1;
float minTanRatio = upperLightTanRatio;
float minDist = lightRadius;
float minT = tfar;

// raymarch soft shadow
for (;;)
{
	float dist = softShadowDistance( p, d, t, lightTanRatio );
	if ( dist < 0.00005 ) break;
	float tanRatio = dist / t;
	if (tanRatio < minTanRatio) { minTanRatio = tanRatio; minDist = dist; minT = t; }
	t += max( dist, 0.00001 );
	if (t >= tfar) break;
}

// full light or penumbra area?
if (t >= tfar)
{
	// penumbra?
	if (minTanRatio < upperLightTanRatio)
	{
		// yes, we have to refine the minima to avoid artifacts...
		float tA = minT - minDist;
		float tB = minT + minDist;
		
		float dstM = minDist;
		float tM = minT;
		
		float dEps = minDist*0.05;
		for (int i=0; i<8; i++)
		{
			if (dEps < 0.0000001) break;
			
			float dM = softShadowDistance( p, d, tM+dEps, lightTanRatio ) - dstM;
			
			if (dM <= 0.0) tA = tM;
			else tB = tM;
			
			tM = (tA+tB) * 0.5;
			dstM = softShadowDistance( p, d, tM, lightTanRatio );
			
			float ratioM = dstM / tM;
			if (ratioM <= minTanRatio) minTanRatio = ratioM;
			
			dEps = (tB-tA)*0.025;
		}
		
		// compute light source's visible aera, approximation
		float r = min( minTanRatio, lightTanRatio ) / lightTanRatio;
		return r * r;
	}
	else return 1.0;
}
else return 0.0;

}

First, enclose the code in the special [code] tags (or use external service with syntax highlighting like pastebin.ca).

Second, tell what you changed in order to break it, to make us sure you didn’t do anything wrong.
Your shader is pretty complicated with a lot of branches and even a pseudo-infinite loop, so I’d start with something simpler (or try to reduce the example to make it work).

Indeed, i don’t manage to reproduce the issue now (so i probably fixed something i don’t even remenber…), and in the latter case i described in the first post, i managed to fix things also…

Here is the full source code still, so you can see what i was trying to do.

http://www.pastebin.ca/1679972

and a screenshot of the result:

http://www.lostgarden.eu/soft_shadows1.jpg

My excuses then to the driver dev team. regards. :slight_smile:

Do I take it that your issues are resolved and that you can’t reproduce this any more?

Cheers,

Graham