PDA

View Full Version : glTexImage2DMultisample with GL_DEPTH_COMPONENT results in GL_INVALID_VALUE



yousry
02-04-2013, 06:42 AM
I don't know if this is a driver problem or my fault:


NSLog(@"GL_MAX_TEXTURE_SIZE: %d (%d, %d)", GL_MAX_TEXTURE_SIZE, width, height);
NSLog(@"GL_MAX_SAMPLES: %d", GL_MAX_SAMPLES);
glGenTextures(1, &shadowTextureId);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, shadowTextureId);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_DEPTH_COMPONENT , width, height, false);
[YALog isGLStateOk:TAG];


The output is:


GL_MAX_TEXTURE_SIZE: 3379 (512, 512)
GL_MAX_SAMPLES: 36183
[YAShadowMap] glTexImage2DMultisample [OpenGL] GL_INVALID_VALUE



GL_INVALID_VALUE is called if:


GL_INVALID_VALUE is generated if either width or height negative or is greater than GL_MAX_TEXTURE_SIZE.
GL_INVALID_VALUE is generated if samples is greater than GL_MAX_SAMPLES.

Both causes can be excluded.

My NSOpenGLPixelFormatAttribute looks like this:


NSOpenGLPFAMultisample ,
NSOpenGLPFASampleBuffers, 1,
NSOpenGLPFASamples, 4,

and multisample is enabled:

glEnable(GL_MULTISAMPLE);

arekkusu
02-04-2013, 10:48 AM
NSLog(@"GL_MAX_SAMPLES: %d", GL_MAX_SAMPLES);


That isn't how queries work (http://www.opengl.org/wiki/Get_Context_Info).
You use GL_MAX_ enums to ask the driver what the limit is, like this:


GLint max_samples = 0;
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
NSLog(@"GL_MAX_SAMPLES: %d", max_samples);



And, because you're using a depth format, the specification (http://www.opengl.org/registry/specs/ARB/texture_multisample.txt) says the actual limit is MAX_DEPTH_TEXTURE_SAMPLES, not MAX_SAMPLES. And I'm guessing you're using an ATI GPU, where you can see (https://developer.apple.com/graphicsimaging/opengl/capabilities/) that the limit is "1".

yousry
02-04-2013, 01:50 PM
Thank You.
I confused a query with an extension availability check.
Also GL_MAX_TEXTURE_SIZE(16384) doesn't help, because glFramebufferTexture2D then creates a GL_FRMAEBUFFER_UNSUPPORTED error.