View Full Version : Bug in nvidia glsl compiler?
grisha
08-11-2005, 10:33 AM
void main()
{
gl_Position = ftransform();
#if 1
float d = gl_ProjectionMatrix[3][2]*gl_Normal.x-gl_ProjectionMatrix[2][2];
#else
float d = -gl_ProjectionMatrix[2][2]+gl_ProjectionMatrix[3][2]*gl_Normal.x;
#endif
gl_FrontColor = vec4( d );
} Both variants of calculation of d should give same result, isn't it? With second variant '-' operator is ignored. Just try it yorself - by changing '#if 1' to '#if 0'.
driver version: 77.72
grisha
08-15-2005, 10:08 PM
Is anybody able to reproduce it?
these two shaders produce same asm output.
Shader 1:
void main()
{
gl_Position = ftransform();
float d = gl_ProjectionMatrix[2][2]+gl_ProjectionMatrix[3][2]*gl_Normal.x;
gl_FrontColor = vec4( d );
} Shader 2:
void main()
{
gl_Position = ftransform();
float d = -gl_ProjectionMatrix[2][2]+gl_ProjectionMatrix[3][2]*gl_Normal.x;
gl_FrontColor = vec4( d );
} Asm output (enabled in nvemulate) for both:
!!VP2.0
# cgc version 1.3.0001, build date Jun 15 2005 17:58:26
# command line args:
#vendor NVIDIA Corporation
#version 1.0.02
#profile vp30
#program main
#semantic gl_ProjectionMatrix
#semantic gl_ModelViewProjectionMatrixTranspose
#var float3 gl_Normal : $vin.NORMAL : ATTR2 : -1 : 1
#var float4 gl_Vertex : $vin.POSITION : ATTR0 : -1 : 1
#var float4 gl_Position : $vout.POSITION : HPOS : -1 : 1
#var float4 gl_FrontColor : $vout.COLOR0 : COL0 : -1 : 1
#var float4x4 gl_ProjectionMatrix : : c[0], 4 : -1 : 1
#var float4x4 gl_ModelViewProjectionMatrixTranspose : : c[4], 4 : -1 : 1
BB1:
DP4 o[HPOS].w, v[0], c[7];
DP4 o[HPOS].z, v[0], c[6];
DP4 o[HPOS].y, v[0], c[5];
DP4 o[HPOS].x, v[0], c[4];
MUL R0.x, v[2], c[3].z;
ADD o[COL0], R0.x, c[2].z;
END
# 6 instructions, 1 R-regs
sqrt[-1]
08-16-2005, 04:00 AM
If it looks like a bug, acts like a bug, it is a ....
It certainly appears it is just ignoring the -(negate operator)
I think you are going to need cass or another nvidia guy to give a difinite answer. (Have you emailed them about it?)
Have you tried assigning the uniforms to a tempoary value before using them. It should not make any difference but who knows...
speedy
08-16-2005, 12:29 PM
Consider trying beta drivers from ie. www.guru3d.com.. (http://www.guru3d.com..) BETA 80.40 seem to have quite good behaving GLSL implementation. (and luckily only one which works for me at the moment) YMMV.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.