From b660d064c2f64f9ec6453709691add600274b207 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 30 Jan 2023 20:11:58 -0600 Subject: [PATCH] nvk: Add an nvk_queue_submit_simple helper Part-of: --- src/nouveau/vulkan/nvk_queue.c | 27 ++++++++++++++++++++++ src/nouveau/vulkan/nvk_queue.h | 9 ++++++++ src/nouveau/vulkan/nvk_queue_drm_nouveau.c | 19 +++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/src/nouveau/vulkan/nvk_queue.c b/src/nouveau/vulkan/nvk_queue.c index 82146b25082..cfa8b0ee6a2 100644 --- a/src/nouveau/vulkan/nvk_queue.c +++ b/src/nouveau/vulkan/nvk_queue.c @@ -272,3 +272,30 @@ nvk_queue_finish(struct nvk_device *dev, struct nvk_queue *queue) nouveau_ws_bo_destroy(queue->empty_push); vk_queue_finish(&queue->vk); } + +VkResult +nvk_queue_submit_simple(struct nvk_queue *queue, + const uint32_t *dw, uint32_t dw_count, + struct nouveau_ws_bo *extra_bo) +{ + struct nvk_device *dev = nvk_queue_device(queue); + struct nouveau_ws_bo *push_bo; + VkResult result; + + void *push_map; + push_bo = nouveau_ws_bo_new_mapped(dev->pdev->dev, dw_count * 4, 0, + NOUVEAU_WS_BO_GART | NOUVEAU_WS_BO_MAP, + NOUVEAU_WS_BO_WR, &push_map); + if (push_bo == NULL) + return vk_error(queue, VK_ERROR_OUT_OF_DEVICE_MEMORY); + + memcpy(push_map, dw, dw_count * 4); + + result = nvk_queue_submit_simple_drm_nouveau(queue, push_bo, dw_count, + extra_bo); + + nouveau_ws_bo_unmap(push_bo, push_map); + nouveau_ws_bo_destroy(push_bo); + + return result; +} diff --git a/src/nouveau/vulkan/nvk_queue.h b/src/nouveau/vulkan/nvk_queue.h index ca9d142a20a..dc2e30d0352 100644 --- a/src/nouveau/vulkan/nvk_queue.h +++ b/src/nouveau/vulkan/nvk_queue.h @@ -56,6 +56,15 @@ VkResult nvk_queue_init(struct nvk_device *dev, struct nvk_queue *queue, void 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); + +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); + VkResult nvk_queue_submit_drm_nouveau(struct vk_queue *vkqueue, struct vk_queue_submit *submit); diff --git a/src/nouveau/vulkan/nvk_queue_drm_nouveau.c b/src/nouveau/vulkan/nvk_queue_drm_nouveau.c index d5b01622814..9cbb93c84be 100644 --- a/src/nouveau/vulkan/nvk_queue_drm_nouveau.c +++ b/src/nouveau/vulkan/nvk_queue_drm_nouveau.c @@ -107,6 +107,25 @@ push_submit(struct push_builder *pb, struct nvk_queue *queue) return VK_SUCCESS; } +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 nvk_device *dev = nvk_queue_device(queue); + + struct push_builder pb; + 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); + + return push_submit(&pb, queue); +} + static void push_add_queue_state(struct push_builder *pb, struct nvk_queue_state *qs) {