4 Replies Latest reply on Dec 12, 2012 9:56 AM by gsellers

    Are dynamically-indexed subroutine arrays in GL4 on HD5xxx hardware half-possible?

    bananafish

      To my astonishment, the following successfully compiles in GLSL 410 on a Radeon HD 5570 using FGLRX-updates 2:9.000 ubuntu:

       

      #version 410
      subroutine uniform testSR testSub[2];
      /**
      Code here setting up the subroutines for testSR
      **/
      
      void main()
      {
      testSub[gl_VertexID%2]();
      }
      

       

      ...however this resulted in execution only of the subroutine at array element 0. My understanding is that instructions within wavefronts are in lock-step and cannot truly branch so I did not expect this to compile at all, or perhaps it would be compiled to the equivalent to a switch() block and inline the subroutines the old fashioned way. When a constant is passed as array index, implicit or otherwise, the array call for that index works.  For example:

       

      void main()
      {
      testSub[1]();
      }
      

      ..correctly results in subroutine behavior of the subroutine specified at index 1.

       

      Why is this? Is this a bug?

       

      The test code above was inspired by this posting. The wording was confusing but the idea of using dynamically-indexed subroutine arrays seemed impossible in GPU hardware as it would imply that each thread could follow its own instruction path without traditional clause-lockouts.

       

      Driver info below, in case this is a bug:

      sudo modinfo fglrx_updates

      filename:       /lib/modules/3.5.0-18-generic/updates/dkms/fglrx_updates.ko

      license:        Proprietary. (C) 2002 - ATI Technologies, Starnberg, GERMANY

      description:    ATI Fire GL

      author:         Fire GL - ATI Research GmbH, Germany

      srcversion:     9C5BC5DE95ACE501DA51B24

      ...

      vermagic:   3.5.0-18-generic SMP mod_unload modversions