From patchwork Fri Aug 9 14:46:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 50959 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b106:0:b0:489:2eb3:e4c4 with SMTP id o6csp496943vqn; Fri, 9 Aug 2024 08:06:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUE1te3VB3udDBAe5Gr9bRd0EYFO9HssoDzPrAAglqQXgQx/oU+Q8xdRA6T9SZ7h8H7IgO3i0dhw9/khBAqQ0QFCjrzdpGOommdGg== X-Google-Smtp-Source: AGHT+IFYQfjfa3M+RxGsx9IpnUGb1BvuJtNCXLH8kCsIMhrVZpiW6PXa7MaDe1jQ/E3X+XIYUNsq X-Received: by 2002:a17:907:94cc:b0:a77:eb34:3b4b with SMTP id a640c23a62f3a-a80aa53e35dmr117232366b.11.1723215968941; Fri, 09 Aug 2024 08:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723215968; cv=none; d=google.com; s=arc-20160816; b=ddb3eudANimRbQX77TJELMHBrP2bscD33BHzHdCCemrtyMePMtg2RXwYUQoBJcEx9B f+hLQoEOTpK5KJbjepJLj7LNBta2+GSZtfuz396KiP4oSMUByn51vINpQ/AG5rpx8CRh mP7ouS3bm8Y2vqZZOa/RHADqrsCwUZJBl5kPVy3WgvecGdQFg45IjcCHRBfC/6x13mrz vzu/FuxjkdzxVsLp/Y4+A3xSDloGgwSb2UbUqrRAdwaxMc78a7JIyr/Z3p5DcEUal/qE yBT23I4zpnSuZJ+RQC8SQygKvF24hQ+UX8amQQ8tZVAKSgwt6D0T5RvZdu5gYcMwaIG0 ENVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to :delivered-to; bh=XnqpcfwksOFUOqBoaap2jn9oDsjRaGzUOvmnnwjIRyE=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=nNZRfAAPn940nC8ta/S2KGBJcmLwlRIFOPeSp7Z19HYZ7vMw8SMlvY3Nc6iyL8wmsm SOqKs4XE6tVVobKXvWaLOxVTqfOFkSyHD3ZTCkn08d+MecwgDyu05DM5guB+xxMDhYO6 gHGSGw5JHNkKglsjO6EdxXVTAmmCGgiuh+/xC6onheP0autVO0QmX6u7JWuJBCneqmwo DWHjUatBYLvX3DUqUcJWXKyV+kHLxDX2SxZUZ+h3SOVs/xmVcGnaCe49yObQTo6q8IO1 peHBhmsp6z4ksjYRVrv/66ctq6My+EvQFEKXBkG5RD800rglyxtD6iSW3XSqN9x2ddr2 CFpQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a7dc9bd05dcsi933425066b.166.2024.08.09.08.06.08; Fri, 09 Aug 2024 08:06:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6D6AE68DA1F; Fri, 9 Aug 2024 17:47:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A23968D842 for ; Fri, 9 Aug 2024 17:47:11 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Aug 2024 16:46:45 +0200 Message-ID: <20240809144703.1278661-1-dev@lynne.ee> X-Mailer: git-send-email 2.45.2.753.g447d99e1c3b MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] vulkan: add support for encode feedback queries X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: hbr9mjftra40 --- libavutil/vulkan.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 7b45e43a89..13344b7aed 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -281,6 +281,15 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkCommandPoolCreateInfo cqueue_create; VkCommandBufferAllocateInfo cbuf_create; + const VkQueryPoolVideoEncodeFeedbackCreateInfoKHR *ef = NULL; + + if (query_type == VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR) { + ef = ff_vk_find_struct(query_create_pnext, + VK_STRUCTURE_TYPE_QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR); + if (!ef) + return AVERROR(EINVAL); + } + /* Create command pool */ cqueue_create = (VkCommandPoolCreateInfo) { .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, @@ -338,21 +347,18 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, } pool->nb_queries = nb_queries; - pool->query_status_stride = 2; + pool->query_status_stride = 1 + 1; /* One result, one status by default */ pool->query_results = nb_queries; - pool->query_statuses = 0; /* if radv supports it, nb_queries; */ + pool->query_statuses = nb_queries; -#if 0 /* CONFIG_VULKAN_ENCODE */ /* Video encode quieries produce two results per query */ if (query_type == VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR) { - pool->query_status_stride = 3; /* skip,skip,result,skip,skip,result */ - pool->query_results *= 2; - } else -#endif - if (query_type == VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR) { + int nb_results = av_popcount(ef->encodeFeedbackFlags); + pool->query_status_stride = nb_results + 1; + pool->query_results *= nb_results; + } else if (query_type == VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR) { pool->query_status_stride = 1; pool->query_results = 0; - pool->query_statuses = nb_queries; } pool->qd_size = (pool->query_results + pool->query_statuses)*(query_64bit ? 8 : 4); @@ -444,7 +450,7 @@ VkResult ff_vk_exec_get_query(FFVulkanContext *s, FFVkExecContext *e, e->query_idx, pool->nb_queries, pool->qd_size, e->query_data, - pool->query_64bit ? 8 : 4, qf); + pool->qd_size, qf); if (ret != VK_SUCCESS) return ret;