Skip to content

Conversation

@MeFisto94
Copy link
Member

Use a reflection-based approach to call checkError() after every call to the openGL API to reduce Code Duplication and increase Maintainability, while also fixing the regression caused by GLDebugDesktop extending from GLDebugES and thus making the Renderer think it is on mobile.

As discussed, if I should make this version more dynamic to support GLFbo and GLExt as separate GLDebugDesktop instances, I can do that, but having the if statement probably isn't that bad, but I can see that it is better and more flexible and especially gets rid of the exception in line 73

@MeFisto94 MeFisto94 requested a review from pspeed42 February 2, 2020 15:00
@MeFisto94 MeFisto94 self-assigned this Feb 2, 2020
@MeFisto94
Copy link
Member Author

MeFisto94 commented Feb 2, 2020

I forgot to add the changes to LWJGL3, will force-push shortly.

Edit: I think we could do even better and only have GLDebug which can then be invoked for Desktop OR ES (in case of ES, the only thing different is that we have to add GLES_30 as implemented interface and keep GL3 and GL4 off)

@MeFisto94 MeFisto94 force-pushed the fix-gldebug branch 2 times, most recently from 5485e1f to 9a50669 Compare February 2, 2020 17:05
@stephengold
Copy link
Member

Before we can integrate this, we need to upgrade the NDK version.

@MeFisto94
Copy link
Member Author

Do you talk about the build failure stemming from #1281 ?
If so I can rebase this to master, then the Android build will succeed.

@stephengold
Copy link
Member

I was assuming the build failure was something more serious. Go ahead and rebase then, and we'll see.

… to the openGL API to reduce Code Duplication and increase Maintainability, while also fixing the regression caused by GLDebugDesktop extending from GLDebugES and thus making the Renderer think it is on mobile.
@pspeed42
Copy link
Contributor

Sorry it's taken me so long to look at this and thanks for being patient. It mostly looks good.

A concern I have is that code that used to create on gl object and then cast it to different fields is now creating three separate proxies.
gl = (GL) GLDebug.createProxy(gl, gl, GL.class, GL2.class, GL3.class, GL4.class);
glext = (GLExt) GLDebug.createProxy(gl, glext, GLExt.class);
glfbo = (GLFbo) GLDebug.createProxy(gl, glfbo, GLFbo.class);

I don't really know how/where these fields are used and haven't had time to look, but any code expecting them to be the same object (or expecting to be able to case glfbo to GL4 or whatever) is going to fail where it would have succeeded before.

Perhaps we are correct to enforce this and I guess it would only break if they turn debugging on... and then they could see their error and correct it.

Otherwise, the changes look good to me.

public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result = method.invoke(obj, args);

if (method.getName().equals("glGetError")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pspeed42 Actually I just stumbled over this:
Do you think it would be more wise to lookup the Method object and use equals there instead of comparing the string all the time?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure it would be slightly faster, I guess, if the method is looked up at proxy creation time. I wasn't overly concerned about it since this is a debugging class.

I'm ok if that's a follow-on improvement, too.

@riccardobl
Copy link
Member

What is the status for this?

@MeFisto94
Copy link
Member Author

I need to change the if to be Method based and think about the separate proxies first, so this is mostly a "draft"

@MeFisto94
Copy link
Member Author

I looked through the concern of having multiple proxies and:
In Release Mode, GLEXT and GLFbo are different classes already, so it's just that the old Debug State was mixing them up. The old Debug state still provided separate variables for this, so there is no real reason to assume the above.

That means, I'm fine with breaking code that relied on glfbo = gl = glext only on debug.
I will fix what I commited eariler this day, though.

…force a crash when glGetError is not present.
@MeFisto94
Copy link
Member Author

@pspeed42 Any objections based on the fact that I throw an unchecked exception when glGetError cannot be found?

@pspeed42
Copy link
Contributor

pspeed42 commented Apr 4, 2020

IllegalStateException isn't really the right exception here. If you want to avoid a naked RuntimeException (and that's probably a good idea), IllegalArgumentException is probably better. ie: the caller passed a GL context that is incompatible with this debugger.

@MeFisto94 MeFisto94 merged commit 2379cfb into jMonkeyEngine:master Apr 4, 2020
@stephengold stephengold added this to the v3.3.1 milestone Apr 16, 2020
@stephengold
Copy link
Member

Fixed in v3.3 branch at 4c2c3fa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants