GL_INVALID_OPERATION after calling ShaderState.glUniform

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

GL_INVALID_OPERATION after calling ShaderState.glUniform

Pete
Hello again folks,

Some of my devices aren't drawing with one of my shaders, a simple block colour fill / stroke shader, and I'm mystified why:

Running target profile GL2ES2 in JOGL debugGL mode via command line params & getting this:


Caused by: com.jogamp.opengl.GLException: Thread[Redrawer,5,main] glGetError() returned the following error codes after a call to glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name matViewProjection, location 5, size 4x4, count 1, data
0: [    0.00104    0.00000    0.00000   -1.00000 ]
0: [    0.00000    0.00185    0.00000    1.00000 ]
0: [    0.00000    0.00000   -2.00000   -1.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,
]): GL_INVALID_OPERATION ( 1282 0x502),
        at com.jogamp.opengl.DebugGLES3.writeGLError(DebugGLES3.java:7703)
        at com.jogamp.opengl.DebugGLES3.glUniform(DebugGLES3.java:6273)
        at com.jogamp.opengl.util.glsl.ShaderState.uniform(ShaderState.java:955)


this is happening whenever it tries to first draw with my colour paint shader but after looking up the GL error I still can't see what's wrong :(

The program should be set, the uniform location looks ok, the data is there..

My other paints - linear & radial gradients & textures - all work fine. Which is odd because they use the same names in their files for the matrices for matViewProjection and matWorld - with the same common paint draw method so everything happens in the same order.

here is the shader code of the colour paint:

VS:
uniform mat4 matViewProjection;
uniform mat4 matWorld;

attribute vec3 position;

void main()
{
        gl_Position = matViewProjection * matWorld * vec4( position, 1.0 );
}

PS:
uniform vec4 colour;
uniform vec4 blend;

void main()
{
   gl_FragColor = colour * blend;
}


Some data about the device in question:

os.name Linux
os.arch arm
java.vendor Oracle Corporation
java.home /usr/lib/jvm/java-8-oracle/jre
java.vm.name Java HotSpot(TM) Client VM
java.vm.vendor Oracle Corporation
java.runtime.name Java(TM) SE Runtime Environment

Vendor: ARM
Renderer: Mali-T628
Version: OpenGL ES 3.1
GL Profile: GLProfile[GLES3/GLES3.hw]


If its of any consequence - and it may very well be but I wouldn't know why.. - the only difference between the shaders running on my working devices is when loading them:

ShaderCode.defaultShaderCustomization( GL, false, true ) <- on devices where this isn't working and

ShaderCode.defaultShaderCustomization( GL, false, false ) <- on devices where this is working

Again, why would this break only the 1 shader and not all of them?

Any ideas anyone? :S

Pedro
Reply | Threaded
Open this post in threaded view
|

Re: GL_INVALID_OPERATION after calling ShaderState.glUniform

gouessej
Administrator
Hi

I don't see why the default precision causes some troubles here :s
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: GL_INVALID_OPERATION after calling ShaderState.glUniform

elect
In reply to this post by Pete
Do you have Debug Output available?
Reply | Threaded
Open this post in threaded view
|

Re: GL_INVALID_OPERATION after calling ShaderState.glUniform

Pete
There simply has to be something really stupid I'm doing that for the life of me I can't see yet. I've replaced my colour fill paint usages with my linear gradient paint - just to see what would happen - and everything is fine.. though slightly less efficient.

In an effort to address the original problem I have re-written my matrix class, I've stripped all the logic out of the colour paint class and associated shader files to simply draw the geometry filled red, no other data or ops. I've tried forcing other shaders to load first incase it was program id issue - non of this made any difference.

Completely baffled. I will get some trace + debug output if you want to take a look. I had a nice example of it drawing a texture, using the same geometry as a following colour fill, and you can see the texture ops go through ok, then the colour fill explode on glUniform.

I can't see it being precision modifiers either, as surely the texture shader would have blown as it was loaded & used first & features basically the same code + a texture sample op..

MADNESS!!
Reply | Threaded
Open this post in threaded view
|

Re: GL_INVALID_OPERATION after calling ShaderState.glUniform

elect
Have you checked the uniform location values?
Reply | Threaded
Open this post in threaded view
|

Re: GL_INVALID_OPERATION after calling ShaderState.glUniform

Pete
Some debug + trace output:

draw texture ( this works ):

glBindTexture(<int> 0xDE1, <int> 0x2)
glUseProgram(<int> 0x4)
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name mvp, location 5, size 4x4, count 1, data
0: [    0.00104    0.00000    0.00000   -1.00000 ]
0: [    0.00000    0.00185    0.00000    1.00000 ]
0: [    0.00000    0.00000   -2.00000   -1.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,
])
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name mworld, location 6, size 4x4, count 1, data
0: [    1.92000    0.00000    0.00000    0.00000 ]
0: [    0.00000    1.08000    0.00000 -1080.00000 ]
0: [    0.00000    0.00000    1.00000    0.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,
])
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name texture, location 0, size 1x1, count 1, data 0])
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name source, location 4, size 1x4, count 1, data DirectFloatBufferU[pos 0, lim 4, cap 4, remaining 4; array false, direct true, r/w true: 0.0, 0.0, 1.0, 1.0]])
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name blend, location 3, size 1x4, count 1, data DirectFloatBufferU[pos 0, lim 4, cap 4, remaining 4; array false, direct true, r/w true: 1.0, 1.0, 1.0, 1.0]])
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name geomsize, location 2, size 1x2, count 1, data DirectFloatBufferU[pos 0, lim 2, cap 2, remaining 2; array false, direct true, r/w true: 1000.0, 1000.0]])
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name texrotation, location 1, size 1x1, count 1, data DirectFloatBufferU[pos 0, lim 1, cap 1, remaining 1; array false, direct true, r/w true: 0.0]])
glGenBuffers(<int> 0x1, <[I>, <int> 0x0)
glBindBuffer(<int> 0x8892, <int> 0x1)
glBufferData(<int> 0x8892, <long> 48, <java.nio.Buffer> java.nio.DirectFloatBufferU[pos=0 lim=12 cap=12], <int> 0x88E4)
glVertexAttribPointer(<com.jogamp.opengl.GLArrayData> GLArrayDataServer[position, index -1, location 0, isVertexAttribute true, usesGLSL true, usesShaderState false, dataType 0x1406, bufferClazz class java.nio.FloatBuffer, elements 4, components 3, stride 12b 3c, initialElementCount 4, mappedElementCount 0, mappedStorage null, vboEnabled true, vboName 1, vboUsage 0x88e4, vboTarget 0x8892, vboOffset 0, sealed true, bufferEnabled false, bufferWritten true, buffer java.nio.DirectFloatBufferU[pos=0 lim=12 cap=12], alive true])
glBindBuffer(<int> 0x8892, <int> 0x0)
glEnableVertexAttribArray(<int> 0x0)
glDrawArrays(<int> 0x6, <int> 0x0, <int> 0x4)
glDisableVertexAttribArray(<int> 0x0)
glBindTexture(<int> 0xDE1, <int> 0x0)
glUseProgram(<int> 0x0)

Done with the texture, no issues..

glScissor(<int> 0x0, <int> 0x0, <int> 0x780, <int> 0x438)
glScissor(<int> 0x0, <int> 0x0, <int> 0x780, <int> 0x438)
glUseProgram(<int> 0x1)
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name mvp, location 5, size 4x4, count 1, data
0: [    0.00104    0.00000    0.00000   -1.00000 ]
0: [    0.00000    0.00185    0.00000    1.00000 ]
0: [    0.00000    0.00000   -2.00000   -1.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,
])[DEBUG:Renderer] pushFrameBuffer - pFrameBuffer is already assignedjava.lang.RuntimeException: com.jogamp.opengl.GLException: Caught GLException: Thread[main-Display-.x11_:0.0-1-EDT-1,5,main] glGetError() returned the following error codes after a call to glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name mvp, location 5, size 4x4, count 1, data
0: [    0.00104    0.00000    0.00000   -1.00000 ]
0: [    0.00000    0.00185    0.00000    1.00000 ]
0: [    0.00000    0.00000   -2.00000   -1.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,
]): GL_INVALID_OPERATION ( 1282 0x502),  on thread main-Display-.x11_:0.0-1-EDT-1

        at jogamp.newt.DefaultEDTUtil.invokeImpl(DefaultEDTUtil.java:249)
        at jogamp.newt.DefaultEDTUtil.invoke(DefaultEDTUtil.java:163)
        at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:427)
        at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2133)
        at jogamp.newt.WindowImpl.setVisible(WindowImpl.java:1024)
        at jogamp.newt.WindowImpl.setVisible(WindowImpl.java:1029)
        at com.jogamp.newt.opengl.GLWindow.setVisible(GLWindow.java:499)
