Skip to content

anv: rework queries writes to ensure ordering memory writes

We use a mix of MI & PIPE_CONTROL commands to write our queries' data (results & availability). Those commands' memory write order is not guaranteed with regard to their order in the command stream, unless CS stalls are inserted between them. This is problematic for 2 reasons :

  1. We copy results from the device using MI commands even though the values are generated from PIPE_CONTROL, meaning we could copy unlanded values into the results and then copy the availability that is inconsistent with the values.

  2. We allow the user to poll on the availability values of the query pool from the CPU. If the availability lands in memory before the values then we could return invalid values.

This change does 3 things to address this problem :

  • To address 1:

    • We try to use only MI commands as much as possible. For example we switch occlusion queries to read values using MI commands, so that we don't have to synchronize PIPE_CONTROL & MI writes.

    • For the timestamp queries we apply a CS stall before copying the results on the device. This is because we can only do timestamp writes using PIPE_CONTROL (MI commands cannot atomically snapshot 64bit registers).

  • To address 2:

    • We use either PIPE_CONTROL or MI commands to write both queries values and availability, so that the ordering of the memory writes guarantees that if availability is visible, results are also visible.

Signed-off-by: Lionel Landwerlin lionel.g.landwerlin@intel.com Cc: mesa-stable@lists.freedesktop.org

Edited by Lionel Landwerlin

Merge request reports