PDA

View Full Version : internal compile error on GF6200



remdul
09-15-2006, 05:09 PM
I'm getting this error string returned:

Fragment info
-------------
(54) : warning C7011: implicit cast from "int" to "float"
(55) : warning C7011: implicit cast from "int" to "float"
(56) : warning C7011: implicit cast from "int" to "float"
(96) : warning C7506: OpenGL does not define the global function lerp
(75) : warning C7011: implicit cast from "int" to "float"
(75) : warning C7011: implicit cast from "int" to "float"
Internal error: assembly compile error for fragment shader at offset 2228:
-- error message --
line 67, column 11: error: invalid operand variable
line 69, column 29: error: invalid operand variable
-- internal assembly text --
!!ARBfp1.0
OPTION NV_fragment_program2;
# cgc version 1.5.0000, build date Dec 10 2005 03:29:49
# command line args:
#vendor NVIDIA Corporation
#version 1.0.02
#profile fp40
#program main
#semantic texture0
#semantic texture1
#semantic texture3
#semantic eyepos
#semantic sunvec
#semantic texture2
#semantic texture4
#var float4 gl_TexCoord[0] : $vin.TEX0 : TEX0 : -1 : 1
#var float4 gl_TexCoord[1] : : : -1 : 0
#var float4 gl_TexCoord[2] : : : -1 : 0
#var float4 gl_TexCoord[3] : : : -1 : 0
#var float4 gl_TexCoord[4] : : : -1 : 0
#var float4 gl_TexCoord[5] : : : -1 : 0
#var float4 gl_TexCoord[6] : : : -1 : 0
#var float4 gl_TexCoord[7] : : : -1 : 0
#var float4 gl_FragColor : $vout.COLOR : COL : -1 : 1
#var sampler2D texture0 : : texunit 0 : -1 : 1
#var sampler2D texture1 : : texunit 3 : -1 : 1
#var sampler2D texture3 : : texunit 1 : -1 : 1
#var float3 eyepos : : c[0] : -1 : 1
#var float3 sunvec : : c[8] : -1 : 1
#var float4 ambientColor : : : -1 : 0
#var float3 normWorldSpace : $vin.TEX1 : TEX1 : -1 : 1
#var float3 posWorldSpace : $vin.TEX2 : TEX2 : -1 : 1
#var samplerCUBE texture2 : : texunit 4 : -1 : 1
#var sampler2D texture4 : : texunit 2 : -1 : 1
#var float4 diffuseColor : $vin.TEX3 : TEX3 : -1 : 1
#var float3 posViewSpace : : : -1 : 0
#var float3 halfvector : : : -1 : 0
#var float3 normViewSpace : : : -1 : 0
#const c[1] = 1 4 2 0
#const c[2] = -0.721 -0.6859999 0
#const c[3] = 0.7179999 0.698 0.6819999 0
#const c[4] = -0.7609999 -0.6819999 -0.5529999 0
#const c[5] = 0.6669999 0.7099999 0.7919999 0
#const c[6] = -0.7369999 -0.7219999 -0.702 0
#const c[7] = 0.7289999 0.7139999 0.6899999 0
PARAM c[9] = { program.local[0],
{ 1, 4, 2, 0 },
{ -0.72099996, -0.68599993, 0 },
{ 0.71799994, 0.69799995, 0.68199992, 0 },
{ -0.76099986, -0.68199992, -0.55299991, 0 },
{ 0.66699994, 0.70999992, 0.79199988, 0 },
{ -0.73699993, -0.72199994, -0.70199996, 0 },
{ 0.72899991, 0.71399993, 0.68999994, 0 },
program.local[8] };
TEMP R0;
TEMP R1;
TEMP R2;
TEMP R3;
SHORT TEMP H0;
TEMP RC;
TEMP HC;
OUTPUT oCol = result.color;
DP3R R0.x, fragment.texcoord[1], fragment.texcoord[1];
RSQR R0.x, R0.x;
MULR R3.xyz, R0.x, fragment.texcoord[1];
MULR R2.xyz, R3, R3;
MOVR R1, vr4;
MOVXC HC.xyz, R3;
MADR R1(GT.x), R2.x, c[7], vr4;
SGTR H0.xyz, R3, c[1].w;
MOVR R0, R1;
MOVXC HC.xyz, H0;
MADR R0(EQ.x), -R2.x, c[6], R1;
MOVR R1, R0;
MOVXC HC.xyz, R3;
MADR R1(GT.y), R2.y, c[5], R0;
MOVR R0, R1;
MOVXC HC.xyz, H0;
MADR R0(EQ.y), -R2.y, c[4], R1;
DP3R R2.y, R3, -c[8];
MOVR R1, R0;
MOVXC HC.xyz, R3;
MADR R1(GT.z), R2.z, c[3], R0;
MOVR R0, R1;
MOVXC HC.xyz, H0;
MADR R0(EQ.z), -R2.z, c[2].xxyz, R1;
TEX R1.w, fragment.texcoord[0], texture[0], 2D;
MOVR R1.xyz, c[1].x;
MULR R0, R0, R1;
TEX R2.x, fragment.texcoord[0], texture[2], 2D;
MULR R0, R2.x, R0;
MADR R1, R1, fragment.texcoord[3], -R0;
MAXR R2.y, R2, c[1].w;
MULR R1, R2.y, R1;
ADDR R1, R0, R1;
ADDR R0.xyz, -fragment.texcoord[2], c[0];
DP3R R0.w, R0, R0;
RSQR R0.w, R0.w;
MULR R2.yzw, R0.w, R0.xxyz;
DP3R R0.x, R2.yzww, R3;
MULR R0.xyz, R3, R0.x;
MULR R0.xyz, R0, c[1].z;
ADDR R0.xyz, R2.yzww, -R0;
DP3R_SAT R2.y, R2.yzww, R3;
MOVR R0.x, -R0;
TEX R0, R0, texture[4], CUBE;
ADDR R2.y, -R2, c[1].x;
ADDR R0, R0, -R1;
POWR R2.y, R2.y, c[1].y;
TEX R3.x, fragment.texcoord[0], texture[1], 2D;
MULR R2.y, R3.x, R2;
MULR R2.x, R2.y, R2;
MADR oCol, R2.x, R0, R1;
END
# 51 instructions, 4 R-regs, 1 H-regsWhen I try to compile this fragment shader:

