diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 5f3297fef8b..e831750d911 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3128,15 +3128,8 @@ VkResult anv_CreateDevice( &pCreateInfo->pQueueCreateInfos[i]; for (uint32_t j = 0; j < queueCreateInfo->queueCount; j++) { - /* When using legacy contexts, we use I915_EXEC_RENDER but, with - * engine-based contexts, the bottom 6 bits of exec_flags are used - * for the engine ID. - */ - uint32_t exec_flags = device->physical->engine_info ? - device->queue_count : I915_EXEC_RENDER; - result = anv_queue_init(device, &device->queues[device->queue_count], - exec_flags, queueCreateInfo, j); + queueCreateInfo, j); if (result != VK_SUCCESS) goto fail_queues; diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 7ecea5534e3..5323da25ed3 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1387,7 +1387,6 @@ VkResult anv_device_wait(struct anv_device *device, struct anv_bo *bo, int64_t timeout); VkResult anv_queue_init(struct anv_device *device, struct anv_queue *queue, - uint32_t exec_flags, const VkDeviceQueueCreateInfo *pCreateInfo, uint32_t index_in_family); void anv_queue_finish(struct anv_queue *queue); diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c index 078211cb0f3..9178145894a 100644 --- a/src/intel/vulkan/anv_queue.c +++ b/src/intel/vulkan/anv_queue.c @@ -27,6 +27,7 @@ #include "anv_private.h" +#include "i915/anv_queue.h" #include "xe/anv_queue.h" static VkResult @@ -36,7 +37,7 @@ anv_create_engine(struct anv_device *device, { switch (device->info->kmd_type) { case INTEL_KMD_TYPE_I915: - return VK_SUCCESS; + return anv_i915_create_engine(device, queue, pCreateInfo); case INTEL_KMD_TYPE_XE: return anv_xe_create_engine(device, queue, pCreateInfo); default: @@ -51,6 +52,7 @@ anv_destroy_engine(struct anv_queue *queue) struct anv_device *device = queue->device; switch (device->info->kmd_type) { case INTEL_KMD_TYPE_I915: + anv_i915_destroy_engine(device, queue); break; case INTEL_KMD_TYPE_XE: anv_xe_destroy_engine(device, queue); @@ -62,21 +64,20 @@ anv_destroy_engine(struct anv_queue *queue) VkResult anv_queue_init(struct anv_device *device, struct anv_queue *queue, - uint32_t exec_flags, const VkDeviceQueueCreateInfo *pCreateInfo, uint32_t index_in_family) { struct anv_physical_device *pdevice = device->physical; VkResult result; - result = anv_create_engine(device, queue, pCreateInfo); + result = vk_queue_init(&queue->vk, &device->vk, pCreateInfo, + index_in_family); if (result != VK_SUCCESS) return result; - result = vk_queue_init(&queue->vk, &device->vk, pCreateInfo, - index_in_family); + result = anv_create_engine(device, queue, pCreateInfo); if (result != VK_SUCCESS) { - anv_destroy_engine(queue); + vk_queue_finish(&queue->vk); return result; } @@ -97,9 +98,6 @@ anv_queue_init(struct anv_device *device, struct anv_queue *queue, assert(queue->vk.queue_family_index < pdevice->queue.family_count); queue->family = &pdevice->queue.families[queue->vk.queue_family_index]; - if (device->info->kmd_type == INTEL_KMD_TYPE_I915) - queue->exec_flags = exec_flags; - queue->decoder = &device->decoder[queue->vk.queue_family_index]; return VK_SUCCESS; diff --git a/src/intel/vulkan/i915/anv_queue.c b/src/intel/vulkan/i915/anv_queue.c new file mode 100644 index 00000000000..28e02e90466 --- /dev/null +++ b/src/intel/vulkan/i915/anv_queue.c @@ -0,0 +1,72 @@ +/* + * Copyright © 2023 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "i915/anv_queue.h" + +#include "anv_private.h" + +#include "common/i915/intel_engine.h" +#include "common/intel_gem.h" + +#include "i915/anv_device.h" + +#include "drm-uapi/i915_drm.h" + +VkResult +anv_i915_create_engine(struct anv_device *device, + struct anv_queue *queue, + const VkDeviceQueueCreateInfo *pCreateInfo) +{ + struct anv_physical_device *physical = device->physical; + struct anv_queue_family *queue_family = + &physical->queue.families[pCreateInfo->queueFamilyIndex]; + + if (device->physical->engine_info == NULL) { + switch (queue_family->engine_class) { + case INTEL_ENGINE_CLASS_COPY: + queue->exec_flags = I915_EXEC_BLT; + break; + case INTEL_ENGINE_CLASS_RENDER: + queue->exec_flags = I915_EXEC_RENDER; + break; + case INTEL_ENGINE_CLASS_VIDEO: + /* We want VCS0 (with ring1) for HW lacking HEVC on VCS1. */ + queue->exec_flags = I915_EXEC_BSD | I915_EXEC_BSD_RING1; + break; + default: + unreachable("Unsupported legacy engine"); + } + } else { + /* When using the new engine creation uAPI, the exec_flags value is the + * index of the engine in the group specified at GEM context creation. + */ + queue->exec_flags = device->queue_count; + } + + return VK_SUCCESS; +} + +void +anv_i915_destroy_engine(struct anv_device *device, struct anv_queue *queue) +{ + /* NO-OP */ +} diff --git a/src/intel/vulkan/i915/anv_queue.h b/src/intel/vulkan/i915/anv_queue.h new file mode 100644 index 00000000000..ab75cd5b2cb --- /dev/null +++ b/src/intel/vulkan/i915/anv_queue.h @@ -0,0 +1,35 @@ +/* + * Copyright © 2023 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +#include "vulkan/vulkan_core.h" + +struct anv_device; +struct anv_queue; + +VkResult +anv_i915_create_engine(struct anv_device *device, + struct anv_queue *queue, + const VkDeviceQueueCreateInfo *pCreateInfo); +void +anv_i915_destroy_engine(struct anv_device *device, struct anv_queue *queue); diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index 298797c316d..eb2cd4bf5a4 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -137,6 +137,8 @@ libanv_files = files( 'i915/anv_device.c', 'i915/anv_device.h', 'i915/anv_kmd_backend.c', + 'i915/anv_queue.c', + 'i915/anv_queue.h', 'layers/anv_doom64.c', 'layers/anv_hitman3.c', 'layers/anv_android_layer.c', diff --git a/src/intel/vulkan/xe/anv_device.c b/src/intel/vulkan/xe/anv_device.c index d839a54a4f4..598bbe301b0 100644 --- a/src/intel/vulkan/xe/anv_device.c +++ b/src/intel/vulkan/xe/anv_device.c @@ -23,6 +23,7 @@ #include "xe/anv_device.h" #include "anv_private.h" +#include "drm-uapi/gpu_scheduler.h" #include "drm-uapi/xe_drm.h" bool anv_xe_device_destroy_vm(struct anv_device *device) @@ -46,22 +47,6 @@ VkResult anv_xe_device_setup_vm(struct anv_device *device) return VK_SUCCESS; } -enum drm_sched_priority -anv_vk_priority_to_drm_sched_priority(VkQueueGlobalPriorityKHR vk_priority) -{ - switch (vk_priority) { - case VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR: - return DRM_SCHED_PRIORITY_MIN; - case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR: - return DRM_SCHED_PRIORITY_NORMAL; - case VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR: - return DRM_SCHED_PRIORITY_HIGH; - default: - unreachable("Invalid priority"); - return DRM_SCHED_PRIORITY_MIN; - } -} - static VkQueueGlobalPriorityKHR drm_sched_priority_to_vk_priority(enum drm_sched_priority drm_sched_priority) { diff --git a/src/intel/vulkan/xe/anv_device.h b/src/intel/vulkan/xe/anv_device.h index 7cb5568b256..5ed069d727d 100644 --- a/src/intel/vulkan/xe/anv_device.h +++ b/src/intel/vulkan/xe/anv_device.h @@ -27,8 +27,6 @@ #include "vulkan/vulkan_core.h" #include "vk_device.h" -#include "drm-uapi/gpu_scheduler.h" - struct anv_device; struct anv_physical_device; @@ -40,6 +38,3 @@ VkResult anv_xe_physical_device_get_parameters(struct anv_physical_device *device); VkResult anv_xe_physical_device_init_memory_types(struct anv_physical_device *device); - -enum drm_sched_priority -anv_vk_priority_to_drm_sched_priority(VkQueueGlobalPriorityKHR vk_priority); diff --git a/src/intel/vulkan/xe/anv_kmd_backend.c b/src/intel/vulkan/xe/anv_kmd_backend.c index 46c4939e4da..5140254b2de 100644 --- a/src/intel/vulkan/xe/anv_kmd_backend.c +++ b/src/intel/vulkan/xe/anv_kmd_backend.c @@ -24,10 +24,13 @@ #include #include +#include "common/xe/intel_engine.h" + #include "anv_private.h" #include "xe/anv_batch_chain.h" +#include "drm-uapi/gpu_scheduler.h" #include "drm-uapi/xe_drm.h" static uint32_t diff --git a/src/intel/vulkan/xe/anv_queue.c b/src/intel/vulkan/xe/anv_queue.c index 954dddea22e..0506d84fd97 100644 --- a/src/intel/vulkan/xe/anv_queue.c +++ b/src/intel/vulkan/xe/anv_queue.c @@ -32,6 +32,22 @@ #include "drm-uapi/xe_drm.h" #include "drm-uapi/gpu_scheduler.h" +static enum drm_sched_priority +anv_vk_priority_to_drm_sched_priority(VkQueueGlobalPriorityKHR vk_priority) +{ + switch (vk_priority) { + case VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR: + return DRM_SCHED_PRIORITY_MIN; + case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR: + return DRM_SCHED_PRIORITY_NORMAL; + case VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR: + return DRM_SCHED_PRIORITY_HIGH; + default: + unreachable("Invalid priority"); + return DRM_SCHED_PRIORITY_MIN; + } +} + VkResult anv_xe_create_engine(struct anv_device *device, struct anv_queue *queue,