problems with shaders

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

problems with shaders

gouessej
Administrator
Hi!

When I use shaders, the returned compile status is always false even though the shader is successfully compiled. The logs are always empty even though there are real errors during compilation. I use Cent OS 5.3 with this graphics card:
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: Quadro FX 3450/4000 SDI/PCI/SSE2
OpenGL version string: 2.1.2 NVIDIA 185.18.14

Please find enclosed the source code of my example.

shaderBug.zip

Should I write a bug report?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

gouessej
Administrator
Ok I reply to myself. The example found on Javagaming was wrong. When I replaced glGetProgramiv by glGetShaderiv for each shader, it solved my problem.

Sven, could I suggest a very simple example of shaders? Mine uses a vertex shader, a pixel shader and a geometry shader.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

Demoscene Passivist
Administrator
>Sven, could I suggest a very simple example of shaders?

For basic shader setup/compilation u could take a look at my ShaderUtils.java. For many medium/advanced routines using shaders u might have a look at my programmable pipeline directory at github.
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

Sven Gothel
Administrator
In reply to this post by gouessej
On Thursday, December 16, 2010 13:02:19 gouessej [via jogamp] wrote:
>
> Ok I reply to myself. The example found on Javagaming was wrong. When I replaced glGetProgramiv by glGetShaderiv for each shader, it solved my problem.
>
> Sven, could I suggest a very simple example of shaders? Mine uses a vertex shader, a pixel shader and a geometry shader.
>

We also have a GL2ES2 unit test in :)

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

gouessej
Administrator
In reply to this post by Demoscene Passivist
Demoscene Passivist wrote
For basic shader setup/compilation u could take a look at my ShaderUtils.java. For many medium/advanced routines using shaders u might have a look at my programmable pipeline directory at github.
Why do you mix "old" ARB things with OpenGL 2.0 methods to fetch the logs? Thank you for the tip.

Edit.: where is the support of geometry shaders? Your code is fine but it lacks some tests.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

Demoscene Passivist
Administrator
>Why do you mix "old" ARB things with OpenGL 2.0 methods to fetch the logs?

Ups  ... Seems like I have forgotten some lines while migrating my old stuff to JOGL2. Will fix this in my next commit :)

>where is the support of geometry shaders? Your code is fine but it lacks some tests.

Methods for geometry shaders are missing coz I don't have a GPU that supports 'em. But XMas is at the door step, so maybe Santa will fix this issue
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

gouessej
Administrator
Lol I tried to use geometry shaders at work. At home, my graphics card does not even support ARB shaders ;) OpenGL 1.3 only.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

Demoscene Passivist
Administrator
>At home, my graphics card does not even support ARB shaders

Hehe, welcome to the club
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

Demoscene Passivist
Administrator
In reply to this post by Demoscene Passivist
I came back to the issue of glGetProgramInfoLog vs. glGetObjectParameterivARB today. I tried to debug a fragment shader wich was working fine on ATI hardware but was completely broken on NVidia.

As I dug further into the issue I noticed that I got nearly no debug output (only glerror messages) from the nvidia machine wich output was generally way more detailed before I switched to using glGetProgramInfoLog as suggested by julien.

After I switched back to glGetObjectParameterivARB I got a very detailled debug/error output from the NVidia driver.

So it seems either glGetProgramInfoLog is broken in JOGL or this is some kind of strange driver behavior on NVidia or I'am too stupid to understand a subtile difference between glGetProgramInfoLog  and glGetObjectParameterivARB ... . Maybe some else can shed light on this issue ...
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

gouessej
Administrator
glGetProgramInfoLog works fine on NVidia Quadro FX. Which graphics card do you use?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

Demoscene Passivist
Administrator
> Which graphics card do you use?

NVidia GTX 8800M (Notebook GPU) on Windows Vista x32.

inGL.glGetProgramInfoLog(inShaderObjectID, tLogLength, tReturnValue, tShaderLog);

.. returns nothing, no errors. but with:

inGL.glGetInfoLogARB(inShaderObjectID, tLogLength, tReturnValue, tShaderLog);

... I get detailed compiler error messages . Up until now I thought glGetProgramInfoLog was the way to go when trying to get the compile error logs ?!
Reply | Threaded
Open this post in threaded view
|

Re: problems with shaders

gouessej
Administrator
No you're wrong, I rather do this:

final GL2 gl = GLU.getCurrentGL().getGL2();
gl.glGetShaderiv(id, GL2ES2.GL_COMPILE_STATUS, intBuffer);
if (intBuffer.get(0) == GL.GL_FALSE) {
            gl.glGetShaderiv(id, GL2ES2.GL_INFO_LOG_LENGTH, intBuffer);
            final int length = intBuffer.get(0);
            String out = null;
            if (length > 0) {
                final ByteBuffer infoLog = Buffers.newDirectByteBuffer(length);
                gl.glGetShaderInfoLog(id, infoLog.limit(), intBuffer, infoLog);
                final byte[] infoBytes = new byte[length];
                infoLog.get(infoBytes);
                out = new String(infoBytes);
            }
            throw new GLException("Error during shader compilation: " + out);
        }


You compile a shader, not a program. Therefore, you have to use methods related on shaders (glGetShaderiv, ...) instead of using methods related on programs. If you want to get errors about the link, then use methods related on programs (glGetProgramiv, ...).
Julien Gouesse | Personal blog | Website