<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - OSMesaGetDepthBuffer flipped vertically"
href="https://bugs.freedesktop.org/show_bug.cgi?id=108853">108853</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>OSMesaGetDepthBuffer flipped vertically
</td>
</tr>
<tr>
<th>Product</th>
<td>Mesa
</td>
</tr>
<tr>
<th>Version</th>
<td>18.2
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>Drivers/OSMesa
</td>
</tr>
<tr>
<th>Assignee</th>
<td>mesa-dev@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>popinet@basilisk.fr
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>mesa-dev@lists.freedesktop.org
</td>
</tr></table>
<p>
<div>
<pre>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);
#if GALLIUM
// 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;
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>