From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id C89134D7A8
	for <ffmpegdev@gitmailbox.com>; Sun, 20 Apr 2025 09:03:52 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CD799687DA1;
	Sun, 20 Apr 2025 12:03:36 +0300 (EEST)
Received: from vidala.pars.ee (vidala.pars.ee [116.203.72.101])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 53307687D4E
 for <ffmpeg-devel@ffmpeg.org>; Sun, 20 Apr 2025 12:03:12 +0300 (EEST)
DKIM-Signature: v=1; a=rsa-sha256; s=202405r; d=lynne.ee; c=relaxed/relaxed;
 h=Message-ID:Date:Subject:To:From; t=1745139789; bh=8BO47GD6Xzrmf75clUE5Sga
 a9D7559X/+ppN3i40Eps=; b=aJRgvCIJYGM3ZHtLIfO+IPj2irrHVRYqyaPUGeoQF3WG09XKZc
 aWhUcwr6AS3/84NezKFSRaWdyeGhFMUUGYi9akNENb5E7g0QfltNX0bqE+nCbKqQZ+/RDaHHvK9
 FcKsnVyUUFLI9dCf6rIDWwMKWZuzQh/P0UGPuI5+Xp0lTpPM1dAPzHGOcX+JKyg8qjqbkY2vBEW
 j03BEN+o0KMxAiEWkSX2t4T8Fa496oQK3jH0/4xkYMB1M55jvKD5/vU8okiB8lw3TvPxxzcKlM1
 0dSPm8ZX7hMn/dFZY9gBm/vmD9xW9Tqu88zfzxmLH/LxzuG9Tkn3HeR4wRLQ9jRE6DQ==;
DKIM-Signature: v=1; a=ed25519-sha256; s=202405e; d=lynne.ee; c=relaxed/relaxed;
 h=Message-ID:Date:Subject:To:From; t=1745139789; bh=8BO47GD6Xzrmf75clUE5Sga
 a9D7559X/+ppN3i40Eps=; b=R4FALXWA3K1WoNCAWQKbNC+W9xSv4hmoFEnGA4HD4nZhuCC1pv
 s7vKcKgMxsLme332tuF9PLHPQwaKONs7PoCg==;
From: Lynne <dev@lynne.ee>
To: ffmpeg-devel@ffmpeg.org
Date: Sun, 20 Apr 2025 11:03:01 +0200
Message-ID: <20250420090308.11213-2-dev@lynne.ee>
X-Mailer: git-send-email 2.49.0.395.g12beb8f557c
In-Reply-To: <20250420090308.11213-1-dev@lynne.ee>
References: <20250420090308.11213-1-dev@lynne.ee>
MIME-Version: 1.0
Subject: [FFmpeg-devel] [PATCH 2/3] vulkan: check that the max number of
 push descriptors is not exceeded
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Lynne <dev@lynne.ee>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250420090308.11213-2-dev@lynne.ee/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

Just correctness. We don't exceed this on any known hardware, but
its better to check.
If we do, we simply fall back to regular descriptors.
---
 libavutil/vulkan.c | 15 ++++++++++-----
 libavutil/vulkan.h |  1 +
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 8ab977c734..3d155c9933 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -148,9 +148,13 @@ int ff_vk_load_props(FFVulkanContext *s)
         .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV,
         .pNext = &s->hprops,
     };
+    s->push_desc_props = (VkPhysicalDevicePushDescriptorPropertiesKHR) {
+        .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES,
+        .pNext = &s->optical_flow_props,
+    };
     s->coop_matrix_props = (VkPhysicalDeviceCooperativeMatrixPropertiesKHR) {
         .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_KHR,
-        .pNext = &s->optical_flow_props,
+        .pNext = &s->push_desc_props,
     };
     s->subgroup_props = (VkPhysicalDeviceSubgroupSizeControlProperties) {
         .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES,
@@ -2250,15 +2254,16 @@ static int init_descriptors(FFVulkanContext *s, FFVulkanShader *shd)
 
     if (!(s->extensions & FF_VK_EXT_DESCRIPTOR_BUFFER)) {
         int has_singular = 0;
+        int max_descriptors = 0;
         for (int i = 0; i < shd->nb_descriptor_sets; i++) {
-            if (shd->desc_set[i].singular) {
+            max_descriptors = FFMAX(max_descriptors, shd->desc_set[i].nb_bindings);
+            if (shd->desc_set[i].singular)
                 has_singular = 1;
-                break;
-            }
         }
         shd->use_push = (s->extensions & FF_VK_EXT_PUSH_DESCRIPTOR) &&
+                        (max_descriptors <= s->push_desc_props.maxPushDescriptors) &&
                         (shd->nb_descriptor_sets == 1) &&
-                        !has_singular;
+                        (has_singular == 0);
     }
 
     for (int i = 0; i < shd->nb_descriptor_sets; i++) {
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index 49f015ae9d..649a28be27 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -285,6 +285,7 @@ typedef struct FFVulkanContext {
     VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props;
     VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props;
     VkPhysicalDeviceCooperativeMatrixPropertiesKHR coop_matrix_props;
+    VkPhysicalDevicePushDescriptorPropertiesKHR push_desc_props;
     VkPhysicalDeviceOpticalFlowPropertiesNV optical_flow_props;
     VkQueueFamilyQueryResultStatusPropertiesKHR *query_props;
     VkQueueFamilyVideoPropertiesKHR *video_props;
-- 
2.49.0.395.g12beb8f557c
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".