0

I want to use bindless textures and multisampling. But Strange stuff happens.

My Texture that is supposed to be bindless:

glBindTexture(GL_TEXTURE_2D, texResolve);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);

GLuint64 texResolveHandle = glGetTextureHandleARB(texResolve);

GL_CHECK_ERROR("after glGetTextureHandleARB");
//glMakeTextureHandleResidentARB(texResolveHandle);
//glMakeTextureHandleNonResidentARB(texResolveHandle);

GL_CHECK_ERROR("after glMakeTextureHandleResidentARB");

//All good so far!

Now I cerate my multisample Texture and things are getting strange:

glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texMSAA);
GL_CHECK_ERROR("after glTexImage2DMultisample 1"); //still ok

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
GL_CHECK_ERROR("after glTexImage2DMultisample 2"); //ERROR

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GL_CHECK_ERROR("after glTexImage2DMultisample 3"); //ERROR

glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, width, height, false);
GL_CHECK_ERROR("after glTexImage2DMultisample texMSAA"); //Again OK ????

So, my question: What is happening?

Best Regards

  • You're not setting the texture parameters on the multisample texture, since you use `GL_TEXTURE_2D` as the first argument to `glTexParameteri()`. That being said, setting sampler parameters on multisample textures would be an error anyway, they are not supported. – Reto Koradi Oct 21 '15 at 06:07
  • There's nothing strange about trying to apply linear filtering to a multisampled texture and getting an error. The strange thing is trying to filter a multisampled texture. These textures are not sampled the same way as regular ones and texture filter and wrap mode have no meaning. – Andon M. Coleman Oct 21 '15 at 06:30
  • I see. Makes sense. But why does it fail only if I create the texture handles? – user3497417 Oct 21 '15 at 18:14

1 Answers1

0

Since you bind the texture the GL_TEXTURE_2D_MULTISAMPLE binding point, you also have to use this binding point in the glTexParameteri calls.

glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, GL_REPEAT);
GL_CHECK_ERROR("after glTexImage2DMultisample 2");

glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GL_CHECK_ERROR("after glTexImage2DMultisample 3");

Note, that binding points in OpenGL are "by type", so one can bind, e.g., a GL_TEXTURE_2D and a GL_TEXTURE_3D to the same active texture unit at the same time.

BDL
  • 21,052
  • 22
  • 49
  • 55
  • 2
    All of these calls will result in an error. From the 4.5 spec: "An INVALID_ENUM error is generated if the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any sampler state from table 23.18." – Reto Koradi Oct 21 '15 at 06:12