Bug 821

Summary: GL2ES2 backward compatibility broken using OpenGL 4.3.0 NVIDIA drivers
Product: [JogAmp] Jogl Reporter: Xerxes Rånby <xerxes>
Component: coreAssignee: Xerxes Rånby <xerxes>
Status: RESOLVED FIXED    
Severity: enhancement CC: alexa.gerancho, gouessej, sgothel
Priority: ---    
Version: 2   
Hardware: All   
OS: all   
Type: --- SCM Refs:
Workaround: ---
Bug Depends on: 852    
Bug Blocks:    
Attachments: hs_err_pid3060.log
sh etc/test_dbg.sh test_dbg.log
fix-bug821-commit-de2662a.patch

Description Xerxes Rånby 2013-08-29 11:11:06 CEST
Created attachment 498 [details]
hs_err_pid3060.log

JogAmp 2.0.2
System setup:
Linux Ubuntu 12.04 LTS 32bit + Nvidia 319.32 drivers
GeForce GT 610 GPU

Testcase:
wget http://jogamp.org/deployment/jogamp-current/archive/jogamp-all-platforms.7z
7z x jogamp-all-platforms.7z
cd jogamp-all-platforms
mkdir -p demos/es2
cd demos/es2
wget https://raw.github.com/xranby/jogl-demos/master/src/demos/es2/RawGL2ES2demo.java
cd ../..
javac -cp jar/jogl-all.jar:jar/gluegen-rt.jar demos/es2/RawGL2ES2demo.java
java -cp jar/jogl-all.jar:jar/gluegen-rt.jar:. demos.es2.RawGL2ES2demo

Output:
xranby@xranby-ESPRIMO-P7935:~/2.0.2/jogamp-all-platforms$ java -cp jar/jogl-all.jar:jar/gluegen-rt.jar:. demos.es2.RawGL2ES2demo
libEGL warning: DRI2: failed to authenticate
Chosen GLCapabilities: GLCaps[glx vid 0xbe, fbc 0x1a2: rgba 8/8/8/8, trans-rgba 0xff/ff/ff/ff, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono  , hw, GLProfile[GL2ES2/GL4.hw], on-scr[.]]
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce GT 610/PCIe/SSE2
GL_VERSION: 4.3.0 NVIDIA 319.32
Horray! vertex shader compiled
Horray! fragment shader compiled
Window resized to width=1853 height=1022
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0055fd36, pid=3060, tid=2303380288
#
# JRE version: 7.0_25-b30
# Java VM: OpenJDK Server VM (23.7-b01 mixed mode linux-x86 )
# Problematic frame:
# C  0x0055fd36
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/xranby/2.0.2/jogamp-all-platforms/hs_err_pid3060.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   https://bugs.launchpad.net/ubuntu/+source/openjdk-7/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Avbruten (SIGABRT) (minnesutskrift skapad)
Comment 1 Xerxes Rånby 2013-08-29 11:13:02 CEST
Created attachment 499 [details]
sh etc/test_dbg.sh test_dbg.log
Comment 2 Xerxes Rånby 2013-08-29 11:32:36 CEST
This bug have been reproduced on Windows 7 & 8 systems as well using the NVIDIA 4.3 drivers.

Windows 8
C:\jogamp-all-platforms>java -cp jar/jogl-all.jar;jar/gluegen-rt.jar;. demos.es2.RawGL2ES2demo
Chosen GLCapabilities: GLCaps[wgl vid 0x8 arb: rgba 8/8/8/8, trans-rgba 0x0/0/0/0, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, m
ono  , hw, GLProfile[GL2ES2/GL4.hw], on-scr[.]]
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce GTX 550 Ti/PCIe/SSE2
GL_VERSION: 4.3.0
Horray! vertex shader compiled
Horray! fragment shader compiled
Window resized to width=1920 height=1080
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000001d55fec2, pid=3932, tid=408
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b103) (build 1.8.0-ea-b103)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b45 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  0x000000001d55fec2
http://www.raspberrypi.org/phpBB3/viewtopic.php?p=411009#p411009

Windows 7
Chosen GLCapabilities: GLCaps[wgl vid 0x8 arb: rgba 8/8/8/8, trans-rgba 0x0/0/0/0, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono  , hw, GLProfile[GL2ES2/GL4.hw], on-scr[.]]
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
Horray! vertex shader compiled
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce GT 650M/PCIe/SSE2
GL_VERSION: 4.3.0
Horray! fragment shader compiled
Window resized to width=1920 height=1062
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00e7fd36, pid=6816, tid=4436
#
# JRE version: 7.0_25-b17
# Java VM: Java HotSpot(TM) Client VM (23.25-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C  0x00e7fd36
http://forum.jogamp.org/GLES2-on-Windows-7-RawGL2ES2demo-crashes-td4029816.html
Comment 3 Xerxes Rånby 2013-08-29 12:05:47 CEST
The code work fine if i request a GL2 profile instead of a GL2ES2 profile
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));

Note that the GL2, ok, profile selected GLProfile[GL2/GL2.hw]
while GL2ES2, broken, profile selected GLProfile[GL2ES2/GL4.hw]

Output using the GL2 profile:
xranby@xranby-ESPRIMO-P7935:~/2.0.2/jogamp-all-platforms$ java -cp jar/jogl-all.jar:jar/gluegen-rt.jar:. demos.es2.RawGL2ES2demo
libEGL warning: DRI2: failed to authenticate
Chosen GLCapabilities: GLCaps[glx vid 0xbe, fbc 0x1a2: rgba 8/8/8/8, trans-rgba 0xff/ff/ff/ff, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono  , hw, GLProfile[GL2/GL2.hw], on-scr[.]]
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce GT 610/PCIe/SSE2
GL_VERSION: 4.3.0 NVIDIA 319.32
Horray! vertex shader compiled
Horray! fragment shader compiled
Window resized to width=1853 height=1022
Window resized to width=1855 height=1056
cleanup, remember to release shaders
X11Util.Display: Shutdown (JVM shutdown: true, open (no close attempt): 2/2, reusable (open, marked uncloseable): 0, pending (open in creation order): 2)
X11Util: Open X11 Display Connections: 2
X11Util: Open[0]: NamedX11Display[:0, 0xffffffff86d6de00, refCount 1, unCloseable false]
X11Util: Open[1]: NamedX11Display[:0, 0xffffffff86d53870, refCount 1, unCloseable false]
xranby@xranby-ESPRIMO-P7935:~/2.0.2/jogamp-all-platforms$
Comment 4 Xerxes Rånby 2013-08-29 12:15:56 CEST
More testing using different profiles:

GL3 profile also triggers the bug: (expected since it is not supposed to be backward compatible)
What is still unexpected is the native crash, i would have expected this to be handled by an exception.
xranby@xranby-ESPRIMO-P7935:~/2.0.2/jogamp-all-platforms$ java -cp jar/jogl-all.jar:jar/gluegen-rt.jar:. demos.es2.RawGL2ES2demo
libEGL warning: DRI2: failed to authenticate
Chosen GLCapabilities: GLCaps[glx vid 0xbe, fbc 0x1a2: rgba 8/8/8/8, trans-rgba 0xff/ff/ff/ff, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono  , hw, GLProfile[GL3/GL3.hw], on-scr[.]]
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce GT 610/PCIe/SSE2
GL_VERSION: 4.3.0 NVIDIA 319.32
Horray! vertex shader compiled
Horray! fragment shader compiled
Window resized to width=1853 height=1022
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x004e8d36, pid=6818, tid=2303380288
#
# JRE version: 7.0_25-b30
# Java VM: OpenJDK Server VM (23.7-b01 mixed mode linux-x86 )
# Problematic frame:
# C  0x004e8d36


GL3bc profile work ok:
Chosen GLCapabilities: GLCaps[glx vid 0xbe, fbc 0x1a2: rgba 8/8/8/8, trans-rgba 0xff/ff/ff/ff, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono  , hw, GLProfile[GL3bc/GL3bc.hw], on-scr[.]]
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce GT 610/PCIe/SSE2
GL_VERSION: 4.3.0 NVIDIA 319.32
Horray! vertex shader compiled


