From 16bdefa53011f09d18cea66a2d34d3ad07724bcd Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 30 Jan 2023 20:12:00 -0600 Subject: [PATCH] nvk: Rework nvk_queue_submit_simple() This is a few changes rolled into one: 1. Add a sync flag to force a stall before returning 2. Re-order dw and push_dw_count to put the count first 3. Take an array of extra BOs instead of just one Part-of: --- src/nouveau/vulkan/nvk_cmd_draw.c | 4 ++-- src/nouveau/vulkan/nvk_device_memory.c | 4 ++-- src/nouveau/vulkan/nvk_queue.c | 15 +++++++++------ src/nouveau/vulkan/nvk_queue.h | 11 +++++++---- src/nouveau/vulkan/nvk_queue_drm_nouveau.c | 10 +++++----- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index 7a1c4e62083..74bd6f27a84 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -308,8 +308,8 @@ nvk_queue_init_context_draw_state(struct nvk_queue *queue) P_NV9097_SET_VERTEX_STREAM_SUBSTITUTE_A(p, zero_addr >> 32); P_NV9097_SET_VERTEX_STREAM_SUBSTITUTE_B(p, zero_addr); - return nvk_queue_submit_simple(queue, push_data, nv_push_dw_count(&push), - NULL /* extra_bo */); + return nvk_queue_submit_simple(queue, nv_push_dw_count(&push), push_data, + 0, NULL, false /* sync */); } void diff --git a/src/nouveau/vulkan/nvk_device_memory.c b/src/nouveau/vulkan/nvk_device_memory.c index 105679cb034..ad7b830e9d0 100644 --- a/src/nouveau/vulkan/nvk_device_memory.c +++ b/src/nouveau/vulkan/nvk_device_memory.c @@ -63,8 +63,8 @@ zero_vram(struct nvk_device *dev, struct nouveau_ws_bo *bo) P_NV902D_RENDER_SOLID_PRIM_POINT_SET_X(p, 1, extra / 4); P_NV902D_RENDER_SOLID_PRIM_POINT_Y(p, 1, height); - return nvk_queue_submit_simple(&dev->queue, push_data, - nv_push_dw_count(&push), bo); + return nvk_queue_submit_simple(&dev->queue, nv_push_dw_count(&push), + push_data, 1, &bo, false /* sync */); } VkResult diff --git a/src/nouveau/vulkan/nvk_queue.c b/src/nouveau/vulkan/nvk_queue.c index a7c1fa21e73..74fc9837a9c 100644 --- a/src/nouveau/vulkan/nvk_queue.c +++ b/src/nouveau/vulkan/nvk_queue.c @@ -335,8 +335,10 @@ nvk_queue_finish(struct nvk_device *dev, struct nvk_queue *queue) VkResult nvk_queue_submit_simple(struct nvk_queue *queue, - const uint32_t *dw, uint32_t dw_count, - struct nouveau_ws_bo *extra_bo) + uint32_t dw_count, const uint32_t *dw, + uint32_t extra_bo_count, + struct nouveau_ws_bo **extra_bos, + bool sync) { struct nvk_device *dev = nvk_queue_device(queue); struct nouveau_ws_bo *push_bo; @@ -354,12 +356,13 @@ nvk_queue_submit_simple(struct nvk_queue *queue, memcpy(push_map, dw, dw_count * 4); - const bool sync = dev->pdev->dev->debug_flags & NVK_DEBUG_PUSH_SYNC; + const bool debug_sync = dev->pdev->dev->debug_flags & NVK_DEBUG_PUSH_SYNC; - result = nvk_queue_submit_simple_drm_nouveau(queue, push_bo, dw_count, - extra_bo, sync); + result = nvk_queue_submit_simple_drm_nouveau(queue, dw_count, push_bo, + extra_bo_count, extra_bos, + sync || debug_sync); - if ((sync && result != VK_SUCCESS) || + if ((debug_sync && result != VK_SUCCESS) || (dev->pdev->dev->debug_flags & NVK_DEBUG_PUSH_DUMP)) { struct nv_push push = { .start = (uint32_t *)dw, diff --git a/src/nouveau/vulkan/nvk_queue.h b/src/nouveau/vulkan/nvk_queue.h index c8d0be13187..4df7abcdcf4 100644 --- a/src/nouveau/vulkan/nvk_queue.h +++ b/src/nouveau/vulkan/nvk_queue.h @@ -60,13 +60,16 @@ void nvk_queue_finish(struct nvk_device *dev, struct nvk_queue *queue); VkResult nvk_queue_init_context_draw_state(struct nvk_queue *queue); VkResult nvk_queue_submit_simple(struct nvk_queue *queue, - const uint32_t *dw, uint32_t dw_count, - struct nouveau_ws_bo *extra_bo); + uint32_t dw_count, const uint32_t *dw, + uint32_t extra_bo_count, + struct nouveau_ws_bo **extra_bos, + bool sync); VkResult nvk_queue_submit_simple_drm_nouveau(struct nvk_queue *queue, - struct nouveau_ws_bo *push_bo, uint32_t push_dw_count, - struct nouveau_ws_bo *extra_bo, + struct nouveau_ws_bo *push_bo, + uint32_t extra_bo_count, + struct nouveau_ws_bo **extra_bos, bool sync); VkResult nvk_queue_submit_drm_nouveau(struct nvk_queue *queue, diff --git a/src/nouveau/vulkan/nvk_queue_drm_nouveau.c b/src/nouveau/vulkan/nvk_queue_drm_nouveau.c index 3e710de9b01..1a1a1691ac6 100644 --- a/src/nouveau/vulkan/nvk_queue_drm_nouveau.c +++ b/src/nouveau/vulkan/nvk_queue_drm_nouveau.c @@ -112,9 +112,10 @@ push_submit(struct push_builder *pb, struct nvk_queue *queue, bool sync) VkResult nvk_queue_submit_simple_drm_nouveau(struct nvk_queue *queue, - struct nouveau_ws_bo *push_bo, uint32_t push_dw_count, - struct nouveau_ws_bo *extra_bo, + struct nouveau_ws_bo *push_bo, + uint32_t extra_bo_count, + struct nouveau_ws_bo **extra_bos, bool sync) { struct nvk_device *dev = nvk_queue_device(queue); @@ -123,9 +124,8 @@ nvk_queue_submit_simple_drm_nouveau(struct nvk_queue *queue, push_builder_init(dev, &pb); push_add_push(&pb, push_bo, 0, push_dw_count); - - if (extra_bo) - push_add_bo(&pb, extra_bo, NOUVEAU_WS_BO_RDWR); + for (uint32_t i = 0; i < extra_bo_count; i++) + push_add_bo(&pb, extra_bos[i], NOUVEAU_WS_BO_RDWR); return push_submit(&pb, queue, sync); }