mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 19:40:10 +01:00
tu: Move queue-related code to a new file
We will be expanding this shortly, as we move device state over to queue state. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32165>
This commit is contained in:
parent
6115cf93b0
commit
d8c9856e75
12 changed files with 151 additions and 98 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "tu_device.h"
|
||||
#include "tu_entrypoints.h"
|
||||
#include "tu_queue.h"
|
||||
#include "tu_rmv.h"
|
||||
#include "vk_common_entrypoints.h"
|
||||
#include "wsi_common_entrypoints.h"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ libtu_files = files(
|
|||
'tu_pipeline.cc',
|
||||
'tu_sampler.cc',
|
||||
'tu_query_pool.cc',
|
||||
'tu_queue.cc',
|
||||
'tu_rmv.cc',
|
||||
'tu_shader.cc',
|
||||
'tu_suballoc.cc',
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "tu_dynamic_rendering.h"
|
||||
#include "tu_image.h"
|
||||
#include "tu_pass.h"
|
||||
#include "tu_queue.h"
|
||||
#include "tu_query_pool.h"
|
||||
#include "tu_rmv.h"
|
||||
#include "tu_tracepoints.h"
|
||||
|
|
@ -1650,7 +1651,7 @@ static const VkQueueFamilyProperties tu_queue_family_properties = {
|
|||
.minImageTransferGranularity = { 1, 1, 1 },
|
||||
};
|
||||
|
||||
static void
|
||||
void
|
||||
tu_physical_device_get_global_priority_properties(const struct tu_physical_device *pdevice,
|
||||
VkQueueFamilyGlobalPriorityPropertiesKHR *props)
|
||||
{
|
||||
|
|
@ -1674,41 +1675,6 @@ tu_physical_device_get_global_priority_properties(const struct tu_physical_devic
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
tu_physical_device_get_submitqueue_priority(const struct tu_physical_device *pdevice,
|
||||
VkQueueGlobalPriorityKHR global_priority,
|
||||
bool global_priority_query)
|
||||
{
|
||||
if (global_priority_query) {
|
||||
VkQueueFamilyGlobalPriorityPropertiesKHR props;
|
||||
tu_physical_device_get_global_priority_properties(pdevice, &props);
|
||||
|
||||
bool valid = false;
|
||||
for (uint32_t i = 0; i < props.priorityCount; i++) {
|
||||
if (props.priorities[i] == global_priority) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Valid values are from 0 to (pdevice->submitqueue_priority_count - 1),
|
||||
* with 0 being the highest priority. This matches what freedreno does.
|
||||
*/
|
||||
int priority;
|
||||
if (global_priority == VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR)
|
||||
priority = pdevice->submitqueue_priority_count / 2;
|
||||
else if (global_priority < VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR)
|
||||
priority = pdevice->submitqueue_priority_count - 1;
|
||||
else
|
||||
priority = 0;
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
tu_GetPhysicalDeviceQueueFamilyProperties2(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
|
|
@ -1859,53 +1825,6 @@ tu_GetPhysicalDeviceFragmentShadingRatesKHR(
|
|||
return vk_outarray_status(&out);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
tu_queue_init(struct tu_device *device,
|
||||
struct tu_queue *queue,
|
||||
int idx,
|
||||
const VkDeviceQueueCreateInfo *create_info,
|
||||
bool global_priority_query)
|
||||
{
|
||||
const VkDeviceQueueGlobalPriorityCreateInfoKHR *priority_info =
|
||||
vk_find_struct_const(create_info->pNext,
|
||||
DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR);
|
||||
const VkQueueGlobalPriorityKHR global_priority = priority_info ?
|
||||
priority_info->globalPriority :
|
||||
(TU_DEBUG(HIPRIO) ? VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR :
|
||||
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR);
|
||||
|
||||
const int priority = tu_physical_device_get_submitqueue_priority(
|
||||
device->physical_device, global_priority, global_priority_query);
|
||||
if (priority < 0) {
|
||||
return vk_startup_errorf(device->instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"invalid global priority");
|
||||
}
|
||||
|
||||
VkResult result = vk_queue_init(&queue->vk, &device->vk, create_info, idx);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
queue->device = device;
|
||||
queue->priority = priority;
|
||||
queue->vk.driver_submit = tu_queue_submit;
|
||||
|
||||
int ret = tu_drm_submitqueue_new(device, priority, &queue->msm_queue_id);
|
||||
if (ret)
|
||||
return vk_startup_errorf(device->instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"submitqueue create failed");
|
||||
|
||||
queue->fence = -1;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
tu_queue_finish(struct tu_queue *queue)
|
||||
{
|
||||
vk_queue_finish(&queue->vk);
|
||||
tu_drm_submitqueue_close(queue->device, queue->msm_queue_id);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
tu_device_ticks_to_ns(struct tu_device *dev, uint64_t ts)
|
||||
{
|
||||
|
|
@ -2533,8 +2452,7 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
device->queue_count[qfi] = queue_create->queueCount;
|
||||
|
||||
for (unsigned q = 0; q < queue_create->queueCount; q++) {
|
||||
result = tu_queue_init(device, &device->queues[qfi][q], q, queue_create,
|
||||
device->vk.enabled_features.globalPriorityQuery);
|
||||
result = tu_queue_init(device, &device->queues[qfi][q], q, queue_create);
|
||||
if (result != VK_SUCCESS) {
|
||||
device->queue_count[qfi] = q;
|
||||
goto fail_queues;
|
||||
|
|
|
|||
|
|
@ -204,19 +204,6 @@ struct tu_instance
|
|||
VK_DEFINE_HANDLE_CASTS(tu_instance, vk.base, VkInstance,
|
||||
VK_OBJECT_TYPE_INSTANCE)
|
||||
|
||||
struct tu_queue
|
||||
{
|
||||
struct vk_queue vk;
|
||||
|
||||
struct tu_device *device;
|
||||
|
||||
uint32_t msm_queue_id;
|
||||
uint32_t priority;
|
||||
|
||||
int fence; /* timestamp/fence of the last queue submission */
|
||||
};
|
||||
VK_DEFINE_HANDLE_CASTS(tu_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE)
|
||||
|
||||
/* This struct defines the layout of the global_bo */
|
||||
struct tu6_global
|
||||
{
|
||||
|
|
@ -280,6 +267,7 @@ struct tu_pvtmem_bo {
|
|||
};
|
||||
|
||||
struct tu_virtio_device;
|
||||
struct tu_queue;
|
||||
|
||||
struct tu_device
|
||||
{
|
||||
|
|
@ -502,6 +490,10 @@ VkResult
|
|||
tu_physical_device_init(struct tu_physical_device *device,
|
||||
struct tu_instance *instance);
|
||||
|
||||
void
|
||||
tu_physical_device_get_global_priority_properties(const struct tu_physical_device *pdevice,
|
||||
VkQueueFamilyGlobalPriorityPropertiesKHR *props);
|
||||
|
||||
uint64_t
|
||||
tu_device_ticks_to_ns(struct tu_device *dev, uint64_t ts);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "tu_device.h"
|
||||
#include "tu_knl.h"
|
||||
#include "tu_queue.h"
|
||||
#include "tu_rmv.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "tu_knl_drm.h"
|
||||
#include "tu_device.h"
|
||||
#include "tu_queue.h"
|
||||
#include "tu_rmv.h"
|
||||
|
||||
VkResult
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "tu_device.h"
|
||||
#include "tu_dynamic_rendering.h"
|
||||
#include "tu_knl_drm.h"
|
||||
#include "tu_queue.h"
|
||||
#include "tu_rmv.h"
|
||||
#include "redump.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "tu_device.h"
|
||||
#include "tu_dynamic_rendering.h"
|
||||
#include "tu_knl_drm.h"
|
||||
#include "tu_queue.h"
|
||||
|
||||
#include "virglrenderer_hw.h"
|
||||
#include "msm_proto.h"
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "tu_cs.h"
|
||||
#include "tu_device.h"
|
||||
#include "tu_dynamic_rendering.h"
|
||||
#include "tu_queue.h"
|
||||
#include "tu_rmv.h"
|
||||
|
||||
/* ION_HEAP(ION_SYSTEM_HEAP_ID) */
|
||||
|
|
|
|||
98
src/freedreno/vulkan/tu_queue.cc
Normal file
98
src/freedreno/vulkan/tu_queue.cc
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright © 2016 Red Hat.
|
||||
* Copyright © 2016 Bas Nieuwenhuizen
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* based in part on anv driver which is:
|
||||
* Copyright © 2015 Intel Corporation
|
||||
*/
|
||||
|
||||
#include "tu_queue.h"
|
||||
|
||||
#include "tu_knl.h"
|
||||
#include "tu_device.h"
|
||||
|
||||
#include "vk_util.h"
|
||||
|
||||
static int
|
||||
tu_get_submitqueue_priority(const struct tu_physical_device *pdevice,
|
||||
VkQueueGlobalPriorityKHR global_priority,
|
||||
bool global_priority_query)
|
||||
{
|
||||
if (global_priority_query) {
|
||||
VkQueueFamilyGlobalPriorityPropertiesKHR props;
|
||||
tu_physical_device_get_global_priority_properties(pdevice, &props);
|
||||
|
||||
bool valid = false;
|
||||
for (uint32_t i = 0; i < props.priorityCount; i++) {
|
||||
if (props.priorities[i] == global_priority) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Valid values are from 0 to (pdevice->submitqueue_priority_count - 1),
|
||||
* with 0 being the highest priority. This matches what freedreno does.
|
||||
*/
|
||||
int priority;
|
||||
if (global_priority == VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR)
|
||||
priority = pdevice->submitqueue_priority_count / 2;
|
||||
else if (global_priority < VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR)
|
||||
priority = pdevice->submitqueue_priority_count - 1;
|
||||
else
|
||||
priority = 0;
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
VkResult
|
||||
tu_queue_init(struct tu_device *device,
|
||||
struct tu_queue *queue,
|
||||
int idx,
|
||||
const VkDeviceQueueCreateInfo *create_info)
|
||||
{
|
||||
const VkDeviceQueueGlobalPriorityCreateInfoKHR *priority_info =
|
||||
vk_find_struct_const(create_info->pNext,
|
||||
DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR);
|
||||
const VkQueueGlobalPriorityKHR global_priority = priority_info ?
|
||||
priority_info->globalPriority :
|
||||
(TU_DEBUG(HIPRIO) ? VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR :
|
||||
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR);
|
||||
|
||||
const int priority = tu_get_submitqueue_priority(
|
||||
device->physical_device, global_priority,
|
||||
device->vk.enabled_features.globalPriorityQuery);
|
||||
if (priority < 0) {
|
||||
return vk_startup_errorf(device->instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"invalid global priority");
|
||||
}
|
||||
|
||||
VkResult result = vk_queue_init(&queue->vk, &device->vk, create_info, idx);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
queue->device = device;
|
||||
queue->priority = priority;
|
||||
queue->vk.driver_submit = tu_queue_submit;
|
||||
|
||||
int ret = tu_drm_submitqueue_new(device, priority, &queue->msm_queue_id);
|
||||
if (ret)
|
||||
return vk_startup_errorf(device->instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"submitqueue create failed");
|
||||
|
||||
queue->fence = -1;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
tu_queue_finish(struct tu_queue *queue)
|
||||
{
|
||||
vk_queue_finish(&queue->vk);
|
||||
tu_drm_submitqueue_close(queue->device, queue->msm_queue_id);
|
||||
}
|
||||
|
||||
37
src/freedreno/vulkan/tu_queue.h
Normal file
37
src/freedreno/vulkan/tu_queue.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright © 2016 Red Hat.
|
||||
* Copyright © 2016 Bas Nieuwenhuizen
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* based in part on anv driver which is:
|
||||
* Copyright © 2015 Intel Corporation
|
||||
*/
|
||||
|
||||
#ifndef TU_QUEUE_H
|
||||
#define TU_QUEUE_H
|
||||
|
||||
#include "tu_common.h"
|
||||
|
||||
struct tu_queue
|
||||
{
|
||||
struct vk_queue vk;
|
||||
|
||||
struct tu_device *device;
|
||||
|
||||
uint32_t msm_queue_id;
|
||||
uint32_t priority;
|
||||
|
||||
int fence; /* timestamp/fence of the last queue submission */
|
||||
};
|
||||
VK_DEFINE_HANDLE_CASTS(tu_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE)
|
||||
|
||||
VkResult
|
||||
tu_queue_init(struct tu_device *device,
|
||||
struct tu_queue *queue,
|
||||
int idx,
|
||||
const VkDeviceQueueCreateInfo *create_info);
|
||||
|
||||
void
|
||||
tu_queue_finish(struct tu_queue *queue);
|
||||
|
||||
#endif
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include "tu_device.h"
|
||||
#include "tu_event.h"
|
||||
#include "tu_image.h"
|
||||
#include "tu_queue.h"
|
||||
#include "tu_query_pool.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue