PDA

View Full Version : Shaders vs Programs



glfreak
08-01-2004, 09:38 PM
Hello,

I would like to know what is advantage of using vertex/fragment shaders over the vertex/fragment programs? Do shaders are compiled into assembly programs, or do they have special features implemented in hardware that have no equivalence in v/f programs?

Thanks.

glfreak
08-02-2004, 03:03 AM
Let me put reward my question:

Are shaders implemented on top of vertex/fragment programs? If so how are conditional statements, loops and functions implemented then?

SeskaPeel
08-02-2004, 04:53 AM
Shaders and programs are the same.
For D3D, you say shaders, and for OGL, you say programs.

On top of these, you have high level languages, like CG (agnostic), GLSL (only OGL), or HLSL (only D3D). These languages generate automatically for you assembly shaders/programs.

SeskaPeel.

evanGLizr
08-02-2004, 08:35 AM
Originally posted by wismak:
Let me put reward my question:

Are shaders implemented on top of vertex/fragment programs? If so how are conditional statements, loops and functions implemented then?Unless done internally by the driver for convenience, glsl shaders are not implemented on top of programs. Cg shaders on the other hand are.

What probably happens is that both (glsl) shaders and programs are compiled to an intermediate language(three-address-code/register transfer language/decorated tree) which is optimized using the same code path.

glfreak
08-02-2004, 10:08 AM
Thanks for your answers.
What about functions/conditions? they don't have equivalents in v/f programs, thus they are not implemented on top of them.
Where is general, more efficient choice in the meantime of programmable GPUs?

V-man
08-02-2004, 10:21 AM
That depends on what you mean by v/f programs.

If you means ARBvp/ARBfp 1.0, then these don't represent the state of the art. You have to use NVidia extensions for ARBvp/fp 1.0 or just use NVvp/NVfp (many version).

Or just use GLSL. Or use GLSL with NV extensions.

Efficicency does not matter if you are learning.

Besides, the IHV's are always updating their drivers every 1 or 2 months so sometimes GLSL runs as fast as ARBvp/fp, sometimes not (according to my tests)

glfreak
08-02-2004, 11:41 AM
So to ensure performance ARBvp/fp is the way to go. But still not understand how functions and conditional statements work.
If shading language is compiled into low level GPU binaries, then it should perform the same as ARBvp/fp if not faster faster.

Korval
08-02-2004, 12:23 PM
If shading language is compiled into low level GPU binaries, then it should perform the same as ARBvp/fp if not faster faster.It took a long time for optimizing C compilers to start beating hand-optimized assembly. While a lot of that time was spent learning how to make good optimizing compilers (knowledge that can, in theory, be transplanted into GPU's), a lot of it is spent actually writing that code.

Also, the GPU paths that are optimized are the ones that are used most frequently. Eventually, ARB_vp/fp will no longer be used, as they will not be upgraded (all future GL shading language features will go into glslang). at that point, when people are using glslang more and more frequently, driver developers will have a significant need to optimize the output of compilers.

glfreak
08-02-2004, 09:23 PM
How do I define and call a function in vertex_program_ARB and fragment_program_ARB?

How do I make a conditional branch in
vertex_program_ARB and fragment_program_ARB?

If it's not possible, then GLSL is directly related to GPU and not implelented on top of assembly programs.

SeskaPeel
08-03-2004, 12:39 AM
That's not because one API lets you do things and that another don't that they have different implementations. It's all a matter of interface.

And for that conditonal stuff, you need latest nv4x GPUs.

SeskaPeel.

Korval
08-03-2004, 09:33 AM
And for that conditonal stuff, you need latest nv4x GPUs.Only in the fragment programs. Vertex programs have had conditional looping since R300/NV30.

V-man
08-03-2004, 07:01 PM
If it's not possible, then GLSL is directly related to GPU and not implelented on top of assembly programs. You are generalizing. Every company does it as they wish.

Nvidia for example has a full blown extensions that represents their own hardware to the fullest and can convert to their NV_vp & NV_fp
You can hack the registry so that it will dump the files.

I think they do this because it is easy for them by design.

I suggest you start with GLSL now. 3dlabs has an SDK with many samples.