aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/vulkan.c
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2025-04-20 10:29:17 +0200
committerLynne <dev@lynne.ee>2025-04-22 13:43:19 +0200
commitcee34e0a550eddccdd4984926d519f5cd46a9d55 (patch)
treec8fa04526210347a430b5e1cc6287c0141519aa4 /libavutil/vulkan.c
parent5098b1a34545e8c16787c0a8d2823b1fb0194221 (diff)
downloadffmpeg-cee34e0a550eddccdd4984926d519f5cd46a9d55.tar.gz
vulkan: check that the max number of push descriptors is not exceeded
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.
Diffstat (limited to 'libavutil/vulkan.c')
-rw-r--r--libavutil/vulkan.c15
1 files changed, 10 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++) {