<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 - Compute Shader can't deal with Depth Buffers correctly"
href="https://bugs.freedesktop.org/show_bug.cgi?id=99511">99511</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compute Shader can't deal with Depth Buffers correctly
</td>
</tr>
<tr>
<th>Product</th>
<td>Mesa
</td>
</tr>
<tr>
<th>Version</th>
<td>git
</td>
</tr>
<tr>
<th>Hardware</th>
<td>x86-64 (AMD64)
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (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/Gallium/radeonsi
</td>
</tr>
<tr>
<th>Assignee</th>
<td>dri-devel@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dark_sylinc@yahoo.com.ar
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>dri-devel@lists.freedesktop.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=129119" name="attach_129119" title="Sample repro. Also contains GCN generated ISA for the Compute Shader">attachment 129119</a> <a href="attachment.cgi?id=129119&action=edit" title="Sample repro. Also contains GCN generated ISA for the Compute Shader">[details]</a></span>
Sample repro. Also contains GCN generated ISA for the Compute Shader
OS: Linux Ubuntu 16.04
Kernel 4.7.3
AMD Radeon HD 7770 1GB
Mesa from git 0f8afde7baf2b4764c3832387607021f2d318f6e
After discovering a Mesa bug in my own app; I've managed to isolate it in a
repro.
The demo does the following:
1. Render a triangle with a specific depth pattern to an 8x8 FBO depth texture
(also outputs colour but this will be ignored). We use gl_FragDepth to achieve
this.
2. Use a compute shader to copy the 8x8 depth texture to a GL_R32F. The CS
copies 4 pixels (2x2 blocks) per thread (there will a few out of bound read and
writes that per spec should be handled correctly by GLSL). It basically acts
like a memcpy.
3. Render a triangle to the RenderWindow sampling from that GL_R32F we just
wrote to.
On Windows, it works as expected and produces the following output:
<a href="http://imgur.com/MLWzweG">http://imgur.com/MLWzweG</a>
You can see the 8x8 grid pattern, (the sampling causes the tiling).
However on Mesa, I only get a black triangle.
The sample works as intended if we try to copy colour. I did not research
whether the problem is the GL_R32F destination, or that the source is a depth
texture rather than a colour texture.
The sample should be easy to build and run.
A few tips:
1. There is a "#if 1" in main.cpp. Flip it to 0 so that that step 3 will sample
directly from the depth buffer instead of using the compute shader. It will
produce the desired output (just for reference), though it's grey instead of
red (because of GL specs).
2. Inside the "#if 1", changing instances of texName[1] & dstTexName[1] for
texName[0] & dstTexName[0] will cause the demo to use the colour texture
instead of the depth; which does work as expected.
Oddities:
Comparing Mesa's generated ISA vs CodeXL makes no sense.
CodeXL generates something like this:
image_load v[X:X], v[0:3], s[X:X] dmask:0xf
image_load v[X:X], v[4:7], s[X:X] dmask:0xf
image_load v[X:X], v[8:11], s[X:X] dmask:0xf
image_load v[X:X], v[12:15], s[X:X] dmask:0xf
image_store v[X:X], v[0:3], s[X:X] dmask:0xf unorm glc
image_store v[X:X], v[4:7], s[X:X] dmask:0xf unorm glc
image_store v[X:X], v[8:11], s[X:X] dmask:0xf unorm glc
image_store v[X:X], v[12:15], s[X:X] dmask:0xf unorm glc
That is, both loads and stores reuse the second arguments and they match.
However Mesa generates:
image_load_mip v[X:X], v[0:3], s[X:X] dmask:0xf
image_load_mip v[X:X], v[4:7], s[X:X] dmask:0xf
image_load_mip v[X:X], v[8:11], s[X:X] dmask:0xf
image_load_mip v[X:X], v[12:15], s[X:X] dmask:0xf
image_store v[X:X], v[0:1], s[X:X] dmask:0xf unorm glc
image_store v[X:X], v[34:35], s[X:X] dmask:0xf unorm glc
image_store v[X:X], v[11:12], s[X:X] dmask:0xf unorm glc
image_store v[X:X], v[21:22], s[X:X] dmask:0xf unorm glc
That is, the vectors used for the image_store look totally random; and it
stands out that subtracting these ranges is 1 (i.e. Mesa's 35-34 = 1) when
CodeXL's is always 3. Either the dump is decoding the instructions incorrectly,
the ISA is wrong, or this is a different but wasteful way to do it correctly
(???).
Also Mesa uses image_load_mip whereas CodeXL prefers image_store.
Happy bug hunting</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>