On Sun, May 10, 2009 at 7:53 AM, Maciej Cencora <[email protected]> wrote:
> Hi,
>
> I'm going to implement GLSL 1.0 support for r300 and I have few questions.
> The problem is r300 and r400 hw doesn't support branching/loops. For loops
> there's no other way than fallback to software, but I can do branching by
> executing all branches and then selecting result depending on condition.
>
> Let's take a look at this shader (in pseudo-code):
>
> if (some_vec4 > {2.0, 3.0, 1.0, 0.0})
> some_code;
> else
> other_code;
> endif
>
> It would be translated into something like this:
> SGT TEMP[1].w, TEMP[0].xyzw, CONST[0].xyzw
> IF TEMP[1].wwww
> some_code;
> ELSE
> other_code;
> ENDIF
>
> How should I understand that IF instruction? If all components are greater
> than zero, or only one have to be greater than zero, or maybe all components
> must equal to 1.0?
If the X component of the register is non-zero it's considered to be
true. The other components aren't significant.
> What if the condition be something like this (var.xw > {2.0, 0.0})?
That's not legal GLSL. If you want to compare vectors you need to use
a built-in function like greaterThan() which will return a boolean
vector result. Then, you can convert the boolean vector to a scalar
boolean with the any() or all() functions.
> Is it even legal to compare only selected vector components?
> If so, how would the code look like after translation?
Take a look at the docs/shading.html file and try building the
stand-alone GLSL compiler. It's a quick way to compile GLSL code and
see what the resulting GPU code looks like.
-Brian
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev