anv: Use Vulkan types for priority as much as possible
Continuing the work to split i915_drm.h specific code. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18942>
This commit is contained in:

committed by
Marge Bot

parent
f5a58b8886
commit
bc384e24f0
@@ -282,9 +282,9 @@ get_device_extensions(const struct anv_physical_device *device,
|
|||||||
.EXT_external_memory_host = true,
|
.EXT_external_memory_host = true,
|
||||||
.EXT_fragment_shader_interlock = true,
|
.EXT_fragment_shader_interlock = true,
|
||||||
.EXT_global_priority = device->max_context_priority >=
|
.EXT_global_priority = device->max_context_priority >=
|
||||||
INTEL_CONTEXT_MEDIUM_PRIORITY,
|
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR,
|
||||||
.EXT_global_priority_query = device->max_context_priority >=
|
.EXT_global_priority_query = device->max_context_priority >=
|
||||||
INTEL_CONTEXT_MEDIUM_PRIORITY,
|
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR,
|
||||||
.EXT_host_query_reset = true,
|
.EXT_host_query_reset = true,
|
||||||
.EXT_image_2d_view_of_3d = true,
|
.EXT_image_2d_view_of_3d = true,
|
||||||
.EXT_image_robustness = true,
|
.EXT_image_robustness = true,
|
||||||
@@ -776,12 +776,13 @@ anv_i915_physical_device_get_parameters(struct anv_physical_device *device)
|
|||||||
device->has_exec_capture = anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_CAPTURE);
|
device->has_exec_capture = anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_CAPTURE);
|
||||||
|
|
||||||
/* Start with medium; sorted low to high */
|
/* Start with medium; sorted low to high */
|
||||||
const int priorities[] = {
|
const VkQueueGlobalPriorityKHR priorities[] = {
|
||||||
INTEL_CONTEXT_MEDIUM_PRIORITY,
|
VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR,
|
||||||
INTEL_CONTEXT_HIGH_PRIORITY,
|
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR,
|
||||||
INTEL_CONTEXT_REALTIME_PRIORITY,
|
VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR,
|
||||||
|
VK_QUEUE_GLOBAL_PRIORITY_REALTIME_KHR,
|
||||||
};
|
};
|
||||||
device->max_context_priority = INT_MIN;
|
device->max_context_priority = VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR;
|
||||||
for (unsigned i = 0; i < ARRAY_SIZE(priorities); i++) {
|
for (unsigned i = 0; i < ARRAY_SIZE(priorities); i++) {
|
||||||
if (!anv_gem_has_context_priority(fd, priorities[i]))
|
if (!anv_gem_has_context_priority(fd, priorities[i]))
|
||||||
break;
|
break;
|
||||||
@@ -2683,23 +2684,6 @@ void anv_GetPhysicalDeviceProperties2(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
vk_priority_to_gen(int priority)
|
|
||||||
{
|
|
||||||
switch (priority) {
|
|
||||||
case VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR:
|
|
||||||
return INTEL_CONTEXT_LOW_PRIORITY;
|
|
||||||
case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR:
|
|
||||||
return INTEL_CONTEXT_MEDIUM_PRIORITY;
|
|
||||||
case VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR:
|
|
||||||
return INTEL_CONTEXT_HIGH_PRIORITY;
|
|
||||||
case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_KHR:
|
|
||||||
return INTEL_CONTEXT_REALTIME_PRIORITY;
|
|
||||||
default:
|
|
||||||
unreachable("Invalid priority");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const VkQueueFamilyProperties
|
static const VkQueueFamilyProperties
|
||||||
anv_queue_family_properties_template = {
|
anv_queue_family_properties_template = {
|
||||||
.timestampValidBits = 36, /* XXX: Real value here */
|
.timestampValidBits = 36, /* XXX: Real value here */
|
||||||
@@ -2738,8 +2722,7 @@ void anv_GetPhysicalDeviceQueueFamilyProperties2(
|
|||||||
|
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
for (unsigned i = 0; i < ARRAY_SIZE(all_priorities); i++) {
|
for (unsigned i = 0; i < ARRAY_SIZE(all_priorities); i++) {
|
||||||
if (vk_priority_to_gen(all_priorities[i]) >
|
if (all_priorities[i] > pdevice->max_context_priority)
|
||||||
pdevice->max_context_priority)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
properties->priorities[count++] = all_priorities[i];
|
properties->priorities[count++] = all_priorities[i];
|
||||||
@@ -3158,10 +3141,10 @@ anv_device_setup_context(struct anv_device *device,
|
|||||||
* have sufficient privileges. In this scenario VK_ERROR_NOT_PERMITTED_KHR
|
* have sufficient privileges. In this scenario VK_ERROR_NOT_PERMITTED_KHR
|
||||||
* is returned.
|
* is returned.
|
||||||
*/
|
*/
|
||||||
if (physical_device->max_context_priority >= INTEL_CONTEXT_MEDIUM_PRIORITY) {
|
if (physical_device->max_context_priority >= VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR) {
|
||||||
int err = anv_gem_set_context_param(device->fd, device->context_id,
|
int err = anv_gem_set_context_param(device->fd, device->context_id,
|
||||||
I915_CONTEXT_PARAM_PRIORITY,
|
I915_CONTEXT_PARAM_PRIORITY,
|
||||||
vk_priority_to_gen(priority));
|
priority);
|
||||||
if (err != 0 && priority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR) {
|
if (err != 0 && priority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR) {
|
||||||
result = vk_error(device, VK_ERROR_NOT_PERMITTED_KHR);
|
result = vk_error(device, VK_ERROR_NOT_PERMITTED_KHR);
|
||||||
goto fail_context;
|
goto fail_context;
|
||||||
|
@@ -296,7 +296,7 @@ anv_gem_get_param(int fd, uint32_t param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
anv_gem_has_context_priority(int fd, int priority)
|
anv_gem_has_context_priority(int fd, VkQueueGlobalPriorityKHR priority)
|
||||||
{
|
{
|
||||||
return !anv_gem_set_context_param(fd, 0, I915_CONTEXT_PARAM_PRIORITY,
|
return !anv_gem_set_context_param(fd, 0, I915_CONTEXT_PARAM_PRIORITY,
|
||||||
priority);
|
priority);
|
||||||
@@ -324,9 +324,29 @@ anv_gem_destroy_context(struct anv_device *device, int context)
|
|||||||
return intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
|
return intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vk_priority_to_i915(VkQueueGlobalPriorityKHR priority)
|
||||||
|
{
|
||||||
|
switch (priority) {
|
||||||
|
case VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR:
|
||||||
|
return INTEL_CONTEXT_LOW_PRIORITY;
|
||||||
|
case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR:
|
||||||
|
return INTEL_CONTEXT_MEDIUM_PRIORITY;
|
||||||
|
case VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR:
|
||||||
|
return INTEL_CONTEXT_HIGH_PRIORITY;
|
||||||
|
case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_KHR:
|
||||||
|
return INTEL_CONTEXT_REALTIME_PRIORITY;
|
||||||
|
default:
|
||||||
|
unreachable("Invalid priority");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
|
anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
|
||||||
{
|
{
|
||||||
|
if (param == I915_CONTEXT_PARAM_PRIORITY)
|
||||||
|
value = vk_priority_to_i915(value);
|
||||||
|
|
||||||
struct drm_i915_gem_context_param p = {
|
struct drm_i915_gem_context_param p = {
|
||||||
.ctx_id = context,
|
.ctx_id = context,
|
||||||
.param = param,
|
.param = param,
|
||||||
|
@@ -143,7 +143,7 @@ anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
anv_gem_has_context_priority(int fd, int priority)
|
anv_gem_has_context_priority(int fd, VkQueueGlobalPriorityKHR priority)
|
||||||
{
|
{
|
||||||
unreachable("Unused");
|
unreachable("Unused");
|
||||||
}
|
}
|
||||||
|
@@ -987,7 +987,7 @@ struct anv_physical_device {
|
|||||||
uint32_t n_perf_query_commands;
|
uint32_t n_perf_query_commands;
|
||||||
bool has_exec_async;
|
bool has_exec_async;
|
||||||
bool has_exec_capture;
|
bool has_exec_capture;
|
||||||
int max_context_priority;
|
VkQueueGlobalPriorityKHR max_context_priority;
|
||||||
bool has_context_isolation;
|
bool has_context_isolation;
|
||||||
bool has_mmap_offset;
|
bool has_mmap_offset;
|
||||||
bool has_userptr_probe;
|
bool has_userptr_probe;
|
||||||
@@ -1361,7 +1361,7 @@ int anv_gem_execbuffer(struct anv_device *device,
|
|||||||
int anv_gem_set_tiling(struct anv_device *device, uint32_t gem_handle,
|
int anv_gem_set_tiling(struct anv_device *device, uint32_t gem_handle,
|
||||||
uint32_t stride, uint32_t tiling);
|
uint32_t stride, uint32_t tiling);
|
||||||
int anv_gem_create_context(struct anv_device *device);
|
int anv_gem_create_context(struct anv_device *device);
|
||||||
bool anv_gem_has_context_priority(int fd, int priority);
|
bool anv_gem_has_context_priority(int fd, VkQueueGlobalPriorityKHR priority);
|
||||||
int anv_gem_destroy_context(struct anv_device *device, int context);
|
int anv_gem_destroy_context(struct anv_device *device, int context);
|
||||||
int anv_gem_set_context_param(int fd, int context, uint32_t param,
|
int anv_gem_set_context_param(int fd, int context, uint32_t param,
|
||||||
uint64_t value);
|
uint64_t value);
|
||||||
|
Reference in New Issue
Block a user