Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Nested functions, aborting!

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    21

    Nested functions, aborting!

    Hi all -- I'm running into an odd error using NVIDIA drivers on Mac OS X Snow Leopard. The app actually exits during compile, with the following error text:

    (0) : fatal error C9999: Nested functions, aborting!
    Cg compiler terminated due to fatal error
    This same shader code compiles and executes fine with NVIDIA's Windows driver, not even a warning. Only the OS X Snow Leopard drivers are the issue.

    A little web search reveals the VTK project is encountering the same issue:
    http://www.vtk.org/Bug/print_bug_page.php?bug_id=10716

    Any ideas how I might work around this? It doesn't appear that Apple intends to provide a fix anytime soon.

    My driver version appears to be 1.6.26 (as reported by GLView).

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,892

    Re: Nested functions, aborting!

    Are you nesting functions? What is your shader?

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    989

    Re: Nested functions, aborting!

    If you really use nested functions then you should know that GLSL does not allow anything like that. The possible reason why it works on NVIDIA Windows drivers is because NVIDIA tends to not really care about the restrictions of GLSL as they use the same backend compiler for GLSL as they use for Cg, which have different syntax.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    21

    Re: Nested functions, aborting!

    Wow. Nesting functions isn't allowed, eh? I guess I'll have to read the spec a little closer, as this is news to me. Thanks.

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    21

    Re: Nested functions, aborting!

    Just spent a bit going over the spec, and I don't see where nested functions are disallowed. Can you quote the relevant spec language, or point me to the section?

    Here's what I read:

    * A function call returning a value is an expression (section 5.9).
    * A function-definition contains a statement-list, which contains a statement, which contains a simple-statement, which contains an expression-statement (section 6).

    These definitions are consistent in spec versions 1.20 through 4.00.

    I'll go back and check my shader to ensure that my nested functions actually return values; if they return void, that's the only way I can see that I might be in violation of the spec.

  6. #6
    Member Regular Contributor
    Join Date
    Dec 2009
    Posts
    251

    Re: Nested functions, aborting!

    A function definition may contain arbitrary function calls, but not (nested) function definitions.

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    989

    Re: Nested functions, aborting!

    Yes, mbentrup is right. You confuse two different things:

    - nested function calls, i.e. calling a function from another function is allowed (actually the main() is also a function so not allowing it would mean that there is no possibility to make user defined functions).

    - nested functions (nested function definitions) which are not allowed neither in C nor in GLSL
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  8. #8
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,042

    Re: Nested functions, aborting!

    I was once told by someone from nVidia that C9999 errors are not supposed to happen and are considered to be compiler-errors.

    I once had one myself, and nVidia was extremely quick to take a look at it, just because I had postet the "C9999" part in the topics headline, such that someone from nVidia saw it.

    So, maybe post it in nVidias forum or something like that, maybe they ARE interested to see your particular shader.

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  9. #9
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,892

    Re: Nested functions, aborting!

    Just spent a bit going over the spec, and I don't see where nested functions are disallowed.
    From the spec:

    Quote Originally Posted by GLSL 4.1
    Recursion is not allowed, not even statically. Static recursion is present if the static function-call graph of
    a program contains cycles. This includes all potential function calls through variables declared as subroutine uniform (described below).
    I'm guessing that this is what the error meant by "nested functions."

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    989

    Re: Nested functions, aborting!

    I'm guessing that this is what the error meant by "nested functions."
    That makes sense. Anyway, you should believe much more in the MacOSX driver as there the OpenGL driver is developed by Apple and only the low level stuff is maybe provided by NVIDIA, but the GLSL compiler is definitely Apple's work. That's the difference, because NVIDIA GLSL compiler usually allows much more things than it is specified in the GL spec.

    AFAIK NVIDIA supports recursion so maybe they exposed this not only for Cg and CUDA but also for GLSL. Still if this is the case, your GLSL code is invalid.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

Posting Permissions

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