Caused by: com.jogamp.opengl.GLException: Caught GLException: Thread[main-Display-.x11_:0.0-1-EDT-1,5,main] glGetError() returned the following error codes after a call to glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name mvp, location 5, size 4x4, count 1, data
0: [    0.00104    0.00000    0.00000   -1.00000 ]
0: [    0.00000    0.00185    0.00000    1.00000 ]
0: [    0.00000    0.00000   -2.00000   -1.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,
]): GL_INVALID_OPERATION ( 1282 0x502),  on thread main-Display-.x11_:0.0-1-EDT-1
        at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1311)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1131)
        at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:680)
        at jogamp.opengl.GLAutoDrawableBase.defaultWindowResizedOp(GLAutoDrawableBase.java:259)
        at com.jogamp.newt.opengl.GLWindow.access$200(GLWindow.java:119)
        at com.jogamp.newt.opengl.GLWindow$2.windowResized(GLWindow.java:141)
        at jogamp.newt.WindowImpl.consumeWindowEvent(WindowImpl.java:3682)
        at jogamp.newt.WindowImpl.sendWindowEvent(WindowImpl.java:3616)
        at jogamp.newt.WindowImpl.setVisibleActionImpl(WindowImpl.java:1003)
        at jogamp.newt.WindowImpl$VisibleAction.run(WindowImpl.java:1015)
        at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:150)
        at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:372)
