Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Do GLSL structures any performance overhead?

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2013

    Question Do GLSL structures any performance overhead?

    Do GLSL varying structures any performance overhead? How they are implemented?
    Are the following snippets equivalent in the aspect of performance?

    out MyBlock
    out vec3 var0;
    out vec3 var1;
    out vec3 var2;
    } Out;
    struct MyStruct
    vec3 var0;
    vec3 var1;
    vec3 var2;
    out MyBlock
    MyStruct Out;

    Thanks in advance.
    Last edited by plasmacel; 01-19-2014 at 12:11 AM.

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2004
    structures are pure syntactical convenience for you to increase readability/style/aesthetics of your code
    the 2 cases you ask about should have no difference performance-wise (apart from bad compiler with bugs)
    ultimately they will be translated to a bunch of GPU registers and any high-level grouping in structs is discarded.

    There are various considerations that are beneficial to bear in mind though.
    One such is that if you need an array that is to be indexed, you better make sure it has elements that are multiple of 16 bytes
    (16 bytes is one vec4 - the hardware register unit) or else the compiler will generate very large and complicated GPU code
    to emulate the requested behavior, because today's GPUs can only index arrays that are multiple of vec4.

Posting Permissions

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