History

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.

Lynne committed 1 year ago

Commit cee34e01 parent 5098b1a2 files · +11 −5Browse files

Unified · Split

2 files
  1. libavutil/vulkan.c +10 −5
  2. libavutil/vulkan.h +1 −0
libavutil/vulkan.c+10−5
@@ -148,9 +148,13 @@ int ff_vk_load_props(FFVulkanContext *s) · 147 unmodified lines
148148 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV,
149149 .pNext = &s->hprops,
150150 };
151+ s->push_desc_props = (VkPhysicalDevicePushDescriptorPropertiesKHR) {
152+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES,
153+ .pNext = &s->optical_flow_props,
154+ };
151155 s->coop_matrix_props = (VkPhysicalDeviceCooperativeMatrixPropertiesKHR) {
152156 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_KHR,
153− .pNext = &s->optical_flow_props,
157+ .pNext = &s->push_desc_props,
154158 };
155159 s->subgroup_props = (VkPhysicalDeviceSubgroupSizeControlProperties) {
156160 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES,
@@ -2250,15 +2254,16 @@ static int init_descriptors(FFVulkanContext *s, FFVulkanShader *shd) · 2093 unmodified lines
22502254
22512255 if (!(s->extensions & FF_VK_EXT_DESCRIPTOR_BUFFER)) {
22522256 int has_singular = 0;
2257+ int max_descriptors = 0;
22532258 for (int i = 0; i < shd->nb_descriptor_sets; i++) {
2254− if (shd->desc_set[i].singular) {
2259+ max_descriptors = FFMAX(max_descriptors, shd->desc_set[i].nb_bindings);
2260+ if (shd->desc_set[i].singular)
22552261 has_singular = 1;
2256− break;
2257− }
22582262 }
22592263 shd->use_push = (s->extensions & FF_VK_EXT_PUSH_DESCRIPTOR) &&
2264+ (max_descriptors <= s->push_desc_props.maxPushDescriptors) &&
22602265 (shd->nb_descriptor_sets == 1) &&
2261− !has_singular;
2266+ (has_singular == 0);
22622267 }
22632268
22642269 for (int i = 0; i < shd->nb_descriptor_sets; i++) {
libavutil/vulkan.h+1−0
@@ -285,6 +285,7 @@ typedef struct FFVulkanContext { · 284 unmodified lines
285285 VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props;
286286 VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props;
287287 VkPhysicalDeviceCooperativeMatrixPropertiesKHR coop_matrix_props;
288+ VkPhysicalDevicePushDescriptorPropertiesKHR push_desc_props;
288289 VkPhysicalDeviceOpticalFlowPropertiesNV optical_flow_props;
289290 VkQueueFamilyQueryResultStatusPropertiesKHR *query_props;
290291 VkQueueFamilyVideoPropertiesKHR *video_props;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t