jmonkeyengine icon indicating copy to clipboard operation
jmonkeyengine copied to clipboard

OpenGLException in TestToneMapFilter

Open stephengold opened this issue 3 years ago • 14 comments

While running TestToneMapFilter in jme3-examples, press the spacebar twice:

May 13, 2021 2:28:56 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.4.0-SNAPSHOT
 * Branch: v3.4
 * Git Hash: bdf15ba
 * Build Date: 2021-05-13
May 13, 2021 2:28:57 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: null
 * Driver Version: null
 * Scaling Factor: 1
May 13, 2021 2:28:57 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GT 545/PCIe/SSE2
 * OpenGL Version: 4.6.0 NVIDIA 390.143
 * GLSL Version: 4.60 NVIDIA
 * Profile: Compatibility
May 13, 2021 2:28:57 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
May 13, 2021 2:28:57 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
May 13, 2021 2:28:57 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
May 13, 2021 2:28:57 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4
== Tone Mapping Sample ==
 SPACE:	Toggle tone-mapping OFF or ON
 Y:	Increase white-point
 H:	Decrease white-point
May 13, 2021 2:28:58 PM com.jme3.material.Material checkTextureParamColorSpace
WARNING: The texture Textures/HdrTest/Memorial.hdr has linear color space, but the material parameter ColorMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Tone Mapping OFF
Tone Mapping ON
May 13, 2021 2:29:00 PM com.jme3.app.LegacyApplication handleError
SEVERE: An OpenGL error has occurred!
org.lwjgl.opengl.OpenGLException: Invalid operation (1282)
	at org.lwjgl.opengl.Util.checkGLError(Util.java:59)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.checkGLError(LwjglAbstractDisplay.java:145)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:166)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:201)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:242)
	at java.lang.Thread.run(Thread.java:748)

After enabling graphics debug:

Tone Mapping OFF
Tone Mapping ON
[JME3] OpenGL debug message
       ID: 1282
       Source: API
       Type: ERROR
       Severity: HIGH
       Message: GL_INVALID_OPERATION error generated. Render buffer not bound.
java.lang.Exception: Stack trace
	at java.lang.Thread.dumpStack(Thread.java:1336)
	at com.jme3.system.lwjgl.LwjglGLDebugOutputHandler.handleMessage(LwjglGLDebugOutputHandler.java:76)
	at org.lwjgl.opengl.GL30.nglRenderbufferStorage(Native Method)
	at org.lwjgl.opengl.GL30.glRenderbufferStorage(GL30.java:1079)
	at com.jme3.renderer.lwjgl.LwjglGLFboGL3.glRenderbufferStorageEXT(LwjglGLFboGL3.java:94)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.jme3.renderer.opengl.GLDebug.invoke(GLDebug.java:107)
	at com.sun.proxy.$Proxy2.glRenderbufferStorageEXT(Unknown Source)
	at com.jme3.renderer.opengl.GLRenderer.updateRenderBuffer(GLRenderer.java:1812)
	at com.jme3.renderer.opengl.GLRenderer.updateFrameBufferAttachment(GLRenderer.java:1869)
	at com.jme3.renderer.opengl.GLRenderer.updateFrameBuffer(GLRenderer.java:1922)
	at com.jme3.renderer.opengl.GLRenderer.setFrameBuffer(GLRenderer.java:2076)
	at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1102)
	at com.jme3.renderer.RenderManager.render(RenderManager.java:1180)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:273)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:160)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:201)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:242)
	at java.lang.Thread.run(Thread.java:748)
May 13, 2021 2:30:58 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.renderer.RendererException: An OpenGL error occurred - Invalid operation (Error Code: 1282)
	at com.jme3.renderer.opengl.GLDebug.checkError(GLDebug.java:101)
	at com.jme3.renderer.opengl.GLDebug.invoke(GLDebug.java:113)
	at com.sun.proxy.$Proxy2.glRenderbufferStorageEXT(Unknown Source)
	at com.jme3.renderer.opengl.GLRenderer.updateRenderBuffer(GLRenderer.java:1812)
	at com.jme3.renderer.opengl.GLRenderer.updateFrameBufferAttachment(GLRenderer.java:1869)
	at com.jme3.renderer.opengl.GLRenderer.updateFrameBuffer(GLRenderer.java:1922)
	at com.jme3.renderer.opengl.GLRenderer.setFrameBuffer(GLRenderer.java:2076)
	at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1102)
	at com.jme3.renderer.RenderManager.render(RenderManager.java:1180)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:273)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:160)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:201)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:242)
	at java.lang.Thread.run(Thread.java:748)

stephengold avatar May 13 '21 21:05 stephengold

This issue has been present since at least v3.1.0-stable, so it's not a recent regression.

stephengold avatar May 14 '21 06:05 stephengold

Thanks, Riccardo!

stephengold avatar May 17 '21 16:05 stephengold

I am testing this with the master branch, can't reproduce. Is this happening also with lwjgl3?

If you are still able to reproduce it, can you try change lines 1787-1790 in GLRenderer.java from

        if (context.boundRB != id) {
            glfbo.glBindRenderbufferEXT(GLFbo.GL_RENDERBUFFER_EXT, id);
            context.boundRB = id;
        }

to

        //if (context.boundRB != id) {
            glfbo.glBindRenderbufferEXT(GLFbo.GL_RENDERBUFFER_EXT, id);
            context.boundRB = id;
        //}

