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
148 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV,148 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV,
149 .pNext = &s->hprops,149 .pNext = &s->hprops,
150 };150 };
151 s->push_desc_props = (VkPhysicalDevicePushDescriptorPropertiesKHR) {
152 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES,
153 .pNext = &s->optical_flow_props,
154 };
151 s->coop_matrix_props = (VkPhysicalDeviceCooperativeMatrixPropertiesKHR) {155 s->coop_matrix_props = (VkPhysicalDeviceCooperativeMatrixPropertiesKHR) {
152 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_KHR,156 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_KHR,
153 .pNext = &s->optical_flow_props,157 .pNext = &s->push_desc_props,
154 };158 };
155 s->subgroup_props = (VkPhysicalDeviceSubgroupSizeControlProperties) {159 s->subgroup_props = (VkPhysicalDeviceSubgroupSizeControlProperties) {
156 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES,160 .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
2250 2254
2251 if (!(s->extensions & FF_VK_EXT_DESCRIPTOR_BUFFER)) {2255 if (!(s->extensions & FF_VK_EXT_DESCRIPTOR_BUFFER)) {
2252 int has_singular = 0;2256 int has_singular = 0;
2257 int max_descriptors = 0;
2253 for (int i = 0; i < shd->nb_descriptor_sets; i++) {2258 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)
2255 has_singular = 1;2261 has_singular = 1;
2256 break;
2257 }
2258 }2262 }
2259 shd->use_push = (s->extensions & FF_VK_EXT_PUSH_DESCRIPTOR) &&2263 shd->use_push = (s->extensions & FF_VK_EXT_PUSH_DESCRIPTOR) &&
2264 (max_descriptors <= s->push_desc_props.maxPushDescriptors) &&
2260 (shd->nb_descriptor_sets == 1) &&2265 (shd->nb_descriptor_sets == 1) &&
2261 !has_singular;2266 (has_singular == 0);
2262 }2267 }
2263 2268
2264 for (int i = 0; i < shd->nb_descriptor_sets; i++) {2269 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
285 VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props;285 VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props;
286 VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props;286 VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props;
287 VkPhysicalDeviceCooperativeMatrixPropertiesKHR coop_matrix_props;287 VkPhysicalDeviceCooperativeMatrixPropertiesKHR coop_matrix_props;
288 VkPhysicalDevicePushDescriptorPropertiesKHR push_desc_props;
288 VkPhysicalDeviceOpticalFlowPropertiesNV optical_flow_props;289 VkPhysicalDeviceOpticalFlowPropertiesNV optical_flow_props;
289 VkQueueFamilyQueryResultStatusPropertiesKHR *query_props;290 VkQueueFamilyQueryResultStatusPropertiesKHR *query_props;
290 VkQueueFamilyVideoPropertiesKHR *video_props;291 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