From: Matt Coster Date: Fri, 28 Oct 2022 16:07:09 +0000 (+0100) Subject: pvr: debug: Add option to zero-alloc all buffer objects X-Git-Tag: upstream/23.3.3~16121 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b530a6b05569b37077265b1e021654674a8c678f;p=platform%2Fupstream%2Fmesa.git pvr: debug: Add option to zero-alloc all buffer objects 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 Reviewed-by: Karmjit Mahil Part-of: --- diff --git a/src/imagination/common/pvr_debug.c b/src/imagination/common/pvr_debug.c index 94f1985825c..829e8f570db 100644 --- a/src/imagination/common/pvr_debug.c +++ b/src/imagination/common/pvr_debug.c @@ -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); + } } diff --git a/src/imagination/common/pvr_debug.h b/src/imagination/common/pvr_debug.h index 9050be46ac8..c2378cc01ae 100644 --- a/src/imagination/common/pvr_debug.h +++ b/src/imagination/common/pvr_debug.h @@ -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); diff --git a/src/imagination/vulkan/pvr_bo.c b/src/imagination/vulkan/pvr_bo.c index 682491f1526..2e4cdc57e9d 100644 --- a/src/imagination/vulkan/pvr_bo.c +++ b/src/imagination/vulkan/pvr_bo.c @@ -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; diff --git a/src/imagination/vulkan/pvr_csb.c b/src/imagination/vulkan/pvr_csb.c index 2ad014e7add..bb5593616cc 100644 --- a/src/imagination/vulkan/pvr_csb.c +++ b/src/imagination/vulkan/pvr_csb.c @@ -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);