question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

glGetActiveUniformBlockiv not functioning for vector output

See original GitHub issue

Related PR https://github.com/libgdx/libgdx/pull/6208

Issue details

When querying vector information from UniformBlocks (i.e. GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) only the first item is ever written.

Reproduction steps/code

I don’t have time to create a reproduction rn, but my stacktrace looks something like this

My code:

                val indices = allocateIntBuffer(count) // direct byte buffer as an int buffer
                indices.rewind()
                gl.glGetActiveUniformBlockiv( // gl is typealiased to Gdx.gl30
                    programId,
                    i, // index of the ubo
                    GL30.GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES,
                    indices
                )
Libgdx: Lwjgl3GL30.java:484

	@Override
	public void glGetActiveUniformBlockiv (int program, int uniformBlockIndex, int pname, IntBuffer params) {
		params.put(GL31.glGetActiveUniformBlocki(program, uniformBlockIndex, pname));
	}
Lwjgl: GL31C.java:584

    @NativeType("void")
    public static int glGetActiveUniformBlocki(@NativeType("GLuint") int program, @NativeType("GLuint") int uniformBlockIndex, @NativeType("GLenum") int pname) {
        MemoryStack stack = stackGet(); int stackPointer = stack.getPointer();
        try {
            IntBuffer params = stack.callocInt(1);
            nglGetActiveUniformBlockiv(program, uniformBlockIndex, pname, memAddress(params));
            return params.get(0);
        } finally {
            stack.setPointer(stackPointer);
        }
    }

I may provide a proper reproduction later on.

Version of LibGDX and/or relevant dependencies

1.9.11

Stacktrace

glGetActiveUniformBlocki:553, GL31 (org.lwjgl.opengl)
glGetActiveUniformBlockiv:485, Lwjgl3GL30 (com.badlogic.gdx.backends.lwjgl3)
introspect:140, ShaderProgram (com.nanite.graphics)
. . .
initializeListener:433, Lwjgl3Window (com.badlogic.gdx.backends.lwjgl3)
update:381, Lwjgl3Window (com.badlogic.gdx.backends.lwjgl3)
loop:138, Lwjgl3Application (com.badlogic.gdx.backends.lwjgl3)
<init>:114, Lwjgl3Application (com.badlogic.gdx.backends.lwjgl3)
main:18, DesktopLauncher (com.cellular.game.desktop)

Please select the affected platforms

  • Android
  • iOS
  • HTML/GWT
  • Windows
  • Linux
  • MacOS (although I imagine other platforms will be affected as well)

I imagine it’s a simple matter of calling the wrong jwjgl function.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
FreakingBarbarianscommented, Oct 8, 2020

Sure I could have something ready by tomorrow-ish

0reactions
mgsx-devcommented, Oct 8, 2020

fixed by #6208

Read more comments on GitHub >

github_iconTop Results From Across the Web

Catalyst 10.12 and std140 uniform blocks - Khronos Forums
Basically using the glGetActiveUniformBlockiv interface. Here's the code if you're ... It does not say this vector should occupy 16 bytes.
Read more >
GLSL, multiple uniform blocks - opengl - Stack Overflow
... the uniforms resulting after this optimization are called "active" uniforms and the reason why a uniform declared but not otherwise used ...
Read more >
C++ (Cpp) glGetActiveUniformBlockiv Examples - HotExamples
C++ (Cpp) glGetActiveUniformBlockiv - 30 examples found. ... used for debugging to print the offsets of uniform buffer members void ...
Read more >
Lesson 3 – GLSL - PV227 – GPU Rendering - IS MUNI
all output parameter values are copied from the function after execution, in parameters can be also const (not writeable inside function).
Read more >
glLinkProgram - OpenGL ES 3 - docs.gl
Also, any active user-defined attribute variables that have not been bound to a ... in the varyings array is not declared as an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found