causing the framebuffer to be rebound every call, in case we are dealing with some sort of driver issue that unbounds the framebuffer...

riccardobl avatar May 25 '21 13:05 riccardobl

Thank you for your investigations so far. I just now reproduced the issue in the latest "master" branch, but only with LWJGL v2. With LWJGL v3, I failed to reproduce the issue. I tried commenting out the id test per your suggestion, in "master" with LWJGL v2, and this resolved the issue.

stephengold avatar May 25 '21 15:05 stephengold

Mhh, what is the value of fbOnLoad in GLRenderer line 637 ?

riccardobl avatar May 26 '21 13:05 riccardobl

In the "v3.4" branch with LWJGL v2, it's 0.

stephengold avatar May 26 '21 19:05 stephengold

If you're convinced this is a driver bug with no obvious workaround, then let's close this issue.

stephengold avatar May 27 '21 20:05 stephengold

I am not entirely sure, i'd like to investigate it some more

riccardobl avatar May 30 '21 17:05 riccardobl

Okay. Let me know if I can assist in any way.

stephengold avatar May 30 '21 19:05 stephengold

I reproduced the crash on different hardware (GeForce RTX 2070), running Windows 10, so apparently it's not driver-specific. I'm still seeing the crash only with LWJGL 2.9.3, not with LWJGL 3.

stephengold avatar Dec 02 '21 22:12 stephengold

I can not reproduce the crash. I am testing on Linux with LWJGL 2 and Mesa graphics driver.

> Task :jme3-examples:TestToneMapFilter.main()
Feb 09, 2023 11:57:42 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.7.0-SNAPSHOT
 * Branch: master
 * Git Hash: aaabd10
 * Build Date: 2023-02-09
Feb 09, 2023 11:57:44 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main
 * Graphics Adapter: null
 * Driver Version: null
 * Scaling Factor: 1
Feb 09, 2023 11:57:44 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: X.Org
 * Renderer: AMD CEDAR (DRM 2.50.0 / 5.4.0-58-generic, LLVM 10.0.0)
 * OpenGL Version: 3.3 (Core Profile) Mesa 20.0.8
 * GLSL Version: 3.30
 * Profile: Core
Feb 09, 2023 11:57:44 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Feb 09, 2023 11:57:44 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
Feb 09, 2023 11:57:44 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Feb 09, 2023 11:57:44 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4
== Tone Mapping Sample ==
 SPACE:	Toggle tone-mapping OFF or ON
 Y:	Increase white-point
 H:	Decrease white-point
Feb 09, 2023 11:57:46 AM com.jme3.material.Material checkTextureParamColorSpace
WARNING: The texture Textures/HdrTest/Memorial.hdr has linear color space, but the material parameter ColorMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Tone Mapping OFF
Tone Mapping ON

Ali-RS avatar Feb 09 '23 08:02 Ali-RS

Because of the following code https://github.com/jMonkeyEngine/jmonkeyengine/blob/aaabd104771019e1a627696a98f5de5794c3c4cc/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglAbstractDisplay.java#L166

assertions must be enabled in order to reproduce this crash.

@Ali-RS Please check whether assertions are enabled in your test environment.

stephengold avatar Feb 10 '23 17:02 stephengold

I'm still able to reproduce this issue in "master" branch. With Linux, LWJGL v2.9.5, NVIDIA GeForce graphics, and Core 3.2 profile:

Feb 10, 2023 9:34:03 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.7.0-SNAPSHOT
 * Branch: master
 * Git Hash: aaabd10
 * Build Date: 2023-02-10
Feb 10, 2023 9:34:04 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main
 * Graphics Adapter: null
 * Driver Version: null
 * Scaling Factor: 1
Feb 10, 2023 9:34:04 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GT 545/PCIe/SSE2
 * OpenGL Version: 3.2.0 NVIDIA 390.157
 * GLSL Version: 1.50 NVIDIA via Cg compiler
 * Profile: Core
Feb 10, 2023 9:34:04 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Feb 10, 2023 9:34:04 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
Feb 10, 2023 9:34:04 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Feb 10, 2023 9:34:04 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4
== Tone Mapping Sample ==
 SPACE:	Toggle tone-mapping OFF or ON
 Y:	Increase white-point
 H:	Decrease white-point
Feb 10, 2023 9:34:04 AM com.jme3.material.Material checkTextureParamColorSpace
WARNING: The texture Textures/HdrTest/Memorial.hdr has linear color space, but the material parameter ColorMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Tone Mapping OFF
Tone Mapping ON
Feb 10, 2023 9:34:07 AM com.jme3.app.LegacyApplication handleError
SEVERE: An OpenGL error has occurred!
org.lwjgl.opengl.OpenGLException: Invalid operation (1282)
	at org.lwjgl.opengl.Util.checkGLError(Util.java:59)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.checkGLError(LwjglAbstractDisplay.java:145)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:166)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:224)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:242)
	at java.base/java.lang.Thread.run(Thread.java:833)

I also reproduced it with Compatibility profile.

To enable assertions, I added the following code to jme3-examples/build.gradle:

tasks.withType(JavaExec) { // Java runtime options:
    enableAssertions true
}

stephengold avatar Feb 10 '23 17:02 stephengold

Even with assertions enabled, I can not reproduce the crash.

Ali-RS avatar Feb 10 '23 18:02 Ali-RS