EGL / OpenGL rendering to a surface with just a luminance channel

80 Views Asked by At

I am (attempting) to use EGL / OpenGL to perform headless rendering using a framebuffer that contains only a single luminance channel. I am able to choose a EGL configuration just fine:

EGLint major, minor;
eglSuccess = eglInitialize(eglDpy, &major, &minor);
assert(eglSuccess == EGL_TRUE); // success
...
static const EGLint configAttribs[] = {
    EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
    EGL_COLOR_BUFFER_TYPE, EGL_LUMINANCE_BUFFER,
    EGL_LUMINANCE_SIZE, 16,
    EGL_DEPTH_SIZE, 24,
    EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
    EGL_NONE
};
EGLint numConfigs;
EGLConfig eglCfg;
eglSuccess = eglChooseConfig(eglDpy, configAttribs, &eglCfg, 1, &numConfigs);
assert(eglSuccess == EGL_TRUE); // success

But I am unable to successfully create a surface:

const EGLint pbufferAttribs[] = {
    EGL_WIDTH, surfaceWidth,
    EGL_HEIGHT, surfaceHeight,
    EGL_NONE,
};
eglSurf = eglCreatePbufferSurface(eglDpy, eglCfg, pbufferAttribs);
assert(eglSurf != EGL_NO_SURFACE); // fail

The docs for eglCreatePbufferSurface do not even mention a luminance option.

How do a I create a surface for rendering to a framebuffer with only luminance channel? Does EGL even provide this option (eglChooseConfig seems to indicate that it is supported as the code above shows)? Am I better of trying to render to texture?

EDIT:

It turns out when I query the number of configs I get numTotalConfigs = 91

eglGetConfigs(eglDpy, nullptr, 0, &numTotalConfigs);

None of the configs support EGL_LUMINANCE_BUFFER!

std::vector<EGLConfig> configs(numTotalConfigs);
eglGetConfigs(eglDpy, const_cast<EGLConfig*>(configs.data()),
              configs.size(), &numTotalConfigs);
for (size_t i = 0; i < configs.size(); i++) {
    const auto& config = configs[i];
    eglGetConfigAttrib(eglDpy, config, 
                       EGL_COLOR_BUFFER_TYPE, &val);
    // val == EGL_RGB_BUFFER every time!
    ...
 }

The device is nVidia Quadro P5000. eglQueryDeviceStringEXT yeilds the following

 EGL_NV_device_cuda 
 EGL_EXT_device_drm 
 EGL_EXT_device_drm_render_node
 EGL_EXT_device_query_name 
 EGL_EXT_device_persistent_id

I guess I am out of luck on the device. Maybe try the software rendered(?)

Thanks to @Remc4 for steering me in the right direction.

0

There are 0 best solutions below