// PERPIXEL_FRAG.GLSL

uniform sampler2D texture0; // diffuse map
uniform sampler2D texture1; // normal map
uniform samplerCube texture2; // reflect map
uniform sampler2D texture3; // specular map
uniform sampler2D texture4; // ambient occlusion map

uniform vec3 eyepos; // eye direction vector
uniform vec3 sunvec; // sunlight direction vector

varying vec4 diffuseColor;
varying vec4 ambientColor;

varying vec3 posWorldSpace; // position in world space
varying vec3 posViewSpace; // position in view space
varying vec3 normWorldSpace; // normal in world space
varying vec3 normViewSpace; // normal in view space

varying vec3 halfvector;


void main()
{
vec3 halfV, viewV, ldir;
float NdotHV;

vec3 vn; // vertex normal
vec3 tn; // texture normal
vec3 n; // combined normal
vec3 v; // view vector
vec3 r; // reflected view vector
vec4 color; // final output color

vec4 diffuse; // diffuse map
vec4 reflection; // reflection map
float specular; // specular map
float occlusion; // occlusion map
float lighting; // computed lighting

float sa = 0.707107;
float sb = 1.414213;
vec4 amb_rt = vec4( 0.729, 0.714, 0.690, 0.0 );
vec4 amb_lf = vec4( 0.737, 0.722, 0.702, 0.0 );
vec4 amb_up = vec4( 0.667, 0.710, 0.792, 0.0 );
vec4 amb_dn = vec4( 0.761, 0.682, 0.553, 0.0 );
vec4 amb_fr = vec4( 0.718, 0.698, 0.682, 0.0 );
vec4 amb_bk = vec4( 0.721, 0.721, 0.686, 0.0 );
vec4 amb;


// diffuse map
diffuse = texture2D(texture0, gl_TexCoord[0].st);
diffuse.r = 1;
diffuse.g = 1;
diffuse.b = 1;

// specular map
specular = texture2D(texture3,gl_TexCoord[0].st).r;

// occlusion map
occlusion = texture2D(texture4, gl_TexCoord[0].st).r;

// normal map
tn = 2.0 * (texture2D(texture1, gl_TexCoord[0].st).rgb - 0.5);

// normalize vertex normal
vn = normalize(normWorldSpace);

// todo: tangent space stuff
n = vn;

// compute lighting
lighting = max(0, dot(n,-sunvec));


// ambient cube lighting
if (n.x > 0.0) {
amb += amb_rt * ( n.x * (sa * (n.x * sb)) );
} else {
amb += amb_lf * ( -n.x * (sa * (n.x * -sb)) );
}
if (n.y > 0.0) {
amb += amb_up * ( n.y * (sa * (n.y * sb)) );
} else {
amb += amb_dn * ( -n.y * (sa * (n.y * -sb)) );
}
if (n.z > 0.0) {
amb += amb_fr * ( n.z * (sa * (n.z * sb)) );
} else {
amb += amb_bk * ( -n.z * (sa * (n.z * -sb)) );
}

// combine
color = lerp(amb*diffuse*occlusion, diffuseColor*diffuse, lighting); // <------ this breaks
color = lerp(ambientColor*diffuse*occlusion, diffuseColor*diffuse, lighting); // <----- this works fine

// reflection

v = normalize(eyepos - posWorldSpace);
r = reflect(v, n);
r.x = -r.x;
reflection = textureCube(texture2, r);

// fresnel
float fresnel=pow(1.0-clamp( dot(v,n) ,0.0,1.0),4.0);

// apply reflection
color = lerp(color, reflection, specular*fresnel*occlusion);

//// temp
//color.rgb = (n.xyz+1)*0.5; // normal color
//color.rgb = vn.xyz; // vertex normal color
//color = texture2D(texture4, gl_TexCoord[0].st);
//// temp
/*
color.g = fresnel;
color.r = color.g;
color.b = color.g;
*/

//color = amb*diffuse*occlusion; // <----- this works fine

gl_FragColor = color;
}

// END OF FILENote: there may be some nonsense in this shader as I was testing stuff, but I don't think that it is relevant.

Compiles fine when uncommenting some lines (indicated by ascii arrows ). The odd thing is that I swap one vec4 with another triggers this ("amb" and "ambientColor").

1) Is this a normal error? The only hit I got on Google was a forum post (gamedev.net) with a similar problem where replies suggested it could be a driver bug.

2) This happens with Forceware Driver 81.98 . I'd love to try it on the latest drivers, but the installer repeatedly fails to copy the by the setup program extracted files for unknown reason (reinstalling 81.98 works fine, haven't tried the more recent older versions yet).

sqrt[-1]
09-15-2006, 05:46 PM
Two things:

- lerp is not defined in GLSL. use "mix". (or make a "#define lerp mix" at the top of the file)

- You should use "1.0" instead of "1". (unless you are using GLSL 1.2 - which no driver currently supports?)

This is probably not the casue of the errors, but you should clean it up.

mjkrol
09-16-2006, 12:01 AM
Looks like a codegen bug for conditionals.
Try to simplify or eliminate "if" statements, like this:

if (n.x > 0.0) {
amb += amb_rt * ( n.x * (sa * (n.x * sb)) );
} else {
amb += amb_lf * ( -n.x * (sa * (n.x * -sb)) );
}Make it look like this:

vec4 temp = n.x * sa * n.x * sb;
if (n.x > 0.0) {
amb += amb_rt * temp;
} else {
amb += amb_lf * temp;
}Or, in case it still does not work:

amb += mix (amb_lf, amb_rt, step (0.0, n.x)) * n.x * sa * n.x * sb;

remdul
09-16-2006, 05:17 AM
I pinned it down to the code in one of the six if/else clauses. If I comment out one of those lines, it compiles, but if all six are there it won't compile.

E.g.:
if (n.x > 0.0) {
amb += amb_rt * ( n.x * (sa * (n.x * sb)) );
} else {
amb += amb_lf * ( -n.x * (sa * (n.x * -sb)) );
}
if (n.y > 0.0) {
amb += amb_up * ( n.y * (sa * (n.y * sb)) );
} else {
amb += amb_dn * ( -n.y * (sa * (n.y * -sb)) );
}
if (n.z > 0.0) {
amb += amb_fr * ( n.z * (sa * (n.z * sb)) );
} else {
//amb += amb_bk * ( -n.z * (sa * (n.z * -sb)) ); // <------ this works, uncomment = no compile
}(This works if I comment out any of these lines, not just the last.)

@sqrt[-1]:
Applied those changes, but as expected the didn't solve it.

@mjkrol:
I tried your first suggestion (and a few variations) but that didn't fix it.
Your last suggestion however compiles flawlessly, and solved the problem.


I will try to install the latest drivers again, if I succeed I'll try the old code again and see if it still persists.

Thanks for the help. :)

Jedimaster
09-16-2006, 07:30 PM
But I have a huge question.

does 6200 supports 5 texture units in your shader ??? NVIDIA says only 4 units,16 textures in each units.

maybe you should paste codes in ShaderDesiger,it supply 2 compiler,one is local drivers compiler,another is generel compiler(maybe from 3dlabs)

remdul
09-17-2006, 11:27 AM
I believe the 4 units thing only applies to multi-texturing and register combiners, not to shaders. Most (if not all) GLSL implementations support at least 16 units AFAIK.

arekkusu
09-17-2006, 04:18 PM
FAQ (http://developer.nvidia.com/object/General_FAQ.html#t6)

remdul
10-15-2006, 07:14 AM
UPDATE:

nVidia has fixed the installer issue and I've now succesfully installed the latest drivers again (91.47 Sept 29).

The shader now works fine, the driver bug apears to have been fixed.