SOLVED - LWJGL <--> Renderdoc - No context...

Started by bmcclint, March 31, 2024, 17:05:27

Previous topic - Next topic

bmcclint

All,

This is my first post and a stab in the dark while I attempt to debug whats going on.  If this is better in the OpenGL topic OR on the RenderDoc platform please let me know.

OK...I am attempting to debug an existing application I've been tinkering with for years now in RenderDoc as I am trying to see whats going on in several of the off screen textures I am rendering to.  The application is using LWGJL 3.3.3-snapshot(also tried 3.3.2-snapshot) and Java 17.  Its a Gradle project and I am currently working on a Ubuntu install.  The project works, builds, runs and the like.  I can command line execute the jar or debug via an IDE and life is grand.  So I seem to think the java application is correct.  Note...I hooked up a C++ GLFW/Cmake variant the RenderDoc runs that code.

When attempting to run via RenderDoc, with the JVM path set, working folder and command line args, RenderDoc does seem to start my application.  I see the window appear, the console where RenderDoc loads is showing the log output, OpenGL version, OpenAL, etc (see below)...then when the scene loads and attempts to compile its first shader it throws an exception and aborts.  Error is...

FATAL ERROR in native method: Thread[main,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
   at org.lwjgl.opengl.ARBShaderObjects.glCreateShaderObjectARB(Native Method)
   at com.bbs.platform.desktop.drivers.OpenGLDriver.glCreateShader(OpenGLDriver.java:492)
   at com.bbs.engine.graphics.opengl.GLSL.CompileShader(GLSL.java:140)
   at com.bbs.engine.graphics.opengl.GLSL.CompileVertexShader(GLSL.java:122)
   at com.bbs.engine.shader.ShaderProgram.CompileVertexShaders(ShaderProgram.java:162)
   at com.bbs.engine.asset.shader.DiffusePhong.Compile(DiffusePhong.java:25)
...

...it seems that the OpenGL context is either gone, on another thread or RenderDoc just cannot access it.  From the first parts of the log, LWJGL is detected, versions captured and OpenGL contexts seem to be in play.  As stated, when running in RenderDoc I see the window and the title appear, stay up for a second or so then close.  I assume that's the stack dump process casing the delay.

Question...Anyone know what might be wrong?  Do I need an addl JVM switch?  Different version?  I will strip down to a boiler plate example project but that's going to take some time as it appears to 'find' OpenGL and query strings, versions, the shader is where we fail, so I will need to build a skeleton and keep addling the layers till we get to the stopping point.  This is my quick attempt at 'what am I missing?' type post.  As noted, C++ variant is fine so RenderDoc is at least installed correctly.

Insight greatly appreciated...

*** condensed version of the log...
19.317Z : INFO  : .platform.desktop.MainActivity - Host OS: Linux
19.325Z : INFO  : .platform.desktop.MainActivity - LWJGL V: 3.3.3-snapshot
19.365Z : INFO  : .platform.desktop.MainActivity - GLFW V: 3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic shared
19.365Z : INFO  : .platform.desktop.MainActivity - Java Version: 17.0.10+7-Ubuntu-122.04.1; Processors: 8
19.560Z : INFO  : .platform.desktop.MainActivity - Created GLTF Window: 'HemetTV'
19.575Z : INFO  : .platform.desktop.MainActivity - Display VSYNC Enabled: true
19.620Z : INFO  : com.bbs.app.hemettv.VREngine   - ===============================================================================
19.620Z : INFO  : com.bbs.app.hemettv.VREngine   - Create Engine: 'VREngine'
19.620Z : INFO  : com.bbs.app.hemettv.VREngine   - = = = = = = = = = = = = = = = = = = = = = = =
19.908Z : INFO  : m.desktop.drivers.OpenALDriver - Desktop OpenAL(JWJGL) sound system initialized.
19.909Z : INFO  : m.desktop.drivers.OpenALDriver - Vendor = OpenAL Community
19.909Z : INFO  : m.desktop.drivers.OpenALDriver - Renderer = OpenAL Soft
19.909Z : INFO  : m.desktop.drivers.OpenALDriver - Version = 1.1 ALSOFT 1.23.1
19.909Z : INFO  : m.desktop.drivers.OpenALDriver - ALC_MAJOR_VERSION: 1
19.910Z : INFO  : m.desktop.drivers.OpenALDriver - ALC_MINOR_VERSION: 1
19.910Z : INFO  : m.desktop.drivers.OpenALDriver - ALC_FREQUENCY: 44100
19.910Z : INFO  : m.desktop.drivers.OpenALDriver - ALC_REFRESH: 50
19.910Z : INFO  : m.desktop.drivers.OpenALDriver - ALC_SYNC: 0
19.910Z : INFO  : m.desktop.drivers.OpenALDriver - ALC_MONO_SOURCES: 255
19.910Z : INFO  : m.desktop.drivers.OpenALDriver - ALC_STEREO_SOURCES: 1
19.940Z : INFO  : com.bbs.app.hemettv.VREngine   - toggleStereoscopic: false
19.941Z : INFO  : com.bbs.app.hemettv.VREngine   - toggleVirtualControls: false
19.965Z : INFO  : bbs.engine.manager.FileManager - FileManager::Successfully loaded data folder: ./Data/
19.967Z : INFO  : bs.engine.graphics.opengl.GLES - GL version:   4.6.0 NVIDIA 535.161.07
19.967Z : INFO  : bs.engine.graphics.opengl.GLES - GL vendor:   NVIDIA Corporation
19.967Z : INFO  : bs.engine.graphics.opengl.GLES - GL renderer:   NVIDIA GeForce RTX 2060/PCIe/SSE2
19.967Z : INFO  : bs.engine.graphics.opengl.GLES - GLSL version:   4.60 NVIDIA
19.968Z : INFO  : bs.engine.graphics.opengl.GLES - GLSL version tag:   #version 460
19.968Z : INFO  : bs.engine.graphics.opengl.GLES - GLSL extensions:   
20.081Z : INFO  : bs.app.hemettv.scene.BaseScene - -------------------------------------------------------------------------------
20.081Z : INFO  : bs.app.hemettv.scene.BaseScene - Creating scene: 'HDRBloom'
FATAL ERROR in native method: Thread[main,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
...

bmcclint

Found it...

TLDR...import org.lwjgl.opengl.ARBShaderObjects;

Apparently 'years' ago I created the shader logic and used the ARB imports and methods.  Not sure why...older LWJGL versions?  Anyway...for whatever reason, then iterating the list of shaders to compile using a stream lamba call, the context is NOT visible to the shader programs trying to compile.  I started by converting the lamba from a .stream().foreach() to a for(x : y) type operation and the exception moved into the abstract class where I called the ARBShaderObjects.glCreateProgramObjectARB() was executed.  That clued my off.  I remember thinking the logic was odd when I wrote it so...converted the logic to GL20.glCreateProgram() and the application loads now in RenderDoc.  I can capture frames, etc...

If anyone reads this and has an idea why the lambda caused what seemed like a new thread I'd love to hear.  Or why the ARB methods and the lambda did not play nice BUT only when trying to connect to RendeDoc, also please chime in.