anv/sparse: replace device->using_sparse with device->num_sparse_resources
The device->using_sparse variable is only used at cmd_buffer_barrier() to decide if we need to apply the heavier-weight flushes that are only applicable to sparse resources. The big problem here is that we need to apply the flushes to the non-image and non-buffer memory barriers, so we were trying to limit those only to applications that ever submit a sparse resource to the sparse queue. The reason why we were applying this only to devices that ever submitted sparse resources is that dxvk games have this thing where during startup they create and then delete tiny sparse resources, so switching device->using_sparse to true at resource creation would make basically every dxvk game start applying the heavier-weight workaround. The problem with all that is that even if an application creates a sparse resource but doesn't ever bind them, the resource should still behave as an unbound resource (because they are bound with a NULL bind), so the flushes affecting them should happen. This case is exercised by vkd3d-proton/test_buffer_feedback_instructions_sm51. In order to satisfy all the above cases and only really apply the heavier-weight flushes to applications actually using sparse resources, let's just count the number of sparse resources that currently exist and then apply the workaround only if it's not zero. That covers the dxvk case since dxvk deletes the resources as soon as they create, so num_sparse_resources goes back to 0. Testcase: vkd3d-proton/test_buffer_feedback_instructions_sm51 Closes: mesa/mesa#10960 Fixes: 6368c144 ("anv/sparse: add the initial code for Sparse Resources") Reviewed-by:Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by:
Paulo Zanoni <paulo.r.zanoni@intel.com> Part-of: <mesa/mesa!28724> (cherry picked from commit 95dc34cd)
- .pick_status.json 1 addition, 1 deletion.pick_status.json
- src/intel/vulkan/anv_batch_chain.c 0 additions, 2 deletionssrc/intel/vulkan/anv_batch_chain.c
- src/intel/vulkan/anv_private.h 6 additions, 6 deletionssrc/intel/vulkan/anv_private.h
- src/intel/vulkan/anv_sparse.c 3 additions, 0 deletionssrc/intel/vulkan/anv_sparse.c
- src/intel/vulkan/genX_cmd_buffer.c 2 additions, 1 deletionsrc/intel/vulkan/genX_cmd_buffer.c