pvr: debug: Add option to zero-alloc all buffer objects
authorMatt Coster <matt.coster@imgtec.com>
Fri, 28 Oct 2022 16:07:09 +0000 (17:07 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 1 Dec 2022 15:05:59 +0000 (15:05 +0000)
This is designed for use by the control stream dump debug option, but
can also be used any time deterministic buffer state is desired.

Signed-off-by: Matt Coster <matt.coster@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20040>

src/imagination/common/pvr_debug.c
src/imagination/common/pvr_debug.h
src/imagination/vulkan/pvr_bo.c
src/imagination/vulkan/pvr_csb.c

index 94f1985825c2154108294c7c06d4fab5f7fcf5aa..829e8f570dbf14b896f9b509e89af344c26f24e1 100644 (file)
@@ -34,6 +34,8 @@ static const struct debug_named_value debug_control[] = {
      "Dump the contents of the control stream buffer on every job submit." },
    { "bo_track", PVR_DEBUG_TRACK_BOS,
      "Track all buffer objects with at least one reference." },
+   { "bo_zero", PVR_DEBUG_ZERO_BOS,
+     "Zero all buffer objects at allocation to make them deterministic." },
    DEBUG_NAMED_VALUE_END
 };
 /* clang-format on */
@@ -50,6 +52,8 @@ void pvr_process_debug_variable(void)
     * implies another it should be set here.
     */
 
-   if (PVR_IS_DEBUG_SET(DUMP_CONTROL_STREAM))
+   if (PVR_IS_DEBUG_SET(DUMP_CONTROL_STREAM)) {
       PVR_DEBUG_SET(TRACK_BOS);
+      PVR_DEBUG_SET(ZERO_BOS);
+   }
 }
index 9050be46ac8478c56a5bf8ebfb47dee1cfa69880..c2378cc01ae9362fa6d52c7741ef4d52cd5fef21 100644 (file)
@@ -36,6 +36,7 @@ extern uint32_t PVR_DEBUG;
 
 #define PVR_DEBUG_DUMP_CONTROL_STREAM BITFIELD_BIT(0)
 #define PVR_DEBUG_TRACK_BOS BITFIELD_BIT(1)
+#define PVR_DEBUG_ZERO_BOS BITFIELD_BIT(2)
 
 void pvr_process_debug_variable(void);
 
index 682491f1526880a88bb566fb032026206b335416..2e4cdc57e9db863526f420ca14768c1eb3fcd54e 100644 (file)
@@ -342,11 +342,13 @@ VkResult pvr_bo_alloc(struct pvr_device *device,
                       uint64_t flags,
                       struct pvr_bo **const pvr_bo_out)
 {
-   const uint32_t ws_flags = pvr_bo_alloc_to_winsys_flags(flags);
    struct pvr_bo *pvr_bo;
    pvr_dev_addr_t addr;
    VkResult result;
 
+   if (PVR_IS_DEBUG_SET(ZERO_BOS))
+      flags |= PVR_BO_ALLOC_FLAG_ZERO_ON_ALLOC;
+
    pvr_bo = pvr_bo_alloc_bo(device);
    if (!pvr_bo)
       return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -355,7 +357,7 @@ VkResult pvr_bo_alloc(struct pvr_device *device,
                                            size,
                                            alignment,
                                            PVR_WINSYS_BO_TYPE_GPU,
-                                           ws_flags,
+                                           pvr_bo_alloc_to_winsys_flags(flags),
                                            &pvr_bo->bo);
    if (result != VK_SUCCESS)
       goto err_free_bo;
index 2ad014e7addac9bd509e9e94adf6b3fc06e72d6f..bb5593616ccea2f63541e1b22c57c5c204f38347 100644 (file)
@@ -133,17 +133,9 @@ static bool pvr_csb_buffer_extend(struct pvr_csb *csb)
                                      sizeof(uint32_t);
    const uint32_t cache_line_size =
       rogue_get_slc_cache_line_size(&csb->device->pdevice->dev_info);
-   uint64_t alloc_flags = PVR_BO_ALLOC_FLAG_CPU_MAPPED;
    struct pvr_bo *pvr_bo;
    VkResult result;
 
-   /* If we're dumping the control stream, ensure the buffer is zeroed to make
-    * the contents deterministic. This keeps valgrind happy and makes for
-    * cleaner dump output.
-    */
-   if (PVR_IS_DEBUG_SET(DUMP_CONTROL_STREAM))
-      alloc_flags |= PVR_BO_ALLOC_FLAG_ZERO_ON_ALLOC;
-
    /* Make sure extra space allocated for stream links is sufficient for both
     * stream types.
     */
@@ -156,7 +148,7 @@ static bool pvr_csb_buffer_extend(struct pvr_csb *csb)
                          csb->device->heaps.general_heap,
                          PVR_CMD_BUFFER_CSB_BO_SIZE,
                          cache_line_size,
-                         alloc_flags,
+                         PVR_BO_ALLOC_FLAG_CPU_MAPPED,
                          &pvr_bo);
    if (result != VK_SUCCESS) {
       vk_error(csb->device, result);