MantisBT - VTK
View Issue Details
0010716VTK(No Category)public2010-05-14 15:222016-08-12 09:55
François Bertel 
Kitware Robot 
normalminoralways
closedmoved 
 
 
0010716: GPU ray cast volume mapper does not work on Snow Leopard
any the the GPURayCast* tests exit with:

(0) : fatal error C9999: Nested functions, aborting!
Cg compiler terminated due to fatal error
No tags attached.
txt mac_output.txt (7,683) 2010-05-14 16:09
https://www.vtk.org/Bug/file/8116/mac_output.txt
txt linux_output.txt (36,156) 2010-05-14 16:09
https://www.vtk.org/Bug/file/8117/linux_output.txt
txt windows_output.txt (44,989) 2010-05-14 16:10
https://www.vtk.org/Bug/file/8118/windows_output.txt
Issue History
2010-05-14 15:22François BertelNew Issue
2010-05-14 15:23François BertelStatusbacklog => tabled
2010-05-14 15:23François BertelAssigned To => François Bertel
2010-05-14 15:42François BertelNote Added: 0020744
2010-05-14 16:09François BertelNote Added: 0020745
2010-05-14 16:09François BertelFile Added: mac_output.txt
2010-05-14 16:09François BertelFile Added: linux_output.txt
2010-05-14 16:10François BertelFile Added: windows_output.txt
2010-06-16 14:33François BertelNote Added: 0021031
2010-06-18 10:19François BertelNote Added: 0021088
2010-06-22 13:17François BertelNote Added: 0021124
2010-07-12 12:05François BertelNote Added: 0021357
2010-08-06 10:34François BertelNote Added: 0021688
2010-08-19 10:05François BertelNote Added: 0021843
2010-08-19 12:22François BertelNote Added: 0021848
2010-09-07 13:43François BertelAssigned ToFrançois Bertel =>
2011-06-16 13:11Zack GalbreathCategory => (No Category)
2012-10-20 00:06Julien FinetNote Added: 0029462
2016-08-12 09:55Kitware RobotNote Added: 0037173
2016-08-12 09:55Kitware RobotStatusexpired => closed
2016-08-12 09:55Kitware RobotResolutionopen => moved
2016-08-12 09:55Kitware RobotAssigned To => Kitware Robot

Notes
(0020744)
François Bertel   
2010-05-14 15:42   
reporting a bug at http://developer.apple.com/bugreporter/ [^]
(0020745)
François Bertel   
2010-05-14 16:09   
Apple bug 7986198.

The bug reports is:
Title: Validation stage of GLSL program broken
product: Mac OS X
Classification: Serious Bug

14-May-2010 04:06 PM Francois Bertel:
Hello,

Summary:

VTK (The visualization tookit) is an open-source (BSD license) C++ library
for scientific and medical visualization.
It allows to do volume rendering, notably with the help of the GPU through OpenGL/GLSL.
The class doing this work in vtkOpenGLGPUVolumeRayCastMapper (and
its superclass vtkGPUVolumeRayCastMapper)

It works with no error on Windows and Linux with an nVidia graphics card.
It does not work on Mac OS X Snow Leopard with an nVidia card (see Notes section for details).

On Mac, the graphics driver exits (!!) the test program with:
(0) : fatal error C9999: Nested functions, aborting!
Cg compiler terminated due to fatal error

Steps to Reproduce:

Here are the step to reproduce the graphics driver bug:
1. Download and install cmake 2.8.1
2. Download the development version of VTK and VTKData with git
3. Build vtk
4. Try the test program
5. change some line of code in VTK/VolumeRendering/vtkOpenGLGPURayCastMapper.cxx
6. go back to step 3.




Details steps:

In order the run the test:

DOWNLOAD

1. Download and install cmake 2.8.1 from http://cmake.org/cmake/resources/software.html [^] or directly here: http://www.cmake.org/files/v2.8/cmake-2.8.1-Darwin-universal.dmg [^]
2. download the development version of VTK from the central git repository with:

