diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index 54238584db1..24f8f6a8df9 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -28,14 +28,14 @@ nvk_cmd_buffer_3d_cls(struct nvk_cmd_buffer *cmd) } VkResult -nvk_device_init_context_draw_state(struct nvk_device *dev) +nvk_queue_init_context_draw_state(struct nvk_queue *queue) { - struct nouveau_ws_push *pb = - nouveau_ws_push_new(dev->pdev->dev, NVK_CMD_BUF_SIZE); - if (pb == NULL) - return VK_ERROR_OUT_OF_DEVICE_MEMORY; + struct nvk_device *dev = nvk_queue_device(queue); - struct nv_push *p = P_SPACE(pb, 0x1000); + uint32_t push_data[512]; + struct nv_push push; + nv_push_init(&push, push_data, ARRAY_SIZE(push_data)); + struct nv_push *p = &push; P_MTHD(p, NV9097, SET_OBJECT); P_NV9097_SET_OBJECT(p, { @@ -46,10 +46,8 @@ nvk_device_init_context_draw_state(struct nvk_device *dev) for (uint32_t mme = 0, mme_pos = 0; mme < NVK_MME_COUNT; mme++) { size_t size; uint32_t *dw = nvk_build_mme(dev, mme, &size); - if (dw == NULL) { - nouveau_ws_push_destroy(pb); + if (dw == NULL) return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY); - } assert(size % sizeof(uint32_t) == 0); const uint32_t num_dw = size / sizeof(uint32_t); @@ -310,12 +308,8 @@ nvk_device_init_context_draw_state(struct nvk_device *dev) P_NV9097_SET_VERTEX_STREAM_SUBSTITUTE_A(p, zero_addr >> 32); P_NV9097_SET_VERTEX_STREAM_SUBSTITUTE_B(p, zero_addr); - int ret = nouveau_ws_push_submit(pb, dev->pdev->dev, dev->ctx); - nouveau_ws_push_destroy(pb); - if (ret) - return vk_error(dev, VK_ERROR_INITIALIZATION_FAILED); - - return VK_SUCCESS; + return nvk_queue_submit_simple(queue, push_data, nv_push_dw_count(&push), + NULL /* extra_bo */); } void diff --git a/src/nouveau/vulkan/nvk_device.c b/src/nouveau/vulkan/nvk_device.c index 1442b75abaf..d3d962ed1fc 100644 --- a/src/nouveau/vulkan/nvk_device.c +++ b/src/nouveau/vulkan/nvk_device.c @@ -207,10 +207,6 @@ nvk_CreateDevice(VkPhysicalDevice physicalDevice, if (result != VK_SUCCESS) goto fail_zero_page; - result = nvk_device_init_context_draw_state(device); - if (result != VK_SUCCESS) - goto fail_queue; - result = nvk_device_init_meta(device); if (result != VK_SUCCESS) goto fail_queue; diff --git a/src/nouveau/vulkan/nvk_device.h b/src/nouveau/vulkan/nvk_device.h index cbe4ec128ce..fee3e34b19c 100644 --- a/src/nouveau/vulkan/nvk_device.h +++ b/src/nouveau/vulkan/nvk_device.h @@ -57,8 +57,6 @@ nvk_device_physical(struct nvk_device *device) return (struct nvk_physical_device *)device->vk.physical; } -VkResult nvk_device_init_context_draw_state(struct nvk_device *dev); - VkResult nvk_device_init_meta(struct nvk_device *dev); void nvk_device_finish_meta(struct nvk_device *dev); diff --git a/src/nouveau/vulkan/nvk_queue.c b/src/nouveau/vulkan/nvk_queue.c index cfa8b0ee6a2..dd5a55e2842 100644 --- a/src/nouveau/vulkan/nvk_queue.c +++ b/src/nouveau/vulkan/nvk_queue.c @@ -257,8 +257,14 @@ nvk_queue_init(struct nvk_device *dev, struct nvk_queue *queue, } nouveau_ws_bo_unmap(queue->empty_push, empty_push_map); + result = nvk_queue_init_context_draw_state(queue); + if (result != VK_SUCCESS) + goto fail_empty_push; + return VK_SUCCESS; +fail_empty_push: + nouveau_ws_bo_destroy(queue->empty_push); fail_init: vk_queue_finish(&queue->vk); diff --git a/src/nouveau/vulkan/nvk_queue.h b/src/nouveau/vulkan/nvk_queue.h index dc2e30d0352..5236f5c6308 100644 --- a/src/nouveau/vulkan/nvk_queue.h +++ b/src/nouveau/vulkan/nvk_queue.h @@ -56,6 +56,8 @@ 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_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);