[FFmpeg-devel] [PATCH 2/3] vulkan: check that the max number of push descriptors is not exceeded
Lynne
dev at lynne.ee
Sun Apr 20 12:03:01 EEST 2025
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
More information about the ffmpeg-devel
mailing list