Bug 108853 - OSMesaGetDepthBuffer flipped vertically
Summary: OSMesaGetDepthBuffer flipped vertically
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/OSMesa (show other bugs)
Version: 18.2
Hardware: All All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
Depends on:
Reported: 2018-11-24 16:16 UTC by popinet
Modified: 2019-09-18 20:12 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description popinet 2018-11-24 16:16:16 UTC
When installing OSMesa using

./configure --prefix=$install_dir                 \
    --enable-opengl --disable-gles1 --disable-gles2   \
    --disable-va --disable-xvmc --disable-vdpau       \
    --enable-shared-glapi                             \
    --disable-texture-float                           \
    --with-gallium-drivers=swrast                 \
    --disable-dri --with-dri-drivers=                 \
    --disable-egl --with-platforms= --disable-gbm \
    --enable-glx    --with-platforms=x11              \
    --disable-osmesa --enable-gallium-osmesa

i.e. using the gallium osmesa implementation, the depth buffer returned by OSMesaGetDepthBuffer is flipped vertically relative to the OSMesa framebuffer.

Using the non-gallium osmesa implementation returns a depth buffer correctly aligned with the framebuffer.

The gallium-returned depth buffer can be fixed using something like:

fbdepth_t * framebuffer_depth (framebuffer * p)
  unsigned int * depth;
  GLint width, height, bytesPerValue;
  OSMesaGetDepthBuffer (p->ctx, &width, &height, &bytesPerValue,
			(void **)&depth);
  assert (p->width == width && p->height == height && bytesPerValue == 4);
  assert (sizeof(fbdepth_t) == bytesPerValue);
  // fix for bug in gallium/libosmesa
  // the depth buffer is flipped vertically
  for (GLint j = 0; j < height/2; j++)
    for (GLint i = 0; i < width; i++) {
      unsigned int tmp = depth[j*width + i];
      depth[j*width + i] = depth[(height - 1 - j)*width + i];
      depth[(height - 1 - j)*width + i] = tmp;
#endif // GALLIUM
  return depth;
Comment 1 GitLab Migration User 2019-09-18 20:12:58 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/885.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.