ANV: Bad output from TransformFeedback . Regression from Mesa 21. Something to do with VB+XFB -> VB+XFB dependency?
At work we had a few failing tests involving streamout on newer Intel drivers. They pass with Mesa 21.0.3, but fail with e.g (I didn't try to find the exact commit, but here's one): Mesa 22.0.0-devel (git-1cb5c177).
I made a test that reproduces and doesn't have too much going on: https://github.com/Jonathan-Weinstein/vktest/blob/062b2b5618e8ab31db516f56066cc81e548ac7fb/xfb_pingpong_bug.cpp
This is the gist of what it does:
for (int i = 0; i < 16; ++i) {
if (i != 0) {
PipelineGlobalBarrier(
.srcStages = VB | XFB,
.srcAccess = XFB_WRITE | XFB_COUNTER_WRITE,
.dstStages = VB | XFB,
.dstAccess = VB_READ | XFB_WRITE | XFB_COUNTER_WRITE
);
}
BeginRenderPass(noAttachmentRenderPass);
BindVertexBuffer(bufs[i & 1]);
BindXfbBuffer(bufs[(i & 1) ^ 1]);
BeginXfb(.resumeCounter = NULL);
/* Uses a PSO with rast disabled that is a
vec4 buffer -> vec4 buffer tranfer that rotates each .xy
by pi/16 and adds 1.0f/32 to .z: */
Draw(5);
EndXfb(.pauseCounter = xfbCounterBuf);
EndRenderPass();
}
BindVertexBuffer(bufs[16 & 1]);
PipelineGlobalBarrier(XFB_WRITE -> VB_READ);
// ... draw that uses that VB, no XFB, rast enabled, has color attachment ...
I am fairly certain the necessary barriers are in place and synchronization validation emits no errors.
The last draw should generate an image that looks like this: https://github.com/Jonathan-Weinstein/vktest/blob/062b2b5618e8ab31db516f56066cc81e548ac7fb/expected_xfb_output.png, but on newer ANV drivers the resulting image is not close to that. The final values in bufs[0] are also unexpected; the code will check those, though only the .z component of each vec4. The code can be built and run via:
# only submodule is volk:
git clone --recurse-submodules https://github.com/Jonathan-Weinstein/vktest.git
cd vktest
git pull --recurse-submodules
make
./vktest.out --test=xfb_vb_pingpong
# can optionally pass --gpuindex=%d and --save-failing-images
The code doesn't have a swapchain but is wrapped around renderdoc StartFrameCapture()/EndFrameCapture() calls. If you prefer not to build/run the code, I can provide a .rdc renderdoc capture or a .gfxr gfxreconstruct capture.