PDA

View Full Version : GL_FRAMEBUFFER_ATTACHMENT_LAYERED is invalid



Xepil
01-08-2011, 10:25 AM
I think this is a stupid mistake on my part, but I've read the relevant sections of the manual several times and I still can't figure out what I am doing wrong.

I want to use GL_FRAMEBUFFER_ATTACHMENT_LAYERED to verify that a 3D texture that I am attaching to my framebuffer is being attached correctly. In particular, I want to verify that the texture is attached as a layered texture. I want to make sure it is attached correctly so that I can use gl_Layer in my geometry shader. Here is the Java/LWJGL code I am using:


GL11.glEnable(GL12.GL_TEXTURE_3D);

// Create the framebuffer
int framebuffer = GL30.glGenFramebuffers();

// Create the 3d texture
int texture3d;
texture3d = GL11.glGenTextures();
GL11.glBindTexture(GL12.GL_TEXTURE_3D, texture3d);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL12.GL_TEXTURE_WRAP_R, GL11.GL_CLAMP);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

GL12.glTexImage3D(GL12.GL_TEXTURE_3D, 0, GL11.GL_RGBA8, 32, 32, 32, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_INT, (IntBuffer) null);
GL11.glBindTexture(GL12.GL_TEXTURE_3D, 0);

// Attach the texture to the framebuffer
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, texture3d, 0);

// Check the result
int result = GL30.glGetFramebufferAttachmentParameter(GL30.GL_F RAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL32.GL_FRAMEBUFFER_ATTACHMENT_LAYERED); // THIS LINE OF CODE IS THE PROBLEM


The last line of code is the problem. It causes the following OpenGL error:

Exception: org.lwjgl.opengl.OpenGLException: Invalid enum (1280)

If I pass any of the other parameters specified in the OpenGL manual to glGetFramebufferAttachmentParameter() then everything works fine. For example, these parameters will work:
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE

Only the GL_FRAMEBUFFER_ATTACHMENT_LAYERED parameter throws the "invalid enum" exception.

Here's my runtime environment:
Windows 7 64-bit
Catalyst 10.12 (display driver only)
ATI Radeon HD 4850
JavaSE 1.6
LWJGL 2.6

Does anyone have any ideas on what I am doing wrong?

Thank you for reading this post.

Dark Photon
01-08-2011, 01:35 PM
GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, texture3d, 0);
Looks right.


int result = GL30.glGetFramebufferAttachmentParameter(GL30.GL_F RAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL32.GL_FRAMEBUFFER_ATTACHMENT_LAYERED); // THIS LINE OF CODE IS THE PROBLEM

Maybe there's something wrong with your Java wrapper? I'd flip to C/C++ and verify that this works with your driver using GetFramebufferAttachmentParameteriv.

Alfonse Reinheart
01-08-2011, 01:58 PM
Only the GL_FRAMEBUFFER_ATTACHMENT_LAYERED parameter throws the "invalid enum" exception.

The only reason it would throw that is if you called the wrong glGetFramebufferAttachmentParameter function (or you aren't using GL 3.2 or greater somehow).

This suggests that it is a problem with the GL binding code. That is, it isn't calling the right function.

Xepil
01-08-2011, 02:43 PM
Thank you for the replies, Dark and Alfonse. I'll submit a bug report to LWJGL and see if they can confirm or deny the Java wrapper bug theory.

At least I now have others to confirm that I didn't make a stupid mistake with my code :)

skynet
04-05-2011, 02:38 AM
I just had the same problem on a FireGLV5700, WinXP64, 8.773 drivers. I'm using C++, so no GL wrapper is involved. I suspect a driver bug :-(