GL4 profile also triggers the bug: (expected since it is not supposed to be backward compatible)
What is still unexpected is the native crash, i would have expected this to be handled by an exception.
xranby@xranby-ESPRIMO-P7935:~/2.0.2/jogamp-all-platforms$ java -cp jar/jogl-all.jar:jar/gluegen-rt.jar:. demos.es2.RawGL2ES2demo
libEGL warning: DRI2: failed to authenticate
Chosen GLCapabilities: GLCaps[glx vid 0xbe, fbc 0x1a2: rgba 8/8/8/8, trans-rgba 0xff/ff/ff/ff, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono  , hw, GLProfile[GL4/GL4.hw], on-scr[.]]
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce GT 610/PCIe/SSE2
GL_VERSION: 4.3.0 NVIDIA 319.32
Horray! vertex shader compiled
Horray! fragment shader compiled
Window resized to width=1855 height=1056
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x006add36, pid=7126, tid=2303380288
#
# JRE version: 7.0_25-b30
# Java VM: OpenJDK Server VM (23.7-b01 mixed mode linux-x86 )
# Problematic frame:
# C  0x006add36



GL4bc profile work ok:
Chosen GLCapabilities: GLCaps[glx vid 0xbe, fbc 0x1a2: rgba 8/8/8/8, trans-rgba 0xff/ff/ff/ff, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono  , hw, GLProfile[GL4bc/GL4bc.hw], on-scr[.]]
INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce GT 610/PCIe/SSE2
GL_VERSION: 4.3.0 NVIDIA 319.32
Horray! vertex shader compiled
Horray! fragment shader compiled
Window resized to width=1853 height=1022
Window resized to width=1855 height=1056
Window resized to width=1920 height=1080
cleanup, remember to release shaders
Comment 5 Xerxes Rånby 2013-08-29 12:19:52 CEST
Summary:
GL2ES2 profile should use GLProfile[GL2ES2/GL4bc.hw] instead of GLProfile[GL2ES2/GL4.hw]
in order to fix this bug.

Exceptions needs to be raised to handle situations when backward compatible functionality is used on non backward compatible contexts.
Comment 6 Xerxes Rånby 2013-08-29 15:41:35 CEST
https://github.com/xranby/jogl/commit/de2662aaf4c3f6ac3a8c7fba70d62a809f2bca50
Fix Bug 821: GLProfile: computeProfileImpl GL4 & GL3 impl not valid for GL2ES2 profile.
    
    Signed-off-by: Xerxes Rånby <xerxes@zafena.se>

Please test and merge:

Test results using 
Linux Ubuntu 12.04 LTS 32bit + Nvidia 319.32 drivers
GeForce GT 610 GPU

-Djogl.debug.GLProfile=true

