Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Vertex/fragment glsl shader performance question

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Sunnyvale
    Posts
    26

    Vertex/fragment glsl shader performance question

    Hi,

    implementing a simple phong lighting shader, i've noticed a strange performance issue:
    in my first shot, i've implemented the refection & view vector computation in the fragment shader getting the interpolated value of the light direction and view direction from vertex shader (using varying variable).
    Then, thinking that deferring the maximum of the computation to vertex shader would have increased the perf, i moved the reflection part to the vertex shader and added a varying variable to interpolate the reflected vector from the vertex shader to the fragment one.
    I then noticed a serious performance hit (-20%).

    Does someone have some kind of explanation for this performance hit?

    The only explainations i can expect is that adding varying variable is far from "free" or maybe i've reach the vertex shader limitation ...

    thx for any help

  2. #2
    Advanced Member Frequent Contributor yooyo's Avatar
    Join Date
    Apr 2003
    Location
    Belgrade, Serbia
    Posts
    872

    Re: Vertex/fragment glsl shader performance question

    I have do some tests about varying on FX5900 and it support 8 vec4 varying's. Performaces drops 4-6x times when I use 8 varyngs. Even for simple fragment shader (gl_FragColor = v0 + v1 + v2 + .. + v7.

    For each varying hw must interpolate and compute perspective correction on it in rasterization stage.

    yooyo

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Sunnyvale
    Posts
    26

    Re: Vertex/fragment glsl shader performance question

    ok, but i really think that a simple vec3/4 interpolation is less expensive than a reflect + normalize for each fragment (don't know about the perspective correction complexity).

    As you said, perhaps it's due to some hardware limitation...

    Anyway, i would really appreciate some light on the "varying" mechanism and the way it is implemented (at least for personnal culture )

    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •