Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / cgD3D9LoadProgram() returns error: invalid data Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
gjaegy

May 15, 2005, 02:14 PM

hi everybody,

i experience a very strange problem. I've already searched for similar posts, but I didn't find a suitable answer. so my problem is the following:

I have a fragment program, which compile fine with both runtime cg compiler and command line compiler, with the ps_2_0 profile.

But when I try to load it, I get the following error -2005529767 (invalid data in the directx error look up tool). I have no idea where the problem comes from, but I know where it comes from:

Code:

  1.  
  2. FragmentOutput mainfrag(
  3.   VertexOutput IN,
  4.   const uniform float3 lightmodeldir0 : C3,      // position of light0 in view coordinates
  5.   const uniform float3 eyepositionmodel : C4,      // camera position in view coordinates
  6.  
  7.   const uniform float3 AmbientColor : C5,
  8.   const uniform float3 DiffuseColor : C6,
  9.   const uniform float3 SpecularColor : C7,
  10.   const uniform float specExp : C8,
  11.   const uniform float4x4 matworld : C9,
  12.   const uniform float4x4 mattsm : C10,
  13.   uniform sampler2D basetexture0,         // normal tex
  14.   uniform sampler2D basetexture1         // shadow map texture
  15. )
  16. {
  17.   FragmentOutput finalColor;
  18.  
  19.   float fEpsilon = 0.001f;
  20.  
  21.   float texelSize = 1.0f / 1024f;
  22.  
  23.   float fZToCompare = IN.PositionZ.z/IN.PositionZ.w - fEpsilon;
  24.   //float shadow = 0;//1.0f * (( fZToCompare > shadowTex) ? 0.0 : 1.0);
  25.  
  26.   float2 ShadowTexC = IN.projCoords.xy / IN.projCoords.w;
  27.  
  28.   // transform to texel space
  29.   float2 texelpos = 1024 * ShadowTexC;
  30.  
  31.   // Determine the lerp amounts          
  32.   float2 lerps = frac( texelpos );
  33.  
  34.   //read in bilerp stamp, doing the shadow checks
  35.   float sourcevals[4];
  36.   sourcevals[0] = (fZToCompare > tex2D( basetexture1, ShadowTexC ).r) ? 0.0f : 1.0f;        
  37.   sourcevals[1] = (fZToCompare > tex2D( basetexture1, ShadowTexC + float2(texelSize, 0) ).r) ? 0.0f : 1.0f;        
  38.   sourcevals[2] = (fZToCompare > tex2D( basetexture1, ShadowTexC + float2(0, texelSize) ).r) ? 0.0f : 1.0f;        
  39.   sourcevals[3] = (fZToCompare > tex2D( basetexture1, ShadowTexC + float2(texelSize, texelSize) ).r) ? 0.0f : 1.0f;        
  40.  
  41.   // lerp between the shadow values to calculate our light amount
  42.   float shadow = lerp( lerp( sourcevals[0], sourcevals[1], lerps.x ),
  43.                   lerp( sourcevals[2], sourcevals[3], lerps.x ),
  44.                  lerps.y );
  45.   //float shadow = sourcevals[0];
  46.  
  47.   float4 Kd         = tex2D( basetexture0,  IN.TexCoord0.xy );   // normal texture
  48.      
  49.   float3 N         = normalize(IN.Normal);
  50.   float3 L         = -normalize(lightmodeldir0);
  51.   float diffuse      = max( dot(N, L), 0 );      
  52.        
  53.   float3 finalShadow   = float3(shadow, shadow, shadow);
  54.   finalColor.Color   = float4( ( Kd.xyz * AmbientColor ) + ( Kd.xyz * diffuse * DiffuseColor/* + Ks.xyz * SpecularColor */) * finalShadow, 1 );
  55.  
  56.  
  57.   return finalColor;
  58.    
  59. }
  60.  


when I comment the lerp function and uncommend the "float shadow = sourcevals[0];" line (meaning only one sample is used), then it loads successfully.

I've already had similar with other shaders. I use the 9.0c april revision of directx, and the latest drivers for my ATI 9600 card. I've tried both Cg 1.3 and 1.4b2, the same problem occures.

Could someone help me please ? I'm really stuck... I've find others post about the same subject, but didn't find any answer.

Is it possible that the pseudo assembler code generated by Cg is source of the problem ? Why does some shaders work and some other don't ? I've check the instruction count, and that don't seem to be an issue.

Greg

 
This thread contains 1 message.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.