Caused by: com.jogamp.opengl.GLException: Thread[main-Display-.x11_:0.0-1-EDT-1,5,main] glGetError() returned the following error codes after a call to glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name mvp, location 5, size 4x4, count 1, data
0: [    0.00104    0.00000    0.00000   -1.00000 ]
0: [    0.00000    0.00185    0.00000    1.00000 ]
0: [    0.00000    0.00000   -2.00000   -1.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,
]): GL_INVALID_OPERATION ( 1282 0x502),
        at com.jogamp.opengl.DebugGLES3.writeGLError(DebugGLES3.java:7703)
        at com.jogamp.opengl.DebugGLES3.glUniform(DebugGLES3.java:6273)
        at com.jogamp.opengl.TraceGLES3.glUniform(TraceGLES3.java:4623)
        at com.jogamp.opengl.util.glsl.ShaderState.uniform(ShaderState.java:955)


And then... yeah :/
Reply | Threaded
Open this post in threaded view
|

Re: GL_INVALID_OPERATION after calling ShaderState.glUniform

Pete
In reply to this post by elect
Some progress - indeed the location ids are incorrect! Just need to find out how the mix-up is occuring:

On my working devices, here is the loading of the shader vs the use:

glUseProgram(<int> 0x1)
glGetAttribLocation(<int> 0x1, <java.lang.String> position) = 0
glGetUniformLocation(<int> 0x1, <java.lang.String> colour) = 2
glGetUniformLocation(<int> 0x1, <java.lang.String> mvp) = 0
glGetUniformLocation(<int> 0x1, <java.lang.String> mworld) = 1
...
glUseProgram(<int> 0x1)
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name colour, location 2, size 1x4, count 1, data DirectFloatBufferU[pos 0, lim 4, cap 4, remaining 4; array false, direct true, r/w true: 1.0, 0.0, 1.0, 1.0]])
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name mvp, location 0, size 4x4, count 1, data
0: [    0.00167    0.00000    0.00000   -1.00000 ]
0: [    0.00000    0.00260    0.00000    1.00000 ]
0: [    0.00000    0.00000   -2.00000   -1.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,
])
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name mworld, location 1, size 4x4, count 1, data
0: [    1.00000    0.00000    0.00000    0.00000 ]
0: [    0.00000    1.00000    0.00000    0.00000 ]
0: [    0.00000    0.00000    1.00000    0.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,
])


versus one that doesn't work:

glUseProgram(<int> 0x1)
glGetAttribLocation(<int> 0x1, <java.lang.String> position) = 0
glGetUniformLocation(<int> 0x1, <java.lang.String> colour) = 0
glGetUniformLocation(<int> 0x1, <java.lang.String> mvp) = 1
glGetUniformLocation(<int> 0x1, <java.lang.String> mworld) = 2
...
glUseProgram(<int> 0x1)
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name colour, location 0, size 1x4, count 1, data DirectFloatBufferU[pos 0, lim 4, cap 4, remaining 4; array false, direct true, r/w true: 1.0, 0.0, 1.0, 1.0]])
glUniform(<com.jogamp.opengl.GLUniformData> GLUniformData[name mvp, location 5, size 4x4, count 1, data
0: [    0.00104    0.00000    0.00000   -1.00000 ]
0: [    0.00000    0.00185    0.00000    1.00000 ]
0: [    0.00000    0.00000   -2.00000   -1.00000 ]
0: [    0.00000    0.00000    0.00000    1.00000 ]
,

location 5 ??????????!!!!!!!!!!!!!!!!!!

*rage*

so yeah, the location is what's wrong, your hunch was a good one :) I made the "assumption" that because it wasn't unassigned it must have been right - well you know what they say about assumptions being the mother of all ** ups :D

I'll update when I find out what's going awry.
Reply | Threaded
Open this post in threaded view
|

Re: GL_INVALID_OPERATION after calling ShaderState.glUniform

elect
You bloody ^^ didnt your mum always say you to check uniform locations first? :D

Actually that's the second one, first one is "not accept candies from strangers" :p

However, I was referring to this Debug Output. You can find an example here . It is muuuuch more human readable and helpful.

Ps: don't use spare uniform, use UBOs (or SSBOs)
Pps: use explicit locations if you can
Reply | Threaded
Open this post in threaded view
|

Re: GL_INVALID_OPERATION after calling ShaderState.glUniform

Pete
In reply to this post by Pete
All sorted - turns out indeed I was doing something silly.

I was reusing the same matrix GLUniformData between different shaders - as each shader referenced the model and viewprojection matrices via the same name I'd gone along with the assumption this was ok, especially as it was working on my primary dev machines.

But! This was only by chance, because my machines driver impl of glGetUniformLocation was return the same value for these two matrices in each shader. On the borken machines - guess what - it didn't, and hence the booms.

I'm re-working now to address the problem. Thank you for listening to my ramblings! Its nice to know there are people who care :)
Reply | Threaded
Open this post in threaded view
|

Re: GL_INVALID_OPERATION after calling ShaderState.glUniform

elect
You'r welcome ;)