PDA

View Full Version : validate error



nib
03-06-2007, 08:11 AM
When I compile the vertex and fragment program there are no errors. The link succeeds. But then there is this weird comment about validation:

Validation Failed: Sampler error:
Samplers of different types use the same texture image unit.
- or -
A sampler's texture unit is out of range (greater than max allowed or negative).

Yet, I don't think I've done anything wrong (?). Works on ATI Radeon:

uniform sampler2D texunit0; //diffuse texture
uniform sampler2D texunit1; //normal map
uniform sampler2D texunit3; //shine map
uniform sampler2DShadow shadowmap; //shadow map, 5
uniform samplerCube cubemap; //cube map, 7

Huff, first run on an intel mac with a nvidia card. :)

Also, any gotchas compiling on an Nvidia 7300 GT ? Seem to be having a compile issue with glsl shaders. Everything else appears to work fine -- vbos, display lists, accelerate library -- when I turn off the glsl shaders. I kept the number of varying variables below 8, as someone suggested before.

I think the glsl program fails to compile. Then I fail to attach to a program object. Oddly, it starts to draw but takes about one minute to draw a single frame when the shader is on!

Komat
03-06-2007, 10:09 AM
Originally posted by nib:

Validation Failed: Sampler error:
Samplers of different types use the same texture image unit.
The ValidateProgram checks program against OGL state at the time that call was made. The error you got means that program contains sampler uniforms of different type (eg. sampler2D and samplerCube) which reference the same texture unit. Such setup is not allowed during rendering so the validation reports error. If you latter change the sampler uniforms to non conflicting values, the shader can render (and validate) correctly.

All uniform variables are initially set to zero so when your program uses different types of samplers, calling ValidateProgram before you change the sampler uniforms (e.g. immediately after linking), can report this error.



Oddly, it starts to draw but takes about one minute to draw a single frame when the shader is on! You are probably using something that is not supported on your hardware and the driver switches to sw rendering.

nib
03-07-2007, 04:09 PM
I see. I call validate after I set the uniforms for the samplers. Now validate passes.

Hmm, the nvidia/apple driver says "Yes, I support glsl vertex and fragment programs." Then it says "Yes, the programs compile." Then the driver says "It all links with program object." Viola! It says "That program validates." Its a big hit and deep in left field. Its going over the fence! Oh no! Foul ball and no homer. Your program is kicked into software mode. :(

I just have to disable all the shaders and put one in at a time and watch it break. Sheesh, I was careful not to have to many varying variables. I don't call normalize in the fragment shader. I figure thats why I use the cube map. I guess one single unforgiving mistake is going to do it -- how many different video card venders are out there?

Is there any website that documents what glsl calls actually work on what cards?

I don't know what is worse crashing or running like peanut butter. I'd rather it fail to compile right there.

nib
03-09-2007, 08:49 AM
Fixed my problem. Looks like 3dlabs shader gen code. My nvidia mac driver does not like:

void pointLight(in int i, in vec3 normal, in vec3 eye, in vec3 ecPosition3)

void directionalLight(in int i, in vec3 normal)

void flight(in vec3 normal, in vec4 ecPosition, float alphaFade)

Something like

void foo(in int i) {
float bar = boo[i];
}

So, I manually inlined it. But that is still not enough because the procedure calls are not dead stripped away if you don't use them. So, once I deleted the procedures too then it runs in hardware. :) Sort of reminds me of cg for some reason.

But it worked perfectly on the ati card.