Bug 8065 - celestia crashes with software mesa if opengl 2.0 render path is selected
Summary: celestia crashes with software mesa if opengl 2.0 render path is selected
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-29 11:11 UTC by Roland Scheidegger
Modified: 2009-08-24 12:24 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Roland Scheidegger 2006-08-29 11:11:12 UTC
When selecting the celestia url
cel://Follow/Sol:Saturn/2004-07-05T19:30:03.15247?x=wD/HrUF01aaUDA&y=SqYVgMhcHkT//////////w&z=VcGc/MmuZR53/////////w&ow=0.790347&ox=0.223412&oy=0.532452&oz=0.204778&select=Sol:Saturn&fov=43.293781&ts=1.000000&ltd=0&rf=6023&lm=0
 and using opengl 2.0 render path (which is very slow with software mesa),
celestia instantly crashes (with the linux-x86 target).
Backtrace:
Using host libthread_db library "/lib/tls/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 1099707936 (LWP 28136)]
[KCrash handler]
#7  0xffffe410 in ?? ()
#8  0xbfc7a420 in ?? ()
#9  0x00000006 in ?? ()
#10 0x00006de8 in ?? ()
#11 0x417ce7a1 in raise () from /lib/tls/libc.so.6
#12 0x417cff79 in abort () from /lib/tls/libc.so.6
#13 0x417c7fe3 in __assert_fail () from /lib/tls/libc.so.6
#14 0x41698d2c in _slang_execute2 (file=0x987f3c4, mach=)
    at shader/slang/slang_execute.c:572
#15 0x41694536 in parse_declaration (C=) at shader/slang/slang_compile.c:1571
#16 0x41696b65 in _slang_compile (
    source=0x9800e28 "uniform vec3 ambientColor;\nvec4 diff = vec4(ambientColor,
1.0);\nuniform vec3 lightcolor0;\nvarying vec4 diffFactors;\nvarying vec2
diffTexCoord;\nuniform sampler2D diffTex;\nuniform sampler2D ringTex;\nvar"..., 
    object=) at shader/slang/slang_compile.c:1878
#17 0x41618e02 in _shader_Compile (intf=) at shader/shaderobjects_3dlabs.c:686
#18 0x416135af in _mesa_CompileShaderARB (shaderObj=)
    at shader/shaderobjects.c:259
#19 0x0812b4fe in GLShader::compile ()

This is with celestia 1.4.1.
Might be related (but probably not?) to #8064.
Comment 1 Brian Paul 2006-08-29 12:10:49 UTC
FWIW, I replaced the abort() with a _mesa_problem() call that should be more
informative.
Comment 2 Roland Scheidegger 2006-08-29 15:41:36 UTC
(In reply to comment #1)
> FWIW, I replaced the abort() with a _mesa_problem() call that should be more
> informative.
No longer aborts, whole saturn is fully red, and the message is:
Mesa 6.5.1 implementation error: bad slang opcode 0x43
Please report at bugzilla.freedesktop.org
Comment 3 Brian Paul 2006-08-29 15:56:30 UTC
Looks like the slang compiler is generating opcodes (such as
slang_asm_vec4_copy) which the interpreter can't execute.

Michal Krol will probably have to look into that.
Comment 4 mjkrol 2006-08-30 15:43:14 UTC
Fixed in CVS. Though I would like to see the particualr shader
causing the assertion if it is possible.
Comment 5 mjkrol 2006-08-31 08:19:17 UTC
I have managed to extract the shader causing trouble and, as I expected, the fix
was not necessary - the shader is ill-formed, I am affraid. The Mesa's GLSL
compiler is under development and allows you to do some "extra" things that are
illegal. Other compilers from other vendors also have some "features", but they
are different from ours.

Particularly, Mesa GLSL currently accepts the following code:

const vec3 precalc_sin30 = vec3 (sin (30.0));
const float other_precalculated_constant = clamp (pow (cos (66.6), 16.0), 0.0, 1.0);
void main () {
gl_FragColor = vec4 (precalc_sin30, other_precalculated_constant);
}

It accepts it only because it does not accept lots of semantic errors.

On the other hand, celestia shader initializes a global variable with a uniform
which is illegal. The initializer must be a constant expression. Mesa will
accept that (see above), but will evaluate the initializer at compile-time,
meaning that it will be 0.0 all the time.

This is the celestia's shader.

uniform vec3 ambientColor;
vec4 diff = vec4(ambientColor, 1.0);
uniform vec3 lightcolor0;
varying vec2 diffTexCoord;
uniform sampler2D diffTex;
varying vec2 normTexCoord;
varying vec3 lightDir0;
uniform sampler2D normTex;
void main(void)
{
vec4 color;
vec3 n = texture2D(normTex, normTexCoord.st).xyz * vec3(2.0, 2.0, 2.0) -
vec3(1.0, 1.0, 1.0);
float l;
l = max(0.0, dot(lightDir0, n)) * clamp(lightDir0.z * 8.0, 0.0, 1.0);
diff.rgb += l * lightcolor0;
color = texture2D(diffTex, diffTexCoord.st);
gl_FragColor = color * diff;
}

Simply move the initialization part to the main() function body and it will run
on Mesa and other non-nVIDIA IHVs (I suspect nVIDIA is the development
environment for celestia team).

uniform vec3 ambientColor;
uniform vec3 lightcolor0;
varying vec2 diffTexCoord;
uniform sampler2D diffTex;
varying vec2 normTexCoord;
varying vec3 lightDir0;
uniform sampler2D normTex;
void main(void)
{
vec4 color;
vec3 n = texture2D(normTex, normTexCoord.st).xyz * vec3(2.0, 2.0, 2.0) -
vec3(1.0, 1.0, 1.0);
float l;
l = max(0.0, dot(lightDir0, n)) * clamp(lightDir0.z * 8.0, 0.0, 1.0);
vec4 diff = vec4(ambientColor, 1.0);
diff.rgb += l * lightcolor0;
color = texture2D(diffTex, diffTexCoord.st);
gl_FragColor = color * diff;
}

Roland, can you report the bug to the celestia project?
Comment 6 Roland Scheidegger 2006-08-31 08:59:16 UTC
(In reply to comment #5)
> I have managed to extract the shader causing trouble and, as I expected, the fix
> was not necessary - the shader is ill-formed, I am affraid.
Well, usually crashing isn't how opengl user errors should be handled ;-). 

> Roland, can you report the bug to the celestia project?
Done: http://shatters.net/forum/viewtopic.php?p=76076
Comment 7 Adam Jackson 2009-08-24 12:24:17 UTC
Mass version move, cvs -> git


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.