Before patch:
	Native
		GL4bc	true [4.3 (Compat profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GL4	true [4.3 (Core profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GLES3	false
		GL3bc	true [4.3 (Compat profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GL3	true [4.3 (Core profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GL2	true [4.3 (Compat profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GLES2	false
		GLES1	true [1.0 (ES profile, FP32 compat-api, software)]
		GL4ES3	true
		GL2ES2	true
		GL2ES1	true
	Profiles
		GLProfile[GL2ES2/GL4.hw]
		GLProfile[GL2ES1/GL4bc.hw]
		GLProfile[GL2/GL2.hw]
		GLProfile[GL4/GL4.hw]
		GLProfile[GL3/GL3.hw]
		GLProfile[GL4bc/GL4bc.hw]
		GLProfile[GL4bc/GL4bc.hw]
		GLProfile[GLES1/GLES1.sw]
		GLProfile[GL4ES3/GL4.hw]
		GLProfile[GL2GL3/GL4bc.hw]
		GLProfile[GL3bc/GL3bc.hw]
		default GLProfile[GL4bc/GL4bc.hw]



After patch:
	Native
		GL4bc	true [4.3 (Compat profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GL4	true [4.3 (Core profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GLES3	false
		GL3bc	true [4.3 (Compat profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GL3	true [4.3 (Core profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GL2	true [4.3 (Compat profile, arb, ES2 compat, ES3 compat, FBO, hardware)]
		GLES2	false
		GLES1	true [1.0 (ES profile, FP32 compat-api, software)]
		GL4ES3	true
		GL2ES2	true
		GL2ES1	true
	Profiles
		GLProfile[GL2ES2/GL4bc.hw]
		GLProfile[GL2ES1/GL4bc.hw]
		GLProfile[GL2/GL2.hw]
		GLProfile[GL4/GL4.hw]
		GLProfile[GL3/GL3.hw]
		GLProfile[GL4bc/GL4bc.hw]
		GLProfile[GL4bc/GL4bc.hw]
		GLProfile[GLES1/GLES1.sw]
		GLProfile[GL4ES3/GL4.hw]
		GLProfile[GL2GL3/GL4bc.hw]
		GLProfile[GL3bc/GL3bc.hw]
		default GLProfile[GL4bc/GL4bc.hw]
Comment 7 Xerxes Rånby 2013-08-29 15:57:09 CEST
Created attachment 500 [details]
fix-bug821-commit-de2662a.patch
Comment 8 Xerxes Rånby 2013-08-29 16:22:38 CEST
(In reply to comment #7)
> Created attachment 500 [details]
> fix-bug821-commit-de2662a.patch

If we apply this patch then we may need to add one OSX exception again:
Please consider the commit:
http://jogamp.org/git/?p=jogl.git;a=commit;h=46d370f8cc4b67440872c4cff9f0ee1c47298652
While reviewing the fix-bug821-commit-de2662a.patch .
Comment 9 Sven Gothel 2013-08-29 21:37:17 CEST
(In reply to comment #8)
> (In reply to comment #7)
> > Created attachment 500 [details]
> > fix-bug821-commit-de2662a.patch
> 
> If we apply this patch then we may need to add one OSX exception again:
> Please consider the commit:
> http://jogamp.org/git/?p=jogl.git;a=commit;
> h=46d370f8cc4b67440872c4cff9f0ee1c47298652
> While reviewing the fix-bug821-commit-de2662a.patch .

it's actually not just an 'OSX' exception, 
but pushing code - especially 'core profile' code into correctness.

The problem w/ the demo code is that it does not use a VBO buffer (AFAIK),
and this is illegal for core profiles - at least starting w/ GL4/ES3.

Following 'runs everywhere' philosophy requires users to to patch their 
code, so it runs on most core profiles.

The 'real' bug here is IMHO the lack of handling this case in our code,
i.e. throwing an exception that no VBO was used on an VBO only context.

Hope it makes sense ..
Comment 10 Sven Gothel 2013-08-29 21:38:03 CEST
(In reply to comment #9)
> The problem w/ the demo code is that it does not use a VBO buffer (AFAIK),
> and this is illegal for core profiles - at least starting w/ GL4/ES3.

-> GL3/ES3 core profile, that is.
Comment 11 Xerxes Rånby 2013-08-30 10:03:57 CEST
OK i understand, according to the JogAmp JOGL spec the code is correct:
"GL2ES2 The intersection of the desktop GL3, GL2 and embedded ES2 profile"
https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GLProfile.html#GL2ES2

Its the intersection of GL3 makes GL2ES2 only guarantee to work with core functionality/use; and this removes the backward compatibility assumption that the demo code relied on.


The naming GL2ES2 may be confusing for new users, like myself, who expect it to only include the intersection of GL2 and ES2, like i was assuming when writing the demo code.

I will update the demo code to stay compatible with the current JogAmp JOGL spec.
Comment 12 Xerxes Rånby 2013-08-30 16:57:10 CEST
https://github.com/xranby/jogl-demos/commit/84a886cf4957e8f55af39abf8e9bad04a1de2e4f
Fix bug 821: RawGL2ES2demo: Use VBO buffers and update shaders to stay GL3/ES3 core profile compatible.

Signed-off-by: Xerxes Rånby <xerxes@zafena.se>
Comment 13 Sven Gothel 2013-08-31 11:39:16 CEST
(In reply to comment #12)
> https://github.com/xranby/jogl-demos/commit/
> 84a886cf4957e8f55af39abf8e9bad04a1de2e4f
> Fix bug 821: RawGL2ES2demo: Use VBO buffers and update shaders to stay
> GL3/ES3 core profile compatible.
> 
> Signed-off-by: Xerxes Rånby <xerxes@zafena.se>

thank you, merged
Comment 14 Sven Gothel 2013-08-31 11:43:17 CEST
(In reply to comment #11)
> OK i understand, according to the JogAmp JOGL spec the code is correct:
> "GL2ES2 The intersection of the desktop GL3, GL2 and embedded ES2 profile"
> https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/
> opengl/GLProfile.html#GL2ES2
> 
> Its the intersection of GL3 makes GL2ES2 only guarantee to work with core
> functionality/use; and this removes the backward compatibility assumption
> that the demo code relied on.
> 
> 
> The naming GL2ES2 may be confusing for new users, like myself, who expect it
> to only include the intersection of GL2 and ES2, like i was assuming when
> writing the demo code.

Me too .. i.e. awareness of VBO only since GL 3.1 core was earned 
only a few month ago.

Enhancements:

A) Throw exception if using a 'pointer/array' method w/o VBO and core profile!

B) Remove the array/buffer variant from all core GL profiles,
     i.e. only provide the VBO offset ones.

(A) is easy to do ..
(B) will be a good API change .. which we can add for 2.1 (next version/release)

?
Comment 15 Xerxes Rånby 2013-09-02 10:43:23 CEST
https://github.com/xranby/jogl-demos/commit/594cba9b34faf0ef2f0f7bf7801c2b228984b02a
Fix bug 821: RawGL2ES2demo: Explicit add #version 130 for GL3 core & release VBO using glDeleteBuffers.

Signed-off-by: Xerxes Rånby <xerxes@zafena.se>


This commit adds support for AMD OpenGL 3 & 4 drivers that have deprecated the implicit GLSL version 1.1. Explicit add #version 130 to the shaders if gl.isGL3core()

Release of VBO prevents running out of GPU memory using the NVIDIA Tegra 2 drivers.
Comment 16 Xerxes Rånby 2013-09-02 11:27:16 CEST
(In reply to comment #14)
> (In reply to comment #11)
> > The naming GL2ES2 may be confusing for new users, like myself, who expect it
> > to only include the intersection of GL2 and ES2, like i was assuming when
> > writing the demo code.
> 
> Me too .. i.e. awareness of VBO only since GL 3.1 core was earned 
> only a few month ago.
> 
> Enhancements:
> 
> A) Throw exception if using a 'pointer/array' method w/o VBO and core
> profile!
> 
> B) Remove the array/buffer variant from all core GL profiles,
>      i.e. only provide the VBO offset ones.
> 
> (A) is easy to do ..
> (B) will be a good API change .. which we can add for 2.1 (next
> version/release)
> 
> ?

I agree A and especially B is good enhancements, makes the API clear and forward compatible. B guarantees that applications stay inside the GL2ES2 spec using compile time checks.
Comment 17 Julien Gouesse 2013-10-01 10:59:48 CEST
(In reply to comment #16)
> (In reply to comment #14)
> > (In reply to comment #11)
> > > The naming GL2ES2 may be confusing for new users, like myself, who expect it
> > > to only include the intersection of GL2 and ES2, like i was assuming when
> > > writing the demo code.
> > 
> > Me too .. i.e. awareness of VBO only since GL 3.1 core was earned 
> > only a few month ago.
> > 
> > Enhancements:
> > 
> > A) Throw exception if using a 'pointer/array' method w/o VBO and core
> > profile!
> > 
> > B) Remove the array/buffer variant from all core GL profiles,
> >      i.e. only provide the VBO offset ones.
> > 
> > (A) is easy to do ..
> > (B) will be a good API change .. which we can add for 2.1 (next
> > version/release)
> > 
> > ?
> 
> I agree A and especially B is good enhancements, makes the API clear and
> forward compatible. B guarantees that applications stay inside the GL2ES2
> spec using compile time checks.

Please don't prevent me from using hardware that doesn't support VBOs. I hope that those variants will still be available in the backward compatible profiles.
Comment 18 Sven Gothel 2013-10-09 22:09:33 CEST
> 
> Please don't prevent me from using hardware that doesn't support VBOs. I
> hope that those variants will still be available in the backward compatible
> profiles.

Of course, no intention to remove existing functionality.

I will create a new bug report to tackle this issue properly
w/ reference to the spec.
Comment 19 Sven Gothel 2013-10-09 23:20:29 CEST
Bug 852 tackles the API issue and it's runtime validation.
Comment 20 Alexa 2014-02-03 02:53:59 CET
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen live from the domain http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.