diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index ebd76667e5f..fdb60337b24 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -580,10 +580,14 @@ anv_get_image_format_features2(const struct anv_physical_device *physical_device assert(aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV); - if (physical_device->video_decode_enabled && - anv_format->can_video) { - flags |= VK_FORMAT_FEATURE_2_VIDEO_DECODE_OUTPUT_BIT_KHR | - VK_FORMAT_FEATURE_2_VIDEO_DECODE_DPB_BIT_KHR; + if (anv_format->can_video) { + flags |= physical_device->video_decode_enabled ? + VK_FORMAT_FEATURE_2_VIDEO_DECODE_OUTPUT_BIT_KHR | + VK_FORMAT_FEATURE_2_VIDEO_DECODE_DPB_BIT_KHR : 0; + + flags |= physical_device->video_encode_enabled ? + VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR | + VK_FORMAT_FEATURE_2_VIDEO_ENCODE_DPB_BIT_KHR : 0; } const struct anv_format_plane plane_format = diff --git a/src/intel/vulkan/anv_physical_device.c b/src/intel/vulkan/anv_physical_device.c index 381e5d289d0..52c8ad73901 100644 --- a/src/intel/vulkan/anv_physical_device.c +++ b/src/intel/vulkan/anv_physical_device.c @@ -165,10 +165,12 @@ get_device_extensions(const struct anv_physical_device *device, .KHR_uniform_buffer_standard_layout = true, .KHR_variable_pointers = true, .KHR_vertex_attribute_divisor = true, - .KHR_video_queue = device->video_decode_enabled, + .KHR_video_queue = device->video_decode_enabled || device->video_encode_enabled, .KHR_video_decode_queue = device->video_decode_enabled, .KHR_video_decode_h264 = VIDEO_CODEC_H264DEC && device->video_decode_enabled, .KHR_video_decode_h265 = VIDEO_CODEC_H265DEC && device->video_decode_enabled, + .KHR_video_encode_queue = device->video_encode_enabled, + .KHR_video_encode_h264 = VIDEO_CODEC_H264ENC && device->video_encode_enabled, .KHR_vulkan_memory_model = true, .KHR_workgroup_memory_explicit_layout = true, .KHR_zero_initialize_workgroup_memory = true, @@ -2141,7 +2143,7 @@ anv_physical_device_init_queue_families(struct anv_physical_device *pdevice) .engine_class = compute_class, }; } - if (v_count > 0 && pdevice->video_decode_enabled) { + if (v_count > 0 && (pdevice->video_decode_enabled || pdevice->video_encode_enabled)) { /* HEVC support on Gfx9 is only available on VCS0. So limit the number of video queues * to the first VCS engine instance. * @@ -2154,7 +2156,8 @@ anv_physical_device_init_queue_families(struct anv_physical_device *pdevice) */ /* TODO: enable protected content on video queue */ pdevice->queue.families[family_count++] = (struct anv_queue_family) { - .queueFlags = VK_QUEUE_VIDEO_DECODE_BIT_KHR, + .queueFlags = (pdevice->video_decode_enabled ? VK_QUEUE_VIDEO_DECODE_BIT_KHR : 0) | + (pdevice->video_encode_enabled ? VK_QUEUE_VIDEO_ENCODE_BIT_KHR : 0), .queueCount = pdevice->info.ver == 9 ? MIN2(1, v_count) : v_count, .engine_class = INTEL_ENGINE_CLASS_VIDEO, }; @@ -2368,6 +2371,7 @@ anv_physical_device_try_create(struct vk_instance *vk_instance, !debug_get_bool_option("ANV_DISABLE_SECONDARY_CMD_BUFFER_CALLS", false); device->video_decode_enabled = debug_get_bool_option("ANV_VIDEO_DECODE", false); + device->video_encode_enabled = debug_get_bool_option("ANV_VIDEO_ENCODE", false); device->uses_ex_bso = device->info.verx10 >= 125; @@ -2614,6 +2618,10 @@ void anv_GetPhysicalDeviceQueueFamilyProperties2( prop->videoCodecOperations = VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR | VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR; } + + if (queue_family->queueFlags & VK_QUEUE_VIDEO_ENCODE_BIT_KHR) { + prop->videoCodecOperations |= VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR; + } break; } default: diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 23a766707ba..58f117cb819 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1005,6 +1005,7 @@ struct anv_physical_device { struct intel_device_info info; bool video_decode_enabled; + bool video_encode_enabled; struct brw_compiler * compiler; struct isl_device isl_dev; @@ -4212,7 +4213,8 @@ static inline bool anv_cmd_buffer_is_video_queue(const struct anv_cmd_buffer *cmd_buffer) { struct anv_queue_family *queue_family = cmd_buffer->queue_family; - return (queue_family->queueFlags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) != 0; + return ((queue_family->queueFlags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) | + (queue_family->queueFlags & VK_QUEUE_VIDEO_ENCODE_BIT_KHR)) != 0; } static inline bool