Hello,
I’m running into an issue where creating a texture sampler from a GL_TEXTURE_2D (createTextureSamplerFromGLImage) is throwing an exception, but only on Linux.
terminate called after throwing an instance of 'optix::Exception'
what(): Invalid value (Details: Function "RTresult _rtTextureSamplerCreateFromGLImage(RTcontext, unsigned int, RTgltarget, RTtexturesampler_api**)" detected error: Not a valid OpenGL texture)
I have tried using OptiX 5.0.0, as well as going back to 4.1.1 and 3.9.1, but all throw the same exception, including the pre-compiled sample included with the 3.9.1 SDK distribution. This happens on Ubuntu 16.04 and 17.10 with the 384.111, 387.23 and 390.12 driver versions. TextureSampler creation in general works as expected, and other GL interop (createBufferFromGLBO) also works fine, the only issue seems to be with createTextureSamplerFromGLImage.
Running the simplified code below reproduces the issue on Linux, but runs and exits cleanly on OSX (378.05.05.25f04 driver), and Windows 10 (390.65 driver).
Any insights would be greatly appreciated,
Chris
#include <optixu/optixpp.h>
#include <GLFW/glfw3.h>
int main() {
glfwInit();
auto window = glfwCreateWindow(640, 480, "gl_texture", nullptr, nullptr);
glfwMakeContextCurrent(window);
auto context = optix::Context::create();
GLuint texture_id;
glGenTextures(1, &texture_id);
glBindTexture(GL_TEXTURE_2D, texture_id);
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_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glBindTexture(GL_TEXTURE_2D, 0);
auto sampler = context->createTextureSamplerFromGLImage(texture_id, RT_TARGET_GL_TEXTURE_2D);
return 0;
}