Archived

This topic is now archived and is closed to further replies.

vNistelrooy

GLSL vs ARB_fragment_program: Instruction consuming

Recommended Posts

vNistelrooy    140
It looks like a GLSL shader needs a lot more instructions than an ARB_fragment_program shader (same shaders of course). Am I correct?
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
DannerGL    122
quote:
Original post by CPPMaster Poppet
It looks like a GLSL shader needs a lot more instructions than an ARB_fragment_program shader (same shaders of course). Am I correct?


If you are refering to the actual number of hardware, an ARB_fp shader and a GLSL shader serving exactly the same functionality would most likely be compiled down the same number of hardware instructions.

In terms of the actual amount of code you write, you may end up with a bigger code string when using GLSL, but it's much easier to write and youre less prone to making errors using GLSL. The amount of code you write does not directly translate into the number of instructions you'll use.

Dan


[edited by - DannerGL on May 26, 2004 4:45:40 PM]

Share this post


Link to post
Share on other sites
vNistelrooy    140
quote:
Original post by DannerGL
The amount of code you write does not directly translate into the number of instructions you''ll use.



I know.

quote:
Original post by DannerGL
If you are refering to the actual number of hardware, an ARB_fp shader and a GLSL shader serving exactly the same functionality would most likely be compiled down the same number of hardware instructions.



Strange, because when translating my CG shader to GLSL, the GLSL shader was running in software while the CG shader was running in hardware.



"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
_the_phantom_    11250
its probably a compiler thing, maybe the GLSL backend isnt as tweaked as it could be, maybe you'll have to restructure your code slightly to drop the instruction count.
Infact, are you sure its the instruction count causing the issue and not something else?

edit: in theory, GLSL shaders could take up less instructions in the long run

[edited by - _the_phantom_ on May 26, 2004 8:51:07 PM]

Share this post


Link to post
Share on other sites
vNistelrooy    140
quote:
Original post by _the_phantom_
edit: in theory, GLSL shaders could take up less instructions in the long run



Umm yeah? Why is that?

edit: You mean loops right?



"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"



[edited by - CPPMaster Poppet on May 27, 2004 3:59:50 AM]

Share this post


Link to post
Share on other sites
Trienco    2555
quote:
Original post by CPPMaster Poppet
quote:
Original post by _the_phantom_
edit: in theory, GLSL shaders could take up less instructions in the long run

Umm yeah? Why is that?


in theory i would expect glsl to be optimized to death by the compiler (but then, id expect something similiar for programs too).

but if your assumption is based on comparing glsl and vertex/fragment program versions of the same "shader" (and you happen to have made them on an ati) then my guess would be that whatever compiler they use simply sucks at optimizing or doesnt even try (and in fact must be doing some really weird things to slow it down).

but thats something that should change with more driver releases, even though i still find glsl a pain in the ... to use.

Share this post


Link to post
Share on other sites
vNistelrooy    140
quote:
Original post by Trienco
but if your assumption is based on comparing glsl and vertex/fragment program versions of the same "shader" (and you happen to have made them on an ati) then my guess would be that whatever compiler they use simply sucks at optimizing or doesnt even try (and in fact must be doing some really weird things to slow it down).



Actually ATi''s compiler sucks at optimizing. This will change of course in the future but I think I have optimized my shader as good as possible.



"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites