On Wed Mar 22 17:28:23 2023 +0000, Stefan Dösinger wrote:
Hmm, do we need a barrier after every draw, even if nothing else is done in between? Do we need a barrier after every vkCmdCopyImage? I always had the assumption that this is not the case - barriers are needed if you switch between different operations or pipelines, but not when doing more of the same. I'll re-read the Vulkan docs with this question in mind...
The validation layer agrees with you (VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT):
SYNC-HAZARD-WRITE-AFTER-WRITE(ERROR / SPEC): msgNum: 1544472022 - Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0x4306440000001c3c, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x5c0ec5d6 | vkCmdCopyImage: Hazard WRITE_AFTER_WRITE for dstImage VkImage 0x4306440000001c3c[], region 0. Access info (usage: SYNC_COPY_TRANSFER_WRITE, prior_usage: SYNC_COPY_TRANSFER_WRITE, write_barriers: 0, command: vkCmdCopyImage, seq_no: 449, reset_no: 1).
Now investigating the background behind the two consecutive copy calls I think there is some odd game behavior:
``` 08e4:trace:d3d11:d3d11_device_context_CopySubresourceRegion iface 00000000007E01D8, dst_resource 00007FF9AFE68B20, dst_subresource_idx 0, dst_x 0, dst_y 0, dst_z 0, src_resource 00007FF9AFE68B90, src_subresource_idx 0, src_box 0000000000000000. 08e4:trace:d3d11:d3d11_texture2d_GetType iface 00007FF9AFE68B20, resource_dimension 0000000023E3F84C. 08e4:trace:d3d11:d3d11_texture2d_GetType iface 00007FF9AFE68B90, resource_dimension 0000000023E3F84C. 08e4:trace:d3d11:d3d11_device_context_CopySubresourceRegion iface 00000000007E01D8, dst_resource 00007FF9AFE68B20, dst_subresource_idx 0, dst_x 0, dst_y 0, dst_z 0, src_resource 00007FF9AFE68B90, src_subresource_idx 0, src_box 0000000000000000. 08e4:trace:d3d11:d3d11_texture2d_GetType iface 00007FF9AFE68B20, resource_dimension 0000000023E3F84C. 08e4:trace:d3d11:d3d11_texture2d_GetType iface 00007FF9AFE68B90, resource_dimension 0000000023E3F84C. SYNC-HAZARD-WRITE-AFTER-WRITE(ERROR / SPEC): ... ```
It is doing the same copy twice, without any other d3d11 calls in between. The source texture might be mapped and modified in the meantime, but that would be illegal afaiu. So I am probably trying to optimize around a game bug here.