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 5 of 5

Thread: GLSL pads int arrays to 16 bytes, taking 4 times local memory

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011

    GLSL pads int arrays to 16 bytes, taking 4 times local memory

    I have an NVIDIA GTX 670, linux driver 319.49. In my shader I declare an array of integers...

    int myArray[512];

    When I use glGetProgramBinary and have a look at Nvidia's handy plaintext output I can see the lmem declaration as follows:

    TEMP lmem[512];

    Re-declaring the array as ivec4 myArray[128] and modifying my code to index the array with myArray[i/4][i%4] produces the following line in the binary output:

    TEMP lmem[128];

    Also, and this is the really cool part, my program doesn't crash on the first draw call using this shader.

    Has anyone else seen this annoying behaviour? Why would padding an int array to 16 bytes per element help? I can understand padding user-defined structs to align accesses for performance, but taking 4 times memory seems a little overkill.

    Finally, I can't imagine [i/4][i%4] gives great performance. Is there a nicer way to have a linear integer array I can access with a single index AND not run out of memory due to padding?
    Last edited by sleap; 10-21-2013 at 07:15 PM.

Tags for this Thread

Posting Permissions

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