radv: Odd lack of implicit host memory invalidation
I ran into an interesting scenario in vkd3d-proton.
See repro in https://github.com/HansKristian-Work/vkd3d-proton/tree/host-mem-invalidation-repro branch.
When running VKD3D_TEST_FILTER=test_queue_wait ./build/tests/d3d12
I get:
d3d12: ======== test_queue_wait begin ========
test_queue_wait:182: Test failed: Got 0xff00ff00, expected 0xffff0000 at (0, 0, 0).
d3d12: ======== test_queue_wait end ==========
GPU: RX 6800 Mesa: 8564a4c5
I cannot reproduce this on amdgpu-pro or NVIDIA.
The bug behavior is fairly bizarre. The test basically boils down to:
- Make one command buffer. It reads a UBO value and emits that to a render target in a full screen primitive.
- The UBO is updated with a green color, command buffer is kicked.
- WaitIdle
- Green result is asserted.
- The UBO is updated with a blue color and kicked again. We still observe green.
The first idea was a sync bug on our end, but I don't see how that can be possible. Host memory is invalidated on submission. The other odd part is how I can make irrelevant changes and still make it work:
- Record two separate command buffers with exact same commands instead. Now test passes.
diff --git a/tests/d3d12_sync.c b/tests/d3d12_sync.c
index c824d88a..96962377 100644
--- a/tests/d3d12_sync.c
+++ b/tests/d3d12_sync.c
@@ -159,7 +159,7 @@ void test_queue_wait(void)
/* Wait() before CPU signal */
update_buffer_data(cb, 0, sizeof(blue), &blue);
queue_wait(queue, fence, 1000);
- exec_command_list(queue, command_list);
+ exec_command_list(queue, command_list2);
queue_signal(queue, fence2, 1);
hr = ID3D12Fence_SetEventOnCompletion(fence2, 1, event);
ok(hr == S_OK, "Failed to set event on completion, hr %#x.\n", hr);
- Capture with RenderDoc. Now test passes ._. For reference, an RDC of the test is: d3d12-test_2021.09.24_12.35_capture_2.rdc
My theory is that host memory is not invalidated properly for resubmitted command lists, but not sure if that even makes sense.