$ git clone git://vtk.org/VTK.git [^] VTK

or, if you have firewall issue, through the less efficient http protocol:

$ git clone http://vtk.org/VTK.git [^] VTK

(additional help here: http://www.vtk.org/Wiki/VTK/Git [^])
3. download VTKData from the central git repository with:

$ git clone [git://vtk.org/VTKData.git [^] or http://vtk.org/VTKData.git [^]]

BUILD VTK
4. create a build directory "vtk-build" (not in the source tree)
5. run cmake-gui
6. select the "where to build the binaries" to be the path to vtk-build
7. select the "where is the source code" to be the path the the VTK source tree
8. click "configure" at the bottom
9. select generator "Unix Makefiles" and click "Done"
10. once cmake is done with the configuration stage, check BUILD_SHARED_LIBS, and type Debug for the CMAKE_BUILD_TYPE.
11. click "configure" again.
12. click "configure" again (or until the generate bottom is not ghosted anymore)
10. once cmake is done with the configuration stage, click "Generate"
11. once cmake is done with the generation stage, close the gui
12. in vtk-build, type "make -j3"

RUN THE TEST

1. from the build directory vtk-build, type

$ ctest -R TestGPURayCastAdditive -V

without any change the test passes because of #ifdef __APPLE__ in the source code.


2. replace #ifdef __APPLE__ by #if 0 at line 2143 of VTK/VolumeRendering/vtkOpenGLGPURayCastMapper.cxx and rebuild

the test now exits badly with:

(0) : fatal error C9999: Nested functions, aborting!
Cg compiler terminated due to fatal error


3. uncomment #define APPLE_SNOW_LEOPARD_BUG at line 93 to have some verbose output and rebuild

the test now exits badly in a more verbose way with the attached log.

For comparison purpose, I attached the ouput I get on Windows and Linux when #define APPLE_SNOW_LEOPARD_BUG is activated.



Expected Results:

An image of a volume rendered dataset with a passing test.

Actual Results:

the graphics driver exits the test program with:
(0) : fatal error C9999: Nested functions, aborting!
Cg compiler terminated due to fatal error

Regression:

Notes:

Notably it works on a laptop Dell Precision M6300M with a nVidia Quadro 3600M, 512MB
either on Windows Vista SP1 x64 (with nVidia driver 190.00) or Ubuntu x86_64 10.04 (with nVidia driver 195.36.15)


It does not work (among others) on Apple Mac Book Pro 15" with nVidia GeForce 9400M, GeForce 9600M GT, 512 MB.
This is Snow Leopard 10.6.3 build 10D573, with Xcode 3.2.2.

I nailed the driver failure to the first call of glBegin(),
basically when the driver is supposed to see if the shader program is valid
. The shader program compiles and links successfully.

My guess is the driver is confused because some texture objects can be used later one in an FBO (framebuffer object).

Comment about the code in VTK/VolumeRendering/vtkOpenGLGPURayCastMapper.cxx:

The program and uniform variables are all set at the end of
vtkOpenGLGPUVolumeRayCastMapper::RenderSubVolume()

with a call to this->Program->SendUniforms();

The actual OpenGL drawing happens right after in vtkOpenGLGPUVolumeRayCastMapper::RenderClippedBoundingBox()

with a call to:
glBegin( GL_TRIANGLE_FAN );

The call to glBegin() trigger the following error only on Mac Snow Leopard:

(0) : fatal error C9999: Nested functions, aborting!
Cg compiler terminated due to fatal error

The driver actually exits (!!) the application.


The code has been enhanced to track down the bug when APPLE_SNOW_LEOPARD_BUG is defined.

I narrowed down the cause of the crash to the following lines:

You can see that around line 4301 there is a first call to validate that does not crash (isValid0)
(even if the result of the validation failed, which is fine). see the log section betwen "BEFORE isValid0" and "AFTER isValid0".

Several lines after setting some texture objects and texture units, another validation stage is forced
but this one make the driver fails around line 4328.

the section "BEFORE isValid1" does not have a change to end with "AFTER isValid1" because the driver fails.


Regards.



14-May-2010 04:07 PM Francois Bertel:
'windows_output.txt' was successfully uploaded
(0021031)
François Bertel   
2010-06-16 14:33   
There is a typo in the bug report: where ever there is vtkOpenGLGPURayCastMapper, you should read
vtkOpenGLGPUVolumeRayCastMapper.
(0021088)
François Bertel   
2010-06-18 10:19   
The update to Snow Leopard 10.6.4 did not fix the bug.
(0021124)
François Bertel   
2010-06-22 13:17   
Apparently, 10.6.4 has graphics performance regression issues.

http://www.macrumors.com/2010/06/21/valve-warns-of-gaming-performance-issues-with-nvidia-graphics-cards-on-mac-os-x-10-6-4/ [^]
(0021357)
François Bertel   
2010-07-12 12:05   
Still no feedback from Apple
(0021688)
François Bertel   
2010-08-06 10:34   
Notified Apple that bug 8204106 reported by James Barabas from MIT is probably the root of the problem.

James used OpenGL Shader Builder (coming with XCode) for quickly testing the shaders.

Here is the contents of bug 8204106

////////////////////////////////Apple Bug Report Text


Summary:
Shader programs can cause application termination.

Steps to Reproduce:

Create two new text files, File1.fs and File2.fs with the contents below
Use OpenGL Shader Builder to create a shader program containing these two files
Click on Render tab to attempt to run shaders


//////////////////////////////////File1.fs
vec4 f2(vec4 value2)
{
 return value2;
}

vec4 shade(vec4 value1)
{
 return f2(value1);
}

//////////////////////////File2.fs
void main()
{
if(gl_FragCoord.x < 0.5)
 {
   discard;
 }
 gl_FragColor = vec4(0.0,0.0,0.0,1.0);
}


Expected Results:
Shader runs and creates an image

Actual Results:
OpenGL Shader Builder crashes. Console reports:

7/17/10 7:22:57 PM [0x0-0x2e82e8].com.apple.ShaderBuilder[12570] (0) :
fatal error C9999: Function does not end at the end of the
representation
7/17/10 7:22:57 PM [0x0-0x2e82e8].com.apple.ShaderBuilder[12570] Cg
compiler terminated due to fatal error
7/17/10 7:22:57
PM com.apple.launchd.peruser.501[832] ([0x0-0x2e82e8].com.apple.ShaderBuilder[12570])
Exited with exit code: 15

Regression:
Appears to be interaction between the use of discard, and the two
nested functions in the second file. Removal of discard statement
prevents crash. Removal of File1.fs prevents crash. Crash still occurs
if functions from file1 are called inside main(). Crash was regressed
from larger shader crash in Slicer's VTK volume renderer, which
crashes that application. In regressing, some related crashes report:
Fatal error C9999: Nested functions, aborting! Cg compiler terminated
due to fatal error

Notes:
Crash does not appear to terminate application when forcing use of
intel graphics on Macbook Pro.
(0021843)
François Bertel   
2010-08-19 10:05   
First time Apple even answers the bug report on August 18 2010, to ask about a full System Profiler Report.

Note: the full report can be created with the GUI:

1. Launch the System Profiler application ("About This Mac"->"More Info").
2. View > Full Profile->Save
3. Keep the format as 'System Profile'->Save

or with the command line:
$ /usr/sbin/system_profiler -detailLevel full -xml >myreport.spx
(0021848)
François Bertel   
2010-08-19 12:22   
Even after the Snow Leopard Graphics Update, the bug is still there.

http://support.apple.com/kb/HT4286 [^]
(0029462)
Julien Finet   
2012-10-20 00:06   
Now works with the following configuration:
 GL_VENDOR = NVIDIA Corporation
 GL_VERSION = 2.1 NVIDIA-8.0.61
 SHADING_LANGUAGE_VERSION = 1.20
(0037173)
Kitware Robot   
2016-08-12 09:55   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.