pvr: Fix page faults in occlusion query tests
authorMatt Coster <matt.coster@imgtec.com>
Mon, 15 May 2023 08:07:16 +0000 (09:07 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 30 May 2023 10:53:41 +0000 (10:53 +0000)
This does not fix the tests completely, but does allow them to run to
completion and fail "properly".

Also contains a few trivial bugfixes in the same codepath.

Signed-off-by: Matt Coster <matt.coster@imgtec.com>
Reported-by: James Glanville <james.glanville@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23100>

src/imagination/vulkan/pvr_job_render.c
src/imagination/vulkan/pvr_private.h
src/imagination/vulkan/pvr_query.c
src/imagination/vulkan/pvr_query_compute.c

index 8011eaf..167a5f6 100644 (file)
@@ -1380,7 +1380,13 @@ static void pvr_frag_state_stream_init(struct pvr_render_ctx *ctx,
    stream_ptr += pvr_cmd_length(CR_ISP_DBIAS_BASE);
 
    pvr_csb_pack ((uint64_t *)stream_ptr, CR_ISP_OCLQRY_BASE, value) {
-      value.addr = PVR_DEV_ADDR_INVALID;
+      const struct pvr_sub_cmd_gfx *sub_cmd =
+         container_of(job, const struct pvr_sub_cmd_gfx, job);
+
+      if (sub_cmd->query_pool)
+         value.addr = sub_cmd->query_pool->result_buffer->dev_addr;
+      else
+         value.addr = PVR_DEV_ADDR_INVALID;
    }
    stream_ptr += pvr_cmd_length(CR_ISP_OCLQRY_BASE);
 
index c6ce81c..e074c7a 100644 (file)
@@ -714,7 +714,7 @@ struct pvr_cmd_buffer_state {
    /* Array size of barriers_needed is based on number of sync pipeline
     * stages.
     */
-   uint32_t barriers_needed[4];
+   uint32_t barriers_needed[PVR_NUM_SYNC_PIPELINE_STAGES];
 
    struct pvr_descriptor_state gfx_desc_state;
    struct pvr_descriptor_state compute_desc_state;
index bd71da6..b6d15dc 100644 (file)
@@ -146,9 +146,9 @@ static inline bool pvr_query_is_available(const struct pvr_query_pool *pool,
  * device.
  */
 /* TODO: Handle device loss scenario properly. */
-static bool pvr_wait_for_available(struct pvr_device *device,
-                                   const struct pvr_query_pool *pool,
-                                   uint32_t query_idx)
+static VkResult pvr_wait_for_available(struct pvr_device *device,
+                                       const struct pvr_query_pool *pool,
+                                       uint32_t query_idx)
 {
    const uint64_t abs_timeout =
       os_time_get_absolute_timeout(PVR_WAIT_TIMEOUT * NSEC_PER_SEC);
index 5e7bc44..f9cdb0f 100644 (file)
@@ -701,7 +701,7 @@ VkResult pvr_add_query_program(struct pvr_cmd_buffer *cmd_buffer,
              PVR_COPY_QUERY_POOL_RESULTS_COUNT);
 
       /* Assert if no memory is bound to destination buffer. */
-      assert(buffer->dev_addr.addr == 0);
+      assert(buffer->dev_addr.addr);
 
       addr = buffer->dev_addr;
       addr.addr += query_info->copy_query_results.dst_offset;